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

📄 frmstudentinfo.cs

📁 学生类:Student 教师类:Teacher 主任:AdminTeacher 班主任:MasterTeacher 授课老师: PrelectTeacher 班级类:classTeam 班
💻 CS
📖 第 1 页 / 共 2 页
字号:
															  "畲族",
															  "高山族",
															  "拉祜族",
															  "水族",
															  "东乡族",
															  "纳西族",
															  "景颇族",
															  "柯尔克孜族",
															  "土族",
															  "达斡尔族",
															  "仫佬族",
															  "羌族",
															  "布朗族",
															  "撒拉族",
															  "毛南族",
															  "仡佬族",
															  "锡伯族",
															  "阿昌族",
															  "普米族",
															  "塔吉克族",
															  "怒族",
															  "乌孜别克族",
															  "俄罗斯族",
															  "鄂温克族",
															  "德昂族",
															  "保安族",
															  "裕固族",
															  "京族",
															  "塔塔尔族",
															  "独龙族",
															  "鄂伦春族",
															  "赫哲族",
															  "门巴族",
															  "珞巴族",
															  "基诺族",
															  ""});
			this.cboStuNation.Location = new System.Drawing.Point(104, 192);
			this.cboStuNation.Name = "cboStuNation";
			this.cboStuNation.Size = new System.Drawing.Size(168, 20);
			this.cboStuNation.TabIndex = 28;
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.radFemale);
			this.groupBox1.Controls.Add(this.radMale);
			this.groupBox1.Location = new System.Drawing.Point(104, 72);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(168, 48);
			this.groupBox1.TabIndex = 31;
			this.groupBox1.TabStop = false;
			// 
			// radFemale
			// 
			this.radFemale.Location = new System.Drawing.Point(80, 16);
			this.radFemale.Name = "radFemale";
			this.radFemale.Size = new System.Drawing.Size(48, 24);
			this.radFemale.TabIndex = 25;
			this.radFemale.Text = "女";
			// 
			// radMale
			// 
			this.radMale.Checked = true;
			this.radMale.Location = new System.Drawing.Point(16, 16);
			this.radMale.Name = "radMale";
			this.radMale.Size = new System.Drawing.Size(48, 24);
			this.radMale.TabIndex = 24;
			this.radMale.TabStop = true;
			this.radMale.Text = "男";
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.radNo);
			this.groupBox2.Controls.Add(this.radYes);
			this.groupBox2.Location = new System.Drawing.Point(384, 140);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(168, 48);
			this.groupBox2.TabIndex = 32;
			this.groupBox2.TabStop = false;
			// 
			// radNo
			// 
			this.radNo.Location = new System.Drawing.Point(80, 16);
			this.radNo.Name = "radNo";
			this.radNo.Size = new System.Drawing.Size(48, 24);
			this.radNo.TabIndex = 25;
			this.radNo.Text = "否";
			// 
			// radYes
			// 
			this.radYes.Checked = true;
			this.radYes.Location = new System.Drawing.Point(16, 16);
			this.radYes.Name = "radYes";
			this.radYes.Size = new System.Drawing.Size(48, 24);
			this.radYes.TabIndex = 24;
			this.radYes.TabStop = true;
			this.radYes.Text = "是";
			// 
			// lblStudentID
			// 
			this.lblStudentID.AutoSize = true;
			this.lblStudentID.Location = new System.Drawing.Point(24, 10);
			this.lblStudentID.Name = "lblStudentID";
			this.lblStudentID.Size = new System.Drawing.Size(72, 17);
			this.lblStudentID.TabIndex = 33;
			this.lblStudentID.Text = "学员编号: ";
			// 
			// lblStuID
			// 
			this.lblStuID.AutoSize = true;
			this.lblStuID.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.lblStuID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.lblStuID.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblStuID.Location = new System.Drawing.Point(104, 8);
			this.lblStuID.Name = "lblStuID";
			this.lblStuID.Size = new System.Drawing.Size(86, 22);
			this.lblStuID.TabIndex = 34;
			this.lblStuID.Text = "学员编号: ";
			// 
			// frmStudentInfo
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(568, 325);
			this.Controls.Add(this.lblStuID);
			this.Controls.Add(this.lblStudentID);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.cboStuNation);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.txtStuRemark);
			this.Controls.Add(this.txtStuGrade3);
			this.Controls.Add(this.txtStuGrade2);
			this.Controls.Add(this.txtStuGrade1);
			this.Controls.Add(this.txtStuPostcode);
			this.Controls.Add(this.txtStuAddress);
			this.Controls.Add(this.txtStuTelephone);
			this.Controls.Add(this.txtStuOrigin);
			this.Controls.Add(this.txtStuName);
			this.Controls.Add(this.lblStuRemark);
			this.Controls.Add(this.lblStuAt_School);
			this.Controls.Add(this.lblStuGrade3);
			this.Controls.Add(this.lblStuGrade2);
			this.Controls.Add(this.lblStuGrade1);
			this.Controls.Add(this.lblPostcode);
			this.Controls.Add(this.lblStuAddress);
			this.Controls.Add(this.lblStuTelephone);
			this.Controls.Add(this.lblStuNation);
			this.Controls.Add(this.lblStuOrigin);
			this.Controls.Add(this.lblStuSex);
			this.Controls.Add(this.lblSutName);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.Name = "frmStudentInfo";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "添加学生基本信息";
			this.Load += new System.EventHandler(this.frmStudentInfo_Load);
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		//窗体加载事件
		private void frmStudentInfo_Load(object sender, System.EventArgs e)
		{
			if(stuID == 10001)
			{
				if(Ateacher != null)
				{
					lblStuID.Text = Ateacher.GetNewStuId().ToString();
				}
				else
				{
					lblStuID.Text = Mteacher.GetNewStuId().ToString();
				}
				cboStuNation.SelectedIndex = 0;
				return;
			}
			this.Text = "修改学员信息";
			lblStuID.Text = stuID.ToString();
			//建立学员实体
			student = new Student(stuID);
			TakeStudentInfo();
		}

		//订阅“邮递员”
		private void Post_EventSendStudentInfo(object obj,object teacher,string formName)
		{
			stuID = (int)obj;
			if(teacher.GetType().ToString().Equals("BusinessRule.AdminTeacher"))
			{
				this.Ateacher = (AdminTeacher)teacher;
			}
			else if(teacher.GetType().ToString().Equals("BusinessRule.MasterTeacher"))
			{
				this.Mteacher = (MasterTeacher)teacher;
			}
			else
			{
				this.Pteacher = (PrelectTeacher)teacher;
			}
			Post.EventSendLoginedID -= new DataAccess.Post.SendMsgDelegate(Post_EventSendStudentInfo);
		}

		//获得实例化好的用户实例
		public Teacher User
		{
			get
			{
				if(Ateacher != null)
				{
					return Ateacher;
				}
				else if(Mteacher != null)
				{
					return Mteacher;
				}
				else
				{
					return Pteacher;
				}
			}
		}

		//根据学员实体为控件赋值
		private void TakeStudentInfo()
		{
			txtStuName.Text = student.StuName;
			if(student.StuSex)
			{
				radFemale.Checked = true;
			}
			else
			{
				radMale.Checked = true;
			}
			txtStuOrigin.Text = student.StuOrigin;
			cboStuNation.Text = student.StuNation;
			txtStuTelephone.Text = student.StuTelephone;
			txtStuAddress.Text = student.StuTelephone;
			txtStuPostcode.Text = student.StuPostcode;
			if(!student.StuGrade1.Equals("0000"))
			{
				txtStuGrade1.Text = student.StuGrade1;
			}
			if(!student.StuGrade2.Equals("0000"))
			{
				txtStuGrade2.Text = student.StuGrade2;
			}
			if(!student.StuGrade3.Equals("0000"))
			{
				txtStuGrade3.Text = student.StuGrade3;
			}
			if(student.StuAt_School)
			{
				radYes.Checked = true;
			}
			else
			{
				radNo.Checked = true;
			}
			txtStuRemark.Text = student.StuRemark;
		}

		//根据控件内容,修改学生实例
		private void SetStudentInfo()
		{
			student.StuName = txtStuName.Text.Trim();
			student.StuSex = (radMale.Checked)? false : true;
			student.StuOrigin = txtStuOrigin.Text.Trim();
			student.StuNation = cboStuNation.Text;
			student.StuTelephone = txtStuTelephone.Text.Trim();
			student.StuAddress = txtStuAddress.Text.Trim();
			student.StuPostcode = txtStuPostcode.Text.Trim();
			if(txtStuGrade1.Text.Trim().Equals(""))
			{
				student.StuGrade1 = "0000";
			}
			else
			{
				student.StuGrade1 = txtStuGrade1.Text.Trim();
			}
			if(txtStuGrade2.Text.Trim().Equals(""))
			{
				student.StuGrade2 = "0000";
			}
			else
			{
				student.StuGrade2 = txtStuGrade2.Text.Trim();
			}
			if(txtStuGrade3.Text.Trim().Equals(""))
			{
				student.StuGrade3 = "0000";
			}
			else
			{
				student.StuGrade3 = txtStuGrade3.Text.Trim();
			}
			student.StuAt_School = (radYes.Checked)? true : false;
			student.StuRemark = txtStuRemark.Text.Trim();
		}

		//添加按键
		private void btnAdd_Click(object sender, System.EventArgs e)
		{
			if(student == null)
			{
				student = new Student();
			}
			SetStudentInfo();
			try
			{
				if(Ateacher!= null)
				{
					if(student.StuID == 0)
					{
						Ateacher.InsertStudentInfo(student);
					}
					else
					{
						Ateacher.UpdateStudentInfo(student);
					}
				}
				else
				{
					if(student.StuID == 0)
					{
						Mteacher.InsertStudentInfo(student);
					}
					else
					{
						Mteacher.UpdateStudentInfo(student);
					}
				}
				MessageBox.Show("学员信息已被成功写入数据库!","成功",MessageBoxButtons.OK,MessageBoxIcon.Information);	
				this.Close();
			}
			catch(Exception ex)
			{
				MessageBox.Show("添加失败!\n\n" + ex.Message,"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}			
		}

		
		//取消按键
		private void btnExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

	}
}

⌨️ 快捷键说明

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