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

📄 mrp_enter_mo_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
      begin
        edt_qty.Enabled:=False;
        exit;
      end;
      if AdoQry_Body.fieldbyname('MoInqty').asfloat>0 then 
      begin
        edt_qty.Enabled:=False;
        exit;
      end;
      sqltext:='select sum(isnull(MoRealqty,0)) as MoRealqty from mnItemList'    
              +' where mono='+quotedstr(AdoQry_Body.fieldbyname('mono').asstring)
              +'  and  MoLineno='+AdoQry_Body.fieldbyname('MoLineno').asstring;
      Executesql(AdoQry_tmp,sqltext,0);
      if AdoQry_tmp.fieldbyname('MoRealqty').asfloat>0 then 
        begin
          edt_qty.Enabled:=False;
          exit;
        end;
    enablecontrols:=enablecontrols+'Edt_Qty,';
  end;
    
 //   showmessage(inttostr(linestatus));
end;

procedure TFrm_Mrp_Enter_Mo_D.DateCheck(Sender: TObject);
begin
  If (ActiveControl.Name ='btn_Cancel') Or (ActiveControl.Name='medt_Modate') Then
    Exit;
  inherited;
  If SlCalendar(DbConnect,Medt_MoStArtWorkDate.Text,0)<>Medt_MoStArtWorkDate.Text Then
  begin
    DispInfo(Medt_MoStArtWorkDate.Text+'不是工作日!',3);
    Medt_MoStArtWorkDate.Text:=SlCalendar(DbConnect,Medt_MoStArtWorkDate.Text,0);
    Medt_MoStArtWorkDate.SetFocus;
    Abort;
  end;  //约定开工日必须是工作日,否则返回前一个工作日
  If (Status='Add') And ((StrToDate(Medt_MoStArtWorkDate.Text)>StrToDate(Medt_MoDate.Text))
    Or (StrToDate(Medt_MoStArtWorkDate.Text)<Date())) Then
   begin
     DispInfo('约定开工日必须为系统工作日与约定交货日之间的日期,请修改!',3);
     TWinControl(Sender).SetFocus;
     Abort;
   end;
  If (Status<>'Add') And (StrToDate(Medt_MoStArtWorkDate.Text)>StrToDate(Medt_MoDate.Text)) Then
  begin
    DispInfo('约定开工日必须小于约定交货日,请修改!',3);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
end;

procedure TFrm_Mrp_Enter_Mo_D.btn_okClick(Sender: TObject);
var
  I:String;
begin
  If (Status='Add') Then
  begin
    begin
      if cmbBackflush.ItemIndex=1 then
       if existSalterson(Trim(Extedt_ItemCode.text)) then
         begin
          DispInfo(Trim(Extedt_ItemCode.text)+'物料有替代件子项,不能拉式领料!',3);
          abort;
         end;
    If AdoQry_Body.RecordCount>0 Then
      AdoQry_Body.First;
      While Not AdoQry_Body.Eof Do
      begin
        If (Trim(ExtEdt_ItemCode.Text)=Trim(AdoQry_Body.fieldbyname('ItemCode').AsString))
           And (StrToDateTime(MEdt_MoDate.Text)=AdoQry_Body.fieldbyname('MoLineDate').AsDateTime) Then
          begin
            DispInfo('你不能输入两笔相同(物料代码+约定交货日)的记录!',3);
            Btn_Ok.Enabled:=False;
            ExtEdt_ItemCode.SelectAll;
            ExtEdt_ItemCode.SetFocus;
            Abort;
          end;
        AdoQry_Body.Next;
      end;  //end  while
    end;  //end if
  end;   //end (Add)
  If (Status<>'Add') Then
  begin
      if cmbBackflush.ItemIndex=1 then
       if existSalterson(Trim(Extedt_ItemCode.text)) then
         begin
          DispInfo(Trim(Extedt_ItemCode.text)+'物料有替代件子项,不能拉式领料!',3);
          abort;
         end;
    I:=AdoQry_Body.BookmArk;
    AdoQry_Body.First;
    While Not AdoQry_Body.Eof Do
    begin
      If (Trim(ExtEdt_ItemCode.Text)=Trim(AdoQry_Body.fieldbyname('ItemCode').AsString))
         And (StrToDateTime(MEdt_MoDate.Text)=AdoQry_Body.fieldbyname('MoLineDate').AsDateTime)
         And (I<>AdoQry_Body.BookmArk) Then
        begin
          DispInfo('你不能输入两笔相同(物料代码+约定交货日)的记录!',1);
          Btn_Ok.Enabled:=False;
          ExtEdt_ItemCode.SelectAll;
          ExtEdt_ItemCode.SetFocus;
          Close;
          Abort;
        end;
      AdoQry_Body.Next;
    end;  //end  while
  AdoQry_Body.BookmArk:=I;
  end;
  inherited;
  cmbBackflush.ItemIndex:=AdoQry_Body.fieldbyname('Backflush').asinteger;
end;

procedure TFrm_Mrp_Enter_Mo_D.ExtEdt_ItemCodeExit(Sender: TObject);
var
  SqlText:String;
begin
  If ActiveControl.Name='btn_Cancel' Then
    Exit;
  SqlText:=' Select Item.ItemName,Item.MnldTime,runlt,UomName '
          +' From Item '
          +' Left Outer Join Uom On Item.UomCode=Uom.UomCode '
          +' Where ItemCode='+''''+Trim(ExtEdt_ItemCode.Text)+''''
          +' And PmCode In (0,3) and ItemUsable=1 and ItemType not in (4,7)';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:=SqlText;
  AdoQry_Tmp.Open;
  If AdoQry_Tmp.Eof Then
  begin
    DispInfo('输入了错误的物料代码,请重新输入!',3);
    TWincontrol(Sender).SetFocus;
    Abort;
  end;
  UomName:=AdoQry_Tmp.fieldbyname('UomName').AsString;
  MnldTime:=AdoQry_Tmp.fieldbyname('MnldTime').AsInteger;
  runlt:=AdoQry_tmp.fieldbyname('runlt').asinteger;
  edt_ItemName.text:=AdoQry_Tmp.fieldbyname('ItemName').AsString;
end;

procedure TFrm_Mrp_Enter_Mo_D.ExtEdt_ItemCodeKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
 If key=120 Then
  CommOnHint(Sender,AdoQry_Tmp,'ItemName','物料描述','ItemCode',
             '物料代码',' Item ',' PmCode In (0,3) and ItemType not in (4,7) and ItemUsable=1 ');

end;

procedure TFrm_Mrp_Enter_Mo_D.medt_ModateExit(Sender: TObject);
begin
  inherited;
  If ActiveControl.Name ='btn_Cancel' Then
    Exit;
  Try
    StrToDateTime(Medt_MoDate.Text);
  Except
    DispInfo('约定交货日错误,请重新输入!',3);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
  If (Status='Add') And (StrToDate(MEdt_MoDate.Text)<Date()) Then
  begin
    DispInfo('约定交货日必须大于等于当前系统日期!',3);
    TWinControl(Sender).SetFocus;
    Abort;
  end;
  If SlCalendar(DbConnect,MEdt_MoDate.Text,0)<>MEdt_MoDate.Text Then
  begin
    DispInfo(MEdt_MoDate.Text+'不是工作日!',3);
    MEdt_MoDate.Text:=SlCalendar(DbConnect,MEdt_MoDate.Text,0);
    MEdt_MoDate.SetFocus;
    Abort;
  end;
  If (MoStArtWorkDate<>SlCalendar(DbConnect,MEdt_MoDate.Text,runlt))
      Then                    //And (Status='Add')
    MEdt_MoStArtWorkDate.Text:=SlCalendar(DbConnect,MEdt_MoDate.Text,runlt);
  If (StrToDateTime(MEdt_MoStArtWorkDate.Text)<Date())  Then  // And (Status='Add')
  begin
    AdoQry_Tmp.Close;
    AdoQry_Tmp.SQL.Text:=' Select DateDiff(Day,'''+DateTimeToStr(Date)+''','''+MEdt_MoStArtWorkDate.Text+''') As Day1 ';
    AdoQry_Tmp.Open;
    ShowMessage('理论开工日('+Medt_MoStArtWorkDate.Text+ ')小于了系统工作日('+DateToStr(Date())+') '+IntToStr(Abs(AdoQry_Tmp.fieldbyname('Day1').AsInteger))+' 天!');
    Medt_MoStArtWorkDate.Text:=FormatDateTime('yyyy.mm.dd',Date);
    MoStArtWorkDate:=SlCalendar(DbConnect,MEdt_MoDate.Text,runlt);
  end;
end;

procedure TFrm_Mrp_Enter_Mo_D.FloatCheck(Sender: TObject);
begin
  inherited;
  If (Status='Add') And (StrToFloat(Edt_Qty.Text)<=0 ) Then
  begin
    DispInfo('增加数据时约定交货量不能小于等于0!',3);
    TWincontrol(Sender).SetFocus;
    Abort;
  end;
  Edt_Qty.Text:=FormatFloat('##0.####',StrToFloat(Edt_Qty.Text));
end;

function TFrm_Mrp_Enter_Mo_D.existSalterson(ItemCode: string): boolean;
var AdoQry:TAdoQuery;
    sqltext:string;
begin
   Result:=False;
   AdoQry:=TAdoQuery.Create(self);
   AdoQry.Connection:=dbconnect;
   sqltext:='select ItemCode from Bom where BomItemType=6 and ite_ItemCode='+quotedstr(ItemCode);
   try
     Executesql(AdoQry,sqltext,0);
     if AdoQry.RecordCount>0 then Result:=True;
   finally
    AdoQry.Free;
   end;
end;

procedure TFrm_Mrp_Enter_Mo_D.Extedt_ItemCodeButtonClick(Sender: TObject);
begin
  inherited;
  CommOnHint(Sender,AdoQry_Tmp,'ItemName','物料描述','ItemCode',
             '物料代码',' Item ',' PmCode In (0,3) and ItemType not in (4,7) and ItemUsable=1 ');


end;

end.

⌨️ 快捷键说明

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