📄 unit_modechan.pas
字号:
open;
flt9:=fieldbyname('单价').asfloat; //骨架单价
end;
with Query1 do
begin
close;
//unprepare;
SQL.Clear ;
sql.Add (' select 单价 from 原材料台帐');
sql.Add (' where 材料名称=:index');
parambyname('index').asstring:=str5;
open;
flt10:=fieldbyname('单价').asfloat; //骨架单价
end;
//====查询日清单===========================
//==========如果显示日=====================
if RBdate.Checked=true then begin
with queryone do
begin
close;
//unprepare;
SQL.Clear ;
sql.Add (' select riqi,sum(hao)as SumQcNum,sum(lin)as sumDW,');
sql.Add ('sum(xioufei)as SumLackNum,sum(huai)as SumImpuNum');
sql.Add (' from zhenxiou');//,avg(单价)as avgrubbprce');
sql.Add (' where prodid=:index and riqi between :fromdate and :todate ');
//sql.Add (' where prodnameid=:index and tdate between :fromdate and :todate ');
sql.Add ('group by riqi');
parambyname('fromdate').asdate:=DateTimePicker3.date;
parambyname('todate').asdate:=DateTimePicker4.date;
parambyname('index').asstring:=eName.text;
// prepare;
open;
if recordcount=0 then begin
showmessage('无记录!');
exit;
end;
end;//with
//=========以下把Query2中查询过滤结果向抄写到table1中====================
//TableoneTMonth.visible:=false;
//TableoneTDate.visible:=true;
queryone.First;
tableone.open;
while not queryone.eof do
begin
tableone.DisableControls;
tableone.append;
tableone.FieldByName('tdate').asdatetime:=queryone.fieldbyname('riqi').asdatetime;
tableone.FieldByName('Figid').asstring:=str2;
tableone.FieldByName('prodname').asstring:=str3;
tableone.FieldByName('qcnum').asinteger:=queryone.fieldbyname('sumqcnum').asinteger;
//tableone.FieldByName('生产批号').asstring:=queryone.fieldbyname('生产批号').asstring;
// tableone.FieldByName('sourceid').asstring:=queryone.fieldbyname('sourceid').asstring;
int0:=tableone.FieldByName('qcnum').asinteger;
int1:=queryone.fieldbyname('sumlacknum').asinteger;
int2:=queryone.fieldbyname('sumimpunum').asinteger;
//int3:=queryone.fieldbyname('sumripnum').asinteger;
//int4:=queryone.fieldbyname('sumpolenum').asinteger;
//int5:=queryone.fieldbyname('sumelsenum').asinteger;
int3:=queryone.fieldbyname('sumDW').asinteger;//总领坯
//flt7:=queryone.fieldbyname('SumMW').asfloat;//平均料重
// flt6:=queryone.fieldbyname('avgrubbprce').asfloat; //胶料价
tableone.FieldByName('lacknum').asinteger:=int1;
tableone.FieldByName('impunum').asinteger:=int2;
//tableone.FieldByName('polenum').asinteger:=int4;
//tableone.FieldByName('ripnum').asinteger:=int3;
tableone.FieldByName('elsenum').asinteger:=int3;
//=========以下求废品之和/胶料损耗/金额损耗/合格率/利润率============
flt9:=flt9*int6;
int1:=int1+int2;
tableone.FieldByName('WasterPer').asfloat:=strtofloat(formatfloat('0.0',flt3*int1));//胶料损耗
// 修改小数点
clmodhu:=strtofloat(formatfloat('0.00',(flt3*int1*flt6/1000+flt9*int1)));
tableone.FieldByName('Wastermoney').asfloat:=clmodhu;//金额损耗
tableone.FieldByName('wasternum').asinteger:=int1;
if int0+int1=0 then
tableone.FieldByName('qcper').asfloat:=0
else
begin
flt1:=int0/(int0+int1);
flt1:=strtofloat(formatfloat('0.00',flt1*100));
tableone.FieldByName('qcper').asfloat:=flt1;//合格率
end;
//if flt7*flt6+flt5=0 then
// tableone.FieldByName('ProfitPer').asfloat:=0
// else
// begin
// flt9:=flt9+flt10*int7;
//flt8:=(flt4-flt7*flt6/1000-flt5-flt9-flt7*int1/int0*flt6/1000-flt9*int1/int0)/(flt7*flt6/1000+flt5+flt9+flt7*int1/int0*flt6/1000+flt9*int1/int0);
// flt8:=strtofloat(formatfloat('0.00',flt8*100));
//tableone.FieldByName('ProfitPer').asfloat:=flt8;//利润率
// end;
tableone.post;
queryone.next;
tableone.EnableControls;
end;//while
//========以上向用户界面Table1中抄写记录完===================
//========以下Query1为输出图表和打印查询过滤=================
with SulfqueryPerDate do begin
close;
Unprepare;
sql.Clear;
sql.add('select tdate,prodname,figid,sum(qcnum),sum(wasternum),avg(qcper),avg(ProfitPer),');
sql.add('sum(WasterPer),sum(Wastermoney) from modeper group by tdate,prodname,figid');
Prepare;
open;
end;//with
DBGrid2.Columns[0].Visible:=false;
DBGrid2.Columns[1].Visible:=true;
end;//========显示日结束=================
//======以下是如果显示月份======================
if RBMonth.Checked=true then begin
with queryone do
begin
close;
unprepare;
SQL.Clear ;
sql.Add (' select tmonth,prodid,sum(hao)as SumQcNum,sum(lin)as sumDW,');
sql.Add ('sum(xioufei)as SumLackNum,sum(huai)as SumImpuNum');
sql.Add (' from zhenxiou');
//sql.Add (' where prodnameid=:index and tdate between :fromdate and :todate and SulfCard.生产批号 = 炼胶工艺卡.生产批号');
sql.Add (' where prodid=:index and riqi between :fromdate and :todate ');
sql.Add ('group by prodid,TMonth');
parambyname('fromdate').asdate:=DateTimePicker3.date;
parambyname('todate').asdate:=DateTimePicker4.date;
parambyname('index').asstring:=eName.text;
prepare;
open;
///==========以上第一次SQL查询结束====================
end;//with
//=========以下把Query2中查询过滤结果向抄写到table1中====================
//TableoneTMonth.visible:=true;
//TableoneTDate.visible:=false;
tableone.open;
queryone.First;
while not queryone.eof do
begin
tableone.DisableControls;
tableone.append;
tableone.FieldByName('figid').asstring:=str2;
tableone.FieldByName('prodname').asstring:=str3;
tableone.FieldByName('TMonth').asstring:=queryone.fieldbyname('Tmonth').asstring;
tableone.FieldByName('qcnum').asinteger:=queryone.fieldbyname('sumqcnum').asinteger;
int0:=tableone.FieldByName('qcnum').asinteger;
int1:=queryone.fieldbyname('sumlacknum').asinteger;
int2:=queryone.fieldbyname('sumimpunum').asinteger;
//int3:=queryone.fieldbyname('sumripnum').asinteger;
//int4:=queryone.fieldbyname('sumpolenum').asinteger;
//int5:=queryone.fieldbyname('sumelsenum').asinteger;
int3:=queryone.fieldbyname('sumDW').asinteger;//总领坯
//flt6:=queryone.fieldbyname('avgrubbprce').asfloat; //胶料价
//flt7:=queryone.fieldbyname('SumMW').asfloat;//平均料重
tableone.FieldByName('lacknum').asinteger:=int1;
tableone.FieldByName('impunum').asinteger:=int2;
//tableone.FieldByName('polenum').asinteger:=int4;
//tableone.FieldByName('ripnum').asinteger:=int3;
tableone.FieldByName('elsenum').asinteger:=int3;
//=========以下求废品之和/胶料损耗/金额损耗/合格率/利润率============
flt9:=flt9*int6;
int1:=int1+int2;
tableone.FieldByName('WasterPer').asfloat:=strtofloat(formatfloat('0.0',flt3*int1));//胶料损耗
clmodhu:=strtofloat(formatfloat('0.00',flt3*int1*flt6/1000+flt9*int1));
tableone.FieldByName('Wastermoney').asfloat:=clmodhu;//金额损耗
tableone.FieldByName('wasternum').asinteger:=int1; //废品之和
if int0+int1=0 then
tableone.FieldByName('qcper').asfloat:=0
else
begin
flt1:=int0/(int0+int1);
flt1:=strtofloat(formatfloat('0.00',flt1*100));
tableone.FieldByName('qcper').asfloat:=flt1;//合格率
end;
// if flt7*flt6+flt5=0 then
// tableone.FieldByName('ProfitPer').asfloat:=0
// else
// begin
// flt9:=flt9+flt10*int7;
//flt8:=(flt4-flt7*flt6/1000-flt5-flt9-flt7*int1/int0*flt6/1000-flt9*int1/int0)/(flt7*flt6/1000+flt5+flt9+flt7*int1/int0*flt6/1000+flt9*int1/int0);
//flt8:=strtofloat(formatfloat('0.00',flt8*100));
//tableone.FieldByName('ProfitPer').asfloat:=flt8;//利润率
// end;
tableone.post;
queryone.next;
tableone.EnableControls;
end;//while
//========以上向用户界面Table1中抄写记录完===================
with SulfqueryPerMonth do begin
close;
Unprepare;
sql.Clear;
sql.add('select tmonth,prodname,figid,sum(qcnum),sum(wasternum),avg(qcper),avg(ProfitPer),');
sql.add('sum(WasterPer),sum(Wastermoney) from modeper group by tmonth,prodname,figid');
Prepare;
open;
end;//with
DBGrid2.Columns[0].Visible:=true;
DBGrid2.Columns[1].Visible:=false;
end;//========显示月份结束=================
//==================结束========================================
exit;
end;
showmessage('请先输入产品名称!');
end;
procedure TForm_modechan.enameEnter(Sender: TObject);
begin
j:=0;
i:=1;
tableone.Close;
ename.Text:='';
if CheckBoxdic.Checked = true then begin
FrmcommqueryID.PageControl1.ActivePageIndex:=1;
if FrmcommqueryID.showmodal=mrok then
begin
ename.text:=FrmcommqueryID.query1.fieldbyname('prodid').asstring;
end;
end;
end;
procedure TForm_modechan.RBDateClick(Sender: TObject);
begin
j:=0;
with query1 do
begin
close;
sql.Clear;
sql.Add('delete from modePer ');
execsql;
end;
Tableone.open;
Tableone.Refresh;
end;
procedure TForm_modechan.BitBtn3Click(Sender: TObject);
begin
close;
end;
procedure TForm_modechan.BitBtn6Click(Sender: TObject);
begin
tableone.open;
dbgrid2.SetFocus;
tableone.prior;
end;
procedure TForm_modechan.BitBtn7Click(Sender: TObject);
begin
tableone.open;
dbgrid2.SetFocus;
tableone.next;
end;
procedure TForm_modechan.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
with query1 do
begin
close;
sql.Clear;
sql.Add('delete from modeDate ');
execsql;
end;
with query1 do
begin
close;
sql.Clear;
sql.Add('delete from modePer ');
execsql;
end;
tableall.close;
tableone.close;
ename.text:='';
Form_modechanprt.close;
Form_modechanChart.close;
Form_modechandate.close;
Form_modepermonth.close;
Form_modechandatechart.close;
Form_modechanmonchart.Close;
end;
procedure TForm_modechan.BBPrinttweClick(Sender: TObject);
var
dDatefrom,dDateTo:Tdate;
iChaZhi:integer;
begin
if (i=1)and(j=1) then //if1
begin
if RBDate.Checked=true then //if2
begin
iChaZhi:=0;
dDatefrom:=strtodate(datetostr(DateTimePicker3.date));
dDateto:=strtodate(datetostr(DateTimePicker4.date));
while not (dDatefrom = dDateto) do
begin
Ddateto:=Ddateto-1;
iChaZhi:=iChaZhi+1;
end; //while
if (iChaZhi = 30) or(iChaZhi = 29 ) or(iChaZhi = 28 )or(iChaZhi = 31 ) then //if3
Form_modechandate.QRLabel.Caption:=' '+formatdatetime('mm',DateTimePicker4.date)+'月产品整修质量统计表'
else
Form_modechandate.QRLabel.Caption:='从'+datetostr(DateTimePicker3.date)+'到'+datetostr(DateTimePicker4.date)+' 产品整修质量统计表';
Form_modechandate.QRLabelprod.Caption:=tableone.fieldbyname('prodname').asstring;
Form_modechandate.QRLabelfigid.Caption:=tableone.fieldbyname('figid').asstring;
Form_modechandate.QRLabeldate.Caption:=datetostr(date);
Form_modechandate.QuickRep1.Preview;
end;//if3
if RBMonth.Checked=true then //if4
begin
tableone.open;
Form_modepermonth.QRLabel.Caption:='产品整修质量统计表';
Form_modepermonth.QRLabelprod.Caption:=tableone.fieldbyname('prodname').asstring;
Form_modepermonth.QRLabelfigid.Caption:=tableone.fieldbyname('figid').asstring;
Form_modepermonth.QRLabeldate.Caption:=datetostr(date);
Form_modepermonth.QuickRep1.Preview;
end;//if 4
exit;
end;//if2
// exit;
showmessage('请先按“查询”按键!');
end;
procedure TForm_modechan.TabSheet1Exit(Sender: TObject);
begin
Tableall.Close;
end;
procedure TForm_modechan.TabSheet2Exit(Sender: TObject);
begin
Tableone.Close;
end;
procedure TForm_modechan.bbchartoneClick(Sender: TObject);
begin
if (i=1)and(j=1) then //if1
begin
if RBDate.Checked=true then
begin
Form_modechandatechart.DBChart1.Title.Text.Text:='从'+datetostr(DateTimePicker3.date)+'到 '+datetostr(DateTimePicker4.date)+ tableone.fieldbyname('prodname').asstring+' 整修质量统计图表';
Form_modechandatechart.show;
end;
if RBMonth.Checked=true then
begin
Form_modechanmonchart.DBChart1.Title.Text.Text:='从'+datetostr(DateTimePicker3.date)+'到 '+datetostr(DateTimePicker4.date)+tableone.fieldbyname('prodname').asstring+' 整修质量统计图表';
Form_modechanmonchart.show;
end;
exit;
end;
showmessage('请先按“查询”按键!');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -