private bool checkStaffTodaySchedule(Staff staff)
        {
            string date = DateTimeManager.convertDate(DpScheduleDate.Date.ToString());

            MySqlConnectionStringBuilder builder = DBConnection.Connect();

            MySqlConnection conn = new MySqlConnection(builder.ToString());
            String          qry  = $"SELECT * FROM staff_schedule WHERE StaffID='{staff.staffID}' " +
                                   $"AND Date='{date}';";
            MySqlCommand cmd = new MySqlCommand(qry, conn);

            conn.Open();

            MySqlDataReader reader = cmd.ExecuteReader();

            int counter = 0;

            while (reader.Read())
            {
                counter++;
            }

            conn.Close();

            if (counter > 0)
            {
                PanelError2.Visibility = Visibility.Visible;
                TxtErrorMessage2.Text  = "This staff member already has a shift on the selected date.";
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#2
0
        private void BtnModify_Click(object sender, RoutedEventArgs e)
        {
            Appointment appointment = (Appointment)ListViewAppointment.SelectedItem;

            if (fieldsAreValid())
            {
                appointment.name    = TxtName.Text;
                appointment.surname = TxtName.Text;
                appointment.date    = DateTimeManager.convertDate(DatePickerAddAppt.Date.ToString());
                appointment.time    = TimePickerAddAppt.Time.ToString();
                appointment.contact = TxtName.Text;
                appointment.type    = TxtName.Text;
                appointment.notes   = TxtNotes.Text;

                if ((bool)RadioBurn.IsChecked)
                {
                    appointment.type = "Burn";
                }
                if ((bool)RadioUlcer.IsChecked)
                {
                    appointment.type = "Chronic Ulcer";
                }
                if ((bool)RadioDiabeticFoot.IsChecked)
                {
                    appointment.type = "Diabetic Foot";
                }

                modifyAppointment(appointment);
            }
        }
示例#3
0
        private void getSelectedDateAppointments()
        {
            //clear list
            appointmentList.Clear();
            //Get date selection
            string selectedDate;

            if (CalUpcomingAppt.SelectedDates.Count == 1)
            {
                selectedDate = CalUpcomingAppt.SelectedDates[0].ToString();
            }
            else
            {
                selectedDate = DateTime.Now.ToString();
            }

            selectedDate = selectedDate.Substring(0, 10);

            retrieveAppointmentsFromDB(DateTimeManager.convertDate(selectedDate));

            NextApptPanel.Visibility       = Visibility.Collapsed;
            GridNoApptSelection.Visibility = Visibility.Visible;

            refreshPanelsForAppointments();
        }
        private void BtnModifyThisSchedule_Click(object sender, RoutedEventArgs e)
        {
            if (validateSchedule())
            {
                ScheduleItem item = (ScheduleItem)ListViewSchedule.SelectedItem;

                Staff staff = (Staff)CmbChooseStaff.SelectedItem;

                item.staffID   = staff.staffID;
                item.date      = DateTimeManager.convertDate(DpScheduleDate.Date.ToString());
                item.startTime = TPStart.Time.ToString();
                item.endTime   = TPEnd.Time.ToString();

                modifySchedule(item);

                PanelAddModifySchedule.Visibility = Visibility.Collapsed;
                RightOverlay.Visibility           = Visibility.Collapsed;

                getSchedule(item.date);

                if (ListViewSchedule.SelectedItem == null)
                {
                    BtnModifySchedule.IsEnabled = false;
                    BtnRemoveSchedule.IsEnabled = false;
                }
            }
        }
示例#5
0
        //Add this Appointment
        private void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (fieldsAreValid())
            {
                string appointmentID = IDManager.getNextAppointmentID();
                string name          = TxtName.Text;
                string surname       = TxtSurname.Text;
                string date          = DateTimeManager.convertDate(DatePickerAddAppt.Date.ToString());
                string time          = TimePickerAddAppt.Time.ToString();
                string contact       = TxtContact.Text;
                string notes         = TxtNotes.Text;
                string type          = "";
                string patientId     = TxtID.Text;

                if (patientId.Equals("Select patient from list"))
                {
                    patientId = "";
                }

                time = time.Substring(0, 5);

                if ((bool)RadioBurn.IsChecked)
                {
                    type = "Burn";
                }
                if ((bool)RadioUlcer.IsChecked)
                {
                    type = "Chronic Ulcer";
                }
                if ((bool)RadioDiabeticFoot.IsChecked)
                {
                    type = "Diabetic Foot";
                }

                Appointment newAppointment = new Appointment(appointmentID, name, surname, contact, date, time, type, notes, patientId);

                addAppointment(newAppointment);

                if (!patientId.Equals(""))
                {
                    addPatientAppt(patientId, appointmentID);
                }

                clearFormValues();

                // Dialog
                PanelDialog.Visibility = Visibility.Visible;
                TxtDialogMessage.Text  = "Appointment has been added";
                Overlay.Visibility     = Visibility.Visible;

                getSelectedDateAppointments();

                PanelAddAppointment.Visibility = Visibility.Collapsed;
                MainPanel.Visibility           = Visibility.Visible;

                refreshPanelsForAppointments();
            }
        }
        private void CalSchedule_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
        {
            if (sender.SelectedDates.Count == 1)
            {
                string selectedDate = CalSchedule.SelectedDates[0].ToString();
                selectedDate = selectedDate.Substring(0, 10);

                getSchedule(DateTimeManager.convertDate(selectedDate));
            }
        }
示例#7
0
        private void BtnModifyPatient_Click(object sender, RoutedEventArgs e)
        {
            ListViewPatient.IsEnabled = false;
            BtnAddPatient.IsEnabled   = false;
            TxtSearch.IsEnabled       = false;

            Patient pat = (Patient)ListViewPatient.SelectedItem;

            if (validatePatient())
            {
                pat.title       = CmbTitle.SelectedValue.ToString();
                pat.name        = TxtPatientName.Text;
                pat.surname     = TxtPatientSurname.Text;
                pat.dateOfBirth = DateTimeManager.convertDate(DpPatientDOB.Date.ToString());

                if ((bool)RadioSexM.IsChecked)
                {
                    pat.sex = "Male";
                }
                if ((bool)RadioSexF.IsChecked)
                {
                    pat.sex = "Female";
                }

                pat.address    = TxtPatientAddress.Text;
                pat.contact    = TxtPatientContact.Text;
                pat.email      = TxtPatientEmail.Text;
                pat.occupation = TxtPatientOccupation.Text;

                modifyPatient(pat);

                clearFormValues();

                // Dialog
                PanelDialog.Visibility = Visibility.Visible;
                TxtDialogMessage.Text  = "Patient has been modified";
                Overlay.Visibility     = Visibility.Visible;

                DetailsPanel.Visibility            = Visibility.Collapsed;
                AddPanel.Visibility                = Visibility.Collapsed;
                NoSelectionPanel.Visibility        = Visibility.Visible;
                BtnCancelPatientDetails.Visibility = Visibility.Visible;
                BtnViewArchived.IsEnabled          = true;

                ListViewPatient.IsEnabled = true;
                BtnAddPatient.IsEnabled   = true;
                TxtSearch.IsEnabled       = true;

                LblMainTitle.Text = "Patients";
            }
        }
        private Staff createStaff()
        {
            string sex      = "";
            string password = "";
            string rights   = "";

            string date = DateTimeManager.convertDate(DpStaffDOB.Date.ToString());

            if ((bool)RadioSexM.IsChecked)
            {
                sex = "Male";
            }
            if ((bool)RadioSexF.IsChecked)
            {
                sex = "Female";
            }

            if (TxtPassword.Password.Equals(""))
            {
                password = "******";
            }
            else
            {
                password = TxtPassword.Password;
            }

            if (CmbRights.SelectedIndex == -1)
            {
                rights = "none";
            }
            else
            {
                rights = CmbRights.SelectedValue.ToString();
            }


            Staff staff = new Staff(IDManager.getNextStaffID(), CmbStatus.SelectedValue.ToString(),
                                    CmbTitle.SelectedValue.ToString(), TxtName.Text, TxtSurname.Text, date, sex,
                                    TxtAddress.Text, TxtContact.Text, TxtRate.Text, TxtEmail.Text,
                                    CmbOccurrence.SelectedValue.ToString(), password,
                                    rights);

            return(staff);
        }
示例#9
0
        // CREATE PATIENT
        private Patient createPatient()
        {
            string sex  = "";
            string date = DateTimeManager.convertDate(DpPatientDOB.Date.ToString());

            if ((bool)RadioSexM.IsChecked)
            {
                sex = "Male";
            }
            if ((bool)RadioSexF.IsChecked)
            {
                sex = "Female";
            }

            Patient pat = new Patient(IDManager.getNextPatientID(), CmbTitle.SelectedValue.ToString(),
                                      TxtPatientName.Text, TxtPatientSurname.Text, date, sex, TxtPatientAddress.Text,
                                      TxtPatientContact.Text, TxtPatientEmail.Text, TxtPatientOccupation.Text);

            return(pat);
        }
        private void BtnAddThisSchedule_Click(object sender, RoutedEventArgs e)
        {
            if (validateSchedule())
            {
                Staff  staff = (Staff)CmbChooseStaff.SelectedItem;
                string date  = DateTimeManager.convertDate(DpScheduleDate.Date.ToString());

                string startTime = TPStart.Time.ToString();
                string endTime   = TPEnd.Time.ToString();

                if (startTime.Length > 5)
                {
                    startTime = startTime.Substring(0, 5);
                }

                if (endTime.Length > 5)
                {
                    endTime = endTime.Substring(0, 5);
                }

                if (checkStaffTodaySchedule(staff))
                {
                    ScheduleItem item = new ScheduleItem(IDManager.getNextScheduleID(), date,
                                                         startTime, endTime, staff.staffID, staff.name, staff.surname, staff.contact);

                    addSchedule(item);
                    scheduleList.Add(item);

                    PanelAddModifySchedule.Visibility = Visibility.Collapsed;
                    RightOverlay.Visibility           = Visibility.Collapsed;

                    clearScheduleValues();

                    PanelDialog.Visibility = Visibility.Visible;
                    TxtDialogMessage.Text  = "Staff has been added to the schedule.";

                    NoScheduleSelection.Visibility = Visibility.Collapsed;
                    ListViewSchedule.Visibility    = Visibility.Visible;
                }
            }
        }
        private void BtnModifyThisStaff_Click(object sender, RoutedEventArgs e)
        {
            Staff staff = (Staff)ListViewStaff.SelectedItem;

            if (validateFields())
            {
                staff.status  = CmbStatus.SelectedValue.ToString();
                staff.title   = CmbTitle.SelectedValue.ToString();
                staff.name    = TxtName.Text;
                staff.surname = TxtSurname.Text;
                staff.dob     = DateTimeManager.convertDate(DpStaffDOB.Date.ToString());

                if ((bool)RadioSexM.IsChecked)
                {
                    staff.sex = "Male";
                }
                if ((bool)RadioSexF.IsChecked)
                {
                    staff.sex = "Female";
                }

                if (TxtPassword.Password.Equals(""))
                {
                    staff.password = "******";
                }
                else
                {
                    staff.password = TxtPassword.Password;
                }

                if (CmbRights.SelectedIndex == -1)
                {
                    staff.rights = "none";
                }
                else
                {
                    staff.rights = CmbRights.SelectedValue.ToString();
                }

                staff.address   = TxtAddress.Text;
                staff.contact   = TxtContact.Text;
                staff.email     = TxtEmail.Text;
                staff.rate      = TxtRate.Text;
                staff.occurence = CmbOccurrence.SelectedValue.ToString();
                staff.password  = TxtPassword.Password;

                modifyStaff(staff);

                clearFormValues();

                PanelDialog.Visibility = Visibility.Visible;
                TxtDialogMessage.Text  = "Staff has been modified.";
                Overlay.Visibility     = Visibility.Visible;

                PanelDetails.Visibility     = Visibility.Collapsed;
                PanelAddModify.Visibility   = Visibility.Collapsed;
                NoSelectionPanel.Visibility = Visibility.Visible;
                BtnCancel.Visibility        = Visibility.Visible;

                ListViewStaff.IsEnabled = true;
                BtnAdd.IsEnabled        = true;
                TxtSearch.IsEnabled     = true;

                LblTitle.Text = "Staff";
            }
        }