taariq
Members-
Content Count
29 -
Joined
-
Last visited
Everything posted by taariq
-
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
-
Good day I change the name of the edit box and the var
-
thanks for reply what I get, when using text and no StrTo
-
Good day Lets see if I got it now -
-
Good day I got a nice google video on how to run and use debugger... What I see now ...but still don't understand
-
Good day I got this ?
-
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
-
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
-
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....
-
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;
-
Good day I get runtime error? Sure I did something wrong - I did check my typing
-
Good day I did create Generator BUT for some reason Only works in Flamerobin and not in Delphi...
-
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' ) ) ;
-
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;
-
can you give me a code example and where will I use it - sorry dont understand 100%
-
Good day Yes sorry I used FDQuery to sort table... Sorry still learning...
-
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...
-
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
-
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....
-
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) );
-
Good day I tried that already id Flamerobin and get the following error... Please view attached image
-
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
-
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