?? form1.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 招聘考試成績管理系統
{
/// <summary>
/// Form1 的摘要說明。
/// </summary>
public class login_fm : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox nameBox;
private System.Windows.Forms.TextBox pwdBox;
private System.Windows.Forms.Button okbutton;
private System.Windows.Forms.Button closebutton;
/// <summary>
/// 必需的設計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public login_fm()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.nameBox = new System.Windows.Forms.TextBox();
this.pwdBox = new System.Windows.Forms.TextBox();
this.okbutton = new System.Windows.Forms.Button();
this.closebutton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("宋體", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Location = new System.Drawing.Point(24, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(248, 32);
this.label1.TabIndex = 0;
this.label1.Text = "招聘考試成績管理系統登錄";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(24, 72);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 23);
this.label2.TabIndex = 1;
this.label2.Text = "用戶名:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label3
//
this.label3.Location = new System.Drawing.Point(24, 120);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 23);
this.label3.TabIndex = 2;
this.label3.Text = "密碼:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// nameBox
//
this.nameBox.Location = new System.Drawing.Point(120, 72);
this.nameBox.Name = "nameBox";
this.nameBox.TabIndex = 3;
this.nameBox.Text = "";
//
// pwdBox
//
this.pwdBox.Location = new System.Drawing.Point(120, 120);
this.pwdBox.Name = "pwdBox";
this.pwdBox.PasswordChar = '*';
this.pwdBox.TabIndex = 4;
this.pwdBox.Text = "";
//
// okbutton
//
this.okbutton.Location = new System.Drawing.Point(48, 168);
this.okbutton.Name = "okbutton";
this.okbutton.TabIndex = 5;
this.okbutton.Text = "登錄";
this.okbutton.Click += new System.EventHandler(this.okbutton_Click);
//
// closebutton
//
this.closebutton.Location = new System.Drawing.Point(160, 168);
this.closebutton.Name = "closebutton";
this.closebutton.TabIndex = 6;
this.closebutton.Text = "取消";
this.closebutton.Click += new System.EventHandler(this.closebutton_Click);
//
// login_fm
//
this.AcceptButton = this.okbutton;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(296, 222);
this.Controls.Add(this.closebutton);
this.Controls.Add(this.okbutton);
this.Controls.Add(this.pwdBox);
this.Controls.Add(this.nameBox);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.Name = "login_fm";
this.Text = "招聘考試成績管理系統";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 應用程序的主入口點。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new login_fm());
}
private void closebutton_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void okbutton_Click(object sender, System.EventArgs e)
{
if(nameBox.Text.Trim()=="" ||pwdBox.Text.Trim()=="")
{
MessageBox.Show("請輸入用戶名和密碼");
return;
}
string SQL ="select name from login where name =";
SQL+=nameBox.Text + " and pass = '"+pwdBox.Text.Trim()+"'";
string myConstr ="workstation id=\"GHX-82E19EF0633\";packet size=4096;integrated security=SSPI;data s" +
"ource=\".\";persist security info=False;initial catalog=zhaopin";
SqlCommand myCom= null;
SqlConnection myCon=null;
try
{
myCon =new SqlConnection(myConstr);
myCon.Open();
myCom =new SqlCommand(SQL,myCon);
myCom=new SqlCommand(SQL,myCon);
int power=Convert.ToInt32(myCom.ExecuteScalar());
if(power>0)
{
this.Hide();
Form f1=new main_fm();
f1.Show();
}
}
catch(Exception o)
{
MessageBox.Show(o.Message,"error");
}
finally
{
if(myCon.State==ConnectionState.Open)
myCon.Close();
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -