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

📄 frmstuinfo.cs

📁 一个学籍管理系统 以在某高校投入使用了
💻 CS
📖 第 1 页 / 共 2 页
字号:
				string tableName = "SpecialtyInfo";
				this.cboSpec.DataSource=da.ExecuteDataTable(Sql,tableName);
				this.cboSpec.DisplayMember="SpecialtyName";
				this.cboSpec.SelectedIndex=0;
			}
			else
			{
				this.cboSpec.Items.Add("尚未添加专业");
				this.cboSpec.SelectedIndex=0;
			}
			AddClass();
		}

		private void txtYeay_Leave(object sender, System.EventArgs e)
		{
			if(c.IsYear(this.txtYeay.Text)==false||this.txtYeay.Text.Length!=4)
			{
				MessageBox.Show("请输入正确的年份!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
				this.txtYeay.Focus();
			}
		}

		private void AddClass()
		{
			string Sql = "select * from Class..ClassInfo where SpecialtyName = '"+this.cboSpec.Text+"' and year(BeginTime)='"+this.txtYeay.Text+"' ";
			string tableName = "ClassInfo";
			if(c.IsExits(Sql)==true)
			{
				this.cboClass.DataSource=da.ExecuteDataTable(Sql,tableName);
				this.cboClass.DisplayMember="ClassName";
				this.cboClass.ValueMember="ClassID";
			}
			else
			{
				this.cboClass.Items.Add("尚未创建班级");
			}
			this.cboClass.SelectedIndex=0;
		}

		private void txtYeay_TextChanged(object sender, System.EventArgs e)
		{
			if(this.txtYeay.Text.Length==4&&c.IsYear(this.txtYeay.Text)==true)
			{
				this.cboClass.DataSource=null;
				this.cboClass.Items.Clear();
				AddClass();
			}
		}

		private void cboSpec_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			this.cboClass.DataSource=null;
			this.cboClass.Items.Clear();
			AddClass();
		}

		DataTable dt;
		private void LoadData()
		{
			string Sql1 = "select * from (Class..StudentInfo inner join Class..ClassInfo on Class..StudentInfo.ClassID = Class..ClassInfo.ClassID) where Class..StudentInfo.ClassID = (select ClassID from Class..ClassInfo where ClassName = '"+this.cboClass.Text+"') ";
			string tableName = "StudentInfo";	
			dt = da.ExecuteDataTable(Sql1,tableName);
			this.dataGrid1.DataSource=dt;
			this.dataGrid1.CaptionText="该班级共有"+dt.Rows.Count.ToString()+"位学生";
		}
		private void cboClass_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			LoadData();
		}

		private void btnEdit_Click(object sender, System.EventArgs e)
		{
			if(this.flag==false)
			{
				MessageBox.Show("请选择要修改的学生信息!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else
			{
				frmEditStu f = new frmEditStu(this.stu);
				f.EditStuEvent+=new EditStuHandler(f_EditStuEvent);
				f.ShowDialog();
			}
		}

		private void setDataGridStyle()
		{
			DataGridTableStyle dgs = new DataGridTableStyle();
			dgs.MappingName="StudentInfo";
			this.dataGrid1.TableStyles.Add(dgs);

			DataGridColumnStyle dgs1 = new DataGridTextBoxColumn();
			dgs1.HeaderText="学号";
			dgs1.MappingName="StudentNumber";
			dgs1.Width=100;
			
			DataGridColumnStyle dgs2 = new DataGridTextBoxColumn();
			dgs2.HeaderText="姓名";
			dgs2.MappingName="_Name";
			dgs2.Width=100;

			DataGridColumnStyle dgs3 = new DataGridTextBoxColumn();
			dgs3.HeaderText="性别";
			dgs3.MappingName="Sex";
			dgs3.Width=50;

			DataGridColumnStyle dgs4 = new DataGridTextBoxColumn();
			dgs4.HeaderText="民族";
			dgs4.MappingName="Race";
			dgs4.Width=100;

			DataGridColumnStyle dgs5 = new DataGridTextBoxColumn();
			dgs5.HeaderText="家庭住址";
			dgs5.MappingName="Address";
			dgs5.Width=150;

			DataGridColumnStyle dgs6 = new DataGridTextBoxColumn();
			dgs6.HeaderText="联系方式";
			dgs6.MappingName="Telephone";
			dgs6.Width=100;

			DataGridColumnStyle dgs7 = new DataGridTextBoxColumn();
			dgs7.HeaderText="政治面貌";
			dgs7.MappingName="Role";
			dgs7.Width=100;

			DataGridColumnStyle dgs8 = new DataGridTextBoxColumn();
			dgs8.HeaderText="邮政编码";
			dgs8.MappingName="PostCode";
			dgs8.Width=100;

			DataGridColumnStyle dgs9 = new DataGridTextBoxColumn();
			dgs9.HeaderText="班级名称";
			dgs9.MappingName="ClassName";
			dgs9.Width=150;

			DataGridColumnStyle dgs10 = new DataGridTextBoxColumn();
			dgs10.HeaderText="备注";
			dgs10.MappingName="Memo";
			dgs10.Width=150;

			dgs.GridColumnStyles.Add(dgs1);
			dgs.GridColumnStyles.Add(dgs2);
			dgs.GridColumnStyles.Add(dgs3);
			dgs.GridColumnStyles.Add(dgs4);
			dgs.GridColumnStyles.Add(dgs5);
			dgs.GridColumnStyles.Add(dgs6);
			dgs.GridColumnStyles.Add(dgs7);
			dgs.GridColumnStyles.Add(dgs8);
			dgs.GridColumnStyles.Add(dgs9);
			dgs.GridColumnStyles.Add(dgs10);

		}

		private void dataGrid1_CurrentCellChanged(object sender, EventArgs e)
		{
			if(this.dataGrid1.VisibleRowCount>0)
			{
				stu.StuID=this.dt.Rows[this.dataGrid1.CurrentRowIndex][0].ToString();
				stu.StuNumber=this.dt.Rows[this.dataGrid1.CurrentRowIndex][1].ToString();
				stu.StuName=this.dt.Rows[this.dataGrid1.CurrentRowIndex][2].ToString();
				stu.StuSex=this.dt.Rows[this.dataGrid1.CurrentRowIndex][3].ToString();
				stu.StuRace=this.dt.Rows[this.dataGrid1.CurrentRowIndex][4].ToString();
				stu.StuArrdess=this.dt.Rows[this.dataGrid1.CurrentRowIndex][5].ToString();
				stu.StuTouch=this.dt.Rows[this.dataGrid1.CurrentRowIndex][6].ToString();
				stu.StuRole=this.dt.Rows[this.dataGrid1.CurrentRowIndex][7].ToString();
				stu.StuPost=this.dt.Rows[this.dataGrid1.CurrentRowIndex][8].ToString();
				stu.StuMemo=this.dt.Rows[this.dataGrid1.CurrentRowIndex][10].ToString();
				stu.StuClass=this.dt.Rows[this.dataGrid1.CurrentRowIndex][12].ToString();
				stu.StuSpec=this.dt.Rows[this.dataGrid1.CurrentRowIndex][13].ToString();
				this.flag=true;
			}
		}

		private void dataGrid1_GotFocus(object sender, EventArgs e)
		{
			if(this.dataGrid1.VisibleRowCount>0)
			{
				stu.StuID=this.dt.Rows[this.dataGrid1.CurrentRowIndex][0].ToString();
				stu.StuNumber=this.dt.Rows[this.dataGrid1.CurrentRowIndex][1].ToString();
				stu.StuName=this.dt.Rows[this.dataGrid1.CurrentRowIndex][2].ToString();
				stu.StuSex=this.dt.Rows[this.dataGrid1.CurrentRowIndex][3].ToString();
				stu.StuRace=this.dt.Rows[this.dataGrid1.CurrentRowIndex][4].ToString();
				stu.StuArrdess=this.dt.Rows[this.dataGrid1.CurrentRowIndex][5].ToString();
				stu.StuTouch=this.dt.Rows[this.dataGrid1.CurrentRowIndex][6].ToString();
				stu.StuRole=this.dt.Rows[this.dataGrid1.CurrentRowIndex][7].ToString();
				stu.StuPost=this.dt.Rows[this.dataGrid1.CurrentRowIndex][8].ToString();
				stu.StuMemo=this.dt.Rows[this.dataGrid1.CurrentRowIndex][10].ToString();
				stu.StuClass=this.dt.Rows[this.dataGrid1.CurrentRowIndex][12].ToString();
				stu.StuSpec=this.dt.Rows[this.dataGrid1.CurrentRowIndex][13].ToString();
				this.flag=true;
			}
		}

		private void f_EditStuEvent()
		{
			LoadData();
			this.flag=false;
		}

		private void btnDel_Click(object sender, System.EventArgs e)
		{
			string Sql = "select * from Class..ScoreInfo where StudentNumber = '"+stu.StuNumber+"'";
			if(this.flag==false)
			{
				MessageBox.Show("请选择要删除的学生信息!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else if(c.IsExits(Sql)==true)
			{
				MessageBox.Show("请先删除与该学生相关的成绩信息!","提示信息!",MessageBoxButtons.OK,MessageBoxIcon.Question);
			}
			else
			{
				if(MessageBox.Show("是否删除该学生?","提示信息!",MessageBoxButtons.OKCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2)==DialogResult.OK)
				{
					string Sql1 = "delete Class..StudentInfo where StudentNumber = '"+stu.StuNumber+"'";
					c.EditData(Sql1);
					f_EditStuEvent();
				}
			}

		}

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

⌨️ 快捷键说明

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