/// <summary>
        /// Method that tries to register the patient into the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void registerBtn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(nameTxt.Text) || string.IsNullOrWhiteSpace(addressTxt.Text) || string.IsNullOrWhiteSpace(pstCodeTxt.Text) || string.IsNullOrWhiteSpace(pstCodeTxt.Text) || string.IsNullOrWhiteSpace(cityTxt.Text) || string.IsNullOrWhiteSpace(dobTimePick.Text) || string.IsNullOrWhiteSpace(phoneNumberTxt.Text))
            {
                // Message box
                MessageBox.Show("Please fill all Fields");
            }
            else
            {
                try
                {
                    Logger.Instance.Log("RegisterPatientUserControl:registerBtn_Click() -> Registering a patient");

                    //Try to register patient by getting the data from the user input textboxes
                    //Convert the date time from the value picker to a desired value
                    string dobTemp = dobTimePick.Value.ToString("yyyy/MM/dd");

                    DBConnection.getDBConnectionInstance().SqlStatementExecute(Constants.RegisterPatient(nameTxt.Text, addressTxt.Text, pstCodeTxt.Text, cityTxt.Text, dobTemp, phoneNumberTxt.Text));
                    //Show success message and close form
                    MessageBox.Show("Patient added successfully!");

                    PatientUserControl.RemoveRegister();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #2
0
        //Code for the button methods

        /// <summary>
        /// Login button method that checks for the right credentials
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loginButton_Click(object sender, EventArgs e)
        {
            int i = 0;

            try
            {
                Logger.Instance.Log("LoginFrom:loginButton_Click() -> Accessing the database with the user input");
                //access the database and get an int
                i = DBConnection.getDBConnectionInstance().TryLogin(txtUsername.Text, txtPassword.Text);

                //if i=0 then no result was outputed in the query so invalid username
                if (i == 0)
                {
                    MessageBox.Show("You have entered an invalid username or password.");
                }
                //else the main menu can open
                else
                {
                    this.Hide();
                    overSurgeryTitle mainMenu = new overSurgeryTitle();
                    //Rom addition
                    UsernameText = txtUsername.Text;
                    //
                    mainMenu.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Method that runs whenever the user enter a key in order to find a patient in the DB
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void findBtn_Click(object sender, EventArgs e)
        {
            DataSet dsPatient = DBConnection.getDBConnectionInstance().getDataSet(Constants.FindPatient(findInputTxtBox.Text));

            //get the table to be displayed from the data set
            DataTable dtPatient = dsPatient.Tables[0];

            //set the data source for the data grid view
            dataGridView1.DataSource = dtPatient;
        }
Exemple #4
0
        //check if a staff member is already busy according to the user input
        public int CheckStaffBusy(int staffID, string date, string time)
        {
            int     i           = 0;
            string  staffString = Convert.ToString(staffID);
            DataSet dsUser      = DBConnection.getDBConnectionInstance().getDataSet(Constants.SpecificStaffMember(staffString, date, time));

            //get the table to be displayed from the data set
            DataTable dtUser = dsUser.Tables[0];

            i = Convert.ToInt32(dtUser.Rows.Count.ToString());
            return(i);
        }
Exemple #5
0
        /// <summary>
        /// Method that returns an in based on the amount of rows with the same data as the user input.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public int TryLogin(string username, string password)
        {
            int i = 0;


            DataSet dsUser = DBConnection.getDBConnectionInstance().getDataSet(Constants.SelectLogin(username, password));

            //get the table to be displayed from the data set
            DataTable dtUser = dsUser.Tables[0];

            i = Convert.ToInt32(dtUser.Rows.Count.ToString());
            return(i);
        }
        /// <summary>
        /// Load method for the appointment user control
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AppointmentUserControl_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'oversurgeryDataSet.userdata' table. You can move, or remove it, as needed.
            this.userdataTableAdapter.Fill(this.oversurgeryDataSet.userdata);

            DataSet dsAppoint = DBConnection.getDBConnectionInstance().getDataSet(Constants.selectAllAppointment);

            //get the table to be displayed from the data set
            DataTable dtAppoint = dsAppoint.Tables[0];

            //set the data source for the data grid view
            dataGridView1.DataSource = dtAppoint;
        }
        private void testPrintGridview()
        {
            DataSet   dsPatient = DBConnection.getDBConnectionInstance().getDataSet(Constants.PrintTests(@id));
            DataTable dtPatient = dsPatient.Tables[0];

            dataGridView1.DataSource = dtPatient;

            DataGridViewColumn column3 = dataGridView1.Columns[3];
            DataGridViewColumn column0 = dataGridView1.Columns[0];

            column3.Width = 330;
            column0.Width = 150;
        }
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            //reload the listview
            LoadlistView();

            //Get the quantity of staff for the loop
            int staffNumber = DBConnection.getDBConnectionInstance().GetIntValue(Constants.countStaff);

            for (int i = 0; i <= staffNumber; i++)
            {
                string staffID = Convert.ToString(i);
                AddShiftToListView(staffID);
            }
        }
        /// <summary>
        /// Method that load the list view with the staff shifts data.
        /// </summary>
        private void LoadlistView()
        {
            Logger.Instance.Log("StaffUserControlUserControl:LoadlistView() -> Loading the list view.");


            //Clears the list view
            listView1.Items.Clear();
            listView1.Columns.Clear();

            //I want to add a listview
            listView1.Columns.Add("Time");

            DataSet dsMedicalStaff = DBConnection.getDBConnectionInstance().getDataSet(Constants.selectStaff);

            //get the table to be displayed from the data set
            DataTable dtStaff = dsMedicalStaff.Tables[0];

            //load the list view with data
            int max = DBConnection.getDBConnectionInstance().GetIntValue(Constants.countStaff);

            for (int i = 0; i < max; i++)
            {
                listView1.Columns.Add(dtStaff.Rows[i]["staffName"].ToString(), 120);
            }

            for (int i = 8; i < 24; i++)
            {
                if (i < 10)
                {
                    listView1.Items.Add("0" + i + ":00");
                }
                else
                {
                    listView1.Items.Add(i + ":00");
                }
            }

            for (int index = 0; index < max; index++)
            {
                for (int i = 0; i < 16; i++)
                {
                    listView1.Items[i].SubItems.Add("Available");
                    //property to add colour
                    listView1.Items[i].UseItemStyleForSubItems = false;
                }
            }
        }
        /// <summary>
        /// Method that fill the combo boxes with the correct data
        /// </summary>
        private void FillComboBoxes()
        {
            //get data to fill the patient combo box
            DataSet dsPatient = DBConnection.getDBConnectionInstance().getDataSet(Constants.selectPatientName);

            //get the table to be displayed from the data set
            DataTable dtPatient = dsPatient.Tables[0];

            for (int i = 0; i < dtPatient.Rows.Count; i++)
            {
                patientCombox.Items.Add(dtPatient.Rows[i]["patientName"]);
            }

            //get data to fill the staff combo box
            DataSet dsStaff = DBConnection.getDBConnectionInstance().getDataSet(Constants.selectStaff);

            //get the table to be displayed from the data set
            DataTable dtStaff = dsStaff.Tables[0];

            for (int i = 0; i < dtStaff.Rows.Count; i++)
            {
                staffComboBox.Items.Add(dtStaff.Rows[i]["staffName"]);
            }

            //fill the time combo box
            for (int i = 8; i <= 24; i++)
            {
                if (i < 10)
                {
                    timeComboBox.Items.Add("0" + i + ":00");
                }
                else
                {
                    timeComboBox.Items.Add(i + ":00");
                }
            }

            StaffName   = AppointmentUserControl.ReturnStaffValue();
            PatientName = AppointmentUserControl.ReturnPatientValue();

            //make the selected combo box item be on the right staff and patient from the previous user control
            staffComboBox.Text = StaffName;
            patientCombox.Text = PatientName;
        }
        /// <summary>
        /// Edit appointment load method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditAppoinUserControl_Load(object sender, EventArgs e)
        {
            //fills the combo boxes with data from the database
            FillComboBoxes();

            //get the appointment id
            string appointmentID = AppointmentUserControl.ReturnAppointmentValue();

            AppointID = AppointmentUserControl.ReturnAppointmentValue();



            //debug purposes
            Console.WriteLine("id is" + appointmentID);
            DataSet dsAppointment = DBConnection.getDBConnectionInstance().getDataSet(Constants.SelectAppointment(appointmentID));

            //get the table to be displayed from the data set
            DataTable dtAppointment = dsAppointment.Tables[0];
        }
        private void prescriptionBtn()

        {
            FocusTestPrint_Btn(false);
            FocusRepetePrescription_Btn(true);


            if (@id != null)
            {
                try
                {
                    DataSet   dsPatient = DBConnection.getDBConnectionInstance().getDataSet(Constants.SelectPrescriptions(@id));
                    DataTable dtPatient = dsPatient.Tables[0];
                    dataGridView1.DataSource = dtPatient;

                    if (dataGridView1 != null)
                    {
                        FocusRepetePrescription_Btn(true);
                    }
                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                }
            }
            else if (@id == null)
            {
                try
                {
                    string dgCell = Convert.ToString(dataGridView1.CurrentRow.Cells[0].Value);

                    @id = dgCell;

                    prescriptionBtn();
                }
                catch (Exception ex)
                {
                }
            }
        }
        private void PatientUserControl_Load(object sender, EventArgs e)
        {
            FocusTestPrint_Btn(false);
            FocusRepetePrescription_Btn(false);

            findInputTxtBox.Text = "";
            @id = null;



            // TODO: This line of code loads data into the 'oversurgeryDataSet.userdata' table. You can move, or remove it, as needed.
            this.userdataTableAdapter.Fill(this.oversurgeryDataSet.userdata);

            DataSet dsPatient = DBConnection.getDBConnectionInstance().getDataSet(Constants.selectPatient);

            //get the table to be displayed from the data set
            DataTable dtPatient = dsPatient.Tables[0];

            //set the data source for the data grid view
            dataGridView1.DataSource = dtPatient;
        }
        //Button Methods


        /// <summary>
        /// Method that cancels/deletes a selected appointment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            Logger.Instance.Log("AppointmentUserControl:btnCancel_Click() -> Canceling an appointment.");

            //check to see if an appointment is seleted
            if (valueNotSelected == true)
            {
                MessageBox.Show("Please select the appointment you want to cancel.");
            }
            else
            {
                try
                {
                    //warning message to prevent the user from deleting an appointment by mistake.
                    DialogResult dr = MessageBox.Show("Do you really want to delete this appointment?",
                                                      "Warning", MessageBoxButtons.YesNo);
                    switch (dr)
                    {
                    case DialogResult.Yes:
                        //try to delete appointment
                        DBConnection.getDBConnectionInstance().SqlStatementExecute(Constants.DeleteAppointment(AppointmentID));
                        //try to delete the shift related to the same appointment
                        DBConnection.getDBConnectionInstance().SqlStatementExecute(Constants.DeleteShift(AppointmentID));
                        MessageBox.Show("Appointment deleted successfully!");

                        break;

                    case DialogResult.No:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemple #15
0
        /// <summary>
        /// Method that fill the combo boxes with the correct data from the database
        /// </summary>
        private void FillComboBoxes()
        {
            //get data to fill the patient combo box
            DataSet dsPatient = DBConnection.getDBConnectionInstance().getDataSet(Constants.selectPatientName);

            //get the table to be displayed from the data set
            DataTable dtPatient = dsPatient.Tables[0];

            for (int i = 0; i < dtPatient.Rows.Count; i++)
            {
                patientCombox.Items.Add(dtPatient.Rows[i]["patientName"]);
            }

            //get data to fill the staff combo box
            DataSet dsStaff = DBConnection.getDBConnectionInstance().getDataSet(Constants.selectStaff);

            //get the table to be displayed from the data set
            DataTable dtStaff = dsStaff.Tables[0];

            for (int i = 0; i < dtStaff.Rows.Count; i++)
            {
                staffComboBox.Items.Add(dtStaff.Rows[i]["staffName"]);
            }

            //fill the time combo box
            for (int i = 8; i <= 24; i++)
            {
                if (i < 10)
                {
                    timeComboBox.Items.Add("0" + i + ":00");
                }
                else
                {
                    timeComboBox.Items.Add(i + ":00");
                }
            }
        }
        private void printDocument2_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            string sqlNameReply = DBConnection.getDBConnectionInstance().GetStringValue(Constants.NameReply(id));


            Bitmap bm = new Bitmap(this.dataGridView1.Width, this.dataGridView1.Height);

            dataGridView1.DrawToBitmap(bm, new Rectangle(0, 0, this.dataGridView1.Width, this.dataGridView1.Height));

            String drawString = sqlNameReply;

            // Create font and brush.
            Font       drawFont  = new Font("Arial", 20);
            SolidBrush drawBrush = new SolidBrush(Color.Black);

            // Create point for upper-left corner of drawing.
            PointF drawPoint = new PointF(90.0F, 100.0F);

            // Draw string to screen.
            e.Graphics.DrawString(drawString, drawFont, drawBrush, drawPoint);


            e.Graphics.DrawImage(bm, 35, 200);
        }
        private void RePrescriptionBtn(object sender, EventArgs e)
        {
            if (id != null)
            {
                DateTime currentDateTime = DateTime.Now;
                int      restrictionDays;
                int      NumberOfDaysFromInitialPrescription;

                try
                {
                    string prescription_id         = Convert.ToString(dataGridView1.CurrentRow.Cells[0].Value);
                    string re_prescription_status  = Convert.ToString(dataGridView1.CurrentRow.Cells[5].Value);
                    string sqlReplyDate            = DBConnection.getDBConnectionInstance().GetStringValue(Constants.PrescriptionDateReply(prescription_id));
                    string sqlReplyRestrictionDays = DBConnection.getDBConnectionInstance().GetStringValue(Constants.PrescriptionDaysReply(prescription_id));

                    DateTime queryDate = Convert.ToDateTime(sqlReplyDate);
                    Int32.TryParse(sqlReplyRestrictionDays, out restrictionDays);
                    TimeSpan ts = currentDateTime - queryDate;

                    NumberOfDaysFromInitialPrescription = ts.Days;
                    if (NumberOfDaysFromInitialPrescription >= restrictionDays && re_prescription_status == "NO")
                    {
                        var result = MessageBox.Show("This patient is permitted for Re-Prescription. Are you sure you want to extend the selected Prescription for selected Patient?", "Re-Prescription Form", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            string formatted_date = currentDateTime.ToString("yyyy/MM/dd HH:mm");


                            string prescription_medicat     = Convert.ToString(dataGridView1.CurrentRow.Cells[2].Value);
                            string prescription_course_days = Convert.ToString(dataGridView1.CurrentRow.Cells[3].Value);
                            string rePrescription_day_limit = Convert.ToString(dataGridView1.CurrentRow.Cells[4].Value);


                            try
                            {
                                DBConnection.getDBConnectionInstance().SqlStatementExecute(Constants.RePrescriptions(@id, formatted_date, prescription_medicat, prescription_course_days, rePrescription_day_limit));
                                DBConnection.getDBConnectionInstance().SqlStatementExecute(Constants.ChangeRePrescriptionStatus(prescription_id));
                                MessageBox.Show("Complete");
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Exeption Error Occoured");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Re-Prescription Cancelled");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Re-Prescription Denied.");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("No selected Patient");
                }
            }
            else
            {
                MessageBox.Show(@id);
            }
        }
Exemple #18
0
        //Button Related Methods

        /// <summary>
        /// Method that tries to book an appointment
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bookBtn_Click(object sender, EventArgs e)
        {
            try
            {
                //get all the user input from the combo boxes
                string patientInput = patientCombox.Text;
                string staffInput   = staffComboBox.Text;
                string timeInput    = timeComboBox.Text + ":00";

                string date = dateTimePicker1.Text;

                string description = descriptionTxt.Text;

                //check if all the combo boxes have values selected and then run the code
                if (patientCombox.Text != String.Empty && staffComboBox.Text != String.Empty && timeComboBox.Text != String.Empty)
                {
                    //Add this appointment as a shift to a staff member
                    //get the staff id based on the name selected by the user in the combo box
                    string str = DBConnection.getDBConnectionInstance().GetStringValue(Constants.GetStaffID(staffInput));


                    int staffID = Convert.ToInt32(str);

                    //check too see if the staff member is already busy
                    int i = 0;

                    Logger.Instance.Log("BookAppointUserControl:bookBtn_Click() -> Booking an appointment.");


                    try
                    {
                        i = DBConnection.getDBConnectionInstance().CheckStaffBusy(staffID, date, timeInput);

                        if (i != 0)
                        {
                            MessageBox.Show("The staff member selected is already busy in that time period.");
                        }
                        else
                        {
                            //Try to register patient by getting the data from the user input textboxes
                            DBConnection.getDBConnectionInstance().SqlStatementExecute(Constants.BookAppointment(date, timeInput, staffInput, patientInput, description, staffID));


                            Console.WriteLine(date + " " + timeInput + " " + AddHourTime(timeInput) + " " + staffID);

                            //Need to get the id from the appointment created
                            string appointID = DBConnection.getDBConnectionInstance().GetStringValue(Constants.GetAppointmentNoID(date, timeInput, staffInput, patientInput, description, staffID));

                            //insert appointment as a shift in the shift table for a specific member of staff
                            DBConnection.getDBConnectionInstance().SqlStatementExecute(Constants.AddShift(date, timeInput, AddHourTime(timeInput), staffID, appointID));

                            //Show success message and close form
                            MessageBox.Show("Booking was successfull!");

                            AppointmentUserControl.RemoveBook();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                //warning for the user to select a staff
                else if (string.IsNullOrEmpty(staffComboBox.Text))
                {
                    MessageBox.Show("Please select a staff member.");
                }
                //warning for the user to select a time
                else if (string.IsNullOrEmpty(timeComboBox.Text))
                {
                    MessageBox.Show("Please select a time period.");
                }
                //warning for the user to select a patient
                else if (string.IsNullOrEmpty(patientCombox.Text))
                {
                    MessageBox.Show("Please select a patient.");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Method that load the list view with the staff shifts data.
        /// </summary>
        /// <param name="staffID"></param>
        private void AddShiftToListView(string staffID)
        {
            Logger.Instance.Log("StaffUserControlUserControl:AddShiftToListView() -> Adding shifts to the list view.");


            string date = dateTimePicker1.Text;

            DataSet dsStaffAvail = DBConnection.getDBConnectionInstance().getDataSet(Constants.SelectShiftQuery(date));

            //get the table to be displayed from the data set
            DataTable dtStaffAvail = dsStaffAvail.Tables[0];

            //find out how many shifts a member of staff has in that specific day
            int shiftAmount = DBConnection.getDBConnectionInstance().GetIntValue(Constants.Countshifts(date));

            Console.WriteLine("Shift Amount=" + shiftAmount);

            //debug
            Console.WriteLine("Passed Value:" + staffID);
            for (int i = 0; i < shiftAmount; i++)
            {
                Console.WriteLine("Value from the datatable:" + (dtStaffAvail.Rows[i]["Staff ID"].ToString()));
                if ((dtStaffAvail.Rows[i]["Staff ID"].ToString()) == staffID)
                {
                    //change the subitems value to change the staff member

                    string value = (dtStaffAvail.Rows[i]["From"].ToString());
                    Console.WriteLine("Row value=" + value);
                    int staffInt = Convert.ToInt32(staffID);

                    switch (value)
                    {
                    case "08:00:00":
                        listView1.Items[0].SubItems[staffInt].Text      = "Working";
                        listView1.Items[0].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "09:00:00":
                        listView1.Items[1].SubItems[staffInt].Text      = "Working";
                        listView1.Items[1].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "10:00:00":
                        listView1.Items[2].SubItems[staffInt].Text      = "Working";
                        listView1.Items[2].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "11:00:00":
                        listView1.Items[3].SubItems[staffInt].Text      = "Working";
                        listView1.Items[3].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "12:00:00":
                        listView1.Items[4].SubItems[staffInt].Text      = "Working";
                        listView1.Items[4].SubItems[staffInt].ForeColor = Color.Green;
                        break;

                    case "13:00:00":
                        listView1.Items[5].SubItems[staffInt].Text      = "Working";
                        listView1.Items[5].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "14:00:00":
                        listView1.Items[6].SubItems[staffInt].Text      = "Working";
                        listView1.Items[6].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "15:00:00":
                        listView1.Items[7].SubItems[staffInt].Text      = "Working";
                        listView1.Items[7].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "16:00:00":
                        listView1.Items[8].SubItems[staffInt].Text      = "Working";
                        listView1.Items[8].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "17:00:00":
                        listView1.Items[9].SubItems[staffInt].Text      = "Working";
                        listView1.Items[9].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "18:00:00":
                        listView1.Items[10].SubItems[staffInt].Text      = "Working";
                        listView1.Items[10].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "19:00:00":
                        listView1.Items[11].SubItems[staffInt].Text      = "Working";
                        listView1.Items[11].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "20:00:00":
                        listView1.Items[12].SubItems[staffInt].Text      = "Working";
                        listView1.Items[12].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "21:00:00":
                        listView1.Items[13].SubItems[staffInt].Text      = "Working";
                        listView1.Items[13].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "22:00:00":
                        listView1.Items[14].SubItems[staffInt].Text      = "Working";
                        listView1.Items[14].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    case "23:00:00":
                        listView1.Items[15].SubItems[staffInt].Text      = "Working";
                        listView1.Items[15].SubItems[staffInt].ForeColor = Color.Green;

                        break;

                    default:
                        Console.WriteLine("No time found");
                        break;
                    }
                }
            }
        }