📄 sysdata_manage.pas
字号:
//3.更改与当前人员相关的数据
//3.1处理表outbom_log
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('delete from outbom_log where empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败3.1!');
emp_BLflag:=false; exit;
end;
end;
//3.2处理企业收支表(新增一条支出记录,关于离职员工的领工资的所有金额,以确保数据的安全性)
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('select sum(money) as total from brrow where empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql; open;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败3.6!');
emp_BLflag:=false; exit;
end;
if recordcount=0 then emp_all_money:=0
else emp_all_money:=fieldvalues['total'];
if emp_all_money>0 then
begin
//1.1在企业支出表中新增一条记录,员工的所有借支
close; sql.Clear;
sql.Add('insert into payout (event, money, tmp_id)');
sql.Add('values(:V_event,:V_money, :v_tmp_id)');
parameters.ParamValues['v_money']:=emp_all_money;
parameters.ParamValues['V_tmp_id']:=tmp_id;
parameters.ParamValues['v_event']:='员工:'+ListEditor1.Cells[1,i]+'离厂:所有历史工资收入总和';
try
execsql;
except
msgErr(handle,'离职人员工资清算失败,请重试!');
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
emp_BLflag:=false; break; exit;
end;
end;//if emp_all_money>0 then .End
end;// 3.2.End
//3.3处理表brrow
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('delete from brrow where empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败3.3!');
emp_BLflag:=false; exit;
end;
end;
//3.4处理表ck_material
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('delete from ck_material where empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败3.4!');
emp_BLflag:=false; exit;
end;
end;
//3.5处理表earn_abs
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('delete from earn_abs where empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败3.5!');
emp_BLflag:=false; exit;
end;
end;
//3.6处理表personshouzhi
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('delete from personshouzhi where empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败3.6!');
emp_BLflag:=false; exit;
end;
end;
//3.7处理表emp_pay
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('delete from emp_pay where empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败3.7!');
emp_BLflag:=false; exit;
end;
end;
//3.8处理表Emp_Payout
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('delete from Emp_Payout where empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败3.8!');
emp_BLflag:=false; exit;
end;
end;
//3.9处理表employee_backup
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('delete from employee_Backup where LZ_empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败3.9!');
emp_BLflag:=false; exit;
end;
end;
//4.0处理表employee
with ADOQtmp_emp do
begin
close;sql.clear;
sql.Add('delete from employee where empid=:v_empid');
parameters.ParamValues['v_empid']:=strtoint(ListEditor1.Cells[0,i]);
try
execsql;
except
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
MsgErr(handle,'离职员工数据清理失败4.0!');
emp_BLflag:=false; exit;
end;
end;
//提交数据库
if not emp_BLflag then
begin
if i>1 then tmpstr:='截止到编号为:['+ListEditor1.Cells[0,i-1]+'] 离职员工数据清理成功,剩下其它失败!'
else tmpstr:='离职员工数据清理失败,请重试!';
msgerr(handle,tmpstr);
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
inc(emp_num_e); abort; exit;
end;
if datamod.ADOCon.InTransaction then
begin
try
datamod.ADOCon.CommitTrans;
except
if i>1 then tmpstr:='截止到编号为:['+ListEditor1.Cells[0,i-1]+'] 离职员工数据清理成功,剩下其它失败!'
else tmpstr:='离职员工数据清理失败,请重试!';
MsgErr(handle,tmpstr);
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
inc(emp_num_e); exit;
end;
end;
end;//循环结束.End ( //利用循环清除离职员工数据)
if emp_num_e>0 then
begin
if emp_num_s=emp_num_e then
begin
tmpstr:='当前所选择的:['+inttostr(emp_num_s)+'] 位离职员工的数据清理全部失败!';
end
else
begin
tmpstr:='当前所选择的:['+inttostr(emp_num_s)+']位离职员工中, 其中有 ['+inttostr(emp_num_s-emp_num_e)+'] 位数据清理成功,';
tmpstr:=tmpstr+#13+#13+' 其他 ['+inttostr(emp_num_e)+'] 位离职员工数据清理失败!';
end;
end
else
tmpstr:='当前所选择的:['+inttostr(emp_num_s)+']位离职员工数据清理全部成功!';
msgok(handle,tmpstr);
progressbar1.Position:=0;
Label_Display.Visible:=true;
application.ProcessMessages;
if emp_num_e=0 then
ListEditor1.Strings.Clear;
end;
procedure TfrmSysdata_manage.ListEditor1StringsChange(Sender: TObject);
begin
Label_num.Caption:='----'+inttostr(ListEditor1.Strings.Count)+' 个';
SaveBtn.Enabled:=ListEditor1.Strings.Count>0;
end;
//显示企业应支付的工资
procedure TfrmSysdata_manage.CheckBox1Click(Sender: TObject);
var
all_money:real;
begin
if not ADOQ_away_query.Active then exit;
if ADOQ_away_query.RecordCount=0 then exit;
Btn_Account.Enabled:=checkbox1.Checked;
LBL_money.Visible:=checkbox1.Checked;
all_money:=0;
if not checkbox1.Checked then exit;
ADOQ_away_query.First;
while not ADOQ_away_query.Eof do
begin
all_money:=all_money+ADOQ_away_query.fieldvalues['balance'];
ADOQ_away_query.next;
end;
LBL_money.Visible:=true;
LBL_money.Caption:='当前所选人员企业共需支付:'+'¥'+format('%.2f',[all_money]);
end;
//清算离职员工工资,以保证离职人员的收入为0
procedure TfrmSysdata_manage.Btn_AccountClick(Sender: TObject);
var
tmp_id:integer;
tmpstr:string;
Account_flag: boolean; // , is_scroll
begin
if not ADOQ_away_query.Active then exit;
if ADOQ_away_query.RecordCount=0 then exit;
tmpstr:='确认将当前所选择的: ['+inttostr(ADOQ_away_query.RecordCount);
tmpstr:=tmpstr+'] 位离职员工的工资全部结算清吗?';
if msgqst(handle,tmpstr)=idno then begin abort; exit end;
if not get_oper_tmpid(curAdmin.user_id , tmp_id) then
begin
MsgErr(handle,'离职人员工资清算失败,请重试--ALL!');
exit;
end;
progressbar1.Max:=ADOQ_away_query.RecordCount;
progressbar1.Position:=0;
Label_Display.Visible:=true;
application.ProcessMessages;
ADOQ_away_query.first;
//数据提交开始
datamod.ADOCon.BeginTrans;
Account_flag:=true;
with ADOQ_away_query do
begin
while not Eof do
begin
progressbar1.Position:=progressbar1.Position+1;
application.ProcessMessages;
//1.1在工人借支表中新增一条记录,员工最后的结余
if FieldValues['balance']>0 then
with ADOQtmp do
begin
close; sql.Clear;
sql.Add('insert into brrow (empid, event, money, tmp_id)');
sql.Add('values(:V_empid,:V_event,:V_money, :v_tmp_id)');
parameters.ParamValues['V_empid']:=ADOQ_away_query.FieldValues['empid'];
parameters.ParamValues['v_money']:=ADOQ_away_query.FieldValues['balance'];
parameters.ParamValues['V_tmp_id']:=tmp_id;
parameters.ParamValues['v_event']:='员工离厂工资清算:企业支付现金工资';
try
execsql;
except
msgErr(handle,'离职人员工资清算失败,请重试!');
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
Account_flag:=false; break;
end;
end
else
if FieldValues['balance']<0 then
begin
tmpstr:='该离职员工收入为负数,无法进行清算处理!';
tmpstr:=tmpstr+#13+#13+' 是否跳至 [下一员工] 继续清算工资!';
if Msgqst(handle,tmpstr)=idno then
begin
Account_flag:=false; break; exit;
end
else
begin
if ADOQ_away_query.eof then begin break; exit; end;
ADOQ_away_query.Next; continue;
end;
end
else
if FieldValues['balance']=null then
begin
tmpstr:='该离职员工没有收支记录,无法进行清算处理!';
tmpstr:=tmpstr+#13+#13+'是否跳至 [下一员工] 继续清算工资!';
if Msgqst(handle,tmpstr)=idno then
begin
Account_flag:=false; break; exit;
end
else
begin
if ADOQ_away_query.eof then begin break; exit; end;
ADOQ_away_query.Next; continue;
end;
end;
next;
end; //(while not ADOQ_away_query.Eof do).End
end;
//数据提交
if Account_flag and datamod.ADOCon.InTransaction then
begin
try
datamod.ADOCon.CommitTrans;
except
MSgerr(handle,'离职人员工资清算失败,请重试!');
exit;
end;
MsgoK(handle,'离职人员工资清算成功!');
CheckBox1.Checked:=false;
progressbar1.Position:=0;
Label_Display.Visible:=false;
application.ProcessMessages;
Account_emppay;//刷新当前显示的离职员工的收支表
end
else
begin
if datamod.ADOCon.InTransaction then datamod.ADOCon.RollbackTrans;
progressbar1.Position:=0;
Label_Display.Visible:=false;
application.ProcessMessages;
end;
end;
procedure TfrmSysdata_manage.SearchBtnClick(Sender: TObject);
begin
empid:=trim(ComboBox_awayEmpID.Text);
empname:=trim(edtname.Text);
depname:=trim(combobox_dep.Text);
dutyname:=trim(combobox_duty.Text);
Account_emppay;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -