/// <summary> /// 增加数据方法 /// </summary> private void Add() { int termno, teacherno, workflowno; if (this.cbb_teacher.SelectedIndex == -1) { MessageBox.Show("请选择指导教师!", "提示信息"); return; } BLL.STUDENT_INFO studentBll = new BLL.STUDENT_INFO(); BLL.TERM_INFO termBll = new BLL.TERM_INFO(); Model.TERM_INFO termMdl = new Model.TERM_INFO(); BLL.WORKFLOW workflowBll = new BLL.WORKFLOW(); Model.WORKFLOW workflowMdl = new Model.WORKFLOW(); BLL.TEACHER_INFO teacherBll = new BLL.TEACHER_INFO(); Model.TEACHER_INFO teacherMdl = new Model.TEACHER_INFO(); BLL.TEA_STU teastuBll = new BLL.TEA_STU(); Model.TEA_STU teastuMdl = new Model.TEA_STU(); termMdl = termBll.GetModel(this.cbb_term.Properties.Items[this.cbb_term.SelectedIndex].ToString()); termno = termMdl.TERMNO; workflowMdl = workflowBll.GetModel(this.cbb_workflow.Properties.Items[this.cbb_workflow.SelectedIndex].ToString()); workflowno = workflowMdl.WORKFLOWNO; teacherMdl = teacherBll.GetModel(this.cbb_teacher.Properties.Items[this.cbb_teacher.SelectedIndex].ToString()); teacherno = teacherMdl.TEACHERNO; teastuMdl.TEACHERNO = teacherno; teastuMdl.TERMNO = termno; teastuMdl.WORKFLOWNO = workflowno; //获取所选学生学号列表 this.lstCheckedStudentNo.Clear(); if (this.tl_student.Nodes.Count > 0) { foreach (TreeListNode root in tl_student.Nodes) { GetCheckedStudentNo(root); } } //将所选学生插入该教师所指导学生列表中 string idStr = string.Empty; foreach (string stuno in lstCheckedStudentNo) { teastuMdl.STUNO = stuno; teastuBll.Add(teastuMdl); } //显示更新数据 readData(2); }
/// <summary> /// 删除数据方法 /// </summary> /// <param name="id"></param> /// <returns></returns> private bool deleteData(int id) { try { BLL.TEA_STU teastuBll = new BLL.TEA_STU(); teastuBll.Delete(id); return(true); } catch (Exception exception) { MessageBox.Show("删除失败!", exception.Message); return(false); } }
/// <summary> /// 读取数据 /// </summary> private void readData(int flag) { int termno, teacherno, workflowno; BLL.STUDENT_INFO studentBll = new BLL.STUDENT_INFO(); BLL.TERM_INFO termBll = new BLL.TERM_INFO(); Model.TERM_INFO termMdl = new Model.TERM_INFO(); BLL.WORKFLOW workflowBll = new BLL.WORKFLOW(); Model.WORKFLOW workflowMdl = new Model.WORKFLOW(); BLL.TEACHER_INFO teacherBll = new BLL.TEACHER_INFO(); Model.TEACHER_INFO teacherMdl = new Model.TEACHER_INFO(); termMdl = termBll.GetModel(this.cbb_term.Properties.Items[this.cbb_term.SelectedIndex].ToString()); termno = termMdl.TERMNO; workflowMdl = workflowBll.GetModel(this.cbb_workflow.Properties.Items[this.cbb_workflow.SelectedIndex].ToString()); workflowno = workflowMdl.WORKFLOWNO; //初始化学生列表 this.tl_student.DataSource = studentBll.GetStudentNodeList(termno, workflowno).Tables[0]; this.tl_student.KeyFieldName = "nodeid"; this.tl_student.ParentFieldName = "parentid"; this.tl_student.Columns["nodename"].Caption = "学生列表"; //初始化教师指导学生列表 string condition = ""; condition += " and D.TERMNO = '" + termno.ToString() + "' "; condition += " and E.WORKFLOWNO = '" + workflowno.ToString() + "' "; if (flag == 2) { teacherMdl = teacherBll.GetModel(this.cbb_teacher.Properties.Items[this.cbb_teacher.SelectedIndex].ToString()); teacherno = teacherMdl.TEACHERNO; condition += " and C.TEACHERNO = '" + teacherno.ToString() + "' "; } BLL.TEA_STU teastuBll = new BLL.TEA_STU(); this.gridControl1.DataSource = teastuBll.GetList(condition).Tables[0]; this.gridView1.BestFitColumns(); DBUtility.ToolHelper.DrawRowIndicator(gridView1, 50); DBUtility.ToolHelper.SetLineColorofGridView(this.gridView1); }