mrp_qry_analyzermo2_c.pas
来自「一个MRPII系统源代码版本」· PAS 代码 · 共 192 行
PAS
192 行
unit Mrp_Qry_AnalyzerMo2_C;
//加入订单性质筛选功能
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Condition, Db, AdODB, StdCtrls, Mask;
Type
TFrm_Mrp_Qry_AnalyzerMo2_C = Class(TFrm_Base_Condition)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
edtDeptCodes: TEdit;
medts: TMaskEdit;
medte: TMaskEdit;
edtDeptCodee: TEdit;
edtItemCodes: TEdit;
edtItemCodee: TEdit;
edtFinishrates: TEdit;
edtFinishratee: TEdit;
edtmonos: TEdit;
edtmonoe: TEdit;
edtlinestatuss: TEdit;
edtlinestatuse: TEdit;
Label13: TLabel;
cmbMoSpecial: TComboBox;
procedure FormCreate(Sender: TObject);
procedure btn_okClick(Sender: TObject);
procedure edtItemCodesKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_Mrp_Qry_AnalyzerMo2_C: TFrm_Mrp_Qry_AnalyzerMo2_C;
implementation
uses Mrp_Qry_AnalyzerMo2,Sys_Global;
{$R *.DFM}
procedure TFrm_Mrp_Qry_AnalyzerMo2_C.FormCreate(Sender: TObject);
begin
inherited;
medts.Text:=formatdatetime('yyyy.mm.dd',now-30);
medte.Text:=formatdatetime('yyyy.mm.dd',now);
edtDeptCodes.Text:='0';
edtmonos.Text:='0';
edtItemCodes.Text:='0';
edtDeptCodee.Text:='ZZZZZ';
edtmonoe.Text:='ZZZZZ';
edtItemCodee.Text:='ZZZZZ';
edtFinishrates.Text:='0';
edtFinishratee.Text:='100';
edtlinestatuss.Text:='6';
edtlinestatuse.Text:='6';
cmbMoSpecial.ItemIndex:=0;
end;
procedure TFrm_Mrp_Qry_AnalyzerMo2_C.btn_okClick(Sender: TObject);
var sqltext1,sqltext2,sqltext3,linestatus1,linestatus2:string;
Special:integer;
begin
inherited;
case cmbMoSpecial.Itemindex of
0: Special:=255;
1: Special:=1;
2: Special:=0;
end;
sqltext1:='Select Mo.MoNo,Mo.DeptCode,MoLine.MoLineNo,MoLine.ItemCode,'+
' MoLine.MoQty,'+
' MoLine.MoQty-MoLine.MoNoFinishQty As FinishQty,'+
' MoLine.MoNoFinishQty '+
' Into #TmPMoLine1 '+
' From MoLine '+
' Join Mo On MoLine.MoNo=Mo.MoNo '+
' Where MoLine.MoQty>0 '+
' And MoLine.MoLinedate between '''+medts.Text+''''+' and '''+medte.Text+' 23:59:59'+''''+
' and ((Mo.MoSpecial='+inttostr(Special)+') or ('+inttostr(Special)+'=''255''))'+ ' and Mo.DeptCode between '''+edtDeptCodes.Text+''''+' and '''+edtDeptCodee.Text+''''+
' and MoLine.Mono between '''+edtmonos.Text+''''+' and '''+edtmonoe.Text+''''+
' and MoLine.ItemCode between '''+edtItemCodes.Text+''''+' and '''+edtItemCodee.Text+''''+
' and MoLine.MoLinestatus between '+edtlinestatuss.Text+' and '+edtlinestatuse.Text;
sqltext2:=' Select DeptCode,MoNo,ItemCode,Sum(MoQty) AS MoQty,'+
' Sum(FinishQty) As FinishQty,'+
' Sum(MoNoFinishQty) As MoNoFinishQty'+
' Into #TmPMoLine2 '+
' From #TmPMoLine1 '+
' Group By DeptCode,MoNo,ItemCode';
sqltext3:='Select #TmPMoLine2.*,Dept.DeptName,Item.ItemName,Itemflag=#tmPMoLine2.ItemCode+'' ''+Item.ItemName, '+
' Deptflag=#tmPMoLine2.DeptCode+'' ''+Dept.DeptName,'+
'case #tmPMoLine2.moqty when 0 then ''0%'' else Convert(varchAr,convert(decimal(14,0),( #TmPMoLine2.MoQty- #TmPMoLine2.MoNoFinishqty)*100/#TmPMoLine2.MoQty) )+''%'' end As FinishRate '+
' From #TmPMoLine2 '+
' left outer Join Item On #TmPMoLine2.ItemCode=Item.ItemCode '+
' left outer Join Dept On #TmPMoLine2.DeptCode=Dept.DeptCode '+
' Where #TmPMoLine2.MoQty>0 '+
' and case #tmPMoLine2.moqty when 0 then 0 else ( #TmPMoLine2.MoQty- #TmPMoLine2.MoNoFinishqty)*100/#TmPMoLine2.MoQty end between '+edtFinishrates.Text+' and '+edtFinishratee.Text+
' Order By #TmPMoLine2.DeptCode, #TmPMoLine2.MoNo';
try
with Frm_Mrp_Qry_AnalyzerMo2.AdoQry_Main do
begin
Close;
sql.clear;
sql.Add(sqltext1);
Prepared;
try
execsql;
except
end;
Close;
sql.clear;
sql.Add(sqltext2);
Prepared;
try
execsql;
except
end;
Close;
sql.clear;
sql.Add(sqltext3);
Prepared;
open;
if recordCount=0 then
begin
DispInfo('无符合条件的数据!',3);
medts.SetFocus;
abort;
end;
end;
finally
with Frm_Mrp_Qry_AnalyzerMo2.AdoQry_Tmp do
begin
Close;
sql.clear;
sql.Add('drop table #tmPMoLine1,#tmPMoLine2');
Prepared;
try
execsql;
except
end;
end;
end;
if edtlinestatuss.Text='5' then
linestatus1:='5 准备'
else if edtlinestatuss.Text='6' then
linestatus1:='6 下达'
else if edtlinestatuss.Text='7' then
linestatus1:='7 关闭';
if edtlinestatuse.Text='5' then
linestatus2:='5 准备'
else if edtlinestatuse.Text='6' then
linestatus2:='6 下达'
else if edtlinestatuse.Text='7' then
linestatus2:='7 关闭';
// end;
ConditionHint:='约定交货日从 '+medts.Text+' 到 '+medte.Text+' / 订单性质: '+cmbMoSpecial.Text+' / 受单部门代码从 '+EdtDeptCodes.Text+' 到 '+EdtDeptCodee.Text+' / 生产订单号从 '+Edtmonos.Text+' 到 '+Edtmonoe.Text+#13+'物料代码从 '+EdtItemCodes.Text+' 到 '+EdtItemCodee.Text+' / 行状态从 '+linestatus1+' 到 '+linestatus2+' / 完成率从 '+EdtFinishrates.Text+'%'+' 到 '+EdtFinishratee.Text+'%';
self.ModalResult:=mrOk;
end;
procedure TFrm_Mrp_Qry_AnalyzerMo2_C.edtItemCodesKeyDown(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 + =
减小字号Ctrl + -
显示快捷键?