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);
 }
        //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);
            }
        }
        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);
            }
        }
        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);
            }
        }
 private void lueCustomerGroup_EditValueChanged(object sender, EventArgs e)
 {
     IDCustomerGroup = Convert.ToInt32(lueCustomerGroup.EditValue);
     CustomersBO aCustomersBO = new CustomersBO();
     aListSelectCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
     this.LoadDataSelectCustomers();
 }
        //hiennv
        private void frmAddListCustomerToCustomerGroups_Load(object sender, EventArgs e)
        {
            try
            {
                if (this.afrmTsk_CheckIn_Goverment_Step2 != null || this.afrmTsk_CheckIn_Group_Step2 != null || this.afrm_Tsk_CheckIn_Customer_Step2 != null || this.afrmTsk_Booking_Step2 != null)
                {
                    this.LoadDataAvailableCustomers();
                    CustomersBO aCustomersBO = new CustomersBO();
                    this.aListSelectCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                    this.LoadDataSelectCustomers();

                    lueCompany.Properties.NullText = NameCompany;
                    lueCustomerGroup.Properties.NullText = NameCustomerGroup;
                    lueCompany.Properties.ReadOnly = true;
                    lueCustomerGroup.Properties.ReadOnly = true;

                    btnAddCompanies.Visible = false;
                    btnSearchCompany.Visible = false;
                    btnAddCustomerGroup.Visible = false;
                    btnSearchCustomerGroup.Visible = false;
                }
                else if (this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2 != null || this.afrmTsk_CheckInGroup_ForRoomBooking_Step2 != null || this.afrmTsk_CheckInCustomer_ForRoomBooking_Step2 != null)
                {
                    this.LoadDataAvailableCustomers();
                    CustomersBO aCustomersBO = new CustomersBO();
                    this.aListSelectCustomers = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                    this.LoadDataSelectCustomers();

                    lueCompany.Properties.NullText = NameCompany;
                    lueCustomerGroup.Properties.NullText = NameCustomerGroup;
                    lueCompany.Properties.ReadOnly = true;
                    lueCustomerGroup.Properties.ReadOnly = true;

                    btnAddCompanies.Visible = false;
                    btnSearchCompany.Visible = false;
                    btnAddCustomerGroup.Visible = false;
                    btnSearchCustomerGroup.Visible = false;
                }
                else
                {
                    this.LoadIDCompanies();
                    this.LoadDataAvailableCustomers();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmAddListCustomerToCustomerGroups.frmAddListCustomerToCustomerGroups_Load\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //Load IDCustomers
        public void LoadIDCustomers()
        {
            try
            {
                CustomersBO aCustomersBO = new CustomersBO();
                int IDCustomerGroup = Int32.Parse(lueIDCustomerGroups.EditValue.ToString());

                List<Customers> aListCustomer = aCustomersBO.SelectListCustomer_ByIDCustomerGroups(IDCustomerGroup);
                lueIDCustomers.Properties.DataSource = aListCustomer;
                lueIDCustomers.Properties.DisplayMember = "Name";
                lueIDCustomers.Properties.ValueMember = "ID";

                if (aListCustomer.Count > 0)
                {
                    if ((this.aCheckInRoomBookingEN.IDCompany == Convert.ToInt32(lueIDCompanies.EditValue)) && (this.aCheckInRoomBookingEN.IDCustomerGroup == Convert.ToInt32(lueIDCustomerGroups.EditValue)))
                    {
                        lueIDCustomers.EditValue = this.aCheckInRoomBookingEN.IDCustomer;
                    }
                    else
                    {
                        lueIDCustomers.EditValue = aListCustomer.ToList()[0].ID;
                    }
                }
                else
                {
                    lueIDCustomers.EditValue = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_CheckInGroup_ForRoomBooking_Step2.LoadIDCustomers\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }