?? login.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace CJGL
{
/// <summary>
/// Form1 的摘要說明。
/// </summary>
public class Login : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ComboBox Uname;
private System.Windows.Forms.TextBox UPWD;
private System.Windows.Forms.ComboBox ULogin;
private System.Windows.Forms.Button newLogin;
/// <summary>
/// 必需的設(shè)計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public Login()
{
//
// Windows 窗體設(shè)計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設(shè)計器生成的代碼
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Login));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.Uname = new System.Windows.Forms.ComboBox();
this.UPWD = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.ULogin = new System.Windows.Forms.ComboBox();
this.button3 = new System.Windows.Forms.Button();
this.newLogin = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(352, 50);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 64);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 23);
this.label1.TabIndex = 1;
this.label1.Text = "登錄帳號:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 96);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 2;
this.label2.Text = "登錄密碼:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// Uname
//
this.Uname.Location = new System.Drawing.Point(120, 64);
this.Uname.Name = "Uname";
this.Uname.Size = new System.Drawing.Size(144, 20);
this.Uname.TabIndex = 0;
//
// UPWD
//
this.UPWD.Location = new System.Drawing.Point(120, 96);
this.UPWD.Name = "UPWD";
this.UPWD.PasswordChar = '*';
this.UPWD.Size = new System.Drawing.Size(144, 21);
this.UPWD.TabIndex = 4;
this.UPWD.Text = "";
//
// label3
//
this.label3.Location = new System.Drawing.Point(32, 128);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 23);
this.label3.TabIndex = 7;
this.label3.Text = "登錄模式:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// ULogin
//
this.ULogin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.ULogin.Items.AddRange(new object[] {
"學(xué)生用戶登錄",
"系統(tǒng)管理員登錄"});
this.ULogin.Location = new System.Drawing.Point(120, 128);
this.ULogin.Name = "ULogin";
this.ULogin.Size = new System.Drawing.Size(144, 20);
this.ULogin.TabIndex = 5;
//
// button3
//
this.button3.Location = new System.Drawing.Point(140, 160);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(70, 22);
this.button3.TabIndex = 10;
this.button3.Text = "取消";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// newLogin
//
this.newLogin.Location = new System.Drawing.Point(248, 160);
this.newLogin.Name = "newLogin";
this.newLogin.Size = new System.Drawing.Size(70, 22);
this.newLogin.TabIndex = 11;
this.newLogin.Text = "注冊";
this.newLogin.Click += new System.EventHandler(this.button4_Click);
//
// button2
//
this.button2.BackColor = System.Drawing.Color.WhiteSmoke;
this.button2.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.button2.Location = new System.Drawing.Point(32, 160);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(70, 22);
this.button2.TabIndex = 6;
this.button2.Text = "登錄";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Login
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(235)), ((System.Byte)(246)), ((System.Byte)(255)));
this.ClientSize = new System.Drawing.Size(350, 191);
this.Controls.Add(this.newLogin);
this.Controls.Add(this.button3);
this.Controls.Add(this.ULogin);
this.Controls.Add(this.label3);
this.Controls.Add(this.button2);
this.Controls.Add(this.UPWD);
this.Controls.Add(this.Uname);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(360, 220);
this.MinimumSize = new System.Drawing.Size(360, 220);
this.Name = "Login";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "用戶登錄";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 應(yīng)用程序的主入口點。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Login());
}
private void Form1_Load(object sender, System.EventArgs e)
{
this.ULogin.SelectedIndex=0;
}
private void button3_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void button2_Click(object sender, System.EventArgs e)
{
string username,password,logintype;
if (Uname.Text.Trim()!=""&&UPWD.Text.Trim()!=""&&ULogin.Text.Trim()!="")
{
username=Uname.Text.Trim();
password=UPWD.Text.Trim();
logintype=ULogin.Text.Trim();
DataAccess data=new DataAccess();
if (logintype=="系統(tǒng)管理員登錄")
{
if (data.CheckAdmin(username,password))
{
WinMain winmain=new WinMain();
winmain.user="管理員";
winmain.Show();
}
else
{
MessageBox.Show("您輸入的帳號或密碼有誤,請重新登錄!");
}
}
else
{
if (data.CheckUser(username,password))
{
WinMain winmain=new WinMain();
winmain.user="學(xué)生";
winmain.Show();
}
else
{
MessageBox.Show("您輸入的帳號或密碼有誤,請重新登錄!");
}
}
}
else
MessageBox.Show("請輸入或選擇您的用戶帳號和密碼后進行登錄");
}
private void pictureBox1_Click(object sender, System.EventArgs e)
{
}
private void button4_Click(object sender, System.EventArgs e)
{
WinNewUser winnewuser =new WinNewUser();
winnewuser.Show();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -