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

📄 frmeditstu.cs

📁 一个学籍管理系统 以在某高校投入使用了
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace prjClass
{
	/// <summary>
	/// frmAddStu 的摘要说明。
	/// </summary>
	/// 
	public delegate void EditStuHandler();
	public class frmEditStu : System.Windows.Forms.Form
	{
		public event EditStuHandler EditStuEvent;
		private Class1 c = new Class1();
		private StuInfo stu;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.TextBox txtNumber;
		private System.Windows.Forms.TextBox txtTouch;
		private System.Windows.Forms.TextBox txtName;
		private System.Windows.Forms.ComboBox cboRole;
		private System.Windows.Forms.ComboBox cobSex;
		private System.Windows.Forms.TextBox txtPost;
		private System.Windows.Forms.TextBox txtRace;
		private System.Windows.Forms.ComboBox cboSpe;
		private System.Windows.Forms.TextBox txtAddress;
		private System.Windows.Forms.ComboBox cboClass;
		private System.Windows.Forms.TextBox txtMemo;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.Label label10;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Button btnCancle;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmEditStu(StuInfo stu)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			this.stu=stu;

			//
			// 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.btnOK = new System.Windows.Forms.Button();
			this.txtNumber = new System.Windows.Forms.TextBox();
			this.txtTouch = new System.Windows.Forms.TextBox();
			this.txtName = new System.Windows.Forms.TextBox();
			this.cboRole = new System.Windows.Forms.ComboBox();
			this.cobSex = new System.Windows.Forms.ComboBox();
			this.txtPost = new System.Windows.Forms.TextBox();
			this.txtRace = new System.Windows.Forms.TextBox();
			this.cboSpe = new System.Windows.Forms.ComboBox();
			this.txtAddress = new System.Windows.Forms.TextBox();
			this.cboClass = new System.Windows.Forms.ComboBox();
			this.txtMemo = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.label7 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.label9 = new System.Windows.Forms.Label();
			this.label10 = new System.Windows.Forms.Label();
			this.label11 = new System.Windows.Forms.Label();
			this.label12 = new System.Windows.Forms.Label();
			this.btnCancle = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(128, 336);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 0;
			this.btnOK.Text = "确定";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// txtNumber
			// 
			this.txtNumber.Location = new System.Drawing.Point(80, 48);
			this.txtNumber.Name = "txtNumber";
			this.txtNumber.Size = new System.Drawing.Size(168, 21);
			this.txtNumber.TabIndex = 1;
			this.txtNumber.Text = "";
			// 
			// txtTouch
			// 
			this.txtTouch.Location = new System.Drawing.Point(352, 48);
			this.txtTouch.Name = "txtTouch";
			this.txtTouch.Size = new System.Drawing.Size(168, 21);
			this.txtTouch.TabIndex = 2;
			this.txtTouch.Text = "";
			// 
			// txtName
			// 
			this.txtName.Location = new System.Drawing.Point(80, 88);
			this.txtName.Name = "txtName";
			this.txtName.Size = new System.Drawing.Size(168, 21);
			this.txtName.TabIndex = 3;
			this.txtName.Text = "";
			// 
			// cboRole
			// 
			this.cboRole.Location = new System.Drawing.Point(352, 88);
			this.cboRole.Name = "cboRole";
			this.cboRole.Size = new System.Drawing.Size(88, 20);
			this.cboRole.TabIndex = 4;
			this.cboRole.Text = "comboBox1";
			// 
			// cobSex
			// 
			this.cobSex.Location = new System.Drawing.Point(80, 128);
			this.cobSex.Name = "cobSex";
			this.cobSex.Size = new System.Drawing.Size(88, 20);
			this.cobSex.TabIndex = 5;
			this.cobSex.Text = "comboBox2";
			// 
			// txtPost
			// 
			this.txtPost.Location = new System.Drawing.Point(352, 128);
			this.txtPost.Name = "txtPost";
			this.txtPost.Size = new System.Drawing.Size(168, 21);
			this.txtPost.TabIndex = 6;
			this.txtPost.Text = "";
			// 
			// txtRace
			// 
			this.txtRace.Location = new System.Drawing.Point(80, 168);
			this.txtRace.Name = "txtRace";
			this.txtRace.Size = new System.Drawing.Size(168, 21);
			this.txtRace.TabIndex = 7;
			this.txtRace.Text = "";
			// 
			// cboSpe
			// 
			this.cboSpe.Location = new System.Drawing.Point(352, 168);
			this.cboSpe.Name = "cboSpe";
			this.cboSpe.Size = new System.Drawing.Size(168, 20);
			this.cboSpe.TabIndex = 8;
			this.cboSpe.Text = "comboBox3";
			// 
			// txtAddress
			// 
			this.txtAddress.Location = new System.Drawing.Point(80, 208);
			this.txtAddress.Name = "txtAddress";
			this.txtAddress.Size = new System.Drawing.Size(208, 21);
			this.txtAddress.TabIndex = 9;
			this.txtAddress.Text = "";
			// 
			// cboClass
			// 
			this.cboClass.Location = new System.Drawing.Point(352, 208);
			this.cboClass.Name = "cboClass";
			this.cboClass.Size = new System.Drawing.Size(168, 20);
			this.cboClass.TabIndex = 10;
			this.cboClass.Text = "comboBox4";
			// 
			// txtMemo
			// 
			this.txtMemo.Location = new System.Drawing.Point(80, 248);
			this.txtMemo.Multiline = true;
			this.txtMemo.Name = "txtMemo";
			this.txtMemo.Size = new System.Drawing.Size(440, 64);
			this.txtMemo.TabIndex = 11;
			this.txtMemo.Text = "";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(232, 16);
			this.label1.Name = "label1";
			this.label1.TabIndex = 12;
			this.label1.Text = "添加学生信息";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(40, 48);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(32, 23);
			this.label2.TabIndex = 13;
			this.label2.Text = "学号";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(288, 48);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(64, 23);
			this.label3.TabIndex = 14;
			this.label3.Text = "联系方式";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(40, 88);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(32, 23);
			this.label4.TabIndex = 15;
			this.label4.Text = "姓名";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(288, 88);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(64, 23);
			this.label5.TabIndex = 16;
			this.label5.Text = "政治面貌";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(40, 128);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(32, 23);
			this.label6.TabIndex = 17;
			this.label6.Text = "性别";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(288, 128);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(64, 23);
			this.label7.TabIndex = 18;
			this.label7.Text = "邮政编码";
			// 
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(40, 168);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(32, 23);
			this.label8.TabIndex = 19;
			this.label8.Text = "民族";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(312, 168);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(32, 23);
			this.label9.TabIndex = 20;
			this.label9.Text = "专业";
			// 
			// label10
			// 
			this.label10.Location = new System.Drawing.Point(16, 208);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(64, 23);
			this.label10.TabIndex = 21;
			this.label10.Text = "家庭住址";
			// 
			// label11
			// 
			this.label11.Location = new System.Drawing.Point(312, 208);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(32, 23);
			this.label11.TabIndex = 22;
			this.label11.Text = "班级";
			// 
			// label12
			// 
			this.label12.Location = new System.Drawing.Point(40, 248);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(32, 23);
			this.label12.TabIndex = 23;
			this.label12.Text = "备注";
			// 
			// btnCancle
			// 
			this.btnCancle.Location = new System.Drawing.Point(352, 336);
			this.btnCancle.Name = "btnCancle";
			this.btnCancle.TabIndex = 24;
			this.btnCancle.Text = "取消";
			this.btnCancle.Click += new System.EventHandler(this.btnCancle_Click);
			// 
			// frmAddStu
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(570, 383);
			this.Controls.Add(this.btnCancle);
			this.Controls.Add(this.label12);
			this.Controls.Add(this.label11);
			this.Controls.Add(this.label10);
			this.Controls.Add(this.label9);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txtMemo);
			this.Controls.Add(this.cboClass);
			this.Controls.Add(this.txtAddress);
			this.Controls.Add(this.cboSpe);
			this.Controls.Add(this.txtRace);
			this.Controls.Add(this.txtPost);
			this.Controls.Add(this.cobSex);
			this.Controls.Add(this.cboRole);
			this.Controls.Add(this.txtName);
			this.Controls.Add(this.txtTouch);
			this.Controls.Add(this.txtNumber);
			this.Controls.Add(this.btnOK);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "frmAddStu";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "添加学生";
			this.Load += new System.EventHandler(this.frmAddStu_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmAddStu_Load(object sender, System.EventArgs e)
		{
			this.cboRole.Items.Add("团员");
			this.cboRole.Items.Add("党员");
			this.cboRole.Items.Add("无");
			this.cboRole.SelectedIndex=0;

			this.cobSex.Items.Add("男");
			this.cobSex.Items.Add("女");
			this.cobSex.SelectedIndex=0;

			this.txtNumber.Text=stu.StuNumber;
			this.txtTouch.Text=stu.StuTouch;
			this.txtName.Text=stu.StuName;
			this.cboRole.SelectedItem=stu.StuRole;
			this.cobSex.SelectedItem=stu.StuSex;
			this.txtPost.Text=stu.StuPost;
			this.txtRace.Text=stu.StuRace;
			this.cboSpe.Text=stu.StuSpec;
			this.txtAddress.Text=stu.StuArrdess;
			this.cboClass.Text=stu.StuClass;
			this.txtMemo.Text=stu.StuMemo;

			this.cboClass.Enabled=false;
			this.cboSpe.Enabled=false;
			
		}

	

		

		private void btnCancle_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			string Sql = "select * from Class..StudentInfo where StudentNumber = '"+this.txtNumber.Text
				+"' and StudentID <> "+this.stu.StuID+" ";
			if(c.IsExits(Sql)==true)
			{
				MessageBox.Show("学号重复!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else
			{
				string Sql1 = "update Class..StudentInfo set StudentNumber = '"+this.txtNumber.Text
					+"',Telephone = '"+this.txtTouch.Text
					+"',_Name = '"+this.txtName.Text
					+"',Role = '"+this.cboRole.SelectedItem.ToString()
					+"',Sex = '"+this.cobSex.SelectedItem.ToString()
					+"',PostCode = '"+this.txtPost.Text
					+"',Rece = 'de',Address='"+this.txtAddress.Text
					+"',Memo = '"+this.txtMemo.Text+"' where StudentID = "+this.stu.StuID+"";
				c.EditData(Sql1);
				if(this.EditStuEvent!=null)
				{
					this.EditStuEvent();
				}
				this.Close();
			}
		}
	}
}

⌨️ 快捷键说明

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