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

📄 mrp_enter_newinformalmrpinfo.pas

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

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
  StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls, jpeg;

Type
  TFrm_Mrp_Enter_NewInformalMrpInfo = Class(TFrm_Base_Qry)
    AdoQry_MainSSId: TAutoIncField;
    AdoQry_MainItemCode: TStringField;
    AdoQry_MaInOrderNo: TStringField;
    AdoQry_MaInOrderLineNo: TIntegerField;
    AdoQry_MainSSDate: TDateTimeField;
    AdoQry_MainSSQty: TFloatField;
    AdoQry_MainItemName: TStringField;
    AdoQry_MainUomCode: TStringField;
    AdoQry_MainUomName: TStringField;
    AdoQry_MainDeptName: TStringField;
    AdoQry_MainDeptFlag: TStringField;
    AdoQry_MainItemFlag: TStringField;
    AdoQry_MaInOrderLineStatus: TIntegerField;
    AdoQry_MainDeptVendorCode: TStringField;
    Label2: TLabel;
    DBText2: TDBText;
    Label3: TLabel;
    DBText3: TDBText;
    AdoQry_MainSSSysInfoFlag: TIntegerField;
    AdoQry_MainSsName: TStringField;
    Label1: TLabel;
    DBText1: TDBText;
    DBText4: TDBText;
    Label4: TLabel;
    AdoQry_MainEmployeeCode: TStringField;
    AdoQry_MainEmployeeName: TStringField;
    AdoQry_MainEmployeeFlag: TStringField;
    AdoQry_MainDueDate: TDateTimeField;
    AdoQry_Mainssflag: TStringField;
    Label5: TLabel;
    lbl_RunMrpdate: TLabel;
    AdoQry_MaintMpssreMainqty: TFloatField;
    AdoQry_MainSysqty: TFloatField;
    btn_Item: TButton;
    btn_ite_Item: TButton;
    btn_Order: TButton;
    AdoQry_MainPmCode: TIntegerField;
    Label6: TLabel;
    Label7: TLabel;
    AdoQry_Maincanuseonhand: TFloatField;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btn_ItemClick(Sender: TObject);
    procedure btn_ite_ItemClick(Sender: TObject);
    procedure btn_OrderClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure DataSourceDataChange(Sender: TObject; Field: TField);
    procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
      AFont: TFont; var Background: TColor; State: TGridDrawState);
  private
    function ismorethanzero(fieldName:string;tableName:string;conditionfield:string):boolean;
    { Private declarations }
  public
    procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
    function getMrpdate:string;
    { Public declarations }
  end;

var
  Frm_Mrp_Enter_NewInformalMrpInfo: TFrm_Mrp_Enter_NewInformalMrpInfo;
  ItemCode:string;

implementation
 uses Sys_Global, Mrp_Qry_UpRightMrp_D_Item, Mrp_Qry_InformalTotalMrp_Item,
  Mrp_Qry_InformalTotalMrp_Po, Mrp_Qry_InformalTotalMrp_Mo;
{$R *.DFM}
procedure TFrm_Mrp_Enter_NewInformalMrpInfo.InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);
var sqltext:string;
begin
  Application.ProcessMessages;
  createpanel(1,dbgrideh);
  Inherited;
  lbl_RunMrpdate.Caption:=getMrpdate;
    {sqltext:='select *,Sysqty=ssqty,ssreMainqty=reMainqty  into #tmpInformalssInfo from Informalss                         '
           +' where ssSysInfoflag=1                    '
           +'  and  PmType=0   '
           +' union                                    '
           +' select *,Sysqty=ssqty,ssreMainqty=0 from Informalss                         '
           +' where ssSysInfoflag=3                    '
           +'   and Orderlinestatus<>7                 '
           +'   and exists(select mono from MoLine where Orderno=MoLine.mono) '
           +' union                                    '
           +' select Informalss.*,Sysqty=Informalss.ssqty,ssreMainqty=0 from Informalss                         '
           +' where ssSysInfoflag=4                    '
          // +'   and Orderlinestatus<>7                 '
           +'   and exists(select mono from MoLine where Orderno=MoLine.mono and Orderlineno=MoLine.MoLineno and MoLine.MoLinestatus<>7) '
           +' union                                    '
           +' select Informalss.*,    '
           +'       ssqty=case  when Informalss.reMainqty<MoLine.moqty then MoLine.moqty-Informalss.reMainqty '
           +'             else Informalss.ssqty  '
           + '             end,          '
           +'        ssreMainqty=0       '
           +'   from Informalss,MoLine           '
           +'  where ssSysInfoflag=2     '
            +'  and Orderlinestatus<>7   '
            +'  and exists(select mono from MoLine where Orderno=MoLine.mono) '
            +'  and Informalss.Orderno=MoLine.mono          '
            +'  and Informalss.Orderlineno=MoLine.MoLineno  '; }
  sqltext:='select InformalMrpResult.*,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=1,MoLine.moqty,ssqty=InformalMrpResult.onhand,Sysqty=InformalMrpResult.onhand,ssreMainqty=reMainqty '
           +'  into #tmpInformalssInfo from InformalMrpResult                '
           +' left outer join MoLine on InformalMrpResult.Orderno=MoLine.mono '
           +'    and InformalMrpResult.Orderlineno=MoLine.MoLineno  '
           +' where (ordinal=3 )                    '
           +'  and  PmCode=0   '
           +' union                                    '
           +' select InformalMrpResult.*,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=3,MoLine.moqty,ssqty=InformalMrpResult.Orderqty,Sysqty=InformalMrpResult.Orderqty,ssreMainqty=0 from InformalMrpResult                         '
           +'  join MoLine on InformalMrpResult.Orderno=MoLine.mono '
           +'    and InformalMrpResult.Orderlineno=MoLine.MoLineno  '
           +' where ordinal=2                    '
           +'   and Orderlinestatus=6                 '
           +'   and realOrderqty<=0           '
           +'   and exists(select mono from MoLine where Orderno=MoLine.mono and Orderlineno=MoLine.MoLineno and MoLine.MoLinestatus<>7) '
           +' union                                    '
           +' select InformalMrpResult.*,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=4,MoLine.moqty,ssqty=InformalMrpResult.Orderqty,Sysqty=InformalMrpResult.Orderqty,ssreMainqty=0 from InformalMrpResult                         '
           +'  join MoLine on InformalMrpResult.Orderno=MoLine.mono '
           +'    and InformalMrpResult.Orderlineno=MoLine.MoLineno  '
           +' where ordinal=2                    '
           +'   and Orderlinestatus=5 '
           +'   and onhand>0  '
           +'   and (releasedate<dateName(yy,getdate())+''.''+dateName(mm,getdate())+''.''+dateName(dd,getdate()) or duedate<dateName(yy,getdate())+''.''+dateName(mm,getdate())+''.''+dateName(dd,getdate()))  '
          // +'   and Orderlinestatus<>7                 '
           +'   and exists(select mono from MoLine where Orderno=MoLine.mono and Orderlineno=MoLine.MoLineno and MoLine.MoLinestatus<>7) '
           +' union                                    '
           +' select InformalMrpResult.*,ssid=MrpResultid,ssdate=releasedate,ssSysInfoflag=6,MoLine.moqty,ssqty=InformalMrpResult.onhand,Sysqty=InformalMrpResult.onhand,ssreMainqty=0 from InformalMrpResult                         '
           +'  join MoLine on InformalMrpResult.Orderno=MoLine.mono '
           +'    and InformalMrpResult.Orderlineno=MoLine.MoLineno  '
           +' where ordinal=2                    '
           +'   and Orderlinestatus<>7 '
           +'   and canuseonhand=1  '
          // +'   and Orderlinestatus<>7                 '
           +'   and exists(select mono from MoLine where Orderno=MoLine.mono and Orderlineno=MoLine.MoLineno and MoLine.MoLinestatus<>7) '
           +' union                                    '
           +' select InformalMrpResult.*,    '
           +'        ssid=MrpResultid,'
           +'        ssdate=releasedate, '
           +'        ssSysInfoflag=2, '
           +'        MoLine.moqty,   '
          // +'       Sysqty=case  when ss.reMainqty<MoLine.moqty then MoLine.moqty-ss.reMainqty '
          // +'             else 0  '
          // +'             end,          '
          +'         ssqty=Orderqty-onhand, '
           +'        Sysqty=Orderqty-onhand,  '
           +'        ssreMainqty=0       '
           +'   from InformalMrpResult,MoLine           '
           +'  where (ordinal=2 )    '
            +'  and Orderlinestatus<>7   '
            +'  and Orderqty>onhand      '
            +'  and InformalMrpResult.ItemCode not  in (select ItemCode from InformalMrpResult with(index(ordinal)) where ordinal=4 )'
//            +'  and exists(select mono from MoLine where Orderno=MoLine.mono) '
            +'  and InformalMrpResult.Orderno=MoLine.mono          '
            +'  and InformalMrpResult.Orderlineno=MoLine.MoLineno  '
           +' union                                    '
           +' select InformalMrpResult.*,    '
           +'        ssid=MrpResultid,'
           +'        ssdate=releasedate, '
           +'        ssSysInfoflag=5, '
           +'        MoLine.moqty,   '
          // +'       Sysqty=case  when ss.reMainqty<MoLine.moqty then MoLine.moqty-ss.reMainqty '
          // +'             else 0  '
          // +'             end,          '
          +'         ssqty=Orderqty-onhand, '
           +'        Sysqty=Orderqty-onhand,  '
           +'        ssreMainqty=0       '
           +'   from InformalMrpResult,MoLine           '
           +'  where (ordinal=2 )    '
            +'  and Orderlinestatus<>7   '
            +'  and Orderqty>onhand    '
            +'  and InformalMrpResult.ItemCode in (select ItemCode from InformalMrpResult   with(index(ordinal)) where ordinal=4)'
//            +'  and exists(select mono from MoLine where Orderno=MoLine.mono) '
            +'  and InformalMrpResult.Orderno=MoLine.mono          '
            +'  and InformalMrpResult.Orderlineno=MoLine.MoLineno  ';

   Executesql(AdoQry_Main,sqltext,1);
    sqltext:='select #tmpInformalssInfo.*,tMpssreMainqty=case #tmpInformalssInfo.ssreMainqty when 0 then null else #tmpInformalssInfo.ssreMainqty end,Item.mnldtime,Item.ItemName,Uom.UomCode,Uom.UomName,Dept.DeptCode,Dept.DeptName,'
            +'  Employee.EmployeeCode,Employee.EmployeeName,'
                +' ssflag=convert(varchAr,#tmpInformalssInfo.ssSysInfoflag)+'' ''+SysssInfo.ssName,'
                +' Employee.EmployeeCode+'''+' '+'''+Employee.EmployeeName As EmployeeFlag,'
                +' Dept.DeptCode+'''+' '+'''+Dept.DeptName As DeptFlag, '
                +' Item.ItemCode+'''+' '+'''+Item.ItemName As ItemFlag,'
                //+'  Item.PmCode,'
                +' ConVert(varchAr,SysSsInfo.SSCode)+'''+' '+'''+SysSsInfo.SsName As SsName'
                +'  into #tmpInformalssInfoResult '
                +' From #tmpInformalssInfo '
                +' Join Item On #tmpInformalssInfo.ItemCode=Item.ItemCode '
                +' And #tmpInformalssInfo.PmCode=0 '
                +' Left Join Dept On  isnull(#tmpInformalssInfo.DeptVendorCode,Item.DeptCode)=Dept.DeptCode'
//                +' Left Join Dept On (Case When #tmpInformalssInfo.SsSysInfoFlag<>1 Then #tmpInformalssInfo.DeptVendorCode Else Item.DeptCode end)=Dept.DeptCode'
                +' Left Join Employee On Item.Pla_EmployeeCode=Employee.EmployeeCode'
                +' left Join Uom On Item.UomCode=Uom.UomCode'
                +' Join SysSsInfo On #tmpInformalssInfo.SSSysInfoFlag=SysSsInfo.SSCode'
                +' Order by #tmpInformalssInfo.ItemCode,#tmpInformalssInfo.ssdate ';
     Executesql(AdoQry_Main,sqltext,1);
     Executesql(AdoQry_Main,'select * from #tmpInformalssInfoResult',0);
     selectfromsql:='select * from #tmpInformalssInfoResult';
//------------------------------------------------------------------------
  {SelectFromSql:=' Select InformalSs.*,Item.ItemName,Item.UomCode,Uom.UomName,Dept.DeptCode,Dept.DeptName,'
                +' ConVert(varchAr(10),SysSsInfo.SSCode)+'''+' '+'''+SysSsInfo.SsName As Ssflag,'
                +' SysssInfo.ssName,'
                +' Informalss.DeptVendorCode+'''+' '+'''+DeptName As DeptFlag, '
                +' Item.ItemCode+'''+' '+'''+Item.ItemName As ItemFlag, '
                +' Employee.EmployeeCode,Employee.EmployeeName,'
                +' Employee.EmployeeCode+'''+' '+'''+Employee.EmployeeName As EmployeeFlag '
                +' From Informalss '
                +' Join Item On Item.ItemCode= Informalss.ItemCode '
                +' And InformalSs.PmType=0 '
                +' Join Uom On Item.UomCode=Uom.UomCode '
                +' Left Join Dept On (Case When Informalss.SsSysInfoFlag<>1 Then Informalss.DeptVendorCode Else Item.DeptCode end)=Dept.DeptCode '
                +' Left Join Employee On Item.Pla_EmployeeCode=Employee.EmployeeCode '
                +' Join SysSsInfo On InformalSs.SSSysInfoFlag=SysSsInfo.SSCode ';
 OrderByFields:='SSDate,EmployeeCode ';
 GetData;  }
   if ShowAnimate<>nil then ShowAnimate.Free;
  if ShowPanel<>nil then ShowPanel.Free;

 Application.ProcessMessages;
end;

procedure TFrm_Mrp_Enter_NewInformalMrpInfo.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Mrp_Enter_NewInformalMrpInfo:=Nil;
end;

function TFrm_Mrp_Enter_NewInformalMrpInfo.getMrpdate: string;
var AdoQry:TAdoQuery;
begin
 AdoQry:=TAdoQuery.Create(self);
 try
   with AdoQry do
     begin
       Close;
       Connection:=dbconnect;
       sql.clear;
       sql.Text:=' Select MrpParamValueC    '
                    +'  From MrpParam         '
                   +'   Where MrpParamCode=''InformalRunMrpDate''       ';
       Prepared;
       try
       open;
       Result:=fieldbyname('MrpParamValuec').asstring;
       except
       Result:='';
       end;
     end;
  finally
   AdoQry.Free;
  end;

⌨️ 快捷键说明

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