using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using System.Collections.Generic;


public partial class Controls_PledgeBox : System.Web.UI.UserControl
{
			   	protected System.Web.UI.WebControls.Table tblPledge;
			   
    protected void Page_Load(object sender, EventArgs e)
    {

    }

			   	private void InitializeComponent()
				   {
				   
				   }

    protected void btnAddToMailingList_Click(object sender, EventArgs e)
    {

        int numberPledges = Int32.Parse(SqlHelper.ExecuteScalar(CommandType.Text, "SELECT count(ID) FROM Pledges WHERE EmailAddress = '" + txtEmail.Text + "'").ToString());

        if (numberPledges < 1)
        {
            SqlHelper.ExecuteNonQuery(CommandType.Text, "INSERT INTO Pledges ( EmailAddress,User_IP,DateAdded ) VALUES(  '" + txtEmail.Text + "', '" + Request.ServerVariables["REMOTE_ADDR"].ToString() + "', GETDATE())");
        }

        pnlButton.Visible = false;
        pnlResults.Visible = true;
        lblResults.Text = "Thank you for pledging your support of Dr. Sabrin!";
    }
}
