Unit2.pas
资源名称:xiaobai.rar [点击查看]
上传用户:autowell
上传日期:2022-06-21
资源大小:16754k
文件大小:2k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit Unit2;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, DB, ADODB, Mask;
- type
- TForm2 = class(TForm)
- Label1: TLabel;
- RadioButton1: TRadioButton;
- RadioButton2: TRadioButton;
- Button1: TButton;
- ADOQuery1: TADOQuery;
- GroupBox1: TGroupBox;
- Label2: TLabel;
- Edit3: TEdit;
- Label5: TLabel;
- DataSource1: TDataSource;
- DataSource2: TDataSource;
- ADOQuery2: TADOQuery;
- MaskEdit1: TMaskEdit;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form2: TForm2;
- implementation
- uses Unit3;
- {$R *.dfm}
- procedure TForm2.Button1Click(Sender: TObject);
- var
- ad_name,ad_psd:string;
- sno:string;
- begin
- if not(radiobutton1.Checked) and not(radiobutton2.Checked) then
- application.MessageBox('请选择登陆身份','确定',mb_ok);
- if radiobutton1.Checked then
- begin
- if edit3.Text='' then application.MessageBox('请选择正确用户名登陆','确定',mb_ok);
- adoquery1.Active:=true;
- ad_name:=adoquery1.Fields[0].Value;
- ad_psd:=adoquery1.Fields[1].Value;
- if(edit3.Text=ad_name) and (maskedit1.Text=ad_psd) then
- begin
- application.MessageBox('你已经成功登陆','确定',mb_ok);
- form3.show;
- end
- else
- application.MessageBox('用户名或密码','确定',mb_ok);
- end;
- if radiobutton2.Checked then
- begin
- if edit3.Text='' then application.MessageBox('请选择正确用户名登陆','确定',mb_ok);
- with adoquery2 do
- begin
- close;
- sql.Clear;
- sql.Add('select * from student');
- sql.Add('where');
- sql.Add('sno='+ quotedstr(edit3.Text));
- open;
- active:=true;
- end;
- if adoquery2.Recordcount=0 then
- application.MessageBox('用户名不存在','确定',mb_ok)
- else
- begin
- sno:=adoquery2.Fields[0].Value;
- if(edit3.Text=sno) and (maskedit1.Text=sno) then
- begin
- application.MessageBox('成功登陆','确定',mb_ok);
- form3.Show;
- form2.edit3.Text:='';
- form2.maskedit1.Text:='';
- end
- else
- application.MessageBox('密码有误','确定',mb_ok);
- end;
- end;
- end;
- end.