예제 #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;
 }