1

(15 replies, posted in General)

DriveSoft wrote:

How to get logical serial number of C:\

ShowMessage(GetHardDiskSerial('c'));

But this number will change if user reinstall Windows.


Sorry to reply on old thread, but I want to know if I clone the pc hard drive, is the logical serial number will be the same or cloned on both pc?

Thank you!

2

(6 replies, posted in SQL queries)

derek wrote:

Hi,
I take your point about loading times.
Attached is a slightly different approach you could try (I've replaced the multiple tablegrid approach in my earlier suggestion with a single tablegrid and a script that filters/hides columns as required.  Probably it's a more efficient way of doing it.
Just enter 'MON', 'TUE', 'WED' etc to get your daily delivery schedules or 'blank' to see everything.
Regards,
Derek.


Thanks a lot derek! this is much better smile cheers!

3

(6 replies, posted in SQL queries)

derek wrote:

Hi,
Quite a few different ways to approach this, I imagine.
The easiest way of all would simply be to use a tablegrid and have filters on each of the days - click the appropriate filter for whatever day of the week and the rows in the tablegrid adjust accordingly.  And you shouldn't need to use a script with this approach.
But if you want to see a delivery schedule for discrete days in a separate tablegrid, then I think I'd try it this way (see attached);  I've tried to keep the script to a minimum.
As per your write-up, when you run the program, it defaults to the current day of the week and customers who have deliveries for that day.
But I imagine someone is always going to want to know about tomorrow etc etc (LOL!), so just enter a different day number (Monday = 1 - Sunday = 7) and you can see different schedules for different days.  And if you enter a space, it shows ALL schedules.  Deleting the number (or the space), clears the tablegrid.
Perhaps this gives you some ideas.
Derek.


This is a clever solution derek! I will apply this now but I feel like my loading time is getting longer and heavy the more objects I add. I already have tons of images because I use it as buttons (like hovering effects switching images). Still I would love to learn how to make my sample mySQL statement or script to work, this will also help me solve future problem. Thanks a lot as always for the sample I will use this so I can run my system sooner. smile

4

(6 replies, posted in SQL queries)

hello,

Please i need help with correct syntax.
i have a customer table, with field fullname (string), monday, tuesday, wednesday, thursday, friday, saturday, sunday (all boolean). this day of week will be a checkbox on a form. i can check 1-3 items as the delivery schedule (ex. monday, thursday, sunday).
I want to display customers on a grid or combo box if they are check for the current day. (ex. today is Wednesday, if a customer wednesday field is true then this customer will be displayed in the list.)
Option 1, I try to use Search button and load it to Grid but I cant make query works, the idea is like this:
SELECT DayName(CURDATE()) AS myDay
if myday = 'Sunday' THEN
    SELECT id, fullname FROM customer WHERE sunday = True
ELSEIF myday = 'Monday' THEN
    SELECT id, fullname FROM customer WHERE Monday = True
ELSEIF myday = 'Tuesday' THEN
    SELECT id, fullname FROM customer WHERE Tuesday = True
ELSEIF myday = 'Wednesday' THEN
    SELECT id, fullname FROM customer WHERE Wednesday = True
ELSEIF myday = 'Thursday' THEN
    SELECT id, fullname FROM customer WHERE Thursday = True
ELSEIF myday = 'Friday' THEN
    SELECT id, fullname FROM customer WHERE Friday = True
ELSEIF myday = 'Saturday' THEN
    SELECT id, fullname FROM customer WHERE Saturday = True 
END IF

option 2, i try the scripting to add it in combo box. it could work but i have problem going to the next record?

if intDayWeek = 1 then SQLQuery('SELECT count(id) as iCount FROM customer WHERE sunday=True', Results)
else if intDayWeek = 2 then SQLQuery('SELECT count(id) as iCount,fullname FROM customer WHERE monday=True', Results)
else if intDayWeek = 3 then SQLQuery('SELECT count(id) as iCount,fullname FROM customer WHERE tuesday=True', Results)
else if intDayWeek = 4 then SQLQuery('SELECT count(id) as iCount,fullname FROM customer WHERE wednesday=True', Results)
else if intDayWeek = 5 then SQLQuery('SELECT count(id) as iCount,fullname FROM customer WHERE thursday=True', Results)
else if intDayWeek = 6 then SQLQuery('SELECT count(id) as iCount,fullname FROM customer WHERE friday=True', Results)
else if intDayWeek = 7 then SQLQuery('SELECT count(id) as iCount,fullname FROM customer WHERE saturday=True', Results)
else showmessage('wrong day');
    rCnt := results.fieldbyname('iCount').asinteger;
    for i := 0 to rCnt-1 do
    begin
       Form1.cbSchedule.dbAddRecord(i,Results.FieldByName('fullname').AsString);
       results.next //????
    end;
    Results.Free;

I have tried to make this work my self but my limited skills dont allow me. Can someone please help me correct the syntax for the best approach of what I need to accomplished? Either option 1 or 2 will do.

Thanks a lot!

5

(4 replies, posted in Script)

derek wrote:

Hi,
As per your description of the requirement, I'd probably do it something like this (see attached).
The user doesn't have to do anything except enter readings (the program creates a new row automatically for the current date (if it doesn't already exist) and puts readings into the correct 'morning' or 'evening' field depending on the current time). 
For information, the last week's worth of readings are displayed and there is also an option to manually maintain dates/times/readings to correct for any errors or omissions (mistakes are bound to be made!).
Perhaps this approach gives you some ideas.
Derek.

perfect works like a charm! thank you for creating this derek!
learn a lot of of technique with this smart little software smile

6

(4 replies, posted in Script)

derek wrote:

Hi,
One simple way might be to remove the problem and only have one datetimestamp field and then use calculated fields to display morning(AM) and evening(PM) - see attached.
This option requires no script but does set the datetimestamp when you OPEN the form rather than SAVE the form - I don't know if this is critical to your requirement.
But there are other ways to do it as well if the above option doesn't suit.
Derek.

Thank you for this example, substr is the key here. im still playing with it to fit my requirements.
I need to record for example an electric meter in morning and evening. only one row per day, (date is unique)
user will input the value for AM click save. then comeback and input value at evening. then system fill the rest of information.
Ex.
Date, AM value, AM time, PM value, PM time, consumption. etc

so system will automatically save the time in correct field AM or PM. i can put 2 Edit box for am and pm, still i need to disable/hide one of them when its AM or PM just to make sure user dont make mistake where to put the value.

i want it to be user friendly as much as possible thats why one Editbox is good way, just input and save. quick timestamp of value

7

(4 replies, posted in Script)

Hello derek, dmitry

Please help how to detect if current time is morning or evening..

I need to get the time stamp when click save. I have two fields in the table; Field_morning and Field_evening
When I click the button if morning it will save to field_morning and Field_evening is empty,
else if evening it will save to Field_evening and Field_morning  no change.

I want the user to just click one button and system will take care of recording it and input the correct value in the field. I want to use button [save record] to avoid scripting, problem is both field will be populated same time.


Thanks again in advance!

derek wrote:

Hello Rhyacm,
Try testing your conditions this way (see attached).
Regards,
Derek.

Thank you again derek. so i cant use directly variables with this condition. because i use several statement with AND, now i know why they dont work.
I have to adjust to your method then. thanks!

Is the result standard to delphi or im doing it wrong?

    bolcon1 := False;
    bolcon2 := False;

    if bolcon1 = True and bolcon2 = True then showmessage('both True');
    if bolcon1 = False and bolcon2 = False then showmessage('both false');

what do you think will show up in the message?

both false, right?
wrong..

if both value change to True what will show?
both true only right? wrong again...

derek wrote:

Hello,
The search button can either be manually clicked or automatically triggered (in which case I usually hide it).
In order for the search button to automatically trigger, you need to set the increm. Search property of form1.combobox1 to the relevant search button (form1.button1) - have a look at the screen capture.
Regards,
Derek.

I see! nice info thanks again!

derek wrote:

Hi,
If I understand your question correctly, then I'm not sure why you need to use a script.
It seems that all you are wanting to do is filter tablegrid1 by customer which is a standard MVD search with no script required and the result can either be output to the same tablegrid (tablegrid1) or, as you are doing, to a separate tablegrid (tablegrid2).
Please have a look at the objects that I added to your project as an example.
Derek.

Hello derek

Thank you for response. yes you understand it correctly and your solution will work. I have seen this solution in other thread as example but i did not actually understand the combination of button and combo box thanks to you its clear for me. This means that if I select from combo box the button will be automatically triggered?
I will use this..
I think of scripting because there are lot of things i need to accomplish in this transaction like if the customer exist in Grid1 (Grid1.visible=False), after selecting  the customer from combobox there will be a message congratulating the customer and asking if he or she want to claim this prize now, if yes then items from Grid1 will be added to Grid2 if not nothing will happen, (user will add other items to grid2). Then later this items from Grid2 will be save to table together with additional information found on the Form1 (price, total amount, discount etc etc) but not necessarily existing in the Grid2 which I think of manually using insert query. But this give me idea of using invisible button that will be triggered to save other data or update rather than writing the query my self... im really new to visualdatabase and still evaluating the product...will buy this for sure.

Hello,

It took me many hours to figure out why my do loop executed twice even it should be only 1.
It turns out that when searching by typing and click the item in combo box it will execute it twice so if i have loop script on change event it will execute twice.

what i want to accomplish:
- grid1 have the list of free item that customer can claim (invisible)
- combo box1 has the list of customer
- grid2 will be the list of items added from other buttons. if customer has free items in grid1 it will be automatically added here.

If i select a customer from combobox1, it will search item from grid1 using loop, if found, item will be added to grid2. All good but it go to the loop twice when typing then clicking on item. so if i have showmessage or other procedure to execute it will be executed twice. please see sample
how to fix this? thanks!

13

(6 replies, posted in Script)

Thank you for the help it is working now!

14

(6 replies, posted in Script)

DriveSoft wrote:

Check it out

      SQLExecute('INSERT INTO Customer (count,id_customer,date,due,payed,balance,discount,delivery,pickup,id_user) VALUES ("' + qcnt + '", "' + qcus + '", "' + qdte + '"," ' + qtot + '"," ' + qten + '"," ' + qchn + '"," ' + qdnt + '", "' + qchr + '", "' + qpup + '", "' +  qnme + '")');

Thank you for the sample i really appreciate it! This syntax do not return the error ')' expected, but i have another problem, Incompatible types...
my data come from edit box or labels. I declare Variables as real, double or string depends on value, then I pass the value of text and labels to variable using StrToFloat, StrToInt etc.
Running it return Incompatible types, but when I declare all my variable as string it run without issue, but upon executing the code, the exe crashed. Maybe due to incompatible type in mysql which are Int, double and datetime.
I tried returning one variable to double or real, also removing single quote, etc.. and it flag this point as incompatible.
Im able to create a system for what i need like a pro using visual database but im stuck now the whole day with this inserting thing..
How can i completely save my data pls?

15

(6 replies, posted in Script)

sibprogsistem wrote:
rhyacm wrote:

Hi, can someone please help me with correct syntax pls?
I cant make it work... i want to insert to table via script because i need to manipulate 2 different tables in one button which i cant do in gui.

SQLExecute('INSERT INTO Customer (count,id_customer,date,due,payed,balance,discount,deliver,pickup,id_user) VALUES ("' + qcnt + "','" + qcus + "','" + qdte + "','" + qtot + "','" + qten + "','" + qchn + "','" + qdnt + "','" + qchr + "','" + qpup + "','" +  qnme + '")');

values are variable i convert to proper type StrToFloat, StrToInt etc...
I keep on receiving error') ' expected....

" '  ' "

Thank you for response. i cant make it work , i change it to this
SQLExecute("INSERT INTO Customer (count,id_customer,date,due,payed,balance,discount,delivery,pickup,id_user) VALUES ('" + qcnt + "', '" + qcus + "', '" + qdte + "', '" + qtot + "', '" + qten + "', '" + qchn + "', '" + qdnt + "', '" + qchr + "', '" + qpup + "', '" +  qnme + "')");

Im still receiving  ')' expected
i do like this " ', ' "
maybe i dont really understand how this works but i like learning SQL query.
Is there a way to save into two tables by using only one button so i dont have to build sql query?
Thanks again for answering

16

(6 replies, posted in Script)

Hi, can someone please help me with correct syntax pls?
I cant make it work... i want to insert to table via script because i need to manipulate 2 different tables in one button which i cant do in gui.

SQLExecute('INSERT INTO Customer (count,id_customer,date,due,payed,balance,discount,deliver,pickup,id_user) VALUES ("' + qcnt + "','" + qcus + "','" + qdte + "','" + qtot + "','" + qten + "','" + qchn + "','" + qdnt + "','" + qchr + "','" + qpup + "','" +  qnme + '")');

values are variable i convert to proper type StrToFloat, StrToInt etc...
I keep on receiving error') ' expected....

17

(2 replies, posted in General)

thank you sir!

18

(2 replies, posted in General)

Hello,

I cant seem to find related topic or answer to my problem. I cant properly add column to a table grid. sorry for noob question. but im receiving list index out of bounds.

what i want is to manual add items to grid. i have bigger program seems to work without any issue if items are from database. but there is a requirement for me to populate it manually and also save it to database.
this is just a sample code. how to properly code adding of columns? and also easy way to save it to database after items are added.

procedure frm_main_Button1_OnClick (Sender: TObject; var Cancel: boolean);
begin
frm_main.TableGrid1.AddRow(1);
frm_main.TableGrid1.Cells[0,0] :=  frm_main.Edit1.Text;
frm_main.TableGrid1.Cells[1,0] :=  frm_main.Edit2.Text;
frm_main.TableGrid1.Cells[2,0] :=  frm_main.Edit3.Text;
frm_main.TableGrid1.Cells[3,0] :=  frm_main.Edit4.Text;


end;

procedure frm_main_OnShow (Sender: TObject; Action: string);
begin
    //header name
    frm_main.TableGrid1.AddRow(1);
    frm_main.TableGrid1.Columns[0].Header.Caption := 'First Name';
    frm_main.TableGrid1.Columns[1].Header.Caption := 'Last Name';
    frm_main.TableGrid1.Columns[2].Header.Caption := 'Phone Number';
    frm_main.TableGrid1.Columns[3].Header.Caption := 'Date Time';
end;


begin

end.

Thanks in advance!

DriveSoft wrote:
rhyacm wrote:

Hello,

I try to use this script to connect to mysql but im receiving "exception EAccessViolation..." when UpdateDatabase(''); is used.
without this, there is no error. but combobox cant show data.
Any other way to repopulate data?

Thanks in advance!

Please attach your project, I will test it. Thanks.

it is working fine when i put the connection on form load.  i got the error when i put the connection script at this part...

begin

//sql connection
//sql query

end.

because i want to insert data first if table user is empty.
so i put the connection script there and it return the error.
so i guess im not allowed to put the connection script there.

Hello,

I try to use this script to connect to mysql but im receiving "exception EAccessViolation..." when UpdateDatabase(''); is used.
without this, there is no error. but combobox cant show data.
Any other way to repopulate data?

Thanks in advance!