예제 #1
0
        public void AddPersonTest()
        {
            Repository repo = new Repository();
               // repo.AddPerson("Ivan", "Ivanov", "Иванович", DateTime.Today, "AM", "334455", "passport", 44);

               // Assert.AreEqual(1, repo.GetTotalPersons());
        }
예제 #2
0
        public FormAddPerson(Person person, int addressId)
        {
            InitializeComponent();
            _repo = new Repository();
            _addressId = addressId;
            _person = person;

            this.Text = "Изменить";
            textBoxFirstName.Text = person.FirstName;
            textBoxLastName.Text = person.LastName;
            textBoxPatronymic.Text = person.Patronymic;
            dateEditDoB.DateTime = DateTime.FromBinary(person.DoB);
            comboBoxEditGender.SelectedIndex = person.Gender ? 0 : 1;
            textBoxSeries.Text = person.PassportSeries;
            textBoxNumber.Text = person.PassportNumber;
            comboBoxDocType.SelectedIndex = person.Type.Equals("Паспорт") ? 0 : 1;

            buttonSave.Click -= buttonSave_Click;
            buttonSave.Click += new System.EventHandler(buttonSave_ClickUpdate);
        }
예제 #3
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            _repo = new Repository();
            int building = 0;
            int? apartment = 0;

            if(textBoxApartment.Text == string.Empty)
            {
                apartment = null;
            }
            else
            {
                apartment = int.Parse(textBoxApartment.Text);
            }

            if (int.TryParse(textBoxBuilding.Text, out building))
            {
                try
                {
                    _repo.AddAddress(
                        textBoxCity.Text,
                        textBoxDistrict.Text,
                        textBoxStreet.Text,
                        building,
                        apartment
                        );
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "Ошибка!");
                }
            }
            else
            {
                MessageBox.Show("Проверьте правильность ввода номера дома и квартиры!", "Предупреждение!");
            }
        }
예제 #4
0
 public mainForm()
 {
     InitializeComponent();
     _repo = new Repository();
 }
예제 #5
0
 public FormAddPerson()
 {
     InitializeComponent();
     _repo = new Repository();
     //this.comboBoxEditAddresses.BindingContext = repo.GetAddresses();
 }
예제 #6
0
 public FormAddAddress()
 {
     InitializeComponent();
     _repo = new Repository();
 }