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

📄 mrp_enter_ssalternativeinfo1.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Mrp_Enter_SsAlterNativeInfo1;
//
Interface

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

Type
  TFrm_Mrp_Enter_SsAlterNativeInfo1 = Class(TFrm_Base_Outer)
    AdoQry_MainSSId: TAutoIncField;
    AdoQry_MainItemCode: TStringField;
    AdoQry_MainSSDate: TDateTimeField;
    AdoQry_MainSSQty: TFloatField;
    AdoQry_MainDeptVendorCode: TStringField;
    AdoQry_Mainduedate: TDateTimeField;
    AdoQry_MainItemName: TStringField;
    AdoQry_MainDeptCode: TStringField;
    AdoQry_MainDeptName: TStringField;
    AdoQry_MainUomName: TStringField;
    AdoQry_MainDeptFlag: TStringField;
    AdoQry_MainItemFlag: TStringField;
    AdoQry_MaintMpssreMainqty: TFloatField;
    Label1: TLabel;
    lbl_RunMrpdate: TLabel;
    AdOCommand: TAdOCommand;
    AdoQry_MainPmCode: TIntegerField;
    AdoQry_MainSysqty: TFloatField;
    AdoQry_MainReMainQty: TFloatField;
    AdoQry_Mainssflag: TStringField;
    procedure FormDestroy(Sender: TObject);
    procedure AdoQry_MainBeforeInsert(DataSet: TDataSet);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Act_LookExecute(Sender: TObject);
  private
    checked:boolean;
    { Private declarations }
  public
    procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
    function getMrpdate:string;
   function getQclt(ItemCode:string):string;{ Public declarations }
{ Public declarations }
  end;

var
  Frm_Mrp_Enter_SsAlterNativeInfo1: TFrm_Mrp_Enter_SsAlterNativeInfo1;

implementation

uses Sys_Global, Mrp_Enter_AssignAlterNative1;


{$R *.DFM}
{ TFrm_Mrp_Qry_DynamicMrpInfo }

procedure TFrm_Mrp_Enter_SsAlterNativeInfo1.InitForm(
  AdOConnection: TAdOConnection; ReadOnly: Boolean);
var sqltext:string;
begin
  Application.ProcessMessages;
  inherited;                    
  If ReadOnly=True Then
  begin
    TlBtn_Copy.Visible:=False;
  end;
  lbl_RunMrpdate.Caption:=getMrpdate;
  Adocommand.Connection:=AdoQry_Main.Connection;
  sqltext:='select ItemCode,'
           +'      duedate,   '
           +'      DeptVendorCode,       '
           +'      PmType=PmCode,         '
           +'      ssid=MrpResultid,       '
           +'      ssqty=onhand,           '
           +'      ssdate=releasedate,     '
           +'      ssSysInfoflag=1,        '
           +'      Sysqty=onhand,'
           +'      reMainqty,  '
           +'      ssreMainqty=reMainqty  '
           +' into #tmpalterssInfo from MrpResult                         '
           +' where ordinal=3                   '
           +'  and  PmCode=9  and reMainqty>0 ';
  with Adocommand do
    begin
      commandtext:=sqltext;
      Execute;
    end;
  sqltext:='select #tmpalterssInfo.*,tMpssreMainqty=case #tmpalterssInfo.ssreMainqty when 0 then null else #tmpalterssInfo.ssreMainqty end,Item.mnldtime,Item.ItemName,Uom.UomName,Dept.DeptCode,Dept.DeptName,'
            +'  Employee.EmployeeCode,Employee.EmployeeName,'
                +' ssflag=convert(varchAr,#tmpalterssInfo.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 #tmpalterssInfoResult '
                +' From #tmpalterssInfo '
                +' Join Item On #tmpalterssInfo.ItemCode=Item.ItemCode '
                +' Left Join Dept On  isnull(#tmpalterssInfo.DeptVendorCode,Item.DeptCode)=Dept.DeptCode'
//                +' Left Join Dept On (Case When #tMpssInfo.SsSysInfoFlag<>1 Then #tMpssInfo.DeptVendorCode Else Item.DeptCode end)=Dept.DeptCode'
                +' Left Join Employee On Item.Pla_EmployeeCode=Employee.EmployeeCode'
                +' left outer Join Uom On Item.UomCode=Uom.UomCode'
                +' Join SysSsInfo On #tmpalterssInfo.SSSysInfoFlag=SysSsInfo.SSCode';
  with Adocommand do
    begin
      commandtext:=sqltext;
      Execute;
    end;

    // Executesql(AdoQry_Main,sqltext,1);
  Executesql(AdoQry_Main,'select * from #tmpalterssInfoResult Order by ItemCode',0);
  selectfromsql:='select * from #tmpalterssInfoResult';
  AdoQry_Tmp.Close;
  AdoQry_Tmp.SQL.Text:='Select MrpParamValueN from MrpParam '
                      +' where MrpParamCode='''+'SSForwArdDay'+'''';
  AdoQry_Tmp.Open;
  Lbl_Condition.Caption:='全部';
  AdoQry_Tmp.Close;
  Checked:=False;
  Application.ProcessMessages;
end;

procedure TFrm_Mrp_Enter_SsAlterNativeInfo1.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Mrp_Enter_SsAlterNativeInfo1:=nil;
end;

procedure TFrm_Mrp_Enter_SsAlterNativeInfo1.AdoQry_MainBeforeInsert(
  DataSet: TDataSet);
begin
  inherited;
  Abort;

end;

procedure TFrm_Mrp_Enter_SsAlterNativeInfo1.FormCreate(Sender: TObject);
begin
  inherited;
  ExtendCaption:=False;
  toolbutton6.Action:=act_auto;
end;

procedure TFrm_Mrp_Enter_SsAlterNativeInfo1.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Executesql(AdoQry_tmp,'drop table #tmpalterssInfo,#tmpalterssInfoResult',1);
end;

function TFrm_Mrp_Enter_SsAlterNativeInfo1.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=''RunMrpDate''       ';
       Prepared;
       try
       open;
       Result:=fieldbyname('MrpParamValuec').asstring;
       except
       Result:='';
       end;
     end;
  finally
    AdoQry.Free;
  end;
end;

function TFrm_Mrp_Enter_SsAlterNativeInfo1.getQclt(ItemCode: string): string;
begin
  try
   Executesql(AdoQry_tmp,'select Qclt from Item where ItemCode='+quotedstr(ItemCode),0);
   Result:=inttostr(AdoQry_tmp.fieldbyname('Qclt').asinteger);
  except
   Result:='9999999';
  end;
end;

procedure TFrm_Mrp_Enter_SsAlterNativeInfo1.Act_LookExecute(
  Sender: TObject);
var
  BookmArk:String;
begin
  inherited;
  If AdoQry_Main.RecordCount=0   Then
  begin
    Abort;
  end;
  If AdoQry_Main.fieldbyname('ReMainQty').AsFloat<=0 Then
  begin
    DispInfo('本条建议"系统建议余量"已分配完毕,不能再分配!',3);
    Abort;
  end;
  try
    BookmArk:=AdoQry_Main.BookmArk;
    begin
      Frm_Mrp_Enter_AssignAlterNative1:=TFrm_Mrp_Enter_AssignAlterNative1.Create(Application);
      Frm_Mrp_Enter_AssignAlterNative1.SetSysParam(UserCode,ModuleCode,MenuId,DateTimeToStr(Now));
      Frm_Mrp_Enter_AssignAlterNative1.lbl_Item.Caption:=AdoQry_Main.fieldbyname('Itemflag').asstring;
      Frm_Mrp_Enter_AssignAlterNative1.Label2.Caption:=AdoQry_Main.fieldbyname('UomName').asstring;
      Frm_Mrp_Enter_AssignAlterNative1.Label5.Caption:=AdoQry_Main.fieldbyname('ssflag').asstring;
      Frm_Mrp_Enter_AssignAlterNative1.Label8.Caption:=AdoQry_Main.fieldbyname('ssdate').asstring;
      Frm_Mrp_Enter_AssignAlterNative1.Label12.Caption:=AdoQry_Main.fieldbyname('Sysqty').asstring;
      Frm_Mrp_Enter_AssignAlterNative1.Label14.Caption:=AdoQry_Main.fieldbyname('tMpssreMainqty').asstring;
      Frm_Mrp_Enter_AssignAlterNative1.ite_Ssid:=AdoQry_Main.fieldbyname('ssid').asinteger;
      Frm_Mrp_Enter_AssignAlterNative1.ite_reMainqty:=AdoQry_Main.fieldbyname('tMpssreMainqty').asfloat;
      Frm_Mrp_Enter_AssignAlterNative1.GetalterItem(AdoQry_Main,AdoQry_Main.fieldbyname('ItemCode').asstring);
      Frm_Mrp_Enter_AssignAlterNative1.ShowModal;
      Frm_Mrp_Enter_AssignAlterNative1.Release;
    end;
  finally
    AdoQry_Main.BookmArk:=BookmArk;
  end;
end;

end.

⌨️ 快捷键说明

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