/// <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 ReadData() { string condition = ""; if (this.cbb_coursetype.SelectedIndex != -1) { string coursetypename = this.cbb_coursetype.Properties.Items[this.cbb_coursetype.SelectedIndex].ToString(); condition += " and B.COURSETYPENAME like '%" + coursetypename + "%'"; } if (te_coursename.Text.Length > 0) { condition += " and COURSENAME like '%" + this.te_coursename.Text + "%'"; } BLL.COURSE_INFO courseBll = new BLL.COURSE_INFO(); this.gridControl1.DataSource = courseBll.GetList(condition).Tables[0]; this.gridView1.BestFitColumns(); DBUtility.ToolHelper.DrawRowIndicator(gridView1, 40); DBUtility.ToolHelper.SetLineColorofGridView(this.gridView1); }
/// <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); } }