300 lines
7.1 KiB
ObjectPascal
300 lines
7.1 KiB
ObjectPascal
unit U_PositionInPut;
|
||
|
||
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,
|
||
StrUtils, U_BaseInput, cxLookAndFeels, cxLookAndFeelPainters,
|
||
cxNavigator, dxDateRanges,
|
||
dxScrollbarAnnotations, cxContainer, dxBarBuiltInMenu, System.ImageList,
|
||
Vcl.ImgList,
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
cxMaskEdit, cxImageList;
|
||
|
||
type
|
||
TfrmPositionInPut = 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;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
Panel1: TPanel;
|
||
cxtxtdtQS: TcxTextEdit;
|
||
cxtxtdtJS: TcxTextEdit;
|
||
Label4: TLabel;
|
||
Label1: TLabel;
|
||
QZ: TcxTextEdit;
|
||
Label2: TLabel;
|
||
Label3: TLabel;
|
||
POSName: TcxTextEdit;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
Label5: TLabel;
|
||
LX: TcxButtonEdit;
|
||
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);
|
||
procedure LXDblClick(Sender: TObject);
|
||
procedure LXPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
private
|
||
{ Private declarations }
|
||
function SaveCKData(): Boolean;
|
||
public
|
||
{ Public declarations }
|
||
FBCId, FSTKName: string;
|
||
end;
|
||
|
||
var
|
||
frmPositionInPut: TfrmPositionInPut;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmPositionInPut.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmPositionInPut.TBAddClick(Sender: TObject);
|
||
var
|
||
I: Integer;
|
||
begin
|
||
for I := strtointdef(cxtxtdtQS.Text, 0) to strtointdef(cxtxtdtJS.Text, 0) do
|
||
begin
|
||
with CDS_Sub do
|
||
begin
|
||
Append;
|
||
|
||
CDS_Sub.fieldbyname('POSNO').Value := Trim(QZ.Text) + RightStr(('0000' + inttostr(I)), 5);
|
||
|
||
CDS_Sub.fieldbyname('POSName').Value := Trim(POSName.Text);
|
||
CDS_Sub.fieldbyname('LX').Value := Trim(LX.Text);
|
||
Post;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
function TfrmPositionInPut.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 BS_Position where POSID=''' + Trim(CDS_Sub.fieldbyname('POSID').AsString) + '''');
|
||
open;
|
||
end;
|
||
MWBID := Trim(ADOQueryTemp.fieldbyname('POSID').AsString);
|
||
if Trim(MWBID) = '' then
|
||
begin
|
||
if GetLSNo(ADOQueryCmd, MaxNo, 'M', 'BS_Position', 4, 1) = 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 BS_Position where POSID=''' + 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('POSID').Value := Trim(MaxNo);
|
||
// FieldByName('STKName').Value := Trim(FSTKName);
|
||
RTSetSaveDataCDS(ADOQueryCmd, Tv1, CDS_Sub, 'BS_Position', 0);
|
||
Post;
|
||
end;
|
||
|
||
Edit;
|
||
FieldByName('POSID').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 TfrmPositionInPut.TBCloseClick(Sender: TObject);
|
||
begin
|
||
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmPositionInPut.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 BS_Position A');
|
||
sql.Add(' where POSID=''' + Trim(FBCId) + '''');
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryTemp, CDS_Sub);
|
||
SInitCDSData(ADOQueryTemp, CDS_Sub);
|
||
end;
|
||
|
||
procedure TfrmPositionInPut.LXDblClick(Sender: TObject);
|
||
begin
|
||
LX.text := '';
|
||
end;
|
||
|
||
procedure TfrmPositionInPut.LXPropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
||
begin
|
||
try
|
||
frmZDYHelp := TfrmZDYHelp.Create(Application);
|
||
with frmZDYHelp do
|
||
begin
|
||
flag := 'LX';
|
||
flagname := '<27><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>';
|
||
|
||
if ShowModal = 1 then
|
||
begin
|
||
LX.text := Trim(ClientDataSet1.fieldbyname('ZDYName').AsString);
|
||
end;
|
||
end;
|
||
finally
|
||
frmZDYHelp.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmPositionInPut.TBDelClick(Sender: TObject);
|
||
begin
|
||
if CDS_Sub.IsEmpty then
|
||
Exit;
|
||
if Trim(CDS_Sub.fieldbyname('POSID').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 BS_Position where POSID=''' + Trim(CDS_Sub.fieldbyname('POSID').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 TfrmPositionInPut.TBSaveClick(Sender: TObject);
|
||
begin
|
||
if CDS_Sub.IsEmpty then
|
||
Exit;
|
||
|
||
if CDS_Sub.Locate('POSNO', 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 TfrmPositionInPut.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(trim(self.Caption), Tv1, 'Ⱦɫ<C8BE><C9AB><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>');
|
||
end;
|
||
|
||
end.
|
||
|