private void btnLuu_Click(object sender, EventArgs e)
        {
            LopBLL    LopBll = new LopBLL();
            ErrorType result;
            //neu them moi
            string infor;

            if (this.maLop == null)
            {
                result = LopBll.Themlop(tbMaLop.Text, tbTenLop.Text, cbMaKhoiLop.Text, tbSiSo.Text);
                infor  = "Thêm thành công!";
            }
            else
            {
                result = LopBll.SuaLop(tbMaLop.Text, tbTenLop.Text, cbMaKhoiLop.Text, tbSiSo.Text);
                infor  = "Xóa thành công!";
            }

            if (result == ErrorType.THANH_CONG)
            {
                MessageBox.Show(infor, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            if (result == ErrorType.KI_TU_RONG)
            {
                MessageBox.Show("Bạn nên điền đầy đủ thông tin để thực hiện", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("Thất bại, vui lòng xem lại chuỗi kết nối CSDL!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
 private void btnGhi_Click(object sender, EventArgs e)
 {
     try
     {
         LayThongTin();
         if (action == "them")
         {
             if (lop.maLop == string.Empty)
             {
                 MessageBox.Show("Mã lớp không được để trống.");
             }
             else if (lop.tenLop == string.Empty)
             {
                 MessageBox.Show("Tên lớp không được để trống.");
             }
             if (lop.maGVCN == string.Empty)
             {
                 MessageBox.Show("Mã giáo viên chủ nhiệm không được để trống.");
             }
             else
             {
                 if (bll.ThemLop(lop) == true)
                 {
                     MessageBox.Show("Thêm thành công");
                     dgvDsLop.DataSource = bll.TimKiemLop(lop.maLop);
                 }
                 else
                 {
                     MessageBox.Show("Không thành công");
                 }
             }
             LockControlGhi();
         }
         else if (action == "sua")
         {
             if (bll.SuaLop(lop) == true)
             {
                 MessageBox.Show("Sửa thành công.");
                 dgvDsLop.DataSource = bll.TimKiemLop(lop.maLop);
             }
             else
             {
                 MessageBox.Show("Không thành công.");
             }
             LockControlGhi();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }