private void btnDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { int ID = int.Parse(viewAvailableCustomers.GetFocusedRowCellValue("ID").ToString()); string Name = viewAvailableCustomers.GetFocusedRowCellValue("Name").ToString(); CustomersBO aCustomersBO = new CustomersBO(); DialogResult result = MessageBox.Show("Bạn có muốn xóa khách hàng " + Name + " này không?", "Xóa khách hàng", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { aCustomersBO.Delete(ID); MessageBox.Show("Xóa thành công"); this.ReloadData(); } }
private void btnDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { int ID = int.Parse(viewAvailableCustomers.GetFocusedRowCellValue("ID").ToString()); string Name = viewAvailableCustomers.GetFocusedRowCellValue("Name").ToString(); DialogResult result = MessageBox.Show("Bạn có muốn xóa khách hàng " + Name + " này không?", "Xóa khách hàng", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { CustomerGroups_CustomersBO aCustomerGroups_CustomersBO = new CustomerGroups_CustomersBO(); CustomersBO aCustomersBO = new CustomersBO(); ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO(); List<CustomerGroups_Customers> aListTemp = aCustomerGroups_CustomersBO.Select_ByIDCustomer(ID); List<vw__BookingRInfo__BookingRooms_Rooms_SystemUsers_Customers_CustomerGroups> aList = aReceptionTaskBO.GetInfoBookingRoom_ByIDCustomer(aListTemp.Select(p => p.IDCustomer).ToList()); if (aList.Count > 0) { MessageBox.Show("Bạn không được xóa khách này vì sẽ làm mất thông tin khách này với đặt phòng mã : " + string.Join(",", aList.Select(p => p.BookingRooms_IDBookingR).ToArray())); } else { aCustomersBO.Delete(ID); MessageBox.Show("Xóa thành công"); this.ReloadData(); } } }