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);
     }
 }
        //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;
            }
        }
        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 List<BookingHallsEN> GetListBookingHalls(List<BookingHallsEN> aListBookingHallTemp)
        {
            try
            {
                List<BookingHallsEN> aListBookingHallsEN = new List<BookingHallsEN>();
                BookingHallsEN aBookingHallsEN;
                MenusBO aMenusBO = new MenusBO();

                foreach (BookingHallsEN item in aListBookingHallTemp)
                {
                    aBookingHallsEN = new BookingHallsEN();
                    aBookingHallsEN.IDBookingH = item.IDBookingH;
                    aBookingHallsEN.DisplayCustomerType = CORE.CONSTANTS.SelectedCustomerType(Convert.ToInt32(item.CustomerType)).Name;
                    aBookingHallsEN.ID = item.ID;
                    aBookingHallsEN.BookingStatus = item.BookingStatus;

                    aBookingHallsEN.NameGuest = item.NameGuest;

                    aBookingHallsEN.Date = item.Date;
                    aBookingHallsEN.LunarDate= item.LunarDate;
                    aBookingHallsEN.StartTime = item.StartTime;
                    aBookingHallsEN.EndTime = item.EndTime;
                    aBookingHallsEN.BookingTypeBookingH = item.BookingTypeBookingH;

                    aBookingHallsEN.StatusPayBookingH = item.StatusPayBookingH;
                    aBookingHallsEN.DisplayBookingType = CORE.CONSTANTS.SelectedBookingType(Convert.ToInt32(item.BookingTypeBookingH)).Name;

                    aBookingHallsEN.DisplayLevel = CORE.CONSTANTS.SelectedLevel(Convert.ToInt32(item.LevelBookingH)).Name;
                    aBookingHallsEN.HallSku = item.HallSku;
                    List<Menus> aListMenus = aMenusBO.Select_ByIDBookingHall(item.ID);
                    if (aListMenus.Count > 0)
                    {
                        aBookingHallsEN.HasMenu = " Có";
                    }
                    else
                    {
                        aBookingHallsEN.HasMenu = " Chưa có";
                    }
                    aListBookingHallsEN.Add(aBookingHallsEN);
                }
                return aListBookingHallsEN;
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_CheckMenus.GetListBookingHalls\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
        }