Unit1.pas
上传用户:lcqxtx
上传日期:2013-02-15
资源大小:530k
文件大小:5k
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, FInIfile, StdCtrls, Buttons, ExtCtrls, DB, ADODB;
- type
- TForm1 = class(TForm)
- Label1: TLabel;
- Label2: TLabel;
- Edit2: TEdit;
- Edit3: TEdit;
- Label3: TLabel;
- FInIfile1: TFInIfile;
- BitBtn1: TBitBtn;
- Panel1: TPanel;
- BitBtn2: TBitBtn;
- ComboBox1: TComboBox;
- StaticText1: TStaticText;
- Label4: TLabel;
- Edit1: TEdit;
- procedure BitBtn1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormShow(Sender: TObject);
- procedure ComboBox1Change(Sender: TObject);
- procedure BitBtn2Click(Sender: TObject);
- procedure Edit2KeyPress(Sender: TObject; var Key: Char);
- procedure Edit3KeyPress(Sender: TObject; var Key: Char);
- private
- { Private declarations }
- public
- { Public declarations }
- power:string;
- end;
- var
- Form1: TForm1;
- s_mima:string;
- s_gb:string;
- implementation
- uses data_1, f_main;
- {$R *.dfm}
- procedure TForm1.BitBtn1Click(Sender: TObject);
- begin
- FInIfile1.Writestrings('系统信息', '服务器',Trim(Edit3.Text));
- if Length(Trim(Edit3.Text))=0 then
- begin
- Application.MessageBox('请输入服务器名称!','系统提示',mb_ok);
- Exit;
- end;
- if trim(combobox1.text)=' ' then
- begin
- combobox1.SetFocus;
- showmessage('请选择员工编号');
- exit;
- end ;
- if trim(edit2.text)='' then
- begin
- combobox1.SetFocus;
- showmessage('请输入身份密码');
- exit;
- end
- else
- begin
- data1.ado_tab.Close;
- data1.ado_tab.SQL.Clear;
- data1.ado_tab.SQL.Add('select * from username where user_id='+ char(39)+trim(combobox1.Text)+
- char(39)+ 'and user_password='+char(39)+trim(edit2.Text)+char(39)+
- 'and user_name='+char(39)+trim(edit1.Text)+char(39)) ;
- data1.ado_tab.Open;
- if data1.ado_tab.RecordCount >0 then begin
- s_mima:=trim(data1.ado_tab.fieldbyname('user_password').AsString );
- w_Main.auser.id:= trim(data1.ado_tab.fieldbyname('user_id').AsString );
- w_Main.auser.name:=trim(data1.ado_tab.fieldbyname('user_name').AsString );
- power:=trim(data1.ado_tab.fieldbyname('user_power').AsString );
- if power='一般用户' then
- begin
- w_main.n3.Enabled:=false;
- w_main.ToolButton4.Enabled:=false;
- w_main.show;
- form1.Hide;
- end
- else
- begin
- s_gb:='yes';
- w_main.show;
- w_main.ToolButton4.Enabled:=true;
- form1.Hide;
- end;
- end
- else
- begin
- application.MessageBox('你输入的身份密码不正确',char(48));
- edit2.text:='';
- edit2.setfocus;
- exit;
- end;
- end;
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Edit1.Clear;
- combobox1.Clear;
- Edit2.Clear;
- Edit3.Clear;
- if Length(Trim(Edit3.Text))=0 then
- begin
- Application.MessageBox('请输入服务器名称!','系统提示',mb_ok);
- Exit;
- end;
- FInIfile1.Directory:=ExtractFilePath(Application.ExeName);
- if FileExists('bds.ini') then
- Edit3.Text:=Finifile1.Readstrings('系统信息','服务器');
- Data1.DataBase1.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=SA;Initial Catalog=cbxt;Data Source='+Trim(Edit3.Text);
- Data1.Database1.Connected;
- {cbxt是数据库名称}
- end;
- procedure TForm1.FormShow(Sender: TObject);
- var
- i:integer;
- begin
- combobox1.Clear;
- data1.ado_tab.Close;
- data1.ado_tab.SQL.Clear;
- data1.ado_tab.SQL.Add('select distinct user_id from username') ;
- data1.ado_tab.Open;
- if data1.ado_tab.RecordCount -1>0 then
- begin
- combobox1.Clear;
- data1.ado_tab.First ;
- for i:=0 to data1.ado_tab.RecordCount -1 do
- begin
- combobox1.Items.Add(trim(data1.ado_tab.fieldbyname('user_id').AsString));
- data1.ado_tab.Next ;
- end;
- end;
- end;
- procedure TForm1.ComboBox1Change(Sender: TObject);
- begin
- data1.ado_tab.Close;
- data1.ado_tab.SQL.Clear ;
- data1.ado_tab.SQL.Add('select * from username where user_id='''+combobox1.text+'''');
- data1.ado_tab.Open ;
- edit1.Text := data1.ado_tab.Fieldbyname('user_name').asstring;
- edit2.SetFocus ;
- end;
- procedure TForm1.BitBtn2Click(Sender: TObject);
- begin
- CLOSE;
- end;
- procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
- begin
- if ord(key)=13 then
- BitBtn1Click(Sender);
- end;
- procedure TForm1.Edit3KeyPress(Sender: TObject; var Key: Char);
- begin
- if key=chr(13) then
- if Trim(edit3.Text)<>'' then
- begin
- combobox1.SetFocus;
- end ;
- end;
- end.