public async override void OnNavigatedTo(object navigationParameter, Windows.UI.Xaml.Navigation.NavigationMode navigationMode, Dictionary <string, object> viewModelState) { base.OnNavigatedTo(navigationParameter, navigationMode, viewModelState); if (viewModelState != null) { if (navigationMode == NavigationMode.Refresh) { var personErrorsCollection = RetrieveEntityStateValue <IDictionary <string, ReadOnlyCollection <string> > >("personErrorsCollection", viewModelState); if (personErrorsCollection != null) { SelectedPerson.SetAllErrors(personErrorsCollection); } } } // Note: Each time app selects from main page (PersonListPage) detail page (PersonDetailPage) is recreated. // Meaning that constructor is run and SelectedPerson is null. // If SuspendAndTerminate (e.g. debug mode) SelectedPerson is saved to SessionState (because of [RestorableState] attribute). // Therefore, if SelectedPerson has been saved, use it instead of doing GetPersonAsync. if (SelectedPerson == null) { string errorMessage = string.Empty; int personId = (int)navigationParameter; if (personId == 0) { SelectedPerson = new Person(); SelectedPerson.ValidateProperties(); RunAllCanExecute(); } else { try { LoadingData = true; CrudResult = await _personRepository.GetPersonAsync(personId); SelectedPerson = JsonConvert.DeserializeObject <List <Person> >(CrudResult.Content.ToString()).FirstOrDefault <Person>(); } catch (HttpRequestException ex) { ErrorMessageTitle = ErrorMessagesHelper.HttpRequestExceptionError; //TODO: Log stack trace to database here ErrorMessage = string.Format("{0}", ex.Message); } finally { LoadingData = false; } if (ErrorMessage != null && ErrorMessage != string.Empty) { MessageDialog messageDialog = new MessageDialog(ErrorMessage, ErrorMessageTitle); await messageDialog.ShowAsync(); _navService.GoBack(); } } } RunAllCanExecute(); }
private void EditSelectedPerson() { PersonViewModel vm = SelectedPerson.Copy(); if (SetActiveViewModel != null) { SetActiveViewModel(vm); } }
public override void OnNavigatedFrom(Dictionary <string, object> viewModelState, bool suspending) { base.OnNavigatedFrom(viewModelState, suspending); if (viewModelState != null) { AddEntityStateValue("personErrorsCollection", SelectedPerson.GetAllErrors(), viewModelState); } }
private void DeleteSelectedPerson() { if (MessageBox.Show(PulpBirthday.Resources.Message.ConfirmDelete, SelectedPerson.ToString(), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { SelectedPerson.Delete(); PersonList.Remove(SelectedPerson); SelectedPerson = null; } }
///<summary>Called when the editor's value is changed.</summary> protected override void OnEditValueChanged() { base.OnEditValueChanged(); if (SelectedPerson == null) { SuperTip = null; } else { SuperTip = SelectedPerson.GetSuperTip(); } }
// When Update button is pressed private async void OnUpdatePerson() { string errorMessage = string.Empty; bool isCreating = false; SelectedPerson.ValidateProperties(); var updateErrors = SelectedPerson.GetAllErrors().Values.SelectMany(pc => pc).ToList(); if (updateErrors.Count == 0) { try { LoadingData = true; if (SelectedPerson.Id == 0) { isCreating = true; CrudResult = await _personRepository.CreatePersonAsync(SelectedPerson); SelectedPerson = JsonConvert.DeserializeObject <List <Person> >(CrudResult.Content.ToString()).FirstOrDefault <Person>(); } else { CrudResult = await _personRepository.UpdatePersonAsync(SelectedPerson); } } catch (ModelValidationException mvex) { // there were server-side validation errors DisplayPersonErrorMessages(mvex.ValidationResult); } catch (HttpRequestException ex) { ErrorMessageTitle = isCreating ? ErrorMessagesHelper.CreateAsyncFailedError : ErrorMessagesHelper.UpdateAsyncFailedError; ErrorMessage = ex.Message; } finally { LoadingData = false; RunAllCanExecute(); } if (ErrorMessage != null && ErrorMessage != string.Empty) { MessageDialog messageDialog = new MessageDialog(ErrorMessage, ErrorMessageTitle); await messageDialog.ShowAsync(); _navService.GoBack(); } } else { RunAllCanExecute(); } }
private void LoadSelectedPersonMethod() { try { if (SelectedPerson != null) { SelectedPerson.Load(); } } catch (Exception e) { ExepionLogger.Logger.LogException(e); ExepionLogger.Logger.Show(e); } }
public void SelectPerson(object o) { try { ResponsiblePerson p = SelectedPerson.Last <ResponsiblePerson>(); PersonID = p.PersonID; Name = p.Name; OfficeNumber = p.OfficeNumber; Department = p.Department; ChangeButton = true; RechnungsNummerTextBox = true; } catch (System.ArgumentNullException) { MessageBox.Show("No responsible Person selected"); } }
private void FetchMeetings() { var query = MeetingQueryString.Replace(":personID", SelectedPerson.ToString()); try { var connection = new MySqlConnection("Server=localhost;Port=3306;Database=test;Uid=root;Pwd=;"); connection.Open(); var command = new MySqlCommand(query, connection); var reader = command.ExecuteReader(); var meetings = new List <Meeting>(); while (reader.Read()) { var otherId = reader.GetInt32("person1"); otherId = SelectedPerson == otherId?reader.GetInt32("person2") : otherId; meetings.Add(new Meeting() { Id = reader.GetInt32("ID"), Date = reader.GetDateTime("date"), PersonInformation = otherId.ToString() }); } reader.Close(); foreach (var meeting in meetings) { command = new MySqlCommand($"SELECT * from Person WHERE ID = {int.Parse(meeting.PersonInformation)}", connection); reader = command.ExecuteReader(); reader.Read(); meeting.PersonInformation = reader.GetString("forename") + " " + reader.GetString("surname") + " (" + reader.GetString("zip_code") + " " + reader.GetString("city") + ")"; reader.Close(); } MeetingData = meetings; grid1.GoToPage(0); connection.Close(); } catch (Exception e) { Console.WriteLine(e); } }
public void Edit() { if (SelectedPerson == null) { return; } var p = SelectedPerson.Clone(); var dlg = new PersonEditDialog { DataContext = p, Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; if (dlg.ShowDialog() == true) { SelectedPerson.Copy(p); } }
private void Proverks() { if (SelectedPerson.OK()) { SaveBTN.BackColor = Color.PaleGreen; } else { SaveBTN.BackColor = Color.PaleVioletRed; } var controls = groupBox1.Controls.OfType <Control>().ToArray(); foreach (var control in controls) { if (control is TextBox tb) { if (tb.Text == "") { tb.BackColor = Color.PaleVioletRed; } else { tb.BackColor = SystemColors.Control; } } } if (sportNameTB.Text == "") { sportNameTB.BackColor = Color.PaleVioletRed; } else { sportNameTB.BackColor = SystemColors.Control; } }
private void GetLocationIn3SecExecute(object obj) { SelectedPerson.PropertyChanged += SelectedPerson_PropertyChanged; SelectedPerson.UpdateCurrentLocationIn3Seconds(); }
/// <summary> /// Нажатие кнопки Сохранить /// </summary> private void button5_Click(object sender, EventArgs e) { SelectedPerson.SurName = surnameTB.Text; SelectedPerson.Name = nameTB.Text; SelectedPerson.Patronomyc = patronomycTB.Text; SelectedPerson.Telefon = telefonTB.Text; SelectedPerson.Birthday = dateTimePicker1.Value; SelectedPerson.BirthdayMesto = birthdayMestoTB.Text; SelectedPerson.Country = countryTB.Text; SelectedPerson.Addres = adressTB.Text; SelectedPerson.AddresRegistry = adresRegTB.Text; SelectedPerson.SubjectRF = subjectRFTB.Text; SelectedPerson.VK = vkTB.Text; SelectedPerson.Health = healthTB.Text; SelectedPerson.HealtHron = healthHronTB.Text; SelectedPerson.VUZ = vuzTB.Text; SelectedPerson.VUZKor = vuzKor.Text; SelectedPerson.Specialnost = specialnostTB.Text; SelectedPerson.Diplom = diplomTB.Text; SelectedPerson.SrBall = double.Parse(srBallTB.Text); SelectedPerson.VKR = vkrTB.Text; SelectedPerson.Soiskatelstvo = soiscatelstvoCB.Checked ? 5 : 0; SelectedPerson.Exams = examsTB.Text; SelectedPerson.Statiy[0] = StatiyCLB.GetItemChecked(0) ? 5 : 0; SelectedPerson.Statiy[1] = StatiyCLB.GetItemChecked(1) ? 4 : 0; SelectedPerson.Statiy[2] = StatiyCLB.GetItemChecked(2) ? 3 : 0; SelectedPerson.Statiy[3] = StatiyCLB.GetItemChecked(3) ? 1 : 0; SelectedPerson.Statiy[4] = StatiyCLB.GetItemChecked(4) ? 1 : 0; SelectedPerson.Statiy[5] = StatiyCLB.GetItemChecked(5) ? 0.5 : 0; SelectedPerson.Statya = statiyNameTB.Text; SelectedPerson.Sience[0] = OlympCLB.GetItemChecked(0) ? 4 : 0; SelectedPerson.Sience[1] = OlympCLB.GetItemChecked(1) ? 4 : 0; SelectedPerson.Sience[2] = OlympCLB.GetItemChecked(2) ? 3 : 0; SelectedPerson.Sience[3] = OlympCLB.GetItemChecked(3) ? 3 : 0; SelectedPerson.Sience[4] = OlympCLB.GetItemChecked(4) ? 3 : 0; SelectedPerson.Sience[5] = OlympCLB.GetItemChecked(5) ? 2 : 0; SelectedPerson.Sience[6] = OlympCLB.GetItemChecked(6) ? 1 : 0; SelectedPerson.SienceName = sienceNameTB.Text; SelectedPerson.SienceStepen[0] = KandCLB.GetItemChecked(0) ? 3 : 0; SelectedPerson.SienceStepen[1] = KandCLB.GetItemChecked(1) ? 6 : 0; SelectedPerson.SienceStepen[2] = KandCLB.GetItemChecked(2) ? 8 : 0; SelectedPerson.Work[0] = WorkCLB.GetItemChecked(0) ? 2 : 0; SelectedPerson.Work[1] = WorkCLB.GetItemChecked(1) ? 4 : 0; SelectedPerson.Work[2] = WorkCLB.GetItemChecked(2) ? 6 : 0; SelectedPerson.WorkName = workNameTB.Text; SelectedPerson.Sport[0] = SportCLB.GetItemChecked(0) ? 4 : 0; SelectedPerson.Sport[1] = SportCLB.GetItemChecked(1) ? 2 : 0; SelectedPerson.Prioritet[0] = PrioritetCLB.GetItemChecked(0) ? 3 : 0; SelectedPerson.Prioritet[1] = PrioritetCLB.GetItemChecked(1) ? 1 : 0; SelectedPerson.SportName = sportNameTB.Text; SelectedPerson.Language = languageTB.Text; SelectedPerson.Products = productsTB.Text; SelectedPerson.Napravlenie = napravlenieTB.Text; SelectedPerson.Dopusk = dopuskTB.Text; SelectedPerson.TattooAndPirsing = tattooAndPirsingTB.Text; SelectedPerson.Rost = double.TryParse(rostTB.Text, out double result1) ? result1 : SelectedPerson.Rost; SelectedPerson.Ves = double.TryParse(vesTB.Text, out double result2) ? result2 : SelectedPerson.Ves; SelectedPerson.Family = familyTB.Text; SelectedPerson.Info = infoTB.Text; SelectedPerson.Reserv = reservCB.Checked; SelectedPerson.Magistr = magCB.Checked; SelectedPerson.Zachetka = ZachetCB.Checked; SelectedPerson.Bakalavr = BakCB.Checked; SelectedPerson.Ball = SelectedPerson.ExecuteBall(); ball.Text = SelectedPerson.Ball.ToString(); /*if (!SelectedPerson.OK()) * { * MessageBox.Show("Введите все данные", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); * return; * }*/ _excel = new AccessExcel(); _excel.DoAccess(PathFile); groupBox1.Enabled = false; groupBox2.Enabled = false; listBox1.Enabled = true; changeBTN.Enabled = true; Persons.Sort(new NaturalStringComparer()); Persons.Sort(new BallComparer()); listBox1.Items.Clear(); foreach (var person in Persons) { listBox1.Items.Add(person); } listBox1.SelectedItem = listBox1.Items.OfType <Person>().First(x => x.ID == SelectedPerson.ID); for (int i = 0; i < Persons.Count; i++) { _excel.WriteCell <string>(1, 1, "Дата изменения"); int iRow = i + 2; var p = Persons[i]; int j = 1; _excel.WriteCell <string>(iRow, j++, DateTime.Now.ToString("G")); _excel.WriteCell <string>(iRow, j++, p.URLPhoto); _excel.WriteCell <string>(iRow, j++, p.URLPhoto); _excel.WriteCell <string>(iRow, j++, p.URLSOGLASIE); _excel.WriteCell <string>(iRow, j++, p.SurName); _excel.WriteCell <string>(iRow, j++, p.Name); _excel.WriteCell <string>(iRow, j++, p.Patronomyc); _excel.WriteCell <string>(iRow, j++, p.Telefon); _excel.WriteCell <string>(iRow, j++, p.Birthday.ToShortDateString()); _excel.WriteCell <string>(iRow, j++, p.BirthdayMesto); _excel.WriteCell <string>(iRow, j++, p.Country); _excel.WriteCell <string>(iRow, j++, p.Addres); _excel.WriteCell <string>(iRow, j++, p.AddresRegistry); _excel.WriteCell <string>(iRow, j++, p.SubjectRF); _excel.WriteCell <string>(iRow, j++, p.VK); _excel.WriteCell <string>(iRow, j++, p.Health); _excel.WriteCell <string>(iRow, j++, p.HealtHron); _excel.WriteCell <string>(iRow, j++, p.VUZ); _excel.WriteCell <string>(iRow, j++, p.VUZKor); _excel.WriteCell <string>(iRow, j++, p.Specialnost); _excel.WriteCell <string>(iRow, j++, p.Diplom); _excel.WriteCell <double>(iRow, j++, p.SrBall); _excel.WriteCell <string>(iRow, j++, p.VKR); _excel.WriteCell <string>(iRow, j++, p.Soiskatelstvo == 0 ? "Нет": "Да"); _excel.WriteCell <string>(iRow, j++, p.Exams); _excel.WriteCell <string>(iRow, j++, p.Statiy[0] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Statiy[1] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Statiy[2] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Statiy[3] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Statiy[4] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Statiy[5] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Statya); _excel.WriteCell <string>(iRow, j++, p.Sience[0] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Sience[1] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Sience[2] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Sience[3] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Sience[4] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Sience[5] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Sience[6] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.SienceName); _excel.WriteCell <string>(iRow, j++, p.SienceStepen[0] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.SienceStepen[1] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.SienceStepen[2] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Work[0] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Work[1] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Work[2] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.WorkName); _excel.WriteCell <string>(iRow, j++, p.Sport[0] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.Sport[1] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, j++, p.SportName); _excel.WriteCell <string>(iRow, j++, p.Language); _excel.WriteCell <string>(iRow, j++, p.Products); _excel.WriteCell <string>(iRow, j++, p.Napravlenie); _excel.WriteCell <string>(iRow, j++, p.Dopusk); _excel.WriteCell <string>(iRow, j++, p.TattooAndPirsing); _excel.WriteCell <double>(iRow, j++, p.Rost); _excel.WriteCell <double>(iRow, j++, p.Ves); _excel.WriteCell <string>(iRow, j++, p.Family); _excel.WriteCell <string>(iRow, j++, p.Info); _excel.WriteCell <string>(iRow, 100, p.Prioritet[0] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, 101, p.Prioritet[1] == 0 ? "Нет" : "Есть"); _excel.WriteCell <string>(iRow, 102, p.Reserv ? "Резерв" : "Основа"); _excel.WriteCell <string>(iRow, 103, p.Magistr ? "Магистр" : p.Bakalavr ? "Бакалавр" : p.Zachetka ? "Зачетка" : ""); } _excel.FinishAccess(); }
async void OnSaveExecute() { await _peopleDataService.SaveAsync(SelectedPerson.Model); SelectedPerson.AcceptChanges(); }
/// <summary> /// Handles the Click event of the lbSelectPerson control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void lbSelectPerson_Click(object sender, EventArgs e) { _tbSearch.Text = string.Empty; SelectedPerson?.Invoke(this, new EventArgs()); }