private void CboCustomer_SelectionChanged(object sender, SelectionChangedEventArgs e) { string cboValue = ""; if (CboCustomer.SelectedIndex > 0) { cboValue = ((ComboBoxItem)CboCustomer.SelectedItem).Content.ToString(); } if (cboValue.Equals("Yes")) // || if (CboCustomer.SelectedItem.ToString().Equals("Yes")) { boolIsCustomer = true; User addCustomer = null; Customer newCustomer = null; //MessageBoxResult result = MessageBox.Show("Updating database to customer status.", // "Customer Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Exclamation); //if (result == MessageBoxResult.Yes) //{ if (currentUser.IsCustomer == true) { try { newCustomer = UsersDB.ReadCustomerById(currentUser.UserID); //Customer custTestID = UsersDB.ReadCustomerById(currentUser.UserID); //MessageBox.Show(newCustomer.ToString()); if (currentUser.UserID == newCustomer.UserId)//custTestID.UserID) { return; } //else //{ // addCustomer = new User(currentUser.UserID, currentUser.Username, // currentUser.Password, currentUser.IsAdmin, currentUser.UserCreatedDate, boolIsCustomer); // UsersDB.UpdateCurrentUser(addCustomer); // newCustomer = new Customer(currentUser.UserID, currentUser.Username, TextboxLastName.Text, // TextboxAddress.Text, TextboxCity.Text, null, // TextboxZip.Text, TextEmailAddress.Text); // UsersDB.CreateCustomer(newCustomer); //} } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } else { try { //UPDATE User so 'IsCustomer' property is set to True. addCustomer = new User(currentUser.UserID, currentUser.Username, currentUser.Password, currentUser.IsAdmin, currentUser.UserCreatedDate, boolIsCustomer); UsersDB.UpdateCurrentUser(addCustomer); //CREATE Customer from current User linking together by 'UserId' newCustomer = new Customer(currentUser.UserID, currentUser.Username, TextboxLastName.Text, TextboxAddress.Text, TextboxCity.Text, null, TextboxZip.Text, TextEmailAddress.Text); UsersDB.CreateCustomer(newCustomer); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } } } }