private void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            // update values of AdultConfidentialInfo object
            aci.foodStamps           = foodStampsCheck.IsChecked.ToString();
            aci.dependentChildrenAid = dependentChildrenCheck.IsChecked.ToString();
            aci.supplementaryIncome  = SSIcheck.IsChecked.ToString();
            aci.housingAssistance    = section8Check.IsChecked.ToString();
            aci.none               = noneCheck.IsChecked.ToString();
            aci.homeless           = homelessCheck.IsChecked.ToString();
            aci.agedOutFosterCare  = agedOutCheck.IsChecked.ToString();
            aci.outOfWorkforce     = workforceCheck.IsChecked.ToString();
            aci.formCompletionDate = DateTime.Now;

            // if no boxes are checked, display error message
            if (aci.foodStamps == "False" && aci.dependentChildrenAid == "False" && aci.supplementaryIncome == "False" && aci.housingAssistance == "False" && aci.none == "False")
            {
                ErrorMessage error = new ErrorMessage("Please select all that apply to your family, if none apply --- select \'None of these apply to me or my family\'");

                error.ShowDialog();

                return;
            }

            // if the 'None' box is checked, and another box is also check, error message displays
            if ((aci.foodStamps == "True" || aci.dependentChildrenAid == "True" || aci.supplementaryIncome == "True" || aci.housingAssistance == "True") && aci.none == "True")
            {
                ErrorMessage error = new ErrorMessage("You cannot select \'None apply\' and also check other boxes.");

                error.ShowDialog();

                return;
            }

            // create DataAccess variable to then save the information to the DataBase
            DataAccess db = new DataAccess();

            db.SaveACI(aci);

            // change UserControl Visibility and display success message

            Information_Page.aciuc.Visibility = Visibility.Hidden;

            Information_Page.SuccessMessageAndShutdown();
        }
        private void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            // variable that will validate the signature field
            bool sigError = false;

            // if the signature has not been filled out, changes border color and alters value of sigError
            if (signatureCanvas.Strokes.Count == 0)
            {
                sigCanBorder.BorderBrush = Brushes.Red;
                sigError = true;
            }

            // changes signature border to base color if it has been filled out
            else
            {
                if (sigCanBorder.BorderBrush == Brushes.Red)
                {
                    sigCanBorder.BorderBrush = new SolidColorBrush(Color.FromRgb(33, 148, 243));
                }

                // sets sigError to false, as the signature has now been filled out
                sigError = false;
            }

            // byte array to hold the stroke values of the signature field
            byte[] signature;
            using (MemoryStream ms = new MemoryStream())
            {
                signatureCanvas.Strokes.Save(ms);
                signature = ms.ToArray();
            }

            // update ConfidentialInfo object to contain current values
            hsci.foodStamps           = foodStampsCheck.IsChecked.ToString();
            hsci.dependentChildrenAid = dependentChildrenCheck.IsChecked.ToString();
            hsci.supplementaryIncome  = SSIcheck.IsChecked.ToString();
            hsci.housingAssistance    = section8Check.IsChecked.ToString();
            hsci.none               = noneCheck.IsChecked.ToString();
            hsci.homeless           = homelessCheck.IsChecked.ToString();
            hsci.agedOutFosterCare  = agedOutCheck.IsChecked.ToString();
            hsci.parentsActiveDuty  = activeDutyCheck.IsChecked.ToString();
            hsci.reducedLunch       = reducedLunchCheck.IsChecked.ToString();
            hsci.parentSignature    = signature;
            hsci.formCompletionDate = DateTime.Now;

            // if no boxes are selected, display error
            if (hsci.foodStamps == "False" && hsci.dependentChildrenAid == "False" && hsci.supplementaryIncome == "False" && hsci.housingAssistance == "False" && hsci.none == "False")
            {
                ErrorMessage error = new ErrorMessage("Please select all that apply to your family, if none apply --- select \'None of these apply to me or my family\'");

                error.ShowDialog();

                return;
            }

            // if 'None' box is checked, while others are also checked, display error
            if ((hsci.foodStamps == "True" || hsci.dependentChildrenAid == "True" || hsci.supplementaryIncome == "True" || hsci.housingAssistance == "True") && hsci.none == "True")
            {
                ErrorMessage error = new ErrorMessage("You cannot select \'None apply\' and also check other boxes.");

                error.ShowDialog();

                return;
            }

            // if there was no signature error, save
            if (!sigError)
            {
                // DataAccess variable to save information to database
                DataAccess db = new DataAccess();

                db.SaveHSCI(hsci);

                // alter UC visibility
                Information_Page.hsciuc.Visibility = Visibility.Hidden;

                Information_Page.SuccessMessageAndShutdown();
            }
        }
Example #3
0
        private void SignInBtn_Click(object sender, RoutedEventArgs e)
        {
            DataAccess db = new DataAccess();

            // assign value from password box to temp variable
            string pw = PasswordText.Password;

            // perform searches to see if the user exists in either login table in the db
            highschoolCheck = db.HSCheck(EmailText.Text);

            adultCheck = db.AdultCheck(EmailText.Text);


            // declare byte array that will hold the saltedHash of the user entered password
            // this will later be compared to the stored values to check if the login credentials are correct
            byte[] saltedHash;

            // if the email was found in the highschoollogin table, this code executes
            if (highschoolCheck != null)
            {
                // saltedHash is assigned the value of the salted hash that is returned by the called method
                saltedHash = CommonMethods.GenerateSaltedHash(Encoding.UTF8.GetBytes(pw), Encoding.UTF8.GetBytes(highschoolCheck.passwordSalt));

                // if the byte array that is stored matches the byte array produced by the user input, this code executes
                if (CommonMethods.CompareByteArrays(saltedHash, Convert.FromBase64String(highschoolCheck.passwordHash)))
                {
                    this.Visibility = Visibility.Hidden;

                    Information_Page ip = new Information_Page(highschoolCheck);
                    ip.ShowDialog();

                    this.Close();
                }

                // otherwise an error message is displayed
                else
                {
                    ErrorMessage error = new ErrorMessage("Incorrect password.");

                    error.ShowDialog();
                }
            }


            // if the email is found in the adultlogins table, this code executes
            else if (adultCheck != null)
            {
                // salted hash is generated and assigned to saltedHash variable by calling a method
                saltedHash = CommonMethods.GenerateSaltedHash(Encoding.UTF8.GetBytes(pw), Encoding.UTF8.GetBytes(adultCheck.passwordSalt));

                // if the byte arrays match, this code executes
                if (CommonMethods.CompareByteArrays(saltedHash, Convert.FromBase64String(adultCheck.passwordHash)))
                {
                    this.Visibility = Visibility.Hidden;

                    if (EmailText.Text.ToLower().Equals("cvtcadmin"))
                    {
                        AdminWindow aw = new AdminWindow();

                        aw.ShowDialog();
                    }

                    else
                    {
                        Information_Page ip = new Information_Page(adultCheck);
                        ip.ShowDialog();
                    }

                    this.Close();
                }

                // otherwise, error message displays
                else
                {
                    ErrorMessage error = new ErrorMessage("Incorrect password.");

                    error.ShowDialog();
                }
            }

            // if user is not found in either table, error message displays
            else
            {
                ErrorMessage error = new ErrorMessage("No account exists with that email.");

                error.ShowDialog();
            }
        }