private void btn_ThemMoi_Click(object sender, EventArgs e)
 {
     if (txt_TenKhuVuc.Text.Length == 0)
     {
         Notification.Error("Bạn chưa nhập tên khu vực!");
         return;
     }
     if (_khuVucBLL.KiemTraTenKhuVucTonTai(txt_TenKhuVuc.Text))
     {
         Notification.Error("Tên khu vực đã tồn tại! Vui lòng nhập tên khu vực khác.");
         return;
     }
     _khuVucBLL.ThemKhuVucMoi(txt_TenKhuVuc.Text);
     txt_TenKhuVuc.Text = null;
     Notification.Success("Tạo khu vực mới thành công.");
 }
Example #2
0
        // Cập nhật thông tin khi người dùng chỉnh sửa
        private void btn_Luu_Lai_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string error    = "";
            bool   isUpdate = false;

            foreach (int id in _listUpdate)
            {
                KHU_VUC _khuVuc = new KHU_VUC();
                _khuVuc.ID_Khu_Vuc  = int.Parse(gridView1.GetRowCellValue(id, "ID_Khu_Vuc").ToString());
                _khuVuc.Ten_Khu_Vuc = gridView1.GetRowCellValue(id, "Ten_Khu_Vuc").ToString();
                if (!_khuVucBLL.KiemTraTenKhuVucTonTai(_khuVuc.Ten_Khu_Vuc))
                {
                    _khuVucBLL.CapNhatKhuVuc(_khuVuc);
                    isUpdate = true;
                }
                else
                {
                    if (error == "")
                    {
                        error += _khuVuc.ID_Khu_Vuc;
                    }
                    else
                    {
                        error += " | " + _khuVuc.ID_Khu_Vuc;
                    }
                }
            }
            if (isUpdate == true)
            {
                if (error.Length == 0)
                {
                    Notification.Success("Cập dữ liệu thành công.");
                }
                else
                {
                    Notification.Error("Có lỗi xảy ra khi cập nhật dữ liệu. Các ID chưa được cập nhật (" + error + "). Lỗi: Tên Khu Vực đã tồn tại.");
                }
            }
            else
            {
                Notification.Error("Có lỗi xảy ra khi cập nhật dữ liệu. Lỗi: Tên khu vực đã tồn tại.");
            }
            LoadDataSource();
        }