public int InsertClassInfo(Classes classes,string gradeName) { int rowsAffected = 0; DataSet numberList = new DataSet(); try { DBCommandWrapper dbCommandWrapper = db.GetStoredProcCommandWrapper("InsertClass_Info"); DBCommandWrapper dbCommand = db.GetStoredProcCommandWrapper("SelectGradeNumber"); dbCommand.AddInParameter("@info_gradeName",DbType.String,gradeName); numberList = db.ExecuteDataSet(dbCommand); classes.ClassInfoGradeNumber = Convert.ToInt32(numberList.Tables[0].Rows[0][0]); dbCommandWrapper.AddInParameter("@info_classNumber",DbType.Int32,classes.InfoClassNumber); dbCommandWrapper.AddInParameter("@info_className",DbType.String,classes.InfoClassName); dbCommandWrapper.AddInParameter("@info_gradeNumber",DbType.Int32,classes.ClassInfoGradeNumber); dbCommandWrapper.AddInParameter("@info_machineAddr",DbType.Int32,classes.InfoMachineAddr); dbCommandWrapper.AddInParameter("@info_classRemark",DbType.String,classes.InfoClassRemark); dbCommandWrapper.AddInParameter("@type",DbType.String,classes.ClassType); dbCommandWrapper.AddOutParameter("@rowsAffected",DbType.Int32,4); db.ExecuteNonQuery(dbCommandWrapper); rowsAffected = Convert.ToInt32(dbCommandWrapper.GetParameterValue("@rowsAffected")); } catch(Exception ex) { throw ex; } return rowsAffected; }
public int UpdateClassInfo(Classes classes) { int rowsAffected = 0; using(ClassesDataAccess classDataAccess = new ClassesDataAccess()) { rowsAffected = classDataAccess.UpdateClassInfo(classes); } return rowsAffected; }
public int InsertClassInfo(Classes classes,string gradeName) { int rowsAffected = 0; using(ClassesDataAccess classDataAccess = new ClassesDataAccess()) { rowsAffected = classDataAccess.InsertClassInfo(classes,gradeName); } return rowsAffected; }
//修改班级信息按钮 private void simpleButton_ClassModi_Click(object sender, System.EventArgs e) { string message = "是否确认修改?"; string caption = "消息提示框!"; DialogResult messageResult = MessageBox.Show(message,caption,MessageBoxButtons.YesNo,MessageBoxIcon.Question); if ( messageResult != DialogResult.Yes ) return; int rowsAffected = 0; Classes classes = new Classes(); classes.ClassInfoGradeNumber = gradeID; classes.InfoClassNumber = classID; classes.InfoClassName = comboBoxEdit_ClassNameModify.SelectedItem.ToString(); classes.InfoClassRemark = textEdit_ClassModifyRemark.Text.Trim(); if(classes.InfoClassName != string.Empty) { try { rowsAffected = new ClassSystem().UpdateClassInfo(classes); if(rowsAffected > 0) { MessageBox.Show(radioGroup_Class.SelectedIndex==0?"班级":"岗位"+"信息修改成功","系统信息!", MessageBoxButtons.OK,MessageBoxIcon.Information); gradeDataBinding(); resetClassInfo(); } else { MessageBox.Show(radioGroup_Class.SelectedIndex==0?"班级":"岗位"+"信息修改失败,请重试","系统信息!", MessageBoxButtons.OK,MessageBoxIcon.Warning); } } catch(Exception ex) { MessageBox.Show(radioGroup_Class.SelectedIndex==0?"班级":"岗位"+"信息修改失败,请重试","系统信息!", MessageBoxButtons.OK,MessageBoxIcon.Warning); CPTT.SystemFramework.Util.WriteLog(ex.Message,CPTT.SystemFramework.Util.EXCEPTION_LOG_TITLE); } } else { MessageBox.Show("请先选择要修改的信息","系统信息!", MessageBoxButtons.OK,MessageBoxIcon.Warning); } }
//保存班级信息 private void simpleButton_ClassSave_Click(object sender, System.EventArgs e) { if(comboBoxEdit1.SelectedIndex != -1 && textEdit_ClassName.Text != string.Empty) { Classes classes = new Classes(); classes.InfoClassName = textEdit_ClassName.Text.Trim(); classes.InfoClassRemark = textEdit_ClassRemark.Text.Trim(); if (comboBoxEdit_classNumber.SelectedItem.ToString().Equals("已经到达班级最大容量")) { MessageBox.Show("班级容量已经到达最大容量,无法进行添加操作!"); return; } if (radioGroup_Class.SelectedIndex == 0) classes.InfoClassNumber = Convert.ToInt32(comboBoxEdit_classNumber.SelectedItem); else classes.InfoClassNumber = 0; classes.ClassType = radioGroup_Class.SelectedIndex.ToString(); int rowsAffected = 0; try { rowsAffected = new ClassSystem().InsertClassInfo(classes,comboBoxEdit1.SelectedItem.ToString()); if(rowsAffected > 0) { //清空文本框 resetClassInfoAdd(); MessageBox.Show("插入成功.","系统信息!",MessageBoxButtons.OK,MessageBoxIcon.Information); //重新绑定班级信息 ClassDataBinding(); } else if(rowsAffected == -1) { string info = radioGroup_Class.SelectedIndex==0?"班级":"岗位"; MessageBox.Show(info+"名称重复,请更改名称后重试","系统信息!", MessageBoxButtons.OK,MessageBoxIcon.Warning); } else if(rowsAffected == -2) { MessageBox.Show("该部门的教师岗位由系统内定为班主任,您无法对该项目进行操作!","系统信息!", MessageBoxButtons.OK,MessageBoxIcon.Warning); } else if (rowsAffected == -3) { MessageBox.Show("班级总合不能超过28,添加失败!","系统信息!", MessageBoxButtons.OK,MessageBoxIcon.Warning); } else { MessageBox.Show("插入失败,请重试","系统信息!", MessageBoxButtons.OK,MessageBoxIcon.Warning); } } catch(Exception ex) { MessageBox.Show("插入失败,请重试","系统信息!", MessageBoxButtons.OK,MessageBoxIcon.Information); CPTT.SystemFramework.Util.WriteLog(ex.Message,CPTT.SystemFramework.Util.EXCEPTION_LOG_TITLE); } } else { MessageBox.Show("*号为必须填写内容,请检查输入","系统信息",MessageBoxButtons.OK,MessageBoxIcon.Information); } textEdit_ClassName.Text = string.Empty; }
public int UpdateClassInfo(Classes classes) { return new ClassRules().UpdateClassInfo(classes); }
public int InsertClassInfo(Classes classes,string gradeName) { return new ClassRules().InsertClassInfo(classes,gradeName); }
public int UpdateClassInfo(Classes classes) { int rowsAffected = 0; try { DBCommandWrapper dbCommandWrapper = db.GetStoredProcCommandWrapper("UpdateClass_Info"); dbCommandWrapper.AddInParameter("@info_classNumber",DbType.Int32,classes.InfoClassNumber); dbCommandWrapper.AddInParameter("@info_className",DbType.String,classes.InfoClassName); dbCommandWrapper.AddInParameter("@info_gradeNumber",DbType.Int32,classes.ClassInfoGradeNumber); dbCommandWrapper.AddInParameter("@info_machineAddr",DbType.Int32,classes.InfoMachineAddr); dbCommandWrapper.AddInParameter("@info_classRemark",DbType.String,classes.InfoClassRemark); dbCommandWrapper.AddOutParameter("@rowsAffected",DbType.Int32,4); db.ExecuteNonQuery(dbCommandWrapper); rowsAffected = Convert.ToInt32(dbCommandWrapper.GetParameterValue("@rowsAffected")); } catch(Exception ex) { throw ex; } return rowsAffected; }