📄 cwa550_03.pas.svn-base
字号:
unit Cwa550_03;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Bas100_01, StdCtrls, Buttons, wwdbdatetimepicker, Mask,
ExtCtrls, Db, ADODB, Menus;
type
TCwa550_03Form = class(TBas100_01Form)
Bevel1: TBevel;
Label1: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
dtStartDate: TwwDBDateTimePicker;
dtEndDate: TwwDBDateTimePicker;
cbDepart: TComboBox;
bbtnOk: TBitBtn;
bbtnExit: TBitBtn;
edtFromEmpID: TEdit;
edtToEmpID: TEdit;
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 Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
procedure SetInterface;
{ Private declarations }
public
{ Public declarations }
end;
var
Cwa550_03Form: TCwa550_03Form;
implementation
uses SYSDATA, HwSelData, Wait, CommFun;
{$R *.DFM}
//签卡处理
// ADeptNo: 部门电脑编号
// AFromEmpID: 起始工号
// AToEmpID: 结束工号
// AStartDate: 起始日期
// AEndDate: 结束日期
// AUserName: 签卡人名
procedure ApproveAttend(ADeptNo:Integer;AFromEmpID,AToEmpID:string;AStartDate,AEndDate:TDateTime;AUserName:String);
var
AYear,AMonth:Integer;
begin
if AFromEmpID='' then AFromEmpID:=GetValue('select min(H150_002) from HRM150');
if AToEmpID='' then AToEmpID:=GetValue('select max(H150_002) from HRM150');
if AStartDate=0 then AStartDate:=GetServerDate;
if AEndDate=0 then AEndDate:=GetServerDate;
if AStartDate>AEndDate then
begin
ShowMsg('UMS10000044'); //起始日期不能大于结束日期
Abort;
end;
//取得期段资料
GetPeriod(AStartDate,AEndDate,AYear,AMonth);
if IsExists('select 1 from CWA550A where C550A_006='+GetBoolean(True)+' and C550A_001='+IntToStr(AYear)+' and C550A_002='+IntToStr(AMonth)) then
begin
ShowMsg('UMS10000082'); //本月数据已审核,不能进行签卡
Abort;
end;
if ADeptNo=0 then //所有部门
begin
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('update CWA550B set C550B_007='+GetBoolean(True)+',C550B_006='+''''+AUserName+'''');
SYSDM.qryQuery.SQL.Add('where C550B_001>='+GetDateString(AStartDate)+' and C550B_001<='+GetDateString(AEndDate)+' and');
SYSDM.qryQuery.SQL.Add(' C550B_002 in (select H150_001 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 CWA550B set C550B_007='+GetBoolean(True)+',C550B_006='+''''+AUserName+'''');
SYSDM.qryQuery.SQL.Add('where C550B_001>='+GetDateString(AStartDate)+' and C550B_001<='+GetDateString(AEndDate)+' and');
SYSDM.qryQuery.SQL.Add(' C550B_002 in (select H150_001 from HRM150 where H150_002>='+''''+AFromEmpID+''''+' and H150_002<='+''''+AToEmpID+''''+') and');
SYSDM.qryQuery.SQL.Add(' exists(select 1 from HRM150 where H150_001=C550B_002 and H150_005='+IntToStr(ADeptNo)+')');
SYSDM.qryQuery.ExecSQL;
end;
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('update CWA550A set C550A_006='+GetBoolean(False));
SYSDM.qryQuery.ExecSQL;
//考勤结果明细表(CWA550B)(按年、月、员工编号、事务类型分级汇总)
SYSDM.qryQuery.Close;
SYSDM.qryQuery.SQL.Clear;
SYSDM.qryQuery.SQL.Add('update A set A.C550A_007=B.C550B_006');
SYSDM.qryQuery.SQL.Add('from CWA550A A,');
SYSDM.qryQuery.SQL.Add(' (select C550B_002, C550B_004, sum(C550B_006) as C550B_006 from CWA550B');
SYSDM.qryQuery.SQL.Add(' where C550B_001>='+GetDateString(AStartDate)+' and C550B_001<='+GetDateString(AEndDate)+' and C550B_007<>1');
SYSDM.qryQuery.SQL.Add(' group by C550B_001, C550B_002, C550B_004) B');
SYSDM.qryQuery.SQL.Add('where A.C550A_003=B.C550B_002 and A.C550A_005=B.C550B_004 and');
SYSDM.qryQuery.SQL.Add(' A.C550A_001='+IntToStr(AYear)+' and A.C550A_002='+IntToStr(AMonth));
SYSDM.qryQuery.ExecSQL;
end;
procedure TCwa550_03Form.SetInterface;
begin
Caption:=GetDBString('CWA55003001'); //签卡
Label1.Caption:=GetDBString('CWA55003002'); //部门编号
Label3.Caption:=GetDBString('CWA55003003'); //员工编号
Label4.Caption:=GetDBString('CWA55003004'); //至
Label5.Caption:=GetDBString('CWA55003005'); //日期范围
Label6.Caption:=GetDBString('CWA55003004'); //至
bbtnOk.Caption:=GetDBString('CWA55003006'); //确定(&O)
bbtnExit.Caption:=GetDBString('CWA55003007'); //退出(&X)
qryHrm150H150_002.DisplayLabel:=GetDBString('CWA55003008'); //员工编号
qryHrm150H150_003.DisplayLabel:=GetDBString('CWA55003009'); //员工姓名
end;
procedure TCwa550_03Form.FormCreate(Sender: TObject);
begin
inherited;
qryHrm150.Close;
qryHrm150.SQL.Clear;
if not ASuper then
qryHrm150.SQL.Add('select H150_001,H150_002,H150_003 from HRM150 where H150_005 in (select S500C_002 from SYS500C where S500C_003=''DEP'' and S500C_004='+GetBoolean(True)+' and S500C_001='+IntToStr(AUserID)+') order by H150_002')
else
qryHrm150.SQL.Add('select H150_001,H150_002,H150_003 from HRM150 order by H150_002');
qryHrm150.Open;
//部门资料
cbDepart.Items.Clear;
cbDepart.Items.Add(GetDBString('COM00004007')); //所有部门
qryHrm100.Close;
qryHrm100.SQL.Clear;
qryHrm100.SQL.Add('select * from HRM100 where H100_004='+GetBoolean(True));
qryHrm100.Open;
while not qryHrm100.Eof do
begin
cbDepart.Items.Add(qryHrm100.FieldByName('H100_002').AsString);
qryHrm100.Next;
end;
cbDepart.ItemIndex:=0;
dtStartDate.Date:=Date;
dtEndDate.Date:=Date;
//设置界面信息
SetInterface;
end;
procedure TCwa550_03Form.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
//
end;
procedure TCwa550_03Form.bbtnOkClick(Sender: TObject);
var
ADeptNo:Integer;
ADeptName,AFromEmpID,AToEmpID:string;
AStartDate,AEndDate:TDateTime;
begin
inherited;
//确定
WaitForm.Show;
WaitForm.Update;
ADeptName:=cbDepart.Text;
AFromEmpID:=edtFromEmpID.Text;
AToEmpID:=edtToEmpID.Text;
AStartDate:=dtStartDate.Date;
AEndDate:=dtEndDate.Date;
ADeptNo:=GetValue('select H100_001 from HRM100 where H100_002='+''''+ADeptName+'''');
ApproveAttend(ADeptNo,AFromEmpID,AToEmpID,AStartDate,AEndDate,AUserName);
WaitForm.Close;
ShowMsg('UMS10000080'); //签卡处理成功
Close;
end;
procedure TCwa550_03Form.bbtnExitClick(Sender: TObject);
begin
inherited;
//退出
Close;
end;
procedure TCwa550_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 TCwa550_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 TCwa550_03Form.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key=vk_F4 then SpeedButton1.Click;
end;
procedure TCwa550_03Form.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key=vk_F4 then SpeedButton2.Click;
end;
initialization
RegisterClass(TCwa550_03Form);
finalization
UnRegisterClass(TCwa550_03Form);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -