Пример #1
0
        public static void AddNewPatient(Patient patient)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            hlthCareContext.Patients.Add(patient);
            hlthCareContext.SaveChanges();
        }
Пример #2
0
        public static void UpdatePatient(Patient patient)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            var pt = hlthCareContext.Patients.Where(p => p.Id == patient.Id).First();

            pt.Name = patient.Name;
            pt.Phone = patient.Phone;
            pt.Address = patient.Address;

            hlthCareContext.SaveChanges();
        }
Пример #3
0
 public PatientForm(int cmd, Patient pt)
 {
     InitializeComponent();
     this.pt = pt;
     flagEdit = false;
     switch (cmd)
     {
         case 0: FormForEdit(); break;
         case 1: FormForAdd(); break;
         default: throw new Exception("Not correct parametr to constructor for PatientForm!");
     }
 }
Пример #4
0
        public static void DeletePatient(int id)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            Patient patient = new Patient
            {
                Id = id
            };

            hlthCareContext.Patients.Attach(patient);
            hlthCareContext.Patients.Remove(patient);

            hlthCareContext.SaveChanges();
        }
Пример #5
0
        private void SetChangesToDB()
        {
            using (HealthCareEntities healthCareContext = new HealthCareEntities())
            {
                try
                {
                    GetDataFromForms();

                    if (pt.Id != 0)
                    {
                        Patient.UpdatePatient(pt);
                    }
                    else
                    {
                        Patient patient = new Patient()
                        {
                            Phone = pt.Phone,
                            Name =pt.Name,
                            Address = pt.Address
                        };

                        Patient.AddNewPatient(patient);
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Error! " + exp.Message);
                }
            }
        }
Пример #6
0
 public PatientForm()
 {
     InitializeComponent();
     pt = new Patient();
     flagEdit = false;
 }