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);
            }
        }
Пример #2
0
        public string AddNewGuest(string name, int type, string nation, string info)
        {
            string result = "";
            try
            {
                var guest = new Guests() {Name = name, Type = type, Nationality = nation, GroupName = "", Info = info};
                aDatabaseDA.Guests.Add(guest);
                aDatabaseDA.SaveChanges();
                result = "Thêm mới thành công";
            }
            catch (Exception ex)
            {

                result = "Lỗi hệ thống";
            }

            return result;
        }
        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);
            }
        }
Пример #4
0
        //Author : Linhting
        public int Update(Guests aGuests)
        {
            try
            {
                aDatabaseDA.Guests.AddOrUpdate(aGuests);
                return aDatabaseDA.SaveChanges();

            }
            catch (Exception ex)
            {

                throw new Exception("GuestsBO.Update:" + ex.ToString());
            }
        }
Пример #5
0
 //Author : Linhting
 public int Insert(Guests aGuests)
 {
     try
     {
         aDatabaseDA.Guests.Add(aGuests);
         aDatabaseDA.SaveChanges();
         return aGuests.ID;
     }
     catch (Exception ex)
     {
         throw new Exception("GuestsBO.Insert:" + ex.ToString());
     }
 }