476

(9 replies, posted in General)

Hi EHW,


Thank you very much for the magic filter.................
I also like to thank you for fixing the issue after deleting sale invoice, which I have failed to take into account................
Truly appreciated.......................................

477

(9 replies, posted in General)

Perhaps I couldn't explain the issue clearly on my post above that I wasn't able to solve. Here is another attempt with illustrations.....


https://s26.postimg.org/rbhqnnmnd/zzzzz_Temp54.png


https://s26.postimg.org/m1crwd2eh/zzzzz_Temp55.png


https://s26.postimg.org/xual0kyuh/zzzzz_Temp56.png


Could somebody help please...

478

(9 replies, posted in General)

Thanks to EHW's and Derek's kind help, I could do somethings with one and two table version of the sample project attached.


Now I'm trying 4 tables and 4 forms version. I could take it as far as moving purchase inv to sale inv tGrid. Currently, I can save sale invoice but cannot move the sold purchase item to sale inv tGrid.  I may be totally wrong but I'm guessing tGrid filters doesn't work in their current definitions because purchase and sale inv have their own tables. My one cell brain couldn't come up with a solution.
Reason for moving purchase inv item from purchase inv tGrid to sale inv tGrid is that the approach is based on single product items and using purchase tGrid as inventory same time.


Please see the attached sample project below:

479

(7 replies, posted in General)

Hi Derek,


Thank you very much.........
As always your simple solutions truly appreciated...........


I guess I'm one of those trying to do everything with code. However, I agree that if there is a simpler solution rather than coding I should use it where appropriate rather than trying to code it.
I'm glad we have you around Derek.


I added Dmitry's ordering filter to yours to order available combo items by lastname:

unavaiable = 0 and 1=1 ORDER BY lastname

480

(7 replies, posted in General)

Thanks for the sample Dmitry..............


Is it possible to hide Unavailable person not displayed on combo dropdown?
I tried the following but couldn't get the script right.

procedure Form1_ComboBox2_OnDropDown (Sender: string);
begin
If Form1.ComboBox2.Text = '(Unavailable)' then
   begin
   Form1.ComboBox2.DBItemID.Visible := False;
   end;
end;

481

(4 replies, posted in General)

In that case I can only hope that one day you'll have a time to offer a sample project for resizing components on a form for MVD user...........


Perhaps, in the meantime if somebody else have the time and knowledge to offer a solution would be great.

482

(4 replies, posted in General)

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


Could you provide some sample script using the sample project on my post #1 please...

483

(1 replies, posted in General)

I have two comboboxes on same form and same table. One for customers and other for supplier.
Supplier combo shows when issuing a purchase invoice
Customers combo shows when issuing a sale invoice


I wanted make them required field by adding not null on table fields. However, when issuing and inv (i.e. purchase invoice) it asks both combo boxes to be filled even tho one of them not visible.
Is there solution for this please?


Please see the attached sample project:


============================================
EDIT:
After hitting my head few times on the wall I came up with a workaround.
Since both combos are on the same form and when issuing purchase invoice customer details combo is not needed (hidden) and when issuing sale invoice supplier details combo hidden.
I marked supplier combo only as not null and added following code for the sales invoice in order to prevent saving the sale invoice without selecting a customer from customer combo using message box:

procedure frmInvoice_btnInvSave_OnClick (Sender: string; var Cancel: boolean);
begin
  if (frmInvoice.edDBCR.Text = 'Sale') and (frmInvoice.cbSIcustName.dbItemID = -1) Then
  begin
  Cancel := true;
  MessageDlg ('Customer detail fields are required.',mtInformation,MB_OK,0);
  frmInvoice.cbSIcustName.SetFocus
  end;
end;

It seems to be working but I'm not sure if this is the proper way to do it?


Please note that attached sample project is not updated with the above code.

484

(4 replies, posted in General)

I couldn't achieve window and it's component sizing as I wanted using Anchors.

I wanted do the following:
https://s26.postimg.org/6u5a4h5ux/zzzzz_Temp52.png
I wanted all tGrids and fields resizing horizontally and vertically without overlapping.


Maximum I could do with anchor property is the following:
https://s26.postimg.org/qnlzax8mh/zzzzz_Temp53.png


Am I missing something?


Please see the attached sample project:

485

(4 replies, posted in General)

I thought, I tried that... Looks like I missed something.


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

486

(4 replies, posted in General)

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


I added it in button's SQL Query as follows but it didn't work?

Select 'PI-' || Invoice.Counter3,'Db-' || Refund.Counter4,Refund.DBCRvalue,
    Refund.PIRdate,Supplier.name,Invoice.product,
    strftime('%d/%m/%Y', Refund.PIRdate),
    TaxRates.TaxRate,printf('%.2f',Invoice.PIprice),printf('%.2f',Refund.PIRprice),
    Refund.Id
 From Refund 
 Left Outer Join Invoice On Invoice.Id = Refund.id_Invoice 
 Left Outer Join Supplier On Supplier.Id = Refund.id_Supplier
 Left Outer Join TaxRates On TaxRates.Id = (Select TaxRates.Id From TaxRAtes
     Where TaxRates.Id = Invoice.id_TaxRates)
 Where Refund.DBCRValue = 'Db'

487

(4 replies, posted in General)

I have a button to populate tGrid via SQL Query (Populating tGrid via search wasn't satisfactory so SQL Query used instead).


The following script is written by EHW. I only added date bit.

Select 'PI-' || Invoice.Counter3,'Db-' || Refund.Counter4,Refund.DBCRvalue,
    Refund.PIRdate,Supplier.name,Invoice.product,
    TaxRates.TaxRate,printf('%.2f',Invoice.PIprice),printf('%.2f',Refund.PIRprice),
    Refund.Id
 From Refund 
 Left Outer Join Invoice On Invoice.Id = Refund.id_Invoice 
 Left Outer Join Supplier On Supplier.Id = Refund.id_Supplier
 Left Outer Join TaxRates On TaxRates.Id = (Select TaxRates.Id From TaxRAtes
     Where TaxRates.Id = Invoice.id_TaxRates)
 Where Refund.DBCRValue = 'Db'  

All good but I couldn't get date displayed correctly. "PIR Date" field (Date field to be displayed on tGrid under "Date" column, set as Date only not including time. I guess when SQL used it gets row data which includes date and time ( I remember Dmitry saying something like this about display format of values of currency fields on tGrid when calc fields used etc.)
https://s26.postimg.org/690h3cbjd/zzzzz_Temp51.png


How can I get date on tGrid displayed without the time while using SQL script above in a same format as in my PC date time settings?
On the image above "PIR Date" field date format (DD-MM-YYYY) matches to my PC date and time settings, but tGrid date is not .

488

(6 replies, posted in General)

Could it be that  sqlite.db file moved somewhere else for backup db purposes instead of copying?
If there is no sqlite.db in app directory, MVD will create a blank sqlite.db file on app run.
Just a wild guess as it happened to me once few months back.


As far as I know MVD doesn't allow creation of custom named db file. It'll always be sqlite.db. Only differentiation is file creation date and time.

489

(1 replies, posted in General)

Is it possible disable windows print screen capture and other screen capture apps capturing MVD application screens?

490

(34 replies, posted in General)

... I think I would have used the variables though. It's a whole lot less typing. But that's just a personal preference.


Indeed, it's a better way.
Thank you very much...........
Truly appreciated..................

491

(34 replies, posted in General)

Hi EHW,


Great stuff... I like the idea of using labels for supplier details instead of field/s.
Thank you very much..... Truly appreciated...............


I agree, in this project, using supplier fields on invoice form since they are already there instead of retrieving them again using SQLExecute as you have suggested. Thank you for SQLExecute script which will be useful for me in future projects.


Without SQLExecute with labels I have tried the following which seems to be working OK

frmInvoice.lblSuppName.Caption := frmInvoice.cbPIsuppName.Text;
  frmInvoice.lblSuppStreet.Caption := frmInvoice.edPIsuppStreet.Text;
  frmInvoice.lblSuppCity.Caption := frmInvoice.edPIsuppCity.Text;
  frmInvoice.lblSuppState.Caption := frmInvoice.edPIsuppState.Text;
  frmInvoice.lblSuppZip.Caption := frmInvoice.edPIsuppZip.Text;
  frmInvoice.lblSuppCountry.Caption := frmInvoice.cbPIsuppCountry.Text;

  If frmInvoice.lblSuppZip.Caption = '' then
    Begin
      frmInvoice.lblSuppZip.Caption := frmInvoice.lblSuppCountry.Caption;
      frmInvoice.lblSuppCountry.Caption := '';
    End;

  If frmInvoice.lblSuppState.Caption = '' then
     Begin
       frmInvoice.lblSuppState.Caption := frmInvoice.lblSuppZip.Caption;
       frmInvoice.lblSuppZip.Caption := frmInvoice.lblSuppCountry.Caption;
       frmInvoice.lblSuppCountry.Caption := '';
     End;

  If frmInvoice.lblSuppCity.Caption = '' then
    Begin
      frmInvoice.lblSuppCity.Caption := frmInvoice.lblSuppState.Caption;
      frmInvoice.lblSuppState.Caption := frmInvoice.lblSuppZip.Caption;
      frmInvoice.lblSuppZip.Caption := frmInvoice.lblSuppCountry.Caption;
      frmInvoice.lblSuppCountry.Caption := '';
    End;

  If frmInvoice.lblSuppStreet.Caption = '' then
    Begin
      frmInvoice.lblSuppStreet.Caption := frmInvoice.lblSuppCity.Caption;
      frmInvoice.lblSuppCity.Caption := frmInvoice.lblSuppState.Caption;
      frmInvoice.lblSuppState.Caption := frmInvoice.lblSuppZip.Caption;
      frmInvoice.lblSuppZip.Caption := frmInvoice.lblSuppCountry.Caption;
      frmInvoice.lblSuppCountry.Caption := '';
    End;

492

(34 replies, posted in General)

Hi Derek,


Thank you very much for the simple approach to refunds demo. It doesn't fit what I'm trying to do but it's a great demonstration of simple alternative approach with minimal code.
Couple of points I noticed if I'm not missing anything.
- How can we tell that refund/s belongs to purchase or sale?
- On click of Form1 TableGrid1 header produces a "List index out of bounds (-1)" error message.


Not sure if something like this helps on a couple of the points you raised.  As always, probably other(better) ways to do it.

Thanks for the example. I'll try to apply it and see if I can get it working.

493

(34 replies, posted in General)

Hi EHW,


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


I have some additional questions but you can ignore them if you wish as you have already helped me a great deal on this matter.


1. Under sale inv onShow

frmInvoice.cbSIcustCountry.dbItemID := -1;
... 

what the above line does?


2. How can I change each text line font style, size and color in supplier memo field?
For instance, making Supplier name line font size 10 and style underlined or bold.


3. Is it possible to hide lines or copied fields within supplier memo field when there is no data entered for certain fields?. For instance if there is no city, lines moves up to fill blank (visially) space (I moved city to it's own line rather than having city, state and zip on same line) or if there is no state, can we move zip code to a left (filling the spacer)


4. This would be a bonus if you also provide getting supplier fields into supplier memo field using SQLExecute. What you have done perfectly fine for this project. It'd be great reference info for my code repository for future projects.

494

(34 replies, posted in General)

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


Unfortunately, I'm not there yet to construct proper SQL.

I tried followings under frmInvoice onShow but surely they didn't work as they are not correct:

frmInvoice.memSIsupplier.Lines.add(frmInvoice.name.id_Supplier);
frmInvoice.memSIsupplier.Lines.add(frmInvoice.Street.id_Supplier);
frmInvoice.memSIsupplier.Lines.add := SQLExecute('SELECT Name FROM Supplier WHERE id='+inttostr(form1.tgMainSaleInvs.dbitemid));
frmInvoice.memSIsupplier.Lines.add := SQLExecute('SELECT Street FROM Supplier WHERE id='+inttostr(form1.tgMainSaleInvs.dbitemid));

495

(34 replies, posted in General)

Hi EHW,


Thanks for the alternative approach example......


On this project, I'm using single product invoicing. Purchases tGrid also acts as a inventory. So once a product sold it moves into sales invoices.
Derek was kind enough to highlight shortcomings in my design.


I have added a message box for the purchase invoice contains "Db" refunds to the btnSaleAdd with a cancel which stops user converting purch inv with refund/s to sale inv. If all refunds were full this would be it but sometimes there are partial refunds where product may be kept. Supplier may give some refund rather than having product returned and issuing full refun in some occasions. We end up with a product at new purchase price (original purchase price - refund). In accounting terms (as far as I know) we can sell it as a new product at discount, if we cannot then it has to be written off in order to balance the books, alternatively it may be kept as an asset depending on product nature. I'm not going into write offs, asset management etc with this project. Trying to keep it simple and basic.


On traceability front, having purchase inv key fields displayed on sale inv could solve the issue imho. When sale inv viewed, user can see the details of the original purch inv on sale inv form. I have done all these and they seems to be functioning ok so far. However, one thing I couldn't do. Instead of using combos and textboxes, for supplier name and address, I wanted display the in a read only memo field. Please see the reference image below:


https://s29.postimg.org/pijpmsxjb/zzzzz_Temp49.png

496

(34 replies, posted in General)

derek wrote:

... do you mean that on this particular project, everything that comes in on 1 purchase invoice then goes out on one sales invoice?

Yes.

497

(34 replies, posted in General)

Hi Derek,


Selling the purchase deletes it from tgmainpurchinvs and adds it to the tgmainsalesinvs.  But it leaves the refund record behind in tgmainpir. That's how you get more records in tgmainpir than in tgmainpurchinvs...

... the MAIN one being the way in which you delete a purchase record when you sell it - you lose all traceability back to the purchase record which, from both a commercial and an audit point of view, could be a big problem.


You are absolutely right on both points. Thank you very much for taking time to look into my sample project.... Truly appreciated.............
If there are more design issues you spot please let me know.


Solutions I can think of...
1. Prevent moving purchase inv to sale inv if purchase inv contains refund/s. If purchase inv contains only partial refunds and user still wants to sell what's left then user needs to create a new purchase invoice for the same product.


2. Traceability; display purchase invoice details on sale and sale refund invs forms or on separate form via a buttons on sale and sale invs reforms.


I didn't commit any changes yet before having your view. Probably you have better solutions.


The reason I'm converting purchase inv to sale inv rather than having them separately is that this part of the project involves 1 product transactions hence there is no qty field. In and out.

498

(34 replies, posted in General)

Hi Derek,


2.  Your design allows for multiple refunds against one invoice, therefore it is quite normal for the PIR refunds tgrid to contain more records than the PI invoices tgrid  - so I am struggling to understand why this is an issue?...


If I'm not missing something, the following image may explain the issue better hopefully:
https://s29.postimg.org/66mmsbgef/zzzzz_Temp48.png


I agree EHW's solution is the proper one and I'll use it in this case.
I also like your workarounds too. It'll be useful for other projects not only mine but also other MVD users' too. That's why I highlighted the above issue.

499

(34 replies, posted in General)

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


Derek:
With your approach you missed hiding refund edit and delete buttons plus disabling double click for refund tGrids. I added them. Downside is that in order to edit refunds, user needs to click on edit button as disabling doubleclick applies to both all refunds and normal states. There may be a code using if etc so that double click disabled only when all refunds are displayed. I didn't try anything on this front yet.

There is one issue I noticed tho, All refunds displays more records then what's shown on invoice tGid. PI Invoice tGrid contains 5 refund records but PIR Refunds tGrid shows 8 refund records. Perhaps MVD search doing something that we cannot see as EHW pointed out?


EHW:
Nice one... It works fine without workarounds. I wish I could write SQL script like you can.

500

(34 replies, posted in General)

Hi Derek,


Thank you very much......


I thought about using hidden tGrid too but it didn't solve out the issue of not displaying correct tax rate value under refund prices if a refund record on all refunds display state when refund edit button clicked. All I can think of having all refund tGrid displayed on a separate form without edit and delete buttons as a workaround to this approach.


Hopefully somebody (that includes you too Derek - lol) can offer proper solution.


But I'm not sure why you need a 'search' associated with the 'all refunds' button if you're displaying everything.

When displaying all refunds on same tGrid that was the only way I could think of.


If I get time, I'll have a think about  the other 2 issues you mentioned as well.

Thank you... In the meantime if and when I can replicate them, I'll update here.


Just a word of caution, but with possibly 3 of us looking at it independently, you need to be careful that we don't end up overwriting each others' changes.

No worries. I do not delete you guys changes or code. If I want to try something else I create a new copy of the sample project and work on that.