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"];
         BookAndPlantSaleVolunteerDA DA = new BookAndPlantSaleVolunteerDA();
         StringBuilder sb = DA.GetEmailBody(id, Server.MapPath(MailUtil.BookAndPlantSaleVolunteerInfoTemplate));
         Literal litCurrentInfo = FormView1.FindControl("litCurrentInfo") as Literal;
         litCurrentInfo.Text = sb.ToString();
     }
 }
Esempio n. 2
0
        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;
            }
        }
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            int newID = 0;
            HttpContext ctx = HttpContext.Current;

            if (IsValid)
            {
                try {
                    sb.Append("<h1>Book_And_Plant_Sale_Form</h1>");
                    sb.AppendFormat("<h2>Url:</h2><p>{0}</p>", ctx.Request.Url);
                    sb.AppendFormat("<h2>Referrer:</h2><p>{0}</p>", ctx.Request.UrlReferrer);
                    sb.AppendFormat("<h2>QueryString:</h2><p>{0}</p>", HttpUtility.HtmlEncode(ctx.Request.QueryString.ToString()));
                    sb.AppendFormat("<h2>UserHostName:</h2><p>{0}</p>", ctx.Request.UserHostName);
                    sb.AppendFormat("<h2>UserHostAddress:</h2><p>{0}</p>", ctx.Request.UserHostAddress);
                    sb.Append("<h2>Form Data</h2>");
                    addField("FirstName", txtFirstName.Text);
                    addField("LastName", txtLastName.Text);
                    addField("MailingAddress", txtAddress.Text);
                    addField("Email", txtEmail.Text);
                    addField("HomePhone", txtHomePhone.Text);
                    addField("Day1", getCheckBoxListValues(cbxDay1));
                    addField("Day1", getCheckBoxListValues(cbxDay2));
                    addField("Day1", getCheckBoxListValues(cbxDay3));
                    addField("SpecialInterest", txtInterests.Text);
                } catch (Exception ex) {
                    sb.AppendFormat("<p>Field Capture EXCEPTION : {0}</p>", ex.ToString());
                    sb.AppendFormat("<p>Source : {0}</p>", ex.Source);
                    sb.AppendFormat("<p>Message : {0}</p>", ex.Message);
                    sb.AppendFormat("<p>Stack Trace : {0}</p>", ex.StackTrace);
                }

                SqlCommand cmd = null;
                try {
                    cmd = new SqlCommand("dbo.FSFPL_AddBookAndPlantSaleVolunteer");
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text.Trim());
                    cmd.Parameters.AddWithValue("LastName", txtLastName.Text.Trim());
                    cmd.Parameters.AddWithValue("Email", txtEmail.Text.Trim());
                    cmd.Parameters.AddWithValue("MailingAddress", txtAddress.Text.Trim());
                    cmd.Parameters.AddWithValue("HomePhone", txtHomePhone.Text.Trim());
                    cmd.Parameters.AddWithValue("Day1", getCheckBoxListValues(cbxDay1));
                    cmd.Parameters.AddWithValue("Day2", getCheckBoxListValues(cbxDay2));
                    cmd.Parameters.AddWithValue("Day3", getCheckBoxListValues(cbxDay3));
                    cmd.Parameters.AddWithValue("SpecialInterest", txtInterests.Text.Trim());

                    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;

                    sb.AppendFormat("<p>FSFPL_Book_And_Plant_Sale_Form added, ID : {0}</p>", newID);

                    try {
                        BookAndPlantSaleVolunteerDA DA = new BookAndPlantSaleVolunteerDA();
                        StringBuilder sbEmailBody = DA.GetEmailBody(newID, Server.MapPath(MailUtil.BookAndPlantSaleVolunteerTemplate));
                        MailUtil.SendVolunteerEmail(txtEmail.Text, sbEmailBody);
                        sb.Append("<p>Confirmation Email SUCCESS</p>");
                    } catch (Exception exEmail1) {
                        sb.AppendFormat("<p>Confirmation Email EXCEPTION : {0}</p>", exEmail1.ToString());
                        sb.AppendFormat("<p>Source : {0}</p>", exEmail1.Source);
                        sb.AppendFormat("<p>Message : {0}</p>", exEmail1.Message);
                        sb.AppendFormat("<p>Stack Trace : {0}</p>", exEmail1.StackTrace);
                    }

                    try {
                        MailUtil.SendDataGramEmail("Book_And_Plant_Sale_Form submitted", sb);
                    } catch {}

                } catch (Exception ex) {
                    sb.AppendFormat("<p>General Exception : {0}</p>", ex.ToString());
                    sb.AppendFormat("<p>Source : {0}</p>", ex.Source);
                    sb.AppendFormat("<p>Message : {0}</p>", ex.Message);
                    sb.AppendFormat("<p>Stack Trace : {0}</p>", ex.StackTrace);
                    try {
                        MailUtil.SendDataGramEmail("Book_And_Plant_Sale_Form EXCEPTION", sb);
                    } catch {}
                    throw ex;
                } finally {
                    if (cmd.Connection != null && cmd.Connection.State == ConnectionState.Open) {
                        cmd.Connection.Close();
                    }
                    cmd.Dispose();
                }

                Response.Redirect(String.Format("/?Confirmation&id={0}&typeid={1}", Server.UrlEncode(Security.Encrypt(newID.ToString())), MailUtil.EmailType.BookAndPlantSaleVolunteer.ToString("D")), true);
            }
        }