Exemplo n.º 1
0
        //saves the appointment on the databse.
        private void button1_Click(object sender, EventArgs e)
        {
            clsDB_conn myDb_Con = new clsDB_conn();

            //checks if the chosen appointment date and time is available.
            if (DateTime.Compare(DateAndTime.Now, Convert.ToDateTime(dateTimePicker1.Text + " " + comboBox1.SelectedItem)) < 0)
            {
                appointments = myDb_Con.db_query("SELECT * FROM appointments WHERE time = '" + comboBox1.SelectedItem + "'", "doctor_m.mdb");
                if (appointments.Rows.Count < 1)
                {
                    myDb_Con.db_query("INSERT INTO `appointments` (date_id, patient_id, `time`, comment) VALUES ('" +
                                      dateTimePicker1.Value.ToShortDateString() + "', '" + patient_name + "', '" + comboBox1.SelectedItem + "', '" +
                                      Interaction.InputBox("Comment for appointment", "Appointment", "no comment") + "');", "doctor_m.mdb");
                    load_table();
                    textBox2.Text           = null;
                    comboBox1.SelectedIndex = 0;
                    textBox2.Focus();
                }
                else
                {
                    MessageBox.Show("please Select another time, " + Convert.ToDateTime(dateTimePicker1.Text + " " + comboBox1.SelectedItem).ToString() + "\nis not Available.", "Appointment");
                }
            }
            else
            {
                MessageBox.Show("please Select another time, " + Convert.ToDateTime(dateTimePicker1.Text + " " + comboBox1.SelectedItem).ToString() + "\nis not Available", "Appointment");
            }
            comboBox1.Focus();
        }
Exemplo n.º 2
0
        //searches for all appointments by patient, also enables you to delete an appointment.
        private void searchForAppointmentByPatientToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string     patient_id;
            string     patient  = Interaction.InputBox("Search for patient", "Search", "user");
            clsDB_conn myDb_Con = new clsDB_conn();
            DataTable  tamp     = myDb_Con.db_query("SELECT * FROM patients WHERE patient_name = '" + patient + "'", "doctor_m.mdb");

            if (tamp.Rows.Count == 1)
            {
                patient_id   = tamp.Rows[0].ItemArray[0].ToString();
                appointments = myDb_Con.db_query("SELECT appointments.date_id AS `Date`, appointments.time AS `Appointment Time` FROM appointments, patients  WHERE appointments.patient_id = " + patient_id + "", "doctor_m.mdb");
                if (appointments.Rows.Count < 1)
                {
                    MessageBox.Show("Patient has No appointments", "Appointments", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    dataGridView1.DataSource = appointments;
                    lblviewTitle.Text        = "Appointments for : " + patient;
                    textBox2.Text            = patient;
                }
            }
            else
            {
                MessageBox.Show("Patient Not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 3
0
 private void searchPatientToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //display the result of a search
     //prevent index out of range related crashes
     try
     {
         string     input    = Interaction.InputBox("Please enter a patiants name or telephone number", "search user");
         clsDB_conn myDb_Con = new clsDB_conn();
         appointments = myDb_Con.db_query("SELECT * FROM patients  WHERE  patient_name = '" + input + "' OR patient_telephone = '" + input + "'", "doctor_m.mdb");
         frmPatientManagement frm = new frmPatientManagement();
         if (appointments.Rows.Count > 0)
         {
             for (int i = 0; i < appointments.Rows.Count; i++)
             {
                 listBox1.Items.Add("Patient Details:");
                 for (int j = 1; j < 5; j++)
                 {
                     listBox1.Items.Add("\t" + appointments.Rows[i].ItemArray[j]);
                 }
             }
         }
         else
         {
             MessageBox.Show("Patient not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (IndexOutOfRangeException m)
     {
         MessageBox.Show(m.Message + "\nPlease contact the administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 4
0
        //to delete a record, search for a patient, if the patient has an appointment, you can select the date and the time of the appointment and delete the record
        //use the datetime picker to select the date and the combobox to select the time that corresponds to the appointment you want to delete.
        //button will only enable if the patient exists and has an apponitment at the date and time selected.
        private void button2_Click(object sender, EventArgs e)
        {
            clsDB_conn myDb_Con = new clsDB_conn();

            myDb_Con.db_query("DELETE * FROM appointments WHERE  patient_id = " + patient_name + " AND date_id = '" + Convert.ToDateTime(dateTimePicker1.Text).ToShortDateString() + "' AND `time` = '" + comboBox1.Text + "'", "doctor_m.mdb");
            load_table();
            textBox2.Clear();
            comboBox1.SelectedIndex = 0;
        }
Exemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //save new patient details
            clsDB_conn myDb_Con = new clsDB_conn();
            DataTable  temp     = myDb_Con.db_query("SELECT * FROM patients WHERE patient_name = '" + txtName.Text + "' AND patient_surname = '" + txtSurname.Text + "'", "|DataDirectory|/doctor_m.mdb");

            if (!(temp.Rows.Count > 0))
            {
                temp = myDb_Con.db_query("SELECT * FROM patients", "doctor_m.mdb");
                myDb_Con.db_query("INSERT INTO `patients` (`patient_name`,`patient_surname`,`patient_telephone`,`patient_address`) VALUES ('" + txtName.Text + "', '" + txtSurname.Text + "', '" + txtTelephone.Text + "', '" + txtAddress.Text + "')", "doctor_m.mdb");
                DataTable temp2 = myDb_Con.db_query("SELECT * FROM patients", "doctor_m.mdb");
                MessageBox.Show("Save Successful", "Add patient", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Data failed to write to table,\nPatient already in Database.", "Add patient", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 6
0
        //loads the table for displaying.
        private void load_table()
        {
            clsDB_conn myDb_Con = new clsDB_conn();

            appointments.Reset();
            appointments = myDb_Con.db_query("SELECT patients.patient_name AS Patient, patients.patient_telephone AS `Phone Number`,appointments.comment AS Comment , appointments.time AS `Appointment Time` FROM appointments, patients  WHERE date_id = '" +
                                             dateTimePicker1.Value.ToShortDateString() +
                                             "' AND appointments.patient_id = patients.patient_id ORDER BY appointments.time", "|DataDirectory|/doctor_m.mdb");
            dataGridView1.DataSource = appointments;
            lblviewTitle.Text        = "Appointments for : " + dateTimePicker1.Value.ToShortDateString();
        }
Exemplo n.º 7
0
        //allows you to change your password.
        private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string     input    = Interaction.InputBox("Please enter your username", "change password");
            clsDB_conn myDb_Con = new clsDB_conn();

            load_table(input);
            if (appointments.Rows.Count > 0)
            {
                myDb_Con.db_query("UPDATE users  SET  passKey = '" + Interaction.InputBox("Please enter your new Password", "change password") + "' WHERE userName = '******'", "doctor_m.mdb");
            }
            else
            {
                MessageBox.Show("User does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 8
0
 //allows use to verify if the selected patient has any appointment and enables the delete appointment button.
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (textBox2.ForeColor == Color.Green)
     {
         clsDB_conn myDb_Con = new clsDB_conn();
         appointments = myDb_Con.db_query("SELECT * FROM appointments WHERE  patient_id = " + patient_name + " AND date_id = '" + Convert.ToDateTime(dateTimePicker1.Text).ToShortDateString() + "' AND `time` = '" + comboBox1.Text + "'", "doctor_m.mdb");
         if (appointments.Rows.Count > 0)
         {
             btnDelete.Enabled = true;
         }
         else
         {
             btnDelete.Enabled = false;
         }
     }
 }
Exemplo n.º 9
0
        //allows you to view all patients in the form of a report.
        private void allPatientsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //save the report to a file.
            clsDB_conn     myDb_Con = new clsDB_conn();
            DataTable      temp     = myDb_Con.db_query("SELECT * FROM patients", "doctor_m.mdb");
            string         path;
            SaveFileDialog sf = new SaveFileDialog();

            sf.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            sf.Filter           = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (sf.ShowDialog(this) == DialogResult.OK)
            {
                path = sf.FileName;
                frmPatientManagement frm = new frmPatientManagement();
                ///prevent io releted crashes
                try
                {
                    if (temp.Rows.Count > 0)
                    {
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }
                        using (StreamWriter wr = File.AppendText(path))
                        {
                            for (int j = 1; j < temp.Rows.Count; j++)
                            {
                                wr.WriteLine("Patient : " + temp.Rows[j].ItemArray[1] + " " + temp.Rows[j].ItemArray[2]);
                                for (int i = 3; i < 5; i++)
                                {
                                    wr.WriteLine("\t" + temp.Rows[j].ItemArray[i]);
                                }
                            }
                        }
                        MessageBox.Show("Save Successful", "write to file", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("No Patients found", "write to file", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (IOException a)
                {
                    MessageBox.Show(a.Message + "\nFailed to open file,\nPlease try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 10
0
        //dynamically search for the patient when the text typed into the textbox.
        //only when the text in the textbox is green, can you create a new appointment or delete an appointment.
        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            clsDB_conn myDb_Con = new clsDB_conn();

            appointments = myDb_Con.db_query("SELECT * FROM patients WHERE patient_name = '" + textBox2.Text + "'", "doctor_m.mdb");
            if (appointments.Rows.Count == 1)
            {
                textBox2.ForeColor = Color.Green;
                patient_name       = appointments.Rows[0].ItemArray[0].ToString();
                btnSave.Enabled    = true;
            }
            else
            {
                textBox2.ForeColor = Color.Red;
                btnSave.Enabled    = false;
            }
        }
Exemplo n.º 11
0
        private void load_table()
        {
            clsDB_conn myDb_Con = new clsDB_conn();

            appointments = myDb_Con.db_query("SELECT * FROM users  WHERE  userName = '******'", "|DataDirectory|/doctor_m.mdb");
        }
Exemplo n.º 12
0
        //loads the contents of the datatable in the database to the application.
        private void load_table(string val)
        {
            clsDB_conn myDb_Con = new clsDB_conn();

            appointments = myDb_Con.db_query("SELECT * FROM users  WHERE  userName = '******'", "doctor_m.mdb");
        }