//删除: private void btnDel_Click(object sender, EventArgs e) { #region 使用SQL语句删除,已注释,改到三层架构的数据访问层了。 //int CurrentRow = dgvSelCourse.CurrentRow.Index; //string StuNum = dgvSelCourse[0, CurrentRow].Value.ToString(); //string SqlString = "delete from SelCourse where StuNum='" + StuNum + "'"; ////objSqlCommand.CommandText = SqlString; ////objSqlCommand.Connection = objConn; //DataBaseOperaClass objDataBase = new DataBaseOperaClass(); //if (objDataBase.GetExecute(SqlString) == true) //{ MessageBox.Show("退选成功!"); } //else //{ MessageBox.Show("退选失败!"); } #endregion #region 使用实体类在各层传递数据 if (cbxStuNum.Text == "") { MessageBox.Show("学号不能为空!\n 请重新输入!"); } else { SelCourseBLL objSelCourseBLLClass = new SelCourseBLL(); SelCourseModel objSelCourseModel = new SelCourseModel(); objSelCourseModel.StuNum = cbxStuNum.Text; if (objSelCourseBLLClass.CancelSel(objSelCourseModel) == true) { MessageBox.Show("删除成功!!"); } else { MessageBox.Show("删除失败!"); } } #endregion RefreshTable(); }
//删除: private void btnCancelSel_Click(object sender, EventArgs e) { strTrans ="更新时间"+DateTime.Now.ToString(); #region 使用SQL语句删除,已注释,改到三层架构的数据访问层了。 // //int CurrentRow = dgvSelCourse.CurrentRow.Index; // //string StuNum = dgvSelCourse[0, CurrentRow].Value.ToString(); // //string SqlString = "delete from SelCourse where StuNum='" + StuNum + "'"; // ////objSqlCommand.CommandText = SqlString; // ////objSqlCommand.Connection = objConn; // //DataBaseOperaClass objDataBase = new DataBaseOperaClass(); // //if (objDataBase.GetExecute(SqlString) == true) // //{ MessageBox.Show("退选成功!"); } // //else // //{ MessageBox.Show("退选失败!"); } // #endregion // if (txtStuNum.Text == "") // { // MessageBox.Show("学号不能为空!\n 请重新输入!"); // } // else // { // SelCourseBLLClass objSelCourseBLLClass = new SelCourseBLLClass(); // if (objSelCourseBLLClass.CancelSel(txtStuNum.Text) == true) // { // MessageBox.Show("已退选!"); // } // else // { // MessageBox.Show("退选失败!"); // } // } // RefreshTable(); //} #endregion #region 使用实体类在各层传递数据 //if (txtStuNum.Text == "") if (txtStuNum.Text == "") { MessageBox.Show("学号不能为空!\n 请重新输入!"); } else { SelCourseBLL objSelCourseBLLClass = new SelCourseBLL(); SelCourseModel objSelCourseClass = new SelCourseModel(); //objSelCourseClass.StuNum = txtStuNum.Text; objSelCourseClass.StuNum = txtStuNum.Text; objSelCourseClass.CourseNum = cbxCourseNum.Text; if (objSelCourseBLLClass.CancelSel(objSelCourseClass) == true) { MessageBox.Show("已退选!"); } else { MessageBox.Show("退选失败!"); } } #endregion ShowCurrentLoginUserInfo(); //触发事件,即执行“显示成绩窗体中”的RefreshDataGridView()的代码 #region 触发事件,即执行“显示成绩窗体中”的RefreshDataGridView()的代码 if (this.EventRefersh == null) { foreach (Form objForm in this.MdiParent.MdiChildren) { if (objForm is StuScoreSearch) { StuScoreSearch objStuScoreSearch = (StuScoreSearch)objForm; this.EventRefersh += new DelegateRefresh(objStuScoreSearch.RefreshDataGridView); } } } if (this.EventRefersh != null) { //e.Name = "test"; this.EventRefersh(this, null); } #endregion }