private void btnAddNewUser_Click(object sender, RoutedEventArgs e) { AddEditNewWorkerView addEditView = new AddEditNewWorkerView(new User(), false); addEditView.Show(); Close(); }
public void EditEmployee() { try { User userEdit = new User(); userEdit.UserId = SelectedUser.UserId; userEdit.FullName = SelectedUser.FullName; userEdit.IDNumber = SelectedUser.IDNumber; userEdit.Jmbg = SelectedUser.Jmbg; userEdit.Date = SelectedUser.Date; userEdit.GenderId = SelectedUser.GenderId; userEdit.PhoneNumber = SelectedUser.PhoneNumber; userEdit.SectorId = SelectedUser.SectorId; userEdit.LocationId = SelectedUser.LocationId; userEdit.PhoneNumber = SelectedUser.PhoneNumber; userEdit.SectorName = selectedUser.SectorName; userEdit.MenagerId = selectedUser.MenagerId; AddEditNewWorkerView addEditView = new AddEditNewWorkerView(userEdit, true); addEditView.Show(); mainView.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public AddEditNewWorkerViewModel(User user, AddEditNewWorkerView addEditUserViewOpen, bool isForEdit) { this.isForEdit = isForEdit; this.user = user; addEditUserView = addEditUserViewOpen; GenderList = new ObservableCollection <Gender>(service.GettAllGender()); SelectedGender = GenderList.FirstOrDefault(p => p.GenderId == user.GenderId); LocationList = new ObservableCollection <Location>(service.GettAllLocations()); SelectedLocation = LocationList.FirstOrDefault(p => p.LocationId == user.LocationId); MenagerList = new ObservableCollection <User>(service.GettAllUsers()); SelectedMenager = MenagerList.FirstOrDefault(p => p.UserId == user.MenagerId); MenagerListForEdit = new ObservableCollection <User>(service.GettAllMenagersForEdit(user.UserId)); SelectedMenagerForEdit = MenagerListForEdit.FirstOrDefault(p => p.UserId == user.MenagerId); }