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

📄 frmupdatespc.cs

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


namespace prjClass
{
	/// <summary>
	/// frmUpdateSpc 的摘要说明。
	/// </summary>
	/// 
	public delegate void UpdatSpeHandler();
	public class frmUpdateSpc : System.Windows.Forms.Form
	{
		private Specialty sp;
		public event UpdatSpeHandler UpdateSpeEvent;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancle;
		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.TextBox txtID;
		private System.Windows.Forms.TextBox txtName;
		private System.Windows.Forms.TextBox txtMemo;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmUpdateSpc(Specialty sp)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			this.sp=sp;

			//
			// 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.btnCancle = new System.Windows.Forms.Button();
			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.txtID = new System.Windows.Forms.TextBox();
			this.txtName = new System.Windows.Forms.TextBox();
			this.txtMemo = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(112, 216);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 0;
			this.btnOK.Text = "确定";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancle
			// 
			this.btnCancle.Location = new System.Drawing.Point(352, 216);
			this.btnCancle.Name = "btnCancle";
			this.btnCancle.TabIndex = 1;
			this.btnCancle.Text = "取消";
			this.btnCancle.Click += new System.EventHandler(this.btnCancle_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(184, 16);
			this.label1.Name = "label1";
			this.label1.TabIndex = 2;
			this.label1.Text = "修改专业信息";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(32, 56);
			this.label2.Name = "label2";
			this.label2.TabIndex = 3;
			this.label2.Text = "专业编号";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(256, 56);
			this.label3.Name = "label3";
			this.label3.TabIndex = 4;
			this.label3.Text = "专业名称";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(32, 120);
			this.label4.Name = "label4";
			this.label4.TabIndex = 5;
			this.label4.Text = "专业描述";
			// 
			// txtID
			// 
			this.txtID.Location = new System.Drawing.Point(96, 56);
			this.txtID.Name = "txtID";
			this.txtID.ReadOnly = true;
			this.txtID.Size = new System.Drawing.Size(136, 21);
			this.txtID.TabIndex = 6;
			this.txtID.Text = "";
			// 
			// txtName
			// 
			this.txtName.Location = new System.Drawing.Point(320, 56);
			this.txtName.Name = "txtName";
			this.txtName.Size = new System.Drawing.Size(136, 21);
			this.txtName.TabIndex = 7;
			this.txtName.Text = "";
			// 
			// txtMemo
			// 
			this.txtMemo.Location = new System.Drawing.Point(96, 120);
			this.txtMemo.Multiline = true;
			this.txtMemo.Name = "txtMemo";
			this.txtMemo.Size = new System.Drawing.Size(360, 70);
			this.txtMemo.TabIndex = 8;
			this.txtMemo.Text = "";
			// 
			// frmUpdateSpc
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(490, 265);
			this.Controls.Add(this.txtMemo);
			this.Controls.Add(this.txtName);
			this.Controls.Add(this.txtID);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.btnCancle);
			this.Controls.Add(this.btnOK);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "frmUpdateSpc";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "修改专业信息";
			this.Load += new System.EventHandler(this.frmUpdateSpc_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmUpdateSpc_Load(object sender, System.EventArgs e)
		{
			this.txtID.Text=sp.ID;
			this.txtName.Text=sp.Name;
			this.txtMemo.Text=sp.Memo;
		}

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

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			Class1 c = new Class1();
			string Sql1 = "select * from Class..SpecialtyInfo where SpecialtyName='"+this.txtName.Text+"' and SpecialtyId <> "+this.txtID.Text+"";
			string Sql = "update Class..SpecialtyInfo set SpecialtyName='"+this.txtName.Text+"',Memo='"+this.txtMemo.Text+"' where SpecialtyId = "+this.txtID.Text+"";
			if(this.txtName.Text.Trim()==""||this.txtMemo.Text.Trim()=="")
			{
				MessageBox.Show("请填写完整信息!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else if(c.IsExits(Sql1)==true)
			{
				MessageBox.Show("该专业已经存在!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else
			{
				c.EditData(Sql);
				if(this.UpdateSpeEvent!=null)
				{
					this.UpdateSpeEvent();
				}
				MessageBox.Show("专业修改成功!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Information);
				this.Close();
			}
		}
	}
}

⌨️ 快捷键说明

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