Jump to content

taariq

Members
  • Content Count

    29
  • Joined

  • Last visited

Everything posted by taariq

  1. taariq

    Currency Calculations

    Good day Plz note I am a newbie to Delphi and still learning but enjoying it... I need help with calculations please... I got total sum via database by using the following code that is working... dmuse.dmDBuse.FDQueryMaterialTotal.Open('SELECT SUM(COST) AS TC FROM MATERIAL WHERE ORDERNO=:d',[dbOrderNo.Text]); Showmessage(format( 'Total for Material OrderNo %s is %m',[dbOrderNo.text,dmuse.dmDBuse.FDQueryMaterialTotal.FieldbyName('TC').asCurrency])); tMaterial.text:=Format('%m',[dmuse.dmDBuse.FDQueryMaterialTotal.fieldbyName('TC').asCurrency]); dmuse.dmDBuse.fdQueryTraveling.Open('SELECT SUM(COST) AS TC FROM TRAVELING WHERE ORDERNO=:d',[dbOrderNo.Text]); Showmessage(format( 'Total for Traveling OrderNo %s is %m',[dbOrderNo.text,dmuse.dmDBuse.fdQueryTraveling.FieldbyName('TC').asCurrency])); tTraveling.text:=Format('%m',[dmuse.dmDBuse.fdQueryTraveling.fieldbyName('TC').asCurrency]); But here is my issue - trying to add the two values together Code I tried but get error - Code I am using... procedure TForm1.Button2Click(Sender: TObject); var tMaterial, tTraveling, tTotalCost: Currency ; usSet : TFormatSettings; begin usSet:=TFormatSettings.Create('EN_US'); tMaterial := StrToCurr (lbMaterial.Caption,usSet) ; tTraveling := StrToCurr (lbTraveling.Caption,usSet) ; tTotalCost := tMaterial + tTraveling; tProjectCosting.text := CurrToStrF(tTotalCost, ffCurrency, 2); end; Please help Thank you
  2. taariq

    Currency Calculations

    updated
  3. taariq

    Currency Calculations

    Good day I change the name of the edit box and the var
  4. taariq

    Currency Calculations

    thanks for reply what I get, when using text and no StrTo
  5. taariq

    Currency Calculations

    Good day Lets see if I got it now -
  6. taariq

    Currency Calculations

    Good day I got a nice google video on how to run and use debugger... What I see now ...but still don't understand
  7. taariq

    Currency Calculations

    Good day I got this ?
  8. taariq

    Currency Calculations

    Thanks for quick reply Do you know how to use the debugger to inspect vakues being passed to StrToCurr? > this will be so helpful - how do I inspect error Thank you
  9. taariq

    Syntax error in From clause

    Good day Please assist, I am a newbie I am trying to save data to an Access database... Keep getting the following error Syntax error in From clause Code below procedure TMainForm.b_save_new_recorsClick(Sender: TObject); begin dmTaS.query_JobCard.SQL.Add('Insert into JobCard('); dmTaS.query_JobCard.SQL.Add('(ID ,OrderNo ,JobName)'); dmTaS.query_JobCard.SQL.Add('Values :ID :OrderNo, :JobName)'); dmTaS.query_JobCard.Parameters.ParamByName('ID').Value := lb_ID.Text; dmTaS.query_JobCard.Parameters.ParamByName('OrderNo').Value := lb_OrderNo.Text; dmTaS.query_JobCard.Parameters.ParamByName('JobName').Value := lb_JobName.Text; dmtas.query_JobCard.ExecSQL; dmTaS.query_JobCard.SQL.Clear; dmTaS.query_JobCard.SQL.Text := 'Select * from JobCard'; dmTaS.query_JobCard.Open; I added the following in the TADOQuery under SQL SELECT * FROM JobCard Thank you
  10. taariq

    Syntax error in From clause

    It is finally working... Thank you so much I am definitely going to redo it now and learn learn.... Thank you so much for your time....
  11. taariq

    Syntax error in From clause

    Good day Thank you - getting closer now.... I updated the code to include amountex - hope I did it correct - it runs and then I get this error... My current records The updated code procedure TMainForm.Button1Click(Sender: TObject); //declare var to enter new job card var sOrderNo, sJobName , sStartDate, sCompletionDate, sAmountEx: string ; begin sOrderNo := Inputbox ( 'OrderNo' , 'Enter OrderNo' , 'QU000' ) ; sJobName := Inputbox ( 'JobName' , 'Enter JobName' , 'Company Name' ) ; sStartDate := Inputbox ( 'StartDate' , 'Enter Start Date' , 'YYYY/MM/DD' ) ; sCompletionDate := Inputbox ( 'CompletionDate' , 'Enter Completion Date' , 'YYYY/MM/DD' ) ; sAmountEx := Inputbox ( 'AmountEx' , 'Enter Amount Ex' , 'R ' ) ; dmTas.tblJobCard.Connection.ExecSQL('INSERT INTO jobCard (orderno,jobname,StartDate,Completiondate,AmountEx) values (?,?,?,?,?)', [sOrderNo,sJobName,sStartDate,sCompletionDate,sAmountEx]); // // if you want to retrieve last id you can use ExecSQLScalar //LID:=dmTas.tblJobCard.Connection.ExeSQL('INSERT INTO jobCard (orderno,jobname,StartDate,Completiondate,AmountEx) values (?,?,?,?,?) RETRUNING ID into :id', [sOrderNo,sJobName,sStartDate,sCompletionDate,sAmountEx]); // put LID as private or public of the form // do refresh Grid end;
  12. taariq

    Syntax error in From clause

    Good day I get runtime error? Sure I did something wrong - I did check my typing
  13. taariq

    Syntax error in From clause

    Good day I did create Generator BUT for some reason Only works in Flamerobin and not in Delphi...
  14. taariq

    Syntax error in From clause

    Good day Thank you so much I will have a look - this is my first FlameRobin and Firecad database - I had it all working 100% with a Access database... So now just trying to understand Flamerobin and Firecad ...... But for now if I want to take the ID as I got it in DBText2 and + 1 their how will I set the following to get the value from a label or the dbtext iID:= StrToInt ( Inputbox ( 'ID' , 'ID' , '002' ) ) ;
  15. taariq

    Syntax error in From clause

    That is the issue I got ? In Flamerobin I can add a record and it generates the id for the next record... But in Delphi it asks for ID? My code that I currently got where it asks for id... I get error > Field 'ID' must have a value. procedure TMainForm.Button1Click(Sender: TObject); //declare my var to enter new job card var sOrderNo, sJobName , sStartDate, sCompletionDate, sAmountEx: string ; //iID : integer; begin //asign values to input box //iID:= StrToInt ( Inputbox ( 'ID' , 'ID' , '002' ) ) ; sOrderNo := Inputbox ( 'OrderNo' , 'Enter OrderNo' , 'QU000' ) ; sJobName := Inputbox ( 'JobName' , 'Enter JobName' , 'Company Name' ) ; sStartDate := Inputbox ( 'StartDate' , 'Enter Start Date' , 'YYYY/MM/DD' ) ; sCompletionDate := Inputbox ( 'CompletionDate' , 'Enter Completion Date' , 'YYYY/MM/DD' ) ; sAmountEx := Inputbox ( 'AmountEx' , 'Enter Amount Ex' , 'R ' ) ; //insert values to DBgrid dmTaS.tblJobCard.Insert ; //dmTaS.tblJobCard['ID' ] := iID ; dmTaS.tblJobCard['OrderNo' ] := sOrderNo ; dmTaS.tblJobCard['JobName' ] := sJobName ; dmTaS.tblJobCard['StartDate' ] := sStartDate ; dmTaS.tblJobCard['CompletionDate' ] := sCompletionDate ; dmTaS.tblJobCard['AmountEx' ] := sAmountEx ; dmTaS.tblJobCard.Post ; //refresh db grid DBGrid1.DataSource.DataSet.Refresh; //show mesagges end; But if I do it like the following and add the ID manually it works - so I sorted the query via sql to get the last ID - I have the last ID in DBText2 - so now trying to figure out how to + 1 and give the value to iID procedure TMainForm.Button1Click(Sender: TObject); //declare my var to enter new job card var sOrderNo, sJobName , sStartDate, sCompletionDate, sAmountEx: string ; iID : integer; begin //asign values to input box iID:= StrToInt ( Inputbox ( 'ID' , 'ID' , '002' ) ) ; sOrderNo := Inputbox ( 'OrderNo' , 'Enter OrderNo' , 'QU000' ) ; sJobName := Inputbox ( 'JobName' , 'Enter JobName' , 'Company Name' ) ; sStartDate := Inputbox ( 'StartDate' , 'Enter Start Date' , 'YYYY/MM/DD' ) ; sCompletionDate := Inputbox ( 'CompletionDate' , 'Enter Completion Date' , 'YYYY/MM/DD' ) ; sAmountEx := Inputbox ( 'AmountEx' , 'Enter Amount Ex' , 'R ' ) ; //insert values to DBgrid dmTaS.tblJobCard.Insert ; dmTaS.tblJobCard['ID' ] := iID ; dmTaS.tblJobCard['OrderNo' ] := sOrderNo ; dmTaS.tblJobCard['JobName' ] := sJobName ; dmTaS.tblJobCard['StartDate' ] := sStartDate ; dmTaS.tblJobCard['CompletionDate' ] := sCompletionDate ; dmTaS.tblJobCard['AmountEx' ] := sAmountEx ; dmTaS.tblJobCard.Post ; //refresh db grid DBGrid1.DataSource.DataSet.Refresh; //show mesagges end;
  16. taariq

    Syntax error in From clause

    can you give me a code example and where will I use it - sorry dont understand 100%
  17. taariq

    Syntax error in From clause

    Good day Yes sorry I used FDQuery to sort table... Sorry still learning...
  18. taariq

    Syntax error in From clause

    Good day I am VCL I got my table ordered correctly now via SQL It is ordering DESC I got the last ID now in a DBText2 So all I have to figure out now is how to add +1 to the value and I assume update the following... iID:= StrToInt ( Inputbox ( 'ID' , 'ID' , '002' ) ) ; or dmTaS.tblJobCard['ID' ] := iID ; So the Delphi passes the next id on .... I think...
  19. taariq

    Syntax error in From clause

    Good day I got it to work now from Delphi side when I manual add the id... Now I see that the sort by does not work and I have to do it by SQL.. So now I am trying to figure out how to sort the db grid to get last ID record to get the next ID - is this correct ? please point me in the right direction.... Thank you
  20. taariq

    Syntax error in From clause

    Good day I got Flamerobin now to auto generate the id when I insert new record via Flamerobin But on my Delphi side it is still asking for valid ID? Sorry for all the question, but learning....
  21. taariq

    Syntax error in From clause

    thanks for the quick reply - I don't understand that - sorry newbie - first time working with Firebird and flamerobin... Maybe I created the table wrong - here is the code I used to created the table.. create table JobCard (id integer generated by default as identity primary key, orderno varchar(12), jobname varchar(100), startdate varchar(24), completiondate varchar(24), amountex varchar(12), desc varchar (50) );
  22. taariq

    Syntax error in From clause

    Good day I tried that already id Flamerobin and get the following error... Please view attached image
  23. taariq

    Syntax error in From clause

    Thank for all the help - really learning a lot now - thank you so much for your time and effort... So now I did the following... 1. Create my Firbird databse 2. Used FlameRobin 3. I added a record via Delphi to the database - so happy 4. Now I am trying to generate the ID next number so I don't have to manually add it... My code works all fine adding record, but not once I add the code to sort field to get ID vale... I get error under //get next ID procedure TMainForm.Button1Click(Sender: TObject); //declare my var to enter new job card var sOrderNo, sJobName , sStartDate, sCompletionDate, sAmountEx: string ; iID : integer; begin //assign values to input box //iID:= StrToInt ( Inputbox ( 'ID' , 'ID' , '002' ) ) ; sOrderNo := Inputbox ( 'OrderNo' , 'Enter OrderNo' , 'QU000' ) ; sJobName := Inputbox ( 'JobName' , 'Enter JobName' , 'Company Name' ) ; sStartDate := Inputbox ( 'StartDate' , 'Enter Start Date' , 'YYYY/MM/DD' ) ; sCompletionDate := Inputbox ( 'CompletionDate' , 'Enter Completion Date' , 'YYYY/MM/DD' ) ; sAmountEx := Inputbox ( 'AmountEx' , 'Enter Amount Ex' , 'R ' ) ; //get next ID dmTaS.tblJobCard.Sort := 'ID ASC' ; dmTaS.tblJobCard.Last; iID : = dmTaS.tblJobCard['ID'] + 1 ; //insert values to DBgrid dmTaS.tblJobCard.Insert ; dmTaS.tblJobCard['ID' ] := iID ; dmTaS.tblJobCard['OrderNo' ] := sOrderNo ; dmTaS.tblJobCard['JobName' ] := sJobName ; dmTaS.tblJobCard['StartDate' ] := sStartDate ; dmTaS.tblJobCard['CompletionDate' ] := sCompletionDate ; dmTaS.tblJobCard['AmountEx' ] := sAmountEx ; dmTaS.tblJobCard.Post ; //refresh db grid DBGrid1.DataSource.DataSet.Refresh; //show messages Thank you
  24. taariq

    Syntax error in From clause

    Thanks will have a look... Just a question if I have a field > ORDERNO , can I use that as my id as all tables will use the >orderno< to identify the records related to that order number... Or is it a must that I must have an id field.... Thank you
×