public static void UpdateDoctor(Doctor doctor) { MedicalCardEntities context = new MedicalCardEntities(); context.Doctors.AddObject(doctor); context.ObjectStateManager.ChangeObjectState(doctor, EntityState.Modified); context.SaveChanges(); }
public static void DeleteDoctor(Doctor doctor) { MedicalCardEntities context = new MedicalCardEntities(); if (doctor.EntityState == EntityState.Detached) { context.Doctors.Attach(doctor); } context.Doctors.DeleteObject(doctor); context.SaveChanges(); }
public static void InsertDoctor(Doctor doctor) { MedicalCardEntities context = new MedicalCardEntities(); if (doctor.EntityState != EntityState.Detached) { context.ObjectStateManager.ChangeObjectState(doctor, EntityState.Added); } else { context.Doctors.AddObject(doctor); } context.SaveChanges(); }
public bool TryChooseDoctor(out Doctor doctor) { doctor = null; this.panelButtons.Visible = true; this.panelChooseButtons.Visible = true; this.ShowDialog(); if (this.DialogResult != System.Windows.Forms.DialogResult.OK) { return false; } var selectedDoctor = GetSelectedDoctor(); if (selectedDoctor == null) { return false; } doctor = selectedDoctor; return true; }
/// <summary> /// Create a new Doctor object. /// </summary> /// <param name="doctorId">Initial value of the DoctorId property.</param> public static Doctor CreateDoctor(global::System.Int32 doctorId) { Doctor doctor = new Doctor(); doctor.DoctorId = doctorId; return doctor; }
/// <summary> /// Deprecated Method for adding a new object to the Doctors EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDoctors(Doctor doctor) { base.AddObject("Doctors", doctor); }
public void CreateNew() { var newDoctor = new Doctor(); this.Doctor = newDoctor; this.FillView(); }
private void SaveModel(Doctor model) { try { if (Doctor.DoctorId == 0) { DoctorsDataAccess.InsertDoctor(Doctor); } else { DoctorsDataAccess.UpdateDoctor(Doctor); } View.Message = "Успешен запис!"; } catch (Exception e) { var message = String.Format("Възникна грешка при съхраняване! Обадете се на администратор!/n [0] ", e.Message); View.Message = message; } }