private void btnLuu_Click(object sender, EventArgs e)
        {
            MonHocBLL monhocbll = new MonHocBLL();
            ErrorType result;

            //them
            if (this.tenMH == null)
            {
                result = monhocbll.ThemMonHoc(tbMaMH_DSMH.Text, tbTenMH_DSMH.Text);
            }
            else //sua
            {
                result = monhocbll.SuaMonHoc(tbMaMH_DSMH.Text, tbTenMH_DSMH.Text);
            }

            switch ((int)result)
            {
            case (int)ErrorType.KI_TU_RONG:
                MessageBox.Show("Thất bại, bạn phải điền đầy đủ thông tin để thực hiện!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case (int)ErrorType.DA_TON_TAI:
                MessageBox.Show("Không thể thêm, Môn học này đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case (int)ErrorType.THAT_BAI:
                MessageBox.Show("Thất bại, Xin kiểm tra lại kết nối CSDL!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            default:
                string infor;
                if (this.tenMH == null)
                {
                    infor = "Thêm thành công!";
                }
                else
                {
                    infor = "Sửa thành công !";
                }
                MessageBox.Show(infor, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tbMaMH_DSMH.Text  = "";
                tbTenMH_DSMH.Text = "";
                break;
            }
        }
Пример #2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenmonhoc.Text == "" || txtSotiet.Text == "")
            {
                MessageBox.Show("Bạn phải nhập dữ liệu");
                return;
            }
            MonHocDTO mh = new MonHocDTO();

            mh.STenMH  = txtTenmonhoc.Text;
            mh.ISoTiet = int.Parse(txtSotiet.Text);
            mh.IMaHK   = int.Parse(cbHocky.SelectedValue.ToString());
            mh.IMaKhoi = int.Parse(cbKhoi.SelectedValue.ToString());
            if (MonHocBLL.ThemMonHoc(mh))
            {
                MessageBox.Show("Thêm thành công.");
                LoadMonHoc();
                return;
            }
            MessageBox.Show("Thêm thất bại.");
        }
Пример #3
0
 /// <summary>
 /// Them mon hoc vao CSDL
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btThemMH_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(tbMaMH.Text) || string.IsNullOrEmpty(tbTenMH.Text))
     {
         MessageBox.Show("Thêm thất bại,phải điền đầy đủ thông tin !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         MonHocBLL mhbll = new MonHocBLL();
         if (mhbll.ThemMonHoc(tbMaMH.Text, tbTenMH.Text) == true)
         {
             MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             //cap nhat du lieu len giao dien
             LoadMonHoc_DanhSachMonHoc();
         }
         else
         {
             MessageBox.Show("Thêm thất bại,Môn học này đã có !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }