//Checks if current password matches and if password is strong enough and new passwords match. Updates table if conditions met.
 //Clears the text boxes if password is reset to prevent spam.
 private void butUpdatePass_Click(object sender, EventArgs e)
 {
     if (SQLQuery.Exists("Patients", "passWord = '******'") == 1)
     {
         if (txtNewPass.Text == txtReEnterPass.Text)
         {
             if (Validation.IsValidPassword(txtNewPass.Text))
             {
                 SQLQuery.UpdateRow("Patients", "passWord", txtNewPass.Text, condition);
                 MessageBox.Show("Password updated");
                 txtCPass.Clear();
                 txtNewPass.Clear();
                 txtReEnterPass.Clear();
             }
         }
         else
         {
             MessageBox.Show("Passwords do not match");
         }
     }
     else if (txtCPass.Text == "")
     {
         MessageBox.Show("Must enter your current password");
     }
     else
     {
         MessageBox.Show("Incorrect Password");
     }
 }
Exemplo n.º 2
0
        //Validates the fields to see if patient exists. Creates SQL insert with user text and current date.
        private void butNote_Click(object sender, EventArgs e)
        {
            string FirstName = txtFirstName.Text;
            string LastName  = txtLastName.Text;
            string condition = "firstName = '" + FirstName + "' AND lastName = '" + LastName + "'";

            //If the patient specified by the doctor exists then proceed
            if (SQLQuery.Exists("Patients", condition) == 1)
            {
                object   pID            = SQLQuery.SingleSelect("pId", "Patients", condition);
                string   Date           = DateTime.Now.ToString("MM/dd/yyyy");
                string   SymptomName    = txtSymptomName.Text;
                string   SymptomDetails = txtSymptomDetails.Text;
                object[] values         = new object[5] {
                    (dID), (pID), (Date), (SymptomName), (SymptomDetails)
                };
                SQLQuery.Insert("Medical_History", values);
                MessageBox.Show("Medical Note Added");
                this.Hide();
                this.Close();
            }
            else
            {
                MessageBox.Show("Invalid First or Last Patient Name");
            }
        }
        //When a date is picked, check the database for available times for the patient to schedule an appt with specified doctor
        private void datePicker_ValueChanged(object sender, EventArgs e)
        {
            boxTimes.Enabled = true;
            string selectedDate = datePicker.Value.ToShortDateString();


            foreach (var control in boxTimes.Controls.OfType <RadioButton>())
            {
                //String WHERE condition to see if the patient and doctor are available at the specified time
                string Availability = "date = '" + selectedDate +
                                      "' AND (dID = '" + dID + "' OR pId = '" + pID +
                                      "') AND time = '" + control.Text + "'";

                //If note available, the time is disabled
                if (SQLQuery.Exists("Appointments", Availability) == 1)
                {
                    control.Enabled = false;
                }
                //Otherwise it is enabled
                else
                {
                    control.Enabled = true;
                }
            }
        }
        //When a valid doctor last name has been entered, allow patient to pick a time
        private void txtDoctorLast_TextChanged(object sender, EventArgs e)
        {
            string LastName  = txtDoctorLast.Text;
            string condition = "lastName = '" + LastName + "'";

            if (SQLQuery.Exists("Doctor", condition) == 1)
            {
                datePicker.Enabled = true;
                dID = Convert.ToInt32(SQLQuery.SingleSelect("dID", "Doctor", condition));
            }
            else
            {
                dID = -1;
                datePicker.Enabled = false;
                boxTimes.Enabled   = false;
            }
        }
        //Once a valid doctor, date and time have been selected, appointment will be made.
        private void butMakeAppt_Click(object sender, EventArgs e)
        {
            //Gather variables for validation and insert.
            string subject       = txtSubject.Text;
            string selectedDate  = datePicker.Value.ToShortDateString();
            var    checkedButton = boxTimes.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);
            string time          = checkedButton.Text;
            string checkCon      = "date = '" + selectedDate + "' AND dID = '" + dID + "' AND pId = '" + pID + "'";

            //Check to see if the patient has an appointment with that doctor that day.
            if (SQLQuery.Exists("Appointments", checkCon) == 0)
            {
                object[] values = new object[5] {
                    (dID), (pID), (selectedDate), (time), (subject)
                };
                //Insert appointment into database
                SQLQuery.Insert("Appointments", values);

                //Notify user of their selected appointment
                string message = ("Appointment made for: " + selectedDate + ", at " + time + " with Dr." + txtDoctorLast.Text);
                MessageBox.Show(message);
                this.Hide();
                this.Close();
            }

            //Give user the option to reschedule appointment to new time.
            else
            {
                DialogResult dialogResult = MessageBox.Show(
                    "You already have an appointment with this doctor today. " +
                    "\nWould you like to change it to the newly selected time?", "Reschedule Appointment", MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    SQLQuery.UpdateRow("Appointments", "time", time, checkCon);
                    string message = ("Appointment made for: " + selectedDate + ", at " + time + " with Dr." + txtDoctorLast.Text);
                    MessageBox.Show(message);
                    this.Hide();
                    this.Close();
                }
            }
        }