⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitsulfdate.~pas

📁 此代码为企业原料管理代码
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
      if recordcount=0 then  begin
        showmessage('无记录!');
        exit;
      end;
 end;//with }
  flt8:=0.00;
  flt1:=0.00;
  if (i=1) and (ename.text<>'') then
  begin
//===========初始化tableone,清空记录==========
  j:=1;
 with query1 do
      begin
        close;
        sql.Clear;
        sql.Add('delete from SulfCardPer ');
        execsql;
      end;

 //==过滤字典,求出厂价,净重,胶料价,加工费======
  dm.tabProdDictionary.Open;
  dm.tabProdDictionary.Filtered:=true;
  dm.tabProdDictionary.Filter:=format('prodid=''%s''',[edit1.text]);
  int6:=dm.tabProdDictionary.fieldbyname('gujia').asinteger;
  str2:=dm.tabProdDictionary.fieldbyname('figid').asstring; //图号
  str3:=dm.tabProdDictionary.fieldbyname('prodname').asstring; //产品名称
  flt3:=dm.tabProdDictionary.fieldbyname('Weight').asfloat; //单净重
  flt4:=dm.tabProdDictionary.fieldbyname('SellPrice').asfloat; //出厂价
  flt5:=dm.tabProdDictionary.fieldbyname('MakePrice').asfloat; //加工费
   str1:=dm.tabProdDictionary.fieldbyname('rubbname').asstring;
   str4:=dm.tabProdDictionary.fieldbyname('gjxh').asstring;//骨架型号
 // str5:=dm.tabProdDictionary.fieldbyname('thxh').asstring;//骨架型号
    with Query1 do
    begin
      close;
      //unprepare;
      SQL.Clear ;
      sql.Add (' select 单价 from 炼胶工艺卡');
      sql.Add (' where 制成品名称=:index');
      parambyname('index').asstring:=str1;
      open;
      flt6:=fieldbyname('单价').asfloat; //胶料价
      end;
     with Query1 do
    begin
      close;
      //unprepare;
      SQL.Clear ;
      sql.Add (' select 单价 from 原材料台帐');
      sql.Add (' where 材料名称=:index');
      parambyname('index').asstring:=str4;
      open;
      flt9:=fieldbyname('单价').asfloat; //骨架单价
      end;

 //====查询日清单===========================

//==========如果显示日=====================
if RBdate.Checked=true then
  begin
  //showmessage(eName.text);
  with queryone do
    begin
      close;
      //unprepare;
      SQL.Clear ;
      sql.Add (' select tdate,sum(qcnum)as SumQcNum,sum(DrawWeight)as sumDW,avg(MaterWeight)as SumMW,');
      sql.Add ('sum(lacknum)as SumLackNum,sum(impunum)as SumImpuNum,sum(polenum)as SumPoleNum,');
      sql.Add ('sum(ripnum)as SumRipNum,sum(elsenum)as SumElseNum from sulfcard');//,avg(单价)as avgrubbprce');
      sql.Add (' where prodnameid=:index and  tdate between :fromdate and :todate ');
      //sql.Add (' where prodnameid=:index and  tdate between :fromdate and :todate ');
      sql.Add ('group by tdate');
      parambyname('fromdate').asdate:=DateTimePicker3.date;
      parambyname('todate').asdate:=DateTimePicker4.date;
      parambyname('index').asstring:=edit1.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('tdate').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;
  flt2:=queryone.fieldbyname('sumDW').asfloat;//总领料
  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:=int5;
   //=========以下求废品之和/胶料损耗/金额损耗/合格率/利润率============
   flt9:=flt9*int6;
   int7:=int1+int2+int3+int4+int5;
  tableone.FieldByName('WasterPer').asfloat:=strtofloat(formatfloat('0.0',flt2-flt3*int0));//flt2-flt3*int0;胶料损耗
  flt2:=strtofloat(formatfloat('0.00',((flt2-flt3*int0)/(int0*flt3))*100));
  tableone.FieldByName('shl').asfloat:=flt2;
// 修改小数点
  clmodhu:=strtofloat(formatfloat('0.00',(flt2-flt3*int0)*flt6/1000+flt9*int7));
  tableone.FieldByName('Wastermoney').asfloat:=clmodhu;//金额损耗
  tableone.FieldByName('wasternum').asinteger:=int7;
  if int0+int1=0 then
     tableone.FieldByName('qcper').asfloat:=0
  else
    begin
    flt1:=int0/(int0+int7);
    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
  flt10:=flt7*flt6/1000;//每个胶价
  flt8:=(flt4-flt10-flt5-flt9-flt10*int7/int0-flt9*int7/int0)/(flt10+flt5+flt9+flt10*int7/int0+flt9*int7/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),avg(shl),sum(Wastermoney) from sulfcardper 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,prodnameid,sum(qcnum)as SumQcNum,sum(DrawWeight)as sumDW,avg(MaterWeight)as SumMW,');
      sql.Add ('sum(lacknum)as SumLackNum,sum(impunum)as SumImpuNum,sum(polenum)as SumPoleNum,sum(ripnum)as SumRipNum,');
      sql.Add ('sum(elsenum)as SumElseNum from SulfCard');
      //sql.Add (' where prodnameid=:index and  tdate between :fromdate and  :todate and SulfCard.生产批号 = 炼胶工艺卡.生产批号');
      sql.Add (' where prodnameid=:index and  tdate between :fromdate and  :todate ');
      sql.Add ('group by prodnameid,TMonth');
      parambyname('fromdate').asdate:=DateTimePicker3.date;
      parambyname('todate').asdate:=DateTimePicker4.date;
      parambyname('index').asstring:=edit1.text;
      prepare;
      open;
      if recordcount=0 then  begin
        showmessage('无记录!');
        exit;
      end;
 ///==========以上第一次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;
    flt2:=queryone.fieldbyname('sumDW').asfloat;//总领料
    //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:=int5;
   //=========以下求废品之和/胶料损耗/金额损耗/合格率/利润率============
   flt9:=flt9*int6;
   int1:=int1+int2+int3+int4+int5;
  tableone.FieldByName('WasterPer').asfloat:=strtofloat(formatfloat('0.0',flt2-flt3*int0));//flt2-flt3*int0;胶料损耗
  flt2:=strtofloat(formatfloat('0.00',((flt2-flt3*int0)/(int0*flt3))*100));
  tableone.FieldByName('shl').asfloat:=flt2;
  clmodhu:=strtofloat(formatfloat('0.00',(flt2-flt3*int0)*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
    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 sulfcardper 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 TFrmSulfDate.bbchartoneClick(Sender: TObject);
begin
  if (i=1)and(j=1) then //if1
  begin
if RBDate.Checked=true then
begin
 frmSulfPerChart.DBChart1.Title.Text.Text:='从'+datetostr(DateTimePicker3.date)+'到 '+datetostr(DateTimePicker4.date)+ tableone.fieldbyname('prodname').asstring+' 质量统计图表';
 frmSulfPerChart.show;
end;
if RBMonth.Checked=true then
begin
 frmSulfPerChartMonth.DBChart1.Title.Text.Text:='从'+datetostr(DateTimePicker3.date)+'到 '+datetostr(DateTimePicker4.date)+tableone.fieldbyname('prodname').asstring+' 质量统计图表';
 frmSulfPerChartMonth.show;
end;
  exit;
end;
 showmessage('请先按“查询”按键!');
end;

procedure TFrmSulfDate.RBDateClick(Sender: TObject);
begin
   j:=0;
  with query1 do
      begin
        close;
        sql.Clear;
        sql.Add('delete from SulfCardPer ');
        execsql;
      end;
       Tableone.open;
      Tableone.Refresh;
end;

procedure TFrmSulfDate.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;
      edit1.text:=FrmcommqueryID.query1.fieldbyname('prodid').asstring;
     end;
   end;
end;

procedure TFrmSulfDate.BitBtn7Click(Sender: TObject);
begin
tableone.open;;
dbgrid2.SetFocus;
tableone.Next;
end;

procedure TFrmSulfDate.BitBtn6Click(Sender: TObject);
begin
tableone.open;
dbgrid2.SetFocus;
tableone.prior;

end;

procedure TFrmSulfDate.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
//  showmessage(inttostr(iChaZhi));

// vdate:=DateTimePicker4.date-DateTimePicker3.date;
// showmessage(datetostr(vdate));

if   (iChaZhi = 30)  or(iChaZhi = 29 ) or(iChaZhi = 28 )or(iChaZhi = 31 ) then //if3
  FrmSulfPerPrintTwo.QRLabel.Caption:='        '+formatdatetime('mm',DateTimePicker4.date)+'月产品质量统计表'
else
  FrmSulfPerPrintTwo.QRLabel.Caption:='从'+datetostr(DateTimePicker3.date)+'到'+datetostr(DateTimePicker4.date)+' 产品质量统计表';
FrmSulfPerPrintTwo.QRLabelprod.Caption:=tableone.fieldbyname('prodname').asstring;
FrmSulfPerPrintTwo.QRLabelfigid.Caption:=tableone.fieldbyname('figid').asstring;
FrmSulfPerPrintTwo.QRLabeldate.Caption:=datetostr(date);
FrmSulfPerPrintTwo.QuickRep1.Preview;
end;//if3
if RBMonth.Checked=true then //if4
begin
tableone.open;
FrmSulfPerPrintTwoM.QRLabel.Caption:='产品质量统计表';
FrmSulfPerPrintTwoM.QRLabelprod.Caption:=tableone.fieldbyname('prodname').asstring;
FrmSulfPerPrintTwoM.QRLabelfigid.Caption:=tableone.fieldbyname('figid').asstring;
FrmSulfPerPrintTwoM.QRLabeldate.Caption:=datetostr(date);
FrmSulfPerPrintTwoM.QuickRep1.Preview;
end;//if 4
 exit;
end;//if2
 // exit;
showmessage('请先按“查询”按键!');
end;
// showmessage('请先按“查询”按键!');
procedure TFrmSulfDate.TabSheet1Show(Sender: TObject);
begin
 j:=0;
 i:=0;
 Tableone.close;
 Tableall.close;
end;

procedure TFrmSulfDate.DateTimePicker1Change(Sender: TObject);
begin
 i:=0;
end;

end.




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -