public void RefreshDataBinding(int maKH) { try { khachHangDTO = KhachHangBUS.LayKhachHang(maKH); //Lấy tất cả loại phòng vào cmb listLoaiKH = LoaiKhachHangBUS.LayTatCaLoaiKhachHang_List(); //Nếu không có loại phòng, thông báo cần tạo loại phòng trước if (listLoaiKH.Count == 0) { XtraMessageBox.Show("Cần thêm loại khách hàng trước!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } cmbLoaiKH.Properties.Items.Clear(); foreach (LoaiKhachHangDTO loaiKH in listLoaiKH) { cmbLoaiKH.Properties.Items.Add(new MyComboBoxItem(loaiKH.TenLoaiKH, loaiKH.MaLoaiKH)); if (loaiKH.MaLoaiKH == khachHangDTO.MaLoaiKH) { cmbLoaiKH.SelectedIndex = cmbLoaiKH.Properties.Items.Count - 1; } } txtNgaySinh.DateTime = khachHangDTO.NgaySinh; txtMaKH.EditValue = khachHangDTO.MaKH.ToString(); txtTenKH.EditValue = khachHangDTO.TenKH; txtEmail.EditValue = khachHangDTO.Email; txtDiaChi.EditValue = khachHangDTO.DiaChi; txtSDT.EditValue = khachHangDTO.SDT.ToString(); txtDiemtichluy.EditValue = khachHangDTO.DiemTichLuy; // pictureEdit1.Image = khachHangDTO.HinhAnh; ValidateChildren(); } catch (Exception x) { } }
private void wbntKhachhang_ButtonClick(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e) { switch (e.Button.Properties.Tag.ToString()) { case "Thêm khách hàng": //Nếu không có loại KH, thông báo cần tạo loại phòng trước if (LoaiKhachHangBUS.LayTatCaLoaiKhachHang_List().Count == 0) { XtraMessageBox.Show("Cần phải thêm loại khách hàng trước!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } themKhachHang3.Initialize(); this.KhachhangPagecontrol.SelectedPage = PageThemkhachhang; break; case "Sửa khách hàng": suaKhachHang3.RefreshDataBinding((int)khachHang.Rows[gridView1.GetFocusedDataSourceRowIndex()]["MaKH"]); this.KhachhangPagecontrol.SelectedPage = PageSuakhachang; break; case "Bộ lọc": DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutAction action = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutAction() { Caption = "BỘ LỌC", Description = "Close the application?" }; DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand command1 = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() { Text = "Lọc", Result = System.Windows.Forms.DialogResult.Yes }; DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand command2 = new DevExpress.XtraBars.Docking2010.Views.WindowsUI.FlyoutCommand() { Text = "Hủy", Result = System.Windows.Forms.DialogResult.No }; action.Commands.Add(command1); action.Commands.Add(command2); FlyoutProperties properties = new FlyoutProperties(); properties.ButtonSize = new Size(160, 50); properties.Style = FlyoutStyle.MessageBox; filterDialog = new FilterControlDialog(gridControl1, gridView1.ActiveFilterString.ToString()); if (DevExpress.XtraBars.Docking2010.Customization.FlyoutDialog.Show(this.FindForm(), filterDialog, action, properties) == DialogResult.Yes) { if (filterDialog.GetFilterString() == "") { return; } gridView1.ActiveFilterString = strFilterDialog = filterDialog.GetFilterString(); tileControl2.SelectedItem = tileFilter; tileFilter.Visible = true; } break; case "Quản lý loại khách hàng": goToLoaiKhachHang(); break; //case "Xóa": // //Thông báo xác nhận // if (XtraMessageBox.Show("Bạn có chắc xóa khách hàng '" + gridView1.GetFocusedRowCellValue(colTenKH).ToString() + "' ?", "Xác nhận", MessageBoxButtons.OKCancel) == DialogResult.OK) // { // if (BUS.KhachHangBUS.XoaKhachHang((int)gridView1.GetFocusedRowCellValue(colMaKH))) // { // //Thông báo thành công/thất bại // XtraMessageBox.Show("Xóa khách hàng thành công!", "Thông báo", MessageBoxButtons.OK); // RefreshDataBinding(); // } // else // //Thông báo thành công/thất bại // XtraMessageBox.Show("Xóa khách hàng thất bại!", "Thông báo", MessageBoxButtons.OK); // } // break; } }