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

📄 pay500_01.pas.svn-base

📁 这是一个功能齐全的,代码完整的ERP企业信息管理系统,现在上传和大家分享
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
  begin
    edtReasonID.Text:=qryCwa160C160_002.Value;
    qryPay500P500_002.Value:=qryCwa160C160_001.Value;
    qryPay500P500_006.Value:=qryCwa160C160_005.Value;
  end;
end;

procedure TPay500_01Form.edtTypeIDExit(Sender: TObject);
begin
  inherited;
  //事务类型合法性检查
  if (ActSave.Enabled) and (trim(edtTypeID.Text)<>'') then
  begin
    if qryPay150.Locate('P150_002',edtTypeID.Text,[loCaseInsensitive]) then
    begin
      qryPay500P500_001.Value:=qryPay150.FieldByName('P150_001').Value;
      qryPay500P500_003.Value:=qryPay150.FieldByName('P150_003').Value;
    end else
    begin
      ShowMsg('UMS10000072');  //无效的事务类型
      edtTypeID.SetFocus;
      Abort;
    end;
  end;
end;

procedure TPay500_01Form.edtEmpIDExit(Sender: TObject);
begin
  inherited;
  //员工编号合法性检查
  if (ActSave.Enabled) and (trim(edtEmpID.Text)<>'') then
  begin
    if qryHrm150.Locate('H150_002',edtEmpID.Text,[loCaseInsensitive]) then
    begin
      qryPay500P500_002.Value:=qryHrm150.FieldByName('H150_001').Value;
    end else
    begin
      ShowMsg('UMS10000042');  //无效的员工编号
      edtEmpID.SetFocus;
      Abort;
    end;
  end;
end;

procedure TPay500_01Form.edtReasonIDExit(Sender: TObject);
begin
  inherited;
  //原因编号查询
  if (ActSave.Enabled) and (trim(edtReasonID.Text)<>'') then
  begin
    if qryCwa160.Locate('C160_002',edtReasonID.Text,[loCaseInsensitive]) then
    begin
      edtReasonID.Text:=qryCwa160C160_002.Value;
      qryPay500P500_002.Value:=qryCwa160C160_001.Value;
      qryPay500P500_006.Value:=qryCwa160C160_005.Value;
    end else
    begin
      ShowMsg('UMS10000074');  //无效的原因编号
      edtReasonID.SetFocus;
      Abort;
    end;
  end;
end;

procedure TPay500_01Form.edtTypeIDKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if Key=vk_F4 then SpeedButton1.Click;
end;

procedure TPay500_01Form.edtEmpIDKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if Key=vk_F4 then SpeedButton2.Click;
end;

procedure TPay500_01Form.edtReasonIDKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if Key=vk_F4 then SpeedButton3.Click;
end;

procedure TPay500_01Form.cbMonthChange(Sender: TObject);
begin
  inherited;
  //取得期段的起始结束日期
  GetPeriodDate(cbYear.Text,cbMonth.Text,AStartDate,AEndDate,APeriod);
end;

procedure TPay500_01Form.cbTypeChange(Sender: TObject);
begin
  inherited;
  if cbYear.Text='' then Exit;
  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('select C150_001 from CWA150 where C150_003='+''''+cbType.Text+'''');
  SYSDM.qryQuery.Open;
  if SYSDM.qryQuery.IsEmpty then
    ATypeNo:=0
  else
    ATypeNo:=SYSDM.qryQuery.Fields[0].Value;   //事务类型
end;

procedure TPay500_01Form.sbOkClick(Sender: TObject);
begin
  inherited;
//确定
  if (cbYear.Text='') or (cbMonth.Text='') or (cbType.Text='') then Exit;
  //取得期段的起始结束日期
  GetPeriodDate(cbYear.Text,cbMonth.Text,AStartDate,AEndDate,APeriod);
  qryPay500.Close;
  qryPay500.SQL.Clear;
  if ATypeNo=0 then
    qryPay500.SQL.Add('select * from PAY500 where P500_005>='+GetDateString(AStartDate)+' and P500_005<='+GetDateString(AEndDate))
  else
    qryPay500.SQL.Add('select * from PAY500 where P500_001='+IntToStr(ATypeNo)+' and P500_005>='+GetDateString(AStartDate)+' and P500_005<='+GetDateString(AEndDate));
  qryPay500.Open;
end;

procedure TPay500_01Form.PageControl1Changing(Sender: TObject;
  var AllowChange: Boolean);
begin
  inherited;
  if qryPay500.State in [dsInsert, dsEdit] then AllowChange:=False;
end;

procedure TPay500_01Form.qryPay500AfterScroll(DataSet: TDataSet);
begin
  inherited;
  edtTypeID.Text:=qryPay500P150_002.AsString;
  edtEmpID.Text:=qryPay500H150_002.AsString;
  edtReasonID.Text:=qryPay500C160_002.AsString;
end;

procedure TPay500_01Form.ActFirstExecute(Sender: TObject);
begin
  inherited;
//最前
  if qryPay500.IsEmpty then Exit;
  qryPay500.First;
  ActFirst.Enabled:=False;
  ActPrior.Enabled:=False;
  ActNext.Enabled:=True;
  ActLast.Enabled:=True;
end;

procedure TPay500_01Form.ActPriorExecute(Sender: TObject);
begin
  inherited;
//上移
  if qryPay500.IsEmpty then Exit;
  qryPay500.Prior;
  ActNext.Enabled:=not qryPay500.Eof;
  ActLast.Enabled:=not qryPay500.Eof;
  ActFirst.Enabled:=not qryPay500.Bof;
  ActPrior.Enabled:=not qryPay500.Bof;
end;

procedure TPay500_01Form.ActNextExecute(Sender: TObject);
begin
  inherited;
//下移
  if qryPay500.IsEmpty then Exit;
  qryPay500.Next;
  ActNext.Enabled:=not qryPay500.Eof;
  ActLast.Enabled:=not qryPay500.Eof;
  ActFirst.Enabled:=not qryPay500.Bof;
  ActPrior.Enabled:=not qryPay500.Bof;
end;

procedure TPay500_01Form.ActLastExecute(Sender: TObject);
begin
  inherited;
//最后
  if qryPay500.IsEmpty then Exit;
  qryPay500.Last;
  ActNext.Enabled:=False;
  ActLast.Enabled:=False;
  ActFirst.Enabled:=True;
  ActPrior.Enabled:=True;
end;

procedure TPay500_01Form.ActInsertExecute(Sender: TObject);
var
  ADate:TDateTime;
begin
  inherited;
//新增
  qryPay500.Insert;
  qryPay500P500_007.Value:=False;
  SetButtonState(True);
  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, ASystemDate, SizeOf(ASystemDate));
  ADate:=StrToDate(FormatDateTime(ASystemDate,GetServerDate));
  qryPay500P500_005.Value:=ADate;
  edtTypeID.SetFocus;
end;

procedure TPay500_01Form.ActUpdateExecute(Sender: TObject);
begin
  inherited;
//修改
  if qryPay500.IsEmpty then
  begin
    ShowMsg('UMS10000002');  //表记录为空,操作无效
    Abort;
  end;
  qryPay500.Edit;
  SetButtonState(True);
  edtTypeID.SetFocus;
end;

procedure TPay500_01Form.ActDeleteExecute(Sender: TObject);
begin
  inherited;
//删除
  if qryPay500.IsEmpty then
  begin
    ShowMsg('UMS10000002');  //表记录为空,操作无效
    Abort;
  end;

  if ShowDialog('UMS10000008')=IDYES then  //确定要删除此记录吗?
  begin
    qryPay500.Delete;
  end;
end;

procedure TPay500_01Form.ActSaveExecute(Sender: TObject);
var
  AItemNo,AEmpNo:Integer;
  ADate:TDateTime;
  ANo:Integer;
begin
  inherited;
//保存
  AItemNo:=qryPay500P500_001.Value;
  AEmpNo:=qryPay500P500_002.Value;
  ADate:=qryPay500P500_005.Value;

  if trim(edtTypeID.Text)='' then
  begin
    ShowMsg('UMS10000073');  //事务类型不能为空
    edtTypeID.SetFocus;
    Abort;
  end else
  begin
    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('select 1 from PAY150 where P150_002='+''''+edtTypeID.Text+'''');
    SYSDM.qryQuery.Open;
    if SYSDM.qryQuery.IsEmpty then
    begin
      ShowMsg('UMS10000072');  //无效的事务类型
      edtTypeID.SetFocus;
      Abort;
    end;
  end;

  if trim(edtReasonID.Text)<>'' then
  begin
    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('select 1 from CWA160 where C160_002='+''''+edtReasonID.Text+'''');
    SYSDM.qryQuery.Open;
    if SYSDM.qryQuery.IsEmpty then
    begin
      ShowMsg('UMS10000074');  //无效的原因编号
      edtReasonID.SetFocus;
      Abort;
    end;
  end;

  if trim(edtDest.Text)='' then
  begin
    ShowMsg('UMS10000250');  //事务说明不能为空
    edtDest.SetFocus;
    Abort;
  end;

  if trim(edtEmpID.Text)='' then
  begin
    ShowMsg('UMS10000071');  //员工编号不能为空
    edtEmpID.SetFocus;
    Abort;
  end else
  begin
    SYSDM.qryQuery.Close;
    SYSDM.qryQuery.SQL.Clear;
    SYSDM.qryQuery.SQL.Add('select H150_001 from HRM150 where H150_002='+''''+edtEmpID.Text+'''');
    SYSDM.qryQuery.Open;
    if SYSDM.qryQuery.IsEmpty then
    begin
      ShowMsg('UMS10000042');  //无效的员工编号
      edtEmpID.SetFocus;
      Abort;
    end;
    AEmpNo:=SYSDM.qryQuery.Fields[0].Value;
  end;

  if (trim(edtAmount.Text)='') or (trim(edtAmount.Text)='0') then
  begin
    ShowMsg('UMS10000240');  //事务金额不能为空或零
    edtAmount.SetFocus;
    Abort;
  end;

  ANo:=GetValue('select top 1 P510A_001 from PAY510A where P510A_002='+IntToStr(AEmpNo)+' and P510A_004<='+GetDateString(ADate)+' order by P510A_004 desc');
  if not IsExists('select 1 from PAY510B where P510B_001='+IntToStr(ANo)+' and P510B_002='+IntToStr(AItemNo)) then
  begin
    ShowMsg('UMS10000234');  //该员工的薪资结构中没有定义此薪资项目
    Abort;
  end;

  if trim(edtReasonID.Text)='' then qryPay500P500_002.AsString:='';
  try
     qryPay500.Post;
  except
    ShowMsg(SYSDM.ADOC.Errors[0].Description,1);
    Abort;
  end;
  SetButtonState(False);
end;

procedure TPay500_01Form.ActCancelExecute(Sender: TObject);
begin
  inherited;
//取消
  qryPay500.CancelUpdates;
  SetButtonState(False);
end;

procedure TPay500_01Form.ActRefreshExecute(Sender: TObject);
begin
  inherited;
//刷新
  qryPay500.Close;
  qryPay500.Open;
end;

procedure TPay500_01Form.ActLocateExecute(Sender: TObject);
begin
  inherited;
//查找
  if qryPay500.IsEmpty then
  begin
    ShowMsg('UMS10000002');  //表记录为空,操作无效
    Exit;
  end;
  LocateDialog(dsPay500);
end;

procedure TPay500_01Form.ActSearchExecute(Sender: TObject);
begin
  inherited;
//查询
  FilterDialog(dsPay500);
end;

procedure TPay500_01Form.ActPrintExecute(Sender: TObject);
begin
  inherited;
//打印
  SelectReport(qryPay500,AProgramID,AReportName,ReportGetValue);
  ActRefresh.Execute;
end;

procedure TPay500_01Form.ActExportExecute(Sender: TObject);
begin
  inherited;
//导出到Excel
  if qryPay500.IsEmpty then
  begin
    ShowMsg('UMS10000002');  //表记录为空,操作无效
    Abort;
  end;
  SaveToExcel(dxDBGrid1);
end;

procedure TPay500_01Form.ActCheckExecute(Sender: TObject);
begin
  inherited;
//审核
  if qryPay500.IsEmpty then
  begin
    ShowMsg('UMS10000002');  //表记录为空,操作无效
    Abort;
  end;
  Pay500_03Form:=TPay500_03Form.Create(Application);
  Pay500_03Form.ShowModal;
  qryPay500.Refresh;
end;

procedure TPay500_01Form.ActBatchExecute(Sender: TObject);
begin
  inherited;
//成批录入
  Pay500_02Form:=TPay500_02Form.Create(Application);
  Pay500_02Form.ShowModal;
  qryPay500.Refresh;
end;

procedure TPay500_01Form.ActExitExecute(Sender: TObject);
begin
  inherited;
//退出
  Close;
end;

procedure TPay500_01Form.dxDBGrid1BackgroundDrawEvent(Sender: TObject;
  ACanvas: TCanvas; ARect: TRect);
var
  AText:string;
begin
  inherited;
  ARect.Left:=0;
  ARect.Top:=0;
  ACanvas.Brush.Color:=dxDBGrid1.GroupPanelColor;
  ACanvas.Font.Color:=dxDBGrid1.GroupPanelFontColor;
  //您可以把列标题拖放到此处使记录按此列进行分组
  if dxDBGrid1.GroupColumnCount=0 then AText:=' '+GetDBString('NOT10001012') else AText:='';
  Windows.FillRect(ACanvas.Handle, ARect, 0);
  DrawText(ACanvas.Handle, PChar(AText), Length(AText), ARect, DT_LEFT or DT_EXPANDTABS or DT_NOPREFIX or DT_SINGLELINE or DT_VCENTER);
end;

initialization
  RegisterClass(TPay500_01Form);

finalization
  UnRegisterClass(TPay500_01Form);

end.

⌨️ 快捷键说明

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