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

📄 pm_qry_normalsspoinfo.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 4 页
字号:
        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_NormalSsPoInfo.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_NormalSsPoInfo.btn_uPMrpClick(Sender: TObject);
var AdoQry:TAdoQuery;
    sqltext:string;
begin
  inherited;
{    if AdoQry_Main.fieldbyname('ssSysInfoflag').asinteger<>1 then
     begin
     activecontrol:=dbgrideh;
     exit;
     end;}
  AdoQry:=TAdoQuery.Create(self);
  AdoQry.Connection:=dbconnect;
try
   sqltext:='select distinct ItemCode,PmCode, min(releasedate) as releasedate  '
            +'   into #tmPmm                        '
            +'   from MrpResult                    '
            +' where ordinal=3 '
            +'   and ItemCode='+quotedstr(AdoQry_Main.fieldbyname('ItemCode').asstring)
            +'   and PmCode<>9 '
            +' group by ItemCode,PmCode   '
            +' select t1.ItemCode,t1.PmCode,t1.onhand,t1.oncheck,t1.Assignedqty,t1.releasedate,t1.ordinal '
            +' into #tmponhandm    '
            +' from MrpResult t1, #tmPmm t2             '
            +' where t1.ItemCode=t2.ItemCode            '
            +'  and  t1.releasedate=t2.releasedate      '
            +'  and  t1.ordinal=3                       '
            +'  and  t1.PmCode=t2.PmCode';
  Executesql(AdoQry,sqltext,1);
  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, '+
             ' #tmponhandm.onhand-isnull(#tmponhandm.Assignedqty,0) as CurrentonhandInv, '+
             ' Assignedqty=isnull(#tmponhandm.Assignedqty,0), '+
             ' #tmponhandm.oncheck as oncheckqty '+
             //' Item.CurrentonhandInv '+
             //' into #tmpItemResult'+
             ' From Item '+
             ' Join MrpResult On Item.ItemCode=MrpResult.ItemCode and MrpResult.ordinal=1'+
             ' 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_UpRightMrp_D=nil then
 begin
  Frm_Mrp_Qry_UpRightMrp_D:=TFrm_Mrp_Qry_UpRightMrp_D.Create(Self);
  Frm_Mrp_Qry_UpRightMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
  Frm_Mrp_Qry_UpRightMrp_D.ItemCode:=AdoQry.fieldbyname('ItemCode').asstring;
  Frm_Mrp_Qry_UpRightMrp_D.ItemName:=AdoQry.fieldbyname('ItemName').asstring;
  Frm_Mrp_Qry_UpRightMrp_D.Uom:=AdoQry.fieldbyname('UomName').asstring;
  Frm_Mrp_Qry_UpRightMrp_D.ldtime:=floattostr(AdoQry.fieldbyname('ldtime').asfloat);
  Frm_Mrp_Qry_UpRightMrp_D.Preparelt:=floattostr(AdoQry.fieldbyname('Preparelt').asfloat);
  Frm_Mrp_Qry_UpRightMrp_D.runlt:=floattostr(AdoQry.fieldbyname('runlt').asfloat);
  Frm_Mrp_Qry_UpRightMrp_D.Qclt:=floattostr(AdoQry.fieldbyname('Qclt').asfloat);
  Frm_Mrp_Qry_UpRightMrp_D.PmBatch:=floattostr(AdoQry.fieldbyname('PmBatch').asfloat);
  Frm_Mrp_Qry_UpRightMrp_D.ItemPmCode:=AdoQry.fieldbyname('PmCode').asinteger;
  Frm_Mrp_Qry_UpRightMrp_D.CurrentInv:=floattostr(AdoQry.fieldbyname('CurrentonhandInv').asfloat);
  Frm_Mrp_Qry_UpRightMrp_D.RunMrp:=0;
  Frm_Mrp_Qry_UpRightMrp_D.Assignedqty:=floattostr(AdoQry.fieldbyname('Assignedqty').asfloat);
  Frm_Mrp_Qry_UpRightMrp_D.oncheckqty:=floattostr(AdoQry.fieldbyname('oncheckqty').asfloat);
 if AdoQry.fieldbyname('PmCode').asinteger=0 then
  Frm_Mrp_Qry_UpRightMrp_D.PmCode:='0 制造';
 if AdoQry.fieldbyname('PmCode').asinteger=1 then
  Frm_Mrp_Qry_UpRightMrp_D.PmCode:='1 采购';
 if AdoQry.fieldbyname('PmCode').asinteger=2     then
  Frm_Mrp_Qry_UpRightMrp_D.PmCode:='2 委外加工';
 if AdoQry.fieldbyname('PmCode').asinteger=3     then
  Frm_Mrp_Qry_UpRightMrp_D.PmCode:='3 既制造又委外';
 Frm_Mrp_Qry_UpRightMrp_D.minqty:=floattostr(AdoQry.fieldbyname('minqty').asfloat);
 if AdoQry.fieldbyname('Batchstrat').asinteger=0  then
  Frm_Mrp_Qry_UpRightMrp_D.Batchstrat:='直接批量法';
 if AdoQry.fieldbyname('Batchstrat').asinteger=1   then
  Frm_Mrp_Qry_UpRightMrp_D.Batchstrat:='固定批量法';
  try
   Executesql(AdoQry,'drop table #tmponhandm,#tmPmm',1);
   AdoQry.Free;
  except
  end;
  Frm_Mrp_Qry_UpRightMrp_D.InitForm(AdoQry_Main.Connection,True);
 end
 else Frm_Mrp_Qry_UpRightMrp_D.Show;
finally
  activecontrol:=dbgrideh;
end;

end;


procedure TFrm_Pm_Qry_NormalSsPoInfo.btn_OblongMrpClick(Sender: TObject);
begin
{    if AdoQry_Main.fieldbyname('ssSysInfoflag').asinteger<>1 then
     begin
     activecontrol:=dbgrideh;
     exit;
     end;}
 // inherited;
try
if Frm_Mrp_Qry_OblongMrp_D=nil then
 begin
  Frm_Mrp_Qry_OblongMrp_D:=TFrm_Mrp_Qry_OblongMrp_D.Create(Self);
  Frm_Mrp_Qry_OblongMrp_D.SetSysParam(userCode,ModuleCode,menuid,formatdatetime('yyyy.mm.dd',now));
  Frm_Mrp_Qry_OblongMrp_D.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
  Frm_Mrp_Qry_OblongMrp_D.mRunMrp:=0;
  Frm_Mrp_Qry_OblongMrp_D.InitForm(dbconnect,True);
 end
 else Frm_Mrp_Qry_OblongMrp_D.Show;
finally
 activecontrol:=dbgrideh;
end;
end;

procedure TFrm_Pm_Qry_NormalSsPoInfo.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_NormalSsPoInfo.Button1Click(Sender: TObject);
begin
  inherited;
 { try
    If (AdoQry_Main.RecordCount>0) And (AdoQry_Main.fieldbyname('SsSysInfoFlag').AsInteger=1) Then
    if  Frm_Pm_Enter_PoSsParent=nil then
    begin
      Frm_Pm_Enter_PoSsParent:=TFrm_Pm_Enter_PoSsParent.Create(Self);
      Frm_Pm_Enter_PoSsParent.SetSysParam(UserCode,ModuleCode,MenuId,LoginDate);
      Frm_Pm_Enter_PoSsParent.ItemCode:=AdoQry_Main.fieldbyname('ItemCode').asstring;
      tmplowPmCode:=AdoQry_Main.fieldbyname('PmCode').asinteger;
      Frm_Pm_Enter_PoSsParent.Qclt:=getQclt(AdoQry_Main.fieldbyname('ItemCode').asstring);
      Frm_Pm_Enter_PoSsParent.duedate:=datetimetostr(AdoQry_Main.fieldbyname('ssdate').asdatetime);
      Frm_Pm_Enter_PoSsParent.strpath:=AdoQry_Main.fieldbyname('ItemCode').asstring+',';
      Frm_Pm_Enter_PoSsParent.InitForm(dbconnect,True);
    end
    else  Frm_Pm_Enter_PoSsParent.Show;
  finally
    activecontrol:=dbgrideh;
  end;}
  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;
end;

procedure TFrm_Pm_Qry_NormalSsPoInfo.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 :Label7.Caption :='应重排的原因:订单的约定交货日小于Mrp展开运算的日期' ;
    end;
  end;
end;

procedure TFrm_Pm_Qry_NormalSsPoInfo.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_NormalSsPoInfo.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 + -