⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginform.pas

📁 《Delphi 2005数据库系统开发与应用》源代码
💻 PAS
字号:
unit loginForm;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, Borland.Data.Provider,MainForm;

type
  FrmLogin = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    /// <summary>
    /// Required designer variable.
    /// </summary>
    Components: System.ComponentModel.Container;
    Label1: System.Windows.Forms.Label;
    Label2: System.Windows.Forms.Label;
    Label3: System.Windows.Forms.Label;
    Label4: System.Windows.Forms.Label;
    TxtUserName: System.Windows.Forms.TextBox;
    TxtUserPassword: System.Windows.Forms.TextBox;
    BtOK: System.Windows.Forms.Button;
    BtCancel: System.Windows.Forms.Button;
    BdpConnection1: Borland.Data.Provider.BdpConnection;
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure InitializeComponent;
    procedure BtCancel_Click(sender: System.Object; e: System.EventArgs);
    procedure BtOK_Click(sender: System.Object; e: System.EventArgs);
  {$ENDREGION}
  strict protected
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    procedure Dispose(Disposing: Boolean); override;
  private
    { Private Declarations }
  public
    constructor Create;
  end;

  [assembly: RuntimeRequiredAttribute(TypeOf(FrmLogin))]

implementation

{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure FrmLogin.InitializeComponent;
begin
  Self.Label1 := System.Windows.Forms.Label.Create;
  Self.Label2 := System.Windows.Forms.Label.Create;
  Self.Label3 := System.Windows.Forms.Label.Create;
  Self.Label4 := System.Windows.Forms.Label.Create;
  Self.TxtUserName := System.Windows.Forms.TextBox.Create;
  Self.TxtUserPassword := System.Windows.Forms.TextBox.Create;
  Self.BtOK := System.Windows.Forms.Button.Create;
  Self.BtCancel := System.Windows.Forms.Button.Create;
  Self.BdpConnection1 := Borland.Data.Provider.BdpConnection.Create;
  Self.SuspendLayout;
  // 
  // Label1
  // 
  Self.Label1.Font := System.Drawing.Font.Create('华文彩云', 26.25, System.Drawing.FontStyle.Bold, 
      System.Drawing.GraphicsUnit.Point, (Byte(134)));
  Self.Label1.ForeColor := System.Drawing.SystemColors.ActiveCaption;
  Self.Label1.Location := System.Drawing.Point.Create(16, 24);
  Self.Label1.Name := 'Label1';
  Self.Label1.Size := System.Drawing.Size.Create(248, 56);
  Self.Label1.TabIndex := 0;
  Self.Label1.Text := '教务信息系统';
  Self.Label1.TextAlign := System.Drawing.ContentAlignment.MiddleCenter;
  // 
  // Label2
  // 
  Self.Label2.Location := System.Drawing.Point.Create(24, 104);
  Self.Label2.Name := 'Label2';
  Self.Label2.Size := System.Drawing.Size.Create(72, 23);
  Self.Label2.TabIndex := 1;
  Self.Label2.Text := '用户名';
  Self.Label2.TextAlign := System.Drawing.ContentAlignment.MiddleCenter;
  // 
  // Label3
  // 
  Self.Label3.Location := System.Drawing.Point.Create(24, 152);
  Self.Label3.Name := 'Label3';
  Self.Label3.Size := System.Drawing.Size.Create(72, 23);
  Self.Label3.TabIndex := 3;
  Self.Label3.Text := '密码';
  Self.Label3.TextAlign := System.Drawing.ContentAlignment.MiddleCenter;
  // 
  // Label4
  // 
  Self.Label4.Font := System.Drawing.Font.Create('宋体', 12, System.Drawing.FontStyle.Bold, 
      System.Drawing.GraphicsUnit.Point, (Byte(134)));
  Self.Label4.Location := System.Drawing.Point.Create(16, 224);
  Self.Label4.Name := 'Label4';
  Self.Label4.Size := System.Drawing.Size.Create(256, 32);
  Self.Label4.TabIndex := 4;
  Self.Label4.Text := '版权所有:';
  Self.Label4.TextAlign := System.Drawing.ContentAlignment.MiddleCenter;
  // 
  // TxtUserName
  // 
  Self.TxtUserName.Location := System.Drawing.Point.Create(112, 104);
  Self.TxtUserName.Name := 'TxtUserName';
  Self.TxtUserName.Size := System.Drawing.Size.Create(144, 21);
  Self.TxtUserName.TabIndex := 5;
  Self.TxtUserName.Text := '';
  // 
  // TxtUserPassword
  // 
  Self.TxtUserPassword.Location := System.Drawing.Point.Create(112, 152);
  Self.TxtUserPassword.Name := 'TxtUserPassword';
  Self.TxtUserPassword.PasswordChar := '*';
  Self.TxtUserPassword.Size := System.Drawing.Size.Create(144, 21);
  Self.TxtUserPassword.TabIndex := 6;
  Self.TxtUserPassword.Text := '';
  // 
  // BtOK
  // 
  Self.BtOK.Location := System.Drawing.Point.Create(40, 192);
  Self.BtOK.Name := 'BtOK';
  Self.BtOK.TabIndex := 8;
  Self.BtOK.Text := '确定';
  Include(Self.BtOK.Click, Self.BtOK_Click);
  // 
  // BtCancel
  // 
  Self.BtCancel.Location := System.Drawing.Point.Create(152, 192);
  Self.BtCancel.Name := 'BtCancel';
  Self.BtCancel.TabIndex := 9;
  Self.BtCancel.Text := '取消';
  Include(Self.BtCancel.Click, Self.BtCancel_Click);
  // 
  // BdpConnection1
  // 
  Self.BdpConnection1.ConnectionOptions := 'transaction isolation=ReadCommitted;blob size=1024';
  Self.BdpConnection1.ConnectionString := 'assembly=Borland.Data.Mssql,Version=1.5.0.0,Culture=neutral,PublicKeyToken=91d6'+ 
  '2ebb5b0d1b1b;vendorclient=sqloledb.dll;database=教务信息管理系统;username=sa;hostname='+ 
  'storm;password=sa;provider=MSSQL';
  // 
  // FrmLogin
  // 
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
  Self.ClientSize := System.Drawing.Size.Create(292, 262);
  Self.Controls.Add(Self.BtCancel);
  Self.Controls.Add(Self.BtOK);
  Self.Controls.Add(Self.TxtUserPassword);
  Self.Controls.Add(Self.TxtUserName);
  Self.Controls.Add(Self.Label4);
  Self.Controls.Add(Self.Label3);
  Self.Controls.Add(Self.Label2);
  Self.Controls.Add(Self.Label1);
  Self.Name := 'FrmLogin';
  Self.Text := '登陆';
  Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure FrmLogin.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor FrmLogin.Create;
begin
  inherited Create;
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent;
  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

procedure FrmLogin.BtOK_Click(sender: System.Object; e: System.EventArgs);
var
    slc:string;
    cmd:BdpCommand;
    dr:Borland.Data.Provider.BdpDataReader;
    newFrmMain:FrmMain;
begin
    slc:='Select * From user_Info Where user_ID='+''''+TxtUserName.Text+'''';
    cmd:=BdpCommand.Create(slc,bdpConnection1);
    newFrmMain:=FrmMain.Create ;
    bdpConnection1.Open;
    dr:=cmd.ExecuteReader;
    if dr.Read then
    begin
      if dr[1].ToString =TxtUserPassword.Text then
      begin
        newFrmMain.Show;
        self.Hide;
      end;
    end
    else
    begin
      bdpConnection1.Close;
      MessageBox.Show('没有该用户或输入的密码错误');
    end;
end;

procedure FrmLogin.BtCancel_Click(sender: System.Object; e: System.EventArgs);
begin
    Application.Exit;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -