private void lueIDCompanies_EditValueChanged(object sender, EventArgs e)
        {
            if (lueIDCompanies.EditValue == null)
            {
                MessageBox.Show("Vui lòng chọn tên công ty.");
                lueIDCompanies.Focus();

            }
            BookingRsBO aBookingRsBO = new BookingRsBO();
            BookingRs aBookingRs = new BookingRs();
            List<PaymentExt_GetAllDataEN> aListPaymentExt_GetAllDataEN = new List<PaymentExt_GetAllDataEN>();
            int IDCompany = Convert.ToInt32(lueIDCompanies.EditValue.ToString());

            CustomerGroupsBO aCustomerGroupBO = new CustomerGroupsBO();
            List<int> aListIDCustomerGroup = aCustomerGroupBO.Select_All().Where(x => x.IDCompany == IDCompany).Select(p => p.ID).ToList();

            CompaniesBO aCompaniesBO = new CompaniesBO();
            List<int> ListIDBookingR = aBookingRsBO.Select_ByIDCompany(int.Parse(lueIDCompanies.EditValue.ToString())).Select(p=>p.ID).ToList();
            dgvPaymentViewAll.DataSource = this.aListPaymentExt_GetAllDataEN.Where(p => ListIDBookingR.Contains(p.BookingRs_ID));
        }
 public void ReloadData()
 {
     try
     {
         CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
         List<CustomerGroups> aListCustomerGroup = new List<CustomerGroups>();
         dgvAvailableCustomerGroups.DataSource = null;
         if (this.afrmTsk_CheckIn_Goverment_Step2 != null)
         {
             aListCustomerGroup = aCustomerGroupsBO.Select_ByIDCompany(IDCompany);
             btnAdd.Visible = false;
         }
         else if (this.afrmTsk_CheckIn_Group_Step2 != null)
         {
             aListCustomerGroup = aCustomerGroupsBO.Select_ByIDCompany(IDCompany);
             btnAdd.Visible = false;
         }
         else if (this.afrm_Tsk_CheckIn_Customer_Step2 != null)
         {
             aListCustomerGroup = aCustomerGroupsBO.Select_ByIDCompany(IDCompany);
             btnAdd.Visible = false;
         }
         else if (this.afrmTsk_Booking_Step2 != null)
         {
             aListCustomerGroup = aCustomerGroupsBO.Select_ByIDCompany(IDCompany);
             btnAdd.Visible = false;
         }
         else if (afrmIns_CustomerGroups_Customers_Old != null)
         {
             aListCustomerGroup = aCustomerGroupsBO.Select_ByIDCompany(IDCompany);
             btnAdd.Visible = false;
         }
         else
         {
             aListCustomerGroup = aCustomerGroupsBO.Select_All();
             btnAdd.Visible = true;
         }
         dgvAvailableCustomerGroups.DataSource = aListCustomerGroup;
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmLst_CustomerGroups.ReloadData\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void lueIDCompanies_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                if (lueIDCompanies.EditValue == null)
                {
                    MessageBox.Show("Vui lòng chọn tên công ty.");
                    lueIDCompanies.Focus();
                    return;
                }
                BookingRsBO abookingRsBO = new BookingRsBO();
                BookingRs abookingRs = new BookingRs();
                List<PaymentExt_GetAllDataEN> aListPaymentExt_GetAllDataEN = new List<PaymentExt_GetAllDataEN>();
                int IDCompany = Convert.ToInt32(lueIDCompanies.EditValue.ToString());

                CustomerGroupsBO aCustomerGroupBO = new CustomerGroupsBO();
                List<int> aListIDCustomerGroup = aCustomerGroupBO.Select_All().Where(x => x.IDCompany == IDCompany).Select(p => p.ID).ToList();

                List<int> ListIDBookingR = abookingRsBO.Select_ByListCustomerGroup(aListIDCustomerGroup).Select(p => p.ID).ToList();

                PaymentBO aPaymentBO = new PaymentBO();
                List<sp_PaymentExt_GetAllData_Result> aListTemp = aPaymentBO.Search_ServicesStatus_ObjectStatus_BillRPaymentStatusByCompany(ListIDBookingR);
                PaymentExt_GetAllDataEN aPaymentExt_GetAllDataEN;

                foreach (sp_PaymentExt_GetAllData_Result item in aListTemp)
                {
                    BookingRooms aBookingRoom = aBookingRoomBO.Select_ByIDBookingR(item.BookingRs_ID);

                    decimal? cost = aBookingRoom.Cost;
                    if (cost == null)
                    {
                        cost = 0;
                    }
                    double? addTimeStart = aBookingRoom.AddTimeStart;
                    if (addTimeStart == null)
                    {
                        addTimeStart = 0;
                    }
                    double? addTimeEnd = aBookingRoom.AddTimeEnd;
                    if (addTimeEnd == null)
                    {
                        addTimeEnd = 0;
                    }

                    decimal? timeUser = aBookingRoom.TimeInUse;
                    if (timeUser == null)
                    {
                        timeUser = 0;
                    }
                    double? costPendingRoom = aBookingRoom.CostPendingRoom;
                    if (costPendingRoom == null)
                    {
                        costPendingRoom = 0;
                    }
                    double? tax = aBookingRoom.PercentTax;
                    if (tax == null)
                    {
                        tax = 0;
                    }
                    decimal? sum = CalculatorMoneyRoom(cost, addTimeStart, addTimeEnd, timeUser);

                    // Tinh pending
                    aPaymentExt_GetAllDataEN = new PaymentExt_GetAllDataEN();
                    aPaymentExt_GetAllDataEN.SetValue(item);
                    if (item.IDService == null)
                    {
                        aPaymentExt_GetAllDataEN.DisplayService_PaymentStatus = "";
                    }
                    else
                    {
                        aPaymentExt_GetAllDataEN.DisplayService_PaymentStatus = "Đã thanh toán";
                    }
                    if (item.BillR_PaymentStatus == 8)
                    {
                        aPaymentExt_GetAllDataEN.DisplayBillR_PaymentStatus = "Đã thanh toán";
                    }
                    else
                    {
                        aPaymentExt_GetAllDataEN.DisplayBillR_PaymentStatus = "Chưa thanh toán";
                    }
                    if (item.Object_PaymentStatus == 8)
                    {
                        aPaymentExt_GetAllDataEN.DisplayObject_PaymentStatus = "Đã thanh toán";
                    }
                    else
                    {
                        aPaymentExt_GetAllDataEN.DisplayObject_PaymentStatus = "Chưa thanh toán";

                    }

                    aPaymentExt_GetAllDataEN.DisplayMoneySumRoom = sum;
                    aListPaymentExt_GetAllDataEN.Add(aPaymentExt_GetAllDataEN);
                }
                dgvPaymentViewUnPay.DataSource = aListPaymentExt_GetAllDataEN;
                dgvPaymentViewUnPay.RefreshDataSource();

            }
            catch (Exception ex)
            {
                throw new Exception("frmTsk_UnPay " + ex.ToString());
            }
        }