private void btnSearch_Click(object sender, EventArgs e) { ClassModel objClassModel = new ClassModel(); ScoreSearchBLL objScoreSearchBLL = new ScoreSearchBLL(); objClassModel.ClaName = cmbClassName.Text; objClassModel.StuNum = cmbStuNum.Text; dataGridView1.DataSource = objScoreSearchBLL.ScoreSearch(objClassModel); }
//删除班级信息 public bool DeleteClass(ClassModel objClassModel) { string Sqlstring = "delete from Class where ClaNum = '" + objClassModel.ClaNum + "'"; DataBaseOperaClass objDataBase = new DataBaseOperaClass(); if (objDataBase.GetExecute(Sqlstring)) return (true); else return (false); }
public DataTable ScoreSearch(ClassModel objClassModel) { SqlString += " Where 班级='"+ objClassModel.ClaName+"'Or 学号='"+objClassModel.StuNum+"'"; DataBaseOperateClass2 objDataBase = new DataBaseOperateClass2(); DataTable objDataTable; return objDataTable = objDataBase.ShowTable(SqlString); }
//查找班级信息 public bool SearchClass(ClassModel objClassModel) { string Sqlstring = "select * from Class where ClaNum ='" + objClassModel.ClaNum+ "'"; DataBaseOperaClass objDataBaseOperaClass = new DataBaseOperaClass(); if (objDataBaseOperaClass.GetDataSet(Sqlstring).Tables[0].Rows.Count > 0) return (true); else return (false); }
//修改班级信息 public bool ChangeClass(ClassModel objClassModel) { //string Sqlstring; //Sqlstring = "update Class set ClaNum ='" + objClassModel.ClaNum + "',ClaName ='" + objClassModel.ClaName + "',DeptNum ='" + objClassModel.DeptNum + "',ProNum ='" + objClassModel.ProNum + "' where ClaNum ='"+objClassModel.ClaNum+"'"; string SqlString="Update V_ClassInfo set 班级编号='"+objClassModel.ClaNum+"',班级名称='"+objClassModel.ClaName+"',专业编号='"+objClassModel.ProNum+"',系部编号='"+objClassModel.DeptNum+"'where 班级编号='"+objClassModel.ClaNum+"'"; DataBaseOperaClass objDataBase = new DataBaseOperaClass(); if (objDataBase.GetExecute(SqlString)) return (true); else return (false); }
//添加班级信息的业务逻辑 public bool AddClass(ClassModel objClassModel) { ClassDAL objClass1DAL = new ClassDAL(); if (objClass1DAL.SearchClass(objClassModel)==true) { MessageBox.Show("班级已有,谢绝添加"); return (false); } else { return (objClass1DAL.AddClass(objClassModel)); } }
private void btnAdd_Click(object sender, EventArgs e) { #region // //ClassBLL objClass1BLL = new ClassBLL(); //ClassModel objClass = new ClassModel(); //objClass.ClaNum = txtbClassNum.Text; //objClass.ClaName = txtbClass.Text; //objClass.DeptNum = txtbDeptNum.Text; //objClass.ProNum = txtbcmbProNum.Text; //if (objClass1BLL.AddClass(objClass) == true) // MessageBox.Show("数据添加成功"); //else // MessageBox.Show("数据添加成功"); //dgvClass.DataSource = objClass1BLL.ShowClass(); #endregion #region 使用实体类在各层传递数据: if (cmbClaNum.Text == "" || cmbClaName.Text == "") { MessageBox.Show("班号、班名都不能为空!\n 请重新输入!"); } else { ClassBLL objClassBLL = new ClassBLL(); ClassModel objClassModel = new ClassModel(); objClassModel.ClaNum = cmbClaNum.Text; objClassModel.ClaName = cmbClaName.Text; objClassModel.DeptNum = cmbDeptNum.Text; objClassModel.DeptName = cmbDeptName.Text; objClassModel.ProNum = cmbProNum.Text; //objClassModel.ProName = cmbProName.Text; if (objClassBLL.AddClass(objClassModel)==true) { MessageBox.Show("添加成功!"); } else MessageBox.Show("添加失败!"); } #endregion ShowClass(); }
public bool AddClass(ClassModel objClassModel) { string SqlString = "Insert into V_ClassInfo (班级编号,班级名称,专业编号,系部编号) Values(@ClaNum,@ClaName,@ProNum,@DeptNum)"; SqlParameter[] parms ={ new SqlParameter("@ClaNum",objClassModel.ClaNum), new SqlParameter("@ClaName",objClassModel.ClaName), new SqlParameter("@ProNum",objClassModel.ProNum), new SqlParameter("@DeptNum",objClassModel.DeptNum) }; DataBaseOperaClass objDataBase = new DataBaseOperaClass(); if (objDataBase.GetExecute(SqlString,parms)) return (true); else return (false); }
private void btnDel_Click(object sender, EventArgs e) { #region 使用实体类在各层传递数据 ClassBLL objClass1BLL = new ClassBLL(); ClassModel objClassModel = new ClassModel(); objClassModel.ClaNum = cmbClaNum.Text; if (objClass1BLL.DeleteClass(objClassModel) == true) { objClass1BLL.DeleteClass(objClassModel); MessageBox.Show("数据删除成功"); } else { MessageBox.Show("数据删除失败"); } #endregion ShowClass(); }
public DataTable ScoreSearch(ClassModel objClassModel ) { return (objScoreSearchDAL.ScoreSearch(objClassModel)); }
private void btnUpdate_Click(object sender, EventArgs e) { #region // //ClassBLL objClass1BLL = new ClassBLL(); //ClassModel objClass = new ClassModel(); ////objClass.ClaNum = dgvClass[0, dgvClass.CurrentRow.Index].Value.ToString(); //objClass.ClaNum = txtClassNum.Text; //objClass.ClaName = txtClassName.Text; //objClass.DeptNum = cmbDeptNum.Text; //objClass.ProNum = cmbProNum.Text; //if (objClass1BLL.ChangeClass(objClass) == true) // MessageBox.Show("数据修改成功"); //else // MessageBox.Show("数据修改失败"); //dgvClass.DataSource = objClass1BLL.ShowClass(); #endregion #region 使用实体类在各层传递数据 //if (txtStuNum.Text == "") if (cmbClaNum.Text == "" || cmbClaName.Text == "") { MessageBox.Show("班号、班名不能为空!\n 请重新输入!"); } else { ClassBLL objClassBLL = new ClassBLL(); ClassModel objClassModel = new ClassModel(); objClassModel.ClaName = cmbClaName.Text; objClassModel.ClaNum = cmbClaNum.Text; objClassModel.DeptNum = cmbDeptNum.Text; objClassModel.ProNum = cmbProNum.Text; if(objClassBLL.ChangeClass(objClassModel)==true) { MessageBox.Show("修改成功!"); } else MessageBox.Show("修改失败!"); } #endregion ShowClass(); }
private void btnSearch_Click(object sender, EventArgs e) { #region 使用实体类在三层中传递数据 ClassBLL objClass1BLL = new ClassBLL(); ClassModel objClassModel = new ClassModel(); DataBaseOperaClass objDataBase = new DataBaseOperaClass(); objClassModel.ClaNum = cmbClaNum.Text; dgvClass.DataSource = objClass1BLL.SearchClass(objClassModel); #endregion ShowClass(); }
public bool SearchClass(ClassModel objClassModel) { ClassDAL objClass1DAL = new ClassDAL(); return (objClass1DAL.SearchClass(objClassModel)); }
//任务14 //删除班级信息的业务逻辑 public bool DeleteClass(ClassModel objClassModel) { ClassDAL objClass1DAL = new ClassDAL(); return (objClass1DAL.DeleteClass(objClassModel)); }
//修改班级信息的业务逻辑 public bool ChangeClass(ClassModel objClassModel) { ClassDAL objClass1DAL = new ClassDAL(); return (objClass1DAL.ChangeClass(objClassModel)); }