📄 mrp_enter_delmps.pas
字号:
unit Mrp_Enter_DelMps;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Outer, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, jpeg;
Type
TFrm_Mrp_Enter_DelMps = Class(TFrm_Base_Outer)
AdoQry_MainMpsId: TBCDField;
AdoQry_MainMpsMonth: TStringField;
AdoQry_MainItemCode: TStringField;
AdoQry_MainMpsDATE: TDateTimeField;
AdoQry_MainMpsQTY: TFloatField;
AdoQry_MainMpsStatus: TIntegerField;
AdoQry_MainMpsFinishQty: TFloatField;
AdoQry_MainMpsOutQty: TFloatField;
AdoQry_MainMpsRemArk: TStringField;
AdoQry_MainMpScheck: TIntegerField;
AdoQry_MainItemName: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_MainMpsBatchNo: TStringField;
procedure FormDestroy(Sender: TObject);
procedure Act_DeleteExecute(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
{ Public declarations }
end;
var
Frm_Mrp_Enter_DelMps: TFrm_Mrp_Enter_DelMps;
implementation
uses Sys_Global,Mrp_Enter_DelMps_C;
{$R *.DFM}
{ TFrm_Base_Outer1 }
procedure TFrm_Mrp_Enter_DelMps.InitForm(AdOConnection: TAdOConnection;
ShowExtendColumn: Boolean);
var ItemCodes,ItemCodee:string;
date1,date2:string;
begin
inherited;
with TFrm_Mrp_Enter_DelMps_C.Create(self) do
begin
SetDBConnect(dbconnect);
showmodal;
if modalResult=mrok then
try
ItemCodes:=edt_StArt_ItemCode.text;
ItemCodee:=edt_End_ItemCode.text;
date1:=medt_StArt_Mpsdate.Text;
date2:=medt_End_Mpsdate.Text;
finally
Frm_Mrp_Enter_DelMps_C.Free;
end;
if modalResult<>mrok then
Frm_Mrp_Enter_DelMps_C.Free;
end;
SelectFromSql:=' Select Mps.*,Item.ItemName,Item.ItemCode+'''+' '+'''+Item.ItemName As ItemFlag,Uom.UomName,MpsNoFinishQty=MpsQty-MpsFinishQty '
+' From Mps '
+' Join Item On Mps.ItemCode=Item.ItemCode'
+' Join Uom On Item.UomCode=Uom.UomCode';
ConditionUserDefine:='(MpsStatus=4) and Mps.ItemCode between '+quotedstr(ItemCodes)+' and '+quotedstr(ItemCodee)+
' and Mps.Mpsdate between '+quotedstr(date1)+' and '+quotedstr(date2);
// +' And (Item.PmCode In (0,2,3))';
OrderByFields:='MpsMonth,ItemCode,MpsDate';
GetData;
lbl_Condition.Caption:='物料代码从'+ItemCodes+' 到 '+ItemCodee+'/ 需用日期从'+date1+' 到 '+date2;
end;
procedure TFrm_Mrp_Enter_DelMps.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Mrp_Enter_DelMps:=nil;
end;
procedure TFrm_Mrp_Enter_DelMps.Act_DeleteExecute(Sender: TObject);
var
SqlText:String;
begin
// Inherited;
if AdoQry_Main.RecordCount=0 then
exit;
if DispInfo('确定清除选定的主生产计划吗?',2)<>'y' then
exit;
DbConnect.beginTrans;
Try
AdoQry_Main.First;
While Not AdoQry_Main.Eof Do
begin
if AdoQry_Main.fieldbyname('MpScheck').asinteger<>0 then
begin
AdoQry_Main.Next;
continue;
end;
{ SqlText:='Insert MpsHistory '
+ ' (MpsMonth,ItemCode,Mpsdate,Mpsqty,Mpsstatus,'
+ ' MpsremArk,MpSchgEmployeeCode,MpSchgTime,MpsId,MpSchgType)'
+ ' Values('
+ ''''+AdoQry_Main.fieldbyname('MpsMonth').AsString+''','
+''''+AdoQry_Main.fieldbyname('ItemCode').AsString+''','
+''''+DateTimeToStr(AdoQry_Main.fieldbyname('MpsDate').AsDateTime)+''','
+''''+FormatFloat('##0.##',AdoQry_Main.fieldbyname('MpsQty').AsFloat)+''','
+''''+IntToStr(AdoQry_Main.fieldbyname('MpsStatus').AsInteger)+''','
+''''+AdoQry_Main.fieldbyname('MpsRemArk').AsString+''''+','
+''''+UserCode+''''+','
+'Getdate(),'
+''''+IntToStr(AdoQry_Main.fieldbyname('Mpsid').AsInteger)+''','''+'清除记录'+''')';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL; //保存历史记录
}
saveMpshistory(dbconnect,AdoQry_Main.fieldbyname('Mpsid').asinteger,userCode,7);
SqlText:='Delete Mps Where MpsId='+''''
+AdoQry_Main.fieldbyname('MpsId').AsString+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
AdoQry_Main.Delete;
AdoQry_Main.Next;
end;
DbConnect.CommitTrans;
// Edt_StArt_ItemCode.SetFocus;
Except
DbConnect.RollBackTrans;
DispInfo('由于数据受到约束,不能清除!',3);
// Edt_StArt_ItemCode.SetFocus;
Abort;
end;
end;
procedure TFrm_Mrp_Enter_DelMps.FormCreate(Sender: TObject);
begin
inherited;
extendCaption:=False;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -