public void NewPatient() { PatientSet user = new PatientSet(); user.Address = PAddress1; user.BirthDate = PDateOfBirth1; user.LastName = PLastName1; user.FirstName = PName1; user.Occupation = POccupation1; user.CellPhone = PCellPhone1; user.CitySet = PCity1; user.FileSet = PFile1; user.LastVisit = PLASTVISIT1; user.FileSet = PFile1; user.RDVSets = new List <RDVSet>(); if (user.Address != null && user.BirthDate != null && user.LastName != null && user.FirstName != null && user.Occupation != null && user.CellPhone != null && user.RDVSets != null) { try { ctx.PatientSets.Add(user); ctx.SaveChanges(); this.X = true; Searching(); this.X = false; MessageBox.Show("Patient Added"); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } } }
public void emptyPatient() { PName1 = null; PLastName1 = null; PLASTVISIT1 = DateTime.Today; PDateOfBirth1 = DateTime.Today; PFile1 = null; PCity1 = null; PCellPhone1 = null; PAddress1 = null; POccupation1 = null; SelectedPatient = null; _Files = null; RaisePropertyChanged("Files"); RaisePropertyChanged("SelectedPatient1"); }