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

📄 frmaddspec.cs

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

namespace prjClass
{
	/// <summary>
	/// frmAddSpec 的摘要说明。
	/// </summary>
	public class frmAddSpec : 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 txtName;
		private System.Windows.Forms.TextBox txtStatus;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancle;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmAddSpec()
		{
			//
			// 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.txtName = new System.Windows.Forms.TextBox();
			this.txtStatus = new System.Windows.Forms.TextBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancle = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(144, 24);
			this.label1.Name = "label1";
			this.label1.TabIndex = 0;
			this.label1.Text = "添加专业";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 23);
			this.label2.TabIndex = 1;
			this.label2.Text = "专业名称";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(24, 112);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(72, 23);
			this.label3.TabIndex = 2;
			this.label3.Text = "专业描述";
			// 
			// txtName
			// 
			this.txtName.Location = new System.Drawing.Point(96, 64);
			this.txtName.Name = "txtName";
			this.txtName.Size = new System.Drawing.Size(256, 21);
			this.txtName.TabIndex = 3;
			this.txtName.Text = "";
			// 
			// txtStatus
			// 
			this.txtStatus.Location = new System.Drawing.Point(96, 112);
			this.txtStatus.Multiline = true;
			this.txtStatus.Name = "txtStatus";
			this.txtStatus.Size = new System.Drawing.Size(256, 80);
			this.txtStatus.TabIndex = 4;
			this.txtStatus.Text = "";
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(64, 216);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 5;
			this.btnOK.Text = "确定";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancle
			// 
			this.btnCancle.Location = new System.Drawing.Point(256, 216);
			this.btnCancle.Name = "btnCancle";
			this.btnCancle.TabIndex = 6;
			this.btnCancle.Text = "取消";
			this.btnCancle.Click += new System.EventHandler(this.btnCancle_Click);
			// 
			// frmAddSpec
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(394, 267);
			this.Controls.Add(this.btnCancle);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.txtStatus);
			this.Controls.Add(this.txtName);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "frmAddSpec";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "添加专业";
			this.Load += new System.EventHandler(this.frmAddSpec_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			Class1 c = new Class1();
			string Sql = "select * from Class..SpecialtyInfo where SpecialtyName = '"+this.txtName.Text+"'";
			string SqlAdd = "insert into Class..SpecialtyInfo values ('"+this.txtName.Text+"','"+this.txtStatus.Text+"')";
			if(this.txtName.Text.Trim()==""||this.txtStatus.Text.Trim()=="")
			{
				MessageBox.Show("请输入完整信息!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else if(c.IsExits(Sql)==true)
			{
				MessageBox.Show("该用户名已经存在","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else
			{
				c.EditData(SqlAdd);
				MessageBox.Show("专业添加成功","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Information);
				this.txtName.Text="";
				this.txtStatus.Text="";
			}
		}

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

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

⌨️ 快捷键说明

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