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

📄 scbrow.~pas

📁 实用的毛织生产管理系统
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
          if inmxqy.FieldByName('gxno').asstring <> '' then
          begin
             sch2.SQL.clear;
             sch2.SQL.Add('select * from scpo where pno=:pno and  gxNO=:gxNO and dept=:dept');
             sch2.ParamByName('pno').AsString:=inmxqy.FieldByName('pno').asstring;
             sch2.ParamByName('gxNO').AsString:=inmxqy.FieldByName('gxno').asstring ;
             sch2.ParamByName('dept').AsString:=combobox3.Text;
             sch2.Open;

            if sch2.RecordCount>0 then
            begin
              scprice :=sch2.FieldByName('scprice').asfloat;
              if scprice > 0 then
                begin
                inmxqy.FieldByName('inprice').AsFloat := scprice;
                inmxqy.FieldByName('scgx').asstring:= sch2.FieldByName('scgx').asstring;
                end;
            end;
          end;
        end;
    {  2:
        begin
          if inmxqy.FieldByName('scgx').asstring <> '' then
          begin
//                            tablenm, fieldnm, fieldnm1,fieldnm2, fieldtxt,fieldtxt1:string
            if searchfieldgx('scgx', 'scgxno', 'scgx', 'dept', inmxqy.FieldByName('scgx').asstring, combobox3.text) <> '' then
            begin
              inmxqy.FieldByName('scgx').asstring := searchfieldgx('scgx', 'scgxno', 'scgx', 'dept', inmxqy.FieldByName('scgx').asstring, combobox3.text);
              
              if scprice > 0 then
                inmxqy.FieldByName('inprice').AsFloat := scprice;
            end;
          end;
        end;  }
      4, 5,6:
        begin
          if pos('时工', inmxqy.FieldByName('sg').asstring) <= 0 then
            inmxqy.FieldByName('totalin').asfloat :=
              strtofloat(formatfloat('0.0',
              inmxqy.FieldByName('innum').asfloat *
              inmxqy.FieldByName('inprice').asfloat / PBNumEdit2.value))
          else
              inmxqy.FieldByName('totalin').asfloat :=
              strtofloat(formatfloat('0.0',
              inmxqy.FieldByName('innum').asfloat *
              inmxqy.FieldByName('inprice').asfloat));
          inmxqy.FieldByName('dept1').Asstring :=combobox3.Text;              
        end;

    end;
  end;
end;

procedure Tscbrowfm.DBGridEh3EditButtonClick(Sender: TObject);
begin
  case dbgrideh3.SelectedIndex of
    1:
      begin
        schpnoflg := true;
        pno := '';
        if not assigned(pnmanagefm) then
          pnmanagefm := tpnmanagefm.create(application);
        pnmanagefm.formstyle := fsnormal;
        pnmanagefm.Visible := false;
        pnmanagefm.Position := poScreenCenter;

        pnmanagefm.WindowState := wsnormal;
        scbrowfm.WindowState := wsMaximized;
        pnmanagefm.Showmodal;
        inmxqy.Edit;
        if pno <> '' then
        begin
          inmxqy.FieldByName('pno').asstring := pno;
          button2.Enabled := true;
        end;
      end;
   3:
      begin
    {   schscgxflg := true;
        if not assigned(gxmanagefm) then
        gxmanagefm := tgxmanagefm.create(application);

       gxmanagefm.dept:=combobox3.text;
       gxmanagefm.formstyle := fsnormal;
       gxmanagefm.Position := poScreenCenter;

        gxmanagefm.WindowState := wsnormal;
        scbrowfm.WindowState := wsMaximized;
        gxmanagefm.Showmodal;
        gxmanagefm.Visible := false;     }
  schscgxflg :=true;// false;
  if not assigned(ppricefm) then
    ppricefm := tppricefm.create(application);
    ppricefm.formstyle := fsmdichild;
    ppricefm.Visible := true;
    ppricefm.COMBOBOX1.TEXT:=inmxqy.FieldByName('PNO').asstring;
    ppricefm.ComboBox2.Text:=combobox3.text;
  //gxmanagefm.WindowState := wsMaximized;
    ppricefm.Left := 0;
    ppricefm.top := 0;
    scbrowfm.WindowState := wsMaximized;
    ppricefm.Show;

    inmxqy.Edit;
    if scgx <> '' then
        begin
         //  inmxqy.FieldByName('scgx').asstring := scgx;
          { inmxqy.FieldByName('inprice').asfloat := scprice;
          if inmxqy.state in [dsinsert, dsedit] then
            inmxqy.FieldByName('totalin').asfloat :=
              inmxqy.FieldByName('innum').asfloat *
              inmxqy.FieldByName('inprice').asfloat;   }
          button2.Enabled := true;
        end;

      end;
  end;

end;

procedure Tscbrowfm.SpinEdit4Exit(Sender: TObject);
begin
  maxday := monthdays[IsLeapYear(spinedit1.Value)][spinedit2.Value];
end;

procedure Tscbrowfm.SpinEdit5Exit(Sender: TObject);
begin
  maxday := monthdays[IsLeapYear(spinedit1.Value)][spinedit2.Value];
end;

procedure Tscbrowfm.Button5Click(Sender: TObject);
begin
  close;
end;

procedure Tscbrowfm.TabSheet2Exit(Sender: TObject);
begin
  //inmxqy.Active := false;
end;

procedure Tscbrowfm.DBGridEh3KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if char(key)='q'  then
  button2.Click;
  if key = 40 then
    if inmxqy.Eof then
      inmxqy.Cancel;
  if not (key in [13, 10, 40, 37, 38, 39]) then
    button2.Enabled := true;
end;

procedure Tscbrowfm.Button6Click(Sender: TObject);
begin
  printdbgrideh1.PageHeader.LeftText.add('人事号:' + edit6.text + '    姓名: ' + edit7.text + '  部门:' + combobox3.text);
  printdbgrideh1.Preview;

end;

procedure Tscbrowfm.ComboBox3Exit(Sender: TObject);
begin
  dbgrideh3.SetFocus;
end;

procedure Tscbrowfm.BitBtn1Click(Sender: TObject);
begin
close;
end;

procedure Tscbrowfm.BitBtn2Click(Sender: TObject);
var
  excelid, mybook: variant;
  row, col, i, j, colcount, frow: integer;
  excelflg: boolean;
  rpstr: string;
  datasum, dsum1, dsum2: integer;
  datas1, datas2, datas3: string;
  selectstr, fromstr, wherestr: string;
begin


  selectstr := ' select b.pno, b.dept1,sum(b.innum) innum, sum(b.totalin) totalin';

  fromstr := ' from scintb a ,scinmx b ';
  wherestr := ' where  a.idno=b.idno ';
  if checkbox2.checked then
  wherestr:=' and a.years=:years and a.months=:months ';

  if edit1.Text <> '' then
    wherestr := wherestr + ' and a.staffid=:staffid ';
  if edit2.Text <> '' then
    wherestr := wherestr + ' and a.name=:name ';
  if combobox1.Text <> '' then
    wherestr := wherestr + ' and a.dept=:dept';


  if combobox4.Text <> '' then
    wherestr := wherestr + ' and b.dept1  LIKE :dept1';

  if checkbox1.Checked then
  begin
    wherestr := wherestr + ' and  b.days=:days ';
  end;
  if edit3.Text <> '' then
  begin
    wherestr := wherestr + ' and  b.pno like :pno ';

  end;
//  if pbnumedit1.Value > 0 then
//  begin
 //   wherestr := wherestr + ' and  b.inprice=:inprice ';

//  end;
  if work_again_check.Checked then
  begin
    wherestr := wherestr + ' and  b.work_again=:work_again ';

  end;
  if combobox2.Text <> '' then
  begin
    wherestr := wherestr + ' and  b.scgx like :scgx ';
  end;
  if edit4.Text <> '' then
  begin
    if pos('scpno', fromstr) <= 0 then
    begin
      fromstr := fromstr + ',scpno c';
      wherestr := wherestr + ' and b.pno=c.pno ';
    end;
    wherestr := wherestr + ' and c.kno like :kno ';
  end;
  if edit5.Text <> '' then
  begin
    if pos('scpno', fromstr) <= 0 then
    begin
      fromstr := fromstr + ',scpno c ';
      wherestr := wherestr + ' and b.pno=c.pno ';
    end;
    wherestr := wherestr + ' and c.kfjz like :kfjz ';
  end;
   with sch2 do
   begin
  SQl.Clear;
  SQL.add(selectstr);
  sql.Add(fromstr);
  sql.add(wherestr);
  if radiobutton1.Checked then
   SQL.add(' order by a.dept,a.staffid');
  if radiobutton2.Checked then
    SQL.add(' order by b.pno,b.scgx,a.dept');
  if checkbox2.checked then
  begin
  ParamByName('years').asinteger := spinedit1.Value;
  ParamByName('months').asinteger := spinedit2.Value;
  end;
  if checkbox1.Checked then
    ParamByName('days').asinteger := spinedit3.Value;
  if edit1.Text <> '' then
    ParamByName('staffid').asstring := edit1.Text;
  if edit2.Text <> '' then
    ParamByName('name').asstring := edit2.Text;
  if combobox1.Text <> '' then
    ParamByName('dept').asstring := combobox1.Text;
  if combobox4.Text <> '' then
    ParamByName('dept1').asstring := combobox4.Text;
  if edit3.Text <> '' then
    ParamByName('pno').asstring := '%' + edit3.Text + '%';
  if edit4.Text <> '' then
    ParamByName('kno').asstring := '%' + edit4.Text + '%';
  if edit5.Text <> '' then
    ParamByName('kfjz').asstring := '%' + edit5.Text + '%';
  if combobox2.Text <> '' then
     ParamByName('scgx').asstring := combobox2.Text;

//  if pbnumedit1.Value > 0 then
 // begin
  //  schscinqy.ParamByName('inprice').AsFloat := pbnumedit1.Value;

//  end;
  if work_again_check.Checked then
  begin
    ParamByName('work_again').Asboolean := true;

  end;
   sql.add('group by b.pno,b.dept1');
  open;
  end;


  ///////////////////excel start

  sch2.DisableControls;
  try
    excelid := createoleobject('excel.application');
    mybook := createoleobject('excel.sheet');
    mybook := excelid.workbooks.add;
    row := 1;
    col := 1;

    excelflg := true;
  except
    excelflg := false;
    application.MessageBox('请确定EXCEL是否正确安装!', '提示信息', mb_ok);
  end;
  if excelflg then
  begin
      colcount := sch2.fieldcount;

      excelid.ActiveSheet.PageSetup.Orientation := xlPortrait ;
//    excelid.ActiveSheet.PageSetup.Orientation := xlLandscape;

      mybook.worksheets[1].cells.item[row, col] := company + '生产日报表';
      mybook.worksheets[1].cells.item[row, col].font.size := 9;
      mybook.worksheets[1].cells.item[row, col].font.bold := true;
      mybook.worksheets[1].cells.item[row, col].HorizontalAlignment := xlcenter;
      row := row + 1;
      mybook.worksheets[1].cells.item[row, col] := '报表日期:' +
        datetostr(date);
      row := row + 1;
      frow := row;
      sch2.First;
      for i := 1 to colcount do
      begin
        mybook.worksheets[1].cells.item[row,i].font.size := 9;
        excelid.columns[i].ColumnWidth :=12;
        mybook.worksheets[1].cells.item[row, i] :=sch2.Fields[i-1].fieldname;
        mybook.worksheets[1].cells.item[row, i].HorizontalAlignment := xlcenter;
      end;
      row := row + 1;
      while not sch2.Eof do
      begin
        for i := 1 to colcount do
         mybook.worksheets[1].cells.item[row,i] := sch2.Fields[i-1].AsString;
         row := row + 1;
         sch2.Next;
      end;

 {   schscdayqy.SQL.clear;
    schscdayqy.SQL.add('select char(null),char(null),char(null),char(null),char(null),sum(fznum) 发织量,sum(sbdaynum) 日收片,sum(sbtolnum) 总收片,char(null),sum(ffnum) 发外数,sum(sfdaynum) 日收外,sum(sftolnum) 总收外,');
    schscdayqy.SQL.add(' sum(bfdaynum) 缝盘,sum(bftolnum) 厂缝,sum(btdaynum) 日挑,sum(bttolnum) 总挑,sum(xsdaynum),sum(xstolnum) 总洗,sum(dcdaynum) 日电,sum(dctolnum) 总电,sum(tsdaynum) 日烫,');
    schscdayqy.SQL.add(' sum(tstolnum) 总烫,sum(zmdaynum) 日车,sum(zmtolnum) 总车,sum(cbdaynum) 日查,sum(cbtolnum) 总查,sum(zxdaynum) 日装,sum(zxtolnum) 总装,sum(pnonum) 制单,sum(subzx) 装差,char(null) from scday a');
    schscdayqy.SQL.add('  inner join  dayscpno b on a.pno=b.pno');
    schscdayqy.Open; }

    {  for i := 1 to colcount do
         mybook.worksheets[1].cells.item[row,i] := schscdayqy.Fields[i-1].AsString; }
     row:=row+1;
      mybook.worksheets[1].cells.item[row, col].font.size := 12;
      mybook.worksheets[1].cells.item[row, col].font.bold := true;
      mybook.worksheets[1].cells.item[row, col].HorizontalAlignment := xlcenter;
      mybook.worksheets[1].cells.item[row, col] := '总记录数:' + inttostr(sch2.RecordCount) + '条';
      row := row + 1;
      rpstr := '报表条件:';

        for i := 0 to sch2.recordcount - 1 do
          for j := 0 to 3 do

    excelid.visible := true;
  end;
  sch2.EnableControls;

end;

end.

⌨️ 快捷键说明

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