private void btnContinue_Click(object sender, EventArgs e)
        {
            if (_newFacility)
            {
                FacilitiesForm.AddFacility(this.txtName.Text, this.txtAddress.Text, this.txtZip.Text, this.txtPhone.Text, this.txtCity.Text, this.lbStates.Text);
            }
            else
            {
                using (var MedDB = new MedicalEntities())
                {
                    var entry = MedDB.Facilities.Find(_facility.FacilityID);

                    _facility.Address = this.txtAddress.Text;
                    _facility.City    = this.txtCity.Text;
                    _facility.Name    = this.txtName.Text;
                    _facility.Phone   = this.txtPhone.Text;
                    _facility.Zip     = this.txtZip.Text;
                    _facility.State   = this.lbStates.Text;

                    MedDB.Entry(entry).CurrentValues.SetValues(_facility);
                    MedDB.SaveChanges();
                }
            }

            this.Close();
        }
        private void AddPatient(string fname, string mname, string lname)
        {
            using (var MedDB = new MedicalEntities())
            {
                Patient p = new Patient()
                {
                    FacilityID = _facility.FacilityID,
                    FirstName  = fname,
                    MiddleName = lname,
                    Status     = 0,
                    PatientID  = Guid.NewGuid()
                };

                MedDB.Patients.Add(p);
                MedDB.SaveChanges();
            }
        }
 public static void AddFacility(string name, string address, string zip, string phone, string city, string state)
 {
     using (var MedDB = new MedicalEntities())
     {
         Facility f = new Facility();
         f.FacilityID = Guid.NewGuid();
         f.Name       = name;
         f.Address    = address;
         f.Zip        = zip;
         f.Phone      = phone;
         f.City       = city;
         f.State      = state;
         MedDB.Facilities.Add(f);
         MedDB.SaveChanges();
         //UpdateFacilities();
     }
 }
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show($"Are you sure you want to delete {selection.Name} from the facilities table?", "Are You Sure?", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                MessageBox.Show($"{selection.Name} was sucessfully deleted from the facilities table!");

                using (var MedDB = new MedicalEntities())
                {
                    MedDB.Entry(selection).State = EntityState.Deleted;
                    MedDB.SaveChanges();
                }

                UpdateFacilities();
            }
        }
        public static void AddPatient(Guid facility, string fname, string mname, string lname)
        {
            using (var MedDB = new MedicalEntities())
            {
                Patient p = new Patient()
                {
                    FacilityID = facility,
                    FirstName  = fname,
                    MiddleName = mname,
                    LastName   = lname,
                    Status     = 0,
                    PatientID  = Guid.NewGuid()
                };

                MedDB.Patients.Add(p);
                MedDB.SaveChanges();
            }
        }
Пример #6
0
        public static void AddEmployee(Guid facility, string fname, string mname, string lname, string phone, int position, decimal salary, string title, bool working)
        {
            using (var MedDB = new MedicalEntities())
            {
                Employee e = new Employee()
                {
                    EmployeeID = Guid.NewGuid(),
                    FirstName  = fname,
                    MiddleName = mname,
                    LastName   = lname,
                    Phone      = phone,
                    Position   = position,
                    Salary     = salary,
                    Title      = title,
                    Working    = working
                };

                MedDB.Employees.Add(e);
                MedDB.SaveChanges();
            }
        }