248 lines
6.0 KiB
ObjectPascal
248 lines
6.0 KiB
ObjectPascal
|
unit U_WarpBeamInfoInPut;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
|
|||
|
cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit, ComCtrls, ToolWin,
|
|||
|
cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
|||
|
cxClasses, cxControls, cxGridCustomView, cxGrid, cxGridCustomPopupMenu,
|
|||
|
cxGridPopupMenu, ADODB, DBClient, cxButtonEdit, cxTextEdit, StdCtrls, ExtCtrls,
|
|||
|
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
|
|||
|
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseInput,
|
|||
|
U_BaseList, System.ImageList, Vcl.ImgList;
|
|||
|
|
|||
|
type
|
|||
|
TfrmWarpBeamInfoInPut = class(TfrmBaseInput)
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1Column2: TcxGridDBColumn;
|
|||
|
cxGrid2Level1: TcxGridLevel;
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBAdd: TToolButton;
|
|||
|
TBDel: TToolButton;
|
|||
|
TBSave: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
DataSource3: TDataSource;
|
|||
|
CDS_Sub: TClientDataSet;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
cxGridPopupMenu2: TcxGridPopupMenu;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure TBAddClick(Sender: TObject);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure TBDelClick(Sender: TObject);
|
|||
|
procedure TBSaveClick(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
private
|
|||
|
{ Private declarations }
|
|||
|
function SaveCKData(): Boolean;
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
FBCId, FSTKName: string;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmWarpBeamInfoInPut: TfrmWarpBeamInfoInPut;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmWarpBeamInfoInPut.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmWarpBeamInfoInPut.TBAddClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Sub.IsEmpty = False then
|
|||
|
begin
|
|||
|
CopyAddRowCDS(CDS_Sub);
|
|||
|
with CDS_Sub do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName('WBID').Value := null;
|
|||
|
post;
|
|||
|
end;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
with CDS_Sub do
|
|||
|
begin
|
|||
|
Append;
|
|||
|
Post;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmWarpBeamInfoInPut.SaveCKData(): Boolean;
|
|||
|
var
|
|||
|
MaxNo, MWBID: string;
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
CDS_Sub.DisableControls;
|
|||
|
with CDS_Sub do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not eof do
|
|||
|
begin
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from Tat_WB_Stk where WBID=''' + Trim(CDS_Sub.fieldbyname('WBID').AsString) + '''');
|
|||
|
open;
|
|||
|
end;
|
|||
|
MWBID := Trim(ADOQueryTemp.fieldbyname('WBID').AsString);
|
|||
|
if Trim(MWBID) = '' then
|
|||
|
begin
|
|||
|
if GetLSNo(ADOQueryCmd, MaxNo, 'WB', 'Tat_WB_Stk', 4, 0) = False then
|
|||
|
raise Exception.Create('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
MaxNo := Trim(MWBID);
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from Tat_WB_Stk where WBID=''' + Trim(MaxNo) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
if Trim(MWBID) = '' then
|
|||
|
begin
|
|||
|
Append;
|
|||
|
FieldByName('Fillid').Value := Trim(Dcode);
|
|||
|
FieldByName('Filler').Value := Trim(DName)
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName('Editid').Value := Trim(Dcode);
|
|||
|
FieldByName('Editer').Value := Trim(DName);
|
|||
|
FieldByName('EditTime').Value := SGetServerDate(ADOQueryTemp);
|
|||
|
end;
|
|||
|
FieldByName('WBID').Value := Trim(MaxNo);
|
|||
|
// FieldByName('STKName').Value := Trim(FSTKName);
|
|||
|
RTSetSaveDataCDS(ADOQueryCmd, Tv1, CDS_Sub, 'Tat_WB_Stk', 0);
|
|||
|
Post;
|
|||
|
end;
|
|||
|
|
|||
|
Edit;
|
|||
|
FieldByName('WBID').Value := Trim(MaxNo);
|
|||
|
Post;
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
CDS_Sub.EnableControls;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
Result := True;
|
|||
|
except
|
|||
|
Result := False;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmWarpBeamInfoInPut.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmWarpBeamInfoInPut.FormShow(Sender: TObject);
|
|||
|
var
|
|||
|
fsj: string;
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
ReadCxGrid(trim(self.Caption), Tv1, 'Ⱦɫ<C8BE><C9AB><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>');
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select A.* ');
|
|||
|
sql.Add(' from Tat_WB_Stk A');
|
|||
|
sql.Add(' where WBID=''' + Trim(FBCId) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS(ADOQueryTemp, CDS_Sub);
|
|||
|
SInitCDSData(ADOQueryTemp, CDS_Sub);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmWarpBeamInfoInPut.TBDelClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Sub.IsEmpty then
|
|||
|
Exit;
|
|||
|
if Trim(CDS_Sub.fieldbyname('WBID').AsString) <> '' then
|
|||
|
begin
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
|||
|
Exit;
|
|||
|
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' delete Tat_WB_Stk where WBID=''' + Trim(CDS_Sub.fieldbyname('WBID').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
CDS_Sub.Delete;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
Application.MessageBox('ɾ<><C9BE><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
CDS_Sub.Delete;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmWarpBeamInfoInPut.TBSaveClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Sub.IsEmpty then
|
|||
|
Exit;
|
|||
|
|
|||
|
if CDS_Sub.Locate('WBNo', null, []) = True then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
|
|||
|
if SaveCKData() then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
ModalResult := 1;
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmWarpBeamInfoInPut.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(trim(self.Caption), Tv1, 'Ⱦɫ<C8BE><C9AB><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>');
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|