RTFormwork/项目代码/RTBasicsV1/A00通用窗体/U_UserSel.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

200 lines
4.7 KiB
ObjectPascal

unit U_UserSel;
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, cxDBLookupComboBox, ComObj, cxLookAndFeels, cxLookAndFeelPainters,
dxSkinsCore, dxSkinsDefaultPainters, cxNavigator, dxDateRanges, U_BaseHelp,
dxBarBuiltInMenu, System.ImageList, Vcl.ImgList;
type
FdDy = record
inc: integer; //客户端套接字句柄
FDdys: string[32]; //客户端套接字
FdDysName: string[32]; //客户端套接字
end;
TfrmUserSel = class(TfrmBaseHelp)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBClose: TToolButton;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
Panel1: TPanel;
ToolButton2: TToolButton;
ADOQueryMain: TADOQuery;
Label3: TLabel;
UserName: TEdit;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
cxGridLevel1: TcxGridLevel;
cxGridPopupMenu2: TcxGridPopupMenu;
DS_1: TDataSource;
CDS_1: TClientDataSet;
Label1: TLabel;
UserID: TEdit;
btnOK: TToolButton;
v2Column1: TcxGridDBColumn;
v2Column2: TcxGridDBColumn;
v2Column3: TcxGridDBColumn;
VC_SSel: TcxGridDBColumn;
ADOConnection1: TADOConnection;
ImageList1: TImageList;
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 UserNameChange(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Tv1DblClick(Sender: TObject);
private
{ Private declarations }
procedure InitGrid();
public
Fdept: string;
FMultiple: Boolean;
end;
var
frmUserSel: TfrmUserSel;
implementation
uses
U_DataLink, U_RTFun;
{$R *.dfm}
procedure TfrmUserSel.InitGrid();
begin
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
SQL.Clear;
sql.Add(' select * from SY_User where 1=1 ');
if Trim(Fdept) <> '' then
begin
sql.Add('and Udept=' + QuotedStr(Trim(Fdept)));
end;
Open;
end;
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
finally
ADOQueryMain.EnableControls;
end;
end;
procedure TfrmUserSel.FormCreate(Sender: TObject);
begin
inherited;
try
with ADOConnection1 do
begin
Connected := false;
ConnectionString := DConString;
Connected := true;
end;
ADOQueryBaseCmd.Connection := ADOConnection1;
ADOQueryBaseTemp.Connection := ADOConnection1;
except
application.MessageBox('网络连接失败!', '提示信息');
end;
end;
procedure TfrmUserSel.FormDestroy(Sender: TObject);
begin
inherited;
frmUserSel := nil;
end;
procedure TfrmUserSel.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmUserSel.TBCloseClick(Sender: TObject);
begin
WriteCxGrid(trim(self.caption), Tv1, '账户选择');
Close;
end;
procedure TfrmUserSel.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid(trim(self.Caption), Tv1, '账户选择');
if FMultiple then
begin
VC_SSel.Visible := True;
VC_SSel.Hidden := False;
end
else
begin
VC_SSel.Visible := False;
VC_SSel.Hidden := True;
end;
InitGrid();
end;
procedure TfrmUserSel.TBRafreshClick(Sender: TObject);
begin
InitGrid();
end;
procedure TfrmUserSel.ToolButton2Click(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
end;
end;
procedure TfrmUserSel.Tv1DblClick(Sender: TObject);
begin
ModalResult := 1;
end;
procedure TfrmUserSel.UserNameChange(Sender: TObject);
begin
ToolButton2.Click;
end;
procedure TfrmUserSel.btnOKClick(Sender: TObject);
begin
if FMultiple then
begin
if not CDS_1.Locate('SSel', true, []) then
begin
Application.MessageBox('请选择数据!', '提示', 0);
Exit;
end;
end;
ModalResult := 1;
end;
end.