private void btn_ThemMoi_Click(object sender, EventArgs e) { if (txt_SoBan.Text.Length == 0 && lkup_KhuVuc.Text == null) { Utils.Notification.Error("Vui lòng chọn khu vực và nhập số bàn."); return; } // Kiểm tra số bàn đã có chưa if (_banBLL.KiemTraTenBanTonTai(txt_SoBan.Text)) { Utils.Notification.Error("Số bàn đã tồn tại."); return; } // Thêm bàn mới BAN b = new BAN(); b.Ten_Ban = txt_SoBan.Text; b.ID_Khu_Vuc = int.Parse(lkup_KhuVuc.EditValue.ToString()); b.Trang_Thai = 0; _banBLL.ThemBanMoi(b); Utils.Notification.Success("Thêm bàn mới thành công!"); txt_SoBan.Text = null; }
// 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) { BAN _ban = new BAN(); _ban.ID_Ban = int.Parse(gridView1.GetRowCellValue(id, "ID_Ban").ToString()); _ban.Ten_Ban = gridView1.GetRowCellValue(id, "Ten_Ban").ToString(); _ban.ID_Khu_Vuc = int.Parse(gridView1.GetRowCellValue(id, "ID_Khu_Vuc").ToString()); if (!_banBLL.KiemTraTenBanTonTai(_ban.Ten_Ban, _ban.ID_Ban)) { _banBLL.CapNhatBan(_ban); isUpdate = true; } else { if (error == "") { error += _ban.ID_Ban; } else { error += " | " + _ban.ID_Ban; } } } 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 bàn đã 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 bàn đã tồn tại."); } LoadDataSource(); }