📄 cllrwh.pas
字号:
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.cz'+relation+cx+trim(qcz.Text)+cx+''')';
end;
end
else
begin
qcz.Text:='';
end;
if (trim(qbz.Text)<>'') and (cbz.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.bz'+relation+cx+trim(qbz.Text)+cx+''')';
end;
end
else
begin
qbz.Text:='';
end;
if (trim(qczy.Text)<>'') and (cczy.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.cllrb.czy'+relation+cx+trim(qczy.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.cllrb.czy'+relation+cx+trim(qczy.Text)+cx+''')';
end;
end
else
begin
qczy.Text:='';
end;
commandstring:=commandstring+' order by ddh,clh desc ';
commandstringq:=commandstring;
DataModule1.ClientDataSet25.DisableControls;
DataModule1.ClientDataSet25.Close;
DataModule1.ClientDataSet25.CommandText:=commandstring;
DataModule1.ClientDataSet25.Open;
DataModule1.ClientDataSet25.EnableControls;
help.Caption:=' 查询完毕,要修改员工产量记录请用鼠标双击该员工产量记录所在的行!';
pz.Enabled:=true;
dbgrid5.Enabled:=true;
except
DataModule1.clientdataset25.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmcllrwh.tbhKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tys.SetFocus;
end;
procedure TFrmcllrwh.tcmKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tgxmc.SetFocus;
end;
procedure TFrmcllrwh.txsKeyPress(Sender: TObject; var Key: Char);
begin
if not (key in['0'..'9',#8,#13,'.','-']) then
begin
key:=#0;
help.caption:=' 请输入数字!';
end;
if key=#13 then tdj.SetFocus;
end;
procedure TFrmcllrwh.DBGrid5TitleClick(Column: TColumn);
var i : integer;
begin
for i:= 1 to DBGrid5.Columns.Count do
begin
//恢复所有标题字体为默认
DBGrid5.Columns[i-1].Title.Font.Color := clBlue;
DBGrid5.Columns[i-1].Title.Font.Style := [];
end;
if DataModule1.ClientDataSet25.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet25.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;
procedure TFrmcllrwh.DBGrid5DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if DataModule1.ClientDataSet25.FieldByName('shbj').AsInteger=1 then
begin
dbgrid5.Canvas.Font.Color:=clred;
dbgrid5.Canvas.Brush.Color:=clyellow;
end
else
begin
dbgrid5.Canvas.Font.Color:=clblue;
dbgrid5.Canvas.Brush.Color:=clwhite;
end;
dbgrid5.DefaultDrawColumnCell(rect,datacol,column,state);
if ((State = [gdSelected]) or (State = [gdSelected, gdFocused])) then
begin
DBGrid5.Canvas.Brush.Color:=clred;
DBGrid5.Canvas.Font.Color:=clWhite;
DBGrid5.DefaultDrawColumnCell(Rect, datacol,column, State);
end;
end;
procedure TFrmcllrwh.breworkClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet25.Active then exit;
if DataModule1.ClientDataSet25.RecordCount<1 then exit;
if DataModule1.ClientDataSet25.FieldByName('shbj').AsInteger=1 then
begin
help.Caption:=' 记录已经审核,您无权修改!';
brework.Enabled:=false;
exit;
end;
help.Caption:='';
brework.Enabled:=false;
bsave.Enabled:=true;
bcancel.Enabled:=true;
bdelete.Enabled:=false;
bsh.Enabled:=false;
bprint.Enabled:=false;
pz.Enabled:=true;
rq.SetFocus;
help.Caption:=' 请您输入数据!';
end;
procedure TFrmcllrwh.BdeleteClick(Sender: TObject);
var
relation,cx,dx,datestr:string;
begin
relation:='=''';
cx:='';
dx:='''';
datestr:=frmxtfz.checkfzrq(formatdatetime('yyyy-mm-dd',rq.date));
if datestr<>'' then
begin
help.Caption:=' 封账日期为'+datestr+'您不能删除封账日期前的数据';
exit;
end;
if not DataModule1.ClientDataSet25.Active then exit;
if DataModule1.ClientDataSet25.RecordCount<1 then exit;
if not check then exit;
if DataModule1.ClientDataSet25.FieldByName('shbj').AsInteger=1 then
begin
help.Caption:=' 记录已经审核,您无权修改!' ;
exit;
end;
brework.Enabled:=false;
bsave.Enabled:=false;
bdelete.Enabled:=false;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=false;
if (MessageDlg('您确认要删除该条记录吗?',mtConfirmation,[mbYes, mbCancel], 0) = mrYes) then
begin
try
commandstring:='delete from dbo.cllrb';
commandstring:=commandstring+' where (dbo.cllrb.clh'+relation+cx+DataModule1.ClientDataSet25.fieldbyname('clh').asstring+cx+''')';
DataModule1.ClientDataSet25.CommandText:=commandstring;
DataModule1.ClientDataSet25.Execute;
DataModule1.ClientDataSet25.Close;
DataModule1.ClientDataSet25.CommandText:=commandstringq;
DataModule1.ClientDataSet25.Open;
DataModule1.ClientDataSet25.EnableControls;
dbgrid5.Enabled:=true;
help.Caption:=' 该记录删除成功!';
except
dbgrid5.Enabled:=true;
DataModule1.clientdataset25.EnableControls;
showmessage('数据库没有打开')
end;
end;
end;
procedure TFrmcllrwh.bshClick(Sender: TObject);
var
relation,cx,dx,sqlstr:string;
begin
if not DataModule1.ClientDataSet25.Active then exit;
if DataModule1.ClientDataSet25.RecordCount<1 then exit;
relation:=' = ''';
cx:='';
dx:= ' ''';
try
DataModule1.ClientDataSet25.Edit;
if DataModule1.ClientDataSet25.FieldByName('shbj').AsInteger=0 then
begin
sqlstr:='update dbo.cllrb set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'1'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (clh' +relation+cx+DataModule1.ClientDataSet25.FieldByName('clh').AsString+cx+''')';
DataModule1.ClientDataSet25.CommandText:=sqlstr;
DataModule1.ClientDataSet25.Execute;
DataModule1.ClientDataSet25.ApplyUpdates(-1);
DataModule1.ClientDataSet25.DisableControls;
DataModule1.ClientDataSet25.Close;
DataModule1.ClientDataSet25.CommandText:=commandstringq;
DataModule1.ClientDataSet25.Open;
DataModule1.ClientDataSet25.EnableControls;
brework.Enabled:=false;
bsave.Enabled:=false;
bdelete.Enabled:=false;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=false;
dbgrid5.Enabled:=true;
help.Caption:= '数据审核成功!';
end;
except
dbgrid5.Enabled:=true;
DataModule1.clientdataset25.EnableControls;
help.Caption:= '数据审核失败!';
end;
end;
procedure TFrmcllrwh.DBGrid2DblClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet23.Active then exit;
if DataModule1.ClientDataSet23.RecordCount>0 then
begin
tgxmc.Text:=DataModule1.ClientDataSet23.FieldByName('gxmc').AsString;
txs.Text:=DataModule1.ClientDataSet23.FieldByName('xs').AsString;
tdj.text:=DataModule1.ClientDataSet23.FieldByName('dj').AsString;
tsl.SetFocus;
end;
end;
procedure TFrmcllrwh.DBGrid3DblClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet3.Active then exit;
if DataModule1.ClientDataSet3.RecordCount>0 then
begin
tgh.Text:=DataModule1.ClientDataSet3.FieldByName('gh').AsString;
tfb.Text:=DataModule1.ClientDataSet3.FieldByName('fb').AsString;
tfz.Text:=DataModule1.ClientDataSet3.FieldByName('fz').AsString;
tyg.text:=DataModule1.ClientDataSet3.FieldByName('xm').AsString;
tbh.SetFocus;
end;
end;
procedure TFrmcllrwh.DBGrid6DblClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet24.Active then exit;
if DataModule1.ClientDataSet24.RecordCount>0 then
begin
tbh.Text:=DataModule1.ClientDataSet24.FieldByName('xh').AsString;
tys.Text:=DataModule1.ClientDataSet24.FieldByName('ys').AsString;
tcm.Text:=DataModule1.ClientDataSet24.FieldByName('cm').AsString;
tsl.text:=DataModule1.ClientDataSet24.FieldByName('sl').AsString;
tgxmc.SetFocus;
end;
end;
procedure TFrmcllrwh.tygChange(Sender: TObject);
var
relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.ygb';
if trim(tyg.Text)<>'' then
begin
commandstring:=commandstring+' where (xm'+relation+cx+trim(tyg.Text)+cx+''')'+' order by xm';;
DataModule1.ClientDataSet3.Close;
DataModule1.ClientDataSet3.CommandText:=commandstring;
DataModule1.ClientDataSet3.Open;
end;
if trim(tyg.Text)='' then
begin
help.Caption:=' 请您输入或选择一位员工!';
exit;
end;
end;
procedure TFrmcllrwh.tgxmcChange(Sender: TObject);
var
relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.gxb';
if trim(tgxmc.Text)<>'' then
begin
commandstring:=commandstring+' where (gxmc'+relation+cx+trim(tgxmc.Text)+cx+''')';
if DataModule1.ClientDataSet25.Active and (DataModule1.ClientDataSet25.RecordCount>0) then commandstring:=commandstring+' and (ddh'+relation+cx+DataModule1.ClientDataSet25.fieldbyname('ddh').AsString+cx+''')';
commandstring:=commandstring+' order by gxmc';
DataModule1.ClientDataSet23.Close;
DataModule1.ClientDataSet23.CommandText:=commandstring;
DataModule1.ClientDataSet23.Open;
end;
if trim(tgxmc.Text)='' then
begin
help.Caption:=' 请您输入或选择一个工序!';
exit;
end;
end;
procedure TFrmcllrwh.tbhChange(Sender: TObject);
var
relation,cx,commandstring1:string;
begin
txsChange(nil);
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.bhb';
commandstring1:=commandstring;
if trim(tbh.Text)<>'' then
begin
commandstring:=commandstring+' where (xh'+relation+cx+trim(tbh.Text)+cx+''')';
if DataModule1.ClientDataSet17.Active and (DataModule1.ClientDataSet17.RecordCount>0) then commandstring:=commandstring+' and (ddh'+relation+cx+DataModule1.ClientDataSet17.fieldbyname('ddh').AsString+cx+''')';
commandstring:=commandstring+' order by xh';
DataModule1.ClientDataSet24.Close;
DataModule1.ClientDataSet24.CommandText:=commandstring;
DataModule1.ClientDataSet24.Open;
exit;
end;
if trim(tsl.Text)<>'' then
begin
commandstring:=commandstring+' where (sl'+relation+cx+trim(tsl.Text)+cx+''')';
if DataModule1.ClientDataSet17.Active and (DataModule1.ClientDataSet17.RecordCount>0) then commandstring:=commandstring+' and (ddh'+relation+cx+DataModule1.ClientDataSet17.fieldbyname('ddh').AsString+cx+''')';
commandstring:=commandstring+' order by xh';
DataModule1.ClientDataSet24.Close;
DataModule1.ClientDataSet24.CommandText:=commandstring;
DataModule1.ClientDataSet24.Open;
exit;
end;
if DataModule1.ClientDataSet17.Active and (DataModule1.ClientDataSet17.RecordCount>0) then commandstring:=commandstring+' where (ddh'+relation+cx+DataModule1.ClientDataSet17.fieldbyname('ddh').AsString+cx+''')';
commandstring:=commandstring+' order by xh';
DataModule1.ClientDataSet24.Close;
DataModule1.ClientDataSet24.CommandText:=commandstring;
DataModule1.ClientDataSet24.Open;
if trim(tbh.Text)='' then
begin
help.Caption:=' 请您输入或选择一个包号!';
exit;
end;
end;
procedure TFrmcllrwh.DBGrid5DblClick(Sender: TObject);
begin
if DataModule1.ClientDataSet25.Active then
begin
if DataModule1.ClientDataSet25.RecordCount<1 then exit;
rq.DateTime:=DataModule1.clientdataset25.FieldByName('rq').AsDateTime;
tgh.Text:=DataModule1.clientdataset25.FieldByName('gh').AsString;
tfb.Text:=DataModule1.clientdataset25.FieldByName('fb').AsString;
tfz.Text:=DataModule1.clientdataset25.FieldByName('fz').AsString;
tyg.Text:=DataModule1.clientdataset25.FieldByName('yg').AsString;
tbh.Text:=DataModule1.clientdataset25.FieldByName('bh').AsString;
tys.Text:=DataModule1.clientdataset25.FieldByName('ys').AsString;
tcm.Text:=DataModule1.clientdataset25.FieldByName('cm').AsString;
tgxmc.Text:=DataModule1.clientdataset25.FieldByName('gxmc').AsString;
txs.Text:=DataModule1.clientdataset25.FieldByName('xs').AsString;
tdj.Text:=DataModule1.clientdataset25.FieldByName('dj').AsString;
tsl.Text:=DataModule1.clientdataset25.FieldByName('sl').AsString;
tcz.Text:=DataModule1.clientdataset25.FieldByName('cz').AsString;
tbz.Text:=DataModule1.clientdataset25.FieldByName('bz').AsString;
brework.Enabled:=true;
bsave.Enabled:=false;
bdelete.Enabled:=true;
bcancel.Enabled:=false;
bprint.Enabled:=false;
bsh.Enabled:=true;
end;
help.Caption:=' 要修改记录请点击<修改>按钮,要删除请点击<删除>按钮!';
dbgrid5.Enabled:=false;
end;
procedure TFrmcllrwh.SpeedButton3Click(Sender: TObject);
begin
frmyg.showmodal;
tyg.Text:=form1.yg;
form1.yg:='';
end;
procedure TFrmcllrwh.tgxmcKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then txs.SetFocus;
end;
procedure TFrmcllrwh.txsChange(Sender: TObject);
begin
if trim(txs.Text)='' then txs.Text:='0';
if trim(tdj.Text)='' then tdj.Text:='0';
if trim(tsl.Text)='' then tsl.Text:='0';
if (trim(tsl.Text)<>'') and (trim(tdj.Text)<>'') and (trim(txs.Text)<>'') then
begin
tcz.Text:=formatfloat('0.00',strtofloat(tsl.Text)*strtofloat(tdj.Text)*strtofloat(txs.Text));
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -