Пример #1
0
        private void AddCourseInfoForm_Load(object sender, EventArgs e)
        {
            //绑定班级
            DataSet ds_Class = new BLL.tbClassInfo().GetAllList();

            this.cboxClassId.DataSource    = ds_Class.Tables[0];
            this.cboxClassId.DisplayMember = "ClassName";
            this.cboxClassId.ValueMember   = "ClassId";

            //如果是修改,则绑定数据
            if (this.FS == FormStatus.Update)
            {
                Model.tbCourseInfo model = new BLL.tbCourseInfo().GetModel(this.CourseId);
                if (model != null)
                {
                    this.txtCourseId.Text          = model.CourseId.ToString();
                    this.txtCourseName.Text        = model.CourseName;
                    this.cboxClassId.SelectedValue = model.ClassId;
                    this.cboxSemester.Text         = model.Semester;
                }
                else
                {
                    MessageBox.Show("该条记录不存在,请确认");
                    this.Close();
                }
            }
        }
Пример #2
0
        private void CourseInfoForm_Load(object sender, EventArgs e)
        {
            //绑定下拉框
            DataSet ds_Specialty = new BLL.tbSpecialtyInfo().GetAllList();
            DataRow dr           = ds_Specialty.Tables[0].NewRow();

            dr["SpecialtyId"]   = 0;
            dr["SpecialtyName"] = "--请选择--";
            ds_Specialty.Tables[0].Rows.InsertAt(dr, 0);
            this.cboxSpecialtyId.DataSource    = ds_Specialty.Tables[0];
            this.cboxSpecialtyId.DisplayMember = "SpecialtyName";
            this.cboxSpecialtyId.ValueMember   = "SpecialtyId";
            DataSet ds = new BLL.tbCourseInfo().GetListByCourseInfoView("");

            this.myDataGridView1.DataSource = ds.Tables[0];
        }
Пример #3
0
        //保存
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool flag = Common.FormHelp.CheckTextBox(this.panel1.Controls, this.txtCourseId);

            if (!flag)
            {
                MessageBox.Show("请将信息输入完整");
                return;
            }
            Model.tbCourseInfo model = new Model.tbCourseInfo();
            model.CourseName = this.txtCourseName.Text.Trim();
            model.ClassId    = int.Parse(this.cboxClassId.SelectedValue.ToString());
            model.Semester   = this.cboxSemester.Text;

            bool SaveStatus = false;

            try
            {
                if (this.FS == FormStatus.Add)
                {
                    int rows = new BLL.tbCourseInfo().Add(model);
                    this.txtCourseId.Text = rows.ToString();
                    SaveStatus            = true;
                }
                else if (this.FS == FormStatus.Update)
                {
                    model.CourseId = int.Parse(this.txtCourseId.Text.Trim());
                    SaveStatus     = new BLL.tbCourseInfo().Update(model);
                }
                if (SaveStatus)
                {
                    MessageBox.Show("保存成功");
                    //将状态改为修改状态
                    this.FS = FormStatus.Update;
                }
                else
                {
                    MessageBox.Show("保存失败");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }