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

📄 bas_bom1_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    execsql;
    Close;
  end;
end;

procedure TFrm_Bas_Bom1_D.SaveAddToLog;
var
  T_MasterString:string;
  T_DeptString:string;
begin
  T_MasterString:='';
  T_DeptString:='';

  with AdoQry_Tmp do
  begin
    Close;
    sql.clear;
    //如果父项为'',则在相应的字段输入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_Bom1_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_Bom1_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_Bom1_D.CmBx_TypeExit(Sender: TObject);
begin
  inherited;
  SetPnl_Slave(Lb_ItemCode.Caption);
  JudgeChild(Frm_Bas_Bom1.Extedt_ItemCode.Text);
end;

Function  TFrm_Bas_Bom1_D.FoundReplaceVirtual(MasterCode:string):boolean;
begin
  with AdoQry_Tmp do
  begin
    Close;
    sql.clear;
    sql.Add('select * from Bom where ItemCode='''+MasterCode+''' ');
    open;
    if Locate('BomItemType',6,[]) then Result:=True
    else Result:=False;
    Close;
  end;
end;

procedure TFrm_Bas_Bom1_D.clearSinGleReCode;
begin
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add('delete '+
            'from Bom '+
            'where ItemCode not in '+
            ' ( select case when ite_ItemCode is null then '''' else ite_ItemCode end '+
            '   from Bom '+
            '  ) '+
            '  and ite_ItemCode is  null '+
            '');
    execsql;
    Close;
  end;
end;

procedure TFrm_Bas_Bom1_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_Bom1_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_Bom1_D.FormActivate(Sender: TObject);
begin
  inherited;
  Lb_ItemCode.Caption:=Frm_Bas_Bom1.Extedt_ItemCode.Text;
  Lb_ItemName.Caption:=Frm_Bas_Bom1.Lb_ItemName.Caption;
  Lb_PmCode.Caption:= Frm_Bas_Bom1.Lb_PmCode.Caption;
  Lb_DesignNo.Caption:= Frm_Bas_Bom1.Lb_DesignNo.Caption;
  Lb_PrepareLT.Caption:= Frm_Bas_Bom1.Lb_PreparelLT.Caption;
  Lb_RunLt.Caption:= Frm_Bas_Bom1.Lb_RunLT.Caption;
  Lb_QcLT.Caption:= Frm_Bas_Bom1.Lb_QcLT.Caption;
  Lb_UomName.Caption:= Frm_Bas_Bom1.AdoQry_Main.fieldbyname('UomName').asstring;
  Lb_ite_PmCode.Caption:=Frm_Bas_Bom1.AdoQry_Main.fieldbyname('PmCode').asstring;
  Lb_ite_PrepareLT.Caption:=Frm_Bas_Bom1.AdoQry_Main.fieldbyname('PrepareLT').asstring;
  Lb_ite_RunLt.Caption:=Frm_Bas_Bom1.AdoQry_Main.fieldbyname('RunLt').asstring;
  Lb_ite_QcLT.Caption:= Frm_Bas_Bom1.AdoQry_Main.fieldbyname('QcLT').asstring;
  Lb_ite_DesignNo.Caption:= Frm_Bas_Bom1.AdoQry_Main.fieldbyname('DesignNo').asstring;
  Lbl_DeptName.Caption:= Frm_Bas_Bom1.AdoQry_Main.fieldbyname('DeptName').asstring;
  if Frm_Bas_Bom1.AdoQry_Main.IsEmpty then Edt_Qty.Text:=''else
  Edt_Qty.Text:=FormatFloat('0.########',StrToFloat(Edt_Qty.Text));
end;

procedure TFrm_Bas_Bom1_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 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_Bom1_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_Bom1_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_Bom1_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_Bom1_D.GetWorkCenterQTY;
begin
end;

procedure TFrm_Bas_Bom1_D.Button1Click(Sender: TObject);
begin
  inherited;
  GetWorkCenterQTY;
end;

end.

⌨️ 快捷键说明

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