322 lines
7.8 KiB
ObjectPascal
322 lines
7.8 KiB
ObjectPascal
unit U_BankList;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
|
||
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
|
||
cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
|
||
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
|
||
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
|
||
IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
|
||
cxTextEdit, cxPC, cxCheckComboBox, cxDropDownEdit, Menus, RM_e_Xls,
|
||
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
|
||
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseList;
|
||
|
||
type
|
||
TfrmBankList = class(TfrmBaseList)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
ToolButton2: TToolButton;
|
||
ADOQueryMain: TADOQuery;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
cxGridLevel1: TcxGridLevel;
|
||
GPM_1: TcxGridPopupMenu;
|
||
DS_1: TDataSource;
|
||
CDS_1: TClientDataSet;
|
||
PopupMenu1: TPopupMenu;
|
||
N1: TMenuItem;
|
||
N2: TMenuItem;
|
||
Panel1: TPanel;
|
||
BKName: TEdit;
|
||
Label1: TLabel;
|
||
btnadd: TToolButton;
|
||
btndel: TToolButton;
|
||
v2Column1: TcxGridDBColumn;
|
||
Tv2Column1: TcxGridDBColumn;
|
||
Tv2Column3: TcxGridDBColumn;
|
||
Tv2Column4: TcxGridDBColumn;
|
||
Tv2Column5: TcxGridDBColumn;
|
||
Tv2Column6: TcxGridDBColumn;
|
||
ToolButton1: TToolButton;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure N1Click(Sender: TObject);
|
||
procedure N2Click(Sender: TObject);
|
||
procedure CustomerChange(Sender: TObject);
|
||
procedure FormCreate(Sender: TObject);
|
||
procedure v2Column8PropertiesEditValueChanged(Sender: TObject);
|
||
procedure btnaddClick(Sender: TObject);
|
||
procedure btndelClick(Sender: TObject);
|
||
procedure btnokClick(Sender: TObject);
|
||
procedure v2Column1PropertiesEditValueChanged(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
procedure InitGrid();
|
||
public
|
||
fFlag: integer;
|
||
{ Public declarations }
|
||
RKFlag, FCYID, fmanage: string;
|
||
end;
|
||
|
||
var
|
||
frmBankList: TfrmBankList;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_ZDYHelp;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmBankList.InitGrid();
|
||
begin
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
Close;
|
||
SQL.Clear;
|
||
sql.Add(' select * from BS_Bank order by SerialNo ');
|
||
Open;
|
||
end;
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
ToolButton2.Click;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmBankList.FormDestroy(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frmBankList := nil;
|
||
end;
|
||
|
||
procedure TfrmBankList.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmBankList.TBCloseClick(Sender: TObject);
|
||
begin
|
||
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmBankList.FormShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
ReadCxGrid(Trim(Self.Caption), Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
InitGrid();
|
||
|
||
end;
|
||
|
||
procedure TfrmBankList.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmBankList.btnokClick(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
exit;
|
||
ModalResult := 1;
|
||
end;
|
||
|
||
procedure TfrmBankList.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(Trim(Self.Caption), Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
end;
|
||
|
||
procedure TfrmBankList.ToolButton2Click(Sender: TObject);
|
||
var
|
||
sql: string;
|
||
begin
|
||
if ADOQueryMain.Active then
|
||
begin
|
||
sql := SGetFilters(Panel1, 1, 2);
|
||
SDofilter(ADOQueryMain, sql);
|
||
SCreateCDS(ADOQueryMain, CDS_1);
|
||
SInitCDSData(ADOQueryMain, CDS_1);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmBankList.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid;
|
||
end;
|
||
|
||
procedure TfrmBankList.N1Click(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
exit;
|
||
with CDS_1 do
|
||
begin
|
||
DisableControls;
|
||
first;
|
||
while not eof do
|
||
begin
|
||
edit;
|
||
fieldbyname('ssel').Value := true;
|
||
post;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmBankList.N2Click(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
exit;
|
||
with CDS_1 do
|
||
begin
|
||
DisableControls;
|
||
first;
|
||
while not eof do
|
||
begin
|
||
edit;
|
||
fieldbyname('ssel').Value := false;
|
||
post;
|
||
next;
|
||
end;
|
||
First;
|
||
EnableControls;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmBankList.CustomerChange(Sender: TObject);
|
||
begin
|
||
ToolButton2.Click;
|
||
end;
|
||
|
||
procedure TfrmBankList.FormCreate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
fmanage := Trim(DParameters1);
|
||
end;
|
||
|
||
procedure TfrmBankList.v2Column1PropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue, FFieldName: string;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
FFieldName := Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_1 do
|
||
begin
|
||
Edit;
|
||
FieldByName(FFieldName).Value := Trim(mvalue);
|
||
Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate BS_Bank ');
|
||
sql.Add(' Set ' + FFieldName + '=' + Trim(mvalue));
|
||
sql.Add(' , Editer=''' + Trim(DName) + '''');
|
||
sql.Add(' , Edittime=getdate()');
|
||
sql.Add(' where BKID=' + quotedstr(CDS_1.fieldbyname('BKID').AsString));
|
||
ExecSQL;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
tv2.Controller.EditingController.ShowEdit();
|
||
except
|
||
tv2.Controller.EditingController.ShowEdit();
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
end
|
||
end;
|
||
|
||
procedure TfrmBankList.v2Column8PropertiesEditValueChanged(Sender: TObject);
|
||
var
|
||
mvalue, FFieldName: string;
|
||
begin
|
||
mvalue := TcxTextEdit(Sender).EditingText;
|
||
FFieldName := Trim(Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
with CDS_1 do
|
||
begin
|
||
Edit;
|
||
FieldByName(FFieldName).Value := Trim(mvalue);
|
||
Post;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('UPdate BS_Bank ');
|
||
sql.Add(' Set ' + FFieldName + '=''' + Trim(mvalue) + '''');
|
||
sql.Add(' , Editer=''' + Trim(DName) + '''');
|
||
sql.Add(' , Edittime=getdate()');
|
||
sql.Add(' where BKID=' + quotedstr(CDS_1.fieldbyname('BKID').AsString));
|
||
ExecSQL;
|
||
end;
|
||
ADOQueryCmd.Connection.CommitTrans;
|
||
tv2.Controller.EditingController.ShowEdit();
|
||
except
|
||
tv2.Controller.EditingController.ShowEdit();
|
||
ADOQueryCmd.Connection.RollbackTrans;
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
end
|
||
end;
|
||
|
||
procedure TfrmBankList.btnaddClick(Sender: TObject);
|
||
var
|
||
maxId: string;
|
||
begin
|
||
BKName.SetFocus;
|
||
if GetLSNo(ADOQueryCmd, maxId, 'BK', 'BS_Bank', 4, 0) = False then
|
||
begin
|
||
Application.MessageBox('ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
|
||
Exit;
|
||
end;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('insert into BS_Bank(BKID,Filler) values(' + quotedstr(Trim(maxId)) + ',' + quotedstr(Trim(dname)) + ')');
|
||
ExecSQL;
|
||
end;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmBankList.btndelClick(Sender: TObject);
|
||
begin
|
||
if CDS_1.IsEmpty then
|
||
Exit;
|
||
if Application.MessageBox('ȷ<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
|
||
Exit;
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
sql.Clear;
|
||
sql.Add('delete BS_Bank where BKID=' + QuotedStr(CDS_1.FieldByName('BKID').AsString));
|
||
ExecSQL;
|
||
end;
|
||
CDS_1.Delete;
|
||
end;
|
||
|
||
end.
|
||
|