Example #1
0
        private void appointBtn_Click(object sender, EventArgs e)
        {
            //put the sidescroll panel in the correct place, selection
            SidePanelScroll.Height = appointBtn.Height;
            SidePanelScroll.Top = appointBtn.Top;

            //removes "booking appointment" and edit appointment if it is present in the panel.
            AppointmentUserControl.RemoveBook();

            if (!userControlPanel.Controls.Contains(AppointmentUserControl.Instance))
            {
                userControlPanel.Controls.Add(AppointmentUserControl.Instance);
                AppointmentUserControl.Instance.Dock = DockStyle.Fill;
                AppointmentUserControl.Instance.BringToFront();
            }
            else
                AppointmentUserControl.Instance.BringToFront();
        }
Example #2
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);
            }
        }