Exemple #1
0
        public static void AddNewClinic(Clinic clinic)
        {
            HealthCareEntities hlthCareContext = new HealthCareEntities();

            hlthCareContext.Clinics.Add(clinic);
            hlthCareContext.SaveChanges();
        }
Exemple #2
0
 public ClinicForm(int cmd, Clinic cl)
 {
     InitializeComponent();
     this.cl = cl;
     flagEdit = false;
     switch (cmd)
     {
         case 0: FormForEdit(); break;
         case 1: FormForAdd(); break;
         default: throw new Exception("Not correct parametr to constructor for ClinicForm!");
     }
 }
Exemple #3
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();
        }
Exemple #4
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();
        }
Exemple #5
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);
                }
            }
        }
Exemple #6
0
 public ClinicForm()
 {
     InitializeComponent();
     cl = new Clinic();
     flagEdit = false;
 }