WZGL_RDB.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:6k
- unit WZGL_RDB;
- {$WARN SYMBOL_PLATFORM OFF}
- interface
- uses
- Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
- DBClient, P_server_TLB, StdVcl, DBTables, DB, Provider, variants, ComCtrls;
- type
- TWZGL = class(TRemoteDataModule, IWZGL)
- Q_QXGL_ZHNR: TQuery;
- Q_QXGL_ZHSZ: TQuery;
- S_QXGL_ZHSZ: TDataSource;
- P_QXGL_ZHSZ: TDataSetProvider;
- Q_QXGL_YHSZ: TQuery;
- P_QXGL_YHSZ: TDataSetProvider;
- Q_General: TQuery;
- Q_QXGL_ZHNR_INDEX: TQuery;
- P_QXGL_ZHNR_INDEX: TDataSetProvider;
- Q_ZGDA: TQuery;
- Q_BMDA: TQuery;
- P_ZGDA: TDataSetProvider;
- P_BMDA: TDataSetProvider;
- Q_DQFLB: TQuery;
- P_DQFLB: TDataSetProvider;
- Q_GYSFLB: TQuery;
- P_GYSFLB: TDataSetProvider;
- Q_GYSDA: TQuery;
- P_GYSDA: TDataSetProvider;
- P_CKXX: TDataSetProvider;
- Q_JFDW: TQuery;
- Q_YFDW: TQuery;
- P_JFDW: TDataSetProvider;
- P_YFDW: TDataSetProvider;
- Q_GCXMDYB: TQuery;
- P_GCXMDYB: TDataSetProvider;
- P_CLBM: TDataSetProvider;
- Q_CLBM: TQuery;
- P_General: TDataSetProvider;
- Q_CLSLD_CX: TQuery;
- P_CLSLD_CX: TDataSetProvider;
- Q_CLSLD: TQuery;
- Q_CLSLD_DETAIL: TQuery;
- S_CLSLD: TDataSource;
- P_CLSLD: TDataSetProvider;
- P_CLSLD_DETAIL_INDEX: TDataSetProvider;
- Q_CLSLD_DETAIL_INDEX: TQuery;
- Q_CLBM_TEMP: TQuery;
- P_CLBM_TEMP: TDataSetProvider;
- Q_CKXX: TQuery;
- Q_BMLLD: TQuery;
- Q_BMLLD_DETAIL: TQuery;
- Q_BMLLD_DETAIL_INDEX: TQuery;
- Q_BMLLD_CX: TQuery;
- S_BMLLD: TDataSource;
- P_BMLLD: TDataSetProvider;
- P_BMLLD_DETAIL_INDEX: TDataSetProvider;
- P_BMLLD_CX: TDataSetProvider;
- Q_KCPD: TQuery;
- Q_KCPD_DETAIL: TQuery;
- Q_KCPD_DETAIL_INDEX: TQuery;
- Q_KCPD_CX: TQuery;
- S_KCPD: TDataSource;
- P_KCPD: TDataSetProvider;
- P_KCPD_DETAIL_INDEX: TDataSetProvider;
- P_KCPD_CX: TDataSetProvider;
- Q_KC: TQuery;
- P_KC: TDataSetProvider;
- private
- { Private declarations }
- protected
- class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
- procedure GetFuncs(aZh: OleVariant; var vFuncs: OleVariant); safecall;
- procedure Logined(bAliasName, aPassword: OleVariant; var aYhbh, aZH,
- aLogined: OleVariant); safecall;
- procedure AddUser(Host, IP, UserAlias, ConnTime: OleVariant); safecall;
- procedure DelUser(Host, IP, UserAlias, ConnTime: OleVariant); safecall;
- procedure GetSysTime(var aTime: OleVariant); safecall;
- procedure updatePassword(bAliasName, aPassword: OleVariant;
- var aResult: OleVariant); safecall;
- public
- { Public declarations }
- end;
- implementation
- uses U_server;
- {$R *.DFM}
- class procedure TWZGL.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
- begin
- if Register then
- begin
- inherited UpdateRegistry(Register, ClassID, ProgID);
- EnableSocketTransport(ClassID);
- EnableWebTransport(ClassID);
- end else
- begin
- DisableSocketTransport(ClassID);
- DisableWebTransport(ClassID);
- inherited UpdateRegistry(Register, ClassID, ProgID);
- end;
- end;
- {根据传进来的组号(aZh),检索出相对应的功能列表,存入vFuncs数组}
- procedure TWZGL.GetFuncs(aZh: OleVariant; var vFuncs: OleVariant);
- var
- sqlString: string;
- i: integer;
- begin
- //sql赋值
- sqlString := 'select 功能项 from WZ_QXGL_ZHNR where 组号=' + '''' + aZh + '''';
- Q_General.Close;
- Q_General.SQL.Clear;
- Q_General.SQL.Add(sqlString);
- try
- Q_General.Open;
- except
- exit;
- end;
- vFuncs := varArrayCreate([0, Q_General.RecordCount], varVariant);
- i := 0;
- //将查到的功能项存入数组
- while not Q_General.Eof do
- begin
- vFuncs[i] := Q_General.Fields[0].asString;
- Q_General.Next;
- i := i + 1;
- end;
- end;
- {根据传进来的bAliasName,aPassword,来验证是否是有效的身份}
- procedure TWZGL.Logined(bAliasName, aPassword: OleVariant; var aYhbh, aZH,
- aLogined: OleVariant);
- var
- sqlString: string;
- begin
- aLogined := True;
- //用SQL语句来判断身份是否存在
- sqlString := 'select 用户编号,用户组号 from wz_qxgl_yhsz where 用户别名=' + '''' + bAliasName + ''' and ';
- sqlString := sqlString + ' 用户密码=' + '''' + aPassword + '''';
- Q_General.Close;
- Q_General.SQL.Clear;
- Q_General.SQL.Add(sqlString);
- try
- Q_General.Open;
- except
- aLogined := False;
- exit;
- end;
- if Q_General.RecordCount = 0 then //查到记录为O,代表身份不存在
- begin
- aLogined := False;
- exit;
- end;
- aYHBH := Q_General.FieldByName('用户编号').asString; //输出用户编号
- aZH := Q_General.FieldbyName('用户组号').asString; //输出用户组号
- end;
- {当有客户端连接时,添加一条显示信息到主窗口的列表框(ListView)}
- procedure TWZGL.AddUser(Host, IP, UserAlias, ConnTime: OleVariant);
- var
- aListItem: TListItem;
- begin
- with frmMain do
- begin
- aListItem := ListView.Items.Add;
- aListItem.Caption := Host;
- aListItem.SubItems.add(IP);
- aListItem.SubItems.Add(UserAlias);
- aListItem.SubItems.Add(ConnTime);
- end;
- end;
- {当有客户端断开时,删除相应的显示信息}
- procedure TWZGL.DelUser(Host, IP, UserAlias, ConnTime: OleVariant);
- var
- i: integer;
- begin
- with frmMain do
- begin
- for i := 0 to ListView.Items.Count - 1 do
- begin
- if (ListView.Items.Item[i].Caption = Host) and
- (ListView.Items.Item[i].SubItems[0] = IP) and
- (ListView.Items.Item[i].SubItems[1] = UserAlias) and
- (ListView.Items.Item[i].SubItems[2] = ConnTime) then
- begin
- ListView.Items.Delete(i);
- exit;
- end;
- end;
- end;
- end;
- {获取数据库当前系统时间}
- procedure TWZGL.GetSysTime(var aTime: OleVariant);
- begin
- Q_General.Close;
- Q_General.SQL.Clear;
- //得到数据库的当前时间
- Q_General.SQL.Add('select aTime = getDate()');
- Q_General.Open;
- aTime := Q_General.Fields[0].AsString;
- Q_General.Close;
- end;
- procedure TWZGL.updatePassword(bAliasName, aPassword: OleVariant;
- var aResult: OleVariant);
- var
- sqlString: string;
- begin
- aResult := True;
- sqlString := 'update WZ_QXGL_YHSZ set 用户密码=' + '''' + aPassword + '''';
- sqlString := sqlString + ' where 用户别名=' + '''' + bAliasName + '''';
- Q_General.Close;
- Q_General.SQL.Clear;
- Q_General.SQL.Add(sqlString);
- try
- Q_General.ExecSQL;
- except
- aResult := False;
- end;
- end;
- initialization
- TComponentFactory.Create(ComServer, TWZGL,
- Class_WZGL, ciMultiInstance, tmApartment);
- end.