cgzxqk.pas
来自「一个仓库管理中的子系统--采购子系统」· PAS 代码 · 共 317 行
PAS
317 行
unit cgzxqk;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, ComCtrls, StdCtrls, Grids, ExtCtrls;
type
TcgzxqkForm = class(TForm)
Label1: TLabel;
Bevel1: TBevel;
StringGrid1: TStringGrid;
Bevel2: TBevel;
Label2: TLabel;
Label3: TLabel;
SpeedButton1: TSpeedButton;
yearCombo: TComboBox;
monthCombo: TComboBox;
StatusBar1: TStatusBar;
SpeedButton2: TSpeedButton;
SpeedButton7: TSpeedButton;
procedure FormActivate(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure SpeedButton1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton7Click(Sender: TObject);
private
procedure write_cgzxqc_table;
{ Private declarations }
public
{ Public declarations }
end;
var
cgzxqkForm: TcgzxqkForm;
implementation
uses sqbinput, htgl, Datamodule, cgzxqk_report;
{$R *.DFM}
procedure TcgzxqkForm.write_cgzxqc_table;
var I:Integer;
begin
with datamodule1.Query3 do
begin
Requestlive:=true;
sql.Clear;
sql.Add('select * From dbo.a_cgzxqk');
prepare;
open;
first;
if not isEmpty then
while not eof do
begin
delete;
end;
with stringGrid1 do
begin
For I:=1 to RowCount-1 do
begin
append;
FieldByName('tjxm').asstring:=Cells[0,I];
FieldByName('sqbsm').asInteger:=StrToInt(Cells[1,I]);
FieldByName('xmsm').asInteger:=StrToInt(Cells[2,I]);
FieldByName('cphjsm').asFloat:=StrToFloat(Cells[3,I]);
FieldByName('wcqk').asstring:=Cells[4,I];
post;
end;
end;
end;
end;
procedure TcgzxqkForm.FormActivate(Sender: TObject);
var I:Integer;
begin
datamodule1.PublicQuery1.RequestLive:=False;
datamodule1.publicQuery2.RequestLive:=false;
with stringGrid1 do
begin
cells[0,1]:='本年度';
Cells[0,2]:='本月份';
with datamodule1.PublicQuery1 do
begin
sql.Clear;
sql.Add('Select * From dbo.p_jhyb');
prepare;
open;
RowCount:=RecordCount+3;
For I:=1 to RecordCount do
begin
cells[0,I+2]:=FieldByName('jhy').asstring;
next;
end;
end;
{Cells[0,3]:='陈来运';
Cells[0,4]:='丁忠祜';
Cells[0,5]:='高源';
Cells[0,6]:='郭刚能';
Cells[0,7]:='黄炜东';
Cells[0,8]:='李明高';
Cells[0,9]:='吴桥悦';
Cells[0,10]:='郑锴';}
Cells[1,0]:='申请表(份数)';
cells[2,0]:='项目';
Cells[3,0]:='数量';
Cells[4,0]:='完成情况';
end;
end;
procedure TcgzxqkForm.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var Text:string;
begin
if arow=0 then
begin
stringgrid1.Canvas.Brush.Color:=grid_headcolor;
stringgrid1.Canvas.FillRect(rect);
htlrForm.writetext(stringgrid1.canvas,rect.left,rect.top,rect.right,rect.bottom,4,1,stringgrid1.cells[acol,arow],font,1,true);
exit;
end;
text:=stringgrid1.cells[acol,arow];
if (arow mod 2) =0 then stringgrid1.Canvas.Brush.Color:=grid_highcolor
else stringgrid1.Canvas.Brush.Color:=grid_lowcolor;
if gdSelected in state then stringgrid1.Canvas.Brush.Color:=grid_selectedcolor;
stringgrid1.Canvas.FillRect(rect);
htlrForm.writetext(stringgrid1.canvas,rect.left,rect.top,rect.right,rect.bottom,1,1,text,font,2,true);
end;
procedure TcgzxqkForm.SpeedButton1Click(Sender: TObject);
var MonthTablesum:Array [0..9] of integer;
MonthJobSum :Array [0..9] of Integer;
ProductSum :Array [0..9] of Real;
I:Integer;
yearTotalSum,monthTotalSum,jhyTotalsum: Real;
yearstr,monthstr:string;
begin
If (yearCombo.Text='') or (monthCombo.Text='') then
begin
showmessage('请您给出统计的时间范围!');
exit;
end;
yearstr:=Copy(yearCombo.Text,3,2);
if Length(monthCOmbo.text)=1 then
monthstr:='0'+MonthCombo.Text
else
monthstr:=MonthCombo.text;
yearTotalSum:=0;
MonthTotalSum:=0;
with datamodule1.PublicQuery1 do
begin
sql.Clear;
sql.Add('Select * From dbo.a_cgsqzb');
sql.Add('where sqbid like '+''''+yearstr+'%'+'''');
prepare;
open;
StringGrid1.Cells[1,1]:=IntToStr(RecordCount); //全年申请表数
sql.Clear;
sql.Add('Select * From dbo.a_cgsqxb');
sql.Add('where sqbid like '+''''+yearstr+'%'+'''');
prepare;
open;
First;
StringGrid1.Cells[2,1]:=IntToStr(RecordCount); //全年申请表中记录总数
while not Eof do
begin
yearTotalSum:=yearTotalSum+FieldByName('sbsl').asFloat;
next;
end;
end;
StringGrid1.Cells[3,1]:=Format('%8.2f',[yearTotalSum]); //全年采购产品数量总数
with datamodule1.publicQuery2 do
begin
sql.Clear;
sql.Add('select * from dbo.a_cgsqzb');
sql.Add('where sqbid like '+''''+yearstr+monthstr+'%'+'''');
prepare;
open;
StringGrid1.Cells[1,2]:=IntTostr(RecordCount);
sql.Clear;
sql.Add('select * from dbo.a_cgsqxb');
sql.Add('where sqbid like '+''''+yearstr+monthstr+'%'+'''');
prepare;
open;
StringGrid1.Cells[2,2]:=IntTostr(RecordCount);
while not Eof do
begin
monthTotalSum:=monthTotalSum+FieldByName('sbsl').asFloat;
next;
end;
end;
StringGrid1.Cells[3,2]:=Format('%8.2f',[monthTotalSum]);
For I:=0 To stringGrid1.RowCount-3 do
begin
JhyTotalSum:=0;
if length(inttostr(I+1))=1 then
begin
with datamodule1.publicQuery2 do
begin
sql.Clear;
sql.Add('select distinct sqbid from dbo.a_cgsqxb');
sql.Add('where sqbid like '+''''+yearstr+monthstr+'%'+''''+' and jhy='+''''+'0'+IntTostr(I+1)+'''');
prepare;
open;
monthTableSum[I]:=RecordCount;
sql.Clear;
sql.Add('select * from dbo.a_cgsqxb');
sql.Add('where sqbid like '+''''+yearstr+monthstr+'%'+''''+' and jhy='+''''+'0'+IntTostr(I+1)+'''');
prepare;
open;
first;
monthJobSum[I]:=RecordCount;
while not eof do
begin
jhyTotalSum:=jhyTotalSum+FieldByName('sbsl').asfloat;
next;
end;
ProductSum[I]:=JhyTotalSum;
end;
end;
{else
begin
with datamodule1.publicQuery2 do
begin
sql.Clear;
sql.Add('select distinct sqbid from dbo.a_cgsqxb');
sql.Add('where sqbid like '+''''+yearstr+monthstr+'%'+''''+' and jhy='+''''+IntTostr(I+1)+'''');
prepare;
open;
monthTableSum[I]:=RecordCount;
sql.Clear;
sql.Add('select * from dbo.a_cgsqxb');
sql.Add('where sqbid like '+''''+yearstr+monthstr+'%'+''''+' and jhy='+''''+IntTostr(I+1)+'''');
prepare;
open;
first;
monthJobSum[I]:=RecordCount;
while not eof do
begin
jhyTotalSum:=jhyTotalSum+FieldByName('sbsl').asfloat;
next;
end;
ProductSum[I]:=JhyTotalSum;
end;
end;}
end;
For I:=0 to stringGrid1.RowCount-3 do
with stringGrid1 do
begin
Cells[1,I+3]:=IntTostr(monthtableSum[I]);
Cells[2,I+3]:=IntTostr(MonthJobSum[I]);
Cells[3,I+3]:=Format('%.2f',[ProductSum[i]]);
end;
end;
procedure TcgzxqkForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
with datamodule1 do
begin
PublicQuery1.close;
PublicQuery2.close;
query3.RequestLive:=False;
query3.close;
end;
end;
procedure TcgzxqkForm.SpeedButton2Click(Sender: TObject);
begin
close;
end;
procedure TcgzxqkForm.SpeedButton7Click(Sender: TObject);
begin
write_cgzxqc_table;
with datamodule1.Query3 do
begin
sql.Clear;
sql.Add('select * From dbo.a_cgzxqk');
prepare;
open;
end;
cgzxqk_reportForm:=Tcgzxqk_reportForm.Create(Application);
//Report:=sqbReportform.QuickRep;
with Datamodule1.Query3 do
with cgzxqk_reportForm do
begin
tjxmQR.DataField:=FieldByName('tjxm').FieldName;
sqbsmQR.DataField:=FieldByname('sqbsm').FieldName;
xmsmQR.DataField:=FieldBYNAme('xmsm').FieldName;
cphjsmQR.DataField:=FieldByName('cphjsm').FieldName;
wcqkQR.DataField:=FieldByName('wcqk').FieldName;
end;
hide;
cgzxqk_reportForm.quickrep1.Preview;
cgzxqk_reportForm.Free;
show;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?