Hi EHW,


Thank you very much..........................
Truly appreaciated..........................

552

(15 replies, posted in General)

Hi EHW,


I'm truly grateful for your kind help and understanding.....................................
Thank you very much.................................

553

(2 replies, posted in General)

Great stuff Dmitry..........
Thank you very much..........
Truly appreciated.............

I couldn't get fields values showing on another form and displayed on relevant tGrid. Please help...


I wanted;
1. to display sale inv fields values displayed on sale inv refund form so that user have full info about the inv they may be issuing full or partial refund against.
2. show them on sale inv refunds tGrid. (some fields are not showing?)


Edit: I think I have managed displaying fields on another form part (however, not a good solution as it involves duplicating invoice fields on refund table) but not sale inv refund tGrid display. Sample project is updated.


Please see the attached sample project.:

555

(2 replies, posted in General)

Could somebody provide text field based counter script where we can use multiple counters on same table please?


MVD has a counter component but it can only be used 1 instance of it on each table.


Counter script I'm looking for does followings:
- It has prefix and unique count numbers. They can be defined in script as to what prefix letters will be used and at what number it starts counting.
- When a record is deleted, it reverts back to last used number and starts counting from there. i.e If record containing SI-10 count text value is deleted, it will start counting from SI-9, therefore new record number will be SI-10.
- Each counter is independent to each other so that multiple counters can be used on same table.

556

(15 replies, posted in General)

Hi EHW,


I'm about to loosing  face for asking you this many questions. I hope I'm not testing your patience.
I have added your working refunds code with appropriate changes (as I could think of) to this sample project but I'm embraced to say that I couldn't make it work.


Please see attached sample project:

557

(15 replies, posted in General)

Hi EHW,


Thank you very much..............
Truly appreciated....................

558

(15 replies, posted in General)

I realized that populating combobox via DB is not a good idea. When DB is deleted combo items will be deleted too.


I decided to populate combo (Inv Type) within script. However, I couldn't get combo values displayed on tGrid and as a result tGrid filters stop working too ?


Please see the attached sample project below:

Hi EHW,


Thanks to your kind help, I think it works OK now. Hopefully it won't break.


I put on Add Particular button showRecord action and changed the code as follows.

procedure Form1_btnParticulars_OnClick (Sender: string; var Cancel: boolean);
begin
  Form1Button := 'Particulars';
  //Form1.btnEdit.Click;
end;

procedure Form2_OnShow (Sender: string; Action: string);
begin
Form2OnShow01;
Form2OnShow02;
Form2OnShow03;
end;

procedure Form2OnShow01;
begin
   If Form2.dbAction = 'NewRecord' then
   begin
   Form2.GroupBoxParticulars.Enabled:= False;
   Form2.GroupBoxCheckboxCategory.Enabled:= True;
   Form2.GroupBoxDetails.Enabled:= True;
   end;
end;

procedure Form2OnShow02;
begin
   If Form2.dbAction = 'ShowRecord' then
   begin
   Form2.GroupBoxParticulars.Enabled:= False;
   Form2.GroupBoxCheckboxCategory.Enabled:= True;
   Form2.GroupBoxDetails.Enabled:= True;
   end;
end;

procedure Form2OnShow03;
begin
   If (Form2.dbAction = 'ShowRecord') and (Form1Button = 'Particulars') then
   begin
   Form2.GroupBoxParticulars.Enabled:= True;
   Form2.GroupBoxCheckboxCategory.Enabled:= False;
   Form2.GroupBoxDetails.Enabled:= False;
   end;
end;

Thanks a lot EHW.....


One thing that I saw that could be problematic with the checkbox logic is that the "Begin" and "End" statements are missing inside the "IF" statements for each of the checkbox Onclick events. Multiple statements should be inside "Begin" and "End" statements for an "If".


Tried it but issue still remains. I think there is a problem with my implementation of second edit  (Add particulars to selected) button.

561

(187 replies, posted in General)

Hi Dmitry,


If it doesn't require considerably big amount of time, adding a bookmark feature on Script tab page of MVD would help great deal on maintaining script.


Bookmark tab may be added under Object inspector or Structure. Bookmark command could be on right click menu pop-up of the script page. Whichever script line right clicked and selected bookmark command, bookmark added to that line then user types a name for the bookmark on bookmarks tab.


https://s1.postimg.org/6r9xk0dj3/zzzzz_Temp40.png

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


I got it working partially thanks to your kind help.
When added new records, editing etc it seems to be loosing its checkbox logic, more likely I couldn't work out the logic properly or implemented incorrectly. It may look strange on sample project as to why I'm using checkboxes as radio buttons instead of combobox. I need to do something with checkboxes (radiobuttons) as it suits the part of the project better.


There is another issue on doubleclick. If the record selected with mouse click on tGrid (active focus) it seems to be working OK most of the time. However, when double clicked while there is a passive focus on tGrid record (when leaving the form and coming back to it after save etc)  then it looses it's logic to show correct checkbox checked. I added set focus on show to avoid passive focus but didn't help much.

https://s29.postimg.org/ihwhlegnr/zzzzz_Temp39.png


Please see the attached sample project:

Could somebody tell me why the script below is not working please?


procedure Form1_Button1_OnClick (Sender: string; var Cancel: boolean);
begin
  Form2.CheckBox1.Checked := True;
end;

I'm trying to get checkbox on form2 checked, when button1 on form1 clicked. I need to have the button and checkbox on different forms.

564

(15 replies, posted in General)

Thank very much EHW.............................

565

(15 replies, posted in General)

Hi EHW,


Thank you very much............... Truly appreciated........................


I have tried showRecord but getting on click of "Edit" button on purch inv tGrid to combobox displaying Purchase and on click of  "Convert Selected Item to Sale Inv" displayed Sale was the issue. Same issue exist.
Issue is visible after clicking on "Convert Selected Item to Sale Inv" then clicking on "Edit" button which combobox shows Sale instead of Purchase.


I'm thinking that the code below should work but end else bit is not working. I cannot see what I have missed or done incorrectly?

procedure frmInvoice_OnShow (Sender: string; Action: string);
begin
if frmInvoice.edInvProduct.Text = '' then
   begin
   frmInvoice.btnInvSave.Enabled := False;
   end else
   frmInvoice.btnInvSave.Enabled := True;
end;

566

(15 replies, posted in General)

Using one form and table with grid filters and combo value moving record from one grid to another.
Kind of converting purchase inv to sale inv.


Please see the image below for reference:
https://s15.postimg.org/usl1kmt63/zzzzz_Temp38.png


Used "Convert Selected Item to Sale Inv" button with showRecord action as I need the purchase inv data on frmInvoice.
Used Inv Type combobox on frmInvoice as tGrid filters uses combobox values for displaying the record on relevant tGrid on form1. Inv Type combobox is disabled so that user cannot choose a wrong value.


I need Inv Type combobox displays Sale text instead of Purchase if button "Convert Selected Item to Sale Inv" clicked, in order to move the item to sale invs tGrid on save.
I tried in code various things I could think of but unfortunately couldn't get it working.


Please see the attached sample project below:

567

(10 replies, posted in General)

Hi EHW,

Adam, I had a little bit of time to look at your project and make modifications to incorporate refunds. I think I have all your basis covered...


Indeed it does.........
Thank you very much......... Truly appreciated.................
Extra thank you for re-arranging the code and comments.........
You are very kind person.....

568

(10 replies, posted in General)

Hi EHW,


Managing stock levels is very tricky indeed. I have tried to add refunds to "Stock Level" sample project that you kindly coded but failed miserably.


I have added DBCR table and relevant fields to sale and purchase invoices without all the checks as priority was getting quantities working when product/s returned. There are few things needs to be taken into account:
-- Not all refunds may be full, there will be partial refunds.
-- Purchase refunds subs qty from product current stock level.
-- Sale refunds adds back qty to product current stock level but not all sale refund qty added back to current stock level;
----- Customer may return faulty product which are not added back to current stock level.
----- Customer may ask money back due to not receiving products  which are not added back to current stock level.
For these kind of situations, I have added new field to sale inv where user can enter qty to be added back to current stock level. Therefore refund qty and qty added back to current stock level may be two different values.
edit: Partial refunds would apply to purchase invoice refunds too. I missed adding extra field on form purch inv. There again, additional fields on sale an purch invs may not be needed.


There seems to be issue with "Add New Product" button on both sale and purchase invs when clicked on Add sale/purch invs buttons on Form1.
Issue seems to be caused by checks on Save buttons on both sale/purch inv forms. I have commented out product selected from combo check as I have checked not null on tables. I may be totally wrong here.


I know you have limited time and to date you have been very kind on helping. Please don't feel any pressure or whatsoever. If and when you have a free time your help on this matter of completing stock levels project with refunds would be greatly appreciated as always.


I have attached sample project file.

569

(10 replies, posted in General)

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


Renamed variables except Qty as I couldn't recognize clearly which ones refers to var and which ones to field name. No worries, it's OK.


I wanted to add another condition to sale inv, where sale qty value entered bigger than products' current stock qty value, when adding a new sale inv with the following but didn't work. Getting minus stock qty on products.

If (frmSaleInv.cbSaleInvProduct.sqlValue = frmSaleInv.SaleInvInitProd.Text) and (frmSaleInv.dbAction = 'NewRecord') then
     Begin
        If CurrQtyVAR - Qty <= 0 then
          Begin
            MessageBox('This sale qty value will cause the stock level to go below zero.','Error',MB_OK+MB_ICONERROR);
            frmSaleInv.edSaleInvQty.SetFocus;
            Cancel := True;
            Exit;
          End;
     End;

570

(10 replies, posted in General)

Hi EHW,


Excellent logic and coding as usual !
Thank you very much...................
Truly appreciated............................


Maintaining proper stock levels in coding seems to be a tricky business... at least for me. I'm in the process of reading and digesting your code at present. I see that I have to get a proper grasp of using variables.

Good spotting and thank you very much for the fix too.
I'll try to implement credit and debit invoices to achieve further stock level integrity, if I can.


In order to make code reading easy and minimize mistakes I try to use idiot proof (that's me) naming convention. i.e. Instead of  'Adj_Qty' I use 'AdjQtyVAR'  This way I don't mix it with events (as _ is used in them by default) and I can see them their own variables, buttons and field names. It's nothing to do with your style, it's just shortcoming on my side.
During renaming variables, changing  var Init_Qty to InitialQtyVAR returns "Undeclared identifier" around //...(frmSaleInv.InitialQtyVAR.Text);//  After changing it to back Init_Qty it works. All other var renaming worked fine. I tried to find if anywhere else it's referenced beside script tab page but couldn't find. I replaced them using find and replace.

571

(10 replies, posted in General)

Looks like Dmitry run out support time for the day or questions weren't specific enough. However, If anybody else can and willing to do so, please do.


Her is another try:
With the image below I tried to highlight issues I couldn't resolve:

https://s30.postimg.org/ss6yc9djl/zzzzz_Temp37.png


On frmProduct I have read only Qty in Stock filed. It's calculated value based on purchase and sale invoices tGrids Qty column footer values.

procedure CalculateTotal; //
begin
  frmProduct.edProdQtyInStock.Value := frmProduct.tgProdPurchInv.Columns[3].Footer.FormulaValue - frmProduct.tgProdSaleInv.Columns[4].Footer.FormulaValue;
end;


procedure frmProduct_tgProdPurchInv_OnChange (Sender: string);
begin
  CalculateTotal;
end;

procedure frmProduct_tgProdSaleInv_OnChange (Sender: string);
begin
  CalculateTotal;
end;

ISSUE 1
On Form1 / PageControl1- products tab / tgMainProducts/  Qty in Stock column doesn't display calculated field value of frmProduct / Qty in Stock . I have tried dbUpdate but couldn't get it working:

procedure frmPurchInv_Button1_OnAfterClick (Sender: string);
begin
  Form1.tgMainProducts.dbUpdate;
  Form1.tgMainPurchInv.dbUpdate;
  frmProduct.tgProdPurchInv.dbUpdate;
end;

procedure frmSaleInv_Button1_OnAfterClick (Sender: string);
begin
  Form1.tgMainProducts.dbUpdate;
  Form1.tgMainSaleInv.dbUpdate;
  frmProduct.tgProdSaleInv.dbUpdate;
end;

ISSUE 2
I wanted to display Qty in Stock value from frmProduct inCurrent Stock Level fields on Sale and Purchase Invoice forms  according combo item and couldn't:

procedure frmPurchInv_cbPurchInvProduct_OnChange (Sender: string);
begin
  frmPurchInv.edPurchInvStockLevel.value := SQLExecute('SELECT qty FROM Product WHERE id='+frmPurchInv.cbPurchInvProduct.sqlValue);
end;
...

ISSUE 3
This one (hiding items on a form onShow) should have been easy. But one item hiding worked OK while second one not?

procedure frmProduct_OnShow (Sender: string; Action: string);
begin
if frmProduct.edProductName.text = '' then
   begin
   frmProduct.PanInvoices.Visible := False; // Worked OK
   frmProduct.panProdQty.Visible := False; // No idea as to why this one is not working?
   end else
   frmProduct.PanInvoices.Visible := True;
   frmProduct.panProdQty.Visible := True;
end;

Updated sample project attached.

572

(10 replies, posted in General)

I thought this was a piece of cake but it turned out to be pie in the sky.


Based on purchases and sales I wanted to update product inventory quantities.
There is two issues I couldn't solve:
1. Updating form1 / PageControl1- products tab / tgMainProducts/  Qty in Stock column.
2. Getting current quantity value on purchInv and SaleInv forms using product combo onChange.


Please see the attached sample project:

573

(6 replies, posted in General)

Hi EHW,


Maybe the attached is what you want...

It's better than what I wanted... Admirable logic and coding skills you have...


Thank you very much................ Truly appreciated................

574

(4 replies, posted in General)

Hi Dmitry,


Thank you very much......
Truly appreciated............

575

(4 replies, posted in General)

Hi Derek,


Nice and neat solution... Thank you very much...... Truly appreciated......


Perhaps Dmitry can offer full script version within MVD only, just to have an alternative.