📄 pay500_02.pas.svn-base
字号:
unit Pay500_02;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Bas100_01, Db, StdCtrls, Buttons, wwdbdatetimepicker,
Mask, ADODB, ExtCtrls, Menus;
type
TPay500_02Form = class(TBas100_01Form)
Bevel1: TBevel;
lblType: TLabel;
lblDept: TLabel;
lblEmp: TLabel;
lblEmpTo: TLabel;
lblDate: TLabel;
lblDateTo: TLabel;
lblAmount: TLabel;
lblUnit: TLabel;
cbType: TComboBox;
dtStartDate: TwwDBDateTimePicker;
dtEndDate: TwwDBDateTimePicker;
bbtnOk: TBitBtn;
bbtnExit: TBitBtn;
cbDepart: TComboBox;
edtAmount: TEdit;
edtFromEmpID: TEdit;
SpeedButton1: TSpeedButton;
edtToEmpID: TEdit;
SpeedButton2: TSpeedButton;
qryHrm100: TADOQuery;
qryHrm150: TADOQuery;
qryHrm150H150_001: TAutoIncField;
qryHrm150H150_002: TStringField;
qryHrm150H150_003: TStringField;
qryPay500: TADOQuery;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure bbtnOkClick(Sender: TObject);
procedure bbtnExitClick(Sender: TObject);
procedure edtAmountKeyPress(Sender: TObject; var Key: Char);
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_02Form: TPay500_02Form;
implementation
uses SYSDATA, HwSelData, CommFun;
{$R *.DFM}
procedure TPay500_02Form.SetInterface;
begin
//设置界面信息
Caption:=GetDBString('PAY50002001'); //成批录入
lblType.Caption:=GetDBString('PAY50002002'); //事务类型
lblDept.Caption:=GetDBString('PAY50002003'); //部门编号
lblEmp.Caption:=GetDBString('PAY50002004'); //员工编号
lblEmpTo.Caption:=GetDBString('PAY50002005'); //至
lblDate.Caption:=GetDBString('PAY50002006'); //日期范围
lblDateTo.Caption:=GetDBString('PAY50002007'); //至
lblAmount.Caption:=GetDBString('PAY50002008'); //事务金额
lblUnit.Caption:=GetDBString('PAY50002009'); //元
bbtnOk.Caption:=GetDBString('PAY50002010'); //确定(&O)
bbtnExit.Caption:=GetDBString('PAY50002011'); //退出(&X)
end;
procedure TPay500_02Form.FormCreate(Sender: TObject);
var
ADate:TDateTime;
begin
inherited;
//事务类型
cbType.Clear;
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.Items.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_02Form.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
//
end;
procedure TPay500_02Form.bbtnOkClick(Sender: TObject);
var
AFromEmpID,AToEmpID:string;
ADeptNo,AEmpNo,ATypeNo:Integer;
AFromDate,AToDate:TDateTime;
begin
inherited;
//确定
if trim(cbType.Text)='' then
begin
ShowMsg('UMS10000073'); //事务类型不能为空
cbType.SetFocus;
Abort;
end;
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;
if (trim(edtAmount.Text)='') or (trim(edtAmount.Text)='0') then
begin
ShowMsg('UMS10000252'); //事务数值不能为空或零
edtAmount.SetFocus;
Abort;
end;
try
StrToInt(edtAmount.Text)
except
ShowMsg('UMS10000251'); //事务数值必须输入数值
edtAmount.SetFocus;
Abort;
end;
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('select H150_001, H150_003 from HRM150');
SYSDM.qryQuery.SQL.Add('where H150_002>='+''''+AFromEmpID+''''+' and H150_002<='+''''+AToEmpID+'''');
if cbDepart.ItemIndex<>0 then SYSDM.qryQuery.SQL.Add(' and H150_005='+IntToStr(ADeptNo));
SYSDM.qryQuery.Open;
while not SYSDM.qryQuery.Eof do
begin
AEmpNo:=SYSDM.qryQuery.FieldByName('H150_001').Value;
while AFromDate<=AToDate do
begin
//插入薪资事务表(PAY500)
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('insert into PAY500(P500_001,P500_002,P500_003,P500_004,P500_005,P500_006,P500_007)');
SYSDM.qryQuery.SQL.Add('select '+IntToStr(ATypeNo)+',null,'+''''+cbType.Text+''''+','+IntToStr(AEmpNo)+','+GetDateString(AFromDate)+','+edtAmount.Text+',0');
SYSDM.qryQuery.ExecSQL;
AFromDate:=AFromDate+1;
end;
SYSDM.qryQuery.Next;
end;
ShowMsg('UMS10000077'); //成批录入成功
Close;
end;
procedure TPay500_02Form.bbtnExitClick(Sender: TObject);
begin
inherited;
//退出
Close;
end;
procedure TPay500_02Form.edtAmountKeyPress(Sender: TObject; var Key: Char);
begin
inherited;
ValidFloat(Sender,Key);
end;
procedure TPay500_02Form.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_02Form.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_02Form.edtFromEmpIDKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key=vk_F4 then SpeedButton1.Click;
end;
procedure TPay500_02Form.edtToEmpIDKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key=vk_F4 then SpeedButton2.Click;
end;
initialization
RegisterClass(TPay500_02Form);
finalization
UnRegisterClass(TPay500_02Form);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -