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

📄 scbrow.pas

📁 实用的毛织生产管理系统
💻 PAS
📖 第 1 页 / 共 3 页
字号:

procedure Tscbrowfm.FormDestroy(Sender: TObject);
begin
  scbrowfm := nil;
end;

procedure Tscbrowfm.FormCreate(Sender: TObject);
var
  years, months, days: word;
begin
  inedflg := '1';
  decodedate(date, years, months, days);
  spinedit1.Value := years;
  spinedit2.Value := months;
  spinedit3.Value := days;
  spinedit4.Value := years;
  spinedit5.Value := months;
  spinedit3.Maxvalue := monthdays[IsLeapYear(years)][months];
  combobox1.items := insertcombobox('scgx', 'dept'); //部门
  combobox2.items := insertcombobox('scgx', 'dept'); //工序
  combobox3.items := combobox1.items; //部门
  inmxqy.RequestLive := true;
  pagecontrol1.ActivePage := tabsheet1;

end;

procedure Tscbrowfm.SpinEdit1Exit(Sender: TObject);
begin
  spinedit4.Value := spinedit1.Value;
  spinedit5.Value := spinedit2.Value;
  maxday := monthdays[IsLeapYear(spinedit1.Value)][spinedit2.Value];
  spinedit3.MaxValue := maxday;
end;

procedure Tscbrowfm.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if key = #13 then
    if not (ActiveControl is TDbgrideh) then
    begin
      key := #0;
      perform(WM_NEXTDLGCTL, 0, 0);
    end;


end;

procedure Tscbrowfm.ComboBox1Exit(Sender: TObject);
begin
  if (combobox1.text <> '') and (olddept <> combobox3.Text) then
  begin
    olddept := searchfield('scdepts', 'deptcode', 'dept', combobox1.Text);
    combobox1.Text := olddept;
  end;
end;

procedure Tscbrowfm.Button1Click(Sender: TObject);
begin

  schscbrow;

end;

procedure Tscbrowfm.ComboBox2Exit(Sender: TObject);
begin
 // if combobox2.text <> '' then
   // combobox2.Text := searchfield('scgx', 'scgxno', 'scgxno', combobox2.Text);
end;

procedure Tscbrowfm.inmxqyAfterOpen(DataSet: TDataSet);
begin
  n6.Enabled := bool(dataset.RecordCount);

end;

procedure Tscbrowfm.N3Click(Sender: TObject);
begin
  saveqy.SQL.Clear;
  saveqy.SQL.Add('delete from scintb where idno=:idno');
  saveqy.ParamByName('idno').asinteger :=
    schscinqy.fieldbyname('idno').asinteger;
  saveqy.ExecSQL;
  saveqy.SQL.Clear;
  saveqy.SQL.Add('delete from scinmx where idno=:idno');
  saveqy.ParamByName('idno').asinteger :=
    schscinqy.fieldbyname('idno').asinteger;
  saveqy.ExecSQL;
  schscbrow;
end;

procedure Tscbrowfm.N1Click(Sender: TObject);
begin
  inedflg := '3';
  pagecontrol1.ActivePage := tabsheet2

end;

procedure Tscbrowfm.TabSheet2Show(Sender: TObject);
begin
  inedshow;
end;

procedure Tscbrowfm.DBGridEh1DblClick(Sender: TObject);
begin
  if (schscinqy.Active) and (schscinqy.recordcount > 0) then
  begin
    inedflg := '2';
    pagecontrol1.ActivePage := tabsheet2;
  end
  else
    messagedlg('没有记录可修改或不能进行新增!', mtinformation, [mbok], 0);
end;

procedure Tscbrowfm.Button4Click(Sender: TObject);
begin
  inedflg := '1';
  inedshow;

end;

procedure Tscbrowfm.inmxqyAfterDelete(DataSet: TDataSet);
begin
  n6.Enabled := bool(dataset.recordcount);

end;

procedure Tscbrowfm.inmxqyAfterPost(DataSet: TDataSet);
begin
  // dataset.Close;
   //dataset.Open;
  button2.Enabled := true;
end;

procedure Tscbrowfm.inmxqyBeforePost(DataSet: TDataSet);
begin
  if dataset.FieldByName('pno').asstring <> '' then
  begin
    if (dataset.FieldByName('days').asinteger > maxday) or
      (dataset.FieldByName('days').asinteger < 1) then
    begin
      messagedlg('天数不在本月天数内,请重输!', mtinformation, [mbok], 0);
      abort;
    end;
  end
  else
    dataset.Cancel;
end;

procedure Tscbrowfm.inmxqyPostError(DataSet: TDataSet; E: EDatabaseError;
  var Action: TDataAction);
begin
  if (E is EDBEngineError) then
  begin
    if ((E as EDBEngineError).Errors
      [0].Errorcode = 9729) or ((E as EDBEngineError).Errors
      [0].Errorcode = 13059) then
    begin
      action := daabort;

    end;
  end;
end;

procedure Tscbrowfm.n6Click(Sender: TObject);
begin
  inmxqy.Delete;
end;

procedure Tscbrowfm.Button2Click(Sender: TObject);
begin
  if (edit6.text <> '') and (edit7.Text <> '') and (combobox3.Text <> '') then
  begin
    saveqy.sql.clear;
    saveqy.sql.add('select idno from scintb where years=:years and months=:months');
    saveqy.sql.add(' and staffid=:staffid and dept=:dept');
    saveqy.ParamByName('years').asinteger := spinedit4.Value;
    saveqy.ParamByName('months').asinteger := spinedit5.Value;
    saveqy.ParamByName('staffid').asstring := edit6.Text;
          // saveqy.ParamByName('name').asstring := edit6.Text;
    saveqy.ParamByName('dept').asstring := combobox3.Text;
    saveqy.open;
    if saveqy.RecordCount > 0 then
    begin
      idno := saveqy.fieldbyname('idno').asinteger;
      inedflg := '2';
    end;


    case inedflg of
      '1':
        begin
          saveqy.SQL.clear;
          saveqy.sql.add('insert into scintb (years,months,staffid,name,dept,dept1)');
          saveqy.sql.Add(' values (:years,:months,:staffid,:name,:dept,:dept1)');
          saveqy.ParamByName('years').asinteger := spinedit4.Value;
          saveqy.ParamByName('months').asinteger := spinedit5.Value;
          saveqy.ParamByName('staffid').asstring := edit6.Text;
          saveqy.ParamByName('name').asstring := edit7.Text;
          saveqy.ParamByName('dept').asstring := combobox3.Text;
          saveqy.ParamByName('dept1').asstring := edit8.Text;
          saveqy.ExecSQL;
          saveqy.sql.clear;
          saveqy.sql.add('select idno from scintb where years=:years and months=:months');
          saveqy.sql.add(' and staffid=:staffid and dept=:dept');
          saveqy.ParamByName('years').asinteger := spinedit4.Value;
          saveqy.ParamByName('months').asinteger := spinedit5.Value;
          saveqy.ParamByName('staffid').asstring := edit6.Text;
          // saveqy.ParamByName('name').asstring := edit6.Text;
          saveqy.ParamByName('dept').asstring := combobox3.Text;
          saveqy.open;
          idno := saveqy.fieldbyname('idno').asinteger;
          inmxqy.DisableControls;
          inmxqy.First;
          while not inmxqy.eof do
          begin
            if inmxqy.FieldByName('idno').IsNull then
            begin
              inmxqy.edit;
              inmxqy.FieldByName('idno').asinteger := idno;

            end;
            inmxqy.Next;
          end;
          inmxqy.EnableControls;
          inmxqy.ApplyUpdates;
          //inmxqy.CommitUpdates;
          inmxqy.SQL.Clear;
          inmxqy.sql.Add('select * from scinmx where idno=:idno order by mxidno ');
          inmxqy.ParamByName('idno').AsInteger := idno;
          inmxqy.Open;
          inedflg := '2';
          button2.Enabled := false;

        end;
      '2', '3':
        begin
          saveqy.sql.Clear;
          saveqy.sql.add('update  scintb  set years=:years,months=:months,staffid=:staffid,name=:name,dept=:dept,dept1=:dept1');
          saveqy.sql.Add('where idno=:idno ');
          saveqy.ParamByName('years').asinteger := spinedit4.Value;
          saveqy.ParamByName('months').asinteger := spinedit5.Value;
          saveqy.ParamByName('staffid').asstring := edit6.Text;
          saveqy.ParamByName('name').asstring := edit7.Text;
          saveqy.ParamByName('dept').asstring := combobox3.Text;
          saveqy.ParamByName('dept1').asstring :=edit8.Text;          
          saveqy.ParamByName('idno').AsInteger := idno;
          saveqy.ExecSQL;
          inmxqy.DisableControls;
          inmxqy.First;
          while not inmxqy.eof do
          begin
            if inmxqy.FieldByName('idno').IsNull then
            begin
              inmxqy.edit;
              inmxqy.FieldByName('idno').asinteger := idno;

            end;
            inmxqy.Next;
          end;
          inmxqy.EnableControls;
          inmxqy.ApplyUpdates;
          //inmxqy.CommitUpdates;
          inmxqy.SQL.Clear;
          inmxqy.sql.Add('select * from scinmx where idno=:idno order by mxidno ');
          inmxqy.ParamByName('idno').AsInteger := idno;
          inmxqy.Open;
          button2.Enabled := false;
        end;
    end;
  end
  else
    messagedlg('数据输入不完成不能进行保存,请检查!', mtinformation, [mbok], 0);

end;

procedure Tscbrowfm.Edit6Exit(Sender: TObject);
begin
  if oldstaffid <> edit6.Text then
    schbb('staffid', edit6.text);
end;

procedure Tscbrowfm.Edit7Exit(Sender: TObject);
begin
  if oldname <> edit7.Text then
    schbb('name', edit7.text);
end;

procedure Tscbrowfm.DBGridEh3KeyPress(Sender: TObject; var Key: Char);
begin

  try
    if key = #13 then
    begin
      with Dbgrideh3 do
      begin
        if inmxqy.state in [dsinsert, dsedit] then
        begin
          if (selectedindex = 4) or (selectedindex = 5) or  (selectedindex = 6) then
          begin
            if pos('时工', inmxqy.FieldByName('sg').asstring) <= 0 then
              inmxqy.FieldByName('totalin').asfloat :=
                inmxqy.FieldByName('innum').asfloat *
                inmxqy.FieldByName('inprice').asfloat / 12
            else
              inmxqy.FieldByName('totalin').asfloat :=
                inmxqy.FieldByName('innum').asfloat *
                inmxqy.FieldByName('inprice').asfloat
                ;
          end;

        end;
        if Selectedindex < (FieldCount - 1) then
          Selectedindex := Selectedindex + 1
        else
        begin
          inmxqy.Next;
          if inmxqy.Eof then
            inmxqy.Append;
          Selectedindex := 0;
        end;
      end;
    end
  except

  end;


end;

procedure Tscbrowfm.SpinEdit4Change(Sender: TObject);
begin
  button2.Enabled := true;
end;

procedure Tscbrowfm.Button3Click(Sender: TObject);
begin
  inmxqy.CancelUpdates;
end;

procedure Tscbrowfm.DBGridEh3ColExit(Sender: TObject);
var scprice: double;
begin
  if inmxqy.state in [dsinsert, dsedit] then
  begin
    case dbgrideh3.SelectedIndex of
      0:
        if (inmxqy.FieldByName('days').asinteger > maxday) or
          (inmxqy.FieldByName('days').asinteger < 1) then
        begin
          messagedlg('天数不在本月天数内,请重输!', mtinformation, [mbok], 0);
          abort;
        end;
      1:
        begin
          if not searchfield1('scpno', 'pno',
            inmxqy.FieldByName('pno').asstring) then
          begin
            messagedlg('没有此批号,请重输!', mtinformation, [mbok], 0);
            abort;

          end
          else
            if searchpno(inmxqy.FieldByName('pno').asstring) then
            begin
              messagedlg('此批号已完工,请重输!', mtinformation, [mbok], 0);
            end;
        end;
      2:
       begin

⌨️ 快捷键说明

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