⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gx.~pas

📁 应对服装行业的生产成本控制系统
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
   begin
 relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddb.jglx'+relation+cx+trim(qjglx.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.jglx'+relation+cx+trim(qjglx.Text)+cx+''')';
end;
end
else
begin
qjglx.Text:='';
end;
if (trim(qkhmc.Text)<>'') and (ckhmc.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  BEGIN
  commandstring:=commandstring+' where (dbo.ddb.khmc'+relation+cx+TRIM(qkhmc.Text)+cx+''')'
 END
  else
  BEGIN
  commandstring:=commandstring+' and (dbo.ddb.khmc'+relation+cx+TRIM(qkhmc.Text)+cx+''')'
  end;
 end
 else
 begin
qkhmc.Text:='';
end;
if (trim(qcpmc.Text)<>'') and (ccpmc.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  BEGIN
  commandstring:=commandstring+' where (dbo.ddb.cpmc'+relation+cx+TRIM(qcpmc.Text)+cx+''')'
 END
  else
  BEGIN
  commandstring:=commandstring+' and (dbo.ddb.cpmc'+relation+cx+TRIM(qcpmc.Text)+cx+''')'
  end;
 end
 else
 begin
qcpmc.Text:='';
end;
if (trim(qcpfl.Text)<>'') and (ccpfl.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  BEGIN
  commandstring:=commandstring+' where (dbo.ddb.cpfl'+relation+cx+TRIM(qcpfl.Text)+cx+''')'
 END
  else
  BEGIN
  commandstring:=commandstring+' and (dbo.ddb.cpfl'+relation+cx+TRIM(qcpfl.Text)+cx+''')'
  end;
 end
 else
 begin
qcpfl.Text:='';
end;
if (trim(qcpdw.Text)<>'') and (ccpdw.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  BEGIN
  commandstring:=commandstring+' where (dbo.ddb.cpdw'+relation+cx+TRIM(qcpdw.Text)+cx+''')'
 END
  else
  BEGIN
  commandstring:=commandstring+' and (dbo.ddb.cpdw'+relation+cx+TRIM(qcpdw.Text)+cx+''')'
  end;
 end
 else
 begin
qcpdw.Text:='';
end;
if csq.Checked then
 begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' where (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sq.Date)+cx+''')';
end;
end;
if csz.Checked then
 begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
    cx:='';
commandstring:=commandstring+' where (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sz.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddb.jdrq'+ relation+FormatDateTime('yyyy-mm-dd',sz.Date+1)+cx+''')';
end;
end;
if cjq.Checked then
 begin
if commandstring=commandtring1 then
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' where (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jq.Date)+cx+''')';
end
else
begin
relation:=' >= ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jq.Date)+cx+''')';
end;
end;
if cjz.Checked then
 begin
if commandstring=commandtring1 then
begin
relation:=' < ''';
    cx:='';
commandstring:=commandstring+' where (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jz.Date+1)+cx+''')';
end
else
begin
relation:=' < ''';
    cx:='';
commandstring:=commandstring+' and (dbo.ddb.jhrq'+ relation+FormatDateTime('yyyy-mm-dd',jz.Date+1)+cx+''')';
end;
end;
if (trim(qsl.Text)<>'') and (csl.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.sl'+relation+cx+trim(qsl.Text)+cx+''')';
end;
end
else
begin
qsl.Text:='';
end;
if (trim(qdj.Text)<>'') and (cdj.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.dj'+relation+cx+trim(qdj.Text)+cx+''')';
end;
end
else
begin
qdj.Text:='';
end;
if (trim(qje.Text)<>'') and (cje.Checked) then
   begin
    relation:=' like ''';
    cx:='%';
  if  commandstring=commandtring1 then
  begin
commandstring:=commandstring+' where (dbo.ddb.je'+relation+cx+trim(qje.Text)+cx+''')';
end
else
begin
commandstring:=commandstring+' and (dbo.ddb.je'+relation+cx+trim(qje.Text)+cx+''')';
end;
end
else
begin
qje.Text:='';
end;
commandstring:=commandstring+' order by ddh desc ';
commandstringq:=commandstring;
DataModule1.ClientDataSet17.DisableControls;
DataModule1.ClientDataSet17.Close;
DataModule1.ClientDataSet17.CommandText:=commandstring;
DataModule1.ClientDataSet17.Open;
DataModule1.ClientDataSet17.EnableControls;
help.Caption:='   查询完毕,请用鼠标双击订单记录所在的行!';
pz.Enabled:=true;
dbgrid1.Enabled:=true;
except
DataModule1.clientdataset17.EnableControls;
showmessage('数据库没有打开!');
end;
end;

procedure TFrmgx.DBGrid1DblClick(Sender: TObject);
var
relation:string;
begin
 relation:=' = ''';
try
if DataModule1.ClientDataSet17.Active then
begin
 if DataModule1.ClientDataSet17.RecordCount<1 then exit;
 bnew.Enabled:=true;
 bsave.Enabled:=false;
 bcancel.Enabled:=false;
 bdelete.Enabled:=false;
 bprint.Enabled:=false;
commandstring:='select * from dbo.gxb where (dbo.gxb.ddh'+relation+DataModule1.ClientDataSet17.FieldByName('ddh').AsString+''' )'+' order by xh desc';
DataModule1.ClientDataSet23.Close;
DataModule1.ClientDataSet23.CommandText:=commandstring;
DataModule1.ClientDataSet23.Open;
 end;
 help.Caption:='  要添加记录请点击<新增>按钮!';
 dbgrid1.Enabled:=false;
 except
 dbgrid1.Enabled:=true;
 showmessage('表格中数据出现了错误!')
 end;
end;

procedure TFrmgx.txhKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tgxmc.SetFocus;
end;

procedure TFrmgx.tgxmcKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then tdj.SetFocus;
end;

procedure TFrmgx.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 tbz.SetFocus;
end;

procedure TFrmgx.tbzKeyPress(Sender: TObject; var Key: Char);
begin
if not bsave.Enabled then exit;
if key=#13 then bsave.SetFocus;
end;

procedure TFrmgx.BdeleteClick(Sender: TObject);
var
relation,cx:string;
begin
 relation:=' = ''';
 cx:='';
  if not DataModule1.ClientDataSet23.Active then exit;
  if DataModule1.ClientDataSet23.RecordCount<1 then exit;
    try
  commandstring:='delete from dbo.gxb';
  commandstring:=commandstring+' where (dbo.gxb.ddh'+relation+cx+DataModule1.ClientDataSet23.fieldbyname('ddh').AsString+cx+''')';
  commandstring:=commandstring+' and (dbo.gxb.xh'+relation+cx+DataModule1.ClientDataSet23.fieldbyname('xh').AsString+cx+''')';
  DataModule1.ClientDataSet23.CommandText:=commandstring;
  DataModule1.ClientDataSet23.Execute;
commandstring:='select * from dbo.gxb where (dbo.gxb.ddh'+relation+DataModule1.ClientDataSet17.FieldByName('ddh').AsString+''' )'+' order by xh desc';
DataModule1.ClientDataSet23.Close;
DataModule1.ClientDataSet23.CommandText:=commandstring;
DataModule1.ClientDataSet23.Open;
  dbgrid5.Enabled:=true;
  bdelete.Enabled:=false;
  except
  showmessage('数据库没有打开');
  end;
end;

procedure TFrmgx.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.ClientDataSet23.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet23.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;

procedure TFrmgx.DBGrid1TitleClick(Column: TColumn);
var i : integer;
begin
for i:= 1 to DBGrid1.Columns.Count do
begin
//恢复所有标题字体为默认
DBGrid1.Columns[i-1].Title.Font.Color := clBlue;
DBGrid1.Columns[i-1].Title.Font.Style := [];
end;
if DataModule1.ClientDataSet17.IndexFieldNames<>(Column.FieldName) then //判断原排序方式
begin
DataModule1.ClientDataSet17.IndexFieldNames:= Column.FieldName;
Column.Title.Font.Color := clRed; //改变标题行字体为红色,表示当前的排序方式为升序
Column.Title.Font.Style := [fsBold];
end;
end;

procedure TFrmgx.DBGrid5DblClick(Sender: TObject);
begin
bdelete.Enabled:=true;
end;

procedure TFrmgx.bprintcClick(Sender: TObject);
var
excelname: string;
begin
 if not (MessageDlg('您只导出该订单包号记录请确认,需要导出全部记录请取消?',mtConfirmation,[mbYes, mbCancel], 0) = mrYes) then
begin
commandstring:='select * from dbo.gxb order by ddh,gxmc';
DataModule1.clientdataset23.Close;
DataModule1.clientdataset23.CommandText:=commandstring;
DataModule1.clientdataset23.Open;
end;
if not DataModule1.ClientDataSet23.Active then exit;
if not form1.excel then
begin
showmessage('您还未获得管理员的授权!请您与管理员联系获取授权!');
exit;
end;
if DataModule1.ClientDataSet23.RecordCount<1 then exit;
opendialog1.Filter:='Excel 文件 (*.xls) │*.xls';
if opendialog1.Execute then excelname:=opendialog1.FileName;
if length(excelname)>0 then writetoexcel(DataModule1.ClientDataSet23,excelname,'工序信息');
exit;
end;

procedure TFrmgx.bnewClick(Sender: TObject);
var
i:integer;
begin
bsave.Enabled:=true;
bcancel.Enabled:=true;
bprint.Enabled:=false;
bdelete.Enabled:=false;
bnew.Enabled:=false;
bquery.Enabled:=true;
i:=DataModule1.ClientDataSet23.RecordCount+1;
txh.Text:=inttostr(i);
while DataModule1.ClientDataSet23.Locate('xh',txh.Text,[]) do
begin
i:=i+1;
txh.Text:=inttostr(i);
end;
txh.SetFocus;
help.Caption:='  请您输入数据!';
pz.Enabled:=true;
end;

function tfrmgx.checkgx(ddh,gxmc,dj:string):boolean;
var
relation,commandstring,cx:string;
begin
relation:=' = ''';
cx:='';
commandstring:='select * from dbo.gxb where (ddh ' +relation+cx+form1.ddh+cx+''')';  //检查
commandstring:=commandstring+' and (gxmc ' +relation+cx+form1.gxmc+cx+''')';
commandstring:=commandstring+' and (dj ' +relation+cx+form1.dj+cx+''')';
try
DataModule1.ClientDataSet28.Close;
DataModule1.ClientDataSet28.CommandText:=commandstring;
DataModule1.ClientDataSet28.Open;
if DataModule1.ClientDataSet28.RecordCount<1 then form1.gxmc:='';
DataModule1.ClientDataSet28.Active:=false;
except
form1.gxmc:='';
end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -