public frmRpt_UnSelectMenus(int IDBookingHall)
        {
            InitializeComponent();
            this.IDBookingHall = IDBookingHall;
            FoodsBO aFoodsBO = new FoodsBO();
            MenusBO aMenusBO = new MenusBO();

            ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();

            // Thông tin buổi tiệc
            BookingHallsBO aBookingHallsBO = new BookingHallsBO();
            BookingHalls aTemp = aBookingHallsBO.Select_ByID(IDBookingHall);
            lblStartTime.Text = aTemp.StartTime.ToString();
            lblEndTime.Text = aTemp.EndTime.ToString();
            HallsBO aHallsBO = new HallsBO();
            lblHallSku.Text = aHallsBO.Select_ByCodeHall(aTemp.CodeHall, 1).Sku;
            BookingHsBO aBookingHsBO = new BookingHsBO();
            lblSubject.Text = aBookingHsBO.Select_ByID(aTemp.IDBookingH).Subject;
            this.LoadMenus();
            //danh sach cac mon an co trong thuc don 1
            DetailReport.DataSource = aListFood1;
            picImage1Food.DataBindings.Add("Image", this.DataSource, "Image1");
            colNameFood.DataBindings.Add("Text", this.DataSource, "Name");
            colName1Food.DataBindings.Add("Text", this.DataSource, "Name1");
            colName2Food.DataBindings.Add("Text", this.DataSource, "Name2");
            colName3Food.DataBindings.Add("Text", this.DataSource, "Name3");
        }
        public frmRpt_UnSelectMenus(int IDBookingHall,int IDMenu)
        {
            InitializeComponent();
            this.IDBookingHall = IDBookingHall;
            FoodsBO aFoodsBO = new FoodsBO();
            MenusBO aMenusBO = new MenusBO();

            ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();

            // Thông tin buổi tiệc
            BookingHallsBO aBookingHallsBO = new BookingHallsBO();
            BookingHalls aTemp = aBookingHallsBO.Select_ByID(IDBookingHall);
            lblStartTime.Text = aTemp.StartTime.ToString();
            lblEndTime.Text = aTemp.EndTime.ToString();
            HallsBO aHallsBO = new HallsBO();
            lblHallSku.Text = aHallsBO.Select_ByCodeHall(aTemp.CodeHall, 1).Sku;
            BookingHsBO aBookingHsBO = new BookingHsBO();
            lblSubject.Text = aBookingHsBO.Select_ByID(aTemp.IDBookingH).Subject;
            // Load Menu
            Menus_FoodsBO aMenus_FoodsBO = new Menus_FoodsBO();
                Menus aMenus = aMenusBO.Select_ByID(IDMenu);
                if (aMenus  != null)
                {
                    List<Foods> aListTemp1 = aMenus_FoodsBO.SelectListFoods_ByIDMenu(aMenus.ID);
                    foreach (Foods item in aListTemp1)
                    {
                        if (item.Image1 != null)
                        {
                            if (item.Image1.Length <= 0)
                            {
                                Image image = RoomManager.Properties.Resources.logo_nkcp_small;
                                image = image.GetThumbnailImage(70, 70, null, IntPtr.Zero);
                                Byte[] aImageByte = this.ConvertImageToByteArray(image);
                                item.Image1 = aImageByte;
                            }
                        }
                        else
                        {
                            Image image = RoomManager.Properties.Resources.logo_nkcp_small;
                            image = image.GetThumbnailImage(70, 70, null, IntPtr.Zero);
                            Byte[] aImageByte = this.ConvertImageToByteArray(image);
                            item.Image1 = aImageByte;
                        }
                        aListFood1.Add(item);
                    }
                }

            //danh sach cac mon an co trong thuc don 1
            DetailReport.DataSource = aListFood1;
            picImage1Food.DataBindings.Add("Image", this.DataSource, "Image1");
            colNameFood.DataBindings.Add("Text", this.DataSource, "Name");
            colName1Food.DataBindings.Add("Text", this.DataSource, "Name1");
            colName2Food.DataBindings.Add("Text", this.DataSource, "Name2");
            colName3Food.DataBindings.Add("Text", this.DataSource, "Name3");
        }
 //Author: Linhting
 public void AutoChangeStatusBookingHalls(int IDBookingH)
 {
     BookingHsBO aBookingHsBO = new BookingHsBO();
     BookingHallsBO aBookingHallsBO = new BookingHallsBO();
     List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookigH(IDBookingH);
     int Status = Convert.ToInt32( aBookingHsBO.Select_ByID(IDBookingH).Status);
     for (int i = 0; i < aListBookingHalls.Count; i++)
     {
         aListBookingHalls[i].Status = Status;
         aBookingHallsBO.UpdateUnSync(aListBookingHalls[i]);
     }
 }
        //Author : Linhting
        public void Insert(BookingHs bookingHs)
        {
            try
            {
                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                aDatabaseDA.BookingHs.Add(bookingHs);
                aDatabaseDA.SaveChanges();
                aBookingHallsBO.AutoChangeStatusBookingHalls(bookingHs.ID);

            }
            catch (Exception ex)
            {
                throw new Exception("BookingHsBO.Insert:" + ex.ToString());
            }
        }
 public void LoadListBookingHallSelectedMenu()
 {
     try
     {
         ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
         BookingHallsBO aBookingHallsBO = new BookingHallsBO();
         List<BookingHallsEN> aListTemp = new List<BookingHallsEN>();
         //danh sach tiec đã chọn thực đơn
         aListTemp.Clear();
         aListTemp = aReceptionTaskBO.GetListBookingHallsSelectedMenus(dtpFrom.DateTime.Date, dtpTo.DateTime.Date); // Đã chốt thực đơn
         dgvBookingHalls_Selected.DataSource = this.GetListBookingHalls(aListTemp);
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_CheckMenus.LoadListBookingHallAlreadyComplete\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public void LoadListBookingHallHaveMenus()
 {
     try
     {
         ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
         BookingHallsBO aBookingHallsBO = new BookingHallsBO();
         List<BookingHallsEN> aListTemp = new List<BookingHallsEN>();
         //danh sach tiec da lên thực đơn nhưng chưa chốt
         aListTemp.Clear();
         aListTemp = aReceptionTaskBO.GetListBookingHallsHaveMenus(dtpFrom.DateTime.Date, dtpTo.DateTime.Date); // Chưa có thực đơn
         dgvBookingHalls_HaveMenus.DataSource = this.GetListBookingHalls(aListTemp);
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_CheckMenus.LoadListBookingHallHaveMenus\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public void LoadListBookingHallHaveNotMenus()
 {
     try
     {
         ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
         BookingHallsBO aBookingHallsBO = new BookingHallsBO();
         List<BookingHallsEN> aListTemp = new List<BookingHallsEN>();
         //danh sach tiec chưa có thực đơn
         aListTemp.Clear();
         aListTemp = aReceptionTaskBO.GetListBookingHallsNotMenus_ByBookingHallsDate(dtpFrom.DateTime.Date, dtpTo.DateTime.Date); // tiec da co thuc don
         dgvHaveNotMenus.DataSource = this.GetListBookingHalls(aListTemp);
         dgvHaveNotMenus.RefreshDataSource();
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_CheckMenus.LoadListBookingHallHaveNotMenus\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        //Author : Linhting
        public int Delete(int id)
        {
            try
            {
                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                BookingHs aBookingHs = aDatabaseDA.BookingHs.Find(id);
                aDatabaseDA.BookingHs.Remove(aBookingHs);
                List<BookingHalls> aListTemp = aBookingHallsBO.Select_ByIDBookigH(id);
                for (int i = 0; i < aListTemp.Count; i++)
                {
                    aDatabaseDA.BookingHalls.Remove(aListTemp[i]);
                }
                return aDatabaseDA.SaveChanges();
            }
            catch (Exception ex)
            {

                throw new Exception("BookingHsBO.Delete:" + ex.ToString());
            }
        }
        public void AutoChangeStatusBookingH(int IDBookingH)
        {
            BookingHsBO aBookingHsBO = new BookingHsBO();
            BookingHallsBO aBookingHallsBO = new BookingHallsBO();
            List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookigH(IDBookingH);
            List<int> ListStatusHall = new List<int>();
            int MinHallStatus;

            MinHallStatus = Convert.ToInt32( aListBookingHalls[0].Status);

            for (int i = 0; i < aListBookingHalls.Count; i++)
            {
                if (MinHallStatus > aListBookingHalls[i].Status)
                {
                    MinHallStatus = Convert.ToInt32(aListBookingHalls[i].Status);
                }

            }
            BookingHs aBookingHs = aBookingHsBO.Select_ByID(IDBookingH);
            aBookingHs.Status = MinHallStatus;
            aBookingHsBO.UpdateUnSync(aBookingHs);
        }
        private void btnDeleteHall_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (this.IsLockForm == false)
            {
                if (this.aNewPaymentEN.aListBookingRoomUsed.Count == 0 && this.aNewPaymentEN.aListBookingHallUsed.Count == 1)
                {
                    MessageBox.Show("Không thể xóa vì hóa đơn này sẽ rỗng. Hãy sử dụng chức năng xóa cả hóa đơn trong tình huống này", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    DialogResult result = MessageBox.Show("Xóa hội trường/tiệc. Tiếp tục?", "Xóa Xóa hội trường/tiệc", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {

                        BookingHalls_ServicesBO aBookingHalls_ServicesBO = new BookingHalls_ServicesBO();
                        BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                        int IDDeletedBookingHall = Convert.ToInt32(viewHalls.GetFocusedRowCellValue("ID"));
                        aBookingHalls_ServicesBO.DeleteListServiceUsed(IDDeletedBookingHall);

                        aBookingHallsBO.Delete(IDDeletedBookingHall);
                        MessageBox.Show("Thực hiện thành công!", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Reload();

                    }
                }
            }
            else
            {
                MessageBox.Show("Không thực hiện được chức năng này do form đang chế độ khóa");
            }
        }
        private void btnDeleteBookingR_Click(object sender, EventArgs e)
        {
            BookingRoomsMembersBO aBookingRoomsMembersBO = new BookingRoomsMembersBO();
            BookingRooms_ServicesBO aBookingRooms_ServicesBO = new BookingRooms_ServicesBO();
            BookingRoomsBO aBookingRoomsBO = new BookingRoomsBO();
            BookingRsBO aBookingRsBO = new BookingRsBO();
            CustomerGroups_CustomersBO aCustomerGroups_CustomersBO = new CustomerGroups_CustomersBO();
            CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
            BookingHsBO aBookingHsBO = new BookingHsBO();
            BookingHalls_ServicesBO aBookingHalls_ServicesBO = new BookingHalls_ServicesBO();
            BookingHallsBO aBookingHallsBO = new BookingHallsBO();
            MenusBO aMenusBO = new MenusBO();
            Menus_FoodsBO aMenus_FoodsBO = new Menus_FoodsBO();
            try
            {
                MessageBox.Show("Chức năng này sẽ xóa tất cả các phòng và hóa đơn đặt phòng đã đặt!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (this.IDBookingH == 0)
                {
                    DialogResult result = MessageBox.Show("Xóa tất cả các phòng đã đặt. Tiếp tục?", "Xóa phòng", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        foreach (BookingRoomUsedEN item in this.aNewPaymentEN.aListBookingRoomUsed)
                        {
                            aBookingRooms_ServicesBO.DeleteListServiceUsed(item.ID);
                            aBookingRoomsMembersBO.DeleteListBookingRoomsMembers(item.ID);
                            aBookingRoomsBO.Delete(item.ID);
                        }
                        aCustomerGroups_CustomersBO.DeleteAllCustomersFromCustomerGroup_ByIDBookingRs(this.IDBookingR);
                        aCustomerGroupsBO.Delete_ByID(Convert.ToInt32(this.aNewPaymentEN.IDCustomerGroup));
                        int ret =  aBookingRsBO.Delete(this.IDBookingR);

                        if (ret > 0)
                        {
                            MessageBox.Show("Thực hiện thành công!", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }

                }
                else
                {
                    DialogResult result = MessageBox.Show("Xóa tất cả các phòng và hội trường đã đặt. Tiếp tục?", "Xóa hóa đơn", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {

                        foreach (BookingRoomUsedEN item in this.aNewPaymentEN.aListBookingRoomUsed)
                        {
                            aBookingRooms_ServicesBO.DeleteListServiceUsed(item.ID);
                            aBookingRoomsMembersBO.DeleteListBookingRoomsMembers(item.ID);
                            aBookingRoomsBO.Delete(item.ID);
                        }
                        aCustomerGroups_CustomersBO.DeleteAllCustomersFromCustomerGroup_ByIDBookingRs(this.IDBookingR);
                        aCustomerGroupsBO.Delete_ByID(Convert.ToInt32(this.aNewPaymentEN.IDCustomerGroup));
                        aBookingRsBO.Delete(this.IDBookingR);
                        foreach (BookingHallUsedEN item1 in this.aNewPaymentEN.aListBookingHallUsed)
                        {
                            aBookingHalls_ServicesBO.DeleteListServiceUsed(item1.ID);
                            aBookingHallsBO.Delete(item1.ID);
                            foreach (MenusEN aMenu in item1.aListMenuEN)
                            {
                                aMenusBO.Delete(aMenu.ID);
                                aMenus_FoodsBO.Delete_ByIDMenu(aMenu.ID);
                            }
                        }
                        int ret = aBookingHsBO.Delete(this.IDBookingH);
                        if (ret > 0)
                        {
                            MessageBox.Show("Thực hiện thành công!", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }

                this.Close();
                if (this.afrmMain != null)
                {
                    this.afrmMain.ReloadData();
                }
                else if (this.afrmMain_Halls != null)
                {
                    this.afrmMain_Halls.ReloadData();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_UpdBookingHall.btnDeleteBookingRs\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        // ===============================================================================
        // Khoi tao doi tuong Payment
        private void InitData(int IDBookingR, int IDBookingH)
        {
            CompaniesBO aCompaniesBO = new CompaniesBO();
            CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
            SystemUsersBO aSystemUsersBO = new SystemUsersBO();
            BookingHsBO aBookingHsBO = new BookingHsBO();
            BookingRsBO aBookingRsBO = new BookingRsBO();
            BookingRoomsBO aBookingRoomBO = new BookingRoomsBO();
            CustomersBO aCustomersBO = new CustomersBO();
            ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
            RoomsBO aRoomsBO = new RoomsBO();
            HallsBO aHallsBO = new HallsBO();
            BookingHallsBO aBookingHallsBO = new BookingHallsBO();
            FoodsBO aFoodsBO = new FoodsBO();
            ExtraCostBO aExtraCostBO = new ExtraCostBO();
            List<int> aListIndexTemp = new List<int>();
            BookingHs aBookingHs = new BookingHs();
            BookingRs aBookingRs = aBookingRsBO.Select_ByID(IDBookingR);
            if (this.IDBookingH > 0)
            {
                aBookingHs = aBookingHsBO.Select_ByID(this.IDBookingH);
            }
            else
            {
                BookingRs_BookingHs aItem = (new BookingRs_BookingHsBO()).Select_ByIDBookingR(this.IDBookingR);
                if (aItem != null)
                {
                    this.IDBookingH = aItem.IDBookingH.GetValueOrDefault(0);
                    aBookingHs = aBookingHsBO.Select_ByID(this.IDBookingH);
                }

            }

            // Truyen du lieu chung cua NewPayment
            if (aBookingRs != null)
            {
                aNewPaymentEN.IDBookingR = aBookingRs.ID;
                aNewPaymentEN.IDCustomer = aBookingRs.IDCustomer;
                Customers aCustomers = aCustomersBO.Select_ByID(aBookingRs.IDCustomer);
                if (aCustomers != null)
                {
                    aNewPaymentEN.NameCustomer = aCustomers.Name;
                }
                aNewPaymentEN.IDSystemUser = aBookingRs.IDSystemUser;
                SystemUsers aSystemUsers = aSystemUsersBO.Select_ByID(aBookingRs.IDSystemUser);
                if (aSystemUsers != null)
                {
                    aNewPaymentEN.NameSystemUser = aSystemUsers.Name;
                }
                aNewPaymentEN.IDCustomerGroup = aBookingRs.IDCustomerGroup;
                CustomerGroups aCustomerGroups = aCustomerGroupsBO.Select_ByID(aBookingRs.IDCustomerGroup);
                if (aCustomerGroups != null)
                {
                    aNewPaymentEN.NameCustomerGroup = aCustomerGroups.Name;
                    aNewPaymentEN.IDCompany = aCustomerGroups.IDCompany;
                    Companies aCompanies = aCompaniesBO.Select_ByID(aCustomerGroups.IDCompany);
                    if (aCompanies != null)
                    {
                        aNewPaymentEN.NameCompany = aCompanies.Name;
                        aNewPaymentEN.TaxNumberCodeCompany = aCompanies.TaxNumberCode;
                        aNewPaymentEN.AddressCompany = aCompanies.Address;
                    }
                }
                aNewPaymentEN.PayMenthodR = aBookingRs.PayMenthod;
                aNewPaymentEN.CreatedDate_BookingR = aBookingRs.CreatedDate;
                aNewPaymentEN.CustomerType = aBookingRs.CustomerType;
                aNewPaymentEN.Status_BookingR = aBookingRs.Status;
                aNewPaymentEN.StatusPay = aBookingRs.StatusPay;
                aNewPaymentEN.BookingRMoney = aBookingRs.BookingMoney;
                aNewPaymentEN.Status_BookingR = aBookingRs.Status;
                aNewPaymentEN.AcceptDate = aBookingRs.AcceptDate;
                aNewPaymentEN.InvoiceDate = aBookingRs.InvoiceDate;
                aNewPaymentEN.InvoiceNumber = aBookingRs.InvoiceNumber;

                // Truyen du lieu cho List BookingRoom cua NewPayment
                List<BookingRooms> aListBookingRooms = aBookingRoomBO.Select_ByIDBookingRs(this.IDBookingR);
                if (aListBookingRooms.Count > 0)
                {
                    BookingRoomUsedEN aBookingRoomUsedEN;

                    foreach (BookingRooms item in aListBookingRooms)
                    {
                        aBookingRoomUsedEN = new BookingRoomUsedEN();
                        aBookingRoomUsedEN.SetValue(item);
                        aBookingRoomUsedEN.ListCustomer = aCustomersBO.SelectListCustomer_ByIDBookingRoom(item.ID);
                        Rooms aRooms = aRoomsBO.Select_ByCodeRoom(item.CodeRoom, 1);
                        if (aRooms != null)
                        {
                            aBookingRoomUsedEN.RoomSku = aRooms.Sku;
                        }
                        else
                        {
                            aBookingRoomUsedEN.RoomSku = string.Empty;
                        }
                        if (item.Status == 8 || item.Status == 7)
                        {
                            aBookingRoomUsedEN.AddTimeStart = Convert.ToDouble(aReceptionTaskBO.GetAddTimeStart(Convert.ToInt32(item.Type), item.CheckInActual));
                            aBookingRoomUsedEN.AddTimeEnd = Convert.ToDouble(aReceptionTaskBO.GetAddTimeEnd(Convert.ToInt32(item.Type), item.CheckOutActual));
                            aBookingRoomUsedEN.TimeInUse = Convert.ToDecimal(aReceptionTaskBO.GetTimeInUsed(item.CheckInActual, item.CheckOutActual) * 24 * 60);
                        }
                        else
                        {
                            aBookingRoomUsedEN.AddTimeStart = Convert.ToDouble(aReceptionTaskBO.GetAddTimeStart(Convert.ToInt32(item.Type), item.CheckInActual));
                            aBookingRoomUsedEN.AddTimeEnd = Convert.ToDouble(aReceptionTaskBO.GetAddTimeEnd(Convert.ToInt32(item.Type), item.CheckOutPlan));
                            aBookingRoomUsedEN.TimeInUse = Convert.ToDecimal(aReceptionTaskBO.GetTimeInUsed(item.CheckInActual, item.CheckOutPlan) * 24 * 60);

                        }
                        decimal? cost = 0;
                        if (item.Cost == null)
                        {
                            cost = item.CostRef_Rooms;
                            aBookingRoomUsedEN.Cost = cost + Convert.ToDecimal(aExtraCostBO.Select_BySku_ByPriceType_ByNumberPeople(aRooms.Sku, aBookingRoomUsedEN.PriceType, aBookingRoomUsedEN.ListCustomer.Count).ExtraValue);
                        }
                        else
                        {
                            cost = item.Cost;
                            aBookingRoomUsedEN.Cost = cost;
                        }
                        List<ServiceUsedEN> aListServiceRTemp = aReceptionTaskBO.GetListServiceUsedInRoom_ByIDBookingRoom(item.ID);
                        foreach (ServiceUsedEN aTemp in aListServiceRTemp)
                        {
                            aBookingRoomUsedEN.ListServiceUsed.Add(aTemp);
                            aListIndexTemp.Add(Convert.ToInt32(aTemp.IndexSubPayment));
                        }
                        aListIndexTemp.Add(Convert.ToInt32(aBookingRoomUsedEN.IndexSubPayment));
                        aNewPaymentEN.aListBookingRoomUsed.Add(aBookingRoomUsedEN);
                    }
                }

                //====================================================================================================
                //====================================================================================================
                //====================================================================================================
                // Brucelee Thanh sửa ngày 04/06/2015
                //
                //---------------
                // Lỗi sai điều kiện câu lệnh if khiến aBookingHs truyền dữ liệu CustomerType sai cho NewPaymentEN
                //---------------
                // Ban đầu : if (aBookingHs != null)
                //-------------------------------------
                if (aBookingHs.ID > 0)
                {
                    aNewPaymentEN.IDBookingH = aBookingHs.ID;
                    aNewPaymentEN.PayMenthodH = aBookingHs.PayMenthod;
                    aNewPaymentEN.CreatedDate_BookingH = aBookingHs.CreatedDate;
                    aNewPaymentEN.CustomerType = aBookingHs.CustomerType;
                    aNewPaymentEN.Status_BookingH = aBookingHs.Status;
                    aNewPaymentEN.BookingHMoney = aBookingHs.BookingMoney;
                    // Truyen du lieu cho List BookingHall cua NewPayment
                    List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookigH(this.IDBookingH);
                    if (aListBookingHalls != null)
                    {
                        BookingHallUsedEN aBookingHallUsedEN;
                        foreach (BookingHalls item in aListBookingHalls)
                        {
                            aBookingHallUsedEN = new BookingHallUsedEN();
                            aBookingHallUsedEN.SetValue(item);
                            Halls aHalls = aHallsBO.Select_ByCodeHall(item.CodeHall, 1);
                            if (aHalls != null)
                            {
                                aBookingHallUsedEN.HallSku = aHalls.Sku;
                            }
                            else
                            {
                                aBookingHallUsedEN.HallSku = string.Empty;
                            }
                            aBookingHallUsedEN.CustomerType = aBookingHs.CustomerType;
                            aBookingHallUsedEN.BookingTypeBookingH = aBookingHs.BookingType;
                            aBookingHallUsedEN.StatusPayBookingH = aBookingHs.StatusPay;
                            aBookingHallUsedEN.LevelBookingH = aBookingHs.Level;
                            aBookingHallUsedEN.aListMenuEN = aReceptionTaskBO.GetListMenus_ByIDBookingHall(item.ID);

                            aListIndexTemp.Add(Convert.ToInt32(aBookingHallUsedEN.IndexSubPayment));
                            List<ServiceUsedEN> aListServiceTemp = aReceptionTaskBO.GetListServiceUsedInHall_ByIDBookingHall(item.ID);
                            foreach (ServiceUsedEN aTemp in aListServiceTemp)
                            {
                                aBookingHallUsedEN.aListServiceUsed.Add(aTemp);
                                aListIndexTemp.Add(Convert.ToInt32(aTemp.IndexSubPayment));
                            }
                            aNewPaymentEN.aListBookingHallUsed.Add(aBookingHallUsedEN);
                        }
                    }
                }
                aNewPaymentEN.ListIndex = aListIndexTemp.Distinct().ToList();
            }
        }
        //hiennv
        public bool PaymentHall(PaymentHallsEN aPaymentHallsEN)
        {
            try
            {
                BookingHsBO aBookingHsBO = new BookingHsBO();
                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                BookingHalls_ServicesBO aBookingHalls_ServicesBO = new BookingHalls_ServicesBO();
                BookingHs aBookingHs = aBookingHsBO.Select_ByID(aPaymentHallsEN.IDBookingH);
                aBookingHs.PayMenthod = aPaymentHallsEN.PayMenthod;
                aBookingHs.DatePay = DateTime.Now;
                aBookingHs.StatusPay = 3;//da thanh toan
                aBookingHs.Status = 8;//da thanh toan toan bo
                aBookingHs.BookingMoney = 0;

                aBookingHsBO.Update(aBookingHs);
                foreach (InfoDetailPaymentHallsEN aInfoDetailPaymentHallsEN in aPaymentHallsEN.aListInfoDetailPaymentHallsEN)
                {
                    if (aInfoDetailPaymentHallsEN.aBookingHalls.IDBookingH == aPaymentHallsEN.IDBookingH)
                    {
                        BookingHalls aBookingHalls = aBookingHallsBO.Select_ByID(aInfoDetailPaymentHallsEN.aBookingHalls.ID);
                        aBookingHalls.Cost = aInfoDetailPaymentHallsEN.aBookingHalls.Cost;
                        aBookingHalls.PercentTax = aInfoDetailPaymentHallsEN.aBookingHalls.PercentTax;
                        aBookingHalls.Status = 8;// da thanh toan

                        aBookingHallsBO.Update(aBookingHalls);
                        foreach (ServicesHallsEN aServicesHallsEN in aInfoDetailPaymentHallsEN.aListServicesHallsEN)
                        {
                            if (aServicesHallsEN.IDBookingHall == aInfoDetailPaymentHallsEN.aBookingHalls.ID)
                            {
                                BookingHalls_Services aBookingHalls_Services = aBookingHalls_ServicesBO.Select_ByIDService_ByIDBookingHall(aServicesHallsEN.IDService, aInfoDetailPaymentHallsEN.aBookingHalls.ID);
                                aBookingHalls_Services.Cost = aServicesHallsEN.Cost;
                                aBookingHalls_Services.Quantity = aServicesHallsEN.Quantity;
                                aBookingHalls_Services.PercentTax = aServicesHallsEN.PercentTax;
                                aBookingHalls_Services.Status = 8;//da thanh toan
                                aBookingHalls_ServicesBO.Update(aBookingHalls_Services);
                            }

                        }

                    }
                }
                return true;

            }
            catch (Exception ex)
            {
                return false;
                throw new Exception(string.Format("ReceptionTaskBO.PaymentHall\n" + ex.Message));
            }
        }
        public void LoadData()
        {
            BookingHsBO aBookingHsBO = new BookingHsBO();
            BookingHallsBO aBookingHallsBO = new BookingHallsBO();
            HallsEN aTemp;
            aBookingHs = aBookingHsBO.Select_ByID(IDBookingH);
            HallsBO aHallsBO = new HallsBO();
            List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookigH(IDBookingH);
            //Fill data for BookingH
            txtSubject.Text = aBookingHs.Subject;
            txtBookingMoney.Text = String.Format("{0:0,0}", aBookingHs.BookingMoney);
            txtNote.Text = aBookingHs.Note;
            //Fill data for BookingHall
            dtpFrom.DateTime = Convert.ToDateTime(aListBookingHalls[0].Date);
               //tedEnd.Time = DateTime.Parse( aListBookingHalls[0].EndTime.ToString());
            //tedStart.Time = DateTime.Parse(aListBookingHalls[0].StartTime.ToString());

            for (int i = 0; i < aListBookingHalls.Count; i++)
            {
                aTemp = new HallsEN();
                aTemp.IDBookingHall = aListBookingHalls[i].ID;
                aTemp.Code = aListBookingHalls[i].CodeHall;
                aTemp.Sku = aHallsBO.Select_ByCodeHall(aListBookingHalls[i].CodeHall, 1).Sku;
                aTemp.CostRef = aListBookingHalls[i].CostRef_Halls;
                aTemp.Type = aHallsBO.Select_ByCodeHall(aListBookingHalls[i].CodeHall, 1).Type;
                aTemp.TypeDisplay = CORE.CONSTANTS.SelectedHallType(Convert.ToInt32(aTemp.Type)).Name;
                aTemp.Cost = aListBookingHalls[i].Cost;
                aTemp.TableOrPerson = aListBookingHalls[i].TableOrPerson;
                aTemp.Unit = aListBookingHalls[i].Unit;
                aListSelected.Add(aTemp);
            }
            dgvSelectedHalls.DataSource = aListSelected;
            dgvSelectedHalls.RefreshDataSource();
        }
        //Author: Linhting
        public int CheckIn(BookingHs BookingHs, List<BookingHalls> ListBookingHalls)
        {
            try
            {
                BookingHs aBookingHs = new BookingHs();

                aBookingHs.CreatedDate = BookingHs.CreatedDate;
                aBookingHs.CustomerType = BookingHs.CustomerType;
                aBookingHs.BookingType = BookingHs.BookingType;
                aBookingHs.Note = BookingHs.Note;
                aBookingHs.IDGuest = BookingHs.IDGuest;
                aBookingHs.StatusPay = BookingHs.StatusPay;
                aBookingHs.BookingMoney = BookingHs.BookingMoney;
                aBookingHs.Status = BookingHs.Status;
                aBookingHs.Type = BookingHs.Type;
                aBookingHs.Disable = BookingHs.Disable;
                aBookingHs.Level = BookingHs.Level;
                aBookingHs.Subject = BookingHs.Subject;
                aBookingHs.IDCustomerGroup = BookingHs.IDCustomerGroup;
                aBookingHs.IDCustomer = BookingHs.IDCustomer;
                aBookingHs.IDSystemUser = BookingHs.IDSystemUser;
                aBookingHs.Description = BookingHs.Description;

                //add new bookingRs
                BookingHsBO aBookingHsBO = new BookingHsBO();
                int IDBookingH = aBookingHsBO.InsertUnSync(aBookingHs);

                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                BookingHalls aBookingHall;
                for (int i = 0; i < ListBookingHalls.Count; i++)
                {
                    aBookingHall = new BookingHalls();
                    aBookingHall.IDBookingH = IDBookingH;
                    aBookingHall.CodeHall = ListBookingHalls[i].CodeHall;
                    aBookingHall.Cost = ListBookingHalls[i].Cost;
                    aBookingHall.PercentTax = ListBookingHalls[i].PercentTax;
                    aBookingHall.CostRef_Halls = ListBookingHalls[i].CostRef_Halls;
                    aBookingHall.Date = ListBookingHalls[i].Date;
                    aBookingHall.LunarDate = ListBookingHalls[i].LunarDate;
                    aBookingHall.BookingStatus = ListBookingHalls[i].BookingStatus;
                    aBookingHall.Unit = ListBookingHalls[i].Unit;
                    aBookingHall.TableOrPerson = ListBookingHalls[i].TableOrPerson;
                    aBookingHall.Note = ListBookingHalls[i].Note;
                    aBookingHall.Status = ListBookingHalls[i].Status;
                    aBookingHall.StartTime = ListBookingHalls[i].StartTime;
                    aBookingHall.EndTime = ListBookingHalls[i].EndTime;
                    aBookingHall.Location = ListBookingHalls[i].Location;
                    aBookingHall.Color = ListBookingHalls[i].Color;

                    aBookingHallsBO.InsertUnSync(aBookingHall);
                }

                return IDBookingH;

            }
            catch (Exception ex)
            {

                throw new Exception("ReceptionTaskBO.CheckIn\n" + ex.ToString());
            }
        }
        //Hiennv
        private void btnPayment_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(lueIndexSub.Text) == true)
                {
                    lueIndexSub.Focus();
                    MessageBox.Show("Vui lòng chọn phiếu thanh toán!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    BookingHalls_ServicesBO aBookingHalls_ServicesBO = new BookingHalls_ServicesBO();
                    foreach (ServicesHallsEN aServicesHallsEN in this.aListServices)
                    {
                        BookingHalls_Services aBookingHalls_Services = aBookingHalls_ServicesBO.Select_ByID(aServicesHallsEN.IDBookingHallService);
                        if (aBookingHalls_Services != null && aBookingHalls_Services.Status != 8)
                        {
                            aBookingHalls_Services.ID = aServicesHallsEN.IDBookingHallService;
                            aBookingHalls_Services.Quantity = aServicesHallsEN.Quantity;
                            aBookingHalls_Services.PercentTax = aServicesHallsEN.PercentTax;
                            aBookingHalls_Services.Cost = aServicesHallsEN.Cost;
                            aBookingHalls_Services.Status = 8;// da thanh toan
                            aBookingHalls_ServicesBO.Update(aBookingHalls_Services);
                        }
                    }

                    BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                    foreach (HallsEN aHallsEN in this.aListHalls)
                    {
                        BookingHalls aBookingHalls = aBookingHallsBO.Select_ByID(aHallsEN.IDBookingHall);
                        if (aBookingHalls != null && aBookingHalls.Status != 8)
                        {
                            aBookingHalls.ID = aHallsEN.IDBookingHall;
                            aBookingHalls.PercentTax = aHallsEN.PercentTax;
                            aBookingHalls.Cost = aHallsEN.Cost;
                            aBookingHalls.Status = 8;//da thanh toan
                            aBookingHallsBO.Update(aBookingHalls);
                        }
                    }
                    BookingHsBO aBookingHsBO = new BookingHsBO();
                    BookingHs aBookingHs = aBookingHsBO.Select_ByID(this.aPaymentHallsEN.IDBookingH);
                    List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookingH_ByStatus(this.aPaymentHallsEN.IDBookingH,8);
                    if (aListBookingHalls.Count < 1)
                    {
                        aBookingHs.ID = aPaymentHallsEN.IDBookingH;
                        aBookingHs.PayMenthod = this.aPaymentHallsEN.PayMenthod;
                        aBookingHs.StatusPay = 3;
                        aBookingHs.Status = 8;
                        btnPayment.Enabled = false;
                    }
                    aBookingHs.BookingMoney = this.aPaymentHallsEN.GetBookingMoney();
                    aBookingHsBO.Update(aBookingHs);

                    MessageBox.Show("Thanh toán thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_SplitBillHalls_Step2_Load.btnPayment_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //hiennv
        public bool LoadDataBookingHalls()
        {
            try
            {
                if (dtpFrom.DateTime.Date > dtpTo.DateTime.Date)
                {
                    dtpFrom.Focus();
                    MessageBox.Show("Vui lòng nhập ngày bắt đầu tìm kiếm phải nhỏ hơn hoặc bằng ngày kết thúc tìm kiếm.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return true;
                }
                else
                {
                    ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
                    BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                    List<BookingHallsEN> aListTemp = new List<BookingHallsEN>();
                    List<BookingHallsEN> aListBookingHallsEN = new List<BookingHallsEN>();

                    int choose = cboChoose.SelectedIndex;
                    int level = Convert.ToInt32(lueBookingHs_Level.EditValue);

                    if (choose == 0) // Tất cả hội trường
                    {
                        colDetail.Visible = true;
                        colCreateMenu.Visible = false;
                        colNameGuest.Visible = false;
                        gridColumn1.Visible = false;

                        aListTemp = aReceptionTaskBO.GetListBookingHallsIsUse_ByBookingHallsDate(dtpFrom.DateTime.Date, dtpTo.DateTime.Date);
                    }
                    else if (choose == 1) // Tiệc VIP
                    {
                        colDetail.Visible = true;
                        colCreateMenu.Visible = false;
                        colNameGuest.Visible = false;
                        gridColumn1.Visible = false;
                        aListTemp = aReceptionTaskBO.GetListBookingHalls_ByBookingHallsDate_ByBookingHsLevel(dtpFrom.DateTime, dtpTo.DateTime, level);
                    }
                    else if (choose == 2) // Tiệc chưa accept
                    {
                        colDetail.Visible = true;
                        colCreateMenu.Visible = true;
                        colNameGuest.Visible = false;
                        gridColumn1.Visible = false;
                        aListTemp = aReceptionTaskBO.GetListBookingHalls_ByBookingHallDate_ByBookingHallStatus(dtpFrom.DateTime, dtpTo.DateTime, 1); // bep chua accept
                    }
                    //else if (choose == 3) // Tiệc đã accept nhưng chưa có thực đơn
                    //{
                    //    colDetail.Visible = true;
                    //    colCreateMenu.Visible = true;
                    //    colNameGuest.Visible = false;
                    //    gridColumn1.Visible = false;
                    //    aListTemp = aReceptionTaskBO.GetListBookingHallsAcceptedButHaveNotMenus(dtpFrom.DateTime, dtpTo.DateTime); // bep da accept
                    //}
                    else if (choose == 4)// Bếp đã lên thực đơn
                    {
                        colDetail.Visible = true;
                        colCreateMenu.Visible = false;
                        colNameGuest.Visible = false;
                        gridColumn1.Visible = true;
                        aListTemp = aReceptionTaskBO.GetListBookingHallsHaveMenus(dtpFrom.DateTime, dtpTo.DateTime);
                    }
                    else if (choose == 5) //Đã lựa chọn thực đơn
                    {
                        colDetail.Visible = true;
                        colCreateMenu.Visible = false;
                        colNameGuest.Visible = false;
                        gridColumn1.Visible = false;
                        aListTemp = aReceptionTaskBO.GetListBookingHallsSelectedMenus(dtpFrom.DateTime, dtpTo.DateTime);
                    }

                    else if (choose == 6) // tim kiem tiec theo khach moi
                    {
                        colDetail.Visible = true;
                        colCreateMenu.Visible = false;
                        colNameGuest.VisibleIndex = 1;
                        colNameGuest.Visible = true;
                        gridColumn1.Visible = false;

                        aListTemp = aReceptionTaskBO.GetListBookingHalls_ByBookingHallsDate_ByNameGuest(dtpFrom.DateTime, dtpTo.DateTime,txtNameGuest.Text);
                    }
                    BookingHallsEN aBookingHallsEN;
                    foreach (BookingHallsEN item in aListTemp)
                    {
                        aBookingHallsEN = new BookingHallsEN();
                        aBookingHallsEN.IDBookingH = item.IDBookingH;
                        aBookingHallsEN.DisplayCustomerType = CORE.CONSTANTS.SelectedCustomerType(Convert.ToInt32(item.CustomerTypeBookingH)).Name;
                        aBookingHallsEN.IDBookingHall = item.IDBookingHall;
                        aBookingHallsEN.BookingStatusBookingHall = item.BookingStatusBookingHall;
                        aBookingHallsEN.NameCustomer = item.NameCustomer;
                        aBookingHallsEN.NameCustomerGroup = item.NameCustomerGroup;
                        aBookingHallsEN.DateBookingHall = item.DateBookingHall;
                        aBookingHallsEN.LunarDateBookingHall = item.LunarDateBookingHall;
                        aBookingHallsEN.StartTimeBookingHall = item.StartTimeBookingHall;
                        aBookingHallsEN.EndTimeBookingHall = item.EndTimeBookingHall;
                        aBookingHallsEN.BookingTypeBookingH = item.BookingTypeBookingH;

                        aBookingHallsEN.StatusPayBookingH = item.StatusPayBookingH;
                        aBookingHallsEN.NoteBookingH = item.NoteBookingH;
                        aBookingHallsEN.DisplayBookingType = CORE.CONSTANTS.SelectedBookingType(Convert.ToInt32(item.BookingTypeBookingH)).Name;
                        aBookingHallsEN.DisplayLevel = CORE.CONSTANTS.SelectedLevel(Convert.ToInt32(item.LevelBookingH)).Name;
                        aBookingHallsEN.SkuHall = item.SkuHall;
                        aBookingHallsEN.NameGuest = item.NameGuest;
                        aListBookingHallsEN.Add(aBookingHallsEN);
                    }
                    dgvBookingHalls.DataSource = aListBookingHallsEN;
                    dgvBookingHalls.RefreshDataSource();
                    if (aListBookingHallsEN.Count > 0)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_SearchBookingHalls.LoadDataBookingHalls\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return true;
            }
        }
 private void btnSearchHall_Click(object sender, EventArgs e)
 {
     try
     {
         BookingHallsBO aBookingHallsBO = new BookingHallsBO();
         aListAvailableHall = aBookingHallsBO.GetListStatusHall(dtpFrom.DateTime, false).Where(p => p.HallStatus == 0).ToList();
         dgvAvailableHalls.DataSource = aListAvailableHall;
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_BookingHall_Customer_New.btnSearchHalls_Click\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        //Hiennv
        private void lueIndexSub_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                int indexSub = Convert.ToInt32(lueIndexSub.Text);
                this.LoadListHall_ByIndexSubHall(this.aPaymentHallsEN, indexSub);
                this.LoadListServices_ByIndexSubServices(this.aPaymentHallsEN, indexSub);

                List<IndexSubSplitBillEN> aListIndexSubSplitBillEN = this.aPaymentHallsEN.aListIndexSubSplitBillH.Where(sub => sub.IndexSub == indexSub && sub.SubStatus > 0).ToList();
                if (aListIndexSubSplitBillEN.Count < 1)
                {
                    decimal? totalBill = this.aListServices.Sum(s => s.Total) + this.aListServices.Sum(r => r.Total);

                    decimal? totalBookingMoney = this.aPaymentHallsEN.GetBookingMoney();

                    if ((totalBill - totalBookingMoney) == 0)
                    {
                        this.aPaymentHallsEN.SetSubBookingMoney(indexSub, totalBookingMoney);
                        this.aPaymentHallsEN.SetSubStatus(indexSub, indexSub); //SubStatus dung de phan biet so tien ung truoc cho tung subBookingmoney

                        this.aPaymentHallsEN.SetBookingMoney(0); // set lai so tien ung truoc bang 0;
                    }
                    else if ((totalBill - totalBookingMoney) > 0)
                    {
                        this.aPaymentHallsEN.SetSubBookingMoney(indexSub, totalBookingMoney);
                        this.aPaymentHallsEN.SetSubStatus(indexSub, indexSub);//SubStatus dung de phan biet so tien ung truoc cho tung subBookingmoney

                        this.aPaymentHallsEN.SetBookingMoney(0); // set lai so tien ung truoc bang 0;
                    }
                    else if ((totalBill - totalBookingMoney) < 0)
                    {
                        BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                        List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookingH_ByStatus(this.aPaymentHallsEN.IDBookingH, 8);
                        if (aListBookingHalls.Count < 2)
                        {
                            this.aPaymentHallsEN.SetSubBookingMoney(indexSub, totalBookingMoney);
                            this.aPaymentHallsEN.SetSubStatus(indexSub, indexSub);//SubStatus dung de phan biet so tien ung truoc cho tung subBookingmoney

                            this.aPaymentHallsEN.SetBookingMoney(0); // set lai so tien ung truoc bang 0;
                        }
                        else
                        {
                            this.aPaymentHallsEN.SetSubBookingMoney(indexSub, totalBill);
                            this.aPaymentHallsEN.SetSubStatus(indexSub, indexSub);//SubStatus dung de phan biet so tien ung truoc cho tung subBookingmoney

                            this.aPaymentHallsEN.SetBookingMoney((totalBookingMoney - totalBill));
                        }
                    }

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_SplitBillHalls_Step2_Load.lueIndexSub_EditValueChanged\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        // Author : Linhting
        public void InitData( int IDBookingH)
        {
            try
            {
                CompaniesBO aCompaniesBO = new CompaniesBO();
                CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
                SystemUsersBO aSystemUsersBO = new SystemUsersBO();
                BookingHsBO aBookingHsBO = new BookingHsBO();
                CustomersBO aCustomersBO = new CustomersBO();
                ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
                HallsBO aHallsBO = new HallsBO();
                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                FoodsBO aFoodsBO = new FoodsBO();

                BookingHs aBookingHs = aBookingHsBO.Select_ByID(IDBookingH);

                    // Truyen du lieu cho List BookingRoom cua NewPayment

                    if (aBookingHs != null)
                    {
                         aNewPaymentEN.IDCustomer = aBookingHs.IDCustomer;
                    Customers aCustomers = aCustomersBO.Select_ByID(aBookingHs.IDCustomer);
                    if (aCustomers != null)
                    {
                        aNewPaymentEN.NameCustomer = aCustomers.Name;
                    }
                    aNewPaymentEN.IDSystemUser = aBookingHs.IDSystemUser;
                    SystemUsers aSystemUsers = aSystemUsersBO.Select_ByID(aBookingHs.IDSystemUser);
                    if (aSystemUsers != null)
                    {
                        aNewPaymentEN.NameSystemUser = aSystemUsers.Name;
                    }
                    aNewPaymentEN.IDCustomerGroup = aBookingHs.IDCustomerGroup;
                    CustomerGroups aCustomerGroups = aCustomerGroupsBO.Select_ByID(aBookingHs.IDCustomerGroup);
                    if (aCustomerGroups != null)
                    {
                        aNewPaymentEN.NameCustomerGroup = aCustomerGroups.Name;
                        aNewPaymentEN.IDCompany = aCustomerGroups.IDCompany;
                        Companies aCompanies = aCompaniesBO.Select_ByID(aCustomerGroups.IDCompany);
                        if (aCompanies != null)
                        {
                            aNewPaymentEN.NameCompany = aCompanies.Name;
                            aNewPaymentEN.TaxNumberCodeCompany = aCompanies.TaxNumberCode;
                            aNewPaymentEN.AddressCompany = aCompanies.Address;
                        }
                    }
                        aNewPaymentEN.IDBookingH = aBookingHs.ID;
                        aNewPaymentEN.CreatedDate_BookingH = aBookingHs.CreatedDate;
                        aNewPaymentEN.CustomerType = aBookingHs.CustomerType;
                        aNewPaymentEN.Status_BookingH = aBookingHs.Status;
                        aNewPaymentEN.BookingHMoney = aBookingHs.BookingMoney;

                        // Truyen du lieu cho List BookingHall cua NewPayment
                        List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookigH(this.IDBookingH);
                        if (aListBookingHalls != null)
                        {
                            BookingHallUsedEN aBookingHallUsedEN;
                            foreach (BookingHalls item in aListBookingHalls)
                            {
                                aBookingHallUsedEN = new BookingHallUsedEN();
                                aBookingHallUsedEN.SetValue(item);
                                Halls aHalls = aHallsBO.Select_ByCodeHall(item.CodeHall, 1);
                                if (aHalls != null)
                                {
                                    aBookingHallUsedEN.HallSku = aHalls.Sku;
                                }
                                else
                                {
                                    aBookingHallUsedEN.HallSku = string.Empty;
                                }
                                aBookingHallUsedEN.CustomerType = aBookingHs.CustomerType;
                                aBookingHallUsedEN.BookingTypeBookingH = aBookingHs.BookingType;
                                aBookingHallUsedEN.StatusPayBookingH = aBookingHs.StatusPay;
                                aBookingHallUsedEN.LevelBookingH = aBookingHs.Level;
                                aBookingHallUsedEN.aListMenuEN = aReceptionTaskBO.GetListMenus_ByIDBookingHall(item.ID);

                                List<ServiceUsedEN> aListServiceTemp = aReceptionTaskBO.GetListServiceUsedInHall_ByIDBookingHall(item.ID);
                                foreach (ServiceUsedEN aTemp in aListServiceTemp)
                                {
                                    aBookingHallUsedEN.aListServiceUsed.Add(aTemp);
                                }
                                aNewPaymentEN.aListBookingHallUsed.Add(aBookingHallUsedEN);
                            }
                        }
                    }

                }

            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_PaymentHall.InitData\n" + ex.ToString());
            }
        }
        public void InitData(int IDBookingH)
        {
            CompaniesBO aCompaniesBO = new CompaniesBO();
            CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
            SystemUsersBO aSystemUsersBO = new SystemUsersBO();
            BookingHsBO aBookingHsBO = new BookingHsBO();
            ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
            HallsBO aHallsBO = new HallsBO();
            BookingHallsBO aBookingHallsBO = new BookingHallsBO();
            FoodsBO aFoodsBO = new FoodsBO();
            List<int> aListIndexTemp = new List<int>();

            BookingHs aBookingHs = aBookingHsBO.Select_ByID(IDBookingH);
            if (aBookingHs != null)
            {
                aNewPaymentHEN.IDCustomer = aBookingHs.IDCustomer;
                Customers aCustomers = aCustomersBO.Select_ByID(aBookingHs.IDCustomer);
                if (aCustomers != null)
                {
                    aNewPaymentHEN.NameCustomer = aCustomers.Name;
                }
                aNewPaymentHEN.IDSystemUser = aBookingHs.IDSystemUser;
                SystemUsers aSystemUsers = aSystemUsersBO.Select_ByID(aBookingHs.IDSystemUser);
                if (aSystemUsers != null)
                {
                    aNewPaymentHEN.NameSystemUser = aSystemUsers.Name;
                }
                aNewPaymentHEN.IDCustomerGroup = aBookingHs.IDCustomerGroup;
                CustomerGroups aCustomerGroups = aCustomerGroupsBO.Select_ByID(aBookingHs.IDCustomerGroup);
                if (aCustomerGroups != null)
                {
                    aNewPaymentHEN.NameCustomerGroup = aCustomerGroups.Name;
                    aNewPaymentHEN.IDCompany = aCustomerGroups.IDCompany;
                    Companies aCompanies = aCompaniesBO.Select_ByID(aCustomerGroups.IDCompany);
                    if (aCompanies != null)
                    {
                        aNewPaymentHEN.NameCompany = aCompanies.Name;
                        aNewPaymentHEN.TaxNumberCodeCompany = aCompanies.TaxNumberCode;
                        aNewPaymentHEN.AddressCompany = aCompanies.Address;
                    }
                }
                aNewPaymentHEN.Subject = aBookingHs.Subject;
                aNewPaymentHEN.PayMenthodH = aBookingHs.PayMenthod;
                aNewPaymentHEN.CreatedDate_BookingH = aBookingHs.CreatedDate;
                aNewPaymentHEN.CustomerType = aBookingHs.CustomerType;
                aNewPaymentHEN.Status_BookingH = aBookingHs.Status;
                aNewPaymentHEN.StatusPay = aBookingHs.StatusPay;
                aNewPaymentHEN.BookingHMoney = aBookingHs.BookingMoney;
                aNewPaymentHEN.AcceptDate = aBookingHs.AcceptDate;
                aNewPaymentHEN.InvoiceDate = aBookingHs.InvoiceDate;
                aNewPaymentHEN.InvoiceNumber = aBookingHs.InvoiceNumber;
                this.aNewPaymentHEN.IDBookingH = aBookingHs.ID;
                this.aNewPaymentHEN.PayMenthodH = aBookingHs.PayMenthod;
                this.aNewPaymentHEN.CreatedDate_BookingH = aBookingHs.CreatedDate;
                this.aNewPaymentHEN.CustomerType = aBookingHs.CustomerType;
                this.aNewPaymentHEN.Status_BookingH = aBookingHs.Status;
                this.aNewPaymentHEN.BookingHMoney = aBookingHs.BookingMoney;
                // Truyen du lieu cho List BookingHall cua NewPayment
                List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookigH(this.IDBookingH);
                if (aListBookingHalls != null)
                {
                    BookingHallUsedEN aBookingHallUsedEN;
                    foreach (BookingHalls item in aListBookingHalls)
                    {
                        aBookingHallUsedEN = new BookingHallUsedEN();
                        aBookingHallUsedEN.SetValue(item);
                        Halls aHalls = aHallsBO.Select_ByCodeHall(item.CodeHall, 1);
                        if (aHalls != null)
                        {
                            aBookingHallUsedEN.HallSku = aHalls.Sku;
                        }
                        else
                        {
                            aBookingHallUsedEN.HallSku = string.Empty;
                        }
                        aBookingHallUsedEN.CustomerType = aBookingHs.CustomerType;
                        aBookingHallUsedEN.BookingTypeBookingH = aBookingHs.BookingType;
                        aBookingHallUsedEN.StatusPayBookingH = aBookingHs.StatusPay;
                        aBookingHallUsedEN.LevelBookingH = aBookingHs.Level;
                        aBookingHallUsedEN.aListMenuEN = aReceptionTaskBO.GetListMenus_ByIDBookingHall(item.ID);

                        aListIndexTemp.Add(Convert.ToInt32(aBookingHallUsedEN.IndexSubPayment));
                        List<ServiceUsedEN> aListServiceTemp = aReceptionTaskBO.GetListServiceUsedInHall_ByIDBookingHall(item.ID);
                        foreach (ServiceUsedEN aTemp in aListServiceTemp)
                        {
                            aBookingHallUsedEN.aListServiceUsed.Add(aTemp);
                            aListIndexTemp.Add(Convert.ToInt32(aTemp.IndexSubPayment));
                        }
                        aNewPaymentHEN.aListBookingHallUsed.Add(aBookingHallUsedEN);

                    }
                }
            }
            aNewPaymentHEN.ListIndex = aListIndexTemp.Distinct().ToList();
        }
        //Hiennv        31/08/2014           Thanh toan le cho hoi truong
        public void SplitPaymentForBookingH(NewPaymentEN aNewPaymentEN, List<BookingHallUsedEN> aListHalls, List<ServiceUsedEN> aListServicesH)
        {
            try
            {
                foreach (ServiceUsedEN aServicesEN in aListServicesH)
                {

                    aServicesEN.StatusPay = 8;
                    aServicesEN.Save(2);
                }

                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                foreach (BookingHallUsedEN aHallsEN in aListHalls)
                {
                    aHallsEN.Status = 8;
                    aHallsEN.Save();
                }
                BookingHsBO aBookingHsBO = new BookingHsBO();
                BookingHs aBookingHs = aBookingHsBO.Select_ByID(Convert.ToInt32(aNewPaymentEN.IDBookingH));
                List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookingH_ByStatus(Convert.ToInt32(aNewPaymentEN.IDBookingH), 8);
                if (aListBookingHalls.Count < 1)
                {
                    aBookingHs.ID = Convert.ToInt32(aNewPaymentEN.IDBookingH);
                    aBookingHs.PayMenthod = aNewPaymentEN.PayMenthodH;
                    aBookingHs.StatusPay = 3;
                    aBookingHs.Status = 8;
                    aBookingHs.DatePay = DateTime.Now;
                }
                aBookingHs.BookingMoney = aNewPaymentEN.BookingHMoney;
                aBookingHsBO.Update(aBookingHs);
            }
            catch (Exception ex)
            {
                throw new Exception("ReceptionTaskBO.SplitPaymentForBookingH \n" + ex.ToString());
            }
        }
        //hiennv
        public void InitData(PaymentHallsEN aPaymentHallsEN, int IDBookingH)
        {
            try
            {
                HallsBO aHallsBO = new HallsBO();
                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                FoodsBO aFoodsBO = new FoodsBO();
                ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
                CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
                CustomersBO aCustomersBO = new CustomersBO();
                BookingHsBO aBookingHsBO = new BookingHsBO();
                CompaniesBO aCompaniesBO = new CompaniesBO();
                SystemUsersBO aSystemUsersBO = new SystemUsersBO();

                BookingHs aBookingHs = aBookingHsBO.Select_ByID(IDBookingH);
                if (aBookingHs != null)
                {
                    aPaymentHallsEN.IDBookingH = aBookingHs.ID;
                    aPaymentHallsEN.IDCustomerGroup = aBookingHs.IDCustomerGroup;
                    CustomerGroups aCustomerGroups = aCustomerGroupsBO.Select_ByID(aBookingHs.IDCustomerGroup);
                    if (aCustomerGroups != null)
                    {
                        aPaymentHallsEN.NameCustomerGroup = aCustomerGroups.Name;
                        aPaymentHallsEN.IDCompany = aCustomerGroups.IDCompany;
                        Companies aCompanies = aCompaniesBO.Select_ByID(aCustomerGroups.IDCompany);
                        if (aCompanies != null)
                        {
                            aPaymentHallsEN.NameCompany = aCompanies.Name;
                            aPaymentHallsEN.TaxNumberCodeCompany = aCompanies.TaxNumberCode;
                        }
                    }
                    aPaymentHallsEN.IDCustomer = aBookingHs.IDCustomer;
                    Customers aCustomers = aCustomersBO.Select_ByID(aBookingHs.IDCustomer);
                    if (aCustomers != null)
                    {
                        aPaymentHallsEN.NameCustomer = aCustomers.Name;

                    }
                    aPaymentHallsEN.IDSystemUser = aBookingHs.IDSystemUser;
                    SystemUsers aSystemUsers = aSystemUsersBO.Select_ByID(aBookingHs.IDSystemUser);
                    if (aSystemUsers != null)
                    {
                        aPaymentHallsEN.NameSystemUser = aSystemUsers.Name;
                    }
                    aPaymentHallsEN.CreatedDate_BookingH = aBookingHs.CreatedDate;
                    aPaymentHallsEN.CustomerType = aBookingHs.CustomerType;
                    aPaymentHallsEN.BookingType = aBookingHs.BookingType;
                    aPaymentHallsEN.PayMenthod = aBookingHs.PayMenthod;
                    aPaymentHallsEN.StatusPay = aBookingHs.StatusPay;
                    aPaymentHallsEN.Status_BookingH = aBookingHs.Status;
                    aPaymentHallsEN.ExchangeRate = aBookingHs.ExchangeRate;
                    aPaymentHallsEN.Level = aBookingHs.Level;
                    aPaymentHallsEN.BookingMoney = aBookingHs.BookingMoney;
                }

                List<BookingHalls> aListBookingHalls = new List<BookingHalls>();
                aListBookingHalls = aBookingHallsBO.Select_ByIDBookigH(IDBookingH);
                InfoDetailPaymentHallsEN aInfoDetailPaymentHallsEN;
                for (int i = 0; i < aListBookingHalls.Count; i++)
                {
                    aInfoDetailPaymentHallsEN = new InfoDetailPaymentHallsEN();
                    Halls aHalls = aHallsBO.Select_ByCodeHall(aListBookingHalls[i].CodeHall, 1);
                    if (aHalls != null)
                    {
                        aInfoDetailPaymentHallsEN.Sku = aHalls.Sku;
                    }
                    else
                    {
                        aInfoDetailPaymentHallsEN.Sku = string.Empty;
                    }
                    aInfoDetailPaymentHallsEN.aBookingHalls = aListBookingHalls[i];
                    aInfoDetailPaymentHallsEN.aMenusEN = aReceptionTaskBO.GetDetailMenu_ByIDBookingHall(aListBookingHalls[i].ID);
                    aInfoDetailPaymentHallsEN.aListServicesHallsEN = aReceptionTaskBO.GetListServicesHallsEN_ByIDBookingHall(aListBookingHalls[i].ID);

                    aPaymentHallsEN.aListInfoDetailPaymentHallsEN.Insert(i, aInfoDetailPaymentHallsEN);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_PaymentHall.InitData\n" + ex.ToString());
            }
        }
        public void Reload()
        {
            try
            {
                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                List<BookingHallsEN> aListBookingHall = new List<BookingHallsEN>();
                BookingHallsEN aBookingHallsEN = new BookingHallsEN();
                BookingHalls aBookingHalls = aBookingHallsBO.Select_ByID(IDBookingHall);
                aBookingHallsEN.ID = aBookingHalls.ID;
                aBookingHallsEN.HallSku = aHallsBO.Select_ByCodeHall(aBookingHalls.CodeHall, 1).Sku;
                aListBookingHall.Add(aBookingHallsEN);

                dtpDate.DateTime = aBookingHalls.Date.GetValueOrDefault();
                dgvHalls.DataSource = aListBookingHall;
                dgvHalls.RefreshDataSource();

                ServicesBO aServicesBO = new ServicesBO();
                aListAvailable = aServicesBO.Select_ByType(1);
                dgvService.DataSource = aListAvailable;
                dgvService.RefreshDataSource();

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_BookingHalls_Services.Reload\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }
 private void grvBookingRs_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     BookingHallsBO aBookingHallsBO = new BookingHallsBO();
     List<BookingHall_ServiceEN> aListBookingHall_ServiceEN = new List<BookingHall_ServiceEN>();
     HallsBO aHallsBO = new HallsBO();
     int IDBookingH = Convert.ToInt32(grvBookingRs.GetFocusedRowCellValue("ID"));
     List<BookingHallsEN> aListBookingHalls = new List<BookingHallsEN>();
     List<BookingHalls> aListTemp = new List<BookingHalls>();
     aListTemp = aBookingHallsBO.Select_ByIDBookigH(IDBookingH);
     BookingHallsEN aBookingHallsEN;
     for (int i = 0; i < aListTemp.Count; i++)
     {
         aBookingHallsEN = new BookingHallsEN();
         aBookingHallsEN.SkuHall = aHallsBO.Select_ByCodeHall(aListTemp[i].CodeHall, 1).Sku;
         aBookingHallsEN.ID = aListTemp[i].ID;
         aBookingHallsEN.Cost = aListTemp[i].Cost;
         aBookingHallsEN.StartTime = aListTemp[i].StartTime;
         aBookingHallsEN.EndTime = aListTemp[i].EndTime;
         aListBookingHalls.Add(aBookingHallsEN);
     }
     dgvListBookingHalls.DataSource = aListBookingHalls;
     dgvListBookingHalls.RefreshDataSource();
     dgvServiceInBookingHall.DataSource = aListBookingHall_ServiceEN;
     dgvServiceInBookingHall.RefreshDataSource();
 }
 private void grvBookingRs_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     try
     {
         BookingHallsBO aBookingHallsBO = new BookingHallsBO();
         List<BookingHall_ServiceEN> aListBookingHall_ServiceEN = new List<BookingHall_ServiceEN>();
         HallsBO aHallsBO = new HallsBO();
         int IDBookingH = Convert.ToInt32(grvBookingRs.GetFocusedRowCellValue("ID"));
         List<BookingHallsEN> aListBookingHalls = new List<BookingHallsEN>();
         List<BookingHalls> aListTemp = new List<BookingHalls>();
         aListTemp = aBookingHallsBO.Select_ByIDBookigH(IDBookingH);
         BookingHallsEN aBookingHallsEN;
         for (int i = 0; i < aListTemp.Count; i++)
         {
             aBookingHallsEN = new BookingHallsEN();
             aBookingHallsEN.SkuHall = aHallsBO.Select_ByCodeHall(aListTemp[i].CodeHall, 1).Sku;
             aBookingHallsEN.ID = aListTemp[i].ID;
             aBookingHallsEN.Cost = aListTemp[i].Cost;
             aBookingHallsEN.StartTime = aListTemp[i].StartTime;
             aBookingHallsEN.EndTime = aListTemp[i].EndTime;
             aListBookingHalls.Add(aBookingHallsEN);
         }
         dgvListBookingHalls.DataSource = aListBookingHalls;
         dgvListBookingHalls.RefreshDataSource();
         dgvServiceInBookingHall.DataSource = aListBookingHall_ServiceEN;
         dgvServiceInBookingHall.RefreshDataSource();
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_UnpayBookingHs.grvBookingRs_RowClick\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void btnSearchHalls_Click(object sender, EventArgs e)
        {
            try
            {
                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                bool IsLunar;
                if (cbbLunarDate.Text == "Dương")
                {
                    IsLunar = false;
                }
                else
                {
                    IsLunar = true;
                }
                aListAvailableHall = aBookingHallsBO.GetListStatusHall(dtpFrom.DateTime, IsLunar).Where(p => p.HallStatus == 0).ToList();
                dgvAvailableHalls.DataSource = aListAvailableHall;

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_UpdBooking.btnSearchHalls_Click\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //Linhting - Book hội trường mới
        public int NewBookHall(NewBookingHEN aNewBookingHEN)
        {
            try
            {
                BookingHalls_ServicesBO aBookingHalls_ServicesBO = new BookingHalls_ServicesBO();

                //Tạo BookingH mới
                BookingHs aBookingHs = new BookingHs();

                aBookingHs.CreatedDate = aNewBookingHEN.CreatedDate;
                aBookingHs.CustomerType = aNewBookingHEN.CustomerType;
                aBookingHs.BookingType = aNewBookingHEN.BookingType;
                aBookingHs.Note = aNewBookingHEN.Note;
                aBookingHs.IDGuest = 0;
                aBookingHs.StatusPay = aNewBookingHEN.StatusPay;
                aBookingHs.BookingMoney = aNewBookingHEN.BookingMoney;
                aBookingHs.Status = aNewBookingHEN.Status;
                aBookingHs.Type = aNewBookingHEN.Type;
                aBookingHs.Disable = aNewBookingHEN.Disable;
                aBookingHs.Level = aNewBookingHEN.Level;
                aBookingHs.Subject = aNewBookingHEN.Subject;
                aBookingHs.IDCustomerGroup = aNewBookingHEN.IDCustomerGroup;
                aBookingHs.IDCustomer = aNewBookingHEN.IDCustomer;
                aBookingHs.IDSystemUser = aNewBookingHEN.IDSystemUser;
                aBookingHs.Description = aNewBookingHEN.Description;

                //Tạo BookingHall mới
                BookingHsBO aBookingHsBO = new BookingHsBO();
                int IDBookingH = aBookingHsBO.InsertUnSync(aBookingHs);

                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                BookingHalls aBookingHall;
                for (int i = 0; i < aNewBookingHEN.aListBookingHallUsed.Count; i++)
                {
                    aBookingHall = new BookingHalls();
                    aBookingHall.IDBookingH = IDBookingH;
                    aBookingHall.CodeHall = aNewBookingHEN.aListBookingHallUsed[i].CodeHall;
                    aBookingHall.Cost = aNewBookingHEN.aListBookingHallUsed[i].Cost;
                    aBookingHall.PercentTax = 10; //Để tạm thuế = 10%
                    aBookingHall.CostRef_Halls = aNewBookingHEN.aListBookingHallUsed[i].CostRef_Halls;
                    aBookingHall.Date = aNewBookingHEN.aListBookingHallUsed[i].Date;
                    aBookingHall.LunarDate = aNewBookingHEN.aListBookingHallUsed[i].LunarDate;
                    aBookingHall.BookingStatus = aNewBookingHEN.aListBookingHallUsed[i].BookingStatus;
                    aBookingHall.Unit = aNewBookingHEN.aListBookingHallUsed[i].Unit;
                    aBookingHall.TableOrPerson = aNewBookingHEN.aListBookingHallUsed[i].TableOrPerson;
                    aBookingHall.Note = aNewBookingHEN.aListBookingHallUsed[i].Note;
                    aBookingHall.Status = aNewBookingHEN.aListBookingHallUsed[i].Status;
                    aBookingHall.StartTime = aNewBookingHEN.aListBookingHallUsed[i].StartTime;
                    aBookingHall.EndTime = aNewBookingHEN.aListBookingHallUsed[i].EndTime;
                    aBookingHall.Location = aNewBookingHEN.aListBookingHallUsed[i].Location;
                    aBookingHall.Color = aNewBookingHEN.aListBookingHallUsed[i].Color;

                    aBookingHallsBO.InsertUnSync(aBookingHall);
                    int IDBookingHall = aBookingHall.ID;
                    // Thêm dịch vụ đã chọn vào hội trường
                    foreach (ServiceUsedEN aTemp in aNewBookingHEN.aListBookingHallUsed[i].aListServiceUsed)
                    {
                        BookingHalls_Services aBookingHalls_Services = new BookingHalls_Services();
                        aBookingHalls_Services.Info = "";
                        aBookingHalls_Services.Type = 1;
                        aBookingHalls_Services.Status = 1;
                        aBookingHalls_Services.Disable = false;
                        aBookingHalls_Services.IDBookingHall = aBookingHall.ID;
                        aBookingHalls_Services.IDService = aTemp.IDService;
                        aBookingHalls_Services.Cost = aTemp.Cost;
                        aBookingHalls_Services.Date = aTemp.DateUsed;
                        aBookingHalls_Services.CostRef_Services = aTemp.CostRef_Service;
                        aBookingHalls_Services.PercentTax = 10;// de mac dinh
                        aBookingHalls_Services.Quantity = aTemp.Quantity;
                        aBookingHalls_ServicesBO.Insert(aBookingHalls_Services);

                    }
                    // Thêm thực đơn vào hội trường
                    foreach (MenusEN aMenuEN in aNewBookingHEN.aListBookingHallUsed[i].aListMenuEN)
                    {
                        aMenuEN.IDBookingHall = IDBookingHall;
                        aMenuEN.Type = 1; // type =1 ; thuc don mau ; Type 2: thuc don moi
                        aMenuEN.Status = 1; // de tam
                        aMenuEN.Disable = false; // de tam
                        aMenuEN.IDSystemUser = 1;//Khi kinh doanh thêm thực đơn mặc định trạng thái là 0 - đã xác nhận thực đơn
                        this.CreateMenus(aMenuEN);
                    }

                }

                return IDBookingH;

            }
            catch (Exception ex)
            {

                throw new Exception("ReceptionTaskBO.NewBookHall\n" + ex.ToString());
            }
        }