protected void Button1_Click(object sender, EventArgs e) { //DataView DV1 = (DataView)AccessDataSource1.Select(DataSourceSelectArguments.Empty); AppCode appcode = new AppCode(); DataSet DV1 = appcode.SelectQuery("Enewsletter_Email_Select"); foreach (DataRow row in DV1.Tables[0].Rows) { string ToAddress = row["Email_Address"].ToString(); MailMessage message = new MailMessage("*****@*****.**", ToAddress); message.Body = TextBox2.Text; message.Subject = TextBox1.Text; message.BodyEncoding = System.Text.Encoding.UTF8; string Path = HttpContext.Current.Server.MapPath("~/images/EnewsLetters/Temp/"); FileUpload1.SaveAs(Path + FileUpload1.FileName); Attachment attach1 = new Attachment(Path + FileUpload1.FileName); message.Attachments.Add(attach1); SmtpClient mailserver = new SmtpClient("amcsmail02.amcs.com", 25); try { mailserver.Send(message); } catch { } attach1.Dispose(); } System.IO.File.Delete(HttpContext.Current.Server.MapPath("~/images/EnewsLetters/Temp/") + FileUpload1.FileName); TextBox1.Text = ""; TextBox2.Text = ""; }
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { //Get Event Data for Calendar AppCode appcode = new AppCode(); string sc = "Calendar_DayRender_Select"; DataSet ds = new DataSet(); ds = appcode.SelectQuery(sc); foreach (DataRow row in ds.Tables[0].Rows) // loop through each rows in order to compare with day cell's date { try { if (Convert.ToDateTime(row["Event_Date"]) == e.Day.Date) { if (e.Cell.Controls.Count > 1) { Image img = new Image(); img.ImageUrl = Convert.ToString(row["Icon_Path"]); img.ToolTip = Convert.ToString(row["Additional_Info"]); e.Cell.Controls.Add(img); string linkbutn = Convert.ToString(row["Event_Name"]); linkbutn = linkbutn + "<br />"; Label linkb = new Label(); linkb.Text = linkbutn; linkb.ToolTip = Convert.ToString(row["Additional_Info"]); linkb.Font.Size = 10; e.Cell.Controls.Add(linkb); } else { e.Cell.Controls.Clear(); Label label = new Label(); string labelstring = e.Day.Date.Day.ToString(); labelstring = labelstring + "<br />"; label.Text = labelstring; e.Cell.Controls.Add(label); Image img = new Image(); img.ImageUrl = Convert.ToString(row["Icon_Path"]); img.ToolTip = Convert.ToString(row["Additional_Info"]); e.Cell.Controls.Add(img); string linkbutn = Convert.ToString(row["Event_Name"]); linkbutn = linkbutn + "<br />"; Label linkb = new Label(); linkb.Text = linkbutn; linkb.ToolTip = Convert.ToString(row["Additional_Info"]); linkb.Font.Size = 10; e.Cell.Controls.Add(linkb); } } } catch { return; } } }
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e) { string IconPath = "Text"; DataSet ds = new DataSet("Event_Calendar"); AppCode appcode = new AppCode(); ds = appcode.SelectQuery("Calendar_Modify_Select_Record", DataList1.SelectedValue, "p1"); foreach (DataRow row in ds.Tables[0].Rows) { TextBox_EventDate.Text = Convert.ToString(row["Event_Date"]); TextBox_EventName.Text = Convert.ToString(row["Event_Name"]); TextBoxEventInfo.Text = Convert.ToString(row["Additional_Info"]); IconPath = Convert.ToString(row["Icon_Path"]); } DropDownList3.DataBind(); DropDownList3.ClearSelection(); ListItem li = DropDownList3.Items.FindByValue(IconPath); DropDownList3.SelectedIndex = DropDownList3.Items.IndexOf(li); Image1.ImageUrl = IconPath; DataList1.Visible = false; Panel1.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { // Set the date on all pages. DateTime dt = DateTime.Now; string today; today = dt.ToLongDateString(); Literal1.Text = today; // Grab the data for the Up-Coming Events box. AppCode appcode = new AppCode(); string sc = "Up_Coming_Events_Select"; string param = dt.ToShortDateString(); DataSet MyDs = new DataSet(); MyDs = appcode.SelectQuery(sc, param, "@datestring"); // Set the text for each Link button in the Up-Coming Events box. LabelLogic(MyDs); // Set the date for the previous month eNewsletter box. int TodayMonth = dt.Month; int TodayYear = dt.Year; if (TodayMonth == 1) { TodayMonth = 12; TodayYear = TodayYear - 1; } else { TodayMonth = dt.Month - 1; TodayYear = dt.Year; } int TodayDay = 01; string eNewsDateString = Convert.ToString(TodayMonth) + "/" + Convert.ToString(TodayDay) + "/" + Convert.ToString(TodayYear); // Grab the data for the previous month eNewsletter box. string eNewsSC = "pre_month_newsletter_select"; string eNewsparam = eNewsDateString; DataSet MyDs1 = new DataSet(); MyDs1 = appcode.SelectQuery(eNewsSC, eNewsparam, "@enewsdatestring"); MyDs1.DataSetName = "PreviousMonth"; // Set the previous month eNewsletter box labels. eNewsLableLogic(MyDs1); // Set the date for the current month eNewsletter box. int CurrentMonth = dt.Month; int CurrentYear = dt.Year; int CurrentDay = 01; string eNewsCurrentDateString = Convert.ToString(CurrentMonth) + "/" + Convert.ToString(CurrentDay) + "/" + Convert.ToString(CurrentYear); // Grab the data for the current month eNewsletter box. string eNewsCurrentSC = "curr_month_newsletter_select"; string eNewsCurrentparam = eNewsCurrentDateString; DataSet MyDsCurrent = new DataSet(); MyDsCurrent = appcode.SelectQuery(eNewsCurrentSC, eNewsCurrentparam, "@enewscurrentdatestring"); MyDsCurrent.DataSetName = "CurrentMonth"; // Set the current eNewsletter box labels. eNewsLableLogic(MyDsCurrent); // Determine if there is a new blog post within the last 7 days. DateTime BlogDateValue = dt.AddDays(-7).Date; DataTable dtable = appcode.AcessDataTable(BlogDateValue); if (dtable.Rows.Count != 0) { ImageButton2.ImageUrl = @"~/images/NewPostBlog.gif"; } else { ImageButton2.ImageUrl = "~/images/Arc_Blog-man.jpg"; } }
protected void Button4_Click(object sender, EventArgs e) { //Find todays date, and place it in the hidden text box... Submit_Time.Text = DateTime.Today.Date.ToShortDateString(); //Set which times were selected in the form, and place those times in the hiddend text boxes. if (RadioButton1.Checked) { Pref_Time.Text = RadioButton1.Text; } else if (RadioButton2.Checked) { Pref_Time.Text = RadioButton2.Text; } if (RadioButton3.Checked) { Second_Time.Text = RadioButton3.Text; } else if (RadioButton4.Checked) { Second_Time.Text = RadioButton4.Text; } if (RadioButton5.Checked) { Third_Time.Text = RadioButton5.Text; } else if (RadioButton6.Checked) { Third_Time.Text = RadioButton6.Text; } //Submit to the database. try { //AccessDataSource1.Insert(); SqlConnection conn = null; SqlDataReader rdr = null; conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Home_ARC_ORGConnectionString"].ToString()); conn.Open(); SqlCommand cmd = new SqlCommand("Donation_Insert", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("Donor_Name", TextBox1.Text)); cmd.Parameters.Add(new SqlParameter("Phone_Number", TextBox2.Text)); cmd.Parameters.Add(new SqlParameter("Address", TextBox3.Text)); cmd.Parameters.Add(new SqlParameter("Address2", TextBox8.Text)); cmd.Parameters.Add(new SqlParameter("City", TextBox9.Text)); cmd.Parameters.Add(new SqlParameter("State", DropDownList2.SelectedValue)); cmd.Parameters.Add(new SqlParameter("Zipcode", TextBox11.Text)); cmd.Parameters.Add(new SqlParameter("Item_Number", DropDownList1.SelectedValue)); if (TextBox4.Text != "Click to Select") { cmd.Parameters.Add(new SqlParameter("Preferred_Date", TextBox4.Text)); } cmd.Parameters.Add(new SqlParameter("Preferred_Time", Pref_Time.Text)); if (TextBox5.Text != "Click to Select") { cmd.Parameters.Add(new SqlParameter("Second_Date", TextBox5.Text)); } cmd.Parameters.Add(new SqlParameter("Second_Time", Second_Time.Text)); if (TextBox6.Text != "Click to Select") { cmd.Parameters.Add(new SqlParameter("Third_Date", TextBox6.Text)); } cmd.Parameters.Add(new SqlParameter("Third_Time", Third_Time.Text)); cmd.Parameters.Add(new SqlParameter("Comments", TextBox7.Text)); cmd.Parameters.Add(new SqlParameter("Submit_Date", Submit_Time.Text)); cmd.Parameters.Add(new SqlParameter("Email_Address", Email_Addr.Text)); rdr = cmd.ExecuteReader(); rdr.Close(); } catch ( Exception m) { if (!ClientScript.IsStartupScriptRegistered("alert")) { string message = "donor_email_fail_pop('" + m.Message + ", please contact the Website Administrator for help.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "donor_email_fail_pop", message, true); } } //Create an email. MailMessage NewMailMessage = new MailMessage(); MailAddress FromAddress = new MailAddress("*****@*****.**"); //Build To: Address list //DataView dv = (DataView)AccessDataSource2.Select(DataSourceSelectArguments.Empty); AppCode ac = new AppCode(); DataSet dv = ac.SelectQuery("Donation_Email_Select"); foreach (DataRow row in dv.Tables[0].Rows) { NewMailMessage.To.Add(Convert.ToString(row["Email_Address"])); } NewMailMessage.From = FromAddress; NewMailMessage.Subject = "A Donation Pickup has been requested!"; NewMailMessage.IsBodyHtml = true; //Email Body. string NewBody = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'><html><head><title></title><style type='text/css'>div {background: #0099CC; padding: 15px;}#header {background: white; padding: 10px; color: #2f4c7c;}.bottom_border {border-bottom-style: solid; border-bottom-color: black; border-bottom-width: 1px; }#Main_table {padding: 10px; color: white; background: #2f4c7c;}#top {background: #6A6A6A; height: 25px;}</style></head><body><div><div id='top'></div><div id='header'><h2>A Donation Pickup has been requested!</h2><br/><h3>Please review the requested times and dates below, and contact the donor to schedule a time for pickup.</h3><br/></div><div id='Main_table'><table style='margin-left: 35px'>"; NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Donors Name:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", TextBox1.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Donors Telephone Number:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", TextBox2.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Donors Email Address:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", Email_Addr.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Donors Address:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", TextBox3.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Donors Address2:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", TextBox8.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Donors City:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", TextBox9.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Donors State:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", DropDownList2.SelectedValue); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Donors Zip:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", TextBox11.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Number of Items to Pickup:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", DropDownList1.SelectedValue); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Preferred Pickup Date and Time:</h3></td><td class='bottom_border'><table><tr><td><h3 style='margin-right: 10px;'>{0}</h3></td><td><h3>{1}</h3></td></tr></table></td></tr>", TextBox4.Text, Pref_Time.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Secondary Pickup Date and Time:</h3></td><td class='bottom_border'><table><tr><td><h3 style='margin-right: 10px;'>{0}</h3></td><td><h3>{1}</h3></td></tr></table></td></tr>", TextBox5.Text, Second_Time.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Third Pickup Date and Time:</h3></td><td class='bottom_border'><table><tr><td><h3 style='margin-right: 10px;'>{0}</h3></td><td><h3>{1}</h3></td></tr></table></td></tr>", TextBox6.Text, Third_Time.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Donors Comments:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", TextBox7.Text); NewBody += string.Format("<tr><td class='bottom_border'><h3 style='margin-right: 15px'>Submitted Date:</h3></td><td class='bottom_border'><h3>{0}</h3></td></tr>", Submit_Time.Text); NewBody += "</table></div></div><br/></body></html>"; NewMailMessage.Body = NewBody; //Send the email. SmtpClient MyMailServer = new SmtpClient(); try { MyMailServer.Send(NewMailMessage); if (!ClientScript.IsStartupScriptRegistered("alert")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "donor_email_success_pop", "donor_email_success_pop('Your Donation Pickup Request has been sent! Thank you so much!');", true); } } catch (Exception m) { if (!ClientScript.IsStartupScriptRegistered("alert")) { string message = "donor_email_fail_pop('" + m.Message + ", please contact the Website Administrator for help.');"; Page.ClientScript.RegisterStartupScript(this.GetType(), "donor_email_fail_pop", message, true); } } Clear(); }