📄 pm_enter_foreverclosepo1.pas
字号:
unit Pm_Enter_ForeverClosePo1;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Check, Menus, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin, DBCtrls, jpeg;
Type
TFrm_Pm_Enter_ForeverClosePo1 = Class(TFrm_Base_Check)
AdoQry_HeadPONO: TStringField;
AdoQry_HeadPOLINENo: TIntegerField;
AdoQry_HeadItemCode: TStringField;
AdoQry_HeadPOLineDATE: TDateTimeField;
AdoQry_HeadPOQTY: TFloatField;
AdoQry_HeadPONoFinishQty: TFloatField;
AdoQry_HeadPOREFERENCEDPRICE: TIntegerField;
AdoQry_HeadPOLINESTATUS: TIntegerField;
AdoQry_HeadPoNoTaxPrice: TFloatField;
AdoQry_HeadPONoTaxAmount: TBCDField;
AdoQry_HeadPoTaxPrice: TFloatField;
AdoQry_HeadPoTaxAmount: TBCDField;
AdoQry_HeadPOStArtWorkDate: TDateTimeField;
AdoQry_HeadVendorCode: TStringField;
AdoQry_HeadVendorName: TStringField;
AdoQry_HeadItemName: TStringField;
AdoQry_HeadPoDate: TDateTimeField;
AdoQry_HeadEmployeeCode: TStringField;
AdoQry_HeadEmployeeName: TStringField;
AdoQry_HeadUomName: TStringField;
AdoQry_HeadEmployeeFlag: TStringField;
AdoQry_HeadItemFlag: TStringField;
AdoQry_HeadVendorFlag: TStringField;
Label2: TLabel;
DBText2: TDBText;
Label1: TLabel;
DBText1: TDBText;
Label3: TLabel;
DBText3: TDBText;
procedure DBGridEhDblClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Act_CheckExecute(Sender: TObject);
private
Function SavePoLineHistory:Boolean;//保存历史记录
procedure CloseRecord; //关闭
{ Private declarations }
public
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
{ Public declarations }
end;
var
Frm_Pm_Enter_ForeverClosePo1: TFrm_Pm_Enter_ForeverClosePo1;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Pm_Enter_ForeverClosePo1.InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);
begin
Application.ProcessMessages;
Inherited;
SelectFromSql:=' Select Distinct PoLine.*,Po.*,Vendor.VendorName,Item.ItemName,Employee.EmployeeName,Uom.UomName,'
+' Employee.EmployeeCode+'''+' '+'''+Employee.EmployeeName As EmployeeFlag,'
+' Item.ItemCode+'''+' '+'''+Item.ItemName As ItemFlag, '
+' Vendor.VendorCode+'''+' '+'''+Vendor.VendorName As VendorFlag '
+' From PoLine '
+' Join Po On Po.PoNo=PoLine.PoNo '
+' Join Item On PoLine.ItemCode=Item.ItemCode '
+' Left Join Vendor On Po.VendorCode=Vendor.VendorCode '
+' Left Join Buyer On Po.EmployeeCode=Buyer.EmployeeCode '
+' Left Join Employee On Buyer.EmployeeCode=Employee.EmployeeCode'
+' Join Uom On Uom.UomCode=Item.UomCode ';
ConditionUserDefine:=' (PoLine.POLineStatus=7 Or PoLine.POLineStatus=8) And (PoLine.PoNo In (Select PoNo From Po Where PoSpecial=0 And PoType=1))';
Condition:=' PoLine.POLineStatus=7 ';
OrderByFields:='EmployeeCode,PoNo';
GetData;
Application.ProcessMessages;
end;
Function TFrm_Pm_Enter_ForeverClosePo1.SavePoLineHistory:Boolean;
var
SqlText:String;
begin
Try
SqlText:='Insert PoLineHistory '
+' (PoNo,PoLineNo,ItemCode,POLineDate,PoStArtWorkDate,POQty,POTaxPrice,POTaxAmount,PONoTaxPrice,'
+' PONoTaxAmount,PONoFinishQty,POReferencedPrice,POLineStatus,PolChgEmployeeCode,PolChgTime,PolChgType)'
+'Values('
+''''+AdoQry_Head.fieldbyname('PoNo').AsString+''''+','
+''''+IntToStr(AdoQry_Head.fieldbyname('PoLineNo').AsInteger)+''''+','
+''''+AdoQry_Head.fieldbyname('ItemCode').AsString+''''+','
+''''+DatetimeToStr(AdoQry_Head.fieldbyname('PoLineDate').AsDateTime)+''''+','
+''''+DatetimeToStr(AdoQry_Head.fieldbyname('PoStArtWorkDate').AsDateTime)+''''+','
+''''+FloatToStr(AdoQry_Head.fieldbyname('PoQty').AsFloat)+''''+','
+''''+FloatToStr(AdoQry_Head.fieldbyname('POTaxPrice').AsFloat)+''''+','
+''''+FloatToStr(AdoQry_Head.fieldbyname('POTaxAmount').AsFloat)+''''+','
+''''+FloatToStr(AdoQry_Head.fieldbyname('PONoTaxPrice').AsFloat)+''''+','
+''''+FloatToStr(AdoQry_Head.fieldbyname('PONoTaxAmount').AsFloat)+''''+','
+''''+FloatToStr(AdoQry_Head.fieldbyname('PONoFinishQty').AsFloat)+''''+','
+''''+IntToStr(AdoQry_Head.fieldbyname('POReferencedPrice').AsInteger)+''''+','
+''''+IntToStr(AdoQry_Head.fieldbyname('POLineStatus').AsInteger)+''''+','
+''''+UserCode+''''+','
+'GetDate(),'
+''''+'更改行状态'+''''+')';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
Result:=True;
Except
Result:=False;
end;
end;
procedure TFrm_Pm_Enter_ForeverClosePo1.CloseRecord;
var
SqlText:String;
begin
DbConnect.beginTrans;
Try
SqlText:=' Select * From PoLine '
+' Where PoNo='''+AdoQry_Head.fieldbyname('PoNo').AsString+''''
+' And PoLineNo='''+IntToStr(AdoQry_Head.fieldbyname('PoLineNo').AsInteger)+''''
+' And PoLineStatus=7';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.Open;
If AdoQry_Tmp.Eof Then
begin
DbConnect.RollBackTrans;
DispInfo('本条采购订单记录行状态已被其它用户修改,请刷新!',3);
Abort;
end;
SavePoLineHistory;
SqlText:=' Update PoLine '
+' set PoLineStatus=8'
+' Where PoLine.PoNo='''+AdoQry_Head.fieldbyname('PoNo').AsString+''''
+' And PoLine.PoLineNo='''+AdoQry_Head.fieldbyname('PoLineNo').AsString+''''
+' And PoLine.PoLineStatus=7'
+' And PoLine.PoNo In (Select PoNo From Po Where PoSpecial=0 And PoType=1) ';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.ExecSQL;
AdoQry_Head.Edit;
AdoQry_Head.fieldbyname('PoLineStatus').AsInteger:=8;
AdoQry_Head.Post;
DbConnect.CommitTrans;
Except
DbConnect.RollBackTrans;
DispInfo('更改数据时出错,请重试!',1);
end;
end;
procedure TFrm_Pm_Enter_ForeverClosePo1.DBGridEhDblClick(Sender: TObject);
begin
inherited;
IF AdoQry_Head.fieldbyname('PoLineStatus').AsInteger=7 Then
begin
Frm_Pm_Enter_ForeverClosePo1.Act_CheckExecute(Act_Check);
Abort;
end;
end;
procedure TFrm_Pm_Enter_ForeverClosePo1.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Pm_Enter_ForeverClosePo1:=Nil;
end;
procedure TFrm_Pm_Enter_ForeverClosePo1.Act_CheckExecute(Sender: TObject);
begin
inherited;
If AdoQry_Head.RecordCount=0 Then
Exit;
If (AdoQry_Head.fieldbyname('PoLineStatus').AsInteger=7) And
(DispInfo('你确认结算此采购订单吗?',2)='y') Then
CloseRecord;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -