26

(19 replies, posted in General)

Here's a workaround, putting password saving function on the mousenter event of the Form1. It seems that the onActivate function runs right after the showing of the login form.

27

(7 replies, posted in General)

Maybe something like this might help you.

28

(4 replies, posted in SQL queries)

Just do if-else in the script instead of that case query

if SQLExecute('SELECT COALESCE(b.is_active, 0) as isActiveReturn FROM bookings b WHERE b.is_active=1 AND b.id_boxed=1 ORDER BY b.is_active DESC LIMIT 1') = 0 then
    Main.Panel1.Caption := "Ja"
else 
    Main.Panel1.Caption := "Nein";

29

(4 replies, posted in General)

Changing this module, in my personal preference, I'll have my own module and forms to update user details.

30

(19 replies, posted in General)

There you have it, maybe you don't have frmSafeguard on your project.

I just put the key there for some security purposes, you can override it

ini.WriteString('REMEMBER', 'user', EncryptRC5(frmdbCoreLogin.edLogin.Text, 'YourKey'));
ini.WriteString('REMEMBER', 'pass', EncryptRC5(frmdbCoreLogin.edPassword.Text, 'YourKey'));
frmdbCoreLogin.edLogin.Text := DecryptRC5(remUser, 'YourKey');
frmdbCoreLogin.edPassword.Text := DecryptRC5(remPass, 'YourKey');

31

(19 replies, posted in General)

Can you check on the error? You can see it below https://ibb.co/Y7yBrbh
Maybe you didn't have the frmSafeguard or the label in it. Check on the error.

Off topic, how can I use the image I mean to show it on my reply/post. LMAO, been a while here but I can't use that img.

32

(19 replies, posted in General)

That code doesn't affect to what DB you use. Is there any error message?
Check your user login settings too, maybe you are using dropdown instead of text

33

(2 replies, posted in Script)

try running the dbupdate after your filter

Payment.ComboBox1.dbFilter := 'id_customers = 4';
Payment.ComboBox1.dbUpdate;

Payment.TableGrid1.dbFilter := 'id_customers = 4';
Payment.TableGrid1.dbUpdate;

34

(4 replies, posted in Script)

Maybe the query returns an array. I'm thinking Combobox3 list is from slujiteli table, right?  The details you gave is a little bit vague for we don't know the Checkbox1's sqlValue, etc. For starter, maybe your select query returns an array. Try adding LIMIT 1 in your query.

newprod.ComboBox3.dbItemID :=  SQLExecute('SELECT id FROM slujiteli WHERE Default = '+ newprod.CheckBox1.sqlValue +' LIMIT 1');

My advice, try debugging it by checking the newprod.CHeckbox1.sqlvalue, then run the query from a third party sqlite viewer to check if it really returns the correct id you are getting from database. It is also easier to work on it if you can send a simple application that address to your query.

35

(19 replies, posted in General)

Try using bLogin as your reference

chkRemember.Left := frmdbCoreLogin.bLogin.Left;
chkRemember.Top := frmdbCoreLogin.bLogin.Top-30;

36

(19 replies, posted in General)

Here.

37

(19 replies, posted in General)

There's a bunch of codes here from my previous work on having a secret question and answer. I hope this can help you start on your problem.
If you find the code OnActivate

TForm(Form1).OnActivate := @activateForm;

somewhat new, you are not alone. I just learned and using it in the Project I am working with Embarcadero Delphi. Helps a lot on some circumstances.

38

(7 replies, posted in General)

Have you tried ClipboardSet?

39

(9 replies, posted in General)

Sorry. I really can't picture it out to what you really want to do.
I want to help but I need the exact and detailed process.

40

(13 replies, posted in General)

v_pozidis wrote:

What I can not understand is that if the program runs the database is active. So with your example when you close the program Form1.close how does the function replace works???

You must first backup the database using the backup button. The button will backup your current sqlite.db to [filename].dbbak using SaveDialog


Then the Add record button is just to populate the table to see if populated table will be replaced by the backup.


To backup, you then click Backup button in which the program will ask the user for a file(backup, the one you save with Backup button) using the OpenDialog, then when the user select [filename].dbbak, it will close Form1, then replace sqlite.db with the user's selected [filename].dbbak, then reopen the program

41

(13 replies, posted in General)

Form1.close; // will also close the database

// replace database with the selected backup
CopyFile(OpenDialog.FileName, ExtractFilePath(Application.ExeName)+'\sqlite.db');

// re open the application
OpenFile('samplebackup.exe');

Just a hunch that closing the main(Form1 in the sample) form will also close the database connection, then after that, you can replace the sqlite.db by the backup. Then running the executable afterwards.

42

(13 replies, posted in General)

Try this one.

43

(9 replies, posted in General)

unforgettable wrote:

Can we use it in conditional statement if....then?
How we use ( select MAX(id) from xyz) in conditional statement? for example
if (select MAX(id) from xyz = (select id_abc from xyz where id_abc = 5) then ......

I'm a bit confused to what you really want with if condition.

Is it If-else condition in script or in sql?
Then, can you elaborate to what extend you are going to use it.
Can you at least tell us the logic to why you want the if-else?
Try not to include sql query first and just elaborate the logic or problem.

44

(9 replies, posted in General)

unforgettable wrote:

Thank you brain. In this query LIMIT 1 means one step before and other 1 is an increment.

Limit is the number or record you want to fetch.

1. Limit 1, will be selecting the first record of the query
2. For Limit 1, 1, First 1 will be the offset(will skip 1 record), then the Next 1 will be the number of record you are selecting
3. For Limit 2, 1, This will skip 2 record, then select 1 record from the query

45

(9 replies, posted in General)

Hello unforgettable, StateOne:

I'm confused. are you just trying to access the last record of your table? If so then you can just do

Select  * from xyz ORDER BY id DESC LIMIT 1

In this way you don't have to include subquery. You don't want it to slow down your query especially for a well-populated table
Then for e.g. last id is 300, being no gap in the IDs, to access 299,

Select  * from xyz ORDER BY id DESC LIMIT 1, 1

for 298

Select  * from xyz ORDER BY id DESC LIMIT 2, 1

for 297

Select  * from xyz ORDER BY id DESC LIMIT 3, 1

and so on.

For the conditional, try elaborating further the result you want to obtain for us to look for a solution.

46

(2 replies, posted in General)

I'm not so sure to what you are trying to do here. Are you perhaps selecting all records from smsLogs? If so then, here's an untested code that might help you

procedure FormReport_SmsSendAllbtn_OnClick (Sender: TObject; var Cancel: boolean);
var
   Msg,smsNumber,smsServer1,SMS_API1,SenderName1 : string;
   sl,slParam: TStringList;
   j : integer;
   jDataStream: TJSONObject;
   jStatus, jSmsID: TJSONString;
   dt : tDateTime;
   SData: TDataSet;
begin
  SQLQuery('SELECT * from smsLogs', SData);
  
  // you might want to just initialize this and not include it in the loop
  SMS_API1 := SQLExecute('Select SmsAPI from Extras where id = 1');
  SenderName1 := SQLExecute('select SenderName from Extras where id = 1');//'BlackPearl';
  
  try
    while (not SData.EoF) do
    begin
      smsNumber := SData.FieldByName('smsNumber').asString;
      Msg := SData.FieldByName('smsData').asString;
      // ShowMessage(smsNumber+' '+Msg);
      slParam := TStringList.Create;
      smsResult := HTTPPost('http://api.veevotech.com/sendsms?hash='+SMS_API1+'&receivenum='+smsNumber+'&sendernum='+SenderName1+'&textmessage='+Msg+'',slParam);
      // slParam.Free;

      sl:=TStringList.Create;
      sl.Text := smsResult;
      jDataStream := nil;

      jDataStream:=TJSONObject(TJSONObject.ParseJSONValue(sl.Text));
      if jDataStream <> nil then
      begin
        jStatus := TJSONString(jDataStream.GetPairByIndex(0).JsonValue);
        jSmsID := TJSONString(jDataStream.GetPairByIndex(3).JsonValue);
      end;
      ShowMessage(jStatus.Value);
      if (vartostr(jStatus.Value) = 'ACCEPTED') then
      begin
        SQLExecute('delete from smsLogs where id = '+inttostr(j)+'');
      end else 
        ShowMessage('Status : '+vartostr(jStatus.Value));

      SData.Next;
    end;    
  finally
    SData.Free;
    sl.Free;
    slParam.Free;
  end;                 
end;

47

(72 replies, posted in General)

unforgettable wrote:

Thank you brain zaballa. I could not understand highlighted lines in these two pics attached. Can you tell some detail about them? Are these executable?

It is to compute for the receivable, deducting discount from sTotal.

48

(3 replies, posted in General)

I'm not sure to what you really need but this might give you an idea.

https://www.dropbox.com/s/74n585xw84u73 … a.zip?dl=1

49

(72 replies, posted in General)

unforgettable wrote:

Any one can tell how do we create trigger in attached project. In fact as data increase system takes time to load form have tablegrid. A trigger speeds up to load?

You haven't attached your project. I used the last attachment from my replies.

Well, trigger will help but in my opinion, if you aren't that familiar with trigger, then you study it first. There are other method to avoid the calculated fields(Most probably, this are the ones responsible in slowing your application). All you can do is just edit that calculated field (In this example the Sales_Ticket.sTotal) to a regular field(Currency in this case). Then handle the calculation in your code.

50

(1 replies, posted in General)

Did you ShowMessage that alert?

You might want to check this out Since the response is in JSON format I think. http://myvisualdatabase.com/forum/viewtopic.php?id=6329