コード例 #1
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");
            }
        }
コード例 #2
0
        //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();
                }
            }
        }