Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 10 of 10 total |
values from table in red color |
Sun, May 28 2006 4:36 AM | Permanent Link |
tom_po | i have a query in my delphi-application and want to show the fields with the
stock-quantity until 100 (and smaller) in red letters, how i do this? "stockfabric" is my table-name, "stock" is the fieldname with the quantities. (i use also in my query a 2.table "fabric", from where i bring other informations) i anexed also a picture of my table. this is my delphi-code: procedure TForm3.ToolButton3Click(Sender: TObject); begin DBISAMQuery1.SQL.Clear; DBISAMQuery1.SQL.Add('select code as "Código",desc as "Descrição",maq as "Maquina destinada",stock as "Quant.Stock",date as "Último movimento" from stockfabric,fabric where nr = 1 and stockfabric.code=fabric.code order by code'); DBISAMQuery1.ExecSQL; DBISAMQuery1.Edit; dbnavigator1.Visible := false; form3.Caption := 'Stock Agulhas'; end; Attachments: redletters.jpg |
Sun, May 28 2006 6:44 AM | Permanent Link |
"Ralf Mimoun" | tom_po wrote:
> i have a query in my delphi-application and want to show the fields > with the stock-quantity until 100 (and smaller) in red letters, how i > do this? Definitely not via SQL, but in the UI component you use. Search for events like OnCustomDraw, OnCellDraw etc., and press F1. .... > procedure TForm3.ToolButton3Click(Sender: TObject); > begin > DBISAMQuery1.SQL.Clear; > DBISAMQuery1.SQL.Add('select code as "Código",desc as "Descrição",maq > as "Maquina destinada",stock as "Quant.Stock",date as "Último > movimento" from stockfabric,fabric where nr = 1 and > stockfabric.code=fabric.code order by code'); A tip: you can ditch the .Clear and simply write: DBISAMQuery1.SQL.Text :=... Then: it's good practice to format he SQL statement (SELECT code AS..., with line breaks), and use always meaningful names for the components you touch! In three days, you will not know what DBISAMQuery1 does, connected via DataSource3 with DBGrid7. .... > tom_po wrote: > i have a query in my delphi-application and want to show the fields > with the stock-quantity until 100 (and smaller) in red letters, how i > do this? Definitely not via SQL, but in the UI component you use. Search for events like OnCustomDraw, OnCellDraw etc., and press F1. .... > procedure TForm3.ToolButton3Click(Sender: TObject); > begin > DBISAMQuery1.SQL.Clear; > DBISAMQuery1.SQL.Add('select code as "Código",desc as "Descrição",maq > as "Maquina destinada",stock as "Quant.Stock",date as "Último > movimento" from stockfabric,fabric where nr = 1 and > stockfabric.code=fabric.code order by code'); A tip: you can ditch the .Clear and simply write: DBISAMQuery1.SQL.Text :=... Then: it's good practice to format he SQL statement (SELECT code AS..., with line breaks), and use always meaningful names for the components you touch! In three days, you will not know what DBISAMQuery1 does, connected via DataSource3 with DBGrid7. .... > begin 0666 redletters.jpg Sorry, can't see the picture. 111 kb is also quite some bunch of data for a question. Please use th .binaries newsgroups for files. Ralf |
Sun, May 28 2006 8:03 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | tom_po
Its nothing to do with DBISAM but rather the control you're displaying the data in. Assuming you're using a standard DBGrid something like procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if DBISAMTable1.FieldByName('_OnFile').AsInteger > 5 then begin DBGrid1.Font.Color := clRed; end else DBGrid1.Font.Color := clBlack; end; Roy Lambert |
Mon, May 29 2006 4:16 AM | Permanent Link |
tom_po | Roy Lambert <roy.lambert@skynet.co.uk> wrote:
tom_po Its nothing to do with DBISAM but rather the control you're displaying the data in. Assuming you're using a standard DBGrid something like procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if DBISAMTable1.FieldByName('_OnFile').AsInteger > 5 then begin DBGrid1.Font.Color := clRed; end else DBGrid1.Font.Color := clBlack; end; Roy Lambert i tried with this, my table name is stockfabric, the fieldname is stock (data-type float): procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin DBISAMQuery1.SQL.text := 'select * from stockfabric'; DBISAMQuery1.ExecSQL; if dbisamtable1.FieldByName('stock').Asfloat <= 100 then begin dbisamdbgrid1.Font.Style := canvas.Font.Style + [fsBold]; dbisamdbgrid1.Font.Color := clred; end else dbisamDBGrid1.Font.Color := clBlack; dbisamdbgrid1.Canvas.FillRect(Rect); dbisamdbgrid1.DrawTextBiDiModeFlags(dbisamdbgrid1.Canvas.Handle); end; but it could not found the field then i tried the same code with ...if dbisamquery1.fieldbyname('stock').Asfloat <= 100 then... it works, but on the dbisamgrid the datas are running through the grid...what happened there? |
Mon, May 29 2006 5:53 AM | Permanent Link |
"Clive" | Use Open instead of ExecSQL.
"tom_po" <info@magoarte.com> wrote in message news:A55F070D-2C43-4DE3-879F-58D7376130ED@news.elevatesoft.com... > Roy Lambert <roy.lambert@skynet.co.uk> wrote: > > tom_po > > > Its nothing to do with DBISAM but rather the control you're displaying the > data in. > Assuming you're using a standard DBGrid something like > > procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; > DataCol: Integer; Column: TColumn; State: TGridDrawState); > begin > if DBISAMTable1.FieldByName('_OnFile').AsInteger > 5 then begin > DBGrid1.Font.Color := clRed; > end else DBGrid1.Font.Color := clBlack; > end; > > Roy Lambert > > i tried with this, my table name is stockfabric, the fieldname is stock > (data-type float): > > procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; > const Rect: TRect; DataCol: Integer; Column: TColumn; > State: TGridDrawState); > begin > DBISAMQuery1.SQL.text := 'select * from stockfabric'; > DBISAMQuery1.ExecSQL; > if dbisamtable1.FieldByName('stock').Asfloat <= 100 then > begin > dbisamdbgrid1.Font.Style := canvas.Font.Style + [fsBold]; > dbisamdbgrid1.Font.Color := clred; > end else dbisamDBGrid1.Font.Color := clBlack; > dbisamdbgrid1.Canvas.FillRect(Rect); > dbisamdbgrid1.DrawTextBiDiModeFlags(dbisamdbgrid1.Canvas.Handle); > end; > > but it could not found the field > > then i tried the same code with > > ..if dbisamquery1.fieldbyname('stock').Asfloat <= 100 then... > > it works, but on the dbisamgrid the datas are running through the > grid...what happened there? > |
Mon, May 29 2006 8:21 AM | Permanent Link |
"Ralf Mimoun" | tom_po wrote:
.... > procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; > const Rect: TRect; DataCol: Integer; Column: TColumn; > State: TGridDrawState); > begin > DBISAMQuery1.SQL.text := 'select * from stockfabric'; You don't want to execute that statement for every cell. Just use the dataset you display in the grid. Ralf |
Tue, May 30 2006 3:29 AM | Permanent Link |
Thomas | "Ralf Mimoun" <nospam@rad-on.de> wrote:
tom_po wrote: .... > procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; > const Rect: TRect; DataCol: Integer; Column: TColumn; > State: TGridDrawState); > begin > DBISAMQuery1.SQL.text := 'select * from stockfabric'; You don't want to execute that statement for every cell. Just use the dataset you display in the grid. Ralf want do you mean exactly with this Ralf? my code now: procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin DBISAMQuery1.SQL.text := 'select * from stockfabric'; DBISAMQuery1.Open; if dbisamquery1.FieldByName('stock').Asfloat = 100 then begin dbisamdbgrid1.Font.Style := canvas.Font.Style + [fsBold]; dbisamdbgrid1.Font.Color := clred; end else dbisamDBGrid1.Font.Color := clBlack; dbisamdbgrid1.Canvas.FillRect(Rect); dbisamdbgrid1.DrawTextBiDiModeFlags(dbisamdbgrid1.Canvas.Handle); end; i think, the problem is on the end..? |
Tue, May 30 2006 5:09 AM | Permanent Link |
"Clive" | The problem is you are reexecuting your query for every cell. And it wont
work this way. Firstly because when you execute your query, the rowid wont be matched with your dbgrid. Something like this is probably what you are after. procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if dbisamdbgrid1.datasource.dataset.FieldBYName('stock').Asfloat = 100 then begin dbisamdbgrid1.Font.Style := canvas.Font.Style + [fsBold]; dbisamdbgrid1.Font.Color := clred; end else dbisamDBGrid1.Font.Color := clBlack; dbisamdbgrid1.Canvas.FillRect(Rect); dbisamdbgrid1.DrawTextBiDiModeFlags(dbisamdbgrid1.Canvas.Handle); end; "Thomas" <info@magoarte.com> wrote in message news:DD602D9B-614E-4D84-943E-FFCFCE709F4E@news.elevatesoft.com... > "Ralf Mimoun" <nospam@rad-on.de> wrote: > > tom_po wrote: > ... >> procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; >> const Rect: TRect; DataCol: Integer; Column: TColumn; >> State: TGridDrawState); >> begin >> DBISAMQuery1.SQL.text := 'select * from stockfabric'; > > You don't want to execute that statement for every cell. Just use the > dataset you display in the grid. > > Ralf > > want do you mean exactly with this Ralf? > > my code now: > > procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; > const Rect: TRect; DataCol: Integer; Column: TColumn; > State: TGridDrawState); > begin > DBISAMQuery1.SQL.text := 'select * from stockfabric'; > DBISAMQuery1.Open; > if dbisamquery1.FieldByName('stock').Asfloat = 100 then > begin > dbisamdbgrid1.Font.Style := canvas.Font.Style + [fsBold]; > dbisamdbgrid1.Font.Color := clred; > end else dbisamDBGrid1.Font.Color := clBlack; > dbisamdbgrid1.Canvas.FillRect(Rect); > dbisamdbgrid1.DrawTextBiDiModeFlags(dbisamdbgrid1.Canvas.Handle); > end; > > i think, the problem is on the end..? > |
Tue, May 30 2006 6:49 AM | Permanent Link |
Thomas | i tried this already, but got the message: field stock cannot be found....
for further explanations, with button3 i do this first: procedure TForm3.ToolButton3Click(Sender: TObject); begin DBISAMQuery1.SQL.text := 'select code as "Código",desc as "Descrição",maq as "Maquina destinada",stock as "Quant.Stock",date as "Último movimento" from stockfabric,fabric where nr = 1 and stockfabric.code=fabric.code order by code'; dbisamquery1.ExecSQL; DBISAMQuery1.Edit; dbnavigator1.Visible := false; form3.Caption := 'Stock Agulhas'; end; then i try to show the quantities (stock) in red letters when it is 100 "Clive" <dd@dddd.com> wrote: The problem is you are reexecuting your query for every cell. And it wont work this way. Firstly because when you execute your query, the rowid wont be matched with your dbgrid. Something like this is probably what you are after. procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if dbisamdbgrid1.datasource.dataset.FieldBYName('stock').Asfloat = 100 then begin dbisamdbgrid1.Font.Style := canvas.Font.Style + [fsBold]; dbisamdbgrid1.Font.Color := clred; end else dbisamDBGrid1.Font.Color := clBlack; dbisamdbgrid1.Canvas.FillRect(Rect); dbisamdbgrid1.DrawTextBiDiModeFlags(dbisamdbgrid1.Canvas.Handle); end; "Thomas" <info@magoarte.com> wrote in message news:DD602D9B-614E-4D84-943E-FFCFCE709F4E@news.elevatesoft.com... > "Ralf Mimoun" <nospam@rad-on.de> wrote: > > tom_po wrote: > ... >> procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; >> const Rect: TRect; DataCol: Integer; Column: TColumn; >> State: TGridDrawState); >> begin >> DBISAMQuery1.SQL.text := 'select * from stockfabric'; > > You don't want to execute that statement for every cell. Just use the > dataset you display in the grid. > > Ralf > > want do you mean exactly with this Ralf? > > my code now: > > procedure TForm3.DBISAMDBGrid1DrawColumnCell(Sender: TObject; > const Rect: TRect; DataCol: Integer; Column: TColumn; > State: TGridDrawState); > begin > DBISAMQuery1.SQL.text := 'select * from stockfabric'; > DBISAMQuery1.Open; > if dbisamquery1.FieldByName('stock').Asfloat = 100 then > begin > dbisamdbgrid1.Font.Style := canvas.Font.Style + [fsBold]; > dbisamdbgrid1.Font.Color := clred; > end else dbisamDBGrid1.Font.Color := clBlack; > dbisamdbgrid1.Canvas.FillRect(Rect); > dbisamdbgrid1.DrawTextBiDiModeFlags(dbisamdbgrid1.Canvas.Handle); > end; > > i think, the problem is on the end..? > |
Tue, May 30 2006 7:39 AM | Permanent Link |
"Frans van Daalen" | "Thomas" <info@magoarte.com> wrote in message news:05CB9F01-1F10-4B26-94F6-43A6EED211DB@news.elevatesoft.com... >i tried this already, but got the message: field stock cannot be found.... > > for further explanations, with button3 i do this first: > > procedure TForm3.ToolButton3Click(Sender: TObject); > begin > DBISAMQuery1.SQL.text := 'select code as "Código",desc as "Descrição",maq > as "Maquina > destinada",stock as "Quant.Stock",date as "Último movimento" from > stockfabric,fabric where > nr = 1 and stockfabric.code=fabric.code order by code'; > dbisamquery1.ExecSQL; > DBISAMQuery1.Edit; > dbnavigator1.Visible := false; > form3.Caption := 'Stock Agulhas'; > end; > because you renamed the table field stock to the resultname Quant.Stock so your code should be something like if dbisamquery1.FieldByName('Quant.Stock').Asfloat = 100 then ^^^^^^^^^^^^^^^ |
This web page was last updated on Thursday, May 23, 2024 at 07:54 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |