📄 employee.pas
字号:
Msgok(handle,'请指定当前员工的性别!');
DBE_Sex.SetFocus;
exit;
end;
if (State in [dsinsert]) and findRec('employee','empid',temp_id,info) then
begin
MsgOK(handle,'该人员编号已存在,致数据不可更新!');
DBE_ID.SetFocus;
exit;
end;
try
post;
except
end;
end;
end;
procedure TForm_employee.PageControl1Changing(Sender: TObject;
var AllowChange: Boolean);
begin
if ADOQ_employee.State in [dsinsert,dsedit] then
if PageControl1.ActivePageIndex in [0,1] then
begin
Msgok(handle,'数据库正处在操作状态,请先按 [取消] 按钮!');
AllowChange:=false;
end;
end;
procedure TForm_employee.DBE_IDCardKeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9',#13,#8]) then abort;
end;
procedure TForm_employee.DBEdit_PhoKeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9',#13,#8,'-']) then abort;
end;
procedure TForm_employee.BitBtn2Click(Sender: TObject);
begin
PageControl1.ActivePageIndex:=0;
PageControl1Change(self);
end;
procedure TForm_employee.RadioGroup1Click(Sender: TObject);
begin
case RadioGroup1.ItemIndex of
0:
begin
edit1.Clear;
GroupBox1.Visible:=true;
Label7.Caption:='人员编码:';
GroupBox3.Visible:=false;
GroupBox2.Visible:=false;
end;
1:
begin
edit1.Clear;
GroupBox1.Visible:=true;
Label7.Caption:='人员姓名:';
GroupBox3.Visible:=false;
GroupBox2.Visible:=false;
end;
2:
begin
GroupBox1.Visible:=false;
GroupBox3.Visible:=true;
Label14.Caption:='部门名称:';
GroupBox2.Visible:=false;
ADOT_dep.Close; ADOT_dep.Open;
DBLookupComboBox3.ListField:='';
DBLookupComboBox3.KeyField:='';
DBLookupComboBox3.ListSource:=DS_dep_T;
DBLookupComboBox3.ListField:='depname';
DBLookupComboBox3.KeyField:='depname';
end;
3:
begin
GroupBox1.Visible:=false;
GroupBox3.Visible:=true;
Label14.Caption:='职务名称:';
GroupBox2.Visible:=false;
ADOT_duty.Close; ADOT_duty.Open;
DBLookupComboBox3.ListField:='';
DBLookupComboBox3.KeyField:='';
DBLookupComboBox3.ListSource:=DS_duty_T;
DBLookupComboBox3.ListField:='dutyname';
DBLookupComboBox3.KeyField:='dutyname';
end;
4:
begin
GroupBox1.Visible:=false;
GroupBox2.Visible:=true;
GroupBox3.Visible:=false;
WktEnd.date:=date;
end;
5:
begin
edit1.Clear;
GroupBox1.Visible:=true;
Label7.Caption:='身份证号:';
GroupBox3.Visible:=false;
GroupBox2.Visible:=false;
end;
6:
begin
edit1.Clear;
GroupBox1.Visible:=true;
Label7.Caption:='省份:';
GroupBox3.Visible:=false;
GroupBox2.Visible:=false;
end;
7:
begin
edit1.Clear;
GroupBox1.Visible:=true;
Label7.Caption:='市:';
GroupBox3.Visible:=false;
GroupBox2.Visible:=false;
end;
end;
end;
procedure TForm_employee.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Label7.Caption <> '身份证号:' then exit;
if not (key in ['0'..'9',#13,#8]) then abort;
end;
procedure TForm_employee.LocateBtnClick(Sender: TObject);
var
strwhere, strorder, str1, str2:string;
begin
strwhere:=''; strorder:='';
case RadioGroup1.ItemIndex of
0:
begin
if trim(Edit1.Text)<>'' then
begin
try
strtoint(trim(Edit1.Text));
except
MsgErr(handle,'请输入正确的员工编号!');
Edit1.SetFocus; exit;
end;
strwhere:='Where empid ='+''''+Trim(Edit1.Text)+'''';
strorder:='order by empid';
end;
end;
1:
begin
if trim(Edit1.Text)<>'' then
begin
strwhere:='Where empname like '+''''+'%'+Trim(Edit1.Text)+'%'+'''';
strorder:='order by empid';
end;
end;
2:
begin
str1:=trim(DBLookupComboBox3.Text);
if str1<>'' then
begin
ADOT_dep.Locate('depname',str1,[loCaseInsensitive]);
str1:=ADOT_dep.FieldValues['depid'];
strwhere:='Where depid='+''''+str1+'''';
strorder:='order by empid';
end;
end;
3:
begin
str2:=trim(DBLookupComboBox3.Text);
if str2<>'' then
begin
ADOT_duty.Locate('dutyname',str1,[loCaseInsensitive]);
str2:=ADOT_duty.FieldValues['dutyid'];
strwhere:='Where dutyid='+''''+str2+'''';
strorder:='order by empid';
end;
end;
4:
begin
if WktStart.Date>WktEnd.Date then
begin
showmessage('开始时间大于结束时间,请重新输入!');
WktStart.SetFocus;
exit;
end;
strwhere:='Where [worktime] between :V_str1 and :V_str2';
strorder:='order by empid';
end;
5:
begin
if trim(Edit1.Text)<>'' then
begin
strwhere:='Where idcard like '+''''+'%'+trim(Edit1.Text)+'%'+'''';
strorder:='order by empid';
end;
end;
6:
begin
if trim(Edit1.Text)<>'' then
begin
strwhere:='Where province like '+''''+'%'+Trim(Edit1.Text)+'%'+'''';
strorder:='order by empid';
end;
end;
7:
begin
if trim(Edit1.Text)<>'' then
begin
strwhere:='Where area like '+''''+'%'+Trim(Edit1.Text)+'%'+'''';
strorder:='order by empid';
end;
end;
end;
//人员范围选择(是否包括非在职人员)
case RadioGroup2.ItemIndex of
0:
strwhere:=strwhere;
1:
begin
if strwhere<>'' then strwhere:=strwhere+' and (state=1)'
else strwhere:='where (state=1)';
end;
2:
begin
if strwhere<>'' then strwhere:=strwhere+' and (state=0)'
else strwhere:='where (state=0)';
end;
end;
if strorder='' then strorder:='ORDER BY empid';
with ADOQ_Employee do
begin
sql.Strings[1]:=strwhere;
sql.Strings[2]:=strorder;
if RadioGroup1.ItemIndex=4 then
begin
parameters.ParamValues['V_str1']:=strtodatetime(formatdatetime('yyyy-mm-dd',WKtstart.Date)+' 00:00:00');
parameters.ParamValues['V_str2']:=strtodatetime(formatdatetime('yyyy-mm-dd',WktEnd.Date)+' 23:59:59');
end;
try
execsql;
open;
except
MsgErr(handle,'人员信息查找失败!');
refreshdb;
exit;
end;
end;
PageControl1.ActivePageIndex:=0;
PageControl1Change(self);
end;
procedure TForm_employee.BitBtn1Click(Sender: TObject);
var maxid, empid_int,tmp_id, tmp_empid:integer;
empid,empname:string;
emp_BLflag:boolean;
begin
//0.判断当前人员状态
if curAdmin.team_power[0][7]='0' then exit;
if not adoq_employee.Active then exit;
if adoq_employee.RecordCount=0 then exit;
if adoq_employee.FieldValues['state']=0 then exit;
if MsgQst(handle,' 确定当前人员 ['+adoq_employee.FieldValues['empname'] +'] 离职吗?'+#13+#13+'(注意:人员离职后,将无法还原人员信息!)')=idno
then exit;
empid_int:=adoq_employee.FieldValues['empid'];
tmp_empid:=adoq_employee.FieldValues['id'];
//1.找到离职人员的最大编码
GetMaxID(datamod.ADOCon,'employee','empid',maxid);
if maxid<500000 then maxid:=500000;
if not get_oper_tmpid(curAdmin.user_id , tmp_id) then
begin
MsgErr(handle,'人员人员离职失败,请重试--ALL!');
exit;
end;
//数据提交开始
emp_BLflag:=true;
datamod.ADOCon.BeginTrans;
//2.更改人员编码
with ADOQtmp_emp do
begin
close;sql.clear;
sql.add('insert into employee(empid,empname,sex,depid,dutyid,grade,telephone,mobile,worktime,email,idcard,born,province,area,address,state,photo)'); //,
sql.add('values(:empid,:empname,:sex,:depid,:dutyid,:grade,:telephone,:mobile,:worktime,:email,:idcard,:born,:province,:area,:address,0,:photo)'); //:photo
parameters.ParamValues['empid']:=maxid;
parameters.ParamValues['empname']:=ADOQ_employee.FieldValues['empname'];
parameters.ParamValues['sex']:=ADOQ_employee.FieldValues['sex'];
parameters.ParamValues['depid']:=ADOQ_employee.FieldValues['depid'];
parameters.ParamValues['dutyid']:=ADOQ_employee.FieldValues['dutyid'];
parameters.ParamValues['grade']:=ADOQ_employee.FieldValues['grade'];
parameters.ParamValues['telephone']:=ADOQ_employee.FieldValues['telephone'];
parameters.ParamValues['mobile']:=ADOQ_employee.FieldValues['mobile'];
parameters.ParamValues['worktime']:=ADOQ_employee.FieldValues['worktime'];
parameters.ParamValues['email']:=ADOQ_employee.FieldValues['email'];
parameters.ParamValues['idcard']:=ADOQ_employee.FieldValues['idcard'];
parameters.ParamValues['born']:=ADOQ_employee.FieldValues['born'];
parameters.ParamValues['province']:=ADOQ_employee.FieldValues['province'];
parameters.ParamValues['area']:=ADOQ_employee.FieldValues['area'];
parameters.ParamValues['address']:=ADOQ_employee.FieldValues['address'];
//传送人员相片
if not ADOQ_employee.FieldByName('photo').IsNull then
Parameters.ParamByName('photo').LoadFromStream(CreateBlobStream(ADOQ_employee.FieldByName('photo'),bmRead),ftGraphic);
// parameters.ParamValues['photo'] :=createblobstream(ADOQ_employee.FieldByName('photo'),bmRead);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'人员离职处理失败2!');
emp_BLflag:=false; exit;
end;
end; //2.更改人员编码
//3.更改与当前人员相关的数据
//3.1处理表outbom_log
with ADOQtmp_emp do
begin
//如果存在未验收的工序料时,提出
close;sql.clear;
sql.Add('select empid from outbom_log where qbfl_flag=0 and empid=:v_oldempid ');
parameters.ParamValues['v_oldempid']:=ADOQ_employee.FieldValues['empid'];
open;
if recordcount >0 then
begin
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'该人员有未退工序料,请先退料!');
emp_BLflag:=false; abort; exit;
end;
close;sql.clear;
sql.Add('update outbom_log set empid=:v_empid where empid=:v_oldempid');
parameters.ParamValues['v_empid']:=maxid;
parameters.ParamValues['v_oldempid']:=ADOQ_employee.FieldValues['empid'];
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'人员离职处理失败3.1!');
emp_BLflag:=false; exit;
end;
end;
//3.3处理表brrow
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('update brrow set empid=:v_empid where empid=:v_oldempid');
parameters.ParamValues['v_empid']:=maxid;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -