Topic: how to do this

hello everyone,

database for my small store. please help me finish.


https://drive.google.com/open?id=1hD4Hr … 6wGCt7BInH

---may the force be with you!

Re: how to do this

Hello.


You just forget to specify TableName and FieldName properties for DateTimePicker1 and DateTimePicker2 component.

TableName = Product
FieldName = Expiry

Dmitry.

Re: how to do this

Thanks Drivesoft,

Yes I forgot that one.
My concern is the AllSales and the NewSale tables.
Notes are on the table. Please help.

Thanks!

---may the force be with you!

Re: how to do this

Please describe your question in more details.

Dmitry.

5 (edited by ehwagner 2020-03-18 01:02:13)

Re: how to do this

Anakin,
I made some guesses and assumptions in what you are wanting to do. I revised your project and hopefully my changes gets you closer to what you are looking for. I didn't do anything with CLASSIFICATION or VARIANT in your project. I assumed that the table Product represents inventory whereby UNITS would be the same as qty on hand. The calculated field in Product represents the value of the inventory items. If these assumptions are correct then when you make sales, the UNITS (qty on hand) in Product table gets updated based on the sales transaction units. The NewSale form can be used for adding and editing sales. The PAYMENT and CHANGE fields are only used to calculate the change amount back to the customer. I don't think it is necessary to actually store those amounts so I removed them. But you can add them back if you need to. I put code in to retrieve the product price from the PRODUCT table when a product is selected from the combobox in NewSale form. Most of the code in the project is for the maintaining of the UNITS (qty on hand) in Product table. That code is at the bottom of the script. If you don't need it then you can remove it.


I also added code to change the UNITs cell in the Products tablegrid to RED if the UNITS qty is zero or below.


I'm not sure why you have UNITS as a search item in the Inventory form. I left it alone.

Post's attachments

Attachment icon store2020 Revised.zip 362.37 kb, 387 downloads since 2020-03-18 

Re: how to do this

ehwagner,

Thank you! you got it right on the mark!

Kudos!


Anakin

---may the force be with you!

Re: how to do this

ehwagner,

one last thing:

In addition to all of the stuffs in my Inventory Form, I wanted to add three more items on it:
1. Capital (my purchase price of my products before selling)
2. Total Capital = Units * Capital
3. Projected Profit =  Price - Capital

I seem to get lost and get errors when i add it on my Product table.
a.Capital is currency
b.Total Capital is calculated field (capital * units)
c. ProjectedProfit is calculated field (price-capital)

I get errors. Can you help me set this up? Thanks

anakin

---may the force be with you!

8 (edited by ehwagner 2020-03-18 20:03:29)

Re: how to do this

Check the attached and see if that is what you want.

Post's attachments

Attachment icon store2020 Profit.zip 362.59 kb, 381 downloads since 2020-03-18 

Re: how to do this

ehwagner,

this is already ok. however, i still get an error with regards to my inventory form.
The error says that my product name is not a 'valid integer'. I think this is the code that is causing it.
can you check on this? so that =< zero will turn red and yet will still accept Name of Product.

procedure Inventory_TableGrid1_OnChange (Sender: TObject);
// If Product Units qty is zero or below then change color in the appropriate tablegrid cell to red and bold it
var
  i: Integer;
begin
    For i := 0 to Inventory.TableGrid1.RowCount - 1 do
      Begin
         If StrToInt(Inventory.TableGrid1.Cells[1,i]) < 1 then
           Begin
              Inventory.TableGrid1.Cell[1,i].TextColor := clRed;
              Inventory.TableGrid1.Cell[1,i].FontStyle := fsBold;
           End;
thanks

      End;
end;
---may the force be with you!

Re: how to do this

It sounds like you may have inserted another column in front of the product name in the tablegrid. If you did then you need to change the FOR LOOP to point to UNITS column in the tablegrid.


Whatever the column number is for UNITS beginning with Column 0 then replace the digit 1 below in Cells[1,i] and Cell[1,i] with the appropriate number. In other words, if the UNITS column is now the third column in the tablegrid, then you want to replace the 1 with 2.

If StrToInt(Inventory.TableGrid1.Cells[1,i]) < 1 then
           Begin
              Inventory.TableGrid1.Cell[1,i].TextColor := clRed;
              Inventory.TableGrid1.Cell[1,i].FontStyle := fsBold;
           End;

Re: how to do this

ehwagner,

ah great! that did it. thank you so much!

how come you're so good at this one?
any tips for me to learn this programming language? any reading material? links?
I'm a very beginner. thanks!

anakin

---may the force be with you!

12 (edited by ehwagner 2020-03-20 17:28:46)

Re: how to do this

Anakin,
Thank you for your kind words. When I came to MVD I knew nothing about the development system and I knew nothing about Pascal except that it is essentially an old development language, meaning it's been around for awhile. However, I've had experience with other development systems and programming languages so my learning curve was very small. I just adapted the same techniques to MVD. For me I learned MVD by going through the videos and online help documents developed by Dimitry http://myvisualdatabase.com/help_en/. I relied on the forum heavily in the beginning and still do. I have also used Delphi Basics website. http://www.delphibasics.co.uk/    I have used SQL reference websites sometimes for assistance with complex SQL statements. For SQL websites you need to make sure the syntax is for either SQLite or MySQL, whichever you are using. There are subtle differences among databases.

The forum is an invaluable resource especially when you are stuck on something. Don't hesitate to ask. There are a lot of people on here who can help. One is Derek who is a very active member on here and he has helped me. I call him the "Master of Non-script Solutions". :-)  I say this out of respect for his knowledge. Obviously, most projects cannot go without some scripting and he has provided significant help with that as well. Dimitry who is the author of MVD is invaluable on here. He can help where other people are not able to. There are a lot more people on here and I don't want to start naming names because I don't want to leave anyone out. As I said before, don't hesitate to ask for help.

I would highly recommend building a code snippet database as soon as you can. Doing so will help you tremendously as you are learning. It can become a very useful resource as a reference tool. Most of the snippets I have came from the forum as new versions come out and from things people have posted that may not be in the help system.

One final thing, I really do not feel that I am an expert on MVD, but I try to help people whenever I can with what I know.

Re: how to do this

ehwagner,

Thanks!

Incidentally, this website that you you gave:  http://www.delphibasics.co.uk/  I just came across this one recently and i'm trying out the tutorials. Thanks for all the tips!

1. I'm trying now, on my All Sales Form, how to make all paid items into color blue. and the unpaid still black. Any idea how to start it?
2. Also, i'm having two lines per Sale Item in my All Sales Form whenever I add a NewSale. I dont know what happened but I just added a Classification and Variant column in it. Any Idea where i could have gone wrong in this?

Post's attachments

Attachment icon allsales.JPG 32.39 kb, 132 downloads since 2020-03-21 

---may the force be with you!

14 (edited by derek 2020-03-21 11:35:43)

Re: how to do this

Hi Anakin, Hi EHW,
Can you upload the most recent version of your project?  But without looking it it, I would guess it's because
1)  you have an incorrectly specified join between tables.
OR
2)  you have specified the wrong 'main' table in your tablegrid
On a more general point, the only thing I would add to EHW's comments made earlier (all of which I agree with), is that you really need to have a basic understanding of how a relational database 'works';  good database design is just as important as good programming and without it, you can quickly run into problems.
Derek.

Re: how to do this

Very good point Derek. I did overlook that aspect. I made an assumption that everybody who comes to this software has a database design background. You're absolutely correct. The proper database design is the main foundation for all database applications. It is essential for a successful project. Thanks for your input.

Re: how to do this

Hi Derek & ehwagner,

I heeded your advise to check whether my project has good database design. And I found out that what was lacking was to make my other tables (classifiction and variants) linked (relationship) to my sales table. That did the trick.

I learned today that the more simple the database structure is, the better. Simplicity is key to good database?

Thanks for your tips guys. I will study this stuffs and catch up with you. Please send me more links to study.

Thanks to you both!

Anakin

---may the force be with you!

Re: how to do this

Hi Derek & ehwagner,

I'm lost guys which to look.
I need to add two columns in my AllSales Form: Classification and Variant.
but I cant seem to make data appear on the All Sales Form.
also, in my NewSale form, how to make classfication and variant input appear/copy automatically in the box when I add ProductName (just like its price)
thanks!

https://drive.google.com/open?id=1T-_Ho … lYopsQAAy2

Anakin

---may the force be with you!

18 (edited by derek 2020-03-22 16:11:36)

Re: how to do this

Hi Anakin,
It's not possible to download your project without permission using a google account.
Can you make it available without requiring permission or as a simple download using something like 'dropbox'?
Derek.

19 (edited by anakin 2020-03-23 01:24:17)

Re: how to do this

Hi Derek and ehwagner,

here's the dropbox link to file
https://www.dropbox.com/s/u68fwypt77hk0 … it.7z?dl=0


in addition, in the NewSale and AllSale Forms how to record also the Payment and Change inputs and make it appear in the TableGrid of AllSale for recording purposes.

thanks


Anakin

---may the force be with you!

20 (edited by ehwagner 2020-03-23 03:35:36)

Re: how to do this

Anakin,
See attached for the revised fixed project. Classification and Variant are correctly defined as a relationship to Product, so you really should not have it related to Sales. But in order to bring in those two fields into the Sales tablegrid I created calculated fields to retrieve the respective names. Keep in mind that calculated fields are not real fields so it is not duplicating data in the Sales table.  Also, the controls for these two fields in the NewSale form are defined as ReadOnly.  You cannot change them in this form because they belong to Product, not Sales. Hope this helps.


I just noticed that you asked about placing the Payment and Change in the tablegrid. All you have to do is define them in the Sales table, then put the definitions in the object Inspector of the Sales form. Don't forget to include them in the Save action.

Post's attachments

Attachment icon store2020 Profit Fixed.zip 364.7 kb, 351 downloads since 2020-03-23 

Re: how to do this

ehwagner,

Thank you. It's fine now.
Regarding this one:

about placing the Payment and Change in the tablegrid. All you have to do is define them in the Sales table, then put the definitions in the object Inspector of the Sales form. Don't forget to include them in the Save action.

i'm still figuring out how to do this. And how to make an entire row in the AllSales be colored red or green once a payment for it has been made (so as to differentiate between paid and not paid items)?

thanks!

---may the force be with you!

Re: how to do this

Anakin,
See attached.  I added Payment and Change fields in the database definitions for the Sales table, placed the new fields in the AllSales tablegrid, changed the NewSale form Object Inspector for each field to point to the corresponding table field, included the new fields in the Save action, and put in script to colorize table rows with no payments to red.

Post's attachments

Attachment icon store2020 Payment.zip 365.58 kb, 459 downloads since 2020-03-23 

Re: how to do this

ehwagner,

thank you!

anakin

---may the force be with you!