private void sbCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateData() == true)
                {
                    GuestsBO aGuestsBO = new GuestsBO();
                    Guests aGuests = new Guests();
                    aGuests.Name = txtName.Text;
                    aGuests.Nationality = lueNationality.EditValue.ToString();
                    aGuests.Type = int.Parse(cbbType.Text);
                    aGuests.Info = txtInfo.Text;
                    aGuests.GroupName = txtGroupName.Text;
                    aGuestsBO.Insert(aGuests);
                    if (afrmLst_Guests != null)
                    {
                        afrmLst_Guests.Reload();
                    }

                    MessageBox.Show("Thêm mới thành công !", "Success ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmUpd_Guests.sbCreate_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public void Reload()
 {
     try
     {
         GuestsBO aGuestsBO = new GuestsBO();
         dgvGuest.DataSource = aGuestsBO.Select_All();
         dgvGuest.RefreshDataSource();
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmLst_Guests.Reload\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void frmUpd_Guests_Load(object sender, EventArgs e)
 {
     lueNationality.Properties.DataSource = CORE.CONSTANTS.ListCountries;//Load Country
     GuestsBO aGuestsBO = new GuestsBO();
     Guests aGuests = aGuestsBO.Select_ByID(IDGuest);
     lueNationality.Properties.DisplayMember = "Name";
     lueNationality.Properties.ValueMember = "Code";
     lueNationality.EditValue = CORE.CONSTANTS.SelectedCountry(aGuests.Nationality).Code;
     txtGroupName.Text = aGuests.GroupName;
     txtInfo.Text = aGuests.Info;
     txtName.Text = aGuests.Name;
     cbbType.Text = aGuests.Type.ToString();
     lblID.Text = aGuests.ID.ToString();
 }
 public void CallBackGuest(int IDGuest)
 {
     try
     {
         GuestsBO aGuestsBO = new GuestsBO();
         lueGuest.Properties.DataSource = aGuestsBO.Select_All();
         lueGuest.Properties.DisplayMember = "Name";
         lueGuest.Properties.ValueMember = "ID";
         lueGuest.EditValue = IDGuest;
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_BookingHall_Customer_New.CallBackGuest\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public void LoadGuest()
        {
            try
            {
                GuestsBO aGuestsBO = new GuestsBO();
                lueGuest.Properties.DataSource = aGuestsBO.Select_All();
                lueGuest.Properties.DisplayMember = "Name";
                lueGuest.Properties.ValueMember = "ID";
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_BookingHall_Customer_New.LoadService\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }
        public void LoadData()
        {
            //Load dữ liệu công ty
            if (this.CustomerType == 1)
            {
                this.Text = "Đặt tiệc cho khách nhà nước";
                Companies aDefault = new Companies();
                List<Companies> aList = new List<Companies>();
                aDefault.Name = "[Tạo mới cty]";
                aDefault.ID = 0;

                aList = aCompaniesBO.Select_ByType(1);// [Company] Type = 1 : khách nhà nước
                aList.Add(aDefault);
                lueCompany.Properties.DataSource = aList;
                lueCompany.Properties.DisplayMember = "Name";
                lueCompany.Properties.ValueMember = "ID";

                if (this.IDCompany > 0)
                {
                    lueCompany.EditValue = this.IDCompany;
                }
                else
                {
                    lueCompany.EditValue = 0;
                }
            }
            if (this.CustomerType == 2)
            {
                this.Text = "Đặt tiệc cho khách đoàn";

                Companies aDefault = new Companies();
                List<Companies> aList = new List<Companies>();
                aDefault.Name = "[Tạo mới cty]";
                aDefault.ID = 0;

                aList = aCompaniesBO.Select_ByType(2);// [Company] Type = 2 : khách đoàn
                aList.Add(aDefault);
                lueCompany.Properties.DataSource = aList;
                lueCompany.Properties.DisplayMember = "Name";
                lueCompany.Properties.ValueMember = "ID";

                if (this.IDCompany > 0)
                {
                    lueCompany.EditValue = this.IDCompany;
                }
                else
                {
                    lueCompany.EditValue = 0;
                }
            }
            if (this.CustomerType == 3)
            {
                this.Text = "Đặt tiệc cho khách lẻ";

                Companies aDefault = new Companies();
                List<Companies> aList = new List<Companies>();
                aDefault.Name = "[Tạo mới cty]";
                aDefault.ID = 0;

                aList = aCompaniesBO.Select_ByType(3);// [Company] Type = 3 : khách lẻ
                aList.Add(aDefault);
                lueCompany.Properties.DataSource = aList;
                lueCompany.Properties.DisplayMember = "Name";
                lueCompany.Properties.ValueMember = "ID";
                if (this.IDCompany > 0)
                {
                    lueCompany.EditValue = this.IDCompany;
                }
                else
                {
                    lueCompany.EditValue = 0;
                }
            }
            //Load dữ liệu khách
            lueCustomer.Properties.DataSource = aCustomersBO.Select_All();
            lueCustomer.Properties.DisplayMember = "Name";
            lueCustomer.Properties.ValueMember = "ID";
            if (this.IDCustomer > 0)
            {
                lueCustomer.EditValue = this.IDCustomer;

            }
            else
            {
                lueCustomer.EditValue = 0;
            }

            // Load khách mời
            GuestsBO aGuestsBO = new GuestsBO();
            lueGuest.Properties.DataSource = aGuestsBO.Select_All();
            lueGuest.Properties.DisplayMember = "Name";
            lueGuest.Properties.ValueMember = "ID";
            LoadDataListFoods();
        }
        private void sbCreate_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateData() == true)
                {
                    GuestsBO aGuestsBO = new GuestsBO();
                    Guests aGuests = new Guests();
                    aGuests.Name = txtName.Text;
                    aGuests.Nationality = lueNationality.EditValue.ToString();
                    aGuests.Type = int.Parse(cbbType.Text);
                    aGuests.Info = txtInfo.Text;
                    aGuests.GroupName = "Khách mời";
                    int ID = aGuestsBO.Insert(aGuests);
                    if (afrmLst_Guests != null)
                    {
                        afrmLst_Guests.Reload();
                    }
                    if (afrmTsk_BookingHall_Goverment != null)
                    {
                        this.afrmTsk_BookingHall_Goverment.ReloadData();
                        this.afrmTsk_BookingHall_Goverment.CallBackGuest(ID);
                    }
                    if (afrmTsk_BookingHall_Group != null)
                    {
                        this.afrmTsk_BookingHall_Group.ReloadData();
                        this.afrmTsk_BookingHall_Group.CallBackGuest(ID);
                    }
                    if (afrmTsk_BookingHall_Customer != null)
                    {
                        this.afrmTsk_BookingHall_Customer.ReloadData();
                        this.afrmTsk_BookingHall_Customer.CallBackGuest(ID);
                    }
                    if (afrmTsk_BookingHall_Customer_New != null)
                    {
                        this.afrmTsk_BookingHall_Customer_New.LoadGuest();
                        this.afrmTsk_BookingHall_Customer_New.CallBackGuest(ID);
                    }
                    if (afrmTsk_UpdBooking != null)
                    {
                        this.afrmTsk_UpdBooking.ReloadData();
                    }
                    MessageBox.Show("Thêm mới thành công !", "Success ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_Guest.sbCreate_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void rebeDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            try
            {
                GuestsBO aGuestsBO = new GuestsBO();
                int IDGuest = Convert.ToInt32(grvGuest.GetFocusedRowCellValue("ID"));
                string Name = grvGuest.GetFocusedRowCellValue("Name").ToString();
                DialogResult result = MessageBox.Show("Bạn có muốn xóa khách mời " + Name + " này không?", "Xóa công ty", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    aGuestsBO.Delete(IDGuest);
                    MessageBox.Show("Xóa thành công");
                    this.Reload();
                }
            }
            catch (Exception ex)
            {

                MessageBox.Show("frmLst_Guests.rebeDelete_ButtonClick\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }