예제 #1
0
        /// <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;
                }
            }
        }
예제 #2
0
        /// <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);
            }
        }