/// <summary> /// 读取数据 /// </summary> private void readData() { if (this._courseno > 0) { BLL.COURSE_INFO coutseBll = new BLL.COURSE_INFO(); Model.COURSE_INFO courseMdl = new Model.COURSE_INFO(); courseMdl = coutseBll.GetModel(this._courseno); if (courseMdl == null) { blankData(); } else { this.te_coursename.Text = courseMdl.COURSENAME; init_coursetype(); this.te_totalhour.Text = DBUtility.ToolHelper.ConvertToString(courseMdl.TOTALHOUR); this.te_theoryhour.Text = DBUtility.ToolHelper.ConvertToString(courseMdl.THEORYHOUR); this.te_experimenthour.Text = DBUtility.ToolHelper.ConvertToString(courseMdl.EXPERIMENTHOUR); this.te_credit.Text = DBUtility.ToolHelper.ConvertToString(courseMdl.CREDIT); this.te_memo.Text = courseMdl.MEMO; Model.COURSE_TYPE coursetypeMdl = new Model.COURSE_TYPE(); BLL.COURSE_TYPE coursetypeBll = new BLL.COURSE_TYPE(); coursetypeMdl = coursetypeBll.GetModel((int)courseMdl.COURSETYPENO); this.cbb_coursetype.EditValue = coursetypeMdl.COURSETYPENAME; } } }
/// <summary> /// 保存方法 /// </summary> /// <returns></returns> private bool saveData() { try { BLL.COURSE_INFO courseBll = new BLL.COURSE_INFO(); Model.COURSE_INFO courseMdl = new Model.COURSE_INFO(); BLL.COURSE_TYPE coursetypeBll = new BLL.COURSE_TYPE(); Model.COURSE_TYPE coursetypeMdl = new Model.COURSE_TYPE(); if (this.cbb_coursetype.SelectedIndex != -1) { coursetypeMdl = coursetypeBll.GetModel(this.cbb_coursetype.Properties.Items[this.cbb_coursetype.SelectedIndex].ToString()); courseMdl.COURSETYPENO = coursetypeMdl.COURSETYPENO; } else { MessageBox.Show("课程类型不能为空!", "提示信息"); return(false); } if (this.te_coursename.Text == "") { MessageBox.Show("课程名称不能为空!", "提示信息"); return(false); } courseMdl.COURSENAME = te_coursename.Text; courseMdl.TOTALHOUR = ToolHelper.ConvertToInt(te_totalhour.Text); courseMdl.THEORYHOUR = ToolHelper.ConvertToInt(te_theoryhour.Text); courseMdl.EXPERIMENTHOUR = ToolHelper.ConvertToInt(te_experimenthour.Text); courseMdl.CREDIT = (decimal)ToolHelper.ConvertToFloat(te_credit.Text); courseMdl.MEMO = te_memo.Text; if (this._enumStatus == StatusClass.AddNew) { courseBll.Add(courseMdl); return(true); } else if (this._enumStatus == StatusClass.Edit) { courseMdl.COURSENO = this._courseno; courseBll.Update(courseMdl); return(true); } return(true); } catch (Exception exception) { MessageBox.Show("保存失败!" + exception.Message, exception.Message); return(false); } }
/// <summary> /// 初始化课程类型列表 /// </summary> private void init_coursetype() { Student.BLL.COURSE_TYPE coursetypeBll = new BLL.COURSE_TYPE(); DataSet ds = coursetypeBll.GetAllList(); cbb_coursetype.Properties.Items.Clear(); cbb_coursetype.EditValue = null; cbb_coursetype.Properties.NullText = "--请选择--"; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string coursetypeName = ds.Tables[0].Rows[i]["COURSETYPENAME"].ToString(); this.cbb_coursetype.Properties.Items.Add(coursetypeName); } this.cbb_coursetype.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; }
/// <summary> /// 查询数据 /// </summary> private void readData() { if (this._coursetypeno > 0) { BLL.COURSE_TYPE coursetypeBll = new BLL.COURSE_TYPE(); Model.COURSE_TYPE coursetypeMdl = new Model.COURSE_TYPE(); coursetypeMdl = coursetypeBll.GetModel(_coursetypeno); if (coursetypeMdl == null) //新增专业功能时 { blankData(); } else { this.te_coursetypename.Text = coursetypeMdl.COURSETYPENAME; this.te_coursetypememo.Text = coursetypeMdl.MEMO; } } }
/// 保存数据方法 /// </summary> /// <returns></returns> private bool saveData() { try { BLL.COURSE_TYPE coursetypeBll = new BLL.COURSE_TYPE(); Model.COURSE_TYPE coursetypeMdl = new Model.COURSE_TYPE(); if (this.te_coursetypename.Text == "") { MessageBox.Show("专业名称不能为空!", "提示信息"); return(false); } coursetypeMdl.COURSETYPENAME = this.te_coursetypename.Text; coursetypeMdl.MEMO = this.te_coursetypememo.Text; if (this._enumStatus == StatusClass.AddNew) //新增专业 { if (coursetypeBll.Exists(this.te_coursetypename.Text)) { MessageBox.Show("当前课程类型已经存在,请核查!", "提示信息"); return(false); } coursetypeBll.Add(coursetypeMdl); return(true); } else if (this._enumStatus == StatusClass.Edit) //修改课程 { coursetypeMdl.COURSETYPENO = this._coursetypeno; coursetypeBll.Update(coursetypeMdl); return(true); } return(true); } catch (Exception exception) { MessageBox.Show("保存失败!" + exception.Message, exception.Message); return(false); } }
/// <summary> /// 删除方法 /// </summary> /// <param name="id"></param> /// <returns></returns> private bool deleteData(int id) { try { BLL.COURSE_INFO courseBll = new BLL.COURSE_INFO(); int recordCount = courseBll.GetRecordCount("COURSETYPENO = " + id.ToString()); if (recordCount > 0) { MessageBox.Show("该课程类型信息已经被使用,不能被删除!", "提示信息"); return(false); } else { BLL.COURSE_TYPE coursetypeBll = new BLL.COURSE_TYPE(); coursetypeBll.Delete(id); return(true); } } catch (Exception exception) { MessageBox.Show("删除失败!", exception.Message); return(false); } }