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

📄 addform.cs

📁 基于SQL CE存储数据的学生信息管理系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace StudInfo
{
	/// <summary>
	/// AddForm 的摘要说明。
	/// </summary>
	public class AddForm : 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.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		public System.Windows.Forms.TextBox textBox1;
		public System.Windows.Forms.TextBox textBox2;
		public System.Windows.Forms.NumericUpDown numericUpDown1;
		public System.Windows.Forms.ComboBox comboBox1;
		private Microsoft.WindowsCE.Forms.InputPanel inputPanel1;
		public System.Windows.Forms.ComboBox comboBox2;
	
		public AddForm()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			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.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.comboBox2 = new System.Windows.Forms.ComboBox();
			this.inputPanel1 = new Microsoft.WindowsCE.Forms.InputPanel();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 9);
			this.label1.Size = new System.Drawing.Size(40, 24);
			this.label1.Text = "学号";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(16, 41);
			this.label2.Size = new System.Drawing.Size(32, 24);
			this.label2.Text = "姓名";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(16, 71);
			this.label3.Size = new System.Drawing.Size(40, 24);
			this.label3.Text = "性别";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(16, 103);
			this.label4.Size = new System.Drawing.Size(40, 16);
			this.label4.Text = "年龄";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(16, 137);
			this.label5.Size = new System.Drawing.Size(48, 24);
			this.label5.Text = "系部";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(24, 170);
			this.button1.Size = new System.Drawing.Size(79, 30);
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(126, 170);
			this.button2.Size = new System.Drawing.Size(79, 30);
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(72, 9);
			this.textBox1.Size = new System.Drawing.Size(144, 21);
			this.textBox1.Text = "";
			this.textBox1.LostFocus += new System.EventHandler(this.bookInfo_LostFocus);
			this.textBox1.GotFocus += new System.EventHandler(this.bookInfo_GotFocus);
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(72, 39);
			this.textBox2.Size = new System.Drawing.Size(144, 21);
			this.textBox2.Text = "";
			this.textBox2.LostFocus += new System.EventHandler(this.bookInfo_LostFocus);
			this.textBox2.GotFocus += new System.EventHandler(this.bookInfo_GotFocus);
			// 
			// numericUpDown1
			// 
			this.numericUpDown1.Location = new System.Drawing.Point(72, 98);
			this.numericUpDown1.Maximum = new System.Decimal(new int[] {
																		   45,
																		   0,
																		   0,
																		   0});
			this.numericUpDown1.Minimum = new System.Decimal(new int[] {
																		   15,
																		   0,
																		   0,
																		   0});
			this.numericUpDown1.Size = new System.Drawing.Size(56, 21);
			this.numericUpDown1.Value = new System.Decimal(new int[] {
																		 15,
																		 0,
																		 0,
																		 0});
			// 
			// comboBox1
			// 
			this.comboBox1.Items.Add("男");
			this.comboBox1.Items.Add("女");
			this.comboBox1.Location = new System.Drawing.Point(72, 69);
			this.comboBox1.Size = new System.Drawing.Size(56, 20);
			// 
			// comboBox2
			// 
			this.comboBox2.Items.Add("计算机系");
			this.comboBox2.Items.Add("英语系");
			this.comboBox2.Items.Add("艺术系");
			this.comboBox2.Items.Add("管理系");
			this.comboBox2.Items.Add("机电系");
			this.comboBox2.Items.Add("园艺系");
			this.comboBox2.Items.Add("中文系");
			this.comboBox2.Location = new System.Drawing.Point(72, 128);
			this.comboBox2.Size = new System.Drawing.Size(144, 20);
			// 
			// AddForm
			// 
			this.ClientSize = new System.Drawing.Size(234, 215);
			this.Controls.Add(this.comboBox2);
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.numericUpDown1);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			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.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Text = "添加学生";

		}
		#endregion


		private void button1_Click(object sender, System.EventArgs e)
		{
			if ((textBox1.Text.ToString()=="")||(textBox1.Text.ToString()==""))
			{
				MessageBox.Show("学号或姓名不能为空!","错误",MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
				
			}
			else if ((comboBox1.Text.ToString()=="")||(comboBox2.Text.ToString()==""))
			{
				MessageBox.Show("性别或系部不能为空!","错误",MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
				
			}
			else
				this.DialogResult = DialogResult.OK;
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
		}
		private void bookInfo_GotFocus(object sender, System.EventArgs e)
		{
			inputPanel1.Enabled = true;
		}

		private void bookInfo_LostFocus(object sender, System.EventArgs e)
		{
			inputPanel1.Enabled = false;
		}
	}
}

⌨️ 快捷键说明

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