Unit1.~pas
上传用户:autowell
上传日期:2022-06-21
资源大小:16754k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit Unit1;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, DB, ADODB, StdCtrls, ExtCtrls;
  6. type
  7.   TForm1 = class(TForm)
  8.     RadioGroup1: TRadioGroup;
  9.     RadioButton1: TRadioButton;
  10.     RadioButton2: TRadioButton;
  11.     Label1: TLabel;
  12.     Label2: TLabel;
  13.     Edit1: TEdit;
  14.     Label3: TLabel;
  15.     Edit2: TEdit;
  16.     DataSource1: TDataSource;
  17.     Button1: TButton;
  18.     Button2: TButton;
  19.     ADOQuery1: TADOQuery;
  20.     ADOQuery2: TADOQuery;
  21.     DataSource2: TDataSource;
  22.     procedure Button1Click(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.   end;
  28. var
  29.   Form1: TForm1;
  30. implementation
  31.     uses unit4;
  32. {$R *.dfm}
  33. procedure TForm1.Button1Click(Sender: TObject);
  34. var
  35.   adminName,adminPsw,stuName,stuPsw:String;
  36. begin
  37.    if RadioButton1.Checked=false and RadioButton2.Checked=false then
  38.       MessageDlg('请选择用户类型!!',mtWarning,[mbok],0)
  39.    else if RadioButton1.Checked=true then
  40.         begin
  41.              if edit1.Text='' and edit2.Text='' then
  42.                 MessageDlg('用户名或密码不能为空!!',mtWarning,[mbok]);
  43.              adminName:=edit1.Text;
  44.              adminPsw:=edit2.Text;
  45.              with ADOQuery1 do
  46.              begin
  47.                   close;
  48.                   sql.Clear;
  49.                   sql.Add('select * from manager');
  50.                   sql.Add('where') ;
  51.                   sql.Add('用户名='+ quotestr(adminName));
  52.                   open;
  53.                   active:=true;
  54.              end;
  55.              if  ADOQuery1.RecordCount=0 then
  56.                  MessageDlg('用户不存在!!',mtWarning,[mbok],0)
  57.              else
  58.                 begin
  59.                     if adminPsw=ADOQuery1.Fields[1] then
  60.                       begin
  61.                           MessageDlg('您已经成功登录系统!!',mtInfomation,mbok);
  62.                           form4.show;
  63.                           form1.Edit1:='';
  64.                           form1.Edit2:='';
  65.                       end;
  66.                     else
  67.                       MessageDlg('密码有误!!',mtWarning,[mbok],0);
  68.                 end;
  69.         end;
  70. end;
  71. end.