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 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();
        }
Пример #3
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);
            }
        }
        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
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter is Appointment)
            {
                thisAppointment  = (Appointment)e.Parameter;
                LblName.Text     = thisAppointment.name + " " + thisAppointment.surname;
                LblDateTime.Text = DateTimeManager.DateToShort(thisAppointment.date) + " | " + thisAppointment.time;
            }
        }
        private void BtnModify_Click(object sender, RoutedEventArgs e)
        {
            LblTitle.Text = "Modify Staff";

            string password = "";

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

            BtnAddThisStaff.Visibility    = Visibility.Collapsed;
            BtnModifyThisStaff.Visibility = Visibility.Visible;

            Staff staff = (Staff)ListViewStaff.SelectedItem;

            CmbStatus.SelectedValue = staff.status;
            CmbTitle.SelectedValue  = staff.title;
            TxtName.Text            = staff.name;
            TxtSurname.Text         = staff.surname;

            DpStaffDOB.Date = DateTimeManager.convertToDate(staff.dob);

            if (staff.sex.Equals("Male"))
            {
                RadioSexM.IsChecked = true;
            }
            else
            {
                RadioSexF.IsChecked = true;
            }

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

            TxtAddress.Text             = staff.address;
            TxtContact.Text             = staff.contact;
            TxtEmail.Text               = staff.email;
            TxtRate.Text                = staff.rate;
            CmbOccurrence.SelectedValue = staff.occurence;
            TxtPassword.Password        = password;
            CmbRights.SelectedValue     = staff.rights;

            ListViewStaff.IsEnabled = false;
            BtnAdd.IsEnabled        = false;
            TxtSearch.IsEnabled     = false;
        }
Пример #9
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";
            }
        }
Пример #10
0
        private void BtnModifyAppointment_Click(object sender, RoutedEventArgs e)
        {
            LblAddModifyTitle.Text = "Modify Appointment";

            Appointment appointment = (Appointment)ListViewAppointment.SelectedItem;

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

            BtnChoosePatient.Visibility = Visibility.Collapsed;
            BtnCancelSelect.Visibility  = Visibility.Collapsed;

            TxtName.Text    = appointment.name;
            TxtSurname.Text = appointment.surname;

            DatePickerAddAppt.Date = DateTimeManager.convertToDate(appointment.date);
            TimePickerAddAppt.Time = TimeSpan.Parse(appointment.time);

            TxtContact.Text = appointment.contact;
            TxtNotes.Text   = appointment.notes;

            if (appointment.patientId == "0")
            {
                TxtID.Text = "";
            }
            else
            {
                TxtID.Text = appointment.patientId;
            }

            string type = appointment.type;

            if (type.Equals("Burn"))
            {
                RadioBurn.IsChecked = true;
            }
            else if (type.Equals("Chronic Ulcer"))
            {
                RadioUlcer.IsChecked = true;
            }
            else if (type.Equals("Diabetic Foot"))
            {
                RadioDiabeticFoot.IsChecked = true;
            }
        }
Пример #11
0
        private void showAppointment(Appointment appt)
        {
            BtnDeleteAppt.Tag = appt;

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

            LblName.Text        = appt.name + " " + appt.surname;
            LblDate.Text        = DateTimeManager.DateToShort(appt.date);
            LblTime.Text        = appt.time;
            LblContactText.Text = appt.contact;
            LblNoteText.Text    = appt.notes;

            string patientId = appt.patientId;

            if (apptIsExisitingPatient(patientId))
            {
                if (visitExists(patientId, appt.date, appt.time))
                {
                    BtnNewVisit.Visibility          = Visibility.Collapsed;
                    BtnViewVisit.Visibility         = Visibility.Visible;
                    BtnDeleteAppt.Visibility        = Visibility.Collapsed;
                    BtnModifyAppointment.Visibility = Visibility.Collapsed;
                }
                else
                {
                    BtnDeleteAppt.Visibility        = Visibility.Visible;
                    BtnModifyAppointment.Visibility = Visibility.Visible;
                    BtnNewVisit.Visibility          = Visibility.Visible;
                    BtnViewVisit.Visibility         = Visibility.Collapsed;
                }
                patientId = " - " + patientId;
            }
            else
            {
                patientId = "";
                BtnViewVisit.Visibility         = Visibility.Collapsed;
                BtnDeleteAppt.Visibility        = Visibility.Visible;
                BtnModifyAppointment.Visibility = Visibility.Visible;
            }

            LblPatientID.Text = patientId;

            BtnNewVisit.Tag = appt;
        }
        // BUTTONS

        private void ListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            PanelDetails.Visibility     = Visibility.Visible;
            NoSelectionPanel.Visibility = Visibility.Collapsed;

            Staff staff = (Staff)e.ClickedItem;

            LblID.Text      = staff.staffID;
            LblName.Text    = staff.title + ". " + staff.name + " " + staff.surname;
            LblDob.Text     = DateTimeManager.DateToShortYear(staff.dob);
            LblAddress.Text = staff.address;
            LblEmail.Text   = staff.email;
            LblRate.Text    = "Rs" + staff.rate + " " + staff.occurence;
            LblSex.Text     = staff.sex;
            LblStatus.Text  = staff.status;
            LblContact.Text = staff.contact;
            LblRights.Text  = staff.rights;
        }
        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);
        }
Пример #14
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;
                }
            }
        }
Пример #16
0
        // PATIENT LIST SELECT
        private void ListViewPatient_ItemClick(object sender, ItemClickEventArgs e)
        {
            DetailsPanel.Visibility     = Visibility.Visible;
            AddPanel.Visibility         = Visibility.Collapsed;
            NoSelectionPanel.Visibility = Visibility.Collapsed;

            Patient patient = (Patient)e.ClickedItem;

            getVisitList(patient);

            LblPatientName.Text  = patient.name + " " + patient.surname;
            LblPatientID.Text    = patient.patientId;
            LblPatientTitle.Text = patient.title;
            LblDOB.Text          = DateTimeManager.DateToShortYear(patient.dateOfBirth);

            LblSex.Text               = patient.sex;
            LblPatientAddress.Text    = patient.address;
            LblPatientContact.Text    = patient.contact;
            LblPatientEmail.Text      = patient.email;
            LblPatientOccupation.Text = patient.occupation;
        }
        // GET MAIN VISIT INFO
        private void getVisitDetails(PatientVisit visit)
        {
            MySqlConnectionStringBuilder builder = DBConnection.Connect();

            MySqlConnection conn = new MySqlConnection(builder.ToString());
            String          qry  = "SELECT patient_visits.*, patients.Name, patients.Surname FROM patient_visits " +
                                   "JOIN patients ON patient_visits.PatientID = patients.PatientID " +
                                   "WHERE patient_visits.PatientVisitID = '" + visit.id + "'; ";
            MySqlCommand cmd = new MySqlCommand(qry, conn);

            conn.Open();

            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                string id            = reader["PatientVisitID"].ToString();
                string pId           = reader["PatientID"].ToString();
                string notes         = reader["Notes"].ToString();
                string date          = reader["Date"].ToString();
                string time          = reader["Time"].ToString();
                string incomeId      = reader["IncomeID"].ToString();
                string afterOpening  = reader["AfterOpening"].ToString();
                string actions       = reader["ActionsPerformed"].ToString();
                string beforeClosing = reader["BeforeClosing"].ToString();
                string name          = reader["Name"].ToString();
                string surname       = reader["Surname"].ToString();
                string type          = reader["Type"].ToString();

                LblName.Text     = name + " " + surname;
                LblDateTime.Text = date + " " + time;
                LblDateTime.Text = DateTimeManager.DateToShort(date) + " | " + time;

                LblAfterOpeningText.Text  = afterOpening;
                LblActionsTakenText.Text  = actions;
                LblBeforeClosingText.Text = beforeClosing;
                LblNotesText.Text         = notes;
            }
        }
Пример #18
0
        private void BtnModify_Click(object sender, RoutedEventArgs e)
        {
            LblMainTitle.Text = "Modify Patient";

            DetailsPanel.Visibility = Visibility.Collapsed;
            AddPanel.Visibility     = Visibility.Visible;

            BtnModifyPatient.Visibility = Visibility.Visible;
            BtnAdd.Visibility           = Visibility.Collapsed;

            BtnCancelPatientDetails.Visibility = Visibility.Collapsed;

            ListViewPatient.IsEnabled = false;
            BtnAddPatient.IsEnabled   = false;
            TxtSearch.IsEnabled       = false;
            BtnViewArchived.IsEnabled = false;

            Patient pat = (Patient)ListViewPatient.SelectedItem;

            CmbTitle.SelectedValue = pat.title;
            TxtPatientSurname.Text = pat.surname;
            TxtPatientName.Text    = pat.name;

            DpPatientDOB.Date = DateTimeManager.convertToDate(pat.dateOfBirth);

            if (pat.sex.Equals("Male"))
            {
                RadioSexM.IsChecked = true;
            }
            else
            {
                RadioSexF.IsChecked = true;
            }

            TxtPatientAddress.Text    = pat.address;
            TxtPatientContact.Text    = pat.contact;
            TxtPatientEmail.Text      = pat.email;
            TxtPatientOccupation.Text = pat.occupation;
        }
        // MODIFY SCHEDULE

        private void BtnModifySchedule_Click(object sender, RoutedEventArgs e)
        {
            PanelAddModifySchedule.Visibility = Visibility.Visible;
            BtnAddThisSchedule.Visibility     = Visibility.Collapsed;
            BtnModifyThisSchedule.Visibility  = Visibility.Visible;
            RightOverlay.Visibility           = Visibility.Visible;

            ScheduleItem item = (ScheduleItem)ListViewSchedule.SelectedItem;

            DpScheduleDate.Date = DateTimeManager.convertToDate(item.date);
            TPStart.Time        = TimeSpan.Parse(item.startTime);
            TPEnd.Time          = TimeSpan.Parse(item.endTime);

            Staff selectedStaff = null;

            foreach (var staff in staffList)
            {
                if (staff.staffID.Equals(item.staffID))
                {
                    selectedStaff = staff;
                }
            }
            CmbChooseStaff.SelectedItem = selectedStaff;
        }
        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";
            }
        }