Пример #1
0
        private void BtnSelectPerson_Click(object sender, RoutedEventArgs e)
        {
            var winPersonSearch = new WinPersonSearch();

            winPersonSearch.ShowDialog();
            if (winPersonSearch.PersonId == 0)
            {
                return;
            }

            if (PersonId.Contains(winPersonSearch.PersonId))
            {
                Utility.Message("خطا", "این شخص یک‌بار انتخاب شده است", "Stop.png");
                return;
            }
            PersonId.Add(winPersonSearch.PersonId);
            PersonName.Add(winPersonSearch.PersonName);
            PersonFamily.Add(winPersonSearch.PersonFamily);
            PersonFather.Add(winPersonSearch.PersonFather);
            PersonCode.Add(winPersonSearch.PersonCode);
            _createPersons = new List <CreatePerson>();
            for (var i = 0; i < PersonId.Count; i++)
            {
                _createPersons.Add(new CreatePerson(PersonId[i], PersonName[i], PersonFamily[i], PersonFather[i],
                                                    PersonCode[i]));
            }
            DgdPerson.ItemsSource = _createPersons;
        }
Пример #2
0
 private void BtnDeletePerson_Click(object sender, RoutedEventArgs e)
 {
     if (DgdPerson.SelectedIndex == -1)
     {
         return;
     }
     PersonId.RemoveAt(DgdPerson.SelectedIndex);
     PersonName.RemoveAt(DgdPerson.SelectedIndex);
     PersonFamily.RemoveAt(DgdPerson.SelectedIndex);
     PersonFather.RemoveAt(DgdPerson.SelectedIndex);
     PersonCode.RemoveAt(DgdPerson.SelectedIndex);
     _createPersons = new List <CreatePerson>();
     for (var i = 0; i < PersonId.Count; i++)
     {
         _createPersons.Add(new CreatePerson(PersonId[i], PersonName[i], PersonFamily[i], PersonFather[i],
                                             PersonCode[i]));
     }
     DgdPerson.ItemsSource = _createPersons;
 }