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

📄 mrp_enter_assignalternative2.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
            +' set IsAssign=1  '
            +' where ToDate='+QuotedStr(Ite_ToDate)
            +'   and ItemCode='+QuotedStr(Ite_ItemCode)
            +'   and SSReleaseDate='+QuotedStr(Ite_SsReleaseDate);
    Executesql(AdoQry_tmp,sqltext,1);
    AdoQry_Body.EnableControls;
    AdoQry_Body1.EnableControls;
    DbConnect.CommitTrans;
    Act_Save.Enabled:=False;
    DispInfo('数据保存完毕!',3);
  Except
    If DbConnect.InTransaction Then
      DbConnect.RollBackTrans;
    DispInfo('保存数据失败,请重试!',1);
    Abort;
  end;
  Act_Save.Enabled:=False;
  AdoQry_Body.BookmArk:=bodymArk;
  self.Close;
end;

procedure TFrm_Mrp_Enter_AssignAlterNative2.FormCreate(Sender: TObject);
begin
  inherited;
  ExtendCaption:=False;
  Frm_Entry_Detail:=TFrm_Mrp_Enter_AssignAlterNative2_D.Create(Self);
end;

procedure TFrm_Mrp_Enter_AssignAlterNative2.SetStatus(CurrentStatus: String;
  var AnswerStatus, EnableControls: String);
begin
  inherited;
end;

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

end;

procedure TFrm_Mrp_Enter_AssignAlterNative2.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_AssignAlterNative2.Act_QuitExecute(Sender: TObject);
begin
  Close;
end;

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

procedure TFrm_Mrp_Enter_AssignAlterNative2.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_AssignAlterNative2.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_AssignAlterNative2.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_AssignAlterNative2.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 PurchaseApplyAssign '
          +'  set  SSQty=IsNull(SSQty,0)+'+floattostr(ssqty)+','
          +'       PlanQty=IsNull(PlanQty,0)+'+floattostr(ssqty)
          +' where ItemCode='+quotedstr(ItemCode)
          +'   and SSreleasedate='+quotedstr(releasedate)
          +'   and Convert(varchAr,Convert(DAtetime,ToDate),102)= '+QuotedStr(Ite_ToDate);
  try
    Executesql(tmpQry,sqltext,1);
  finally
    tmpQry.Free;
  end;
end;

procedure TFrm_Mrp_Enter_AssignAlterNative2.insertss(AdoQry:TAdoQuery);
var sqltext:string;
begin
  SqlText:='insert into  PurchaseApplyAssign  '
          +'      (ToDate,ItemCode,SSQty,PlanQty, '
          +'       SSReleaseDate,PlanDueDate,PlanReleaseDate, '
          +'       CreateEmployeeCode,CreateDate, '
          +'       EdItEmployeeCode,EditDate) '
          +'Values('+QuotedStr(Ite_ToDate)+','
                    +quotedstr(AdoQry.fieldbyname('ItemCode').asstring)+','
                    +floattostr(AdoQry.fieldbyname('ssqty').asfloat)+','
                    +floattostr(AdoQry.fieldbyname('ssqty').asfloat)+','
                    +quotedstr(AdoQry.fieldbyname('ssdate').asstring)+','
                    +quotedstr(AdoQry.fieldbyname('duedate').asstring)+','
                    +quotedstr(AdoQry.fieldbyname('ssdate').asstring)+','
                    +QuotedStr(UserCode)+','
                    +'GetDate(),'
                    +quotedstr(UserCode)+','
                    +'GetDate()'
                    +')';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:=SqlText;
  try
    AdoQry_Tmp.ExecSQL;
  except
  end;
end;

procedure TFrm_Mrp_Enter_AssignAlterNative2.insertss1;
    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,sScheck,canpegging) '
          +'Values('+inttostr(getgroupordinal(AdoQry_Body1.fieldbyname('ItemCode').asstring))+','
                    +quotedstr(AdoQry_Body1.fieldbyname('ItemCode').asstring)+','
                    +'3,'
                    +quotedstr(AdoQry_Body1.fieldbyname('ssdate').asstring)+','
                    +inttostr(AdoQry_Body1.fieldbyname('PmType').asinteger)+','
                    +quotedstr(AdoQry_Body1.fieldbyname('duedate').asstring)+','
                    +floattostr(AdoQry_Body1.fieldbyname('ssqty').asfloat)+','
                    +floattostr(AdoQry_Body1.fieldbyname('ssqty').asfloat)+','
                    +quotedstr(AdoQry_Body1.fieldbyname('DeptVendorCode').asstring)+','
                    +quotedstr('系统建议下达')+','
                    +'0,0'
                    +')';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:=SqlText;
  try
  AdoQry_Tmp.ExecSQL;
  except
  end;
end;

function TFrm_Mrp_Enter_AssignAlterNative2.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 PurchaseApplyAssign '
           +' where ItemCode='+quotedstr(ItemCode)
           +'   and SsReleaseDate='+quotedstr(releasedate)
           +'   and Convert(varchAr,Convert(Datetime,Todate),102)= '+QuotedStr(Ite_ToDate);
  try
    Executesql(AdoQry,sqltext,0);
    if AdoQry.RecordCount>0 then Result:=True;
  finally
    AdoQry.Free;
  end;
end;

procedure TFrm_Mrp_Enter_AssignAlterNative2.AdoQry_BodyAfterScroll(
  DataSet: TDataSet);
var sqltext:string;
    i,j:integer;
begin
  inherited;
  SqlText:=' Select Top 0 #tmpalterssInfo.*,Bom.Bomqty,Bom.BomItemType,Bom.BomScrAp_Percent,'
          +'Bom.ite_ItemCode,Item.CurrentonhandInv,Item.ItemName,Uom.UomName '
          +' From #tmpalterssInfo '
          +' Join Item On #tmpalterssInfo.ItemCode=Item.ItemCode '
          +' join Bom on #tmpalterssInfo.ItemCode=Bom.ite_ItemCode '
          +' Left Join Uom On Item.UomCode=Uom.UomCode';
  Executesql(AdoQry_Body1,sqltext,0);
  SqlText:=' Select Bom.*,Item.PmCode,Item.ItemName,Uom.UomName,Item.CurrentonhandInv,ldtime=Preparelt+runlt+Qclt '
          +' From Bom  '
          +'  join Item on Bom.ItemCode=Item.ItemCode '
          +'  left outer join Uom on Item.UomCode=Uom.UomCode '
          +' Where ite_ItemCode='+quotedstr(AdoQry_Body.fieldbyname('ItemCode').asstring);
  Executesql(AdoQry_Temp,sqltext,0);
  while not AdoQry_Temp.Eof do
    begin
      J:=AdoQry_Temp.fieldbyname('ldtime').AsInteger;
      AdoQry_Body1.Append;
      AdoQry_Body1.fieldbyname('ItemCode').AsString:=AdoQry_Temp.fieldbyname('ItemCode').AsString;
      AdoQry_Body1.fieldbyname('ItemName').AsString:=AdoQry_Temp.fieldbyname('ItemName').AsString;
      AdoQry_Body1.fieldbyname('UomName').AsString:=AdoQry_Temp.fieldbyname('UomName').AsString;
      AdoQry_Body1.fieldbyname('ssSysInfoflag').asinteger:=j;
      AdoQry_Body1.fieldbyname('Bomqty').AsFloat:=AdoQry_Temp.fieldbyname('Bomqty').asfloat;
      AdoQry_Body1.fieldbyname('ite_ItemCode').AsString:=floattostr(AdoQry_Temp.fieldbyname('BomScrAp_Percent').Asfloat/100)+'%';
      AdoQry_Body1.fieldbyname('BomScrAp_Percent').asfloat:=AdoQry_Temp.fieldbyname('BomScrAp_Percent').asfloat;
      AdoQry_Body1.fieldbyname('CurrentonhandInv').AsFloat:=AdoQry_Temp.fieldbyname('CurrentonhandInv').asfloat;
      AdoQry_Body1.fieldbyname('ssDate').Asstring:=AdoQry_Body.fieldbyname('duedate').asstring;
      AdoQry_Body1.fieldbyname('duedate').Asstring:=slCalendar(dbconnect,AdoQry_Body.fieldbyname('duedate').asstring,J);
      AdoQry_Body1.fieldbyname('ssqty').AsFloat:=AdoQry_Body.fieldbyname('ssqty').asfloat*AdoQry_Body1.fieldbyname('Bomqty').asfloat*(1+AdoQry_Body1.fieldbyname('BomScrAp_Percent').asfloat/100.00);
      AdoQry_Body1.Post;
     // getbyProduct(AdoQry_Body.fieldbyname('ItemCode').AsString,AdoQry_Body.fieldbyname('MoQty').AsFloat,AdoQry_Body.fieldbyname('MoLineDate').Asstring,AdoQry_Body.fieldbyname('MoStArtWorkDate').Asstring);
      AdoQry_Temp.Next;
    end;
  DataSource1.DataSet:=AdoQry_Body1;
  dataSource1.DataSet.First;
end;

procedure TFrm_Mrp_Enter_AssignAlterNative2.AdoQry_BodyAfterPost(
  DataSet: TDataSet);
var sqltext:string;
begin
  inherited;
  with AdoQry_Body1 do
  begin
    First;
    while not eof do
    begin
      edit;
      fieldbyname('ssDate').Asstring:=AdoQry_Body.fieldbyname('duedate').asstring;
      fieldbyname('duedate').Asstring:=slCalendar(dbconnect,AdoQry_Body.fieldbyname('duedate').asstring,fieldbyname('ssSysInfoflag').asinteger);
      
      fieldbyname('ssqty').AsFloat:=AdoQry_Body.fieldbyname('ssqty').asfloat*fieldbyname('Bomqty').asfloat*(1+fieldbyname('BomScrAp_Percent').asfloat/100.00);
//      showmessage(fieldbyname('ssqty').asstring);
      Post;
      next;
    end;
  end;
//  abort;
end;

procedure TFrm_Mrp_Enter_AssignAlterNative2.btn_fmoClick(Sender: TObject);
begin
  inherited;
  if AdoQry_Body.RecordCount=0 then exit;
  Frm_Mrp_Enter_AssignAlterNative_Mo:=TFrm_Mrp_Enter_AssignAlterNative_Mo.Create(self);
  try
  with Frm_Mrp_Enter_AssignAlterNative_Mo do
    begin
      ItemCode:=AdoQry_Body.fieldbyname('ItemCode').asstring;
      AdoQry_Mo.Connection:=dbconnect;
      showdbgrid;
      showmodal;
    end;
  finally
    Frm_Mrp_Enter_AssignAlterNative_Mo.Free;
    activecontrol:=dbgrideh;
  end;                   
end;

end.

⌨️ 快捷键说明

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