示例#1
0
        /// <summary>
        /// Book time off using empty customer for practitioner's time off booking
        /// </summary>
        /// <param name="practitionerID"></param>
        private void BookTimeOff(int practitionerID)
        {
            if (listBoxTime.SelectedItem == null)
            {
                MessageBox.Show("Please select a time");
                return;
            }

            Booking timeOffBooking = new Booking
            {
                CustomerID          = 6,
                PractitionerID      = practitionerID,
                Date                = monthCalendarBookingDate.SelectionRange.Start,
                Time                = (TimeSpan)listBoxTime.SelectedItem,
                BookingPrice        = 0,
                BookingStatus       = BookingStatus.TIME_OFF,
                PractitionerComment = ""
            };

            // Booking validation
            if (timeOffBooking.InfoIsInvalid())
            {
                MessageBox.Show("Booking information is invalid. Please check and try it again.");
                return;
            }

            if (Controller <MedicalCentreManagementEntities, Booking> .AddEntity(timeOffBooking) == null)
            {
                MessageBox.Show("Cannot add time off booking to database");
                return;
            }
            BaseFormMethods.ClearAllControls(this);
            this.DialogResult = DialogResult.OK;
            Close();
        }
示例#2
0
 public MedicalCentreBookHoursOff(int practitionerID)
 {
     InitializeComponent();
     monthCalendarBookingDate.MaxSelectionCount = 1;
     BaseFormMethods.ClearAllControls(this);
     monthCalendarBookingDate.DateChanged += (s, e) => GetPractitionerAvailability(practitionerID);
     buttonBookTimeOff.Click += (s, e) => BookTimeOff(practitionerID);
 }
 public MedicalCentreAddPractitioner()
 {
     this.Text = "Medical Centre: Register New Practitioner";
     InitializeComponent();
     BaseFormMethods.PopulateProvinceComboBox(comboBoxProvince);
     PopulatePractitionerTypeComboBox();
     buttonRegisterNewPractitioner.Click += AddNewPractitioner;
 }
 public MedicalCentreAddPatient()
 {
     // set title
     Text = "Medical Centre:Register New Patient";
     InitializeComponent();
     // populate the provinces
     BaseFormMethods.PopulateProvinceComboBox(comboBoxProvince);
     // add event to button
     buttonAddNewPatient.Click += AddNewPatient;
 }
示例#5
0
 /// <summary>
 /// pre-populating practioner's information
 /// </summary>
 /// <param name="practitionerID"></param>
 private void PrePopulateFields(int practitionerID)
 {
     BaseFormMethods.PopulateProvinceComboBox(comboBoxProvince);
     PopulatePractitionerTypeComboBox();
     using (MedicalCentreManagementEntities context = new MedicalCentreManagementEntities())
     {
         var practitioner = context.Practitioners.Find(practitionerID);
         var user         = context.Users.Find(practitioner.UserID);
         textBoxFirstName.Text         = user.FirstName;
         textBoxLastName.Text          = user.LastName;
         dateTimePickerBirthDate.Value = (DateTime)user.Birthdate;
         textBoxStreetAddress.Text     = user.Address;
         textBoxCity.Text = user.City;
         comboBoxProvince.SelectedIndex = comboBoxProvince.FindStringExact(user.Province);
         textBoxEmail.Text       = user.Email;
         textBoxPhoneNumber.Text = user.PhoneNumber;
         comboBoxPractitionerType.SelectedIndex = comboBoxPractitionerType.FindStringExact(practitioner.Practitioner_Types.Title);
     }
 }
示例#6
0
        /// <summary>
        /// Method to prepopulate controls based on customer id
        /// </summary>
        /// <param name="customerID"> customer id </param>
        private void PrePopulateFields(int customerID)
        {
            // set up province combobox
            BaseFormMethods.PopulateProvinceComboBox(comboBoxProvince);
            // using unit-of-work context
            using (MedicalCentreManagementEntities context = new MedicalCentreManagementEntities())
            {
                // find customer in db
                var customer = context.Customers.Find(customerID);
                // find user in db
                var user = context.Users.Find(customer.UserID);

                // populate controls
                textBoxFirstName.Text         = user.FirstName;
                textBoxLastName.Text          = user.LastName;
                dateTimePickerBirthDate.Value = (DateTime)user.Birthdate;
                textBoxAddress.Text           = user.Address;
                textBoxCity.Text = user.City;
                comboBoxProvince.SelectedIndex = comboBoxProvince.FindStringExact(user.Province);
                textBoxEmail.Text       = user.Email;
                textBoxPhoneNumber.Text = user.PhoneNumber;
                textBoxMSP.Text         = customer.MSP;
            }
        }
        /// <summary>
        /// Adding a new patient
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddNewPatient(object sender, EventArgs e)
        {
            // get all values from input controls
            string   firstName   = textBoxFirstName.Text;
            string   lastName    = textBoxLastName.Text;
            DateTime birthdate   = dateTimePickerBirthDate.Value;
            string   address     = textBoxAddress.Text;
            string   city        = textBoxCity.Text;
            string   province    = comboBoxProvince.GetItemText(comboBoxProvince.SelectedItem);
            string   phoneNumber = textBoxPhoneNumber.Text;
            string   email       = textBoxEmail.Text;
            string   msp         = textBoxMSP.Text;

            // build a new user object
            User newUser = new User
            {
                FirstName   = firstName,
                LastName    = lastName,
                Birthdate   = birthdate,
                Address     = address,
                City        = city,
                Province    = province,
                PhoneNumber = phoneNumber,
                Email       = email,
            };

            // validate user information
            if (newUser.InfoIsInvalid())
            {
                // error if invalid
                MessageBox.Show("Patient information is not valid!");
                return;
            }
            // using a unit-of-work context
            using (MedicalCentreManagementEntities context = new MedicalCentreManagementEntities())
            {
                // add to Users table and save changes
                User addedUser = context.Users.Add(newUser);
                context.SaveChanges();

                // make sure it was added
                if (addedUser == null)
                {
                    MessageBox.Show("User was not added into a database!");
                    return;
                }
                // create a new Customer
                Customer newCustomer = new Customer
                {
                    User   = addedUser,
                    UserID = addedUser.UserID,
                    MSP    = msp
                };

                // validate Customer information
                if (!newCustomer.IsValidCustomer())
                {
                    MessageBox.Show("MSP must be unique or blank!");
                    return;
                }
                // add a new customer to DB
                context.Customers.Add(newCustomer);
                context.SaveChanges();// save changes

                // make sure it was added- error if not
                if (newCustomer == null)
                {
                    MessageBox.Show("Customer was not added into a database!");
                    return;
                }

                BaseFormMethods.ClearAllControls(this);
            }
            // If successful- set result to OK and close form
            DialogResult = DialogResult.OK;
            Close();
        }
        /// <summary>
        /// creates new user and practitioner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddNewPractitioner(object sender, EventArgs e)
        {
            string   firstName   = textBoxFirstName.Text;
            string   lastName    = textBoxLastName.Text;
            DateTime birthdate   = dateTimePickerBirthDate.Value;
            string   address     = textBoxStreetAddress.Text;
            string   city        = textBoxCity.Text;
            string   province    = comboBoxProvince.GetItemText(comboBoxProvince.SelectedItem);
            string   phoneNumber = textBoxPhoneNumber.Text;
            string   email       = textBoxEmail.Text;
            int      typeId      = (comboBoxPractitionerType.SelectedItem as Practitioner_Types).TypeID;
            User     newUser     = new User
            {
                FirstName   = firstName,
                LastName    = lastName,
                Birthdate   = birthdate,
                Address     = address,
                City        = city,
                Province    = province,
                PhoneNumber = phoneNumber,
                Email       = email
            };

            // validate user
            if (newUser.InfoIsInvalid())
            {
                MessageBox.Show("Please fill practitioner's information");
                return;
            }



            // check practitionalType is selected
            if (comboBoxPractitionerType.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a Pracitioner Type");
                return;
            }


            using (MedicalCentreManagementEntities context = new MedicalCentreManagementEntities())
            {
                User addedUser = context.Users.Add(newUser);
                context.SaveChanges();
                // get selected practitioner type

                Practitioner newPractitioner = new Practitioner
                {
                    UserID = addedUser.UserID,
                    TypeID = typeId,
                };

                // validate practitioner
                if (!newPractitioner.IsValidPractitioner())
                {
                    MessageBox.Show("Practitioner must picked from User");
                    return;
                }

                context.Practitioners.Add(newPractitioner);
                context.SaveChanges();
            }
            BaseFormMethods.ClearAllControls(this);
            this.DialogResult = DialogResult.OK;
            Close();
        }