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

📄 form1.cs

📁 学生信息管理系统 欢迎下载!!!!!!
💻 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 Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCN;

		string Scon=@"Integrated Security=SSPI;Initial Catalog=Score_mange;Data Source=.";
		private System.Windows.Forms.Label label3;
		//,Connection Timeout = 120,Max Pool Size = 5
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// 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.textBox1 = new System.Windows.Forms.TextBox();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCN = new System.Windows.Forms.Button();
			this.label3 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("楷体_GB2312", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.ForeColor = System.Drawing.SystemColors.InfoText;
			this.label1.Location = new System.Drawing.Point(120, 160);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(136, 40);
			this.label1.TabIndex = 0;
			this.label1.Text = "用户名:";
			// 
			// label2
			// 
			this.label2.Font = new System.Drawing.Font("楷体_GB2312", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label2.ForeColor = System.Drawing.SystemColors.InfoText;
			this.label2.Location = new System.Drawing.Point(120, 224);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(112, 40);
			this.label2.TabIndex = 1;
			this.label2.Text = "密  码:";
			// 
			// textBox1
			// 
			this.textBox1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.textBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.textBox1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(192)));
			this.textBox1.Location = new System.Drawing.Point(296, 168);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(120, 30);
			this.textBox1.TabIndex = 2;
			this.textBox1.Text = "";
			// 
			// textBox2
			// 
			this.textBox2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.textBox2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.textBox2.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(192)));
			this.textBox2.Location = new System.Drawing.Point(296, 232);
			this.textBox2.Name = "textBox2";
			this.textBox2.PasswordChar = '*';
			this.textBox2.Size = new System.Drawing.Size(120, 30);
			this.textBox2.TabIndex = 3;
			this.textBox2.Text = "";
			// 
			// btnOK
			// 
			this.btnOK.Font = new System.Drawing.Font("楷体_GB2312", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnOK.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(192)));
			this.btnOK.Location = new System.Drawing.Point(144, 280);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(96, 48);
			this.btnOK.TabIndex = 4;
			this.btnOK.Text = "确定";
			this.btnOK.Click += new System.EventHandler(this.button1_Click);
			// 
			// btnCN
			// 
			this.btnCN.Font = new System.Drawing.Font("楷体_GB2312", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnCN.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(192)));
			this.btnCN.Location = new System.Drawing.Point(296, 280);
			this.btnCN.Name = "btnCN";
			this.btnCN.Size = new System.Drawing.Size(96, 48);
			this.btnCN.TabIndex = 5;
			this.btnCN.Text = "退出";
			this.btnCN.Click += new System.EventHandler(this.btnCN_Click);
			// 
			// label3
			// 
			this.label3.Font = new System.Drawing.Font("华文彩云", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label3.ForeColor = System.Drawing.Color.Navy;
			this.label3.Location = new System.Drawing.Point(40, 56);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(472, 48);
			this.label3.TabIndex = 6;
			this.label3.Text = "学生成绩管理系统_登陆";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
			this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.ClientSize = new System.Drawing.Size(552, 359);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.btnCN);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "Form1";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "学生成绩管理系统欢迎你!";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		/// 
		
		public static string user_name,user_level;
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			if(this.textBox1.Text=="")
			{
				MessageBox.Show("用户名不能为空");
				this.textBox1.Focus();
				return;
			}
			else if(this.textBox2.Text=="")
			{
				MessageBox.Show("密码不能为空");
				this.textBox2.Focus();
				return;
			}
			else
			{
				string commandstring=@"select * from operator where Op_user = '"+this.textBox1.Text.Trim()+"' and Op_password = '"+this.textBox2.Text.Trim()+"' ";
				SqlDataAdapter sql=new SqlDataAdapter(commandstring,Scon);
				DataSet ds=new DataSet();
				try
				{
					sql.Fill(ds,"operator");

				}
				catch(Exception e1)
				{
				MessageBox.Show(e1.Message);
				}
				int h = ds.Tables[0].Rows.Count;
				if(h==0)
				{
					MessageBox.Show("用户名和密码错误,请重新输入");
					textBox1.Text=this.textBox2.Text="";
					textBox1.Focus();
					return;
				}
				else
				{
					user_name = ds.Tables[0].Rows[0][2].ToString();
					user_level = ds.Tables[0].Rows[0][4].ToString();
				    Main_info mi = new Main_info();
					this.Hide();
					mi.Show();

				}
	        }
		
		}

		private void btnCN_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
		
		}
	}
}

⌨️ 快捷键说明

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