mrp_qry_analyzermo3_f.pas

来自「一个MRPII系统源代码版本」· PAS 代码 · 共 107 行

PAS
107
字号
unit Mrp_Qry_AnalyzerMo3_F;

Interface

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

Type
  TFrm_Mrp_Qry_AnalyzerMo3_F = 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;
    procedure btn_okClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frm_Mrp_Qry_AnalyzerMo3_F: TFrm_Mrp_Qry_AnalyzerMo3_F;

implementation
uses Mrp_Qry_AnalyzerMo3;
{$R *.DFM}



procedure TFrm_Mrp_Qry_AnalyzerMo3_F.btn_okClick(Sender: TObject);
var StrCondition:String;
    StrSQLText:String;
begin
{  inherited; }
  StrCondition:=' And ';
  If (Trim(Edit1.Text)<>'') and (Trim(Edit2.Text)<>'') Then
    StrCondition:=StrCondition+' Mo.DeptCode 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+' Mo.MoDate Between '+quotedstr(Maskedit1.text)+' and '+quotedstr(Maskedit2.Text)+' and ';

  with Frm_Mrp_Qry_AnalyzerMo3.AdoQry_Main do
  begin
    Close;
    SQL.clear;
    StrSQlText:='Select Mo.MoNo,Mo.DeptCode,Dept.DeptName,MoLine.MoLineNo,'+
                 ' MoLine.ItemCode,(Mo.MoDate+Item.MNLDTime) As FinishDate,'+
                 ' MoLine.MoQty,(MoLine.MoQty-MoLine.MoNoFinishQty) As FinishQty,'+
                 ' MoLine.MoNoFinishQty,Item.ItemName,MoLine.MoLineStatus'+
           ' Into #TmPMoLine'+
           ' From MoLine'+
                 ' Join Mo On MoLine.MoNo=Mo.MoNo'+
                 ' Join Item On MoLine.ItemCode=Item.ItemCode'+
                 ' Left Outer Join Dept On Mo.DeptCode=Dept.DeptCode  where 1=1 '+StrCondition+' 1=1 '+
                 ' Order by Mo.DeptCode, MoLine.ItemCode' ;

    SQl.Add(StrSQlText);
    Prepared;
    ExecSQL;

    Close;
    SQL.clear;
    SQL.Add('Select DeptName,ItemCode,ItemName, Sum(MoQty) As MoQty,'+
           ' Sum(FinishQty) As FinishQty, Sum(MoNoFinishQty) As MoNoFinishQty,'+
           ' Convert(varchAr, Sum(FinishQty)*100/Sum(MoQty))+''%'' as FinishArate'+
           ' From #tmPMoLine Group By DeptName,ItemCode,ItemName ');
   open();
  end;

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


end;


procedure TFrm_Mrp_Qry_AnalyzerMo3_F.FormShow(Sender: TObject);
begin
  inherited;
  maskedit1.Text:=formatdatetime('yyyy.mm.dd',date-15);
  maskedit2.Text:=formatdatetime('yyyy.mm.dd',date);
  edit1.Text:='0';
  edit2.Text:='zzzz';
  edit3.Text:='0';
  edit4.Text:='zzzz';
end;

end.

⌨️ 快捷键说明

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