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

📄 form1.cs

📁 招聘考试成绩管理系统,自己做的,C#的,我的软件工程作业
💻 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 + -