📄 unit_mater_sumcfg.~pas
字号:
close;
sql.Clear;
sql.Add('delete from baobiao ');
execsql;
end; //with
with Qry_Sum do
begin
open;
first;
while not eof do
begin
Table1.Open;
Table1.append;
Table1.fieldbyname('材料名称').asstring:=fieldbyname('材料名称').asstring;
Table1.fieldbyname('上月库存').asfloat:=strtofloat(formatfloat('0.000',fieldbyname('上月库存').asfloat));
Table1.fieldbyname('本月入库').asfloat:=strtofloat(formatfloat('0.000',fieldbyname('本月入库').asfloat));
Table1.fieldbyname('本月出库').asfloat:=strtofloat(formatfloat('0.000',fieldbyname('本月出库').asfloat));
Table1.fieldbyname('本月库存').asfloat:=strtofloat(formatfloat('0.000',fieldbyname('本月库存').asfloat));
Table1.fieldbyname('单价').asfloat:=strtofloat(formatfloat('0.00',fieldbyname('单价').asfloat));
Table1.fieldbyname('出库总价').asfloat:=strtofloat(formatfloat('0.00',fieldbyname('出库总价').asfloat));
Table1.fieldbyname('库存总价').asfloat:=strtofloat(formatfloat('0.00',fieldbyname('库存总价').asfloat));
Table1.post;
Table1.close;
next;
end;
Table1.open;
end;
with Qry_Sum do
begin
close;
sql.Clear;
sql.Add('select 材料名称, ');
sql.Add('sum(上月库存) as 上月库存, ');
sql.Add('sum(本月入库) as 本月入库, ');
sql.Add('sum(本月出库) as 本月出库, ');
sql.Add('sum(本月库存) as 本月库存, ');
sql.Add('sum(单价) as 单价,');
sql.Add('sum(出库总价) as 出库总价,');
sql.Add('sum(库存总价) as 库存总价');
if messagedlg('是打印期报表吗?',mtWarning,[mbYes,mbNo],0) = mrYes then
begin
sql.Add('from baobiao where 本月入库<>0 or 本月出库<>0');
sql.Add('group by 材料名称 ');
open;
//打印报表
Form_Mater_PrtSum.QRLabelb1.Caption:='';
Form_Mater_PrtSum.QRLabelb2.Caption:='';
Form_Mater_PrtSum.QRLabelb3.Caption:='';
Form_Mater_PrtSum.QRLabelb4.Caption:='';
Form_Mater_PrtSum.QRLabelb5.Caption:='';
with query1 do
begin
close;
sql.Clear;
sql.Add('select * from mater ');
open;
if recordcount=0 then
Form_Mater_PrtSum.QRLab_DateRange.Caption:=formatdatetime('yy"年"mm"月"dd"日"',DateTimePicker_From.Date)+'----'+formatdatetime('yy"年"mm"月"dd"日"',d_to);
if recordcount<>0 then
Form_Mater_PrtSum.QRLab_DateRange.Caption:=formatdatetime('yy"年"mm"月"dd"日"',dm.zdyGetmaterCheckDate)+'----'+formatdatetime('yy"年"mm"月"dd"日"',d_to);
end;
Form_Mater_PrtSum.QRLabelLast.Caption:='上期库存';
Form_Mater_PrtSum.QRLabel_In.Caption:='本期入库';
Form_Mater_PrtSum.QRLabel_Out.Caption:='本期出库';
Form_Mater_PrtSum.QRLabel_Stock.Caption:='本期库存';
Form_Mater_PrtSum.QRLab_IfMon.Caption:='期报表';
BitBtn1.Cursor:=crDefault;
Form_Mater_PrtSum.QuickRep1.Preview;
exit;
end;
sql.Add('from baobiao');
sql.Add('group by 材料名称 ');
open;
end; //with
//写入Ini文件 结账日期
if d_LimDate < strtodate(s_to) then
begin
JLSumSys:=TIniFile.Create('Jl2000.ini');
JLSumSys.WriteDate('SumDate','date' , strtodate(s_to));
JLSumSys.free;
d_LimDate:=strtodate(s_to);
end; //if
//打印报表
Form_Mater_PrtSum.QRLabelb1.Caption:='';
Form_Mater_PrtSum.QRLabelb2.Caption:='';
Form_Mater_PrtSum.QRLabelb3.Caption:='';
Form_Mater_PrtSum.QRLabelb4.Caption:='';
Form_Mater_PrtSum.QRLabelb5.Caption:='';
with query1 do
begin
close;
sql.Clear;
sql.Add('select * from mater ');
open;
if recordcount=0 then
Form_Mater_PrtSum.QRLab_DateRange.Caption:=formatdatetime('yy"年"mm"月"dd"日"',DateTimePicker_From.Date)+'----'+formatdatetime('yy"年"mm"月"dd"日"',d_to);
if recordcount<>0 then
Form_Mater_PrtSum.QRLab_DateRange.Caption:=formatdatetime('yy"年"mm"月"dd"日"',dm.zdyGetmaterCheckDate)+'----'+formatdatetime('yy"年"mm"月"dd"日"',d_to);
end;
//判断是不是月报表
while d_To > d_from do
begin
d_to:=d_to-1;
inc(n_DateMinus);
end;
// showmessage(format('%d',[n_DateMinus]));
if (( n_DateMinus >= 28) and (n_DateMinus <= 32 )) then //是月报表
begin
Form_Mater_PrtSum.QRLabelLast.Caption:='上月库存';
Form_Mater_PrtSum.QRLabel_In.Caption:='本月入库';
Form_Mater_PrtSum.QRLabel_Out.Caption:='本月出库';
Form_Mater_PrtSum.QRLabel_Stock.Caption:='本月库存';
Form_Mater_PrtSum.QRLab_IfMon.Caption:='月报表';
end
else
begin
Form_Mater_PrtSum.QRLabelLast.Caption:='上期库存';
Form_Mater_PrtSum.QRLabel_In.Caption:='本期入库';
Form_Mater_PrtSum.QRLabel_Out.Caption:='本期出库';
Form_Mater_PrtSum.QRLabel_Stock.Caption:='本期库存';
Form_Mater_PrtSum.QRLab_IfMon.Caption:='期报表';
end;
with query1 do
begin
close;
sql.Clear;
sql.Add('update 结账月份 set IfSum = false');
execsql;
end;//with
with query1 do
begin
close;
sql.Clear;
sql.Add('update 结账月份 set IfSum = true where Id = :m');
parambyname('m').asinteger:=strtoint(formatdatetime('m',d_to))+1;
execsql;
end;//with
if edit1.text='1' then
Form_Mater_PrtSum.QRLabel10.Caption:='化工原辅材料报表';
if edit1.text='2' then
Form_Mater_PrtSum.QRLabel10.Caption:='杂品仓库报表';
BitBtn1.Cursor:=crDefault;
Form_Mater_PrtSum.QuickRep1.Preview;
with dm.table3 do
begin
open;
append;
fieldbyname('mDate').asdatetime:=Form_Mater_SumCfg.DateTimePicker_To.date;
post;
close;
end; //with
zdymaterCheckDiary(); //显示结帐日期表
Panel2.caption:='只设截止日期';
DateTimePicker_From.visible:=false;
DateTimePicker_From.enabled:=false;
Label1.caption:='上次结帐日期是'+datetostr( dm.zdyGetmaterCheckDate);
if Panel2.caption='起始日期' then
Label1.caption:='没结过帐,请输入结帐起始日期:';
end;
procedure TForm_Mater_SumCfg.BitBtn2Click(Sender: TObject);
begin
Form_mater_sumCfg.close;
end;
procedure TForm_Mater_SumCfg.FormShow(Sender: TObject);
begin
zdymaterCheckDiary(); //显示结帐日期表
edit1.Text:='1';
Panel2.caption:='只设截止日期';
DateTimePicker_From.visible:=false;
DateTimePicker_From.enabled:=false;
Label1.caption:='上次结帐日期是'+datetostr( dm.zdyGetmaterCheckDate);
if Panel2.caption='起始日期' then
Label1.caption:='没结过帐,请输入结帐起始日期:';
DateTimePicker_From.date :=date-30;
DateTimePicker_To.date :=date;
end;
procedure TForm_Mater_SumCfg.zdymaterCheckDiary();
var
dDate:Tdate;
begin
Listbox1.Clear;
with dm.table3 do
begin
open;
first;
while not eof do
begin
dDate:=fieldbyname('mDate').asdatetime;
listbox1.items.append(datetostr(dDate));
next;
end; //while
close;
end; //with
listbox1.ItemIndex:=listbox1.Items.Count ;
end;
procedure TForm_Mater_SumCfg.Button1Click(Sender: TObject);
var
dDate:Tdate;
JLSumSys:TIniFile;
begin
//===================================
// 修改 ProdCheckDiary最后一条记录
//===================================
with dm.table3 do
begin
open;
if recordcount = 0 then
begin
dm.table3.close;
exit;
end;
last;
delete;
zdymaterCheckDiary;//上次结帐日期
close;
end; //with //写入Ini文件 结账日期
dDate:=dm.zdyGetmaterCheckDate; //显示修改后的日期
// showmessage(datetostr(dDate));
if d_LimDate> dDate then
begin
JLSumSys:=TIniFile.Create('Jl2000.ini');
JLSumSys.WriteDate('SumDate','date' , dDate);
JLSumSys.free;
d_LimDate:=dDate;
// showmessage(datetostr(dDate));
end; //if
Form_mater_sumCfg.close;
Form_mater_sumCfg.Show;
end;
procedure TForm_Mater_SumCfg.Edit1Click(Sender: TObject);
begin
if edit1.text='1' then
begin
edit1.text:='2';
exit;
end;
if edit1.text='2' then
edit1.text:='1';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -