public override bool saveChanges()
        {
            if (txtName.Text.Trim() == "")
            {
                MessageBox.Show("Please enter guest's name.");
                return false;
            }
            try
            {
                GuestHelper client = new GuestHelper();
                if (selectedIndex == -1)
                {
                    Guest g = new Guest();
                    g.Name = txtName.Text;
                    g.Description = txtDescription.Text;
                    g.Contact = txtContact.Text;
                    g.GuestId = client.AddGuest(user, eventDay_.DayID, g.Name, g.Contact, g.Description);
                    guestList.Add(g);
                    CollectionViewSource.GetDefaultView(lstGuestList.ItemsSource).Refresh();
                    clearAll();
                }
                else
                {
                    Guest g = guestList[selectedIndex];
                    g.Name = txtName.Text;
                    g.Description = txtDescription.Text;
                    g.Contact = txtContact.Text;
                    client.EditGuest(user, g.GuestId, g.Name, g.Description, g.Contact);
                    guestList[selectedIndex] = g;
                    CollectionViewSource.GetDefaultView(lstGuestList.ItemsSource).Refresh();
                    changed = false;
                    clearAll();
                }
                client.Close();

                MessageBox.Show("Operation succeeded!");
                return true;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return false;
            }
        }
 private void loadGuests()
 {
     GuestHelper client = new GuestHelper();
     txtGuestMsg.Text = "There are a total of " + client.ViewGuest(eventday_.DayID).ToList<Guest>().Count + " guest(s) ";
     client.Close();
 }
Example #3
0
 private void loadGuest()
 {
     lstGuest.Items.Clear();
     GuestHelper client = new GuestHelper();
     List<int> countList = client.GetEventGuestCount(event_.EventID).ToList<int>();
     client.Close();
     for (int i = 0; i < countList.Count; i++)
     {
         string tempResult = DayList[i].StartDateTime.ToShortDateString() + "\t\t-\t" + countList[i] + " guest(s)";
         lstGuest.Items.Add(tempResult);
     }
 }
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     if (lstGuestList.SelectedIndex == -1)
         return;
     GuestHelper client = new GuestHelper();
     try
     {
         client.DeleteGuest(user, (int)lstGuestList.SelectedValue);
         MessageBox.Show("Operation succeeded!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         client.Close();
     }
     loadGuests();
 }
        private void loadGuests()
        {
            GuestHelper client = new GuestHelper();
            try
            {
                guestList = client.ViewGuest(eventDay_.DayID).ToList<Guest>();
                lstGuestList.ItemsSource = guestList;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                client.Close();
            }

            clearAll();
        }