Example #1
0
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created On: 2020/03/10
        /// Approved By:  Awaab Elamin ,2020/03/13
        ///
        /// This is a click event when send email button is clicked. It will send an email
        /// to the adoption application customer.
        /// </summary>
        ///
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSendEmai_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AdoptionAppointmentVM selectedApplication =
                    (AdoptionAppointmentVM)dgAppointments.SelectedItem;
                if (selectedApplication == null)
                {
                    MessageBox.Show("Please select an application to notify the customer by email");
                    return;
                }

                var customerEmail =
                    _homeInspectorManager.
                    GetCustomerEmailByAdoptionApplicationID(selectedApplication.AdoptionApplicationID);

                MailMessage mail       = new MailMessage();
                SmtpClient  smtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(customerEmail);// get email address from the Database.
                mail.Subject           = "Adoption Application Status";
                mail.Body              = "Hello, your Application has been approved ";
                smtpServer.Port        = 80;
                smtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
                smtpServer.EnableSsl   = true;
                //smtpServer.Send(mail);
                MessageBox.Show("Email has been sent Successfully to " + customerEmail);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Couldn't send Email", ex.Message + "\n\n" + ex.InnerException.Message);
            }
        }
Example #2
0
        /// <summary>
        /// NAME: Austin Gee
        /// DATE: 3/3/2020
        /// CHECKED BY: Michael Thompson
        ///
        /// Helper method that is responsible for what happens after an appoinment selection is made
        /// </summary>
        /// <remarks>
        /// UPDATED BY: NA
        /// UPDATE DATE: NA
        /// WHAT WAS CHANGED: NA
        ///
        /// </remarks>
        private void selectAppointmentDetails()
        {
            showAppointmentDetails();
            AdoptionAppointmentVM adoptionAppointment = (AdoptionAppointmentVM)dgAppointments.SelectedItem;

            _adoptionAppointment = _adoptionAppointmentManager.RetrieveAdoptionAppointmentByAppointmentID(adoptionAppointment.AppointmentID);
            populateTextBoxes();
        }
Example #3
0
        /// <summary>
        /// Creator: Mohamed Elamin
        /// Created: 2020/04/08
        /// Approver: Austin Gee, 2020/04/09
        /// This is an Event on Cancel Adoption Application Button is clicked It
        /// changes the Adoption Appointment Decision to Cancel. Also the it changes the Adoption
        /// Appliction's Status to Cancel.
        /// </summary>
        /// <remarks>
        /// Updater Name
        /// Updated: yyyy/mm/dd
        /// Update: ()
        /// </remarks>
        /// <param name=" sender"></param>
        /// <param name=" e"></param>
        private void btnCancelApplaction_Click(object sender, RoutedEventArgs e)
        {
            HomeInspectorAdoptionAppointmentDecision newHomeInspectorAdoptionAppointmentDecision =
                new HomeInspectorAdoptionAppointmentDecision();
            AdoptionAppointmentVM selectedApplication = new AdoptionAppointmentVM();

            selectedApplication =
                (AdoptionAppointmentVM)dgAppointments.SelectedItem;
            if (selectedApplication == null)
            {
                MessageBox.Show("Please select an application to Cancel");
                return;
            }
            newHomeInspectorAdoptionAppointmentDecision.Decision      = "Cancel";
            newHomeInspectorAdoptionAppointmentDecision.AppointmentID = selectedApplication.AppointmentID;
            newHomeInspectorAdoptionAppointmentDecision.Notes         = selectedApplication.Notes;

            HomeInspectorAdoptionAppointmentDecision _homeInspectionAppointmentDecision =
                new HomeInspectorAdoptionAppointmentDecision();


            _homeInspectionAppointmentDecision.AppointmentID         = selectedApplication.AppointmentID;
            _homeInspectionAppointmentDecision.AdoptionApplicationID = selectedApplication.AdoptionApplicationID;
            _homeInspectionAppointmentDecision.LocationName          = selectedApplication.LocationName;
            _homeInspectionAppointmentDecision.AppointmentTypeID     = selectedApplication.AppointmentTypeID;
            _homeInspectionAppointmentDecision.DateTime   = selectedApplication.AppointmentDateTime;
            _homeInspectionAppointmentDecision.Notes      = selectedApplication.Notes;
            _homeInspectionAppointmentDecision.Decision   = selectedApplication.Decision;
            _homeInspectionAppointmentDecision.LocationID = selectedApplication.LocationID;
            _homeInspectionAppointmentDecision.Active     = selectedApplication.AppointmentActive;

            try
            {
                _inHomeInspectionAppointmentDecisionManager.EditAppointment
                    (_homeInspectionAppointmentDecision, newHomeInspectorAdoptionAppointmentDecision);

                if (_inHomeInspectionAppointmentDecisionManager.UpdateHomeInspectorDecision
                        (_homeInspectionAppointmentDecision
                        .AdoptionApplicationID, "Cancel"))
                {
                    MessageBox.Show("Adoption Application has been successfully cancelled ");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Appointment can't be Edited", ex.Message + "\n\n"
                                + ex.InnerException.Message);
            }
        }
Example #4
0
        /// <summary>
        /// NAME: Austin Gee
        /// DATE: 3/4/2020
        /// CHECKED BY: Thomas Dupuy
        ///
        /// Selects an AdoptionAppointmentVM from the database
        /// </summary>
        /// <remarks>
        /// UPDATED BY: NA
        /// UPDATE DATE: NA
        /// WHAT WAS CHANGED: NA
        ///
        /// </remarks>
        public AdoptionAppointmentVM SelectAdoptionAppointmentByAppointmentID(int appointmentID)
        {
            AdoptionAppointmentVM adoptionAppointment = new AdoptionAppointmentVM();

            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("sp_select_adoption_appointment_by_appointment_id", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@AppointmentID", appointmentID);

            try
            {
                conn.Open();

                var reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    adoptionAppointment.AppointmentID         = reader.GetInt32(0);
                    adoptionAppointment.AdoptionApplicationID = reader.GetInt32(1);
                    adoptionAppointment.AppointmentTypeID     = reader.GetString(2);
                    adoptionAppointment.AppointmentDateTime   = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4))
                    {
                        adoptionAppointment.Notes = reader.GetString(4);
                    }
                    if (!reader.IsDBNull(5))
                    {
                        adoptionAppointment.Decision = reader.GetString(5);
                    }
                    adoptionAppointment.LocationID        = reader.GetInt32(6);
                    adoptionAppointment.AppointmentActive = reader.GetBoolean(7);
                    adoptionAppointment.CustomerEmail     = reader.GetString(8);
                    adoptionAppointment.AnimalID          = reader.GetInt32(9);
                    if (!reader.IsDBNull(10))
                    {
                        adoptionAppointment.AdoptionApplicationStatus = reader.GetString(10);
                    }
                    adoptionAppointment.AdoptionApplicationRecievedDate = reader.GetDateTime(11);
                    if (!reader.IsDBNull(12))
                    {
                        adoptionAppointment.LocationName = reader.GetString(12);
                    }
                    adoptionAppointment.LocationAddress1 = reader.GetString(13);
                    if (!reader.IsDBNull(14))
                    {
                        adoptionAppointment.LocationAddress2 = reader.GetString(14);
                    }
                    adoptionAppointment.LocationCity  = reader.GetString(15);
                    adoptionAppointment.LocationState = reader.GetString(16);
                    adoptionAppointment.LocationZip   = reader.GetString(17);

                    adoptionAppointment.CustomerFirstName   = reader.GetString(18);
                    adoptionAppointment.CustomerLastName    = reader.GetString(19);
                    adoptionAppointment.CustomerPhoneNumber = reader.GetString(20);
                    adoptionAppointment.CustomerActive      = reader.GetBoolean(21);
                    adoptionAppointment.CustomerCity        = reader.GetString(22);
                    adoptionAppointment.CustomerState       = reader.GetString(23);
                    adoptionAppointment.CustomerZipCode     = reader.GetString(24);
                    adoptionAppointment.AnimalName          = reader.GetString(25);
                    if (!reader.IsDBNull(26))
                    {
                        adoptionAppointment.AnimalDob = reader.GetDateTime(26);
                    }
                    adoptionAppointment.AnimalSpeciesID = reader.GetString(27);
                    if (!reader.IsDBNull(28))
                    {
                        adoptionAppointment.AnimalBreed = reader.GetString(28);
                    }
                    adoptionAppointment.AnimalArrivalDate     = reader.GetDateTime(29);
                    adoptionAppointment.AnimalCurrentlyHoused = reader.GetBoolean(30);
                    adoptionAppointment.AnimalAdoptable       = reader.GetBoolean(31);
                    adoptionAppointment.AnimalActive          = reader.GetBoolean(32);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(adoptionAppointment);
        }
Example #5
0
        /// <summary>
        /// NAME: Austin Gee
        /// DATE: 3/4/2020
        /// CHECKED BY: Michael Thompson
        ///
        /// Event handler that is fired when the save button is clicked. validates input, then updates appointment decision and notes
        /// and updates the application status
        /// </summary>
        /// <remarks>
        /// UPDATED BY: NA
        /// UPDATE DATE: NA
        /// WHAT WAS CHANGED: NA
        ///
        ///
        /// </remarks>
        private void btnSaveNotes_Click(object sender, RoutedEventArgs e)
        {
            if (!txtNotesMeetAndGreet.Text.IsValidString())
            {
                WPFErrorHandler.ErrorMessage("You must enter Valid notes.");
                txtNotesMeetAndGreet.Focus();
                return;
            }
            if (!cmbDecision.Text.IsValidString())
            {
                WPFErrorHandler.ErrorMessage("You Must enter a valid decision.");
                cmbDecision.Focus();
                return;
            }
            AdoptionAppointment oldAppointment = new AdoptionAppointment
            {
                AdoptionApplicationID = _adoptionAppointment.AdoptionApplicationID,
                AppointmentActive     = _adoptionAppointment.AppointmentActive,
                AppointmentDateTime   = _adoptionAppointment.AppointmentDateTime,
                AppointmentID         = _adoptionAppointment.AppointmentID,
                AppointmentTypeID     = _adoptionAppointment.AppointmentTypeID,
                Decision     = _adoptionAppointment.Decision,
                LocationID   = _adoptionAppointment.LocationID,
                LocationName = _adoptionAppointment.LocationName,
                Notes        = _adoptionAppointment.Notes
            };
            AdoptionAppointment newAppointment = new AdoptionAppointment
            {
                AdoptionApplicationID = _adoptionAppointment.AdoptionApplicationID,
                AppointmentActive     = _adoptionAppointment.AppointmentActive,
                AppointmentDateTime   = _adoptionAppointment.AppointmentDateTime,
                AppointmentID         = _adoptionAppointment.AppointmentID,
                AppointmentTypeID     = _adoptionAppointment.AppointmentTypeID,
                Decision     = cmbDecision.SelectedItem.ToString(),
                LocationID   = _adoptionAppointment.LocationID,
                LocationName = _adoptionAppointment.LocationName,
                Notes        = txtNotesMeetAndGreet.Text
            };

            try
            {
                IAdoptionAppointmentManager adoptionAppointmentManager = new AdoptionAppointmentManager();
                adoptionAppointmentManager.EditAdoptionAppointment(oldAppointment, newAppointment);

                if (newAppointment.Decision == "Approved")
                {
                    AdoptionApplicationManager adoptionApplicationManager = new AdoptionApplicationManager();
                    ApplicationVM oldApplicationVM = adoptionApplicationManager.RetrieveAdoptionApplicationByID(oldAppointment.AdoptionApplicationID);

                    string newStatus = "";

                    if (_adoptionAppointment.AppointmentTypeID == "Interview")
                    {
                        newStatus = "Home Inspection";
                    }
                    else if (_adoptionAppointment.AppointmentTypeID == "Home Inspection")
                    {
                        newStatus = "Meet and Greet";
                    }
                    else if (_adoptionAppointment.AppointmentTypeID == "Meet and Greet")
                    {
                        newStatus = "Animal Pick-up";
                    }
                    else if (_adoptionAppointment.AppointmentTypeID == "Animal Pick-up")
                    {
                        newStatus = "Adoption Complete";
                    }

                    DataTransferObjects.Application oldApplication = new DataTransferObjects.Application
                    {
                        AdoptionApplicationID = oldApplicationVM.AdoptionApplicationID,
                        AnimalID          = oldApplicationVM.AnimalID,
                        ApplicationActive = oldApplicationVM.ApplicationActive,
                        CustomerEmail     = oldApplicationVM.CustomerEmail,
                        RecievedDate      = oldApplicationVM.RecievedDate,
                        Status            = oldApplicationVM.Status
                    };


                    DataTransferObjects.Application newApplication = new DataTransferObjects.Application
                    {
                        AdoptionApplicationID = oldApplicationVM.AdoptionApplicationID,
                        AnimalID          = oldApplicationVM.AnimalID,
                        ApplicationActive = oldApplicationVM.ApplicationActive,
                        CustomerEmail     = oldApplicationVM.CustomerEmail,
                        RecievedDate      = oldApplicationVM.RecievedDate,
                        Status            = newStatus
                    };

                    adoptionApplicationManager.UpdateAdoptionApplication(oldApplication, newApplication);

                    _adoptionAppointmentManager.EditAdoptionAppointmentActive(oldAppointment.AppointmentID, false);
                }
            }
            catch (Exception)
            {
                WPFErrorHandler.ErrorMessage("Appointment update failed");
            }
            dgAppointments.Items.Refresh();
            _adoptionAppointment = _adoptionAppointmentManager.RetrieveAdoptionAppointmentByAppointmentID(_adoptionAppointment.AppointmentID);
            populateNoteFields();
            populateTextBoxes();

            disableNotes();
            btnEditNotes.Visibility = Visibility.Visible;
            btnSaveNotes.Visibility = Visibility.Hidden;
            return;
        }