提交 c0fe66d4 编写于 作者: cz_012273's avatar cz_012273

上传新文件

上级 bab21bd1
unit TiShi;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, FireDAC.Stan.Intf,
FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS,
FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt,
FireDAC.UI.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Phys,
FireDAC.Phys.SQLite, FireDAC.Phys.SQLiteDef, FireDAC.Stan.ExprFuncs,
FireDAC.Phys.SQLiteWrapper.Stat, FireDAC.VCLUI.Wait, Vcl.Mask, Vcl.DBCtrls,
Data.DB, FireDAC.Comp.Client, FireDAC.Comp.DataSet, Vcl.ExtCtrls, Vcl.Grids,
Vcl.DBGrids;
type
TForm6 = class(TForm)
Label1: TLabel;
FDQuery1: TFDQuery;
FDConnection1: TFDConnection;
DataSource1: TDataSource;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
DBGrid1: TDBGrid;
DBGrid2: TDBGrid;
FDQuery2: TFDQuery;
DataSource2: TDataSource;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure DBGrid2DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
uses pubunit;
{$R *.dfm}
procedure TForm6.Button1Click(Sender: TObject);
begin
close;
end;
procedure TForm6.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm6.FormShow(Sender: TObject);
begin
FDConnection1.Params.Add('Database=' + dbName);
FDConnection1.Connected := True;
with FDQuery1 do
begin
Close;
Open('SELECT 序号,品名,数量,入库日期,(case when julianday(入库日期) + 保质期(天) <= julianday(''now'') then ''已过期'' else ''未过期'' end ) as 过期提示 FROM 库存表');
Fields[0].DisplayWidth := 4; //这个宽度指字符数
Fields[1].DisplayWidth := 20;
Fields[2].DisplayWidth := 6;
Fields[3].DisplayWidth := 10;
Fields[4].DisplayWidth := 8;
end;
with FDQuery2 do
begin
Close;
Open('SELECT 序号,品名,数量,Max(出库日期),'+
'(case when julianday(出库日期) + 数量/(select count(*) from 人员表 where 所在部门(班组)= 出库表.所在部门(班组))*使用周期(天) <= julianday(''now'') then ''已到期'' else ''未到期'' end ) as 到期提示,'+
'领取人,所在部门(班组),(select count(*) from 人员表 where 所在部门(班组)= 出库表.所在部门(班组)) as 人数,使用周期(天) FROM 出库表 GROUP BY 所在部门(班组),品名 order by 所在部门(班组),品名');
Fields[0].DisplayWidth := 4; //这个宽度指字符数
Fields[1].DisplayWidth := 20;
Fields[2].DisplayWidth := 6;
Fields[3].DisplayWidth := 10;
Fields[4].DisplayWidth := 8;
Fields[5].DisplayWidth := 6;
Fields[6].DisplayWidth := 16;
Fields[7].DisplayWidth := 4;
Fields[8].DisplayWidth := 14;
end;
end;
procedure TForm6.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if column.fieldname='过期提示' then
begin
if FDQuery1.Fields[4].value= '已过期' then
begin
DBGrid1.Canvas.Font.Color := clred; //满足条件时,显示的字体颜色为“红色”
//DBGrid.Canvas.Brush.Color := clred; //满足条件时,显示的背景色颜色为“红色”
end
else
DBGrid1.Canvas.Font.Color := clblack;
end;
DBGrid1.DefaultDrawcolumnCell(Rect, DataCol, Column, State);
end;
procedure TForm6.DBGrid2DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if field.fieldname='到期提示' then
begin
if FDQuery2.Fields[4].value= '已到期' then
begin
DBGrid2.Canvas.Font.Color := clred; //满足条件时,显示的字体颜色为“红色”
//DBGrid.Canvas.Brush.Color := clred; //满足条件时,显示的背景色颜色为“红色”
end
else
DBGrid2.Canvas.Font.Color := clblack;
end;
DBGrid2.DefaultDrawDataCell(Rect, Field, State);
end;
end.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册