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

📄 mrp_enter_commonassignalternative.pas

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

procedure TFrm_Mrp_Enter_CommonAssignAlterNative.DateCheck(Sender: TObject);
begin
  If (ActiveControl.Name='DBGridEh1') Or (ActiveControl.Name='ControlBar')  Then
    Exit;
  inherited;

end;

procedure TFrm_Mrp_Enter_CommonAssignAlterNative.Act_DeleteLineExecute(Sender: TObject);
begin
 if AdoQry_Body.RecordCount=0 then exit;
  If DispInfo('确认真的要删除这行吗?',2)<>'y' Then
    Abort;
  AdoQry_Body.Delete;
end;

procedure TFrm_Mrp_Enter_CommonAssignAlterNative.Act_QuitExecute(Sender: TObject);
begin
 Close;

end;

procedure TFrm_Mrp_Enter_CommonAssignAlterNative.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
//  inherited;

end;

procedure TFrm_Mrp_Enter_CommonAssignAlterNative.Act_ExcelExecute(Sender: TObject);
begin
  //inherited;
  DbGridEhToExcel(DbGridEh1);
end;




procedure TFrm_Mrp_Enter_CommonAssignAlterNative.getbyProduct(ItemCode: string;qty:real;MoLinedate,mostArtdate:string);
var tmpAdoQry:TAdoQuery;
    tmPMoLineno:integer;

begin
  tmpAdoQry:=TAdoQuery.Create(Application);
  tmpAdoQry.EnableBCD:=False;
  try
    tmPMoLineno:=AdoQry_Body.RecordCount;
    with tmpAdoQry do
    begin
      Close;
      Connection:=dbconnect;
      sql.clear;
      sql.Text:='select Bom.ItemCode,    '
              +'        Item.ItemName, '
              +'        Bom.Bomqty,   '
              +'        Uom.UomName  '
              +' from Bom '
              +' join Item on Bom.ItemCode=Item.ItemCode '
              +' left outer join Uom on Item.UomCode=Uom.UomCode '
              +' where ite_ItemCode='+quotedstr(ItemCode)
               +' and BomItemType=4';
      Prepared;
      open;
      if recordCount=0 then exit;
      First;
        while not eof do
        begin
          AdoQry_Body.Append;
          AdoQry_Body.fieldbyname('MoLineNo').AsInteger:=AdoQry_Body.RecordCount+1;
          AdoQry_Body.fieldbyname('LimItOut').AsInteger:=99999999;
          AdoQry_Body.fieldbyname('ItemCode').AsString:=fieldbyname('ItemCode').AsString;
          AdoQry_Body.fieldbyname('ItemName').AsString:=fieldbyname('ItemName').AsString;
          AdoQry_Body.fieldbyname('UomName').AsString:=fieldbyname('UomName').AsString;
          AdoQry_Body.fieldbyname('SsQty').AsFloat:=qty*fieldbyname('Bomqty').asfloat;
          AdoQry_Body.fieldbyname('MoQty').AsFloat:=qty*fieldbyname('Bomqty').asfloat;
          AdoQry_Body.fieldbyname('MoNoFinishQty').AsFloat:=qty*fieldbyname('Bomqty').asfloat;
          AdoQry_Body.fieldbyname('MoLineStatus').AsInteger:=5;
          AdoQry_Body.fieldbyname('MoLineDate').Asstring:=MoLinedate;
          AdoQry_Body.fieldbyname('MoStArtWorkDate').Asstring:=mostArtdate;
          AdoQry_Body.fieldbyname('byProduct').Asinteger:=1;
          AdoQry_Body.fieldbyname('ParentMoLineno').Asinteger:=tmPMoLineno;
          AdoQry_Body.Post;
           next;
        end;
         AdoQry_Body.First;
    end;

  finally
    tmpAdoQry.Free;
  end;

end;

procedure TFrm_Mrp_Enter_CommonAssignAlterNative.deletebyProduct(MoLineno: integer);
var tmPmArk:string;
    tmplineno:integer;
    Count:integer;
begin
   tmPmArk:=AdoQry_Body.BookmArk;
   Count:=AdoQry_Body.RecordCount;
  tmplineno:=AdoQry_Body.fieldbyname('MoLineno').asinteger;
  with AdoQry_Body do
    begin
      First;
      while Count>0  do
        begin
          if AdoQry_Body.fieldbyname('ParentMoLineno').asinteger=tmplineno then
            AdoQry_Body.Delete;
          next;
          Count:=Count-1;
        end;
    end;
  AdoQry_Body.BookmArk:=tmPmArk;
end;

procedure TFrm_Mrp_Enter_CommonAssignAlterNative.Act_ModifyExecute(
  Sender: TObject);
var BookmArk:string;
begin
try
  BookmArk:=AdoQry_Body.BookmArk;
  inherited;
finally
 activecontrol:=dbgrideh;
 dbgrideh.SetFocus;
 AdoQry_Body.BookmArk:=BookmArk;
end;

end;



procedure TFrm_Mrp_Enter_CommonAssignAlterNative.sumItemss(ItemCode,
  releasedate: string; ssqty: real);
var tmpQry:TAdoQuery;
    sqltext:string;
begin
  if not existsItemss(ItemCode,releasedate) then exit;
  tmpQry:=TAdoQuery.Create(self);
  tmpQry.Connection:=dbconnect;
  sqltext:='update MrpResult'
          +'  set  onhand=onhand+'+floattostr(ssqty)+','
          +'       reMainqty=reMainqty+'+floattostr(ssqty)
          +' where ItemCode='+quotedstr(ItemCode)
          +'   and releasedate='+quotedstr(releasedate)
          +'   and ordinal=3 ';
  try
    Executesql(tmpQry,sqltext,1);
  finally
   tmpQry.Free;
  end;
end;

procedure TFrm_Mrp_Enter_CommonAssignAlterNative.insertss;
    function getgroupordinal(ItemCode:string):integer;
      begin
       Result:=0;
       try
       Executesql(AdoQry_tmp,'select groupordinal from MrpResult where ItemCode='+quotedstr(ItemCode),0);
       Result:=AdoQry_tmp.fieldbyname('groupordinal').asinteger;
       except
       Result:=0;
       end;
      end;
var sqltext:string;
begin
      SqlText:='insert into  MrpResult(groupordinal,ItemCode,ordinal,releasedate,PmCode,duedate,onhand,reMainqty,DeptVendorCode,pegging,canpegging) '
              +'Values('+inttostr(getgroupordinal(AdoQry_Body.fieldbyname('ItemCode').asstring))+','
                        +quotedstr(AdoQry_Body.fieldbyname('ItemCode').asstring)+','
                        +'3,'
                        +quotedstr(AdoQry_Body.fieldbyname('ssdate').asstring)+','
                        +inttostr(AdoQry_Body.fieldbyname('PmType').asinteger)+','
                        +quotedstr(AdoQry_Body.fieldbyname('duedate').asstring)+','
                        +floattostr(AdoQry_Body.fieldbyname('ssqty').asfloat)+','
                        +floattostr(AdoQry_Body.fieldbyname('ssqty').asfloat)+','
                        +quotedstr(AdoQry_Body.fieldbyname('DeptVendorCode').asstring)+','
                        +quotedstr('系统建议下达')+','
                        +'0'
                        +')';
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:=SqlText;
      try
      AdoQry_Tmp.ExecSQL;
      except
      end;

end;

function TFrm_Mrp_Enter_CommonAssignAlterNative.existsItemss(ItemCode,
  releasedate: string): boolean;
var AdoQry:TAdoQuery;
    sqltext:string;
begin
 Result:=False;
 AdoQry:=TAdoQuery.Create(nil);
 AdoQry.Connection:=AdoQry_Body.Connection;
 sqltext:='select * from MrpResult '
          +' where ItemCode='+quotedstr(ItemCode)
          +'   and releasedate='+quotedstr(releasedate)
          +'   and ordinal=3 ';
 try
  Executesql(AdoQry,sqltext,0);
  if AdoQry.RecordCount>0 then Result:=True;
 finally
  AdoQry.Free;
 end;

end;

procedure  TFrm_Mrp_Enter_CommonAssignAlterNative.setite_ItemInfo(ssid:integer);
var AdoQry:TAdoQuery;
    sqltext:string;
begin
   AdoQry:=TAdoQuery.Create(nil);
   AdoQry.Connection:=dbconnect;
   sqltext:='select MrpResult.*,'
           +'       MrpResult.ItemCode+'' ''+Item.ItemName as Itemflag,'
           +'       Uom.UomName'
           +'  from MrpResult  '
           +'  join Item on MrpResult.ItemCode=Item.ItemCode  '
           +' left outer join Uom on Item.UomCode=Uom.UomCode  '
           +' where MrpResult.MrpResultid='+inttostr(ssid);
   try
    Executesql(AdoQry,sqltext,0);
    ite_Ssid:=ssid;
    ite_ItemCode:=AdoQry.fieldbyname('ItemCode').asstring;
    ite_reMainqty:=AdoQry.fieldbyname('reMainqty').asfloat;
    lbl_Item.Caption:=AdoQry.fieldbyname('Itemflag').asstring;
    label2.Caption:=AdoQry.fieldbyname('UomName').asstring;
    label5.Caption:='建议下达';
    label8.Caption:=AdoQry.fieldbyname('releasedate').asstring;
    label12.Caption:=floattostr(AdoQry.fieldbyname('onhand').asfloat);
    label14.Caption:=floattostr(AdoQry.fieldbyname('reMainqty').asfloat);
   finally
    AdoQry.Free;
   end;

end;

end.

⌨️ 快捷键说明

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