Example #1
0
 // logic for amend guest save button. Saves the changes in the current object and the database
 private void btnAmengGuestSave_Click(object sender, RoutedEventArgs e)
 {
     btnAmendGuestSave.Visibility = Visibility.Hidden;
     txtBoxEditAge.Visibility     = Visibility.Hidden;
     txtBoxEditName.Visibility    = Visibility.Hidden;
     txtBoxEditPassp.Visibility   = Visibility.Hidden;
     DataLayerFacade.AmendGuest(txtBoxEditName.Text, txtBoxEditPassp.Text,
                                Convert.ToInt32(txtBoxEditAge.Text), selectedGuest.PassportNumber);
     if (selectedGuest.Component != null)
     {
         if (selectedGuest.Component.GetType() == typeof(Client))
         {
             selectedGuest.Component.Name = txtBoxEditName.Text;
             DataLayerFacade.AmendCustomer(((Client)selectedGuest.Component).CustomerNumber,
                                           txtBoxEditName.Text, ((Client)selectedGuest.Component).Address);
         }
     }
     selectedGuest.Name           = txtBoxEditName.Text;
     selectedGuest.PassportNumber = txtBoxEditPassp.Text;
     selectedGuest.Age            = Convert.ToInt32(txtBoxEditAge.Text);
     txtBoxEditAge.Text           = "";
     txtBoxEditName.Text          = "";
     txtBoxEditPassp.Text         = "";
     listBoxGuests.Items.Clear();
     foreach (var guest in booking.GuestList)
     {
         listBoxGuests.Items.Add(guest.Name);
     }
 }
Example #2
0
        // logic for update details button. updates the customer details in the database
        private void button_Click(object sender, RoutedEventArgs e)
        {
            if (textBoxName.Text == String.Empty || textBoxAddress.Text == String.Empty)
            {
                MessageBox.Show(@"Please provide all details.");
                return;
            }
            string name       = textBoxName.Text;
            string address    = textBoxAddress.Text;
            int    curtNumber = Convert.ToInt32(lblCustNumb.Content);

            DataLayer.DataLayerFacade.AmendCustomer(curtNumber, name, address);
            if (textBoxPassNo.Visibility == Visibility.Visible)
            {
                if (textBoxAge.Text == String.Empty || textBoxPassNo.Text == String.Empty)
                {
                    MessageBox.Show(@"Please provide all details.");
                    return;
                }
                string passportNo = textBoxPassNo.Text;
                int    age;
                try
                {
                    age = Convert.ToInt32(textBoxAge.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Please enter age as a number.");
                    return;
                }
                if (age < 0 || age > 101)
                {
                    MessageBox.Show("Please provide age between 0 and 101.");
                    return;
                }
                DataLayerFacade.AmendGuest(name, passportNo, age, oldPassportNo);
            }

            CustomerL CustomerList = new CustomerL();

            CustomerList.Show();
            this.Close();
            MessageBox.Show("Customer details have been updated.");
        }