📄 absent_bom.pas
字号:
begin
if not ADOQ_absent_BOM.Active then exit;
with ADOQ_absent_BOM do
begin
if RecordCount<1 then exit;
if State in [dsinsert,dsedit] then exit;
temp_ordid:=fieldvalues['ord_id'];
temp_seqname:=fieldvalues['seq_name'];
temp_matname:=fieldvalues['mat_name'];
temp_matid:=fieldvalues['mat_id'];
temp_key:=fieldvalues['temp_key'];
if MsgQst(handle,'确定订单批号 ['+temp_ordid+'] 的工序 ['+temp_seqname+'] 不需要辅料 ['+temp_matname+'] 吗?') =IDNO then exit;
end;
try
if not operator_absBOM(2,temp_ordid,temp_key,temp_matid,0) then MsgErr(handle,'数据删除失败!');
except
MsgErr(handle,'数据删除失败!');
exit;
end;
with ADOQ_absent_BOM do
begin
close; open;
locate('temp_key',temp_key,[]);
end;
end;
procedure TForm_Absent_BOM.SaveBtnClick(Sender: TObject);
var
temp_ordid, temp_seqname, temp_key, temp_matid: string;
temp_int:integer; temp_num: real;
begin
if not ADOQ_absent_BOM.Active then exit;
with ADOQ_absent_BOM do
begin
if not (State in [dsinsert,dsedit]) then exit;
temp_ordid:=trim(DBComBox_ordid.Text);
if (temp_ordid='') then
begin
showmessage('订单批号不能为空!!!');
DBComBox_ordid.SetFocus;
exit;
end;
temp_seqname:=trim(DBComBox_seq_name.Text);
if temp_seqname='' then
begin
showmessage('工序名称不能为空!!!');
DBComBox_seq_name.SetFocus;
exit;
end;
temp_matid:=trim(DBE_mat_id.Text);
if temp_matid='' then
begin
showmessage('请选择所需的辅料!');
DBGrid2.SetFocus;
exit;
end;
if trim(DBE_num.Text)='' then
begin
messagebox(handle,'请输入辅料的需求数量!','警告',mb_ok or MB_ICONINFORMATION);
DBE_num.SetFocus;
exit;
end;
try
temp_num:=strtofloat(trim(DBE_num.Text));
if temp_num<=0 then
begin
msgErr(handle,'请输入正确的需求数量!');
DBE_num.SetFocus;
exit;
end;
except
msgERR(handle,'请输入正确的需求数量!');
DBE_num.SetFocus;
exit;
end;
//初始化操作类型
temp_int:=3;
if State in [dsinsert] then
begin
temp_int:=0;
with ADOQ_temp do
begin
close; sql.Clear;
sql.Add('select * from sequence_price where ord_id=:ord_id and seq_name=:seq_name');
Parameters.ParamValues['ord_id']:=temp_ordid;
Parameters.ParamValues['seq_name']:=temp_seqname;
open;
temp_key:=fieldvalues['temp_key'];
close;
end;
end;
if state in [dsedit] then
begin
temp_int:=1;
temp_key:=fieldvalues['temp_key'];
end;
end;
try
//利用另一表对辅料需求表新增
if operator_absBOM(temp_int, temp_ordid, temp_key, temp_matid, temp_num) then
begin
ADOQ_absent_BOM.cancel;
ADOQ_absent_BOM.Close; ADOQ_absent_BOM.Open;
ADOQ_absent_BOM.Locate('log_id',log_id,[]);
with ADOq_material do
begin
close;
sql.Strings[2]:='';
open;
end;
end;
except
MsgErr(handle,'数据操作失败!');
end;
end;
procedure TForm_Absent_BOM.PageControl1Changing(Sender: TObject;
var AllowChange: Boolean);
begin
{ if not ADOQ_absent_BOM.Active then
begin
MsgOk(handle,'工序辅料信息表未打开,'+#13+#13+'请在订单批号下拉文本框内输入订单批号再按回车键!');
AllowChange:=true; exit;
end; }
if (ADOQ_absent_BOM.State in [dsedit,dsinsert]) then
begin
MsgOK(handle,'数据库正处在操作状态,请先按 [取消] 按钮!');
AllowChange:=false;
end;
end;
procedure TForm_Absent_BOM.Bit_Ser2Click(Sender: TObject);
begin
edit3.Text:=trim(edit3.Text);
if edit3.Text='' then begin edit3.SetFocus; exit;end;
//查找对应的物料信息
with ADOQ_material do
begin
close;
sql.Strings[2]:='and a.mat_name like '+''''+'%'+edit3.Text+'%'+'''';
open;
if recordcount<0 then
begin
MsgErr(handle,'没找到名称为 ['+edit3.Text+'] 的物料!');
edit3.SetFocus;
end;
end;
end;
procedure TForm_Absent_BOM.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
if key=chr(13) then Bit_Ser2.Click;
end;
procedure TForm_Absent_BOM.DS_absent_BOMStateChange(Sender: TObject);
var mat_id:string;
begin
if (Sender as TDataSource).DataSet.State in [dsinsert,dsedit] then
begin
AddBtn.Enabled:=false;
EdtBtn.Enabled:=false;
DelBtn.Enabled:=false;
Panel5.Enabled:=true;
DBNavigator1.Enabled:=false;
if (Sender as TDataSource).DataSet.State in [dsinsert] then
begin
GroupBox2.Enabled:=true;
with ADOq_material do
begin
close; sql.Strings[2]:='';
open;
end;
DBComBox_ordid.Enabled:=true;
DBComBox_ordid.ParentColor:=false;
DBComBox_ordid.Color:=clWindow;
DBComBox_seq_name.enabled:=true;
DBComBox_seq_name.ParentColor:=false;
DBComBox_seq_name.Color:=clWindow;
DBE_num.ParentColor:=false;
DBE_num.Color:=clWindow;
DBComBox_seq_name.SetFocus;
end;
if (Sender as TDataSource).DataSet.State in [dsedit] then
begin
mat_id:=(Sender as TDataSource).DataSet.FieldValues['mat_id'];
with ADOQ_material do
begin
close; sql.Strings[2]:='';
open; Locate('mat_id',mat_id,[loCaseInsensitive]);
end;
DBE_mat_id.Clear; DBE_matname.clear;
DBE_custname.Clear; DBE_costume.Clear;
Editcloth.Clear; Label_unit.Caption:='';
DBComBox_ordid.Text:=''; DBComBox_seq_name.Clear;
DBE_num.clear;
with (Sender as Tdatasource).DataSet do
begin
if recordcount=0 then exit;
DBE_mat_id.text:=fieldvalues['mat_id'];
DBE_matname.text:=fieldvalues['mat_name'];
DBE_custname.text:=fieldvalues['cust_name'];
Editcloth.text:=fieldvalues['clo_name'];
Label_unit.Caption:=fieldvalues['unit'];
DBE_costume.Text:=fieldvalues['costume_name'];
DBComBox_ordid.text:=fieldvalues['ord_id'];
DBComBox_seq_name.text:=fieldvalues['seq_name'];
DBE_num.Text:=floattostr(fieldvalues['num']);
end;
DBComBox_ordid.enabled:=false;
DBComBox_ordid.ParentColor:=true;
DBComBox_seq_name.enabled:=false;
DBComBox_seq_name.ParentColor:=true;
GroupBox2.Enabled:=false;
Dbe_num.ParentColor:=false;
dbe_num.Color:=clwindow;
DBE_num.SetFocus;
end;
end;
if (Sender as TDataSource).DataSet.State in [dsBrowse] then
begin
Panel5.Enabled:=false;
AddBtn.Enabled:=true;
EdtBtn.Enabled:=true;
DelBtn.Enabled:=true;
DBNavigator1.Enabled:=true;
DBComBox_ordid.ParentColor:=true;
DBComBox_seq_name.ParentColor:=true;
DBE_num.ParentColor:=true;
with adoq_material do
begin
close; sql.Strings[2]:='';
open;
end;
end;
end;
procedure TForm_Absent_BOM.DBGrid1DblClick(Sender: TObject);
begin
if not adoq_absent_bom.Active then exit;
if ADOQ_absent_BOM.RecordCount=0 then exit;
PageControl1.ActivePageIndex:=1;
PageControl1Change(self);
end;
procedure TForm_Absent_BOM.DBLookup_orderKeyPress(Sender: TObject;
var Key: Char);
var
tmp_ordid: string;
begin
tmp_ordid:=trim(DBLookup_order.Text);
if tmp_ordid='' then exit;
if key<>chr(13) then exit;
//查找是否存在该订单批号
with ADOQ_temp do
begin
close;sql.clear;
sql.add('select ord_id from order_msg where ord_id=:v_ord_id');
Parameters.ParamValues['v_ord_id']:=tmp_ordid;
open;
if recordcount =0 then
begin
MsgErr(handle,'当前不存在该订单批号,请重新选择!');
exit;
end;
end;
//查找该订单批号是否存在工序编排
with ADOQ_temp do
begin
close;sql.clear;
sql.add('select temp_key from sequence_price where ord_id=:v_ord_id');
Parameters.ParamValues['v_ord_id']:=tmp_ordid;
open;
if recordcount =0 then
begin
MsgErr(handle,'该订单下无工序,请先添加工序!');
exit;
end;
close;
end;
with ADOQ_absent_BOM do
begin
close;
sql.Strings[4]:='and a.ord_id = '+''''+tmp_ordid+'''';
execsql; open;
end;
end;
procedure TForm_Absent_BOM.DBLookup_orderChange(Sender: TObject);
begin
DBLookup_order.Text:=trim(DBLookup_order.Text);
end;
procedure TForm_Absent_BOM.DS_absent_BOMDataChange(Sender: TObject;
Field: TField);
var mat_id:string;
begin
if not (Sender as Tdatasource).DataSet.Active then exit;
if (Sender as Tdatasource).DataSet.State in [dsinsert, dsedit] then exit;
if (Sender as Tdatasource).DataSet.RecordCount=0 then exit;
if PageControl1.ActivePageIndex=0 then exit;
DBE_mat_id.Clear; DBE_matname.clear;
DBE_custname.Clear; DBE_costume.Clear;
Editcloth.Clear; Label_unit.Caption:='';
DBComBox_ordid.Text:=''; DBComBox_seq_name.Clear;
DBE_num.clear;
with (Sender as Tdatasource).DataSet do
begin
if recordcount=0 then exit;
DBE_mat_id.text:=fieldvalues['mat_id'];
DBE_matname.text:=fieldvalues['mat_name'];
DBE_custname.text:=fieldvalues['cust_name'];
Editcloth.text:=fieldvalues['clo_name'];
Label_unit.Caption:=fieldvalues['unit'];
DBE_costume.Text:=fieldvalues['costume_name'];
DBComBox_ordid.text:=fieldvalues['ord_id'];
DBComBox_seq_name.text:=fieldvalues['seq_name'];
DBE_num.Text:=floattostr(fieldvalues['num']);
end;
mat_id:=(Sender as TDataSource).DataSet.FieldValues['mat_id'];
if ADOQ_material.Active then
ADOQ_material.Locate('mat_id',mat_id,[loCaseInsensitive]);
end;
procedure TForm_Absent_BOM.DBComBox_ordidChange(Sender: TObject);
begin
if trim(DBComBox_ordid.Text)='' then exit;
with adoq_temp do
begin
close; sql.Clear;
sql.Add('select c.cust_name, a.costume_name, b.clo_name from order_msg a, clothing b, customer c');
sql.Add('where a.clo_id=b.clo_id and a.cust_id=c.cust_id and ord_id=:ord_id');
parameters.ParamValues['ord_id']:=trim(DBComBox_ordid.Text);
open;
if recordcount=0 then
begin
MsgErr(handle,'该订单批号不存在,请重新重新操作!');
exit;
end;
DBE_custname.Clear; DBE_costume.Clear;
Editcloth.Clear;
DBE_custname.Text:=fieldvalues['cust_name'];
dbe_costume.Text:=fieldvalues['costume_name'];
editcloth.Text:=fieldvalues['clo_name'];
add_seqname;
end;
end;
procedure TForm_Absent_BOM.DS_materialDataChange(Sender: TObject;
Field: TField);
begin
if not (ADOQ_absent_BOM.State in [dsinsert]) then exit;
with ADOQ_material do
begin
if recordcount=0 then exit;
DBE_mat_id.Clear; DBE_matname.Clear;
Label_unit.Caption:='';
DBE_mat_id.Text:=fieldvalues['mat_id'];
DBE_matname.Text:=fieldvalues['mat_name'];
Label_unit.Caption:=fieldvalues['unit'];
end;
end;
procedure TForm_Absent_BOM.FormCreate(Sender: TObject);
begin
add_matype;
end;
procedure TForm_Absent_BOM.DBComBox_ordidKeyPress(Sender: TObject;
var Key: Char);
begin
abort;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -