📄 personmainshoulu.pas
字号:
unit PersonMainShouLU;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, Buttons, Grids, DBGrids, ExtCtrls,
ComCtrls, RpDefine, RpCon, RpConDS, Menus, Mask, DBCtrls, RpRave, RpBase,
RpSystem;
type
TFrmPersonMainShouLU = class(TForm)
DataSource: TDataSource;
DBGrid: TDBGrid;
ADOQtmp: TADOQuery;
Rv_GJSLMX: TRvDataSetConnection;
RvSystem1: TRvSystem;
RvProject1: TRvProject;
Panel1: TPanel;
Label4: TLabel;
Label1: TLabel;
Label2: TLabel;
DBComboBox2: TComboBox;
edtname: TEdit;
edtsex: TEdit;
GroupBox1: TGroupBox;
Label5: TLabel;
Label6: TLabel;
sDate: TDateTimePicker;
eDate: TDateTimePicker;
Bevel1: TBevel;
ADOQuery1: TADOQuery;
StringField1: TStringField;
StringField2: TStringField;
BCDField1: TBCDField;
IntegerField1: TIntegerField;
BCDField2: TBCDField;
adoq_temp: TADOQuery;
SearchBtn: TBitBtn;
PrtBtn: TBitBtn;
ExtBtn: TBitBtn;
Label3: TLabel;
ComboBox1: TComboBox;
procedure FormShow(Sender: TObject);
procedure SearchBtnClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure DBComboBox2Change(Sender: TObject);
procedure PrtBtn12Click(Sender: TObject);
procedure DBEdit3KeyPress(Sender: TObject; var Key: Char);
procedure DBComboBox2KeyPress(Sender: TObject; var Key: Char);
procedure ComboBox11Change(Sender: TObject);
private
{ Private declarations }
emp_id, emp_name, s_date, e_date: string;
public
{ Public declarations }
end;
var
FrmPersonMainShouLU: TFrmPersonMainShouLU;
implementation
uses data,sharevar,sharefun, ColorSetup;
{$R *.dfm}
procedure TFrmPersonMainShouLU.FormShow(Sender: TObject);
var tmp_date:Tdatetime;
begin
GetHostDateTime(datamod.ADOCon,tmp_date);
edate.DateTime :=tmp_date;
//添加人员编码
with ADOQtmp do
begin
close;sql.clear;
sql.add('select empid from employee where state=1 and grade=''计件制''');
try
execsql; open;
except
MsgErr(handle,'添加人员编码失败!'); exit;
end;
if recordcount =0 then
begin
MsgErr(handle,'无人员信息!');
exit;
end;
DBComboBox2.Items.Clear;
first;
while not eof do
begin
DBComboBox2.Items.Add(fieldvalues['empid']);
next;
end;
end;
//添加订单号
with ADOQtmp do
begin
close;sql.clear;
sql.add('select ord_id from order_msg order by order_date');
try
execsql; open;
except
MsgErr(handle,'添加订单号失败!'); exit;
end;
if recordcount =0 then
begin
MsgErr(handle,'当前无订单信息!');
exit;
end;
ComboBox1.Items.Add(' ');
first;
while not eof do
begin
ComboBox1.Items.Add(fieldvalues['ord_id']);
next;
end;
end;
//添加所有人员信息,包括非在职人员
with ADOQtmp do
begin
close;sql.clear;
sql.add('select empid,empname,sex from employee');
try
execsql; open;
except
MsgErr(handle,'得到人员信息失败!'); exit;
end;
end;
DBComboBox2.SetFocus;
end;
procedure TFrmPersonMainShouLU.SearchBtnClick(Sender: TObject);
var
DataTJ_flag:boolean;
inprice_num:integer;
tmpstr:string;
begin
if trim(edtname.Text)='' then
begin
MsgErr(handle,'待查询人员信息为空,请在员工编号文本框内输入员工编号,再按回车键!');
DBComboBox2.SetFocus;
exit;
end;
if sDate.DateTime>eDate.DateTime then
begin
MsgErr(handle,'开始时间大于结束时间,请重新输入!');
exit;
end;
//检查是否给当前所有已验收未入总账的工序定工价
with adoqtmp do
begin
close; sql.Clear;
sql.add('select a.ord_id, b.seq_name, b.seq_price from v_outbom_log2 a,sequence_price b');
sql.add('where a.flag=1 and a.TJflag=0 and (a.temp_key=b.temp_key) and a.empid=:V_empid');
if trim(ComboBox1.Text)<>'' then sql.Add('and a.ord_id=:v_ord_id');
sql.Add('group by b.temp_key, a.ord_id, b.seq_name, b.seq_price');
if trim(ComboBox1.Text)<>'' then parameters.ParamValues['v_ord_id']:=trim(ComboBox1.Text);
parameters.ParamValues['V_empid']:=strtoint(trim(DBComboBox2.Text));
try
open; first;
except
Msgerr(handle,'统计人员收支总账报表失败--工价查找!');
exit;
end;
DataTJ_flag:=true;
inprice_num:=0;
while not eof do
begin
if (fieldvalues['seq_price']=0) or (fieldvalues['seq_price']=null) then
begin
tmpstr:='订单批号:['+fieldvalues['ord_id']+'下的工序 ['+fieldvalues['seq_name']+'] 还没有给工价';
msgerr(handle, tmpstr);
DataTJ_flag:=false; Inc(inprice_num);
end;
next;
end;
if not DataTJ_flag then
begin
tmpstr:='统计人员收支总账报表失败--共有 ['+inttostr(inprice_num)+'] 个工序工价未指定!';
tmpstr:=tmpstr+#13+#13+' 请先到工序工价表指定工价再作统计!';
msgerr(handle,tmpstr);
abort; exit;
end;
end;//工序工价统计结束.End
//查讯对应时间段的人员的工序收入信息
with adoquery1 do
begin
close;sql.clear;
{ sql.add('select a.log_id,a.ord_id,b.seq_name, b.seq_price,a.num,b.seq_price*a.num as total from outbom_log a,sequence_price b');
sql.add(' where (a.temp_key=b.temp_key) and (a.empid=:v_empid ) and (a.flag=1)');
sql.Add(' and (retdate between :v_sd and :v_ed)');
if trim(ComboBox1.Text)<>'' then
sql.Add(' and (a.ord_id=:v_ord_id)');
sql.Add('group by a.temp_key, a.ord_id, a.log_id, b.seq_name, b.seq_price, a.num'); ////////////--------------------------
sql.Add(' order by a.ord_id,a.temp_key'); }
sql.Add('select a.ord_id,b.seq_name, b.seq_price,sum(a.num) as num,(b.seq_price*sum(a.num)) as total');
sql.Add('from outbom_log a,sequence_price b');
sql.Add('where (a.temp_key=b.temp_key) and (a.empid=:v_empid ) and (a.flag=1)');
sql.Add(' and (retdate between :v_sd and :v_ed)');
if trim(ComboBox1.Text)<>'' then
sql.Add(' and (a.ord_id=:v_ord_id)');
sql.Add('group by a.temp_key, a.ord_id, b.seq_name, b.seq_price');
sql.Add('order by a.ord_id, a.temp_key');
if trim(ComboBox1.Text)<>'' then
parameters.ParamValues['v_ord_id']:=trim(ComboBox1.Text);
parameters.ParamValues['v_empid']:=dbcombobox2.Text;
parameters.ParamValues['v_sd']:=strtodatetime(formatdatetime('yyyy-mm-dd',sdate.Date)+' 00:00:00');
parameters.ParamValues['v_ed']:=strtodatetime(formatdatetime('yyyy-mm-dd',edate.Date)+' 23:59:59');
try
execsql; open;
except
msgerr(handle,'员工工序计件收入查询失败!');
exit;
end;
if recordcount=0 then MsgOK(handle,'当前时间段内没找到数据!');
prtbtn.Enabled:=recordcount>0;
if recordcount>0 then
begin
emp_id:=trim(DBComboBox2.Text);
emp_name:=edtname.text;
s_date:=datetostr(sDate.DateTime)+' 00:00:00';
e_date:=datetimetostr(edate.DateTime);
end;
end;
end;
procedure TFrmPersonMainShouLU.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=Cafree;
end;
procedure TFrmPersonMainShouLU.DBComboBox2Change(Sender: TObject);
begin
dbcombobox2.Text:=trim(dbcombobox2.Text);
edtname.Clear;
end;
procedure TFrmPersonMainShouLU.PrtBtn12Click(Sender: TObject);
begin
InitPage(RvProject1,RvSystem1,apppath+'\'+ReportName,apppath+'\'+ReportNdrName,0);
SelectPage(RvProject1,'Report1',2);
//传递参数
AddParameter(RvProject1,'UserName',curAdmin.user_name);
AddParameter(RvProject1,'empid',emp_id);
AddParameter(RvProject1,'empname',emp_name);
AddParameter(RvProject1,'companyname',sysconfig.COMPANYANME);
AddParameter(RvProject1,'sdate',s_date);
AddParameter(RvProject1,'edate',e_date);
//显示页
PageShow(RvProject1);
end;
procedure TFrmPersonMainShouLU.DBEdit3KeyPress(Sender: TObject; var Key: Char);
begin
if not ( key in ['0'..'9',chr(8),chr(13)]) then abort;
end;
procedure TFrmPersonMainShouLU.DBComboBox2KeyPress(Sender: TObject;
var Key: Char);
begin
if trim(DBComboBox2.Text)='' then exit;
if not ( key in ['0'..'9',chr(8),chr(13)]) then abort;
if key <> chr(13) then exit;
edtname.Clear;
with adoq_temp do
begin
SQL.Clear;
sql.Add('select empid, empname, sex from employee where empid='+''''+trim(DBComboBox2.Text)+'''');
execsql; open;
end;
if adoq_temp.RecordCount=0 then
begin
MsgErr(handle,'人员编码 ['+trim(DBComboBox2.Text)+'] 不存在!');
ComboBox1.SetFocus; exit;
end
else
begin
edtname.Text:=adoq_temp.FieldValues['empname'];
edtsex.Text:=adoq_temp.FieldValues['sex'];
end;
end;
procedure TFrmPersonMainShouLU.ComboBox11Change(Sender: TObject);
begin
ComboBox1.Text:=trim(ComboBox1.text);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -