Exemplo n.º 1
0
        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 = txtDeptNum.Text;
            //objClass.ProNum = txtProNum.Text;
            //if (objClass1BLL.ChangeClass(objClass) == true)
            //    MessageBox.Show("数据修改成功");
            //else
            //    MessageBox.Show("数据修改失败");

            //dgvClass.DataSource = objClass1BLL.ShowClass();
            #endregion

            #region 使用实体类在各层传递数据
            //if (txtStuNum.Text == "")
            if (txtClaNum.Text=="" || txtClaName.Text=="")
            {
                MessageBox.Show("班号、班名不能为空!\n 请重新输入!");
            }
            else
            {

                ClassBLL objClassBLL = new ClassBLL();

                SchoolMolel objClassModel = new SchoolMolel();

                objClassModel.ClaName = txtClaName.Text;
                objClassModel.SchNum = txtClaNum.Text;
                objClassModel.DeptNum = txtDeptNum.Text;
                objClassModel.ProNum = txtProNum.Text;

                if(objClassBLL.ChangeClass(objClassModel)==true)
                {
                    MessageBox.Show("修改成功!");
                }
                else
                    MessageBox.Show("修改失败!");
            }
            #endregion

            ShowClass();
        }