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

📄 pay500_03.pas.svn-base

📁 这是一个功能齐全的,代码完整的ERP企业信息管理系统,现在上传和大家分享
💻 SVN-BASE
字号:
unit Pay500_03;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Bas100_01, Db, StdCtrls, Buttons, wwdbdatetimepicker, Mask,
  ExtCtrls, ADODB, Menus;

type
  TPay500_03Form = class(TBas100_01Form)
    Bevel1: TBevel;
    lblType: TLabel;
    lblDept: TLabel;
    lblEmp: TLabel;
    lblEmpTo: TLabel;
    lblDate: TLabel;
    lblDateTo: TLabel;
    cbType: TComboBox;
    dtStartDate: TwwDBDateTimePicker;
    dtEndDate: TwwDBDateTimePicker;
    bbtnOk: TBitBtn;
    bbtnExit: TBitBtn;
    cbDepart: TComboBox;
    edtFromEmpID: TEdit;
    SpeedButton1: TSpeedButton;
    edtToEmpID: TEdit;
    SpeedButton2: TSpeedButton;
    rbCheck: TRadioButton;
    rbUnCheck: TRadioButton;
    qryHrm100: TADOQuery;
    qryHrm150: TADOQuery;
    qryHrm150H150_001: TAutoIncField;
    qryHrm150H150_002: TStringField;
    qryHrm150H150_003: TStringField;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bbtnOkClick(Sender: TObject);
    procedure bbtnExitClick(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure edtFromEmpIDKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure edtToEmpIDKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    procedure SetInterface;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Pay500_03Form: TPay500_03Form;

implementation

uses SYSDATA, CommFun, HwSelData;

{$R *.DFM}

//薪资事务审核
procedure SP_PAY500C(ACheck:Integer;ATypeName,ADeptName,AFromEmpID,AToEmpID:string;
  AStartDate,AEndDate:TDateTime;AIsTypeAll,AIsDeptAll:Boolean);
var
  ATypeNo,ADeptNo:Integer;
  AFlag:string;
begin
  if AFromEmpID='' then AFromEmpID:=GetValue('select min(H150_002) from HRM150');
  if AToEmpID='' then AToEmpID:=GetValue('select max(H150_002) from HRM150');

  //事务类型
  ATypeNo:=GetValue('select P150_001 from PAY150 where P150_003='+''''+ATypeName+'''');
  ADeptNo:=GetValue('select H100_001 from HRM100 where H100_003='+''''+ADeptName+'''');

  //1=审核,2=反审核
  if ACheck=1 then AFlag:='Y' else AFlag:='N';

  if AIsTypeAll then
  begin
    if AIsDeptAll then
    begin
      SYSDM.qryQuery.Close;
      SYSDM.qryQuery.SQL.Clear;
      SYSDM.qryQuery.SQL.Add('update from PAY500 set P500_007='+''''+AFlag+'''');
      SYSDM.qryQuery.SQL.Add('where P500_006>='+GetDateString(AStartDate)+' and P500_006<='+GetDateString(AEndDate)+' and');
      SYSDM.qryQuery.SQL.Add('exists(select 1 from HRM150 where H150_002>='+''''+AFromEmpID+''''+' and H150_002<='+''''+AToEmpID+''''+')');
      SYSDM.qryQuery.ExecSQL;
    end else    //单一部门
    begin
      SYSDM.qryQuery.Close;
      SYSDM.qryQuery.SQL.Clear;
      SYSDM.qryQuery.SQL.Add('update from PAY500 set P500_007='+''''+AFlag+'''');
      SYSDM.qryQuery.SQL.Add('where P500_006>='+GetDateString(AStartDate)+' and P500_006<='+GetDateString(AEndDate)+' and');
      SYSDM.qryQuery.SQL.Add('exists(select 1 from HRM150 where H150_002>='+''''+AFromEmpID+''''+' and H150_002<='+''''+AToEmpID+''''+' and H150_005='+IntToStr(ADeptNo)+')');
      SYSDM.qryQuery.ExecSQL;
    end;
  end else
  begin
    if AIsDeptAll then
    begin
      SYSDM.qryQuery.Close;
      SYSDM.qryQuery.SQL.Clear;
      SYSDM.qryQuery.SQL.Add('update from PAY500 set P500_007='+''''+AFlag+'''');
      SYSDM.qryQuery.SQL.Add('where P500_001='+IntToStr(ATypeNo)+' and P500_006>='+GetDateString(AStartDate)+' and P500_006<='+GetDateString(AEndDate)+' and');
      SYSDM.qryQuery.SQL.Add('exists(select 1 from HRM150 where H150_002>='+''''+AFromEmpID+''''+' and H150_002<='+''''+AToEmpID+''''+' and H150_005='+IntToStr(ADeptNo)+')');
      SYSDM.qryQuery.ExecSQL;
    end else    //单一部门
    begin
      SYSDM.qryQuery.Close;
      SYSDM.qryQuery.SQL.Clear;
      SYSDM.qryQuery.SQL.Add('update from PAY500 set P500_007='+''''+AFlag+'''');
      SYSDM.qryQuery.SQL.Add('where P500_001='+IntToStr(ATypeNo)+' and P500_006>='+GetDateString(AStartDate)+' and P500_006<='+GetDateString(AEndDate)+' and');
      SYSDM.qryQuery.SQL.Add('exists(select 1 from HRM150 where H150_002>='+''''+AFromEmpID+''''+' and H150_002<='+''''+AToEmpID+''''+' and H150_005='+IntToStr(ADeptNo)+')');
      SYSDM.qryQuery.ExecSQL;
    end;
  end;
end;

procedure TPay500_03Form.SetInterface;
begin
  Caption:=GetDBString('PAY50003001');  //审核
  rbCheck.Caption:=GetDBString('PAY50003002');  //审核
  rbUnCheck.Caption:=GetDBString('PAY50003003');  //反审核
  lblType.Caption:=GetDBString('PAY50003004');  //事务类型
  lblDept.Caption:=GetDBString('PAY50003005');  //部门编号
  lblEmp.Caption:=GetDBString('PAY50003006');  //员工编号
  lblEmpTo.Caption:=GetDBString('PAY50003007');  //至
  lblDate.Caption:=GetDBString('PAY50003008');  //日期范围
  lblDateTo.Caption:=GetDBString('PAY50003009');  //至
  bbtnOk.Caption:=GetDBString('PAY50003010');  //确定(&O)
  bbtnExit.Caption:=GetDBString('PAY50003011');  //退出(&X) 
end;

procedure TPay500_03Form.FormCreate(Sender: TObject);
var
  ADate:TDateTime;
begin
  inherited;
  //事务类型
  cbType.Clear;
  cbType.Items.Add(GetDBString('COM00004013'));  //所有事务
  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('select P150_003 from PAY150 where P150_004=0 and P150_008='+GetBoolean(True));
  SYSDM.qryQuery.Open;
  while not SYSDM.qryQuery.Eof do
  begin
    cbType.Items.Add(SYSDM.qryQuery.Fields[0].AsString);
    SYSDM.qryQuery.Next;
  end;
  cbType.ItemIndex:=0;

  //部门资料
  cbDepart.Clear;
  cbDepart.Items.Add(GetDBString('COM00004007'));  //所有部门
  qryHrm100.Close;
  qryHrm100.Open;
  while not qryHrm100.Eof do
  begin
    cbDepart.Items.Add(qryHrm100.FieldByName('H100_002').AsString);
    qryHrm100.Next;
  end;
  cbDepart.ItemIndex:=0;

  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SSHORTDATE, ASystemDate, SizeOf(ASystemDate));
  ADate:=StrToDate(FormatDateTime(ASystemDate,GetServerDate));
  dtStartDate.Date:=ADate;
  dtEndDate.Date:=ADate;
  //设置界面信息
  SetInterface;
end;

procedure TPay500_03Form.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
//
end;

procedure TPay500_03Form.bbtnOkClick(Sender: TObject);
var
  AFromEmpID,AToEmpID:string;
  ADeptNo,ATypeNo:Integer;
  ACheckFlag:Boolean;
  AFromDate,AToDate:TDateTime;
begin
  inherited;
//确定
  if trim(cbType.Text)='' then
  begin
    ShowMsg('UMS10000073');  //事务类型不能为空
    cbType.SetFocus;
    Abort;
  end;
  ACheckFlag:=rbCheck.Checked;
  ATypeNo:=cbType.ItemIndex;
  if ATypeNo<>0 then ATypeNo:=GetValue('select C150_001 from CWA150 where C150_003='+''''+cbType.Text+'''');
  ADeptNo:=cbDepart.ItemIndex;
  if ADeptNo<>0 then ADeptNo:=GetValue('select H100_001 from HRM100 where H100_002='+''''+cbDepart.Text+'''');
  AFromEmpID:=trim(edtFromEmpID.Text);
  AToEmpID:=trim(edtToEmpID.Text);
  if AFromEmpID='' then AFromEmpID:=GetValue('select min(H150_002) from HRM150');
  if AToEmpID='' then AToEmpID:=GetValue('select max(H150_002) from HRM150');
  AFromDate:=dtStartDate.Date;
  AToDate:=dtEndDate.Date;

  if AFromEmpID>AToEmpID then
  begin
    ShowMsg('UMS10000076');  //起始员工编号不能大于结束编号
    edtFromEmpID.SetFocus;
    Abort;
  end;

  if AFromDate>AToDate then
  begin
    ShowMsg('UMS10000044');  //起始日期不能大于结束日期
    dtStartDate.SetFocus;
    Abort;
  end;

  SYSDM.qryQuery.Close;
  SYSDM.qryQuery.SQL.Clear;
  SYSDM.qryQuery.SQL.Add('update PAY500 set P500_007='+GetBoolean(ACheckFlag));
  SYSDM.qryQuery.SQL.Add('where P500_005>='+GetDateString(AFromDate)+' and P500_005<='+GetDateString(AToDate));
  if ATypeNo<>0 then SYSDM.qryQuery.SQL.Add(' and P500_001='+IntToStr(ATypeNo));
  SYSDM.qryQuery.SQL.Add(' and exists(select 1 from HRM150 where H150_001=P500_004 and H150_002>='+''''+AFromEmpID+''''+' and H150_002<='+''''+AToEmpID+'''');
  if ADeptNo<>0 then SYSDM.qryQuery.SQL.Add(' and H150_005='+IntToStr(ADeptNo));
  SYSDM.qryQuery.SQL.Add(')');
  SYSDM.qryQuery.ExecSQL;

  ShowMsg('UMS10000083');  //审核或反审核处理成功
  Close;
end;

procedure TPay500_03Form.bbtnExitClick(Sender: TObject);
begin
  inherited;
//退出
  Close;
end;

procedure TPay500_03Form.SpeedButton1Click(Sender: TObject);
begin
  inherited;
//员工编号查询1
  if not edtFromEmpID.Focused then edtFromEmpID.SetFocus;
  HwSelDataForm:=THwSelDataForm.Create(Application);
  HwSelDataForm.OpenSelData(qryHrm150,nil);
  if HwSelDataForm.ShowModal=1 then
  begin
    edtFromEmpID.Text:=qryHrm150.FieldByName('H150_002').AsString;
  end;
end;

procedure TPay500_03Form.SpeedButton2Click(Sender: TObject);
begin
  inherited;
//员工编号查询2
  if not edtToEmpID.Focused then edtToEmpID.SetFocus;
  HwSelDataForm:=THwSelDataForm.Create(Application);
  HwSelDataForm.OpenSelData(qryHrm150,nil);
  if HwSelDataForm.ShowModal=1 then
  begin
    edtToEmpID.Text:=qryHrm150.FieldByName('H150_002').AsString;
  end;
end;

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

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

initialization
  RegisterClass(TPay500_03Form);

finalization
  UnRegisterClass(TPay500_03Form);

end.

⌨️ 快捷键说明

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