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

📄 mrp_qry_analyzermo4_c.pas

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

//加入订单性质筛选功能

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Condition, Db, AdODB, StdCtrls, Mask;

Type
  TFrm_Mrp_Qry_AnalyzerMo4_C = Class(TFrm_Base_Condition)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    MaskEdit1: TMaskEdit;
    MaskEdit2: TMaskEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Label7: TLabel;
    Label8: TLabel;
    Label13: TLabel;
    cmbMoSpecial: TComboBox;
    procedure FormShow(Sender: TObject);
    procedure btn_okClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Edit3KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frm_Mrp_Qry_AnalyzerMo4_C: TFrm_Mrp_Qry_AnalyzerMo4_C;

implementation
uses Mrp_Qry_AnalyzerMo4,Sys_Global;
{$R *.DFM}

procedure TFrm_Mrp_Qry_AnalyzerMo4_C.FormShow(Sender: TObject);
begin
  inherited;
  maskedit1.Text:=formatdatetime('yyyy.mm.dd',date-15);
  maskedit2.Text:=formatdatetime('yyyy.mm.dd',date);
end;

procedure TFrm_Mrp_Qry_AnalyzerMo4_C.btn_okClick(Sender: TObject);
var StrCondition:String;
    StrSQLText:String;
         linestatus1,linestatus2:string;
     Special:integer;
begin
 inherited;
  case cmbMoSpecial.Itemindex of
    0: Special:=255;
    1: Special:=1;
    2: Special:=0;
  end;
    StrCondition:=' And ';
   If (Trim(Edit1.Text)<>'') and (Trim(Edit2.Text)<>'')Then
     StrCondition:=StrCondition+' Item.Pla_EmployeeCode Between '+Quotedstr(Edit1.Text)+' and '+Quotedstr(Edit2.Text)+' And ';
   If (Trim(Edit3.Text)<>'') and (Trim(Edit4.Text)<>'') Then
     StrCondition:=StrCondition+' MoLine.ItemCode Between '+Quotedstr(Edit3.text)+' and '+Quotedstr(Edit4.Text)+' And ';
   If (Maskedit1.Text<>'    .  .  ') and (Maskedit2.Text<>'    .  .  ')Then
     StrCondition:=StrCondition+' MoLine.MoLineDate Between '+quotedstr(Maskedit1.text)+' and '+quotedstr(Maskedit2.Text+' 23:59:59')+' And ';
   If (Trim(Edit5.Text)<>'') and (Trim(Edit6.Text)<>'') Then
     StrCondition:=StrCondition+' MoLine.MoLineStatus Between '+Edit5.text+' and '+Edit6.Text+' And ';

   with Frm_Mrp_Qry_AnalyzerMo4.AdoQry_Main do
   begin
     Close;
     SQL.clear;
     StrSQlText:='Select Mo.MoNo,mo.modate,Employee.EmployeeName, MoLine.MoLineNo,MoLine.MoLinedate,Dept.DeptName,'+
                ' Deptflag=mo.DeptCode+'' ''+Dept.DeptName,'+
                ' MoLine.ItemCode,(Mo.MoDate+Item.MNLDTime) As FinishDate,'+
                ' MoLine.MoQty,(MoLine.MoQty-MoLine.MoNoFinishQty)As FinishQty,'+
                ' MoLine.MoNoFinishQty,Item.ItemName,Item.Pla_EmployeeCode, '+
                ' MoLineStatus= case MoLineStatus when 5 then ''5 准备''  when 6 then ''6 下达''  when 7 then ''7 关闭'' end'+
            ' Into #TmPMoLine'+
            ' From MoLine'+
               ' Join Mo On MoLine.MoNo=Mo.MoNo'+
               ' and ((Mo.MoSpecial='+inttostr(Special)+') or ('+inttostr(Special)+'=''255''))'+              
               ' left outer join Dept on mo.DeptCode=Dept.DeptCode'+
               ' left outer Join Item On MoLine.ItemCode=Item.ItemCode'+
               ' left outer join Employee on Item.Pla_EmployeeCode =Employee.EmployeeCode where 1=1 '+StrCondition+ ' 1=1 ';
    SQl.Add(StrSQlText);
    Prepared;
    ExecSQL;
    
    Close;
    SQL.clear;
    SQL.Add('Select Pla_EmployeeCode,EmployeeName,Deptflag, Employeeflag=Pla_EmployeeCode+'' ''+EmployeeName,DeptName,ItemCode,ItemName,Itemflag=ItemCode+'' ''+ItemName,MoLineStatus,'+
                ' Sum(MoQty) As MoQty,'+
                ' Sum(FinishQty) As FinishQty,'+
                ' Sum(MoNoFinishQty) As MoNoFinishQty,'+
              'case sum(Moqty) when 0 then ''0%'' else convert(varchAr,Convert(decimal(14,0),Sum(FinishQty)/Sum(MoQty)*100))+''%'' end as Finishrate'+
              ' From #TmPMoLine'+
              ' Group By Pla_EmployeeCode,EmployeeName, Deptflag,DeptName,ItemCode,ItemName,MoLineStatus Order by Pla_EmployeeCode,ItemCode');
    open;
  end;

  with Frm_Mrp_Qry_AnalyzerMo4.AdoQry_Tmp do
  begin
    Connection:= Frm_Mrp_Qry_AnalyzerMo4.AdoQry_Main.Connection;
    Close;
    SQl.clear;
    SQL.Add('Drop table #tmPMoLine');
    Prepared;
    ExecSQL;
  end;

 if  Frm_Mrp_Qry_AnalyzerMo4.AdoQry_Main.RecordCount=0 then
 begin
   DispInfo('没有合符条件的数据!',3);
   edit1.setfocus;
   exit;
 end;
     if edit5.Text='5' then
      linestatus1:='5 准备'
   else if  edit5.Text='6'  then
      linestatus1:='6 下达'
      else if  edit5.Text='7'  then
       linestatus1:='7 关闭';
   if edit6.Text='5' then
      linestatus2:='5 准备'
   else if  edit6.Text='6'  then
      linestatus2:='6 下达'
      else if  edit6.Text='7'  then
       linestatus2:='7 关闭';

 conditionHint:='订单性质: '+cmbMoSpecial.Text+' / 受单对象从 '+edit1.Text+' 到 '+edit2.Text+' / 约定交货日从 '+maskedit1.Text+' 到 '+maskedit2.Text+#13+'物料代码从 '+edit3.Text+' 到 '+edit4.Text+' / 行状态从 '+linestatus1+' 到 '+linestatus2;

 self.ModalResult:=mrOk;
end;

procedure TFrm_Mrp_Qry_AnalyzerMo4_C.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Mrp_Qry_AnalyzerMo4_C:=nil;
end;

procedure TFrm_Mrp_Qry_AnalyzerMo4_C.FormCreate(Sender: TObject);
begin
  inherited;
     cmbMoSpecial.ItemIndex:=0;

end;

procedure TFrm_Mrp_Qry_AnalyzerMo4_C.Edit3KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
 If key=120 Then
  CommOnHint(Sender,AdoQry_Tmp,'ItemName','物料描述','ItemCode',
             '物料代码',' Item ',' PmCode In (0,3) and ItemUsable=1 ');
end;

end.

⌨️ 快捷键说明

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