public void AddPersonTest() { Repository repo = new Repository(); // repo.AddPerson("Ivan", "Ivanov", "Иванович", DateTime.Today, "AM", "334455", "passport", 44); // Assert.AreEqual(1, repo.GetTotalPersons()); }
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); }
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("Проверьте правильность ввода номера дома и квартиры!", "Предупреждение!"); } }
public mainForm() { InitializeComponent(); _repo = new Repository(); }
public FormAddPerson() { InitializeComponent(); _repo = new Repository(); //this.comboBoxEditAddresses.BindingContext = repo.GetAddresses(); }
public FormAddAddress() { InitializeComponent(); _repo = new Repository(); }