コード例 #1
0
ファイル: ClassInfo.cs プロジェクト: CatcherX/WinForm
        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();
        }