public void CreateNew() { var newUser = new User(); var newPatient = new Patient() { Name = "Няма име", Number = "Няма номер" }; newUser.Patient = newPatient; this.User = newUser; this.FillView(); }
public static void UpdatePatient(Patient patient) { MedicalCardEntities context = new MedicalCardEntities(); context.Patients.AddObject(patient); context.ObjectStateManager.ChangeObjectState(patient, EntityState.Modified); context.SaveChanges(); //detach because object is stateless context.Detach(patient); }
public static void DeletePatient(Patient patient) { MedicalCardEntities context = new MedicalCardEntities(); if (patient.EntityState == EntityState.Detached) { context.Patients.Attach(patient); } context.Patients.DeleteObject(patient); context.SaveChanges(); }
public static void InsertPatient(Patient patient) { MedicalCardEntities context = new MedicalCardEntities(); if (patient.EntityState != EntityState.Detached) { context.ObjectStateManager.ChangeObjectState(patient, EntityState.Added); } else { context.Patients.AddObject(patient); } context.SaveChanges(); //detach because object is stateless context.Detach(patient); }
public bool TryChoosePatient(out Patient patient) { patient = null; this.panelButtons.Visible = false; this.panelChooseButtons.Visible = true; this.ShowDialog(); if (this.DialogResult != System.Windows.Forms.DialogResult.OK) { return false; } var selectedPatient = GetSelectedPatient(); if (selectedPatient == null) { return false; } patient = selectedPatient; return true; }
/// <summary> /// Deprecated Method for adding a new object to the Patients EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPatients(Patient patient) { base.AddObject("Patients", patient); }
/// <summary> /// Create a new Patient object. /// </summary> /// <param name="patientId">Initial value of the PatientId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="number">Initial value of the Number property.</param> public static Patient CreatePatient(global::System.Int32 patientId, global::System.String name, global::System.String number) { Patient patient = new Patient(); patient.PatientId = patientId; patient.Name = name; patient.Number = number; return patient; }
public void CreateNew() { var newPatient = new Patient(); this.Patient = newPatient; this.FillView(); }
private void SaveModel(Patient model) { try { if (Patient.PatientId == 0) { PatientsDataAccess.InsertPatient(Patient); } else { PatientsDataAccess.UpdatePatient(Patient); } View.Message = "Успешен запис!"; } catch (Exception e) { var message = String.Format("Възникна грешка при съхраняване! Обадете се на администратор!/n [0] ", e.Message); View.Message = message; } }