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

📄 mrp_qry_analyzermo3_c.pas

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

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

Interface

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

Type
  TFrm_Mrp_Qry_AnalyzerMo3_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 FormDestroy(Sender: TObject);
    procedure btn_okClick(Sender: TObject);
    procedure FormShow(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_AnalyzerMo3_C: TFrm_Mrp_Qry_AnalyzerMo3_C;

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

procedure TFrm_Mrp_Qry_AnalyzerMo3_C.FormDestroy(Sender: TObject);
begin
  inherited;
  Frm_Mrp_Qry_AnalyzerMo3_C:=nil;
end;

procedure TFrm_Mrp_Qry_AnalyzerMo3_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+' 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+' 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_AnalyzerMo3.AdoQry_Main do
  begin
    Close;
    SQL.clear;
    StrSQlText:='Select Mo.MoNo,Mo.DeptCode,Dept.DeptName,MoLine.MoLineNo,'+
                ' 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,'+
                 ' MoLineStatus= case MoLineStatus when 0 then ''0 未批准''  when 1 then ''1 生效''  when 2 then ''2 关闭'' when 3 then ''3 永久关闭'' end'+
           ' Into #TmPMoLine'+
           ' From MoLine'+
                 ' Join Mo On MoLine.MoNo=Mo.MoNo'+
                 ' and   ((Mo.MoSpecial='+inttostr(Special)+') or ('+inttostr(Special)+'=''255''))'+
                 ' left outer Join Item On MoLine.ItemCode=Item.ItemCode'+
                 ' Left Outer Join Dept On Mo.DeptCode=Dept.DeptCode  where MoLine.moQty>0 '+StrCondition+' 1=1 '+
                 ' Order by Mo.DeptCode, MoLine.ItemCode' ;

    SQl.Add(StrSQlText);
    Prepared;
    ExecSQL;

    Close;
    SQL.clear;
    SQL.Add('Select DeptCode,Deptflag,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)*100/Sum(MoQty)))+''%'' end as FinishRate'+
           ' From #tmPMoLine Group By DeptCode,Deptflag,DeptName,ItemCode,ItemName,MoLineStatus  Order by DeptCode,ItemCode');
   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 ;

 if  Frm_Mrp_Qry_AnalyzerMo3.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_AnalyzerMo3_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_AnalyzerMo3_C.FormCreate(Sender: TObject);
begin
  inherited;
     cmbMoSpecial.ItemIndex:=0;

end;

procedure TFrm_Mrp_Qry_AnalyzerMo3_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 + -