📄 ylzjwh.~pas
字号:
procedure TFrmylzjwh.tjeKeyPress(Sender: TObject; var Key: Char);
begin
if not (key in['0'..'9',#8,#13,'.','-']) then
begin
key:=#0;
help.caption:=' 请输入数字!';
if key=#13 then tllr.SetFocus;
end;
end;
procedure TFrmylzjwh.BqueryClick(Sender: TObject);
var
commandtring1,relation,cx:string;
begin
relation:=' like ''';
cx:='%';
commandstring:='select * from dbo.ylzj';
commandtring1:='select * from dbo.ylzj';
try
if (trim(qddh.Text)<>'') and (cddh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ylzj.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ylzj.ddh'+relation+cx+trim(qddh.Text)+cx+''')';
end;
end
else
begin
qddh.Text:='';
end;
if (trim(qxh.Text)<>'') and (cxh.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ylzj.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ylzj.xh'+relation+cx+trim(qxh.Text)+cx+''')';
end;
end
else
begin
qxh.Text:='';
end;
if cqq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' where (dbo.ylzj.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
cx:='';
commandstring:=commandstring+' and (dbo.ylzj.rq'+ relation+FormatDateTime('yyyy-mm-dd',qq.Date)+cx+''')';
end;
end;
if czq.Checked then
begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' where (dbo.ylzj.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
cx:='';
commandstring:=commandstring+' and (dbo.ylzj.rq'+ relation+FormatDateTime('yyyy-mm-dd',zq.Date+1)+cx+''')';
end;
end;
if (trim(qje.Text)<>'') and (cje.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ylzj.je'+relation+cx+trim(qje.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ylzj.je'+relation+cx+trim(qje.Text)+cx+''')';
end;
end
else
begin
qje.Text:='';
end;
if (trim(qllr.Text)<>'') and (cllr.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ylzj.llr'+relation+cx+trim(qllr.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ylzj.llr'+relation+cx+trim(qllr.Text)+cx+''')';
end;
end
else
begin
qllr.Text:='';
end;
if (trim(qflr.Text)<>'') and (cflr.Checked) then
begin
relation:=' like ''';
cx:='%';
if commandstring=commandtring1 then
begin
commandstring:=commandstring+' where (dbo.ylzj.flr'+relation+cx+trim(qflr.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ylzj.flr'+relation+cx+trim(qflr.Text)+cx+''')';
end;
end
else
begin
qflr.Text:='';
end;
commandstring:=commandstring+' order by ddh,xh desc ';
commandstringq:=commandstring;
DataModule1.ClientDataSet27.DisableControls;
DataModule1.ClientDataSet27.Close;
DataModule1.ClientDataSet27.CommandText:=commandstring;
DataModule1.ClientDataSet27.Open;
DataModule1.ClientDataSet27.EnableControls;
help.Caption:=' 查询完毕,要修改余料追加记录请用鼠标双击该订单出货记录所在的行!';
pz.Enabled:=true;
dbgrid5.Enabled:=true;
except
DataModule1.clientdataset27.EnableControls;
showmessage('数据库没有打开!');
end;
end;
procedure TFrmylzjwh.DBGrid5DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if DataModule1.ClientDataSet27.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 TFrmylzjwh.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.ClientDataSet27.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet27.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;
procedure TFrmylzjwh.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.ClientDataSet27.Active then exit;
if DataModule1.ClientDataSet27.RecordCount<1 then exit;
if not check then exit;
if DataModule1.ClientDataSet27.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.ylzj';
commandstring:=commandstring+' where (dbo.ylzj.ddh'+relation+cx+DataModule1.ClientDataSet27.fieldbyname('ddh').asstring+cx+''')';
commandstring:=commandstring+' and (dbo.ylzj.xh'+relation+cx+DataModule1.ClientDataSet27.fieldbyname('xh').asstring+cx+''')';
DataModule1.ClientDataSet27.CommandText:=commandstring;
DataModule1.ClientDataSet27.Execute;
DataModule1.ClientDataSet27.Close;
DataModule1.ClientDataSet27.CommandText:=commandstringq;
DataModule1.ClientDataSet27.Open;
DataModule1.ClientDataSet27.EnableControls;
dbgrid5.Enabled:=true;
help.Caption:=' 该记录删除成功!';
except
dbgrid5.Enabled:=true;
DataModule1.clientdataset27.EnableControls;
showmessage('数据库没有打开')
end;
end;
end;
procedure TFrmylzjwh.bshClick(Sender: TObject);
var
relation,cx,dx,sqlstr:string;
begin
if not DataModule1.ClientDataSet27.Active then exit;
if DataModule1.ClientDataSet27.RecordCount<1 then exit;
relation:=' = ''';
cx:='';
dx:= ' ''';
try
DataModule1.ClientDataSet27.Edit;
if DataModule1.ClientDataSet27.FieldByName('shbj').AsInteger=0 then
begin
sqlstr:='update dbo.ylzj set shy'+relation+form1.StatusBar1.Panels[4].Text+dx+' ,shbj'+relation+'1'+dx+' ,shsj'+relation+datetimetostr(Date)+dx;
sqlstr:=sqlstr+' where (ddh' +relation+cx+DataModule1.ClientDataSet27.FieldByName('ddh').AsString+cx+''')';
sqlstr:=sqlstr+' and (xh' +relation+cx+DataModule1.ClientDataSet27.FieldByName('xh').AsString+cx+''')';
DataModule1.ClientDataSet27.CommandText:=sqlstr;
DataModule1.ClientDataSet27.Execute;
DataModule1.ClientDataSet27.ApplyUpdates(-1);
DataModule1.ClientDataSet27.DisableControls;
DataModule1.ClientDataSet27.Close;
DataModule1.ClientDataSet27.CommandText:=commandstringq;
DataModule1.ClientDataSet27.Open;
DataModule1.ClientDataSet27.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.clientdataset27.EnableControls;
help.Caption:= '数据审核失败!';
end;
end;
procedure TFrmylzjwh.breworkClick(Sender: TObject);
begin
if not DataModule1.ClientDataSet27.Active then exit;
if DataModule1.ClientDataSet27.RecordCount<1 then exit;
if DataModule1.ClientDataSet27.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 TFrmylzjwh.DBGrid5DblClick(Sender: TObject);
begin
if DataModule1.ClientDataSet27.Active then
begin
if DataModule1.ClientDataSet27.RecordCount<1 then exit;
txh.Text:=DataModule1.clientdataset27.FieldByName('xh').AsString;
rq.DateTime:=DataModule1.clientdataset27.FieldByName('rq').AsDateTime;
tje.Text:=DataModule1.clientdataset27.FieldByName('je').AsString;
tllr.Text:=DataModule1.clientdataset27.FieldByName('llr').AsString;
tflr.Text:=DataModule1.clientdataset27.FieldByName('flr').AsString;
tzgr.Text:=DataModule1.clientdataset27.FieldByName('zgr').AsString;
tbz.Text:=DataModule1.clientdataset27.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;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -