コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: balmerd/FSFPL
 protected void btnExport_Click(object sender, EventArgs e)
 {
     DonationDA DA = new DonationDA();
     using (DataTable dt = DA.GetDonation(1)) {
         CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.Donation, DA.DetailsViewName);
     }
     DA = null;
 }
コード例 #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("~/App_Data/DonationEmail.xsl"));
                    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("~/App_Data/MembershipEmail.xsl"));
                    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_Test(ID, Server.MapPath("~/App_Data/VolunteerEmail_Test.xsl"));
                    litEmailBody.Text += sb.ToString();
                    pageName = "Volunteer_Confirmation_Template";
                } else if (strTypeID == MailUtil.EmailType.StudentVolunteer.ToString("D")) {
                    StudentVolunteerDA DA = new StudentVolunteerDA();
                    StringBuilder sb = DA.GetEmailBody_Test(ID, Server.MapPath("~/App_Data/StudentVolunteerEmail_Test.xsl"));
                    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("~/App_Data/AdvocacyEmail.xsl"));
                    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("~/App_Data/BigBookSaleVolunteerEmail.xsl"));
                    litEmailBody.Text += sb.ToString();
                    pageName = "Volunteer_Confirmation_Template";
                }
            } catch (Exception ex) {
                pageName = "";
                litEmailBody.Text = ex.Message;
            } finally {
                masterPage.ComponentName = pageName;
            }
        }
コード例 #3
0
ファイル: CSVExport.aspx.cs プロジェクト: balmerd/FSFPL
 protected void Page_Load(object sender, EventArgs e)
 {
     int id = 0;
     if (!String.IsNullOrEmpty(Request["typeid"])) {
         CSVExporter.ExportType exportType = (CSVExporter.ExportType)Enum.Parse(typeof(CSVExporter.ExportType), Request["typeid"]);
         if (Enum.IsDefined(typeof(CSVExporter.ExportType), exportType)) {
             if (!String.IsNullOrEmpty(Request["id"])) {
                 if (Int32.TryParse(Request["id"], out id)) {
                     switch (exportType) {
                         case CSVExporter.ExportType.Advocacy:
                             AdvocacyDA advocacyDA = new AdvocacyDA();
                             using (DataTable dt = advocacyDA.GetAdvocacy(id)) {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.Advocacy, advocacyDA.DetailsViewName);
                             }
                             advocacyDA = null;
                             break;
                         case CSVExporter.ExportType.Donation:
                             DonationDA donationDA = new DonationDA();
                             using (DataTable dt = donationDA.GetDonation(id)) {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.Donation, donationDA.DetailsViewName);
                             }
                             donationDA = null;
                             break;
                         case CSVExporter.ExportType.Membership:
                             MembershipDA membershipDA = new MembershipDA();
                             using (DataTable dt = membershipDA.GetMembership(id)) {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.Membership, membershipDA.DetailsViewName);
                             }
                             membershipDA = null;
                             break;
                         case CSVExporter.ExportType.StudentVolunteer:
                             StudentVolunteerDA studentVolunteerDA = new StudentVolunteerDA();
                             using (DataTable dt = studentVolunteerDA.GetVolunteer(id)) {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.StudentVolunteer, studentVolunteerDA.DetailsViewName);
                             }
                             studentVolunteerDA = null;
                             break;
                         case CSVExporter.ExportType.Volunteer:
                             VolunteerDA volunteerDA = new VolunteerDA();
                             using (DataTable dt = volunteerDA.GetVolunteer(id)) {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.Volunteer, volunteerDA.DetailsViewName);
                             }
                             volunteerDA = null;
                             break;
                         case CSVExporter.ExportType.BigBookSaleVolunteer:
                             BigBookSaleVolunteerDA bookSaleVolunteerDA = new BigBookSaleVolunteerDA();
                             using (DataTable dt = bookSaleVolunteerDA.GetVolunteer(id)) {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.BigBookSaleVolunteer, bookSaleVolunteerDA.DetailsViewName);
                             }
                             bookSaleVolunteerDA = null;
                             break;
                         case CSVExporter.ExportType.BookAndPlantSaleVolunteer:
                             BookAndPlantSaleVolunteerDA bookAndPlantSaleVolunteerDA = new BookAndPlantSaleVolunteerDA();
                             using (DataTable dt = bookAndPlantSaleVolunteerDA.GetVolunteer(id)) {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.BookAndPlantSaleVolunteer, bookAndPlantSaleVolunteerDA.DetailsViewName);
                             }
                             bookAndPlantSaleVolunteerDA = null;
                             break;
                         case CSVExporter.ExportType.BigBookSaleStudentVolunteer:
                             BigBookSaleStudentVolunteerDA bookSaleStudentVolunteerDA = new BigBookSaleStudentVolunteerDA();
                             using (DataTable dt = bookSaleStudentVolunteerDA.GetVolunteer(id)) {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.BigBookSaleStudentVolunteer, bookSaleStudentVolunteerDA.DetailsViewName);
                             }
                             bookSaleStudentVolunteerDA = null;
                             break;
                         case CSVExporter.ExportType.AnniversaryBookSaleVolunteer:
                             AnniversaryBookSaleVolunteerDA anniversaryBookSaleVolunteerDA = new AnniversaryBookSaleVolunteerDA();
                             using (DataTable dt = anniversaryBookSaleVolunteerDA.GetVolunteer(id))
                             {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.AnniversaryBookSaleVolunteer, anniversaryBookSaleVolunteerDA.DetailsViewName);
                             }
                             anniversaryBookSaleVolunteerDA = null;
                             break;
                         case CSVExporter.ExportType.BookDonation:
                             BookDonationDA bookDonationDA = new BookDonationDA();
                             using (DataTable dt = bookDonationDA.GetBookDonation(id))
                             {
                                 CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.BookDonation, bookDonationDA.DetailsViewName);
                             }
                             bookDonationDA = null;
                             break;
                     }
                 }
             } else if (!String.IsNullOrEmpty(Request["all"])) {
                 switch (exportType) {
                     case CSVExporter.ExportType.Advocacy:
                         AdvocacyDA advocacyDA = new AdvocacyDA();
                         using (DataTable dt = advocacyDA.GetAllAdvocacy()) {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.Advocacy, advocacyDA.DetailsViewName);
                         }
                         advocacyDA = null;
                         break;
                     case CSVExporter.ExportType.Donation:
                         DonationDA donationDA = new DonationDA();
                         using (DataTable dt = donationDA.GetAllDonations()) {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.Donation, donationDA.DetailsViewName);
                         }
                         donationDA = null;
                         break;
                     case CSVExporter.ExportType.Membership:
                         MembershipDA membershipDA = new MembershipDA();
                         using (DataTable dt = membershipDA.GetAllMemberships()) {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.Membership, membershipDA.DetailsViewName);
                         }
                         membershipDA = null;
                         break;
                     case CSVExporter.ExportType.StudentVolunteer:
                         StudentVolunteerDA studentVolunteerDA = new StudentVolunteerDA();
                         using (DataTable dt = studentVolunteerDA.GetAllVolunteers()) {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.StudentVolunteer, studentVolunteerDA.DetailsViewName);
                         }
                         studentVolunteerDA = null;
                         break;
                     case CSVExporter.ExportType.Volunteer:
                         VolunteerDA volunteerDA = new VolunteerDA();
                         using (DataTable dt = volunteerDA.GetAllVolunteers()) {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.Volunteer, volunteerDA.DetailsViewName);
                         }
                         volunteerDA = null;
                         break;
                     case CSVExporter.ExportType.BigBookSaleVolunteer:
                         BigBookSaleVolunteerDA bookSaleVolunteerDA = new BigBookSaleVolunteerDA();
                         using (DataTable dt = bookSaleVolunteerDA.GetAllVolunteers()) {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.BigBookSaleVolunteer, bookSaleVolunteerDA.DetailsViewName);
                         }
                         bookSaleVolunteerDA = null;
                         break;
                     case CSVExporter.ExportType.BookAndPlantSaleVolunteer:
                         BookAndPlantSaleVolunteerDA bookAndPlantSaleVolunteerDA = new BookAndPlantSaleVolunteerDA();
                         using (DataTable dt = bookAndPlantSaleVolunteerDA.GetAllVolunteers()) {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.BookAndPlantSaleVolunteer, bookAndPlantSaleVolunteerDA.DetailsViewName);
                         }
                         bookAndPlantSaleVolunteerDA = null;
                         break;
                     case CSVExporter.ExportType.BigBookSaleStudentVolunteer:
                         BigBookSaleStudentVolunteerDA bookSaleStudentVolunteerDA = new BigBookSaleStudentVolunteerDA();
                         using (DataTable dt = bookSaleStudentVolunteerDA.GetAllVolunteers()) {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.BigBookSaleStudentVolunteer, bookSaleStudentVolunteerDA.DetailsViewName);
                         }
                         bookSaleStudentVolunteerDA = null;
                         break;
                     case CSVExporter.ExportType.AnniversaryBookSaleVolunteer:
                         AnniversaryBookSaleVolunteerDA anniversaryBookSaleVolunteerDA = new AnniversaryBookSaleVolunteerDA();
                         using (DataTable dt = anniversaryBookSaleVolunteerDA.GetAllVolunteers())
                         {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.AnniversaryBookSaleVolunteer, anniversaryBookSaleVolunteerDA.DetailsViewName);
                         }
                         anniversaryBookSaleVolunteerDA = null;
                         break;
                     case CSVExporter.ExportType.BookDonation:
                         BookDonationDA bookDonationDA = new BookDonationDA();
                         using (DataTable dt = bookDonationDA.GetAllBookDonations())
                         {
                             CSVExporter.WriteToCSV(dt, CSVExporter.ExportType.BookDonation, bookDonationDA.DetailsViewName);
                         }
                         bookDonationDA = null;
                         break;
                 }
             }
         }
     }
 }
コード例 #4
0
ファイル: Donate_Now.aspx.cs プロジェクト: balmerd/FSFPL
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            int newID = 0;

            if (IsValid)
            {
                SqlCommand cmd = null;
                try {
                    cmd = new SqlCommand("dbo.FSFPL_AddDonation");
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("Amount", txtDonationAmount.Text);
                    cmd.Parameters.AddWithValue("TypeId", GetDonationType());
                    cmd.Parameters.AddWithValue("TypeDetails", GetDonationTypeDetails());
                    cmd.Parameters.AddWithValue("Title", txtTitle.Text.Trim());
                    cmd.Parameters.AddWithValue("FirstName", txtFirstName.Text.Trim());
                    cmd.Parameters.AddWithValue("MiddleName", txtMiddleName.Text.Trim());
                    cmd.Parameters.AddWithValue("LastName", txtLastName.Text.Trim());
                    cmd.Parameters.AddWithValue("Suffix", txtSuffix.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("HomePhone", txtHomePhone.Text.Trim());
                    cmd.Parameters.AddWithValue("WorkPhone", txtWorkPhone.Text.Trim());
                    cmd.Parameters.AddWithValue("Email", txtEmail.Text.Trim());
                    cmd.Parameters.AddWithValue("LocalLibrary", String.Empty);
                    cmd.Parameters.AddWithValue("GiftTypeId", rbGiftType.SelectedValue);
                    cmd.Parameters.AddWithValue("AltTitle", txtAltTitle.Text.Trim());
                    cmd.Parameters.AddWithValue("AltFirstName", txtAltFirstName.Text.Trim());
                    cmd.Parameters.AddWithValue("AltMiddleName", txtAltMiddleName.Text.Trim());
                    cmd.Parameters.AddWithValue("AltLastName", txtAltLastName.Text.Trim());
                    cmd.Parameters.AddWithValue("AltSuffix", txtAltSuffix.Text.Trim());
                    cmd.Parameters.AddWithValue("AltAddress1", txtAltAddress1.Text.Trim());
                    cmd.Parameters.AddWithValue("AltAddress2", txtAltAddress2.Text.Trim());
                    cmd.Parameters.AddWithValue("AltCity", txtAltCity.Text.Trim());
                    cmd.Parameters.AddWithValue("AltStateCode", ddlAltState.SelectedValue);
                    cmd.Parameters.AddWithValue("AltZipCode", txtAltZipCode.Text.Trim());
                    cmd.Parameters.AddWithValue("InfoTypeIdList", GetSelectedItemsList(cbxInfoType));
                    cmd.Parameters.AddWithValue("CreditCardName", txtCreditCardName.Text.Trim());

                    string creditCardNumber = txtCreditCardNumber.Text.Trim();
                    cmd.Parameters.AddWithValue("CreditCardNumber", Security.Encrypt(creditCardNumber));
                    cmd.Parameters.AddWithValue("Last4Digits", creditCardNumber.Substring(creditCardNumber.Length - 4, 4));

                    cmd.Parameters.AddWithValue("ExpMonth", ddlExpMonth.SelectedValue);
                    cmd.Parameters.AddWithValue("ExpYear", ddlExpYear.SelectedValue);

                    string securityCode = txtSecurityCode.Text.Trim();
                    cmd.Parameters.AddWithValue("SecurityCode", Security.Encrypt(securityCode));

                    cmd.Parameters.AddWithValue("NewsLetter", cbxNewsLetter.Checked);
                    cmd.Parameters.AddWithValue("EmployerMatch", cbxEmployerMatch.Checked);
                    cmd.Parameters.AddWithValue("Anonymous", cbxAnonymous.Checked);
                    cmd.Parameters.AddWithValue("Message", txtMessage.Text.Trim());

                    if (rbDonationType2.Checked) { // Neighborhood Library Campaign
                        cmd.Parameters.AddWithValue("NLC", ddlNLC.SelectedValue);
                        cmd.Parameters.AddWithValue("NLCNaming", txtNLCNaming.Text.Trim());
                    } else {
                        cmd.Parameters.AddWithValue("NLC", DBNull.Value);
                        cmd.Parameters.AddWithValue("NLCNaming", DBNull.Value);
                    }

                    cmd.Parameters.AddWithValue("DoNotShareName", cbxDoNotShareName.Checked);

                    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;

                    DonationDA DA = new DonationDA();
                    StringBuilder sbEmailBody = DA.GetEmailBody(newID, Server.MapPath(MailUtil.DonationTemplate));
                    MailUtil.SendDonationEmail(txtEmail.Text, sbEmailBody);

                    //Response.Redirect(String.Format("/?Confirmation&id={0}&typeid={1}", newID, MailUtil.EmailType.Donation.ToString("D")), true);
                    Response.Redirect(String.Format("/?Confirmation&id={0}&typeid={1}", Server.UrlEncode(Security.Encrypt(newID.ToString())), MailUtil.EmailType.Donation.ToString("D")), true);
                } catch (Exception ex) {
                    throw ex;
                } finally {
                    if (cmd.Connection != null && cmd.Connection.State == ConnectionState.Open) {
                        cmd.Connection.Close();
                    }
                    cmd.Dispose();
                }
            }
        }