private void addUser(TicketMastersEntities context) { AddUserWindow p = new AddUserWindow(); if (p.ShowDialog().Value) { User addNewUser = new User { FirstName = p.firstNameTxt.Text, LastName = p.lastNameTxt.Text, StreetAddress = p.streetAddressTxt.Text, City = p.cityTxt.Text, State = p.stateTxt.Text, ZipCode = p.zipCodeTxt.Text, PhoneNumber = p.phoneNumTxt.Text }; context.Users.AddObject(addNewUser); saveUser(); //fix still shows when data not saving useridLbl.Text = addNewUser.UserID.ToString(); firstLbl.Text = addNewUser.FirstName; lastLbl.Text = addNewUser.LastName; streetLbl.Text = addNewUser.StreetAddress; cityLbl.Text = addNewUser.City; stateLbl.Text = addNewUser.State; zipLbl.Text = addNewUser.ZipCode; phoneLbl.Text = addNewUser.PhoneNumber; } }
private void editUser(TicketMastersEntities context) { int idInfo = int.Parse(useridLbl.Text); User u = context.Users.First(userIdInEntity => userIdInEntity.UserID == idInfo); AddUserWindow p = new AddUserWindow(); p.firstNameTxt.Text = u.FirstName; p.lastNameTxt.Text = u.LastName; p.stateTxt.Text = u.State; p.streetAddressTxt.Text = u.StreetAddress; p.cityTxt.Text = u.City; p.zipCodeTxt.Text = u.ZipCode; p.phoneNumTxt.Text = u.PhoneNumber; if (p.ShowDialog().Value) { //change this so it binds directly u.FirstName = firstLbl.Text = p.firstNameTxt.Text; u.LastName = lastLbl.Text = p.lastNameTxt.Text; u.State = stateLbl.Text = p.stateTxt.Text; u.StreetAddress = streetLbl.Text = p.streetAddressTxt.Text; u.City = cityLbl.Text = p.cityTxt.Text; u.ZipCode = zipLbl.Text = p.zipCodeTxt.Text; u.PhoneNumber = phoneLbl.Text = p.phoneNumTxt.Text; } saveUser(); }
// depending on which button the user chooses, the apropriate window will open: private void AddUserBtn_Click(object sender, RoutedEventArgs e) { _addUserWindow = new AddUserWindow(); _addUserWindow.Show(); this.Close(); }