//public decimal? CalculateCostRoom(NewPaymentEN aNewPaymentEN, int IDBookingRoom, string PriceType)
        //{
        //    if (aNewPaymentEN.aListBookingRoomUsed.Where(a => a.ID == IDBookingRoom).ToList().Count > 0)
        //    {
        //        CustomersBO aCustomersBO = new CustomersBO();
        //        ExtraCostBO aExtraCostBO = new ExtraCostBO();
        //        RoomsBO aRoomsBO = new RoomsBO();
        //        BookingRoomUsedEN aTemp = aNewPaymentEN.aListBookingRoomUsed.Where(a => a.ID == IDBookingRoom).ToList()[0];
        //        List<Customers> aListCustomers = aCustomersBO.SelectListCustomer_ByIDBookingRoom(IDBookingRoom);
        //        if (aListCustomers.Count >0 )
        //        {
        //        int CustomerType = Convert.ToInt32(aNewPaymentEN.CustomerType);
        //        decimal? CostRoom = 0;
        //        //if (aTemp.Cost != 0)
        //        //{
        //        //    CostRoom = aTemp.Cost - Convert.ToDecimal(aExtraCostBO.Select_BySku_ByPriceType_ByNumberPeople(aTemp.RoomSku, aTemp.PriceType, aTemp.ListCustomer.Count).ExtraValue);
        //        //}
        //        //else
        //        //{
        //        CostRoom = aRoomsBO.Select_ByIDBookingRoom(IDBookingRoom).CostRef;
        //        //}
        //        string RoomSku = aTemp.RoomSku;
        //        decimal ExtraMoneyRoom = Convert.ToDecimal(aExtraCostBO.Select_BySku_ByPriceType_ByNumberPeople(RoomSku, PriceType, aListCustomers.Count).ExtraValue);
        //        return (CostRoom + ExtraMoneyRoom);
        //        }
        //        else  // Neu phong k co ai thi tien  =0
        //        {
        //            return 0;
        //        }
        //    }
        //    else
        //    {
        //        return 0;
        //    }
        //}
        public decimal? CalculateCostRoom( int IDBookingRoom, string PriceType , int CustomerType, int NumCustomer )
        {
            BookingRoomsBO aBookingRoomsBO = new BookingRoomsBO();

            if (aBookingRoomsBO.Select_ByID(IDBookingRoom) != null)
            {
                CustomersBO aCustomersBO = new CustomersBO();
                ExtraCostBO aExtraCostBO = new ExtraCostBO();
                RoomsBO aRoomsBO = new RoomsBO();
                //List<Customers> aListCustomers = aCustomersBO.SelectListCustomer_ByIDBookingRoom(IDBookingRoom);

                decimal? CostRoom = 0;

                CostRoom = aRoomsBO.Select_ByIDBookingRoom(IDBookingRoom).CostRef;

                string RoomSku = aRoomsBO.Select_ByIDBookingRoom(IDBookingRoom).Sku;

                try
                {
                    decimal? ExtraMoneyRoom = aExtraCostBO.Select_BySku_ByPriceType_ByNumberPeople(RoomSku, PriceType, NumCustomer).ExtraValue;
                    return (CostRoom + ExtraMoneyRoom);
                }
                catch(Exception w)
                {
                    MessageBox.Show("Trong dữ liệu giá bảng giá " + PriceType + " của phòng " + RoomSku + " chưa có giá dành cho " + NumCustomer + " người ");
                    return 0;
                }

            }
            else
            {
                return 0;
            }
        }
        private void btnPrintByCustomer_Click(object sender, EventArgs e)
        {
            CustomersBO aCustomersBO = new CustomersBO();
            Customers aCustomer = new Customers();
            aCustomer = aCustomersBO.Select_ByID(int.Parse(loeListCustomer.EditValue.ToString()));
            this.aNewPaymentEN = this.aNewPaymentEN.SlipPaymentByCustomer(aCustomer);

            try
            {
                if (this.aNewPaymentEN.Status_BookingR == 8 || this.aNewPaymentEN.Status_BookingR == 7)
                {

                    frmRpt_Payment_BookingRs afrmRpt_Payment_BookingRs = new frmRpt_Payment_BookingRs(this.aNewPaymentEN);
                    ReportPrintTool tool = new ReportPrintTool(afrmRpt_Payment_BookingRs);
                    tool.ShowPreview();
                }
                else
                {
                    frmRpt_Payment_BookingRsUnPay afrmRpt_Payment_BookingRs = new frmRpt_Payment_BookingRsUnPay(this.aNewPaymentEN);
                    ReportPrintTool tool = new ReportPrintTool(afrmRpt_Payment_BookingRs);
                    tool.ShowPreview();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_ChoosePrintType.btnPrint_Click\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //hiennv
        private void btCreateNew_Click(object sender, EventArgs e)
        {
            try
            {

                if (this.CheckDataBeforeCreateNew() == true)
                {
                    DateTime? NullDateTime = null;

                    CustomersBO acustomersBo = new CustomersBO();
                    Customers aCustomers = new Customers();

                    aCustomers.Name = txtNames.Text;
                    aCustomers.Identifier1 = txtIdentifier1.Text;
                    aCustomers.Identifier2 = txtIdentifier2.Text;
                    aCustomers.Identifier3 = txtIdentifier3.Text;
                    aCustomers.Identifier1CreatedDate = String.IsNullOrEmpty(dtpIdentifier1CreatedDate.Text) == true ? NullDateTime : dtpIdentifier1CreatedDate.DateTime;
                    aCustomers.PlaceOfIssue1 = txtPlaceOfIssue1.Text;
                    aCustomers.AgencyOfIssue1 = txtAgencyOfIssue1.Text;
                    aCustomers.Birthday = String.IsNullOrEmpty(dtpBirthday.Text) == true ? NullDateTime : dtpBirthday.DateTime;
                    aCustomers.Gender = Convert.ToString(lueGender.EditValue);
                    aCustomers.Address = txtAddress.Text;
                    aCustomers.Nationality = Convert.ToString(lueNationality.EditValue);
                    aCustomers.Tel = txtTel.Text;
                    aCustomers.Email = txtEmail.Text;
                    aCustomers.Info = txaInfo.Text;
                    aCustomers.Note = txaNote.Text;
                    aCustomers.Description = txaDescription.Text;
                    aCustomers.Status = Convert.ToInt32(lueStatus.EditValue);
                    aCustomers.Type = cbbCustomerType.SelectedIndex + 1;
                    aCustomers.Citizen = Convert.ToInt32(lueCitizen.EditValue);
                    aCustomers.Disable = bool.Parse(cboDisable.Text);

                    int count = acustomersBo.Insert(aCustomers);

                    if (count > 0)
                    {
                        MessageBox.Show("Bạn đã thêm mới khách hàng thành công !", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (this.afrmIns_CustomerGroups_Customers != null)
                        {
                            this.afrmIns_CustomerGroups_Customers.LoadDataAvailableCustomers();
                        }
                        else if (this.afrmLst_Customers != null)
                        {
                            this.afrmLst_Customers.ReloadData();
                        }
                        else if (this.afrmTsk_EditBooking != null)
                        {
                            this.afrmTsk_EditBooking.ReloadCustomers();
                        }
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmAddNewCustomers.btCreateNew_Click\n" + ex.ToString(), "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public frmTsk_CheckIn_Goverment_Step3(frmTsk_CheckIn_Goverment_Step2 afrmTsk_CheckIn_Goverment_Step2, CheckInEN aCheckInEN)
 {
     InitializeComponent();
     this.afrmTsk_CheckIn_Goverment_Step2 = afrmTsk_CheckIn_Goverment_Step2;
     this.aCheckInEN = aCheckInEN;
     CustomersBO aCustomersBO = new CustomersBO();
     this.aListCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(aCheckInEN.IDCustomerGroup);
 }
 public frmTsk_CheckInCustomer_ForRoomBooking_Step3(frmTsk_CheckInCustomer_ForRoomBooking_Step2 afrmTsk_CheckInCustomer_ForRoomBooking_Step2, CheckInRoomBookingEN aCheckInRoomBookingEN)
 {
     InitializeComponent();
     this.afrmTsk_CheckInCustomer_ForRoomBooking_Step2 = afrmTsk_CheckInCustomer_ForRoomBooking_Step2;
     this.aCheckInRoomBookingEN = aCheckInRoomBookingEN;
     CustomersBO aCustomersBO = new CustomersBO();
     this.aListCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(this.aCheckInRoomBookingEN.IDCustomerGroup);
 }
 public void LoadListBookingRoomType()
 {
     CustomersBO aCustomersBO = new CustomersBO();
     aListBookingRoomType.Clear();
     foreach (var temp in aBookingRoomByTypeBO.Select_ByStatus(true)) {
         BookingRoomByTypeEN aBookingRoomByTypeEN = new BookingRoomByTypeEN();
         aBookingRoomByTypeEN.SetValue(temp);
         aBookingRoomByTypeEN.CustomerName = aCustomersBO.Select_ByID(aBookingRoomByTypeEN.IDCustomer).Name;
         aListBookingRoomType.Add(aBookingRoomByTypeEN);
     }
 }
 public List<Customers> LoadAllListCustomers()
 {
     try {
         CustomersBO aCustomersBO = new CustomersBO();
         return aCustomersBO.Select_All();
     }
     catch (Exception ex) {
         MessageBox.Show("frmTsk_BookingForRoom.LoadAllListCustomers()\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return null;
     }
 }
 private void btnDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     int ID = int.Parse(viewAvailableCustomers.GetFocusedRowCellValue("ID").ToString());
     string Name = viewAvailableCustomers.GetFocusedRowCellValue("Name").ToString();
     CustomersBO aCustomersBO = new CustomersBO();
     DialogResult result = MessageBox.Show("Bạn có muốn xóa khách hàng " + Name + " này không?", "Xóa khách hàng", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     if (result == DialogResult.Yes)
     {
         aCustomersBO.Delete(ID);
         MessageBox.Show("Xóa thành công");
         this.ReloadData();
     }
 }
        public void LoadData()
        {
            try
            {
                CustomersBO aCustomersBO = new CustomersBO();
                BookingRoomsBO aBookingRoomsBO = new BookingRoomsBO();
                BookingRooms aBookingRooms = new BookingRooms();
                RoomsBO aRoomsBO = new RoomsBO();

                // Load các thông tin chung về phòng
                aBookingRooms = aBookingRoomsBO.Select_ByID(this.IDBookingRooms);
                if (aBookingRooms != null)
                {
                    lblCheckIn.Text = aBookingRooms.CheckInActual.ToString("dd/MM/yyyy HH:mm");
                    lblCheckOut.Text = aBookingRooms.CheckOutPlan.ToString("dd/MM/yyyy HH:mm");
                    lblRoomSku.Text = aRoomsBO.Select_ByCodeRoom(aBookingRooms.CodeRoom, 1).Sku;
                }
                BookingRsBO aBookingRsBO = new BookingRsBO();
                BookingRs aBookingRs = new BookingRs();
                aBookingRs = aBookingRsBO.Select_ByID(this.IDBookingRs);
                if (aBookingRs != null)
                {
                    lblCustomerType.Text = CORE.CONSTANTS.SelectedCustomerType(Convert.ToInt32(aBookingRs.CustomerType)).Name;

                    CompaniesBO aCompaniesBO = new CompaniesBO();
                    lblCompany.Text = aCompaniesBO.Select_ByIDBookingRoom(this.IDBookingRooms).Name;

                    lblCustomer.Text = aCustomersBO.Select_ByID(aBookingRs.IDCustomer).Name;

                    CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
                    lblGroup.Text = aCustomerGroupsBO.Select_ByID(aBookingRs.IDCustomerGroup).Name;

                    lblTel.Text = aCustomersBO.Select_ByID(aBookingRs.IDCustomer).Tel;

                    this.IDCustomerGroup = aBookingRs.IDCustomerGroup;
                }
                //Load danh sách phòng còn trống
                lueRooms.Properties.DataSource = this.LoadListAvailableRooms(aBookingRooms.CheckInActual, aBookingRooms.CheckOutPlan);
                lueRooms.Properties.ValueMember = "RoomCode";
                lueRooms.EditValue = this.IDBookingRooms;
                //Load danh sách khách trong phòng
                this.aListCustomersInRoom = aCustomersBO.SelectListCustomer_ByIDBookingRoom(this.IDBookingRooms);
                dgvAvailableCustomers.DataSource = this.aListCustomersInRoom;
                dgvAvailableCustomers.RefreshDataSource();

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_EditBooking.ReloadData\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //Hiennv    Tạo mới     18/11/2014
        public void LoadAllListCustomers()
        {
            try
            {
                aListAvailableCustomers.Clear();
                CustomersBO aCustomersBO = new CustomersBO();
                aListAvailableCustomers = aCustomersBO.Select_All();
                dgvAvailableCustomer.DataSource = aListAvailableCustomers;
                dgvAvailableCustomer.RefreshDataSource();

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_CheckIn.LoadAllListCustomers()\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void LoadData()
        {
            try
            {
                CustomersBO aCustomersBO = new CustomersBO();
                BookingRoomsBO aBookingRoomsBO = new BookingRoomsBO();
                BookingRooms aBookingRooms = new BookingRooms();
                RoomsBO aRoomsBO = new RoomsBO();

                aBookingRooms = aBookingRoomsBO.Select_ByID(this.IDBookingRooms);
                if (aBookingRooms != null)
                {
                    lblCheckIn.Text = aBookingRooms.CheckInActual.ToString("dd/MM/yyyy HH:mm");
                    lblCheckOut.Text = aBookingRooms.CheckOutPlan.ToString("dd/MM/yyyy HH:mm");
                    lblRoomSku.Text = aRoomsBO.Select_ByCodeRoom(aBookingRooms.CodeRoom,1).Sku;
                }
                BookingRsBO aBookingRsBO = new BookingRsBO();
                BookingRs aBookingRs = new BookingRs();
                aBookingRs = aBookingRsBO.Select_ByID(this.IDBookingRs);
                if (aBookingRs != null)
                {
                    lblCustomerType.Text = CORE.CONSTANTS.SelectedCustomerType(Convert.ToInt32(aBookingRs.CustomerType)).Name;

                    CompaniesBO aCompaniesBO = new CompaniesBO();
                    lblCompany.Text = aCompaniesBO.Select_ByIDBookingRoom(this.IDBookingRooms).Name;

                    lblCustomer.Text = aCustomersBO.Select_ByID(aBookingRs.IDCustomer).Name;

                    CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
                    lblGroup.Text = aCustomerGroupsBO.Select_ByID(aBookingRs.IDCustomerGroup).Name;

                    lblTel.Text = aCustomersBO.Select_ByID(aBookingRs.IDCustomer).Tel;

                    this.IDCustomerGroup = aBookingRs.IDCustomerGroup;
                }
                dgvAvaiableRooms.DataSource = this.LoadListAvailableRooms(aBookingRooms.CheckInActual, aBookingRooms.CheckOutPlan);
                dgvAvaiableRooms.RefreshDataSource();

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_EditBooking.ReloadData\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void ReloadData()
        {
            try
            {
                dgvAvailableCustomers.DataSource = null;
                CustomersBO aCustomersBO = new CustomersBO();
                List<Customers> aListCustomers = new List<Customers>();
                aListCustomers = aCustomersBO.Select_All();
                btnAddCustomer.Visible = true;

                dgvAvailableCustomers.DataSource = aListCustomers;
                dgvAvailableCustomers.RefreshDataSource();

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmLst_Customers.ReloadData\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                CustomersBO acustomersBO = new CustomersBO();
                Customers aCustomers = acustomersBO.Select_ByID(IDCustomer);
                if (ValidateData() == true)
                {
                    aCustomers.ID = IDCustomer;
                    aCustomers.Name = txtNames.Text;
                    aCustomers.Identifier1 = txtIdentifier1.Text;

                    aCustomers.Birthday = dtpBirthday.DateTime;
                    aCustomers.Tel = txtTel.Text;
                    aCustomers.Address = txtAddress.Text;
                    aCustomers.Email = txtEmail.Text;
                    aCustomers.Info = txtInfo.Text;
                    aCustomers.Status = Convert.ToInt32(lueStatus.EditValue);
                    aCustomers.Type = Convert.ToInt32(cbbCustomerType.Text);
                    aCustomers.Disable = bool.Parse(cbbDisable.Text);

                    acustomersBO.Update(aCustomers);
                    if (this.afrmLst_Customers != null)
                    {
                        this.afrmLst_Customers.ReloadData();
                    }
                    if (this.afrmIns_CustomerGroups_Customers != null)
                    {
                        this.afrmIns_CustomerGroups_Customers.LoadDataAvailableCustomers();
                    }

                    MessageBox.Show("Sửa thông tin khách hàng thành công!", "Success ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmUpdateCustomers.btnUpdate_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public bool NewOrEditBookingRoomByType(BookingRoomByTypeEN aBookingRoomByTypeEN)
        {
            try{
                BookingRoomByType aNewBooking = new BookingRoomByType();
                int IDCustomer = 0;

                #region Them moi khach hang khi khach hang chua co
                if (aBookingRoomByTypeEN.IDCustomer > 0) {
                    IDCustomer = aBookingRoomByTypeEN.IDCustomer;
                }
                else {
                    CustomersBO aCustomersBO = new CustomersBO();
                    Customers aCustomers = new Customers();
                    if (aBookingRoomByTypeEN.CustomerName.Length > 50) {
                        aCustomers.Name = aBookingRoomByTypeEN.CustomerName.Substring(0, 50);
                    }
                    else {
                        aCustomers.Name = aBookingRoomByTypeEN.CustomerName;
                    }
                    IDCustomer = aCustomersBO.Insert(aCustomers);
                }
                #endregion
                aNewBooking.ID = aBookingRoomByTypeEN.ID;
                aNewBooking.IDCustomer = IDCustomer;
                aNewBooking.FromDate = aBookingRoomByTypeEN.FromDate;
                aNewBooking.ToDate = aBookingRoomByTypeEN.ToDate;
                aNewBooking.Suite = aBookingRoomByTypeEN.Suite;
                aNewBooking.Superior = aBookingRoomByTypeEN.Superior;
                aNewBooking.Standard = aBookingRoomByTypeEN.Standard;
                aNewBooking.BookingStatus = aBookingRoomByTypeEN.BookingStatus;

                aDatabaseDA.BookingRoomByType.AddOrUpdate(aNewBooking);
                aDatabaseDA.SaveChanges();
                return true;
            }
            catch(Exception ex){
                return false;
                throw new Exception("BookingRoomByTypeBO.NewBookingRoomByType"+ex.ToString());
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DateTime? dateTime = null;

            CustomersBO aCustomersBO = new CustomersBO();
            Customers aCustomers = new Customers();

            //Update
            if (this.IDCustomer > 0)
            {
                aCustomers = aCustomersBO.Select_ByID(IDCustomer);
            }
            else
            {
                aCustomers = new Customers();
            }
            aCustomers.Address = txtAddress.Text;
            aCustomers.Birthday = String.IsNullOrEmpty(dtpBirthday.Text) ? dateTime : dtpBirthday.DateTime;
            aCustomers.Citizen = Convert.ToInt32(lueCitizen.EditValue);

            aCustomers.Email = txtEmail.Text;
            aCustomers.Gender = lueGender.EditValue.ToString();
            aCustomers.Identifier1 = txtIdentifier1.Text;
            aCustomers.Identifier2 = txtIdentifier2.Text;
            aCustomers.Identifier3 = txtIdentifier3.Text;

            aCustomers.Name = txtNames.Text;
            aCustomers.Nationality = lueNationality.EditValue.ToString();
            aCustomers.Tel = txtTel.Text;

            if (this.IDCustomer > 0)
            {
                aCustomersBO.Update(aCustomers);
            }
            else
            {
                this.IDCustomer = aCustomersBO.Insert(aCustomers);
            }
            MessageBox.Show("Thêm mới khách thành công!", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void LoadServicesInRoom()
        {
            try
            {
                ServicesBO aServicesBO = new ServicesBO();
                BookingRooms_ServicesBO aBookingRooms_ServicesBO = new BookingRooms_ServicesBO();
                List<BookingRooms_Services> aListTemp = aBookingRooms_ServicesBO.Select_ByIDBookingRooms(this.IDBookingRoom);
                BookingRoom_ServiceEN aBookingRoom_ServiceEN;

                for (int i = 0; i < aListTemp.Count; i++)
                {
                    aBookingRoom_ServiceEN = new BookingRoom_ServiceEN();
                    aBookingRoom_ServiceEN.ID = aListTemp[i].ID;
                    aBookingRoom_ServiceEN.Info = aListTemp[i].Info;
                    aBookingRoom_ServiceEN.Type = aListTemp[i].Type;
                    aBookingRoom_ServiceEN.Status = aListTemp[i].Status;
                    aBookingRoom_ServiceEN.Disable = aListTemp[i].Disable;
                    aBookingRoom_ServiceEN.IDBookingRoom = aListTemp[i].IDBookingRoom;
                    aBookingRoom_ServiceEN.IDService = aListTemp[i].IDService;
                    aBookingRoom_ServiceEN.Service_Name = aServicesBO.Select_ByID(aListTemp[i].IDService).Name;
                    aBookingRoom_ServiceEN.Service_Unit = aServicesBO.Select_ByID(aListTemp[i].IDService).Unit;
                    aBookingRoom_ServiceEN.Cost = aListTemp[i].Cost == null ? aListTemp[i].CostRef_Services : aListTemp[i].Cost;
                    aBookingRoom_ServiceEN.CostRef_Services = aListTemp[i].CostRef_Services;
                    aBookingRoom_ServiceEN.Date = aListTemp[i].Date;
                    aBookingRoom_ServiceEN.PercentTax = aListTemp[i].PercentTax;
                    aBookingRoom_ServiceEN.Quantity = aListTemp[i].Quantity;
                    aBookingRoom_ServiceEN.Tag = aListTemp[i].Tag;
                    aListSelected.Add(aBookingRoom_ServiceEN);
                }
                dgvServiceInRoom.DataSource = aListSelected;
                dgvServiceInRoom.RefreshDataSource();

                CustomersBO aCustomersBO = new CustomersBO();

                lueUserInRoom.DataSource = aCustomersBO.SelectListCustomer_ByIDBookingRoom(this.IDBookingRoom);

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

            }
        }
        public void ReloadData()
        {
            try
            {
                dgvAvailableCustomers.DataSource = null;
                CustomersBO aCustomersBO = new CustomersBO();
                List<Customers> aListCustomers = new List<Customers>();
                List<CustomerEN>  aListCustomersEN = new List<CustomerEN>();

                if (this.afrmTsk_CheckIn_Goverment_Step2 != null)
                {
                    aListCustomers.Clear();
                    aListCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                    btnAddCustomer.Visible = false;
                    colChoose.Visible = true;
                }
                else if (this.afrmTsk_CheckIn_Group_Step2 != null)
                {
                    aListCustomers.Clear();
                    aListCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                    btnAddCustomer.Visible = false;
                    colChoose.Visible = true;
                }
                else if (this.afrm_Tsk_CheckIn_Customer_Step2 != null)
                {
                    aListCustomers.Clear();
                    aListCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                    btnAddCustomer.Visible = false;
                    colChoose.Visible = true;
                }
                else if (this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2 != null)
                {
                    aListCustomers.Clear();
                    aListCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                    btnAddCustomer.Visible = false;
                    colChoose.Visible = true;
                }
                else if (this.afrmTsk_CheckInGroup_ForRoomBooking_Step2 != null)
                {
                    aListCustomers.Clear();
                    aListCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                    btnAddCustomer.Visible = false;
                    colChoose.Visible = true;
                }
                else if (this.afrmTsk_CheckInCustomer_ForRoomBooking_Step2 != null)
                {
                    aListCustomers.Clear();
                    aListCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                    btnAddCustomer.Visible = false;
                    colChoose.Visible = true;
                }
                else if (this.afrmTsk_Booking_Step2 != null)
                {
                    aListCustomers.Clear();
                    aListCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                    btnAddCustomer.Visible = false;
                    colChoose.Visible = true;
                }
                else if (this.afrmMain != null)
                {
                    aListCustomers.Clear();
                    aListCustomers = aCustomersBO.Select_All();
                    btnAddCustomer.Visible = true;
                    colChoose.Visible = false;
                }
                else if (this.afrmTsk_BookingHall_Customer_New != null)
                {
                    aListCustomers.Clear();
                    aListCustomers = aCustomersBO.Select_All();
                    btnAddCustomer.Visible = true;
                }

                CustomerEN aCus;
                for (int i = 0; i < aListCustomers.Count; i++)
                {
                    aCus = new CustomerEN();
                    aCus.SetValue(aListCustomers[i]);
                    if (String.IsNullOrEmpty(aListCustomers[i].Gender) == false)
                    {
                        aCus.GenderDisplay = CORE.CONSTANTS.SelectedGender(Convert.ToInt32(aListCustomers[i].Gender)).Name;
                    }
                    if (String.IsNullOrEmpty(aListCustomers[i].Nationality) == false)
                    {
                        aCus.NationalityDisplay = CORE.CONSTANTS.SelectedCountry(Convert.ToString(aListCustomers[i].Nationality)).Name;
                    }
                    if (aListCustomers[i].Citizen != null)
                    {
                        aCus.CitizenDisplay = CORE.CONSTANTS.SelectedCitizen(Convert.ToInt32(aListCustomers[i].Citizen)).Name;
                    }
                    aListCustomersEN.Add(aCus);
                }
                dgvAvailableCustomers.DataSource = aListCustomersEN;
                dgvAvailableCustomers.RefreshDataSource();

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmLst_Customers.ReloadData\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 //Lay danh sach khach hang thuoc 1 phong nao do
 public List<Customers> SelectListCustomerInRoom(int IDBookingRoom)
 {
     CustomersBO aCustomersBO = new CustomersBO();
     return aCustomersBO.SelectListCustomer_ByIDBookingRoom(IDBookingRoom);
 }
        private void loeListCustomer_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
        {
            CustomersBO aCustomersBO = new CustomersBO();
            Customers aCustomer = new Customers();

            if (loeListCustomer.OldEditValue != null || int.Parse(e.NewValue.ToString()) != 0 )  // Để khi fill dữ liệu vào lần đầu không xóa mất aNewPaymentEN
            {
                if (int.Parse(e.OldValue.ToString()) == 0)
                {
                    this.aNewPaymentEN_Backup.Clone(this.aNewPaymentEN);
                    aCustomer = aCustomersBO.Select_ByID(int.Parse(e.NewValue.ToString()));
                    this.aNewPaymentEN = this.aNewPaymentEN.SlipPaymentByCustomer(aCustomer);
                    if (this.aNewPaymentEN.aListBookingRoomUsed.Count > 0)
                    {
                        this.CurrentIDBookingRoom = this.aNewPaymentEN.aListBookingRoomUsed[0].ID;
                    }
                    else
                    {
                        MessageBox.Show("Có thể có lỗi dữ liệu vì người dùng này đang không tồn tại trong phòng nào");
                    }

                    this.LoadDataCurrentHallForControl();
                    this.LoadDataCurrentRoomForControl();
                }
                else if (int.Parse(e.OldValue.ToString()) != 0)
                {

                    if (int.Parse(e.NewValue.ToString()) != 0) // Khi chọn hiển thị dữ liệu cho một người khác
                    {
                        this.aNewPaymentEN.Clone(this.aNewPaymentEN_Backup);

                        aCustomer = aCustomersBO.Select_ByID(int.Parse(e.NewValue.ToString()));
                        this.aNewPaymentEN = this.aNewPaymentEN.SlipPaymentByCustomer(aCustomer);

                        if (this.aNewPaymentEN.aListBookingRoomUsed.Count > 0)
                        {
                            this.CurrentIDBookingRoom = this.aNewPaymentEN.aListBookingRoomUsed[0].ID;
                        }
                        else
                        {
                            MessageBox.Show("Có thể có lỗi dữ liệu vì người dùng này đang không tồn tại trong phòng nào");
                        }

                        this.LoadDataCurrentHallForControl();
                        this.LoadDataCurrentRoomForControl();
                    }
                    else //khi chọn hiển thị dữ liệu cho tất cả
                    {
                        this.aNewPaymentEN.Clone(this.aNewPaymentEN_Backup);
                        if (this.aNewPaymentEN.aListBookingRoomUsed.Count > 0)
                        {
                            this.CurrentIDBookingRoom = this.aNewPaymentEN.aListBookingRoomUsed[0].ID;
                        }
                        else
                        {
                            MessageBox.Show("Có thể có lỗi dữ liệu vì người dùng này đang không tồn tại trong phòng nào");
                        }

                        this.LoadDataCurrentHallForControl();
                        this.LoadDataCurrentRoomForControl();
                    }
                }
            }
        }
        // Author : Linhting
        public void LoadCustomerInfo()
        {
            try
            {
                BookingHsBO aBookingHsBO = new BookingHsBO();
                CustomersBO aCustomersBO = new CustomersBO();
                CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
                CompaniesBO aCompaniesBO = new CompaniesBO();
                int IDCustomer = aBookingHsBO.Select_ByID(this.IDBookingH).IDCustomer;
                int IDCustomerGroup = aBookingHsBO.Select_ByID(this.IDBookingH).IDCustomerGroup;

                lblCompany.Text = aCompaniesBO.Select_ByIDCustomerGroup(IDCustomerGroup).Name;
                lblNameCustomerGroup.Text = aCustomerGroupsBO.Select_ByID(IDCustomerGroup).Name;
                lblNameCustomer.Text = aCustomersBO.Select_ByID(IDCustomer).Name;
            }
            catch (Exception ex)
            {

                MessageBox.Show("frmTsk_PaymentHall.LoadCustomerInfo\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();
            }
        }
        // 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 frmUpd_Customers_2(frmIns_CustomerGroups_Customers afrmIns_CustomerGroups_Customers, int IDCustomer)
        //{
        //    InitializeComponent();
        //    this.afrmIns_CustomerGroups_Customers = afrmIns_CustomerGroups_Customers;
        //    this.IDCustomer = IDCustomer;
        //}
        //public frmUpd_Customers_2(frmLst_Customers afrmLst_Customers, int aIDCustomer)
        //{
        //    InitializeComponent();
        //    this.afrmLst_Customers = afrmLst_Customers;
        //    this.IDCustomer = aIDCustomer;
        //}
        //public frmUpd_Customers_2(frmTsk_EditBooking afrmTsk_EditBooking, int aIDCustomer)
        //{
        //    InitializeComponent();
        //    this.afrmTsk_EditBooking = afrmTsk_EditBooking;
        //    this.IDCustomer = aIDCustomer;
        //}
        //public frmUpd_Customers_2(frmTsk_Payment_Step2 afrmTsk_Payment_Step2, int aIDCustomer)
        //{
        //    InitializeComponent();
        //    this.afrmTsk_Payment_Step2 = afrmTsk_Payment_Step2;
        //    this.IDCustomer = aIDCustomer;
        //}
        private void frmUpdateCustomers_Load(object sender, EventArgs e)
        {
            try
            {
                dgvAvailableCustomers.DataSource = (new CustomersBO()).Select_All();
                btnAdd.Enabled = false;

                lueNationality.Properties.DataSource = CORE.CONSTANTS.ListCountries;//Load Country
                lueNationality.Properties.DisplayMember = "Name";
                lueNationality.Properties.ValueMember = "Code";

                lueCitizen.Properties.DataSource = CORE.CONSTANTS.ListCitizens;//Load Citizen
                lueCitizen.Properties.DisplayMember = "Name";
                lueCitizen.Properties.ValueMember = "ID";

                lueGender.Properties.DataSource = CORE.CONSTANTS.ListGenders;//Load Gioi tinh
                lueGender.Properties.DisplayMember = "Name";
                lueGender.Properties.ValueMember = "ID";

                CustomersBO aCustomersBO = new CustomersBO();
                // lấy IDCustomer này từ FormCustomers
                if (this.IDCustomer > 0)
                {
                    Customers aCustomer = aCustomersBO.Select_ByID(IDCustomer);
                    if (aCustomer != null)
                    {
                        txtNames.EditValue = aCustomer.Name;
                        txtIdentifier1.EditValue = aCustomer.Identifier1;
                        txtIdentifier2.EditValue = aCustomer.Identifier2;
                        txtIdentifier3.EditValue = aCustomer.Identifier3;
                        if (aCustomer.Birthday != null)
                        {
                            dtpBirthday.EditValue = aCustomer.Birthday;
                        }
                        if (String.IsNullOrEmpty(aCustomer.Gender) == false)
                        {
                            lueGender.EditValue = Convert.ToInt32(aCustomer.Gender);
                        }

                        txtAddress.EditValue = aCustomer.Address;

                        if (String.IsNullOrEmpty(aCustomer.Nationality) == false)
                        {
                            lueNationality.EditValue = aCustomer.Nationality;
                        }
                        if (lueNationality.EditValue == null)
                        {
                            lueNationality.EditValue = CORE.CONSTANTS.SelectedCountry(704).Code;
                        }
                        if (aCustomer.Citizen > 0)
                        {
                            lueCitizen.EditValue = aCustomer.Citizen;
                        }
                        else
                        {
                            lueCitizen.EditValue = CORE.CONSTANTS.SelectedCitizen(2).ID;
                        }
                        txtTel.EditValue = aCustomer.Tel;
                        txtEmail.EditValue = aCustomer.Email;
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmUpdateCustomers.frmUpdateCustomers_Load\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void frmUpdateCustomers_Load(object sender, EventArgs e)
        {
            try
            {

                lueNationality.Properties.DataSource = CORE.CONSTANTS.ListCountries;//Load Country
                lueNationality.Properties.DisplayMember = "Name";
                lueNationality.Properties.ValueMember = "Code";

                lueCitizen.Properties.DataSource = CORE.CONSTANTS.ListCitizens;//Load Citizen
                lueCitizen.Properties.DisplayMember = "Name";
                lueCitizen.Properties.ValueMember = "ID";

                lueGender.Properties.DataSource = CORE.CONSTANTS.ListGenders;//Load Gioi tinh
                lueGender.Properties.DisplayMember = "Name";
                lueGender.Properties.ValueMember = "ID";

                lueStatus.Properties.DataSource = CORE.CONSTANTS.ListCustomerStatus;//Load CustomerStatus
                lueStatus.Properties.DisplayMember = "Name";
                lueStatus.Properties.ValueMember = "ID";

                CustomersBO aCustomersBO = new CustomersBO();
                // lấy IDCustomer này từ FormCustomers
                Customers aCustomer = aCustomersBO.Select_ByID(IDCustomer);
                if (aCustomer != null)
                {
                    txtNames.EditValue = aCustomer.Name;
                    txtIdentifier1.EditValue = aCustomer.Identifier1;
                    txtIdentifier2.EditValue = aCustomer.Identifier2;
                    txtIdentifier3.EditValue = aCustomer.Identifier3;
                    txtPlaceOfIssue1.EditValue = aCustomer.PlaceOfIssue1;
                    txtAgencyOfIssue1.EditValue = aCustomer.AgencyOfIssue1;

                    if(aCustomer.Identifier1CreatedDate != null) {
                        dtpIdentifier1CreatedDate.DateTime = aCustomer.Identifier1CreatedDate.GetValueOrDefault();
                    }
                    if (aCustomer.Birthday != null)
                    {
                        dtpBirthday.DateTime = aCustomer.Birthday.GetValueOrDefault();
                    }
                    if (String.IsNullOrEmpty(aCustomer.Gender) == false)
                    {
                        lueGender.EditValue = Convert.ToInt32(aCustomer.Gender);
                    }

                    txtAddress.EditValue = aCustomer.Address;

                    if(String.IsNullOrEmpty(aCustomer.Nationality) == false)
                    {
                        lueNationality.EditValue = aCustomer.Nationality;
                    }
                    if (lueNationality.EditValue == null)
                    {
                        lueNationality.EditValue = CORE.CONSTANTS.SelectedCountry(704).Code;
                    }
                    if (aCustomer.Citizen > 0)
                    {
                        lueCitizen.EditValue = aCustomer.Citizen;
                    }
                    else
                    {
                        lueCitizen.EditValue = CORE.CONSTANTS.SelectedCitizen(2).ID;
                    }

                    txtTel.EditValue = aCustomer.Tel;
                    txtEmail.EditValue = aCustomer.Email;
                    txaInfo.EditValue = aCustomer.Info;
                    txaNote.EditValue = aCustomer.Note;
                    txaDescription.EditValue = aCustomer.Description;
                    lueStatus.EditValue = aCustomer.Status;
                    cbbCustomerType.Text = aCustomer.Type.ToString();
                    if (aCustomer.Disable != null)
                    {
                        cboDisable.Text = Convert.ToString(aCustomer.Disable);
                    }
                    else
                    {
                        cboDisable.Text = "False";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmUpdateCustomers.frmUpdateCustomers_Load\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //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());
            }
        }
        private void LoadDataCurrentHallForControl()
        {
            //--------- Hội trường ----------------
            if (this.IDBookingH > 0)
            {

                //Thong tin nguoi dat
                lblNameCompany_BookingH.Text = this.aNewPaymentEN.NameCompany;
                lblNameCustomerGroup_BookingH.Text = this.aNewPaymentEN.NameCustomerGroup;
                lblNameCustomer_BookingH.Text = this.aNewPaymentEN.NameCustomer;
                txtAddressH.Text = this.aNewPaymentEN.AddressCompany;
                txtTaxNumberCodeH.Text = this.aNewPaymentEN.TaxNumberCodeCompany;
                // Trang thai, hinh thuc thanh toan
                lblTotalMoneyHalls.Text = String.Format("{0:0,0}", this.aNewPaymentEN.GetMoneyHalls());
                txtBookingHMoney.EditValue = this.aNewPaymentEN.BookingHMoney;
                lblTotalMoneyH.Text = String.Format("{0:0,0}", this.aNewPaymentEN.GetMoneyHalls() - this.aNewPaymentEN.BookingHMoney);
                // Thong tin gia tiền, đặt trước
                lueBookingH_PayMethod.Properties.DataSource = CORE.CONSTANTS.ListPayMethods;
                lueBookingH_PayMethod.Properties.DisplayMember = "Name";
                lueBookingH_PayMethod.Properties.ValueMember = "ID";
                lueBookingH_PayMethod.EditValue = CORE.CONSTANTS.SelectedPayMethod(Convert.ToInt32(this.aNewPaymentEN.PayMenthodH)).ID;
                // Danh sách các hội trường
                dgvHalls.DataSource = this.aNewPaymentEN.aListBookingHallUsed;
                dgvHalls.RefreshDataSource();
                // Thông tin 1 hội trường

                if (this.aNewPaymentEN.aListBookingHallUsed.Where(a => a.ID == this.CurrentIDBookingHall).ToList().Count > 0)
                {
                    BookingHallUsedEN aBookingHallUsedEN = this.aNewPaymentEN.aListBookingHallUsed.Where(a => a.ID == this.CurrentIDBookingHall).ToList()[0];
                    lblSkuHalls.Text = Convert.ToString(aBookingHallUsedEN.HallSku);
                    decimal? cost = 0;
                    if (aBookingHallUsedEN.Cost == null || aBookingHallUsedEN.Cost == 0)
                    {
                        cost = aBookingHallUsedEN.CostRef_Halls;
                    }
                    else
                    {
                        cost = aBookingHallUsedEN.Cost;
                    }

                    lblDate.Text = String.Format("{0:dd/MM/yyyy}", aBookingHallUsedEN.Date);
                    lblLunarDate.Text = String.Format("{0:dd/MM/yyyy}", aBookingHallUsedEN.LunarDate);
                    lblStartTime.Text = String.Format(@"{0:hh\:mm}", aBookingHallUsedEN.StartTime);
                    lblEndTime.Text = String.Format(@"{0:hh\:mm}", aBookingHallUsedEN.EndTime);

                    lueMenus.Properties.DataSource = aBookingHallUsedEN.aListMenuEN;
                    lueMenus.Properties.DisplayMember = "Name";
                    lueMenus.Properties.ValueMember = "ID";

                    if (aBookingHallUsedEN.aListMenuEN.Count > 0)
                    {
                        lueMenus.EditValue = aBookingHallUsedEN.aListMenuEN[0].ID;
                        MenusEN aMenusEN = aBookingHallUsedEN.aListMenuEN[0];

                        List<Foods> aListFoods = new List<Foods>();
                        FoodsBO aFoodsBO = new FoodsBO();
                        foreach (Foods item in aMenusEN.aListFoods)
                        {
                            Foods aFoods = aFoodsBO.Select_ByID(item.ID);
                            if (aFoods.Image1 != null)
                            {
                                if (aFoods.Image1.Length <= 0)
                                {
                                    Image image = RoomManager.Properties.Resources.logo_nkcp_small;
                                    image = image.GetThumbnailImage(70, 70, null, IntPtr.Zero);
                                    Byte[] aImageByte = this.ConvertImageToByteArray(image);
                                    aFoods.Image1 = aImageByte;
                                }
                            }
                            else
                            {
                                Image image = RoomManager.Properties.Resources.logo_nkcp_small;
                                image = image.GetThumbnailImage(70, 70, null, IntPtr.Zero);
                                Byte[] aImageByte = this.ConvertImageToByteArray(image);
                                aFoods.Image1 = aImageByte;
                            }
                            aListFoods.Add(aFoods);

                        }

                        dgvFoods.DataSource = aListFoods;
                        dgvFoods.RefreshDataSource();
                    }
                    else
                    {
                        List<Foods> aListFoods = new List<Foods>();
                        dgvFoods.DataSource = aListFoods;
                        dgvFoods.RefreshDataSource();
                    }
                    txtPercentTax_Hall.EditValue = aBookingHallUsedEN.PercentTax;

                    lblMoneyHall.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.GetMoneyAHall(aBookingHallUsedEN.ID));

                    decimal? BookingHallsCost = aBookingHallUsedEN.Cost == null ? aBookingHallUsedEN.CostRef_Halls : aBookingHallUsedEN.Cost;

                    txtBookingHallsCost.EditValue = BookingHallsCost;
                    dgvServicesH.DataSource = this.aNewPaymentEN.GetListServiceUsedInHall(aBookingHallUsedEN.ID);
                    dgvServicesH.RefreshDataSource();
                    //-----------Ngoc bổ sung --------------
                    CustomersBO aCustomersBO = new CustomersBO();
                    lueUserInBookingH.DataSource = aCustomersBO.SelectListCustomer_ByIDBookingH(this.CurrentIDBookingHall);
                    //-----------Ngoc bổ sung --------------

                    lblTotalMoneyServiceH.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.GetMoneyListServiceUsedInAHall(aBookingHallUsedEN.ID));
                }
            }
            else
            {
                btnBookHall.Visible = true;
                btnPaymentHall.Enabled = false;
                btnPrintBookingH.Enabled = false;
                txtTaxNumberCodeH.Enabled = false;
                txtAddressH.Enabled = false;
            }
            // Thông tin tổng tiền
            lblTotalBookingRAndBookingHBeforeTax.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.GetTotalMoneyBeforeTax());
            lblTotalBookingRAndBookingHAfterTax.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.GetTotalMoney());
            if (this.aNewPaymentEN.BookingHMoney != null)
            {
                lblBookingMoney_BookingRAndBookingH.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.BookingHMoney + this.aNewPaymentEN.BookingRMoney);
                lblTotalBookingRAndBookingH.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.GetTotalMoney() - (this.aNewPaymentEN.BookingHMoney + this.aNewPaymentEN.BookingRMoney));
            }
            else
            {
                lblBookingMoney_BookingRAndBookingH.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.BookingRMoney);
                lblTotalBookingRAndBookingH.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.GetTotalMoney() - this.aNewPaymentEN.BookingRMoney);
            }
        }
        public void LoadCustomers()
        {
            try
            {
                CustomersBO aCustomerBO = new CustomersBO();
                int IDCustomerGroup = Convert.ToInt32(lueIDCustomerGroup.EditValue);
                List<Customers> aListCustomer = aCustomerBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                lueIDCustomer.Properties.DataSource = aListCustomer;
                lueIDCustomer.Properties.DisplayMember = "Name";
                lueIDCustomer.Properties.ValueMember = "ID";

                if (aListCustomer.Count > 0)
                {
                    lueIDCustomer.EditValue = aListCustomer.ToList()[0].ID;
                }
                else
                {
                    lueIDCustomer.EditValue = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frm_Tsk_CheckIn_Customer_Step2.LoadCustomers\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //Load lai du lieu cho cac control moi khi select vao 1 phong moi
        // Ngoc - done
        private void LoadDataCurrentRoomForControl()
        {
            if (this.aNewPaymentEN.aListBookingRoomUsed.Where(a => a.ID == this.CurrentIDBookingRoom).ToList().Count > 0)
            {
                BookingRoomUsedEN aBookingRoomUsedEN = this.aNewPaymentEN.aListBookingRoomUsed.Where(a => a.ID == this.CurrentIDBookingRoom).ToList()[0];
                /*Ghi chu TypeBookingRooms
                 * Type = 2: //Tính checkin sớm , không tính checkout muộn.
                 * Type = 0: //Không tính checkIn sớm và checkout muộn.
                 * Type = 3: //Tính checkin sớm và Checkout muộn
                 * Type = 1: //Không tính checkin sớm , tính checkout muộn
                 */
                ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();

                if (aBookingRoomUsedEN.Status == 1 || aBookingRoomUsedEN.Status == 2)
                {
                    dtpCheckInActual.DateTime = aBookingRoomUsedEN.CheckInPlan;
                    dtpCheckOutActual.DateTime = aBookingRoomUsedEN.CheckOutPlan;

                    txtNumberDate.Text = ""; // Phong chua su dung
                    txtAddTimeEnd.Text = "";
                    txtAddTimeStart.Text = "";

                    lblCI.Text = "CI dự kiến";
                    lblCO.Text = "CO dự kiến";
                    lblCaptionStatusRoom.Text = ("Phòng " + aBookingRoomUsedEN.RoomSku + " đang ở trạng thái đặt").ToUpper();

                }
                else if (aBookingRoomUsedEN.Status == 3)
                {
                    dtpCheckInActual.DateTime = aBookingRoomUsedEN.CheckInActual;
                    dtpCheckOutActual.DateTime = aBookingRoomUsedEN.CheckOutPlan;

                    txtNumberDate.Text = aReceptionTaskBO.GetTimeInUsed(aBookingRoomUsedEN.CheckInActual, aBookingRoomUsedEN.CheckOutPlan).ToString();

                    txtAddTimeEnd.Text = aReceptionTaskBO.GetAddTimeEnd(aBookingRoomUsedEN.Type.GetValueOrDefault(0), aBookingRoomUsedEN.CheckOutPlan).ToString();
                    txtAddTimeStart.Text = aReceptionTaskBO.GetAddTimeStart(aBookingRoomUsedEN.Type.GetValueOrDefault(0), aBookingRoomUsedEN.CheckInActual).ToString();
                    lblCI.Text = "CI thực tế";
                    lblCO.Text = "CO dự kiến";
                    lblCaptionStatusRoom.Text = ("Phòng " + aBookingRoomUsedEN.RoomSku + " đang có người ở").ToUpper();
                }
                else if (aBookingRoomUsedEN.Status == 5)
                {
                    dtpCheckInActual.DateTime = aBookingRoomUsedEN.CheckInActual;
                    dtpCheckOutActual.DateTime = aBookingRoomUsedEN.CheckOutPlan;

                    txtNumberDate.Text = aReceptionTaskBO.GetTimeInUsed(aBookingRoomUsedEN.CheckInActual, aBookingRoomUsedEN.CheckOutPlan).ToString();
                    txtAddTimeEnd.Text = aReceptionTaskBO.GetAddTimeEnd(aBookingRoomUsedEN.Type.GetValueOrDefault(0), aBookingRoomUsedEN.CheckOutPlan).ToString();
                    txtAddTimeStart.Text = aReceptionTaskBO.GetAddTimeStart(aBookingRoomUsedEN.Type.GetValueOrDefault(0), aBookingRoomUsedEN.CheckInActual).ToString();

                    lblCI.Text = "CI thực tế";
                    lblCO.Text = "CO dự kiến";
                    lblCaptionStatusRoom.Text = ("Phòng " + aBookingRoomUsedEN.RoomSku + " đang khóa").ToUpper();
                }
                else if (aBookingRoomUsedEN.Status == 7)
                {
                    dtpCheckInActual.DateTime = aBookingRoomUsedEN.CheckInActual;
                    dtpCheckOutActual.DateTime = aBookingRoomUsedEN.CheckOutActual;

                    txtNumberDate.Text = aReceptionTaskBO.GetTimeInUsed(aBookingRoomUsedEN.CheckInActual, aBookingRoomUsedEN.CheckOutActual).ToString();
                    txtAddTimeEnd.Text = aReceptionTaskBO.GetAddTimeEnd(aBookingRoomUsedEN.Type.GetValueOrDefault(0), aBookingRoomUsedEN.CheckOutActual).ToString();
                    txtAddTimeStart.Text = aReceptionTaskBO.GetAddTimeStart(aBookingRoomUsedEN.Type.GetValueOrDefault(0), aBookingRoomUsedEN.CheckInActual).ToString();

                    lblCI.Text = "CI thực tế";
                    lblCO.Text = "CO thực tế";
                    lblCaptionStatusRoom.Text = ("Phòng " + aBookingRoomUsedEN.RoomSku + " đã checkout nhưng chưa thanh toán").ToUpper();
                }
                else if (aBookingRoomUsedEN.Status == 8)
                {
                    dtpCheckInActual.DateTime = aBookingRoomUsedEN.CheckInActual;
                    dtpCheckOutActual.DateTime = aBookingRoomUsedEN.CheckOutActual;

                    // Neu phong da dc thanh toan tuc la thong tin phong da chot. Vay lay thong tin nay de hien thi
                    txtNumberDate.Text = (aBookingRoomUsedEN.TimeInUse.GetValueOrDefault(0)/(24*60)).ToString();
                    txtAddTimeEnd.Text = aBookingRoomUsedEN.AddTimeEnd.ToString();
                    txtAddTimeStart.Text = aBookingRoomUsedEN.AddTimeStart.ToString();

                    lblCI.Text = "CI thực tế";
                    lblCO.Text = "CO thực tế";
                    lblCaptionStatusRoom.Text = ("Phòng " + aBookingRoomUsedEN.RoomSku + " đã thanh toán").ToUpper();
                }
                lblSkuRooms.Text = aBookingRoomUsedEN.RoomSku;

                txtPercentTax_Room.Text = Convert.ToString(aBookingRoomUsedEN.PercentTax);
                lblMoneyRoom.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.GetOnlyMoneyRoom(aBookingRoomUsedEN.ID));

                if (string.IsNullOrEmpty(aBookingRoomUsedEN.Cost.ToString()) == false)
                {
                    txtBookingRoomsCost.EditValue = aBookingRoomUsedEN.Cost;
                }
                else
                {
                    txtBookingRoomsCost.EditValue = aAccountancyBO.CalculateCostRoom(this.CurrentIDBookingRoom, aBookingRoomUsedEN.PriceType, this.aNewPaymentEN.CustomerType.GetValueOrDefault(0), this.aNewPaymentEN.GetNumberCustomerInRoom(this.CurrentIDBookingRoom));
                }
                // Danh sách khách
                dgvCustomers.DataSource = aBookingRoomUsedEN.ListCustomer;
                dgvCustomers.RefreshDataSource();
                // Danh sách dịch vụ
                dgvServicesR.DataSource = aNewPaymentEN.GetListServiceUsedInRoom(aBookingRoomUsedEN.ID);
                dgvServicesR.RefreshDataSource();
                //-----------Ngoc bổ sung --------------
                CustomersBO aCustomersBO = new CustomersBO();
                lueUserInBookingR.DataSource = aCustomersBO.SelectListCustomer_ByIDBookingRoom(this.CurrentIDBookingRoom);
                //-----------Ngoc bổ sung --------------

                lblTotalMoneyServiceR.Text = String.Format("{0:0,0} (VND)", this.aNewPaymentEN.GetMoneyListServiceUsedInARoom(aBookingRoomUsedEN.ID));
            }
                //=========================================
                //=========================================
                //=========================================
                // Load lai  control khac

                //-------------- Phòng ---------------------
                //Thong tin nguoi dat
                lblNameCompany_BookingR.Text = this.aNewPaymentEN.NameCompany;
                lblNameCustomerGroup_BookingR.Text = this.aNewPaymentEN.NameCustomerGroup;
                lblNameCustomer_BookingR.Text = this.aNewPaymentEN.NameCustomer;
                txtAddressR.Text = this.aNewPaymentEN.AddressCompany;
                txtTaxNumberCodeR.Text = this.aNewPaymentEN.TaxNumberCodeCompany;

                // Thông tin hóa đơn
                txtInvoiceNumberR.Text = this.aNewPaymentEN.InvoiceNumber;
                dtpAcceptDateR.DateTime = this.aNewPaymentEN.AcceptDate.GetValueOrDefault(Convert.ToDateTime("01/01/1900"));
                dtpInvoiceDateR.DateTime = this.aNewPaymentEN.InvoiceDate.GetValueOrDefault(Convert.ToDateTime("01/01/1900"));
                // Trang thai, hinh thuc thanh toan
                lueBookingR_Paymethod.Properties.DataSource = CORE.CONSTANTS.ListPayMethods;
                lueBookingR_Paymethod.Properties.DisplayMember = "Name";
                lueBookingR_Paymethod.Properties.ValueMember = "ID";
                lueBookingR_Paymethod.EditValue = CORE.CONSTANTS.SelectedPayMethod(Convert.ToInt32(this.aNewPaymentEN.PayMenthodR)).ID;
                //--------------------------------------------------------------
                // Thong tin gia tiền, đặt trước
                lblTotalMoneyRooms.Text = String.Format("{0:0,0}", this.aNewPaymentEN.GetMoneyRooms());
                txtBookingRMoney.EditValue = this.aNewPaymentEN.BookingRMoney;
                lblTotalMoneyR.Text = String.Format("{0:0,0}", this.aNewPaymentEN.GetMoneyRooms() - this.aNewPaymentEN.BookingRMoney);
                // Bang danh sach phong
                dgvRooms.DataSource = this.aNewPaymentEN.aListBookingRoomUsed;
                dgvRooms.RefreshDataSource();
        }
        //Load IDCustomers
        public void LoadCustomers()
        {
            try
            {
                CustomersBO aCustomersBO = new CustomersBO();
                int IDCustomerGroup = Int32.Parse(lueCustomerGroup.EditValue.ToString());
                List<Customers> aListCustomer = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                lueCustomer.Properties.DataSource = aListCustomer;
                lueCustomer.Properties.DisplayMember = "Name";
                lueCustomer.Properties.ValueMember = "ID";

                if (aListCustomer.Count > 0)
                {
                    lueCustomer.EditValue = aListCustomer.ToList()[0].ID;
                }
                else
                {
                    lueCustomer.EditValue = 0;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_UpdBooking.LoadIDCustomers\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void frmTsk_PendingCheckIn_Step2_Load(object sender, EventArgs e)
        {
            try
            {
                BookingRsBO aBookingRsBO = new BookingRsBO();
                BookingRs aBookingRs = aBookingRsBO.Select_ByID(IDBookingR);
                lblIDBookingR.Text = aBookingRs.ID.ToString();

                CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
                CustomerGroups aCustomerGroups = aCustomerGroupsBO.Select_ByID(aBookingRs.IDCustomerGroup);
                lblNameCustomerGroup.Text = aCustomerGroups.Name;

                CompaniesBO aCompaniesBO = new CompaniesBO();
                Companies aCompanies = aCompaniesBO.Select_ByID(aCustomerGroups.IDCompany);
                lblNameCompany.Text = aCompanies.Name;

                CustomersBO aCustomersBO = new CustomersBO();
                Customers aCustomers = aCustomersBO.Select_ByID(aBookingRs.IDCustomer);
                lblNameCustomer.Text = aCustomers.Name;

                RoomsBO aRoomsBO = new RoomsBO();
                Rooms aRooms = aRoomsBO.Select_ByCodeRoom(CodeRoom, 1);//1=IDLang
                lblSku.Text = aRooms.Sku;

                dtpTo.DateTime = CheckOutPlan;
                dtpFrom.DateTime = DateTime.Now;
                dtpFrom.Enabled = false;
                dtpFrom.Properties.ReadOnly = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_PendingCheckIn_Step2.frmTsk_PendingCheckIn_Step2_Load\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }