private void btnSave_Click(object sender, EventArgs e) { //根据输入插入 if (Regex.IsMatch(txtCourseName.Text, @"^.{5,}$") == false) { return; } T_CourseDAL dal = new T_CourseDAL(); SqlParameter par = new SqlParameter("@courseName", SqlDbType.VarChar) { Value = txtCourseName.Text }; try { var res = (int)dal.ExecuteScalar("InsertedCourse", CommandType.StoredProcedure, par); if (res == 1) { FrmDialog.ShowDialog(this, "保存成功"); } else { throw new Exception(); } } catch { FrmDialog.ShowDialog(this, "保存失败"); } }
/// <summary> /// 加载指定班级下的T_Course /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ComClass_SelectedIndexChanged(object sender, EventArgs e) { T_CourseDAL dal = new T_CourseDAL(); T_Class @class = comClass.SelectedItem as T_Class; if (@class == null) { ucBtnExt2_BtnClick(null, null); } comCourse.DataSource = dal.ExecuteT_ClassSetUpCourseTeach(@class.ClassID); }
private List <T_InsertedFactionModel> LoadComCourseName(string stuid) { string t_sql = "select ClassID from T_StudentBasicInformation where T_StudentBasicInformation.StuID = @stuid"; SqlParameter pars = new SqlParameter("@stuid", SqlDbType.Int) { Value = stu.StuID }; T_CourseDAL dal = new T_CourseDAL(); int classID = (int)dal.ExecuteScalar(t_sql, CommandType.Text, pars); return(dal.ExecuteT_ClassSetUpCourseTeach(classID)); }
//删除客课程信息(即删除班级开课信息) private void OpenDeleteCourseDataInformation(object sender, EventArgs e) { //获取选择的dataGridView var rows = dataGridView1.SelectedRows; if (rows.Count == 0) { FrmDialog.ShowDialog(this, "请选择一行"); return; } var row = rows[0]; var courseName = row.DataBoundItem as T_Course; if (courseName == null) { return; } string t_sql = "DeleClassSetUpCourse"; SqlParameter[] par = new SqlParameter[] { new SqlParameter("@classid", SqlDbType.Int) { Value = courseName.classID }, new SqlParameter("@courseID", SqlDbType.Int) { Value = courseName.CourseID } }; T_CourseDAL dal = new T_CourseDAL(); try { var res = (int)dal.ExecuteScalar(t_sql, CommandType.StoredProcedure, par); if (res == 1) { FrmDialog.ShowDialog(this, "保存成功"); } else { throw new Exception(); } } catch { FrmDialog.ShowDialog(this, "保存失败"); } InitialCurIndexToLoades(modelID, curIndex); }
private void ucBtnExt1_BtnClick(object sender, EventArgs e) { if (Regex.IsMatch(txtFaction.Text, @"^^\d{1,3}\.*5{0,1}$") == false) { return; } else if (courseTeach == null) { return; } T_CourseDAL dal = new T_CourseDAL(); SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@courseID", SqlDbType.Int) { Value = courseTeach.CourseID }, new SqlParameter("@teachID", SqlDbType.Int) { Value = courseTeach.TeacherID }, new SqlParameter("@faction", SqlDbType.Float) { Value = txtFaction.Text }, new SqlParameter("@stuID", SqlDbType.Int) { Value = stu.StuID } }; try { var res = (int)dal.ExecuteScalar("InserintoCourseFaction", CommandType.StoredProcedure, pars); if (res == 1) { FrmDialog.ShowDialog(this, "保存成功"); } else { throw new Exception(); } } catch { FrmDialog.ShowDialog(this, "保存失败!请检查是否重复插入"); } }
private void ComCollege_SelectedIndexChanged(object sender, EventArgs e) { var college = comCollege.SelectedItem as T_College; var @class = comCollege.SelectedItem as T_Class; var course = comCollege.SelectedItem as T_Course; var teach = comCollege.SelectedItem as T_Teach; if (college == null || @class == null || course == null || teach == null) { return; } string t_sql = "InsertedClassSetUpCourse"; T_CourseDAL dal = new T_CourseDAL(); SqlParameter[] pars = new SqlParameter[] { new SqlParameter() { Value = @class.ClassID }, new SqlParameter() { Value = course.CourseID }, new SqlParameter() { Value = teach.TeachID } }; try { var res = (int)dal.ExecuteScalar(t_sql, CommandType.StoredProcedure, pars); if (res == 1) { FrmDialog.ShowDialog(this, "保存成功"); } else { throw new Exception(); } } catch { FrmDialog.ShowDialog(this, "保存失败!请确保录入数据正确且不重复"); } }
private void ucBtnExt1_BtnClick(object sender, EventArgs e) { //保存 if (teach == null) { return; } T_CourseDAL dal = new T_CourseDAL(); SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@classid", SqlDbType.Int) { Value = course.classID }, new SqlParameter("@courseid", SqlDbType.Int) { Value = course.CourseID }, new SqlParameter("@teachid", SqlDbType.Int) { Value = teach.TeachID } }; try { var res = (int)dal.ExecuteScalar("ModifyClassSetUpCourse", CommandType.StoredProcedure, pars); if (res == 1) { FrmDialog.ShowDialog(this, "保存成功"); course.teachID = teach.TeachID; course.TeachName = teach.TeachName; } else { throw new Exception(); } } catch { FrmDialog.ShowDialog(this, "保存失败!"); } }
//初始加载所有课程信息(此课程信息即本学校所开设的课程) private void LoadInitDataGridView() { T_CourseDAL dal = new T_CourseDAL(); int temp = curIndex; List <T_CourseName> res = null; try { curIndex = 1; res = dal.ExecuteListCourseName(curIndex, dataLength); } catch { curIndex = temp; } if (res == null) { return; } dataGridView1.DataSource = res; dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; }
private void btnSave_Click(object sender, EventArgs e) { bool res = Regex.IsMatch(txtCourseName.Text, @"^.{5,}$"); if (res == false) { return; } T_CourseDAL dal = new T_CourseDAL(); string t_sql = "ModifyCourseName"; SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@courseID", SqlDbType.Int) { Value = txtCourseID.Text }, new SqlParameter("@courseName", SqlDbType.VarChar) { Value = txtCourseName.Text } }; try { int modifyRes = (int)dal.ExecuteScalar(t_sql, CommandType.StoredProcedure, pars); if (modifyRes == 1) { FrmDialog.ShowDialog(this, "保存成功"); course.CourseName = txtCourseName.Text; } else { throw new Exception(); } } catch { FrmDialog.ShowDialog(this, "保存失败"); } }
/// <summary> /// 根据ModelID选项来设查询 /// </summary> /// <returns></returns> private object Loades() { object res = null; T_CourseDAL dal = new T_CourseDAL(); switch (modelID) { case -1: { res = dal.ExecuteListCourseName(curIndex, dataLength); }; break; case 0: { res = dal.ExecuteListCourseName(curIndex, dataLength, values[0]); }; break; case 1: { res = dal.ExecuteT_Course(curIndex, dataLength, string.Empty, string.Empty, string.Empty); }; break; case 2: { res = dal.ExecuteT_Course(curIndex, dataLength, values[0], values[1], values[2]); }; break; case 3: { res = dal.ExecuteT_CourseFaction(curIndex, dataLength, string.Empty, string.Empty, string.Empty, string.Empty); }; break; case 4: { res = dal.ExecuteT_CourseFaction(curIndex, dataLength, values[0], values[1], values[2], values[3]); }; break; case 5: { res = dal.ExecuteClassStudentsCompulsoryCourseFaction(curIndex, dataLength, values[0], values[1]); }; break; default:; break; } return(res); }
private void ucBtnExt1_BtnClick(object sender, EventArgs e) { if (Regex.IsMatch(txtFaction.Text, @"^^\d{1,3}\.*5{0,1}$") == false) { return; } T_CourseDAL dal = new T_CourseDAL(); SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@faction", SqlDbType.Int) { Value = txtFaction.Text }, new SqlParameter("@id", SqlDbType.Int) { Value = faction.ID } }; try { var res = (int)dal.ExecuteScalar("UpdateStudentFaction", CommandType.StoredProcedure, pars); if (res == 1) { FrmDialog.ShowDialog(this, "保存成功"); faction.Faction = float.Parse(txtFaction.Text); } else { throw new Exception(); } } catch { FrmDialog.ShowDialog(this, "保存失败!请检查是否重复插入"); } }