USER =   Application.User.First_Name + ' '+ Application.User.Last_Name; OR  application.User.UserName


ROLE = Application.User.Role; 


Admin = Application.User.is_admin;


Active = Application.User.is_active;


Last Login = Application.User.Last_login;


User Creation = Application.User.Date_joined;



For completeness........  //Для полноты ........

Application.User.id;
Application.User.Email; 
Application.User.RoleId;
Application.User.is_logged;


I don't understand, what Delete button?  //Я не понимаю, что такое кнопка Удалить?

152

(1 replies, posted in General)

That's very useful, thank you agusec.

153

(9 replies, posted in Script)

I can offer you this, the rows change colour depending on criteria - basically just another way of doing what JB has written above.   If your code can use a SELECT statement you'd be able to make the code below more compact.


procedure frmMain_tgOrders_OnChange (Sender: TObject);
CONST
    DATE_ORD = 5; DATE_PO = 7; DATE_REQ = 8; ORD_QTY = 9; ORDER_REC = 10; DUE = 11;
var
row, column, rowcnt, colcnt: integer;
begin

   rowcnt := frmMain.tgOrders.RowCount -1;
   colcnt := frmMain.tgOrders.Columns.Count -1;

   for row := 0 to rowcnt do
   begin
       if frmMain.tgOrders.Cells[DUE,row] = '0' then     //Complete order received colour red/pink
       begin
           for column := 0 to colcnt do
           begin
               frmMain.tgOrders.Cell[column,row].Color := $00BDA8FD;
           end;
      end
      else
    
      {Part order received   colour Blue}
          if (frmMain.tgOrders.Cells[DUE,row] < frmMain.tgOrders.Cells[ORD_QTY,row])    then     //Complete order recieved
           begin
               for column := 0 to colcnt do
               begin                                       //light blue
                   frmMain.tgOrders.Cell[column,row].Color :=$00FFFFA8; // interesting brown $0065AACD;
               end;
          end     
      else
     

        {Quote pending colour green}
          if (frmMain.tgOrders.Cells[DATE_REQ,row] <> '') AND (frmMain.tgOrders.Cells[DATE_PO,row] ='') then
           begin
               for column := 0 to colcnt do
               begin                                          //light green
                   frmMain.tgOrders.Cell[column,row].Color := $00B4F2B6;
               end;
          end    
      else   

    {To be ordered colour yellow}
    if  ((frmMain.tgOrders.Cells[DATE_ORD,row] = '')AND (frmMain.tgOrders.Cells[DATE_PO,row] ='') AND (frmMain.tgOrders.Cells[DATE_REQ,row]= '')) then
       begin
           for column := 0 to colcnt do
           begin                                          //light yellow
               frmMain.tgOrders.Cell[column,row].Color := $0080FFFF;
           end;
      end;

   end;
 
end;

Just a personal view, but I think it would be more useful if the User login time was inserted on form.destroy rather than form.create or another column Last_Logged_Out was created.

My reasoning is that if someone needs to know or display the last time the user logged in, it could be argued that that would be the last time they used the program which of course would be derived perhaps from a logged out time.

Currently the way the table is set up it works if it was needed to create a list of users currently logged in, but not if you want to know the last time a user used the system.

Another column Last_Logged_Out would give the developer more options to choose from.

155

(8 replies, posted in General)

Frank,


In the object inspector there is a property called  'DefaultIndex'  it will by default be set at 0, Set it to the index number that your USA entry is at and your problem is solved.

156

(4 replies, posted in General)

v_pozidis,


I assume that Dmitri uses the EncryptRC6 function to encrypt the password. If he does, you would need to know the 'key' used, otherwise you would not be able to decrypt it.

If you want to be able to retrieve a password  you would have to design your own form so that you can select the encryption key.

157

(4 replies, posted in General)

v_pozidis,


I don't have complete code to show you, but so long as you have filled out the email address for each user, you could add a button or clickable link to the logon form to retrieve and send the password.


To add a button, textbox or clickable link to the form the following code needs to be placed between the default 'begin....end' that is automatically placed in the script.


begin

   btnForgotPass := TButton.Create(frmdbCoreLogin); //Change to label or edit text etc if using a label or text edit
   btnForgotPass.Left := 113;  // change these to position your button etc 
   btnForgotPass.Top := 170;  // These positions are for a label that appears under the picture image on the login form
   btnForgotPass.Width := 300;
   btnForgotPass.Height:= 15;
   btnForgotPass.Margins.Top :=10;
   btnForgotPass.Margins.Bottom := 10;
   btnForgotPass.Parent := frmdbCoreLogin;
   btnForgotPass.Wordwrap := true;
   btnForgotPass.Caption := 'Forgot Password';
   btnForgotPass.Visible := True;

   frmdbCoreLogin.Caption := 'Your form title here if you wish'  
   {code above has been tested}

   {code below HAS NOT been tested}
   btnForgotPass.OnClick := @ForgotPassWord; 

    

   code for button click  - you will need to make your own form ( for example password_retrieve) with either a user name or an email entry text edit.


NOT TESTED

procedure ForGotPassWordOnClick
begin
     SQL code to retrieve and match either user name or email address. Or use a table grid and a search button to save writing SQL statements.
 
    
   frmdbCoreLogin.mniChangePassword.click; // this calls the built in password change form
 //however this form requires the current password to be entered. So code below is better
   frmForGotPassword.Show;
end;

On the ForGotPassword form show users name and have two textbox to enter the new password and a save button that saves to the  _user table and the password field.


I've just realised you might be able to change frmdbCoreLogin.mniChangePassword.click to frmdbCoreUserChangePwd.Show or .click

158

(0 replies, posted in General)

I have used Dmitri's sample code to encrypt my SQLite database.  It worked twice until I experimented with the code and now does not work at all in as much as the database is never decrypted.

The code

function OnSQLException(sender: TObject; Msg: string; SQL: string): boolean;
 begin
     if Pos('file is encrypted or is not a database', Msg)>0 then
     begin
         result := True;
         frmMain.SQLConnection.Connected := False;
         DecryptFileRC5('test.db', encDB);
     end;
 end;

EncDB is a constant with the decryption key.

What I did was just once change    result := True;   to False   just to check the error message was correct.

Changing it back to True now makes no difference the database displays the 'file is encrypted or is not a database' error form and then displays  some internal error messages that _roles and _users cannot be accessed and that there is already a user called admin (which of course is correct).


Next the login form is displayed which now fails as that  shows in plain text admin/admin and the password box displays everything in plain text

I have tried deleting the function for both decryption and in the form.onclose event changing the encryption code to the Decryption code  that does not work either.


I'm stumped as to what is wrong in the code.  I've checked through the DCU and form.xml files and can see nothing that is not being changed when the code is altered.


I wonder if the problem is caused by behind the scenes login code.


Any thoughts would be gratefully received.

I think you should also post this in the English language section also - many new browsers can now 'auto translate' web pages.  Bravo and Maxthon browsers do.


Я думаю, вам также следует разместить это в разделе на английском языке - многие новые браузеры теперь могут «автоматически переводить» веб-страницы. Браузеры Bravo и Maxthon это делают.


'Google translate'

160

(2 replies, posted in General)

I'm just thinking aloud here.

I wonder if it could be possible if you included a PowerShell or perhaps a BAT script that actually started your MVD program.

The script could either retrieve the current drive path and then insert it into the VDB settings.ini or much easier force the PC to see the inserted drive as a fixed letter.


That does of course have problems because you could never be sure what drive letters your users were using. I for example have Z,Y,H,I, and F as partitions on my drives.

161

(9 replies, posted in General)

You could also try this.

{function to allow selected comboboxes to have new data added to them directly}

function add2CategoryBox (Sender: String;  indx: Integer): Integer;
begin
   if (indx = -1)  AND (Sender <> '') then
       begin
         SQLExecute('INSERT INTO table_name (field) VALUES ("'+Sender+'")');
         UpdateDatabase('table_name');
         Result := Last_Insert_id;
         showmessage('Categories updated with '+Sender )
      end
      else begin
       Result := indx;
   end;


end;

Example calling code: Substitute your form and combox names.

frmEditPart.cmbEditCategory.dbItemID := add2CategoryBox(frmEditPart.cmbEditCategory.text, frmEditPart.cmbEditCategory.dbItemID)

162

(12 replies, posted in General)

Frank,

If you look at each component you have on your form you will see they all have a TAB property.

This is where you set the tab order yourself instead of leaving it to MVD to allocate.

One way around this is to place the components on the form in the order you want them - however, who knows exactly their layout until the end?

The first tab item will be 1 and each tab item will increment. Just change the numbers to the order you want.

Just for extra information, if you don't want an item to react to a tab just untick the TabStop property.

163

(0 replies, posted in General)

I've hijacked the login form to place my own image and text.  The code below works.

begin
  
  CentreForm(frmMain);

  lbAcknowledge := TLabel.Create(frmdbCoreLogin);
  lbAcknowledge.Left := 113;
  lbAcknowledge.Top := 170;
  lbAcknowledge.Width := 300;
  lbAcknowledge.Height:= 15;
  lbAcknowledge.Parent := frmdbCoreLogin;
  lbAcknowledge.Wordwrap := true;
  lbAcknowledge.Caption := 'image copyright free from unsplash.com/photos/jXd2FSvcRr8';
  lbAcknowledge.Visible := True;

  frmdbCoreLogin.Caption := 'Workshop Parts Login';

   {logo is copyright free from  https://unsplash.com/photos/jXd2FSvcRr8 }
 frmdbCoreLogin.Image1.Picture.loadfromfile((ExtractFilePath(Application.ExeName)+ 'WOS_login.jpg'));

end.

However with screens that have a different resolution the label moves too far from the logo and becomes obscured by the User log in box.


I have tried to use anchors, but I get errors as follows.


lbAcknowledge.Anchors := [akTop, akLeft, akRight];

I get an error "Initialization section......... Could not convert variant into an integer".


If I try

lbAcknowledge.Anchors := [TAnchors.akLeft, TAnchors.akTop];

My error becomes "cannot form an array".


Any thoughts out there on how to set anchors in the 'initialization' section of the script?

164

(5 replies, posted in General)

Have you saved the document into the database or just saved a link to a file in the database?

165

(9 replies, posted in General)

I have read that the  Delphi 'scale by' function works better if percentage scaling is used.

You could try - finding the users screen size as shown in the code snippets above and then using the scale by function increase or decrease the form size. Using your screen resolution as the default screen size.


So you would create two constants that hold your screen size - defaultScreenWidth and defaultScreenHeight and then use those to find the difference as presented by  - screen.width and screen.height (these will always be the users screen size figures).  From the result you can use the percentage figure ScaleBy(Screen.Width,percentage).

166

(9 replies, posted in General)

Papafrank,

The answer probably depends on the screen size that each developer is using.


I have two 22" widescreen monitors which are 1920 x 1080  and a scale magnification of 125%.


My current project has a Main Form size of  1500 x 770 and a Constraint of MinHeight 452. Now this works fine on monitors with a scale of 100 or 125%  it gets the problem you are having if the monitor is 19" and has a magnification of 175%.


This is on PCs running Windows 10.

167

(9 replies, posted in General)

Papafrank,


The divide by 2 centres the form it doesn't halve the form.

I don't have a different screen size to test this out on. I think we will get there with a combination of centering the form and using maximum size constraints in the object inspector.

It might help to have the following temporary debug code in the Form1_OnShow event.

showmessage('screen width = '+ intToStr(screen.width) + ' screen height = ' + intToStr(screen.height));

This will report your screen size - this is just to ensure Windows and VDB are seeing the same thing.

From here there are some other things you can try.

1. Move the screen sizing code from the On_Show event to the begin....end that by default has the 'Hello World' call in it.

2. Some code that didn't work for me when I was trying to get monitors with different magnifications to work, but it might work for you.

procedure ScaleForm  (F: TForm; ScreenWidth, ScreenHeight: LongInt) ;
begin
 F.Scaled := True;
 F.AutoScroll := False;
 F.Position := poDefaultPosOnly; //poScreenCenter;
 F.Font.Name := 'Arial';
 if (Screen.Width <> ScreenWidth) then
 begin
     F.Height :=  (F.Height * Screen.Height) div ScreenHeight;
     F.Width :=  (F.Width * Screen.Width) div ScreenWidth;
     F.ScaleBy(Screen.Width,ScreenWidth) ;
 end;
end;

Called by:

begin
  ScaleForm(frmMain,1920,1080) ; //OR   ScaleForm(frmMain,screen.width,screen.height) 
end.

The code immediately above is again  using the default begin...end that the script file will have.

3. Another option might be (based on code by Tony Bryer  SDA UK  on DelphiGroups)

procedure CentreForm(Form: TForm);
begin
    with Form do
    begin
        Left := Application.Form1.Left + (Application.Form1.Width - Width) div 2;
        if Left < 0 then Left:=0;
        Top := Application.Form1.Top + (Application.Form1.Height - Height) div 2;
        if Top <0 then Top:=0;
   end;
end;

Called by:

begin
   //ScaleForm(Form1 , Screen.Width, Screen.Height) ;
   CentreForm(Form1); //substitute the name of your main form here
end.

dhekabai,

If you have some kind of loop in the double click event you may have counted the records incorrectly.

Could you post your code for this event? That would help us to point you in the right direction.

Generally speaking if you have counted how many records are in your table, you need to have a max_count of record_ count - 1.

169

(2 replies, posted in General)

When you create a topic, there is a tick box at the bottom of the form just above the add a file button that can be ticked to receive notifications.

It only works on topics you have started,  it does not track topics where you have only replied to someone elses topic.


There is a way to subscribe to your replies - and that is to always click on QUOTE to reply, that will allow you subscribe to a topic you haven't started but replied to.

170

(5 replies, posted in General)

papafrank,

Did you just copy and paste my example or did you double click on your main forms' resize event and then enter the code?

I think you ought to move the code to the forms ON SHOW event, rather than the resize one.

171

(7 replies, posted in Russian)

I meant the contents of your SQLExecute statement in the script file.

For example here is a MySQL statement for v8.0.20


CREATE TABLE `backups` (
  `id` tinyint DEFAULT NULL,
  `dateBackup` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

172

(5 replies, posted in General)

You can check for screen.width and screen.height.


I have found though that this fails if someone uses a high magnification in Windows 10 such as 150%. This would appear to be a combination of Windows  and the early version of Delphi used  behind MVD.


You could try in conjunction with the constraints property of a form and components:

procedure frmMain_OnResize (Sender: TObject);

begin

  frmMain.Left := (screen.width - frmMain.width) div 2;
  frmMain.Top := (screen.height - frmMain.Height) div 2;

end;

I should mention that the above code centres the form in the middle of the screen

173

(7 replies, posted in Russian)

Не могли бы вы опубликовать SQL, который вы используете для создания таблиц, это может помочь вам понять, в чем проблема? Также может пригодиться версия MariaDB, которую вы используете.



Could you please post the SQL you are using to create the tables, this might help you understand what is the problem? The version of MariaDB you are using can also come in handy.

Could you upload your project or perhaps post a screenshot of the form?


Не могли бы вы загрузить свой проект или, возможно, опубликовать скриншот формы?


перевод от Гугла

175

(16 replies, posted in Script)

Updated script.