190 lines
5.8 KiB
ObjectPascal
190 lines
5.8 KiB
ObjectPascal
![]() |
unit U_BefChkHX;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|||
|
cxDataStorage, cxEdit, DB, cxDBData, cxCalendar, cxButtonEdit,
|
|||
|
cxTextEdit, StdCtrls, cxGridLevel, cxGridCustomTableView,
|
|||
|
cxGridTableView, cxGridDBTableView, cxClasses, cxControls,
|
|||
|
cxGridCustomView, cxGrid, ComCtrls, ToolWin, ExtCtrls, cxDropDownEdit,
|
|||
|
DBClient, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu;
|
|||
|
|
|||
|
type
|
|||
|
TfrmBefChkHX = class(TForm)
|
|||
|
Panel1: TPanel;
|
|||
|
ToolBar2: TToolBar;
|
|||
|
ToolButton2: TToolButton;
|
|||
|
ToolButton3: TToolButton;
|
|||
|
ToolButton4: TToolButton;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
TV2: TcxGridDBTableView;
|
|||
|
V2Column2: TcxGridDBColumn;
|
|||
|
V2Column8: TcxGridDBColumn;
|
|||
|
V2Column7: TcxGridDBColumn;
|
|||
|
V2Column1: TcxGridDBColumn;
|
|||
|
V2Column5: TcxGridDBColumn;
|
|||
|
V2Column6: TcxGridDBColumn;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
orderno: TLabel;
|
|||
|
PRTColor: TLabel;
|
|||
|
FirstName: TLabel;
|
|||
|
PBFactory: TLabel;
|
|||
|
V2Column3: TcxGridDBColumn;
|
|||
|
ADOQuery1: TADOQuery;
|
|||
|
ADOQuery2: TADOQuery;
|
|||
|
ADOQuery3: TADOQuery;
|
|||
|
ClientDataSet1: TClientDataSet;
|
|||
|
DataSource1: TDataSource;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
V2Column4: TcxGridDBColumn;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
procedure ToolButton4Click(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
private
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
FLLID:String;
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmBefChkHX: TfrmBefChkHX;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_DataLink,U_Fun;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmBefChkHX.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmBefChkHX:=nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBefChkHX.FormClose(Sender: TObject;
|
|||
|
var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action:=caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBefChkHX.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
with ClientDataSet1 do
|
|||
|
begin
|
|||
|
Append;
|
|||
|
FieldByName('HXFactory').Value:=Trim(FirstName.Caption);
|
|||
|
FieldByName('HXDate').Value:=SGetServerDate(ADOQuery2);
|
|||
|
FieldByName('HXType').Value:='<27><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>';
|
|||
|
Post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBefChkHX.ToolButton3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if ClientDataSet1.IsEmpty then Exit;
|
|||
|
if Trim(ClientDataSet1.fieldbyname('HXType').AsString)<>'<27><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>' then Exit;
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27><>ʾ',32+4)<>IDYES then Exit;
|
|||
|
with ADOQuery3 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
SQL.Add('delete Contract_Cloth_BefChkHX where HXID='''+Trim(ClientDataSet1.fieldbyname('HXID').AsString)+'''');
|
|||
|
sql.Add('Update Contract_Cloth_LL Set HXPS=(select sum(HXPS) from Contract_Cloth_BefChkHX A where A.LLID=Contract_Cloth_LL.LLID)');
|
|||
|
sql.Add(',HXQty=(select sum(HXQty) from Contract_Cloth_BefChkHX A where A.LLID=Contract_Cloth_LL.LLID)');
|
|||
|
sql.Add(',HXMQty=(select sum(HXMQty) from Contract_Cloth_BefChkHX A where A.LLID=Contract_Cloth_LL.LLID)');
|
|||
|
sql.Add(',HXUnit=(select Top 1 HXUnit from Contract_Cloth_BefChkHX A where A.LLID=Contract_Cloth_LL.LLID)');
|
|||
|
sql.Add(' where LLID='''+Trim(FLLID)+'''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
ClientDataSet1.Delete;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBefChkHX.ToolButton4Click(Sender: TObject);
|
|||
|
var
|
|||
|
maxno:string;
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQuery3.Connection.BeginTrans;
|
|||
|
with ClientDataSet1 do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
if Trim(ClientDataSet1.fieldbyname('HXType').AsString)='<27><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>' then
|
|||
|
begin
|
|||
|
if Trim(ClientDataSet1.fieldbyname('HXID').AsString)='' then
|
|||
|
begin
|
|||
|
if GetLSNo(ADOQuery3,maxno,'HX','Contract_Cloth_BefChkHX',2,1)=False then
|
|||
|
begin
|
|||
|
ADOQuery3.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end else
|
|||
|
begin
|
|||
|
maxno:=Trim(ClientDataSet1.fieldbyname('HXID').AsString);
|
|||
|
end;
|
|||
|
with ADOQuery3 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from Contract_Cloth_BefChkHX where HXID='''+Trim(ClientDataSet1.fieldbyname('HXID').AsString)+'''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
with ADOQuery3 do
|
|||
|
begin
|
|||
|
if Trim(ClientDataSet1.fieldbyname('HXID').AsString)='' then
|
|||
|
Append
|
|||
|
else
|
|||
|
Edit;
|
|||
|
FieldByName('LLID').Value:=Trim(FLLID);
|
|||
|
FieldByName('HXID').Value:=Trim(maxno);
|
|||
|
SSetSaveDataCDSNew(ADOQuery3,TV2,ClientDataSet1,'Contract_Cloth_BefChkHX',2);
|
|||
|
Post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
with ADOQuery3 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
SQL.Clear;
|
|||
|
SQL.Add('Update Contract_Cloth_BefChkHX Set HXMQty=HXQty*ZSXS where LLID='''+Trim(FLLID)+'''');
|
|||
|
sql.Add('Update Contract_Cloth_LL Set HXPS=(select sum(HXPS) from Contract_Cloth_BefChkHX A where A.LLID=Contract_Cloth_LL.LLID)');
|
|||
|
sql.Add(',HXQty=(select sum(HXQty) from Contract_Cloth_BefChkHX A where A.LLID=Contract_Cloth_LL.LLID)');
|
|||
|
sql.Add(',HXMQty=(select sum(HXMQty) from Contract_Cloth_BefChkHX A where A.LLID=Contract_Cloth_LL.LLID)');
|
|||
|
sql.Add(',HXUnit=(select Top 1 HXUnit from Contract_Cloth_BefChkHX A where A.LLID=Contract_Cloth_LL.LLID)');
|
|||
|
sql.Add(' where LLID='''+Trim(FLLID)+'''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
ADOQuery3.Connection.CommitTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!','<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
except
|
|||
|
ADOQuery3.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!','<27><>ʾ',0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBefChkHX.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
Close;
|
|||
|
WriteCxGrid('<27><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>',TV2,'<27>زֹ<D8B2><D6B9><EFBFBD>');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBefChkHX.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
ReadCxGrid('<27><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>',TV2,'<27>زֹ<D8B2><D6B9><EFBFBD>');
|
|||
|
end;
|
|||
|
|
|||
|
end.
|