protected void SubmitApplication(object sender, EventArgs e) { List <string> panelsNeeded = new List <string>(); List <string> To = new List <string>(); List <string> Bcc = new List <string>(); List <string> Cc = new List <string>(); List <string> collegePanels = new List <string>(); TiffCreator tiff = new TiffCreator(); AdditionalDocs additionalDocs = new AdditionalDocs(); IEnumerable <FieldInfo> transcriptFields; Email email = new Email(); string emailBody; string[] fromAddress; if (Enroll.CampusAttending == "Online" || Enroll.CampusAttending == "Louisa" || Enroll.CampusAttending == "Northern Kentucky" || Enroll.CampusAttending == "CarlisleNicholas" || Enroll.CampusAttending == "Mayfield") { To.Add("*****@*****.**"); } else if (Enroll.CampusAttending == "Lexington") { To.Add("*****@*****.**"); } else if (Enroll.CampusAttending == "Fort Knox") { To.Add("*****@*****.**"); To.Add("*****@*****.**"); } else { To.Add("*****@*****.**"); } if (Enroll.VABenefits == "Yes") { To.Add("*****@*****.**"); } fromAddress = PersonalInfo1.StudentName.Split(','); //mainPanel.ContentTemplateContainer.Controls if (Page.IsValid) { foreach (Control step in pnlMain.Controls) { if (step is Panel) { foreach (Control control in step.Controls) { if (control is UserControl) { foreach (Control currentControl in control.Controls) { if (currentControl is Panel) { formInfo = fieldInfo.CreateFormInfo((Panel)currentControl); } } } } } else if (step is UserControl) { foreach (Control currentControl in step.Controls) { if (currentControl is Panel) { formInfo = fieldInfo.CreateFormInfo((Panel)currentControl); } } } }//end foreach loop for (int i = 0; i <= 9; i++) { if (i > SchoolInfo1.collegeValue) { collegePanels.Add("CollegePanel" + i); } } var colleges = formInfo.Where(c => collegePanels.Contains(c.panelID)).ToList(); foreach (var college in colleges) { formInfo.Remove(college); } if (Enroll.CompanyReimbursement != "Yes") { var companyReimbursement = formInfo.Where(c => c.panelID == "companyDeffermentPanel").ToList(); foreach (var company in companyReimbursement) { formInfo.Remove(company); } } if (Enroll.degreeType == "Graduate" || Enroll.degreeType == "POST GRADUATE") { var KY = formInfo.Where(f => f.panelID == "KYResidentContainer" || f.panelID == "panelStateResident").ToList(); foreach (var res in KY) { formInfo.Remove(res); } } else if (KYResidentInfo.KYRes == "No") { var KY = formInfo.Where(f => f.panelID == "panelStateResident").ToList(); foreach (var res in KY) { formInfo.Remove(res); } } if (PersonalInfo1.State != "California") { var state = formInfo.Where(f => f.panelID == "pnlCalifornia").ToList(); foreach (var statePanel in state) { formInfo.Remove(statePanel); } } if (Enroll.programInfo != null) { if (Enroll.programInfo.StartsWith("Baking and Pastry Arts") || Enroll.programInfo.StartsWith("Culinary Arts")) { var program = formInfo.Where(f => f.panelID == "pnlClassRepeat").ToList(); foreach (var prog in program) { formInfo.Remove(prog); } } } if (Enroll.degreeType == "POST GRADUATE") { var asf = formInfo.Where(f => f.panelID == "pnlASFContainer" || f.panelID == "pnlASF").ToList(); foreach (var asfPanel in asf) { formInfo.Remove(asfPanel); } } var testInfo = formInfo.Where(r => r.panelID == "TestScorePanel").ToList(); foreach (var test in testInfo) { formInfo.Remove(test); } if (EnrollAcknowledge.DisplayGradWork == "No") { var gradWork = formInfo.Where(r => r.panelID == "pnlGradWork").ToList(); foreach (var work in gradWork) { formInfo.Remove(work); } } if (Enroll.enrollStartDate == "Winter: January 2018") { var withdrawPanels = formInfo.Where(f => f.panelID == "pnlWithdraw" || f.panelID == "pnlWithdrawFortKnox").ToList(); foreach (var withdrawPanel in withdrawPanels) { formInfo.Remove(withdrawPanel); } } else { var withdrawPanels = formInfo.Where(f => f.panelID == "pnlOldWithdraw").ToList(); foreach (var withdrawPanel in withdrawPanels) { formInfo.Remove(withdrawPanel); } if (Enroll.CampusAttending != "Fort Knox") { withdrawPanels.Clear(); withdrawPanels = formInfo.Where(f => f.panelID == "pnlWithdrawFortKnox").ToList(); foreach (var withdrawPanel in withdrawPanels) { formInfo.Remove(withdrawPanel); } } } emailBody = email.CreateEmailBody(formInfo); //if (ViewState["DisplayProgramDoc"] != null) //{ // if ((bool)ViewState["DisplayProgramDoc"] == true) // { // if (Enroll.CampusAttending == "Fort Knox") // { // if (Enroll.enrollStartDate == "Winter: January 2018") // { // Session["ProgramDoc"] = "FortKnoxRates"; // } // else // { // Session["ProgramDoc"] = "FortKnoxRates2018"; // } // } // if (ViewState["ESigParent"] == null) // tuitionAttatchments = tiff.SignTuitionSheet((string)Session["ESig"], null, PersonalInfo1.StudentName, TranscriptESign1.SigDate); // else // tuitionAttatchments = tiff.SignTuitionSheet((string)ViewState["ESig"], (string)Session["ESigParent"], PersonalInfo1.StudentName, TranscriptESign1.SigDate); // } //} disclosureAttachment = tiff.SignDisclosure((string)Session["ESig"], PersonalInfo1.StudentName, TranscriptESign1.SigDate); attachments.Add(disclosureAttachment); allAttachments.Add(disclosureAttachment); //Create transcripts // Build HS/ GED Transcript panelsNeeded.Add("PersonalInfoPanel"); panelsNeeded.Add("AcademicHistoryPanel"); panelsNeeded.Add("highSchoolPanel"); panelsNeeded.Add("TranscriptPanel"); transcriptFields = formInfo.Where(f => panelsNeeded.Contains(f.panelID)); HSGedAttatchments.Add(additionalDocs.BuildTranscripts(transcriptFields, (string)Session["ESig"], "HS-GED", Enroll.CampusAttending)); foreach (var item in HSGedAttatchments) { attachments.Add(item); allAttachments.Add(item); } panelsNeeded.Clear(); //Build College Transcipts for (int i = 1; i <= 9; i++) { if (i <= Convert.ToInt16(SchoolInfo1.collegeNumber)) { panelsNeeded.Add("PersonalInfoPanel"); panelsNeeded.Add("CollegePanel" + i); panelsNeeded.Add("creditPanel" + i); panelsNeeded.Add("degreePanel" + i); panelsNeeded.Add("TranscriptPanel"); panelsNeeded.Add("pnlESig"); transcriptFields = formInfo.Where(f => panelsNeeded.Contains(f.panelID)); CollegeAttatchments.Add(additionalDocs.BuildTranscripts(transcriptFields, (string)Session["ESig"], "College" + i, Enroll.CampusAttending)); } } foreach (var item in CollegeAttatchments) { attachments.Add(item); allAttachments.Add(item); } panelsNeeded.Clear(); //Build ROI panelsNeeded.Add("PersonalInfoPanel"); panelsNeeded.Add("AcademicHistoryPanel"); panelsNeeded.Add("highSchoolPanel"); for (int i = 1; i <= 9; i++) { if (i <= Convert.ToInt16(SchoolInfo1.collegeNumber)) { panelsNeeded.Add("CollegePanel" + i); panelsNeeded.Add("creditPanel" + i); panelsNeeded.Add("degreePanel" + i); } } panelsNeeded.Add("TranscriptPanel"); panelsNeeded.Add("pnlESig"); transcriptFields = formInfo.Where(f => panelsNeeded.Contains(f.panelID)); ROIAttatchments.Add(additionalDocs.BuildTranscripts(transcriptFields, (string)Session["ESig"], "ROI", Enroll.CampusAttending)); foreach (var item in ROIAttatchments) { attachments.Add(item); allAttachments.Add(item); } panelsNeeded.Clear(); //foreach (string item in tuitionAttatchments) //{ // attachments.Add(item); //} foreach (string item in SchoolInfo1.GetTranscriptAttachments()) { attachments.Add(item); ROIAttatchments.Add(item); allAttachments.Add(item); } email.SendHTMLEmail("Re-Entry Enrollment Application - " + PersonalInfo1.StudentName, emailBody, To, Bcc, Cc, fromAddress[0] + "@SullivanEnrollment.edu", attachments); if (Enroll.CampusAttending == "Louisville") { To.Clear(); To.Add("*****@*****.**"); try { email.SendHTMLEmail("Re-Entry Enrollment Application - " + PersonalInfo1.StudentName, emailBody, To, Bcc, Cc, fromAddress[0] + "@SullivanEnrollment.edu", attachments); } catch (Exception ex) { email.SendErrorEmail("Application Email Error", "Application Email Error", ex); } } //Session["CampusNumber"] = Enroll.CampusNumber; Session["StudentName"] = PersonalInfo1.StudentName; Session["Phone"] = PersonalInfo1.Phone; Session["Email"] = PersonalInfo1.Email; Session["ReEntry"] = "Yes"; Session["ZipCode"] = PersonalInfo1.ZipCode; //Send and create Tiffs Tiffer(); try { To.Clear(); To.Add(PersonalInfo1.Email); //Send the application to the student if their email address is in the proper format. var ssn = formInfo.FirstOrDefault(f => f.controlID == "tBoxSocialSecurityNumber"); formInfo.Remove(ssn); var dob = formInfo.FirstOrDefault(f => f.controlID == "tbDOB"); formInfo.Remove(dob); if (Enroll.AlumniIncentive == "Yes") { string alumniBody; attachments.Clear(); alumniBody = "<html><p>Hello " + PersonalInfo1.StudentName + "</p>" + "<p>IMPORTANT: In order to receive the Alumni Tuition Incentive, the Alumnus must be registered with the Alumni Association prior to completing an enrollment. " + "Visit <a href='http://alumni.sullivan.edu/register/' target='_blank'>http://alumni.sullivan.edu/register/</a> to register for the Alumni Association. If the alumnus is already a member of the Alumni Association, " + "visit <a href='http://alumni.sullivan.edu/register/' target='_blank'>http://alumni.sullivan.edu/register/</a> to verify enrollment. If you are not the alumnus, please note you are responsible for ensuring the " + "Alumnus registers prior to you completing the enrollment process.</p>"; //Bcc.Add("*****@*****.**"); email.SendHTMLEmail("Sullivan University Alumni Incentive - " + PersonalInfo1.StudentName, alumniBody, To, Bcc, Cc, "*****@*****.**", attachments); To.Clear(); To.Add("*****@*****.**"); attachments.Clear(); panelsNeeded.Clear(); panelsNeeded.Add("PersonalInfoPanel"); panelsNeeded.Add("PersonalInfoPanel2"); panelsNeeded.Add("EnrollPanel"); panelsNeeded.Add("programPanel"); panelsNeeded.Add("pnlAlumnusName"); IEnumerable <FieldInfo> alumniFields = formInfo.Where(f => panelsNeeded.Contains(f.panelID)); alumniBody = additionalDocs.BuildAlumniIncentive(alumniFields); email.SendHTMLEmail("Alumni Incentive - " + PersonalInfo1.StudentName, alumniBody, To, Bcc, Cc, "*****@*****.**", attachments); } } catch { } Session["AllAttachments"] = allAttachments; ScriptManager.RegisterClientScriptBlock(this, typeof(System.Web.UI.Page), "TrackSubmission", "TrackSubmission();", true); if (Enroll.additionalForms == "MBAAccounting") { Response.Redirect("MBAAccounting.aspx"); } else if (Enroll.Housing == "Yes") { Response.Redirect("housing.aspx"); } else { Response.Redirect("ReEntryConfirmation.aspx"); } } }