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

📄 pieceworkeditfrm.pas

📁 考勤管理是企业内部管理的重要环节和基础
💻 PAS
📖 第 1 页 / 共 2 页
字号:
    end;
  end;
end;

procedure TPieceWorkEditForm.dbcbGoodsIDChange(Sender: TObject);
begin
  if dbcbGoodsID.text<>null then begin
    Dm2.qryWorkProDetail.Close;
    DM2.qryWorkProDetail.Params[0].AsString:=dbcbGoodsID.Items.Strings[dbcbGoodsID.itemindex];
    DM2.qryWorkProDetail.Open;
    DM2.qryPieceWorkMakeQty.Close;
    DM2.qryPieceWorkMakeQty.Params[0].AsInteger:=dblcMakeID.KeyValue;
    DM2.qryPieceWorkMakeQty.Params[1].AsString:=dbcbGoodsID.Items.Strings[dbcbGoodsID.itemindex];
    DM2.qryPieceWorkMakeQty.Open;
  end;
end;

procedure TPieceWorkEditForm.ComboBox1Change(Sender: TObject);
begin
  if ComboBox1.ItemIndex=0 then begin
    DBEdit2.Visible:=True;
    DBedit6.Visible:=False;
    DM2.qryPieceWorkPrice.Value:=DM2.qryPieceWorkGprice.Value;
    DM2.qryPieceWorkPriceType.Value:=True;
  end else begin
    DBEdit2.Visible:=False;
    DBedit6.Visible:=True;
    DM2.qryPieceWorkPrice.Value:=DM2.qryPieceWorkYprice.Value;
    DM2.qryPieceWorkPriceType.Value:=False;
  end;
end;

procedure TPieceWorkEditForm.sbBirthdayClick(Sender: TObject);
begin
  BrDateForm.Date := DM2.qryPieceWorkWorkDate.Value; 	{ start with current date }
  if BrDateForm.ShowModal = mrOk then
  begin
    DM2.qryPieceWork.Edit;
    DM2.qryPieceWorkWorkDate.Value := BrDateForm.Date;
  end;
end;

procedure TPieceWorkEditForm.dblcGoodsIDItemsClick(Sender: TObject);
var
  Number2:Double;
begin
  DM2.qryWorkProDeta.Close;
  DM2.qryWorkProDeta.open;
  if DM2.qryWorkProDeta.Locate('No1', dblcGoodsIDItems.KeyValue ,
    [loCaseInsensitive, loPartialKey]) then begin
    DM2.qryPieceWorkGprice.Value:=DM2.qryWorkProDetaGprice.Value;
    DM2.qryPieceWorkYprice.Value:=DM2.qryWorkProDetaprice.Value;
    DM2.qryPieceWorkItemsName.Value:=DM2.qryWorkProDetaName.Value;
    DM2.qryPieceWorkItemItems.Value:=DM2.qryWorkProDetaItems.Value;
  end;
  if ComboBox1.ItemIndex=0 then begin
    DM2.qryPieceWorkPrice.Value:=DM2.qryPieceWorkGprice.Value;
    DM2.qryPieceWorkPriceType.Value:=True;
  end else begin
    DM2.qryPieceWorkPrice.Value:=DM2.qryPieceWorkYprice.Value;
    DM2.qryPieceWorkPriceType.Value:=False;
  end;
  DM2.qryPieceWorkNumber.Close;
  DM2.qryPieceWorkNumber.Params[0].AsInteger:=dblcMakeID.KeyValue;
  DM2.qryPieceWorkNumber.Params[1].AsString:=dbcbGoodsID.Items.Strings[dbcbGoodsID.itemindex];
  DM2.qryPieceWorkNumber.Params[2].AsInteger:=dblcGoodsIDItems.KeyValue;
  DM2.qryPieceWorkNumber.Open;
  if DM2.qryPieceWorkNumberNumber1.Value=0 then
    Edit4.Text:='0'
  else begin
    Number2:=DM2.qryPieceWorkNumberNumber1.Value;
    Edit4.Text:=FloatToStr(Number2);
  end;
end;

procedure TPieceWorkEditForm.BitBtn1Click(Sender: TObject);
begin
  CopyPieceWorkForm:=TCopyPieceWorkForm.Create(Self);
  CopyPieceWorkForm.cbCopy1.Checked:=FCopy[1];
  CopyPieceWorkForm.cbCopy2.Checked:=FCopy[2];
  CopyPieceWorkForm.cbCopy3.Checked:=FCopy[3];
  CopyPieceWorkForm.cbCopy4.Checked:=FCopy[4];
  CopyPieceWorkForm.cbCopy5.Checked:=FCopy[5];
  CopyPieceWorkForm.cbCopy6.Checked:=FCopy[6];
  CopyPieceWorkForm.cbCopy7.Checked:=FCopy[7];
  CopyPieceWorkForm.cbCopy8.Checked:=FCopy[8];
  CopyPieceWorkForm.cbCopy9.Checked:=FCopy[9];
  if CopyPieceWorkForm.ShowModal=mrOK then begin
    Fcopy[1]:=CopyPieceWorkForm.cbCopy1.Checked;
    Fcopy[2]:=CopyPieceWorkForm.cbCopy2.Checked;
    Fcopy[3]:=CopyPieceWorkForm.cbCopy3.Checked;
    Fcopy[4]:=CopyPieceWorkForm.cbCopy4.Checked;
    Fcopy[5]:=CopyPieceWorkForm.cbCopy5.Checked;
    Fcopy[6]:=CopyPieceWorkForm.cbCopy6.Checked;
    Fcopy[7]:=CopyPieceWorkForm.cbCopy7.Checked;
    Fcopy[8]:=CopyPieceWorkForm.cbCopy8.Checked;
    Fcopy[9]:=CopyPieceWorkForm.cbCopy9.Checked;
  end;
end;

procedure TPieceWorkEditForm.bbtnAddEnter(Sender: TObject);
begin
  if Fcopy[1] then
    FCopyItem1:=cbDepartment.ItemIndex;
  if Fcopy[2] then
    FCopyItem2:=cbName.ItemIndex;
  if Fcopy[3] then begin
    FCopyItem3:=dblcMakeID.KeyValue;
    FCopyItem31:=dblcMakeID.Text;
  end;
  if Fcopy[4] then
    FCopyItem4:=DBEdit1.EditText;
  if Fcopy[5] then
    FCopyItem5:=DM2.qryPieceWorkGoodsID.Value;
  if Fcopy[6] then begin
    FCopyItem6:=dblcGoodsIDItems.KeyValue;
    FCopyItem61:=DM2.qryPieceWorkItemsName.Value;
  end;
  if Fcopy[7] then
    FCopyItem7:=DM2.qryPieceWorkPrice.Value;
  if Fcopy[8] then
    FCopyItem8:=DBEdit5.EditText;
  if Fcopy[9] then
    FCopyItem9:=DM2.qryPieceWorkCallBackPay.Value;
end;

procedure TPieceWorkEditForm.Button2Click(Sender: TObject);
begin
  DM2.qryPieceWork.append;
  if Fcopy[1] then
    cbDepartment.ItemIndex:=FCopyItem1;
  if Fcopy[2] then begin
    cbName.ItemIndex:=FCopyItem2;
    cbName.OnExit(cbName);
  end else
    cbName.Text:='';
  if Fcopy[3] then begin
    dblcMakeID.OnClick(dblcMakeID);
    DM2.qryPieceWorkMakeID.Value:=FCopyItem3;
    DM2.qryPieceWorkCode.Value:=FCopyItem31;
  end;
  if Fcopy[4] then
    DBEdit1.EditText:=FCopyItem4;
  if Fcopy[5] then begin
    DM2.qryPieceWorkGoodsID.value:=FCopyItem5;
    dbcbGoodsID.OnChange(dbcbGoodsID);
  end;
  if Fcopy[6] then begin
    DM2.qryPieceWorkItems.Value:=FCopyItem6;
    DM2.qryPieceWorkItemsName.Value:=FCopyItem61;
    dblcGoodsIDItems.OnClick(dblcGoodsIDItems);
  end;
  if Fcopy[7] then begin
    DM2.qryPieceWorkPrice.Value:=FCopyItem7;

  end;
  if Fcopy[8] then begin
    DBEdit5.EditText:=FCopyItem8;
    DM2.qryPieceWorkNumber1.Value:=StrToFloat(FCopyItem8);
    if ActiveControl<>bbtnCancel then
      if Trim(DBEdit5.Text)<>'' then
        if StrToFloat(DBEdit3.EditText)<StrToFloat(Edit4.Text)+StrToFloat(DBEdit5.EditText) then begin
          MessageDlg(Pchar(sError), mtConfirmation, [mbOK], 0);
          DM2.qryPieceWork.Cancel;
          DM2.qryPieceWork.Edit;
          DBEdit5.SetFocus;
        end;
  end;
  if Fcopy[9] then
    DM2.qryPieceWorkCallBackPay.Value:=FCopyItem9;
end;

procedure TPieceWorkEditForm.DBEdit5Exit(Sender: TObject);
begin
  if ActiveControl<>bbtnCancel then
    if Trim(DBEdit5.Text)<>'' then
        if StrToFloat(DBEdit3.EditText)<StrToFloat(Edit4.Text)+StrToFloat(DBEdit5.EditText)-Fnumber then begin
          MessageDlg(Pchar(sError), mtConfirmation, [mbOK], 0);
          DBEdit5.SetFocus;
        end;
{      if CM then begin
      end else
        if StrToFloat(DBEdit3.EditText)<StrToFloat(Edit4.Text)+StrToFloat(DBEdit5.EditText) then begin
          MessageDlg(Pchar(sError), mtConfirmation, [mbOK], 0);
          DBEdit5.SetFocus;
        end;
}  CM:=False;
end;

procedure TPieceWorkEditForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then begin
    if not (ActiveControl is TDBGrid) then begin
      key:=#0;
      perform(WM_NEXTDLGCTL,0,0);
    end else if (ActiveControl is TDBGrid) then begin
      with TDBGrid(ActiveControl) do
        if SelectedIndex<(FieldCount-1) then
          selectedIndex:=SelectedIndex+1
        else selectedIndex:=0;
      end;
    end;
end;

procedure TPieceWorkEditForm.DBEdit1KeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key = ^J then
  begin
    sbBirthdayClick(Sender);
    Key := #0;
  end;
end;

procedure TPieceWorkEditForm.cbNameChange(Sender: TObject);
begin
  DM2.qryEmpID.First;
  if not DM2.qryEmpID.Locate('Name', cbName.Text,
    [loCaseInsensitive, loPartialKey]) then begin
    if ActiveControl<>bbtnCancel then begin
      MessageDlg(Pchar(sName), mtInformation, [mbOK], 0);
      cbName.SetFocus;
    end;
  end else begin
    DM2.qryPieceWorkEmpID.Value:=DM2.qryEmpID.FieldByName('EmpID').Value;
    DM2.qryPieceWorkName.Value:=DM2.qryEmpID.FieldByName('Name').Value;
    DM2.qryPieceWorkDepartment.Value:=DM2.qryEmpID.FieldByName('Department').Value;
    DM2.qryPieceWorkDepartmentID.Value:=DM2.qryEmpID.FieldByName('DepName').Value;
  end;
end;

procedure TPieceWorkEditForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TPieceWorkEditForm.FormDestroy(Sender: TObject);
begin
  DM2.qryMakeNo1.Close;
  PieceWorkEditForm:=nil;
end;

procedure TPieceWorkEditForm.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  CanClose := DM2.DataSetApplyUpdates(DM2.qryPieceWork, ModalResult = mrOK);
end;

procedure TPieceWorkEditForm.DBEdit5Enter(Sender: TObject);
begin
  if CM then
    if Trim(DBedit5.Text)<>'' then
      Fnumber:=StrToFloat(Trim(DBEdit5.EditText))
    else
      Fnumber:=0;
end;

end.

⌨️ 快捷键说明

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