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

📄 pm_qry_newnormalsspoinfo.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 3 页
字号:
        Frm_Mrp_Qry_InformalTotalMrp_Item.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
        Frm_Mrp_Qry_InformalTotalMrp_Item.InitForm(dbconnect,True);
      end
      else  Frm_Mrp_Qry_InformalTotalMrp_Item.Show;
  finally
    activecontrol:=dbgrideh;
  end;
end;

procedure TFrm_Pm_Qry_NewNormalSsPoInfo.btn_OrderClick(Sender: TObject);
begin
  inherited;
  try
  ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
  if ((AdoQry_Main.fieldbyname('PmCode').asinteger=1) or (AdoQry_Main.fieldbyname('PmCode').asinteger=2)) then
   begin
//    if AdoQry_Main.fieldbyname('Orderpreqty').asfloat+AdoQry_Main.fieldbyname('Orderxdqty').asfloat=0 then
 //     exit;
    if Frm_Mrp_Qry_InformalTotalMrp_Po=nil then
          begin
           Frm_Mrp_Qry_InformalTotalMrp_Po:=TFrm_Mrp_Qry_InformalTotalMrp_Po.Create(Self);
           Frm_Mrp_Qry_InformalTotalMrp_Po.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
           Frm_Mrp_Qry_InformalTotalMrp_Po.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
           Frm_Mrp_Qry_InformalTotalMrp_Po.InitForm(AdoQry_Main.Connection,True);
          end
        else Frm_Mrp_Qry_InformalTotalMrp_Po.Show;
    exit;
   end;
  if AdoQry_Main.fieldbyname('PmCode').asinteger=0 then
  begin
//   if AdoQry_Main.fieldbyname('Orderpreqty').asfloat+AdoQry_Main.fieldbyname('Orderxdqty').asfloat=0 then
 //    exit;
   if Frm_Mrp_Qry_InformalTotalMrp_Mo=nil then
          begin
           Frm_Mrp_Qry_InformalTotalMrp_Mo:=TFrm_Mrp_Qry_InformalTotalMrp_Mo.Create(Self);
           Frm_Mrp_Qry_InformalTotalMrp_Mo.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
           Frm_Mrp_Qry_InformalTotalMrp_Mo.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
           Frm_Mrp_Qry_InformalTotalMrp_Mo.InitForm(AdoQry_Main.Connection,True);
          end
        else Frm_Mrp_Qry_InformalTotalMrp_Mo.Show;
   exit;
  end;
  if AdoQry_Main.fieldbyname('PmCode').asinteger=3 then
  begin
    if ismorethanzero('moqty','MoLine','ItemCode')=True then
    if Frm_Mrp_Qry_InformalTotalMrp_Mo=nil then
          begin
           Frm_Mrp_Qry_InformalTotalMrp_Mo:=TFrm_Mrp_Qry_InformalTotalMrp_Mo.Create(Self);
           Frm_Mrp_Qry_InformalTotalMrp_Mo.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
           Frm_Mrp_Qry_InformalTotalMrp_Mo.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
           Frm_Mrp_Qry_InformalTotalMrp_Mo.InitForm(AdoQry_Main.Connection,True);
          end
        else Frm_Mrp_Qry_InformalTotalMrp_Mo.Show;
   if ismorethanzero('poqty','poline','ItemCode')=True then
       if Frm_Mrp_Qry_InformalTotalMrp_Po=nil then
          begin
           Frm_Mrp_Qry_InformalTotalMrp_Po:=TFrm_Mrp_Qry_InformalTotalMrp_Po.Create(Self);
           Frm_Mrp_Qry_InformalTotalMrp_Po.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
           Frm_Mrp_Qry_InformalTotalMrp_Po.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
           Frm_Mrp_Qry_InformalTotalMrp_Po.InitForm(AdoQry_Main.Connection,True);
          end
        else Frm_Mrp_Qry_InformalTotalMrp_Po.Show;

 end;
 finally
 activecontrol:=dbgrideh;
 end;

end;

function TFrm_Pm_Qry_NewNormalSsPoInfo.ismorethanzero(fieldName, tableName,
  conditionfield: string): boolean;
var AdoQry:TAdoQuery;
begin
  Result:=False;
  AdoQry:=TAdoQuery.Create(Application);
  AdoQry.EnableBCD := False;
  try
    with AdoQry do
     begin
       Close;
       Connection:=dbconnect;
       sql.clear;
       sql.Add('select sum('+fieldName+') as SumQty from '+tableName+' where '+conditionfield+'='+quotedstr(AdoQry_Main.fieldbyname('ItemCode').asstring));
       open;
       if fieldbyname('SumQty').asfloat>0 then
         Result:=True
       else Result:=False;
     end;
  finally
   AdoQry.Free;
  end;
end;

procedure TFrm_Pm_Qry_NewNormalSsPoInfo.btn_uPMrpClick(Sender: TObject);
var AdoQry:TAdoQuery;
    sqltext:string;
begin
  inherited;
  AdoQry:=TAdoQuery.Create(self);
  AdoQry.Connection:=dbconnect;

  try
    sqltext:=' Select distinct Item.ItemCode,Item.ItemName,Item.minqty,MrpResult.PmCode,Item.Batchstrat,'+
                ' Itemflag=Item.ItemCode+'' ''+Item.ItemName,'+
               ' UomName=Uom.UomName,'+
               ' ldtime=case MrpResult.PmCode '+
               '     when 0 then Item.mnldtime '+
               '     else Item.purchldtime '+
               '   end,'+
               ' Item.Preparelt,'+
               ' Item.runlt,'+
               ' Item.Qclt,'+
               ' Item.PmBatch, '+
               ' Item.CurrentonhandInv as CurrentonhandInv, '+
               ' Assignedqty=isnull(0,0), '+
               ' Item.CurrentonCheckInv as oncheckqty '+
               //' Item.CurrentonhandInv '+
               //' into #tmpItemResult'+
               ' From Item '+
               ' Join MrpResult On Item.ItemCode=MrpResult.ItemCode and MrpResult.ordinal=1'+
               '      and MrpResult.ItemCode='+quotedstr(AdoQry_Main.fieldbyname('ItemCode').asstring)+
               //' Join #tmponhandm On Item.ItemCode=#tmponhandm.ItemCode and MrpResult.PmCode=#tmponhandm.PmCode '+
               ' left outer join Uom on Item.UomCode=Uom.UomCode ';
    Executesql(AdoQry,sqltext,0);
    if Frm_Mrp_Qry_NewUpRightMrp_D=nil then
   begin
    Frm_Mrp_Qry_NewUpRightMrp_D:=TFrm_Mrp_Qry_NewUpRightMrp_D.Create(Self);
    Frm_Mrp_Qry_NewUpRightMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
    Frm_Mrp_Qry_NewUpRightMrp_D.ItemCode:=AdoQry.fieldbyname('ItemCode').asstring;
    Frm_Mrp_Qry_NewUpRightMrp_D.ItemName:=AdoQry.fieldbyname('ItemName').asstring;
    Frm_Mrp_Qry_NewUpRightMrp_D.Uom:=AdoQry.fieldbyname('UomName').asstring;
    Frm_Mrp_Qry_NewUpRightMrp_D.ldtime:=floattostr(AdoQry.fieldbyname('ldtime').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.Preparelt:=floattostr(AdoQry.fieldbyname('Preparelt').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.runlt:=floattostr(AdoQry.fieldbyname('runlt').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.Qclt:=floattostr(AdoQry.fieldbyname('Qclt').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.PmBatch:=floattostr(AdoQry.fieldbyname('PmBatch').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.ItemPmCode:=AdoQry.fieldbyname('PmCode').asinteger;
    Frm_Mrp_Qry_NewUpRightMrp_D.CurrentInv:=floattostr(AdoQry.fieldbyname('CurrentonhandInv').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.RunMrp:=0;
    Frm_Mrp_Qry_NewUpRightMrp_D.Assignedqty:=floattostr(AdoQry.fieldbyname('Assignedqty').asfloat);
    Frm_Mrp_Qry_NewUpRightMrp_D.oncheckqty:=floattostr(AdoQry.fieldbyname('oncheckqty').asfloat);
   if AdoQry.fieldbyname('PmCode').asinteger=0 then
    Frm_Mrp_Qry_NewUpRightMrp_D.PmCode:='0 制造';
   if AdoQry.fieldbyname('PmCode').asinteger=1 then
    Frm_Mrp_Qry_NewUpRightMrp_D.PmCode:='1 采购';
   if AdoQry.fieldbyname('PmCode').asinteger=2     then
    Frm_Mrp_Qry_NewUpRightMrp_D.PmCode:='2 委外加工';
   if AdoQry.fieldbyname('PmCode').asinteger=3     then
    Frm_Mrp_Qry_NewUpRightMrp_D.PmCode:='3 既制造又委外';
   Frm_Mrp_Qry_NewUpRightMrp_D.minqty:=floattostr(AdoQry.fieldbyname('minqty').asfloat);
   if AdoQry.fieldbyname('Batchstrat').asinteger=0  then
    Frm_Mrp_Qry_NewUpRightMrp_D.Batchstrat:='直接批量法';
   if AdoQry.fieldbyname('Batchstrat').asinteger=1   then
    Frm_Mrp_Qry_NewUpRightMrp_D.Batchstrat:='固定批量法';
    try
     AdoQry.Free;
    except
    end;
    Frm_Mrp_Qry_NewUpRightMrp_D.InitForm(AdoQry_Main.Connection,True);
   end
   else Frm_Mrp_Qry_NewUpRightMrp_D.Show;
  finally
    activecontrol:=dbgrideh;
  end;
end;


procedure TFrm_Pm_Qry_NewNormalSsPoInfo.btn_OblongMrpClick(Sender: TObject);
begin
if AdoQry_Main.fieldbyname('ssSysInfoflag').asinteger=2 then
     begin
     activecontrol:=dbgrideh;
     exit;
     end;
try
if Frm_Mrp_Qry_NewOblongMrp_D=nil then
 begin
  Frm_Mrp_Qry_NewOblongMrp_D:=TFrm_Mrp_Qry_NewOblongMrp_D.Create(Self);
  Frm_Mrp_Qry_NewOblongMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
  Frm_Mrp_Qry_NewOblongMrp_D.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
  Frm_Mrp_Qry_NewOblongMrp_D.mRunMrp:=0;
  Frm_Mrp_Qry_NewOblongMrp_D.InitForm(dbconnect,True);
 end
 else Frm_Mrp_Qry_NewOblongMrp_D.Show;
finally
 activecontrol:=dbgrideh;
end;
end;

procedure TFrm_Pm_Qry_NewNormalSsPoInfo.GetData;
begin
//  inherited;
  if SelectFromSQL<>'' then
  begin
    AdoQry_Main.DisableControls;
    AdoQry_Main.Close;
    AdoQry_Main.SQL.clear;
    AdoQry_Main.SQL.Text:=SelectFromSQL;
    if(Condition<>'')then
    begin
      if(ConditionUserDefine<>'')then
        AdoQry_Main.SQL.Text:=AdoQry_Main.SQL.Text+' Where '+Condition+' and '+ConditionUserDefine
      else
        AdoQry_Main.SQL.Text:=AdoQry_Main.SQL.Text+' Where '+Condition;
    end
    else if(ConditionUserDefine<>'')then
      AdoQry_Main.SQL.Text:=AdoQry_Main.SQL.Text+' Where '+ConditionUserDefine;
    AdoQry_Main.Open;
    AdoQry_Main.Sort:=OrderByFields;
    AdoQry_Main.EnableControls;
  end;
end;

procedure TFrm_Pm_Qry_NewNormalSsPoInfo.Button1Click(Sender: TObject);
begin
  inherited;
{  try
    If (AdoQry_Main.RecordCount>0) And (AdoQry_Main.fieldbyname('SsSysInfoFlag').AsInteger=1) Then
    if  Frm_Mrp_Enter_MoSsParent=nil then
      begin
        Frm_Mrp_Enter_MoSsParent:=TFrm_Mrp_Enter_MoSsParent.Create(Self);
        Frm_Mrp_Enter_MoSsParent.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
        Frm_Mrp_Enter_MoSsParent.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
        tmplowPmCode:=AdoQry_Main.fieldbyname('PmCode').asinteger;
        Frm_Mrp_Enter_MoSsParent.Qclt:=getQclt(AdoQry_Main.fieldbyname('ItemCode').asstring);
        Frm_Mrp_Enter_MoSsParent.duedate:=datetimetostr(AdoQry_Main.fieldbyname('ssdate').asdatetime);
        Frm_Mrp_Enter_MoSsParent.strpath:=AdoQry_Main.fieldbyname('ItemCode').asstring+',';
        Frm_Mrp_Enter_MoSsParent.InitForm(dbconnect,True);
      end
      else  Frm_Mrp_Enter_MoSsParent.Show;
  finally
    activecontrol:=dbgrideh;
  end;}
   try
    If (AdoQry_Main.RecordCount>0) And (AdoQry_Main.fieldbyname('SsSysInfoFlag').AsInteger=1) Then
      if  Frm_Mrp_Enter_NewMoSsParent=nil then
        begin
          Frm_Mrp_Enter_NewMoSsParent:=TFrm_Mrp_Enter_NewMoSsParent.Create(Self);
          Frm_Mrp_Enter_NewMoSsParent.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
          Frm_Mrp_Enter_NewMoSsParent.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
          tmplowPmCode:=AdoQry_Main.fieldbyname('PmCode').asinteger;
          Frm_Mrp_Enter_NewMoSsParent.Qclt:=getQclt(AdoQry_Main.fieldbyname('ItemCode').asstring);
          Frm_Mrp_Enter_NewMoSsParent.duedate:=datetimetostr(AdoQry_Main.fieldbyname('realreleasedate').asdatetime);
          Frm_Mrp_Enter_NewMoSsParent.strpath:=AdoQry_Main.fieldbyname('ItemCode').asstring+',';
          Frm_Mrp_Enter_NewMoSsParent.InitForm(dbconnect,True);
        end
        else  Frm_Mrp_Enter_NewMoSsParent.Show;
  finally
    activecontrol:=dbgrideh;
  end;
end;

procedure TFrm_Pm_Qry_NewNormalSsPoInfo.DataSourceDataChange(Sender: TObject;
  Field: TField);
begin
  inherited;
  if AdoQry_Main.Active = True then
  begin
    case AdoQry_Main.fieldbyname('SsSysInfoFlag').Asinteger of
      1 :Label7.Caption :='' ;
      2 :Label7.Caption :='应取消的原因:父项需求发生改变,当前数量的订单没有父项需求' ;
      3 :Label7.Caption :='应关闭的原因:订单生产/(采购/委外加工)完毕' ;
      4 :if  AdoQry_Main.fieldbyname('CanUseOnHand').AsFloat=1 then
            Label7.Caption:= '应重排的原因:订单的约定交货日大于物料毛需求的需求日期'
         else
            Label7.Caption :='应重排的原因:订单的约定交货日小于Mrp展开运算的日期' ;
      5 :Label7.Caption :='应调整的原因:物料的供应量大于需求量';
    end;
  end;
end;

procedure TFrm_Pm_Qry_NewNormalSsPoInfo.Button3Click(Sender: TObject);
begin
  inherited;
  Frm_Bas_Qry_MultiBomSViewMaster:=TFrm_Bas_Qry_MultiBomSViewMaster.Create(self);
  Frm_Bas_Qry_MultiBomSViewMaster.InitForm(AdoQry_Tmp.Connection);
  Frm_Bas_Qry_MultiBomSViewMaster.ExpandBom(AdoQry_Main.fieldbyname('ItemCode').asstring);
end;

procedure TFrm_Pm_Qry_NewNormalSsPoInfo.DBGridEhGetCellParams(
  Sender: TObject; Column: TColumnEh; AFont: TFont; var Background: TColor;
  State: TGridDrawState);
begin
  inherited;
  if (AdoQry_Main.fieldbyname('SSSysInfoFlag').AsInteger=2) or(AdoQry_Main.fieldbyname('SSSysInfoFlag').AsInteger=4) then
    AFont.Color:= clred;
end;

end.

⌨️ 快捷键说明

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