801

(23 replies, posted in General)

DriveSoft wrote:

Check it out

procedure MenuClick1 (Sender: string);
var
    SaveDialog: TSaveDialog;
    sFileName: string;
begin
    sFileName := FormatDateTime('dd-mm-yyyy hh-nn-ss', now)+'.db';

    SaveDialog := TSaveDialog.Create(Form1);
    SaveDialog.FileName := sFileName;
    SaveDialog.Filter := 'Database|*.db|Any file|*.*';

    if SaveDialog.Execute then
    begin
        CopyFile(ExtractFilePath(Application.ExeName)+'sqlite.db', SaveDialog.FileName);
    end;

    SaveDialog.Free;
end;

Hi Dmitry,


Thank you so much.........


The above provides the solution I was looking for.
One thing is missing tho... When overwriting on existing saved file there is no warning dialog such as "Are you sure you want to overwrite xyz.file"
(I thought windows would provide the warning dialog but it doesn't)

802

(23 replies, posted in General)

Hi Mathias,


Thanks for the effort....
Hopefully Dmitry will provide the solution.

803

(23 replies, posted in General)

Thanks a lot Dmitry..........


Save as dialog is showing fine with your script.
However, save/copy function needed.
Also save as file type needed on windows save as dialog. Currently it's empty.


I have tried the following but didn't show save as file type and didn't save/copy db file into selected folder. In any case CopyFile('sqlite.db'); returns error.:

procedure MenuClick1 (Sender: string);

var
    SaveDialog: TSaveDialog;
begin
    SaveDialog := TSaveDialog.Create(Form1);

    if SaveDialog.Execute then
    begin
        CopyFile('sqlite.db');
        ShowMessage( SaveDialog.FileName );
    end;

    SaveDialog.Free;
end;

804

(23 replies, posted in General)

I prefer the solution suggested on the post 1, using menu item and windows save as dialog where user can choose a location and name the copied db file but the following cut-down version may do the job.

I have tried:

procedure MenuClick1 (Sender: string);
var
    buttonSelected : Integer;
begin
    buttonSelected :=MessageDlg('This will Copy Database file in to App Backup folder',mtWarning,mbOK+mbCancel,0);
    if buttonSelected = mrOK then
        begin
            CopyFile('sqlite.db', 'backup/backup '+ FormatDateTime('dd-mm-yyyy hh-nn-ss', now)+'.db');
        end;
end;

However, it didn't create backup folder and copied the db file.


With this version additional script needed to specify maximum backups. For instance if max backup count specified as 5 on the sixth backup oldest backup file gets deleted before copying.


Please see the attached sample project:

805

(23 replies, posted in General)

Hi Derek,


Thanks a lot for the sample...


Yes, it's a very simple solution for private - own projects. However, I'm not sure it can be used for public projects as we wouldn't know which drives users would have in their computer. Copy file could be used in public project if we can have appropriate settings on options window such as boolean to use backup or not, ability to specify backup folder and back up timer which I don't know how to add these settings to options window and make them work.


My thinking was to do it via menu command as it may be simpler approach - even though not proper one but still better than manually locating db file and copying.


Imho, proper way may be is doing via settings on options window as explained above paragraph. Plus created backup file extension would be .backup and ability to open - save backup file within application when needed.

806

(23 replies, posted in General)

As far as I know, backup and restore DB file feature is not implemented in MVD yet.


I added Backup Database menu item on File menu. It would act as a save as... command. Instead of user locating application folder and copies .db file to another location for db backup purposes, they would do it within app via file menu item.

What would be the script for starting windows save as dialog and save db file on selected loaction?


procedure MenuClick1 (Sender: string);
begin
     ......
end;


If the above is doable, can user choose a different db file name or it always has to be sqlite?

807

(2 replies, posted in General)

Thanks a lot Dmitry................

808

(2 replies, posted in General)

Is it possible to use more than one instances of the same event?


For example, Form1_OnShow event is many times associated to different scripts. Trying to fit all different scripts under one Form1_OnShow event is not a straight forward job for me. I like to to keep all script blocks separately so that I can locate them easily.


Can I use multiples of  Form1_OnShow  by naming them Form1_OnShow , Form1_OnShow 2, Form1_OnShow 3 etc and putting then on MVD Object Inspector / Events / OnShow:   Form1_OnShow , Form1_OnShow 2, Form1_OnShow 3 separated with commas or whatever the correct character.


Perhaps there is another way?

809

(8 replies, posted in General)

Thanks a million Dmitry....


It didn't work adding after for to do. It brought back repeating cells values.


However, adding after each '0'; script lines like below worked fine:

SaleTransHist.tgSaleInvTransHist.Cells[11,i] := '0';
SaleTransHist.tgSaleInvTransHist.CalculateFooter;

Once again, thank you so much for your kind help..............

810

(8 replies, posted in General)

DriveSoft wrote:

Try to add 0 values for the cells, like this

SaleTransHist.tgSaleInvTransHist.Cells[12,i] := '0';

Tried... tGrid cells display 0.00 but somehow footer sum calc still includes those repeating cell values (even though they are displayed as 0.00 on tGrid cells) and produces wrong totals.


https://s24.postimg.org/ss49wqvph/zzz_Test3.png

811

(8 replies, posted in General)

Thank you sooooooooo much Dmitry..........


Filtering out repeating cell values works perfectly with the beta you kindly offered.



However,  filtered out cell values still included in footer sum calc, hence showing incorrect footer totals.
Is there solution for this too?

812

(8 replies, posted in General)

Hi Dmitry,


Thanks a lot............


Your script works fine for columns 0, 1, 3 and 4.
Problem seems to be handling currency field type with decimals and thousand separator.  Column 11 and thereafter filtered columns displays currency field types data. It produces error:  " is not a valid floating point value"

procedure SaleTransHist_tgSaleInvTransHist_OnChange (Sender: string);
var
    i,c: integer;
    sPrevRow: string;
begin
    sPrevRow := '';
    c := SaleTransHist.tgSaleInvTransHist.RowCount-1;
    for i := 0 to c do
    begin
        if SaleTransHist.tgSaleInvTransHist.Cells[0,i] = sPrevRow then
        begin
            sPrevRow := SaleTransHist.tgSaleInvTransHist.Cells[0,i];
            SaleTransHist.tgSaleInvTransHist.Cells[0,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[1,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[3,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[4,i] := '';

            // Columns those are not working
            {SaleTransHist.tgSaleInvTransHist.Cells[11,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[12,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[13,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[14,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[15,i] := '';
            SaleTransHist.tgSaleInvTransHist.Cells[16,i] := '';  }
        end else sPrevRow := SaleTransHist.tgSaleInvTransHist.Cells[0,i];

    end;
end;


begin

end.

813

(8 replies, posted in General)

Hi All,


I'm trying to display inv and inv item details on a same tGrid. There are repeating values when an inv have multiple items. How can I hide (filter out) repeating cell values so that I could get correct footer sums and better view. By better view I mean, repeating cell values are not displayed.


https://s29.postimg.org/rvinuimuv/zzz_Test2.png


Please see the SaleTransHist form in the attched sample project

814

(13 replies, posted in General)

Hi Derek,


Thanks a lot...................


That's a great stuff too... Now, we have two nice password options to use.
Once again thank you sooooooooo much guys............................................................

815

(13 replies, posted in General)

Hi EHW,


Thanks a lot...........................


Great stuff... Appreciated.

816

(13 replies, posted in General)

Hi EHW,


Thanks a lot for the revision...


Unless I'm missing something, there is no save button displayed on "frmAddEditPassw" so that I could test the revised version.
However, imho user friendly version would be as illustrated on the images above. It's almost done thanks to Dmitry...



Just needed showing password on  "edExistingPassword" (Existing / Current Password) field and enabling/disabling delete button according to value / no value on  "edExistingPassword"  field.


Here is updated version:

817

(13 replies, posted in General)

DriveSoft wrote:

To delete password, just execute sql query to delete record with password.

SQLExecute('DELETE FROM password WHERE id=1');

Thanks a lot Dmitry.......


I have associated the sql query to a button with warning message and it works fine - deletes the password.


After user adds and saves a password, on next visit to "frmAddEditPassw" I wanted "edExistingPassword" (Existing / Current Password) field to display saved password in alpha numeric characters. I tried the following but didn't work:

procedure frmAddEditPassw_edExistingPassword_OnChange (Sender: string);
begin
    frmAddEditPassw.edExistingPassword.Text := SQLExecute('SELECT password FROM password WHERE id = '+frmAddEditPassw.edExistingPassword.sqlValue);
end;

Delete button responds regardless there is a saved password or not atm. What I like to do but cannot is; if there is no value displayed in field "edExistingPassword" (Existing / Current Password) delete button becomes disabled or alternatively hidden. Please see the images below as a reference.


https://s24.postimg.org/ex0irh579/zzz_Test.png

818

(13 replies, posted in General)

Hi Dmitry,


Thanks a lot.................
Great stuff... Just as I wanted.


However, I realized that I missed one important area,
After setting up a password, user may decide not to use a password. Needs ability to delete set password.
I have added explaining notes on the form.


Please see the attached same sample project with notes

819

(4 replies, posted in General)

DriveSoft wrote:

Check it out

Form1.edPrice.Value := SQLExecute('SELECT price FROM inv WHERE id='+form1.TableGrid1.sqlValue);

Thanks a lot Dmitry.............
It does the job.

820

(13 replies, posted in General)

Hi Derek,


Thanks a lot for the sample.....


I like having user names and passwords table and having ability to create more than 1 user to be created..


However, I need it to run without asking any username and password until user adds 1 or more within the application.

821

(4 replies, posted in General)

Hi Dmitry,


Yes, I still couldn't find an answer.

822

(8 replies, posted in General)

Hi Mathias,


Thanks a lot.............

823

(13 replies, posted in General)

Is there a sample project with password feature in here? I searched the forum but I couldn't find what I was looking for. There is a multi-user version but I like to have single user version using sqlite db.


On first run of the app no password asked. It's up to the user to set a password within app.
Once user sets up a password, on next run password asked. If wrong password entered then dialog message displayed such as wrong password etc.


here is a sample project for applying password feature:

824

(4 replies, posted in General)

Happy New Year to all.............


How can I format currency field with thousand separator and decimals when field value is called from an another form?
For example, I like the field "Price" on form1 display 42,562,314.25 not 4256231425


I tried the following script but didn't work:

// ***** if the user is scrolling through the grid using the keyboard
procedure Form1_TableGrid1_OnKeyUp (Sender: string; var Key: Word; Shift, Alt, Ctrl: boolean);
var
  i,c: integer;

begin
  Form1.edName.Text := SQLExecute('SELECT itemName FROM inv WHERE id='+inttostr(form1.TableGrid1.dbitemid));
  Form1.edPrice.Text := SQLExecute('SELECT price FROM inv WHERE id='+inttostr(form1.TableGrid1.dbitemid));
  //Form1.edPrice.text := FormatFloat('#,##0.00', Form1.edPrice.text);

end;


//***** if the user is scrolling through the grid using the mouse
procedure Form1_TableGrid1_OnCellClick (Sender: string; ACol, ARow: Integer);
var
  i,c: integer;

begin
  Form1.edName.Text := SQLExecute('SELECT itemName FROM inv WHERE id='+inttostr(form1.TableGrid1.dbitemid));
  Form1.edPrice.Text := SQLExecute('SELECT price FROM inv WHERE id='+inttostr(form1.TableGrid1.dbitemid));
  //Form1.edPrice.text := FormatFloat('#,##0.00', Form1.edPrice.text);

end;

Please see the attached sample project.

825

(8 replies, posted in General)

Hi JB,


Thanks a lot for the sample project......


With my sample project, I wanted to use actual menu item names rather than MyItem1, MySubItem1 and so on.
Again, I wanted each menu item performs appropriate onclick action rather than generic ShowMessage.