📄 emppay_out.pas
字号:
tmpstr:='当前所选择的:['+inttostr(emp_num_s)+']位员工中, 其中有 ['+inttostr(emp_num_e)+'] 位已发该月份工资,';
tmpstr:=tmpstr+#13+#13+' 其他 ['+inttostr(emp_num_s-emp_num_e)+'] 位人员 ['+year_str+'年'+month_str+'月] 的工资均发放成功!';
end;
end
else
begin
tmpstr:='当前所选择的:['+inttostr(emp_num_s)+']位员工的 [';
tmpstr:=tmpstr+year_str+'年'+month_str+'月] 的工资发放成功!';
end;
msgok(handle,tmpstr);
if not sys_bool then exit;
ListEditor1.Strings.Clear;
end;
procedure TForm_EmpPay_Out.FormShow(Sender: TObject);
var tmpdatetime:TDateTime;
begin
GetHostDateTime(datamod.ADOCon,tmpdatetime);
syear.MaxValue:=yearof(tmpdatetime);
syear.Text:=inttostr(yearof(tmpdatetime));
smonth.Text:=inttostr(monthof(tmpdatetime));
//添加部门信息
with ADOQtmp do
begin
close; sql.Clear;
sql.Add('select depname from department');
open;
combobox_dep.Items.Clear;
first;
while not eof do
begin
combobox_dep.Items.Add(fieldvalues['depname']);
next;
end;
end;
//添加职务信息
with adoqtmp do
begin
close; sql.Clear;
sql.Add('select dutyname from duty');
open;
combobox_duty.Items.Clear;
first;
while not eof do
begin
combobox_duty.Items.Add(fieldvalues['dutyname']);
next;
end;
close;
end;
end;
//查找对应待发工资的人员
procedure TForm_EmpPay_Out.SearchBtnClick(Sender: TObject);
begin
with ADOQ_emp do
begin
close; sql.Clear;
sql.Add('select a.empid,a.empname,a.sex,b.depname,c.dutyname from employee a,department b, duty c,Emp_Pay d');
case RadioGroup1.ItemIndex of
0:
begin
sql.add('where a.depid=b.depid and a.dutyid=c.dutyid and d.empid=a.empid and a.state=1 and b.depname=:depname');
parameters.ParamValues['depname']:=trim(combobox_dep.Text);
end;
1:
begin
sql.Add('where a.depid=b.depid and a.dutyid=c.dutyid and a.empid=d.empid and a.state=1 and c.dutyname=:dutyname');
parameters.ParamValues['dutyname']:=trim(combobox_duty.Text);
end;
2:
begin
sql.Add('where a.depid=b.depid and a.dutyid=c.dutyid and d.empid=a.empid and a.state=1 and a.empid=:empid');
parameters.ParamValues['empid']:=trim(edit1.Text);
end;
3:
begin
sql.Add('where a.depid=b.depid and a.dutyid=c.dutyid and d.empid=a.empid and a.state=1 and a.empname=:empname');
parameters.ParamValues['empname']:=trim(edit1.Text);
end;
end;
try
execsql; open;
except
MsgErr(handle,'查找数据出错,请重试!');
end;
end;
end;
procedure TForm_EmpPay_Out.BitBtn1Click(Sender: TObject);
begin
with adoq_emp do
begin
close; sql.Clear;
sql.Add('select a.empid,a.empname,a.sex,b.depname,c.dutyname from employee a,department b, duty c, emp_pay d ');
sql.Add('where a.state=1 and a.depid=b.depid and a.dutyid=c.dutyid and d.empid=a.empid');
open;
end;
end;
procedure TForm_EmpPay_Out.RadioGroup1Click(Sender: TObject);
begin
case RadioGroup1.ItemIndex of
0:
begin
combobox_dep.Visible:=true;
combobox_duty.Visible:=false;
edit1.Visible:=false;
end;
1:
begin
combobox_duty.Visible:=true;
combobox_dep.Visible:=false;
edit1.visible:=false;
end;
2,3:
begin
combobox_dep.Visible:=false;
combobox_duty.Visible:=false;
edit1.Visible:=true;
end;
end;
end;
procedure TForm_EmpPay_Out.ListEditor1StringsChange(Sender: TObject);
begin
emp_num.Caption:='所选择的待发工资的人员数是:'+inttostr(ListEditor1.Strings.Count)+' 个';
end;
//人员月薪工资发放查询开始
procedure TForm_EmpPay_Out.PageControl1Change(Sender: TObject);
var tmpdatetime:Tdatetime;
begin
if PageControl1.ActivePageIndex=0 then
begin
ADOQ_Emp_payout.Close;
ADOQ_emp.Close;
PrtBtn.Enabled:=false;
exit;
end;
if PageControl1.ActivePageIndex=1 then
begin
GetHostDateTime(datamod.ADOCon,tmpdatetime);
year_s.MaxValue:=yearof(tmpdatetime);
eyear.MaxValue:=yearof(tmpdatetime);
eyear.Text:=inttostr(yearof(tmpdatetime));
emonth.Text:=inttostr(monthof(tmpdatetime));
if ComboBox_ID.Items.Count=0 then
//添加月薪人员编码
with ADOQ_emp do
begin
close;sql.clear;
sql.add('select a.empid from emp_pay a,employee b');
sql.Add('where a.empid=b.empid');
try
execsql; open;
except
MsgErr(handle,'添加月薪人员信息失败!'); exit;
end;
if recordcount =0 then
begin
MsgErr(handle,'无月薪人员信息!');
exit;
end;
first;
ComboBox_ID.Items.Clear;
while not eof do
begin
ComboBox_ID.Items.Add(fieldvalues['empid']);
next;
end;
end;
//添加所有月薪人员信息,包括非在职人员
with ADOQ_emp do
begin
close; sql.clear;
sql.add('select a.empid,a.pay, b.empname,b.sex from emp_pay a,employee b');
sql.Add('where a.empid=b.empid');
try
execsql; open;
except
MsgErr(handle,'得到人员信息失败!');
exit;
end;
end;
end;
end;
procedure TForm_EmpPay_Out.ComboBox_IDKeyPress(Sender: TObject;
var Key: Char);
var pay:real;
begin
if trim(ComboBox_ID.Text)='' then exit;
if not ( key in ['0'..'9',chr(8),chr(13)]) then abort;
if key <> chr(13) then exit;
edtname.Clear;
if ADOQ_emp.FieldValues['empid']<>trim(ComboBox_ID.Text) then
begin
if not ADOQ_emp.Locate('empid',trim(ComboBox_ID.Text),[]) then
begin
MsgErr(handle,'人员编码 ['+trim(ComboBox_ID.Text)+'] 不存在,或非月薪制人员!');
ComboBox_ID.SetFocus; exit;
end;
edtname.Text:=ADOQ_emp.FieldValues['empname'];
edtsex.Text:=ADOQ_emp.FieldValues['sex'];
pay:=ADOQ_emp.FieldValues['pay'];
edtpay.Text:='¥'+format('%.2f',[pay])
end
else
begin
edtname.Text:=ADOQ_emp.FieldValues['empname'];
edtsex.Text:=ADOQ_emp.FieldValues['sex'];
pay:=ADOQ_emp.FieldValues['pay'];
edtpay.Text:='¥'+format('%.2f',[pay])
end;
//查询当前人员的历史发放工资全部记录
with adoq_emp_payout do
begin
sql.Strings[2]:='and (a.empid=:V_empid)';
parameters.ParamValues['v_empid']:=trim(combobox_id.Text);
open;
if recordcount=0 then MsgOK(handle,'当前时间段内没找到数据!');
prtbtn.Enabled:=recordcount>0;
end;
end;
procedure TForm_EmpPay_Out.ComboBox_IDChange(Sender: TObject);
begin
ComboBox_ID.Text:=trim(ComboBox_ID.Text);
edtname.Clear;
end;
procedure TForm_EmpPay_Out.BitBtn_locateClick(Sender: TObject);
var
sdate, edate, sm_str, em_str:string;
begin
if (trim(ComboBox_ID.Text)<>'') and (trim(edtname.Text)='') then
begin
MsgErr(handle,'待查询人员信息为空,请在员工编号文本框内输入员工编号,再按回车键!');
ComboBox_ID.SetFocus;
exit;
end;
// 检测时间的合法性
sm_str:=trim(month_s.Text);
em_str:=trim(emonth.Text);
sdate:=year_s.Text +'-'+ sm_str;
edate:=eyear.Text +'-'+ em_str;
if not checkdate(sdate+'-10') then
begin
MsgErr(handle,'请输入正确的开始日期!');
year_s.SetFocus;
exit;
end;
if not checkdate(edate+'-10') then
begin
MsgErr(handle,'请输入正确的结束日期!');
eyear.SetFocus;
exit;
end;
if strtodate(edate+'-1') < strtodate(sdate+'-1') then
begin
msgerr(handle,'结束时间不能小于起始时间!');
eyear.SetFocus;
exit;
end;
with adoq_emp_payout do
begin
if trim(ComboBox_ID.Text)<>'' then
sql.Strings[2]:='and (a.empid=:V_empid) and (yearmonth between :v_sd and :v_ed)'
else
sql.Strings[2]:='and (yearmonth between :v_sd and :v_ed)';
if trim(ComboBox_ID.Text)<>'' then
parameters.ParamValues['v_empid']:=trim(combobox_id.Text);
parameters.ParamValues['v_sd']:=formatdatetime('yyyy-mm',strtodate(sdate+'-01'));
parameters.ParamValues['v_ed']:=formatdatetime('yyyy-mm',strtodate(edate+'-01'));
open;
if recordcount=0 then MsgOK(handle,'当前时间段内没找到数据!');
prtbtn.Enabled:=recordcount>0;
//传递打印参数
if recordcount>0 then
begin
s_date:=formatdatetime('yyyy-mm',strtodate(sdate+'-01'))+'月';
e_date:=formatdatetime('yyyy-mm',strtodate(edate+'-01'))+'月';
end;
end;
end;
//人员月薪工资发放查询结束
procedure TForm_EmpPay_Out.PrtBtnClick(Sender: TObject);
begin
InitPage(RvProject1,RvSystem1,apppath+'\'+ReportName,apppath+'\'+ReportNdrName,0);
SelectPage(RvProject1,'Report1',5);
//传递参数
AddParameter(RvProject1,'sdate',s_date);
AddParameter(RvProject1,'edate',e_date);
AddParameter(RvProject1,'UserName',curAdmin.user_name);
AddParameter(RvProject1,'companyname',sysconfig.COMPANYANME);
//显示页
PageShow(RvProject1);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -