Example #1
0
        public static void AddNewDoctor(Doctor doctor)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            hlthCareContext.Doctors.Add(doctor);
            hlthCareContext.SaveChanges();
        }
Example #2
0
        public static void AdNewJournal(Journal journal)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            hlthCareContext.Journals.Add(journal);
            hlthCareContext.SaveChanges();
        }
Example #3
0
        public static void AddNewPatient(Patient patient)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            hlthCareContext.Patients.Add(patient);
            hlthCareContext.SaveChanges();
        }
Example #4
0
        public static void AddNewClinic(Clinic clinic)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            hlthCareContext.Clinics.Add(clinic);
            hlthCareContext.SaveChanges();
        }
Example #5
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();
        }
Example #6
0
        public static void UpdateClinic(Clinic clinic)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            var cl = hlthCareContext.Clinics.Where(c => c.Id == clinic.Id).First();

            cl.Title = clinic.Title;
            cl.Phone = clinic.Phone;
            cl.Address = clinic.Address;

            hlthCareContext.SaveChanges();
        }
Example #7
0
        public static void UpdateDoctor(Doctor doctor)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            var dr = hlthCareContext.Doctors.Where(d => d.Id == doctor.Id).First();

            dr.Name = doctor.Name;
            dr.Phone = doctor.Phone;
            dr.IdClinic = doctor.IdClinic;
            dr.Address = doctor.Address;

            hlthCareContext.SaveChanges();
        }
Example #8
0
        public static void DeleteDoctor(int id)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            Doctor doctor = new Doctor()
            {
                Id = id
            };

            hlthCareContext.Doctors.Attach(doctor);
            hlthCareContext.Doctors.Remove(doctor);

            hlthCareContext.SaveChanges();
        }
Example #9
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();
        }
Example #10
0
        public static void DeleteClinic(int id)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            Clinic clinic = new Clinic()
            {
                Id = id
            };

            hlthCareContext.Clinics.Attach(clinic);
            hlthCareContext.Clinics.Remove(clinic);

            hlthCareContext.SaveChanges();
        }
Example #11
0
        //Journal journalPast, Journal journalNew )
        public static void UpdateJournal(Journal journal)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            var jr = hlthCareContext.Journals.Where(j => (j.IdDoctor == journal.IdDoctor
                && j.IdPatient == journal.IdPatient && j.Date == journal.Date)).First();

            //jr.IdDoctor = journalNew.IdDoctor;
            //jr.IdPatient = journalNew.IdPatient;
            //jr.SomeInfo = journalNew.SomeInfo;
            //jr.Date = journalNew.Date;
            jr.SomeInfo = journal.SomeInfo;

            hlthCareContext.SaveChanges();
        }
Example #12
0
        public static void DeleteJournal(int idDoctor, int idPatient, DateTime date)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            Journal journal = new Journal
            {
                IdDoctor = idDoctor,
                IdPatient = idPatient,
                Date = date
            };

            hlthCareContext.Journals.Attach(journal);
            hlthCareContext.Journals.Remove(journal);

            hlthCareContext.SaveChanges();
        }
Example #13
0
        private void SetChangesToDB()
        {
            using (HealthCareEntities healthCareContext = new HealthCareEntities())
            {
                try
                {
                    GetDataFromForms();

                    if (dr.Id != 0)
                    {
                        Doctor.UpdateDoctor(dr);
                    }
                    else
                    {
                        Doctor doctor = new Doctor()
                        {
                            Phone = dr.Phone,
                            Name = dr.Name,
                            Address = dr.Address,
                            IdClinic = dr.IdClinic
                        };

                        Doctor.AddNewDoctor(doctor);
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Error! " + exp.Message);
                }
            }
        }
Example #14
0
        private void SetChangesToDB()
        {
            using (HealthCareEntities healthCareContext = new HealthCareEntities())
            {
                try
                {
                    GetDataFromForms();

                    if (cl.Id != 0)
                    {
                        Clinic.UpdateClinic(cl);
                    }
                    else
                    {
                        Clinic clinic = new Clinic()
                        {
                            Phone = cl.Phone,
                            Title = cl.Title,
                            Address = cl.Address
                        };

                        Clinic.AddNewClinic(clinic);
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Error! " + exp.Message);
                }
            }
        }
Example #15
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);
                }
            }
        }
Example #16
0
        private void SetChangesToDB()
        {
            using (HealthCareEntities healthCareContext = new HealthCareEntities())
            {
                try
                {
                    //Journal journalBeforeChanged = new Journal()
                    //{
                    //    IdDoctor = jr.IdDoctor,
                    //    IdPatient = jr.IdPatient,
                    //    Date = jr.Date,
                    //    SomeInfo = jr.SomeInfo
                    //};

                    if (jr.IdDoctor != 0)
                    {
                        GetDataFromForms();
                        Journal.UpdateJournal(jr);
                    }
                    else
                    {
                        GetDataFromForms();
                        Journal journal = new Journal()
                        {
                            IdDoctor = jr.IdDoctor,
                            IdPatient = jr.IdPatient,
                            Date = jr.Date,
                            SomeInfo = jr.SomeInfo
                        };

                        Journal.AdNewJournal(journal);
                    }
                }
                catch (Exception exp)
                {
                    MessageBox.Show("Error! " + exp.Message);
                }
            }
        }