protected void FormView1_DataBound(object sender, EventArgs e) { FormView fv = (FormView)sender; DataRowView dv = (DataRowView)fv.DataItem; if (dv != null) { int id = (int)dv["Id"]; BigBookSaleStudentVolunteerDA DA = new BigBookSaleStudentVolunteerDA(); StringBuilder sb = DA.GetEmailBody(id, Server.MapPath(MailUtil.BigBookSaleVolunteerInfoTemplate)); Literal litCurrentInfo = FormView1.FindControl("litCurrentInfo") as Literal; litCurrentInfo.Text = sb.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { int id; string email; BigBookSaleStudentVolunteerDA bigBookSaleStudentVolunteerDA = new BigBookSaleStudentVolunteerDA(); DataTable dtVolunteers = bigBookSaleStudentVolunteerDA.GetAllVolunteers(); foreach (DataRow row in dtVolunteers.Rows) { id = (int)row["Id"]; email = (string)row["Email"]; MailUtil.SendVolunteerEmail(email, bigBookSaleStudentVolunteerDA.GetEmailBody(id, Server.MapPath(MailUtil.BigBookSaleVolunteerTemplate))); } bigBookSaleStudentVolunteerDA = null; }
protected void btnInsert_Click(object sender, EventArgs e) { int newID = 0; if (IsValid) { SqlCommand cmd = null; try { cmd = new SqlCommand("dbo.FSFPL_AddBigBookSaleStudentVolunteer"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text.Trim()); cmd.Parameters.AddWithValue("LastName", txtLastName.Text.Trim()); cmd.Parameters.AddWithValue("Address1", txtAddress1.Text.Trim()); cmd.Parameters.AddWithValue("Address2", txtAddress2.Text.Trim()); cmd.Parameters.AddWithValue("City", txtCity.Text.Trim()); cmd.Parameters.AddWithValue("StateCode", ddlState.SelectedValue); cmd.Parameters.AddWithValue("ZipCode", txtZipCode.Text.Trim()); cmd.Parameters.AddWithValue("Email", txtEmail.Text.Trim()); cmd.Parameters.AddWithValue("HomePhone", txtHomePhone.Text.Trim()); cmd.Parameters.AddWithValue("SpecialInterest", txtSpecialInterests.Text.Trim()); cmd.Parameters.AddWithValue("School", txtSchool.Text.Trim()); cmd.Parameters.AddWithValue("Grade", txtGrade.Text.Trim()); cmd.Parameters.AddWithValue("Day1BoxMover", GetMultiCheckValues(cbxDay1BoxMover)); cmd.Parameters.AddWithValue("Day1TableMonitor", GetMultiCheckValues(cbxDay1TableMonitor)); cmd.Parameters.AddWithValue("Day2BoxMover", GetMultiCheckValues(cbxDay2BoxMover)); cmd.Parameters.AddWithValue("Day2TableMonitor", GetMultiCheckValues(cbxDay2TableMonitor)); cmd.Parameters.AddWithValue("Day2Cashier", GetMultiCheckValues(cbxDay2Cashier)); cmd.Parameters.AddWithValue("Day2Caller", GetMultiCheckValues(cbxDay2Caller)); cmd.Parameters.AddWithValue("Day3BoxMover", GetMultiCheckValues(cbxDay3BoxMover)); cmd.Parameters.AddWithValue("Day3TableMonitor", GetMultiCheckValues(cbxDay3TableMonitor)); cmd.Parameters.AddWithValue("Day3Floater", GetMultiCheckValues(cbxDay3Floater)); cmd.Parameters.AddWithValue("Day3Cashier", GetMultiCheckValues(cbxDay3Cashier)); cmd.Parameters.AddWithValue("Day3Caller", GetMultiCheckValues(cbxDay3Caller)); cmd.Parameters.AddWithValue("Day4BoxMover", GetMultiCheckValues(cbxDay4BoxMover)); cmd.Parameters.AddWithValue("Day4TableMonitor", GetMultiCheckValues(cbxDay4TableMonitor)); cmd.Parameters.AddWithValue("Day4Floater", GetMultiCheckValues(cbxDay4Floater)); cmd.Parameters.AddWithValue("Day4Cashier", GetMultiCheckValues(cbxDay4Cashier)); cmd.Parameters.AddWithValue("Day4Caller", GetMultiCheckValues(cbxDay4Caller)); cmd.Parameters.AddWithValue("Day5BoxMover", GetMultiCheckValues(cbxDay5BoxMover)); cmd.Parameters.AddWithValue("Day5TableMonitor", GetMultiCheckValues(cbxDay5TableMonitor)); cmd.Parameters.AddWithValue("Day5Floater", GetMultiCheckValues(cbxDay5Floater)); cmd.Parameters.AddWithValue("Day5Cashier", GetMultiCheckValues(cbxDay5Cashier)); cmd.Parameters.AddWithValue("Day5Caller", GetMultiCheckValues(cbxDay5Caller)); cmd.Parameters.AddWithValue("Day6BoxMover", GetMultiCheckValues(cbxDay6BoxMover)); cmd.Parameters.AddWithValue("Day6TableMonitor", GetMultiCheckValues(cbxDay6TableMonitor)); cmd.Parameters.AddWithValue("Day6Floater", GetMultiCheckValues(cbxDay6Floater)); cmd.Parameters.AddWithValue("Day6Cashier", GetMultiCheckValues(cbxDay6Cashier)); cmd.Parameters.AddWithValue("Day6Caller", GetMultiCheckValues(cbxDay6Caller)); cmd.Parameters.AddWithValue("Day6Packup", GetMultiCheckValues(cbxDay6Packup)); cmd.Parameters.AddWithValue("Day7BoxMover", GetMultiCheckValues(cbxDay7BoxMover)); cmd.Parameters.AddWithValue("Day7TableMonitor", GetMultiCheckValues(cbxDay7TableMonitor)); cmd.Parameters.AddWithValue("Day7Floater", GetMultiCheckValues(cbxDay7Floater)); cmd.Parameters.AddWithValue("Day7Cashier", GetMultiCheckValues(cbxDay7Cashier)); cmd.Parameters.AddWithValue("Day7Caller", GetMultiCheckValues(cbxDay7Caller)); cmd.Parameters.AddWithValue("Day7Packup", GetMultiCheckValues(cbxDay7Packup)); cmd.Parameters.AddWithValue("Day8Packup", GetMultiCheckValues(cbxDay8Packup)); SqlParameter param = new SqlParameter("Id", SqlDbType.Int); param.Size = 8; param.Direction = ParameterDirection.Output; cmd.Parameters.Add(param); cmd.Connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["FSFPL"].ConnectionString); cmd.Connection.Open(); cmd.ExecuteNonQuery(); newID = (int)cmd.Parameters["Id"].Value; BigBookSaleStudentVolunteerDA DA = new BigBookSaleStudentVolunteerDA(); StringBuilder sbEmailBody = DA.GetEmailBody(newID, Server.MapPath(MailUtil.SpringBookSaleVolunteerTemplate)); MailUtil.SendVolunteerEmail(txtEmail.Text, sbEmailBody); Response.Redirect(String.Format("/?Confirmation&id={0}&typeid={1}", Server.UrlEncode(Security.Encrypt(newID.ToString())), MailUtil.EmailType.SpringBookSaleStudentVolunteer.ToString("D")), true); } catch (Exception ex) { throw ex; } finally { if (cmd.Connection != null && cmd.Connection.State == ConnectionState.Open) { cmd.Connection.Close(); } cmd.Dispose(); } } }
protected void Page_Load(object sender, EventArgs e) { int ID = 0; string strID = Security.Decrypt(Request["id"]); string strTypeID = Request["typeid"]; masterPage = (masterpages_Site)Master; if (!String.IsNullOrEmpty(strID)) { Int32.TryParse(strID, out ID); } try { if (strTypeID == MailUtil.EmailType.Donation.ToString("D")) { DonationDA DA = new DonationDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.DonationTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Donation_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.Membership.ToString("D")) { MembershipDA DA = new MembershipDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.MembershipTemplate)); litEmailBody.Text += sb.ToString().Replace("Please keep this email as receipt for your order.", "Please keep this as receipt for your order."); pageName = "Membership_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.Volunteer.ToString("D")) { VolunteerDA DA = new VolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.VolunteerTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.StudentVolunteer.ToString("D")) { StudentVolunteerDA DA = new StudentVolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.StudentVolunteerTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.Advocacy.ToString("D")) { AdvocacyDA DA = new AdvocacyDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.AdvocacyTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.BigBookSaleVolunteer.ToString("D")) { BigBookSaleVolunteerDA DA = new BigBookSaleVolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.BigBookSaleVolunteerTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.BigBookSaleVolunteerTest.ToString("D")) { BigBookSaleVolunteerDA DA = new BigBookSaleVolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.BigBookSaleVolunteerTemplateTest)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.BigBookSaleStudentVolunteer.ToString("D")) { BigBookSaleStudentVolunteerDA DA = new BigBookSaleStudentVolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.BigBookSaleVolunteerTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.BigBookSaleStudentVolunteerTest.ToString("D")) { BigBookSaleStudentVolunteerDA DA = new BigBookSaleStudentVolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.BigBookSaleVolunteerTemplateTest)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.BookAndPlantSaleVolunteer.ToString("D")) { BookAndPlantSaleVolunteerDA DA = new BookAndPlantSaleVolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.BookAndPlantSaleVolunteerTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.AnniversaryBookSaleVolunteer.ToString("D")) { AnniversaryBookSaleVolunteerDA DA = new AnniversaryBookSaleVolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.AnniversaryBookSaleVolunteerTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.BookDonation.ToString("D")) { BookDonationDA DA = new BookDonationDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.BookDonationTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.SpringBookSaleVolunteer.ToString("D")) { BigBookSaleVolunteerDA DA = new BigBookSaleVolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.SpringBookSaleVolunteerTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } else if (strTypeID == MailUtil.EmailType.SpringBookSaleStudentVolunteer.ToString("D")) { BigBookSaleStudentVolunteerDA DA = new BigBookSaleStudentVolunteerDA(); StringBuilder sb = DA.GetEmailBody(ID, Server.MapPath(MailUtil.SpringBookSaleVolunteerTemplate)); litEmailBody.Text += sb.ToString(); pageName = "Volunteer_Confirmation_Template"; } } catch (Exception ex) { pageName = ""; litEmailBody.Text = ex.Message; } finally { masterPage.ComponentName = pageName; } }