private void btnAddInoculation_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; if (string.IsNullOrEmpty(txtInoculationName.Text.FullTrim())) { ShowErrorMsg("يجب إدخال اسم التطعيم"); Cursor = Cursors.Default; return; } var inoculation = new Inoculation { Name = txtInoculationName.Text.FullTrim(), Date = dtInoculationDate.Value != default(DateTime) ? dtInoculationDate.Value : (DateTime?)null, PatientId = Patient.Id }; InoculationManager.AddInoculation(inoculation); Patient.Inoculations.Add(inoculation); ClearInoculationInputs(); FillGrid(); Cursor = Cursors.Default; }
public void DeleteInoculation(Inoculation inoculation) { InoculationRepository.Delete(inoculation); InoculationRepository.Save(); }
public void AddInoculation(Inoculation inoculation) { InoculationRepository.Add(inoculation); InoculationRepository.Save(); }
public void UpdateInoculation(Inoculation inoculation) { InoculationRepository.Update(inoculation); InoculationRepository.Save(); }
private void SeedPatients(CancellationToken cancellationToken) { Random rnd = new Random(Environment.TickCount); RandomDate randomDate = new RandomDate(1950, DateTime.Now.Year - 10); int n = 0; var patients = new Patient[] { NewPatient("Максимов", "Сергей", "Иванович", "М"), NewPatient("Иванова", "Любовь", "Андреевна", "Ж"), NewPatient("Касьянов", "Михаил", "Валерьевич", "М"), NewPatient("Путин", "Владимир", "Владимирович", "М"), NewPatient("Жириновский", "Владимир", "Вольфович", "М"), NewPatient("Филатова", "Татьяна", "Николаевна", "Ж"), NewPatient("Гончаров", "Иван", "Александрович", "М"), NewPatient("Державин", "Гавриил", "Романович", "М"), NewPatient("Достоевский", "Фёдор", "Михайлович", "М"), NewPatient("Замятин", "Евгений", "Иванович", "М"), NewPatient("Карамзин", "Николай", "Михайлович", "М"), NewPatient("Тютчев", "Фёдор", "Иванович", "М"), NewPatient("Лермонтов", "Михаил", "Юрьевич", "М"), NewPatient("Ломоносов", "Михаил", "Васильевич", "М"), NewPatient("Некрасов", "Николай", "Николаевич", "М"), NewPatient("Мамин-Сибиряк", "Дмитрий", "Наркисович", "М"), NewPatient("Паустовский", "Константин", "Георгиевич", "М"), NewPatient("Пушкин", "Александр", "Сергеевич", "М"), NewPatient("Толстой", "Алексей", "Николаевич", "М"), NewPatient("Тургенев", "Иван", "Сергеевич", "М"), NewPatient("Цветаева", "Марина", "Ивановна", "Ж"), }; _context.Patients.AddRange(patients); Patient NewPatient(string lastName, string firstName, string patronymic, string sex) { var birthDate = randomDate.Next(); return(new Patient { BirthDate = birthDate, LastName = lastName, FirstName = firstName, Patronymic = patronymic, Sex = sex, InsuranceNumber = NewInsuranceNumber(), Inoculations = NewInoculations(birthDate.Year + 1) }); } string NewInsuranceNumber() { string insNum = (InsuranceNumber.MinNumber + n++).ToString("000000000"); string checkNum = InsuranceNumber.GetChecksum(insNum).ToString("00"); return($"{insNum}{checkNum}"); } ICollection <Inoculation> NewInoculations(int minYear) { var randomDate = new RandomDate(minYear, DateTime.Now.Year - 1); int n = rnd.Next(0, _vaccines.Length); var inoculations = new List <Inoculation>(n); for (int i = 0; i < n; i++) { var inoculation = new Inoculation { HasConsent = (rnd.Next(0, 2) == 1), Date = randomDate.Next(), VaccineId = _vaccines[i].Id, }; inoculations.Add(inoculation); } return(inoculations); } }