private void btnSelectService_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            try
            {
                ServiceUsedEN aServiceUsedEN = new ServiceUsedEN();
                int IDService = Convert.ToInt32(grvService.GetFocusedRowCellValue("ID"));
                aServiceUsedEN.IDService = IDService;
                aServiceUsedEN.DateUsed = dtpFrom.DateTime;
                aServiceUsedEN.NameService = grvService.GetFocusedRowCellValue("Name").ToString();
                aServiceUsedEN.Cost = Convert.ToDecimal(grvService.GetFocusedRowCellValue("CostRef"));
                aServiceUsedEN.CostRef_Service = Convert.ToDecimal(grvService.GetFocusedRowCellValue("CostRef"));
                aServiceUsedEN.Unit = grvService.GetFocusedRowCellValue("Unit").ToString();

                aServiceUsedEN.Quantity = 1;
                aServiceUsedEN.Tax = 10;

                if (this.aNewBookingHEN.aListBookingHallUsed.Where(a => a.CodeHall == CurrentCodeHall).ToList().Count > 0)
                {
                    this.aNewBookingHEN.aListBookingHallUsed.Where(a => a.CodeHall == CurrentCodeHall).ToList()[0].InsertService(aServiceUsedEN);

                    dgvServiceInHall.DataSource = this.aNewBookingHEN.aListBookingHallUsed.Where(a => a.CodeHall == CurrentCodeHall).ToList()[0].aListServiceUsed;
                    dgvServiceInHall.RefreshDataSource();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_BookingHall_Customer_New.btnSelectService_ButtonClick\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        // truyền lại Service vừa thêm vào 2 List
        public void CallBackService(Services aServices)
        {
            try
            {
                this.LoadService();
                ServicesBO aServicesBO = new ServicesBO();
                ServiceUsedEN aServiceUsedEN = new ServiceUsedEN();

                aServiceUsedEN.IDService = aServices.ID;
                aServiceUsedEN.NameService = aServices.Name;
                aServiceUsedEN.Cost = aServices.CostRef;
                aServiceUsedEN.CostRef_Service = aServices.CostRef;
                aServiceUsedEN.Unit = aServices.Unit;
                aServiceUsedEN.Quantity = 1;
                aServiceUsedEN.Tax = 10;
                aServiceUsedEN.DateUsed = dtpFrom.DateTime;

                if (this.aNewBookingHEN.aListBookingHallUsed.Where(a => a.CodeHall == CurrentCodeHall).ToList().Count > 0)
                {
                    this.aNewBookingHEN.aListBookingHallUsed.Where(a => a.CodeHall == CurrentCodeHall).ToList()[0].InsertService(aServiceUsedEN);

                    dgvServiceInHall.DataSource = this.aNewBookingHEN.aListBookingHallUsed.Where(a => a.CodeHall == CurrentCodeHall).ToList()[0].aListServiceUsed;
                    dgvServiceInHall.RefreshDataSource();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_BookingHall_Customer_New.btnSelectService_ButtonClick\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void SaveServiceUsed(ServiceUsedEN aServiceUsedEN, int ServiceType)
        {
            try
            {
                DatabaseDA aDatabaseDA = new DatabaseDA();
                if (ServiceType == 1)
                {

                    if (aDatabaseDA.BookingRooms_Services.Where(b => b.ID == aServiceUsedEN.IDBookingService).ToList().Count > 0)
                    {
                        BookingRooms_Services aTemp = aDatabaseDA.BookingRooms_Services.Where(b => b.ID == aServiceUsedEN.IDBookingService).ToList()[0];
                        aTemp.Cost = aServiceUsedEN.Cost;
                        aTemp.CostRef_Services = aServiceUsedEN.CostRef_Service;
                        aTemp.Date = aServiceUsedEN.DateUsed;
                        aTemp.PercentTax = aServiceUsedEN.Tax;
                        aTemp.Quantity = aServiceUsedEN.Quantity;
                        aTemp.Status = aServiceUsedEN.StatusPay;
                        aTemp.ID = aServiceUsedEN.IDBookingService;
                        aTemp.IndexSubPayment = aServiceUsedEN.IndexSubPayment;
                        aTemp.AcceptDate = aServiceUsedEN.AcceptDate;
                        aTemp.InvoiceDate = aServiceUsedEN.InvoiceDate;
                        aTemp.InvoiceNumber = aServiceUsedEN.InvoiceNumber;
                        aDatabaseDA.BookingRooms_Services.AddOrUpdate(aTemp);
                        aDatabaseDA.SaveChanges();
                    }
                }
                else if (ServiceType == 2)
                {
                    if (aDatabaseDA.BookingHalls_Services.Where(b => b.ID == aServiceUsedEN.IDBookingService).ToList().Count > 0)
                    {
                        BookingHalls_Services aTemp = aDatabaseDA.BookingHalls_Services.Where(b => b.ID == aServiceUsedEN.IDBookingService).ToList()[0];
                        aTemp.Cost = aServiceUsedEN.Cost;
                        aTemp.CostRef_Services = aServiceUsedEN.CostRef_Service;
                        aTemp.Date = aServiceUsedEN.DateUsed;
                        aTemp.PercentTax = aServiceUsedEN.Tax;
                        aTemp.Quantity = aServiceUsedEN.Quantity;
                        aTemp.Status = aServiceUsedEN.StatusPay;
                        aTemp.ID = aServiceUsedEN.IDBookingService;
                        aTemp.IndexSubPayment = aServiceUsedEN.IndexSubPayment;
                        aTemp.AcceptDate = aServiceUsedEN.AcceptDate;
                        aTemp.InvoiceDate = aServiceUsedEN.InvoiceDate;
                        aTemp.InvoiceNumber = aServiceUsedEN.InvoiceNumber;
                        aDatabaseDA.BookingHalls_Services.AddOrUpdate(aTemp);
                        aDatabaseDA.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("ServiceUsedEN.Save :" + ex.Message.ToString()));
            }
        }
        // Linhting - Lay du lieu cho NewPayment
        public List<ServiceUsedEN> GetListServiceUsedInRoom_ByIDBookingRoom(int IDBookingRoom)
        {
            try
            {
                List<vw__BookingRooms_ServicesInfo__BookingRooms_BookingRoomsServices_Services_ServiceGroups> aListTemp = new List<vw__BookingRooms_ServicesInfo__BookingRooms_BookingRoomsServices_Services_ServiceGroups>();
                aListTemp = aDatabaseDA.vw__BookingRooms_ServicesInfo__BookingRooms_BookingRoomsServices_Services_ServiceGroups.Where(v => v.BookingRooms_Services_IDBookingRoom == IDBookingRoom).ToList();
                List<ServiceUsedEN> aListReturn = new List<ServiceUsedEN>();
                ServiceUsedEN aServiceUsedEN;
                RoomsBO aRoomsBO = new RoomsBO();

                List<Rooms> aListRoomTemp = aRoomsBO.Select_ByIDLang(1);

                for (int i = 0; i < aListTemp.Count; i++)
                {
                    aServiceUsedEN = new ServiceUsedEN();
                    aServiceUsedEN.IDBookingService = aListTemp[i].BookingRooms_Services_ID;
                    aServiceUsedEN.IDServiceGroup = aListTemp[i].ServiceGroups_ID;
                    aServiceUsedEN.ServiceGroupName = aListTemp[i].ServiceGroups_Name;
                    aServiceUsedEN.IDService = aListTemp[i].Services_ID;
                    aServiceUsedEN.DateUsed = aListTemp[i].BookingRooms_Services_Date;
                    if (aListRoomTemp.Where(r => r.Code == aListTemp[i].BookingRooms_CodeRoom).ToList().Count > 0)
                    {
                        aServiceUsedEN.Sku = aListRoomTemp.Where(r => r.Code == aListTemp[i].BookingRooms_CodeRoom).ToList()[0].Sku;
                    }
                    aServiceUsedEN.IndexSubPayment = aListTemp[i].BookingRooms_Services_IndexSubPayment;
                    aServiceUsedEN.StatusPay = aListTemp[i].BookingRooms_Services_Status;
                    aServiceUsedEN.NameService = aListTemp[i].Services_Name;
                    aServiceUsedEN.Quantity = aListTemp[i].BookingRooms_Services_Quantity;
                    aServiceUsedEN.Cost = aListTemp[i].BookingRooms_Services_Cost;
                    aServiceUsedEN.CostRef_Service = aListTemp[i].Services_CostRef;
                    aServiceUsedEN.Tax = aListTemp[i].BookingRooms_Services_PercentTax;

                    aListReturn.Insert(i, aServiceUsedEN);
                }

                return aListReturn;

            }
            catch (Exception ex)
            {

                throw new Exception("ReceptionTaskBO.GetListServiceUsed_ByIDBookingRoom\n" + ex.ToString());
            }
        }
        public int UpdateService(int IDService, ServiceUsedEN aServiceUsedEN)
        {
            try
            {
                if (this.aListServiceUsed.Where(a => a.IDService == IDService).ToList().Count > 0)
                {
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].NameService = aServiceUsedEN.NameService;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].ServiceGroupName = aServiceUsedEN.ServiceGroupName;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].DateUsed = aServiceUsedEN.DateUsed;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].Quantity = aServiceUsedEN.Quantity;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].Unit = aServiceUsedEN.Unit;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].Cost = aServiceUsedEN.Cost;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].CostRef_Service = aServiceUsedEN.CostRef_Service;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].Tax = aServiceUsedEN.Tax;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].IndexSubPayment = aServiceUsedEN.StatusPay;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].InvoiceNumber = aServiceUsedEN.InvoiceNumber;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].InvoiceDate = aServiceUsedEN.InvoiceDate;
                    this.aListServiceUsed.Where(a => a.IDService == IDService).ToList()[0].AcceptDate = aServiceUsedEN.AcceptDate;

                }
                return 1;
            }
            catch (Exception ex)
            {
                return 0;
                throw new Exception(string.Format("BookingHallUsedEN.UpdateService :" + ex.Message.ToString()));

            }
        }
        public int InsertService(ServiceUsedEN aServiceUsedEN)
        {
            try
            {
                this.aListServiceUsed.Add(aServiceUsedEN);
                return 1;
            }
            catch (Exception ex)
            {
                return 0;
                throw new Exception(string.Format("BookingHallUsedEN.InsertService :" + ex.Message.ToString()));

            }
        }