📄 bas_bom3_d.pas
字号:
//如果父项为'',则在相应的字段输入NULL
if Extedt_ite_ItemCode.Text='' then
T_MasterString:=' null '
else T_MasterString:=' '''+Extedt_ite_ItemCode.Text+''' ';
//如果部门为'',则在相应的字段输入NULL
if Edt_DeptCode.Text='' then
T_DeptString:=' null '
else T_DeptString:=' '''+Edt_DeptCode.Text+''' ';
//这里是修改的时候,删除在另外的地方
sql.text:='insert into BomChangeInfo '+
' (LogDate,'+
' EmployeeCode,'+
' LogAction,'+
' BomId,'+
' Ite_ItemCode,'+
' ItemCode,'+
' BomItemType,'+
' BomQty,'+
' BomScrAp_Percent,'+
' BomStatus,'+
' DeptCode,'+
' usestyle,'+
' BomMArK) '+
'Values '+
' (getdate(),'+
' '''+UserCode+''','+
' 0,'+
' '+IntToStr(Lc_Identity)+','+
' '+T_MasterString+','+
' '''+Lb_ItemCode.Caption+''','+
' '+GetCode(Cmbx_Type.Text)+','+
' '+Edt_Qty.Text+','+
' '+Edt_ScrAp.Text+','+
' '+GetCode(CmBx_Status.Text)+','+
' '+T_DeptString+','+
' '+getCode(CmBx_usestyle.text)+','+
' 0) ';
execsql;
Close;
end;
end;
procedure TFrm_Bas_Bom3_D.Edt_ScrApExit(Sender: TObject);
begin
inherited;
FloatCheck(sender);
//损耗率不能大于100%
if StrToFloat(Edt_ScrAp.Text)>100 then
begin
DispInfo('损耗率不能超过100%',1);
Edt_ScrAp.SetFocus;
end;
if StrToFloat(Edt_ScrAp.Text)<0 then
begin
DispInfo('损耗率不能小于0!',1);
Edt_ScrAp.SetFocus;
end;
Edt_ScrAp.Text:=FormatFloat('0.#####',StrToFloat(Edt_ScrAp.Text));
end;
procedure TFrm_Bas_Bom3_D.Edt_QtyExit(Sender: TObject);
begin
inherited;
FloatCheck(sender);
if StrToFloat(Edt_Qty.Text)<0 then
begin
DispInfo('定额不能小于0!',1);
Edt_Qty.SetFocus;
end;
Edt_Qty.Text:=FormatFloat('0.########',StrToFloat(Edt_Qty.Text));
end;
{
Item
1 工作中心、4 结构虚项、7 替代虚项
Bom
1 工作中心、3 结构虚项、6 替代虚项
}
procedure TFrm_Bas_Bom3_D.CmBx_TypeExit(Sender: TObject);
begin
inherited;
SetPnl_Slave(Lb_ItemCode.Caption);
JudgeChild(Frm_Bas_Bom3.Extedt_ItemCode.Text);
end;
Function TFrm_Bas_Bom3_D.FoundReplaceVirtual(MasterCode:string):boolean;
begin
with AdoQry_Tmp do
begin
Close;
sql.clear;
sql.Add('select * from BomA where ItemCode='''+MasterCode+''' ');
open;
if Locate('BomItemType',6,[]) then Result:=True
else Result:=False;
Close;
end;
end;
procedure TFrm_Bas_Bom3_D.clearSinGleReCode;
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('delete '+
'from BomA '+
'where ItemCode not in '+
' ( select case when ite_ItemCode is null then '''' else ite_ItemCode end '+
' from BomA '+
' ) '+
' and ite_ItemCode is null '+
'');
execsql;
Close;
end;
end;
procedure TFrm_Bas_Bom3_D.InsertBomChange(realite_ItemCode:string);
begin
tmp_ItemCode:='';
with AdoQry_tmp1 do
begin
Close;
sql.clear;
sql.Add(' exec Find_Real_Ite_ItemCode '''+realite_ItemCode+'''');
Prepared;
open;
end;
AdoQry_tmp1.First ;
while not AdoQry_tmp1.Eof do
begin
tmp_ItemCode:=AdoQry_tmp1.fieldbyname ('ite_ItemCode').asstring;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('insert BomChange(real_ItemCode,ite_ItemCode,ItemCode,BomItemType0,'+
' Bomstatus0,Bomqty0,BomScrAp_Percent0, BomItemType1,Bomstatus1,Bomqty1,BomScrAp_Percent1,BomChangetime)'+
'Values('''+tmp_ItemCode+''','+
' '''+Trim(Extedt_ite_ItemCode.Text)+''','+
' '''+Trim(Lb_ItemCode.Caption)+''','+
' 0,0,0,0,'+
' '''+getCode(Trim(CmBx_Type.text))+''','+
' '''+getCode(Trim(CmBx_Status.text))+''','+
' '''+Trim(Edt_Qty.text)+''','+
' '''+Trim(Edt_ScrAp.text)+''','+
' getdate())');
execsql;
end;
AdoQry_tmp1.Next;
end;
end;
procedure TFrm_Bas_Bom3_D.updateBomChange(realite_ItemCode:string);
begin
tmp_ItemCode:='';
with AdoQry_tmp1 do
begin
Close;
sql.clear;
sql.Add(' exec Find_Real_Ite_ItemCode '''+realite_ItemCode+'''');
Prepared;
open;
end;
AdoQry_tmp1.First ;
tmp_ItemCode:=AdoQry_tmp1.fieldbyname ('ite_ItemCode').asstring;
while not AdoQry_tmp1.Eof do
begin
tmp_ItemCode:=AdoQry_tmp1.fieldbyname ('ite_ItemCode').asstring;
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('insert BomChange(real_ItemCode,ite_ItemCode,ItemCode,BomItemType0,'+
' Bomstatus0,Bomqty0,BomScrAp_Percent0, BomItemType1,Bomstatus1,Bomqty1,BomScrAp_Percent1,BomChangetime)'+
'Values('''+tmp_ItemCode+''','+
' '''+Trim(Extedt_ite_ItemCode.Text)+''','+
' '''+Trim(Lb_ItemCode.Caption)+''','+
' '''+inttostr(AdoQry_Maintain.fieldbyname('BomItemType').asinteger)+''','+
' '''+inttostr(AdoQry_Maintain.fieldbyname('BomStatus').asinteger)+''','+
' '''+floattostr(AdoQry_Maintain.fieldbyname('BomQty').asfloat)+''','+
' '''+floattostr(AdoQry_Maintain.fieldbyname('BomScrAp_Percent').asfloat)+''','+
' '''+getCode(Trim(CmBx_Type.text))+''','+
' '''+getCode(Trim(CmBx_Status.text))+''','+
' '''+Trim(Edt_Qty.text)+''','+
' '''+Trim(Edt_ScrAp.text)+''','+
' getdate())');
execsql;
end;
AdoQry_tmp1.next;
end;
end;
procedure TFrm_Bas_Bom3_D.FormActivate(Sender: TObject);
begin
inherited;
Edt_Qty.Text:='1';
Edt_ScrAp.Text:='0';
Lbl_DeptName.Caption:='';
Lb_ItemCode.Caption:=Frm_Bas_Bom3.Extedt_ItemCode.Text;
Lb_ItemName.Caption:=Frm_Bas_Bom3.Lb_ItemName.Caption;
Lb_PmCode.Caption:= Frm_Bas_Bom3.Lb_PmCode.Caption;
Lb_DesignNo.Caption:= Frm_Bas_Bom3.Lb_DesignNo.Caption;
Lb_PrepareLT.Caption:= Frm_Bas_Bom3.Lb_PreparelLT.Caption;
Lb_RunLt.Caption:= Frm_Bas_Bom3.Lb_RunLT.Caption;
Lb_QcLT.Caption:= Frm_Bas_Bom3.Lb_QcLT.Caption;
Lb_Uom.Caption:=Frm_Bas_Bom3.Lb_Uom.Caption;
if not Frm_Bas_Bom3.AdoQry_Main.IsEmpty then
begin
Lb_UomName.Caption:= Frm_Bas_Bom3.AdoQry_Main.fieldbyname('UomName').asstring;
Lb_ite_PmCode.Caption:=Frm_Bas_Bom3.AdoQry_Main.fieldbyname('PmCode').asstring;
Lb_ite_PrepareLT.Caption:=Frm_Bas_Bom3.AdoQry_Main.fieldbyname('PrepareLT').asstring;
Lb_ite_RunLt.Caption:=Frm_Bas_Bom3.AdoQry_Main.fieldbyname('RunLt').asstring;
Lb_ite_QcLT.Caption:= Frm_Bas_Bom3.AdoQry_Main.fieldbyname('QcLT').asstring;
Lb_ite_DesignNo.Caption:= Frm_Bas_Bom3.AdoQry_Main.fieldbyname('DesignNo').asstring;
Lbl_DeptName.Caption:= Frm_Bas_Bom3.AdoQry_Main.fieldbyname('DeptName').asstring;
end
else
begin
Lb_UomName.Caption:= '';
Lb_ite_PmCode.Caption:='';
Lb_ite_PrepareLT.Caption:='';
Lb_ite_RunLt.Caption:='';
Lb_ite_QcLT.Caption:= '';
Lb_ite_DesignNo.Caption:= '';
Lbl_DeptName.Caption:= '';
end;
Edt_Qty.Text:=FormatFloat('0.########',StrToFloat(Edt_Qty.Text));
end;
procedure TFrm_Bas_Bom3_D.ItemCodeCheck(Sender: TObject);
var
S1:string;
begin
if(ActiveControl.Name='btn_Cancel')then
exit;
//先判断父项子项是否相同,相同则退出
if Extedt_ite_ItemCode.text=Lb_ItemCode.Caption then
begin
DispInfo('父项和子项不能相同!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
checkPmItem(Trim(Extedt_ite_ItemCode.text));
//判断输入的对应关系是否已经存在
if FoundBom(Extedt_ite_ItemCode.Text,Lb_ItemCode.Caption) then
begin
DispInfo('该物料的Bom已经存在!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
if Frm_Bas_Bom3.CheckBomOK(Extedt_ite_ItemCode.Text) then
begin
DispInfo('父项物料Bom已审核,不能执行增加动作!',1);
Extedt_ite_ItemCode.SetFocus;
abort;
end;
if SlaveCodeUsable(Lb_ItemCode.Caption) then
begin
//循环校验输入的子项是否有效,如果无效则退出,
//如果为新的Bom则不进行检查
if not IsNewBom(Extedt_ite_ItemCode.Text) then
begin
if not CicleCheckSlaveValid(Extedt_ite_ItemCode.Text,Lb_ItemCode.Caption ) then
begin
DispInfo('物料循环使用!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
SetPnl_Slave(Lb_ItemCode.Caption);
end
else
begin
DispInfo('请输入代码没找到!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
inherited;
S1:='select ItemName,UomName, PmCode, Preparelt,runlt,Qclt,designno from Item'+
' join Uom on Item.UomCode=Uom.UomCode where ItemCode='+quotedstr(Extedt_ite_ItemCode.Text);
AdoQry_tmp.Close;
AdoQry_tmp.SQL.clear;
AdoQry_tmp.SQL.Add(S1);
AdoQry_tmp.Open;
Lb_ite_ItemName.Caption:= AdoQry_tmp.fieldbyname('ItemName').AsString;
Lb_UomName.Caption:= AdoQry_tmp.fieldbyname('UomName').AsString;
Lb_ite_PmCode.Caption:= AdoQry_tmp.fieldbyname('PmCode').AsString;
Lb_ite_PrepareLT.Caption:= AdoQry_tmp.fieldbyname('Preparelt').AsString;
Lb_ite_RunLt.Caption:= AdoQry_tmp.fieldbyname('runlt').AsString;
Lb_ite_QcLT.Caption:= AdoQry_tmp.fieldbyname('Qclt').AsString;
Lb_ite_DesignNo.Caption:= AdoQry_tmp.fieldbyname('designno').AsString;
if Extedt_ite_ItemCode.Text=Lb_ItemCode.Caption then abort;
end;
procedure TFrm_Bas_Bom3_D.JudgeChild(ItemCode:string);
var
S:string;
begin
S:=' select ItemType from Item where ItemCode='+QuotedStr(ItemCode);
with AdoQry_tmp do
begin
Close;
SQL.clear;
SQL.Add(S);
Open;
end;
case AdoQry_tmp.fieldbyname('ItemType').asinteger of
0: if CmBx_Type.ItemIndex<>4 then CmBx_Type.ItemIndex:=0;
1: CmBx_Type.ItemIndex:=1;
4: CmBx_Type.ItemIndex:=3;
5:
begin
DispInfo('劳务不允许挂入Bom',1);
abort;
end;
6: CmBx_Type.ItemIndex:=5;
7: CmBx_Type.ItemIndex:=6;
3: CmBx_Type.ItemIndex:=7;
end;
end;
procedure TFrm_Bas_Bom3_D.Edt_QtyChange(Sender: TObject);
begin
inherited;
if Length(Edt_Qty.Text)>12 then
begin
DispInfo('您所录入的数据已超过规定长度,请查证后再录入',1);
Edt_Qty.text:='';
Abort;
end
else
btn_ok.Enabled:=True;
end;
procedure TFrm_Bas_Bom3_D.checkPmItem(ItemCode:string);//是否采购件
var
sSQL:string;
begin
if(ActiveControl.Name='btn_Cancel')then
Abort;
sSQL:='select PmCode from Item where ItemCode='+Quotedstr(ItemCode);
with AdoQry_tmp do
begin
Close;
SQL.clear;
SQL.Add(sSQL);
Open;
if fieldbyname('PmCode').AsInteger=1 then
begin
DispInfo('不允许采购件下挂子项',1);
Extedt_ite_ItemCode.SetFocus;
abort;
end;
end;
end;
procedure TFrm_Bas_Bom3_D.GetWorkCenterQTY;
begin
end;
procedure TFrm_Bas_Bom3_D.Button1Click(Sender: TObject);
begin
inherited;
GetWorkCenterQTY;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -