Code:
CREATE PROCEDURE [dbo].[_Insert_Cat_Request]
-- Add the parameters for the stored procedure here
@CompanyNm NVARCHAR(255) = NULL,
@ContactFirst NVARCHAR(255) = NULL,
@ContactLast NVARCHAR(255) = NULL,
@JobTtl NVARCHAR(255) = NULL,
@Addr1 NVARCHAR(255) = NULL,
@Addr2 NVARCHAR(255) = NULL,
@Town NVARCHAR(255) = NULL,
@County NVARCHAR(255) = NULL,
@PCode NVARCHAR(20) = NULL,
@TelArea NVARCHAR(20) = NULL,
@TelNo NVARCHAR(20) = NULL,
@FaxArea NVARCHAR(20) = NULL,
@FaxNo NVARCHAR(20) = NULL,
@Email NVARCHAR(255) = NULL,
@TypeBus NVARCHAR(50) = NULL,
@CompNotes NVARCHAR(255) = NULL,
@CompYrEnd NVARCHAR(9) = NULL,
@SizeBus NVARCHAR(6) = NULL,
@OtherTypeBus NVARCHAR(50) = NULL,
@ip_address NVARCHAR(50) = NULL
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
IF @CompanyNm = '' SET @CompanyNm = NULL
IF @ContactFirst = '' SET @ContactFirst = NULL
IF @ContactLast = '' SET @ContactLast = NULL
IF @JobTtl = '' SET @JobTtl = NULL
IF @Addr1 = '' SET @Addr1 = NULL
IF @Addr2 = '' SET @Addr2 = NULL
IF @Town = '' SET @Town = NULL
IF @County = '' SET @County = NULL
IF @PCode = '' SET @PCode = NULL
IF @TelArea = '' SET @TelArea = NULL
IF @TelNo = '' SET @TelNo = NULL
IF @FaxArea = '' SET @FaxArea = NULL
IF @FaxNo = '' SET @FaxNo = NULL
IF @Email = '' SET @Email = NULL
IF @TypeBus = '' SET @TypeBus = NULL
IF @CompNotes = '' SET @CompNotes = NULL
IF @CompYrEnd = '' SET @CompYrEnd = NULL
IF @SizeBus = '' SET @SizeBus = NULL
IF @OtherTypeBus = '' SET @OtherTypeBus = NULL
IF @ip_address = '' SET @ip_address = NULL
-- Insert statements for procedure here
INSERT INTO [dbo].[_Requests]
([ReqDtTm]
,[CompanyNm]
,[ContactFirst]
,[ContactLast]
,[JobTtl]
,[Addr1]
,[Addr2]
,[Town]
,[County]
,[PCode]
,[TelArea]
,[TelNo]
,[FaxArea]
,[FaxNo]
,[Email]
,[TypeBus]
,[CompNotes]
,[CompYrEnd]
,[SizeBus]
,[Processed]
,[Accepted]
,[CopiedToCRM]
,[OtherTypeBus]
,[ip_address])
VALUES
(GETDATE()
,@CompanyNm
,@ContactFirst
,@ContactLast
,@JobTtl
,@Addr1
,@Addr2
,@Town
,@County
,@PCode
,@TelArea
,@TelNo
,@FaxArea
,@FaxNo
,@Email
,@TypeBus
,@CompNotes
,@CompYrEnd
,@SizeBus
,0
,0
,0
,@OtherTypeBus
,@ip_address)
END
The aspx page:
Code:
// ------------------------------------------------------------------------------------------
// Copyright AspDotNetStorefront.com, 1995-2009. All Rights Reserved.
// http://www.aspdotnetstorefront.com
// For details on this license please visit the product homepage at the URL above.
// THE ABOVE NOTICE MUST REMAIN INTACT.
// ------------------------------------------------------------------------------------------
using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Data;
using System.Globalization;
using AspDotNetStorefrontCore;
using System.Data.SqlClient;
namespace AspDotNetStorefront
{
/// <summary>
/// Summary description for requestcatalog.
/// </summary>
public partial class requestcatalog : SkinBase
{
protected void Page_Load(object sender, System.EventArgs e)
{
if (AppLogic.AppConfigBool("GoNonSecureAgain"))
{
SkinBase.GoNonSecureAgain();
}
// this may be overwridden by the XmlPackage below!
SectionTitle = AppLogic.GetString("requestcatalog.aspx.1", SkinID, ThisCustomer.LocaleSetting);
reqFName.ErrorMessage = AppLogic.GetString("requestcatalog.aspx.9", SkinID, ThisCustomer.LocaleSetting);
reqLName.ErrorMessage = AppLogic.GetString("requestcatalog.aspx.11", SkinID, ThisCustomer.LocaleSetting);
reqAddr1.ErrorMessage = AppLogic.GetString("requestcatalog.aspx.14", SkinID, ThisCustomer.LocaleSetting);
reqCity.ErrorMessage = AppLogic.GetString("requestcatalog.aspx.18", SkinID, ThisCustomer.LocaleSetting);
reqZip.ErrorMessage = AppLogic.GetString("requestcatalog.aspx.22", SkinID, ThisCustomer.LocaleSetting);
/* ESE changes */
reqEmail.ErrorMessage = "Please enter your email address";
reqNotes.ErrorMessage = "Please give us more details of what you are looking for";
reqBusType.ErrorMessage = "Please choose a business type";
reqSTD.ErrorMessage = "Please enter the STD part of your telephone number";
reqTelNo.ErrorMessage = "Please enter your telephone number";
/* ESE changes */
if (!IsPostBack)
{
InitializePageContent();
}
}
public void btnContinue_OnClick(object sender, EventArgs e)
{
Page.Validate();
if (Page.IsValid)
{
string FormInput = "<b>" + AppLogic.GetString("requestcatalog.aspx.2", SkinID, ThisCustomer.LocaleSetting) + "</b><br/><br/>";
FormInput += "Customer Name: " + txtFirstName.Text + " " + txtLastName.Text + "<br/>\n";
FormInput += "Company: " + txtCompany.Text + "<br/>\n";
FormInput += "Job Title: " + txtJobTitle.Text + "<br/>\n";
FormInput += "Address1: " + txtAddr1.Text + "<br/>\n";
FormInput += "Address2: " + txtAddr2.Text + "<br/>\n";
FormInput += "City: " + txtCity.Text + "<br/>\n";
FormInput += "County: " + txtCounty.Text + "<br/>\n";
FormInput += "Postcode: " + txtZip.Text + "<br/>\n";
FormInput += "Tel No: (" + Company_Telephone_Area.Text + ") " + Company_Telephone.Text + "<br/>\n";
FormInput += "Fax No: (" + Company_Fax_Number_Area.Text + ") " + Company_Fax_Number.Text + "<br/>\n";
FormInput += "Email: " + From.Text + "<br/>\n";
FormInput += "Type of Business: " + ddlBusinessType.SelectedItem.Text + "<br/>\n";
FormInput += "Company Year End: " + ddlYearEnd.SelectedItem.Text + "<br/>\n";
FormInput += "Business Size: " + ddlBusinessSize.SelectedItem.Text + "<br/>\n";
FormInput += "Notes: " + Notes.Text + "<br/>\n<br/>\n";
lblSuccess.Text = String.Format(AppLogic.GetString("requestcatalog.aspx.4", SkinID, ThisCustomer.LocaleSetting), AppLogic.AppConfig("SE_MetaTitle"));
pnlCatalogRequest.Visible = false;
pnlSuccess.Visible = true;
/* ESE changes */
string sql = String.Empty;
sql = String.Format("@CompanyNm={0}", cleanString(txtCompany.Text));
sql += "," + String.Format("@ContactFirst={0}", cleanString(txtFirstName.Text));
sql += "," + String.Format("@ContactLast={0}", cleanString(txtLastName.Text));
sql += "," + String.Format("@JobTtl={0}", cleanString(txtJobTitle.Text));
sql += "," + String.Format("@Addr1={0}", cleanString(txtAddr1.Text));
sql += "," + String.Format("@Addr2={0}", cleanString(txtAddr2.Text));
sql += "," + String.Format("@Town={0}", cleanString(txtCity.Text));
sql += "," + String.Format("@County={0}", cleanString(txtCounty.Text));
sql += "," + String.Format("@PCode={0}", cleanString(txtZip.Text));
sql += "," + String.Format("@TelArea={0}", cleanString(Company_Telephone_Area.Text));
sql += "," + String.Format("@TelNo={0}", cleanString(Company_Telephone.Text));
sql += "," + String.Format("@FaxArea={0}", cleanString(Company_Fax_Number_Area.Text));
sql += "," + String.Format("@FaxNo={0}", cleanString(Company_Fax_Number.Text));
sql += "," + String.Format("@Email={0}", cleanString(From.Text));
sql += "," + String.Format("@TypeBus={0}", cleanString(ddlBusinessType.SelectedItem.Value));
sql += "," + String.Format("@CompNotes={0}", cleanString(Notes.Text));
sql += "," + String.Format("@CompYrEnd={0}", cleanString(ddlYearEnd.SelectedItem.Value));
sql += "," + String.Format("@SizeBus={0}", cleanString(ddlBusinessSize.SelectedItem.Value));
sql += "," + String.Format("@ip_address={0}", cleanString(ThisCustomer.LastIPAddress));
DB.ExecuteSQL("exec _Insert_Cat_Request " + sql);
String FromAddress = "yourname@yourdomainname.com"; // reply to
String ToAddress = "yourname@yourdomainname.com"; // destination
//String BotAddress = AppLogic.AppConfig("ReceiptEMailFrom");
String BotAddress = "yourname@yourdomainname.com"; // from
String Subject = "Catalogue Request";
AppLogic.SendMail(Subject, FormInput, true, BotAddress, BotAddress, ToAddress, ToAddress, "", FromAddress, AppLogic.MailServer());
/* ESE changes */
}
else
{
InitializePageContent();
}
}
private String cleanString(String pString)
{
pString = pString.Trim();
pString = DB.SQuote(pString);
return pString;
}
public void reqState_OnServerValidate(Object sender, ServerValidateEventArgs args)
{
if (args.Value == "0")
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
private void InitializePageContent()
{
SetMetaTags("Free ESE Catalogue - ESE Direct - Eastern Storage Equipment", "",
"Request your free catalogue from ESE Direct. Buy from a range of industrial products including shelving and racking!", "");
requestcatalog_aspx_7.Text = AppLogic.GetString("requestcatalog.aspx.7", SkinID, ThisCustomer.LocaleSetting);
requestcatalog_aspx_8.Text = AppLogic.GetString("requestcatalog.aspx.8", SkinID, ThisCustomer.LocaleSetting);
requestcatalog_aspx_10.Text = AppLogic.GetString("requestcatalog.aspx.10", SkinID, ThisCustomer.LocaleSetting);
requestcatalog_aspx_12.Text = AppLogic.GetString("requestcatalog.aspx.12", SkinID, ThisCustomer.LocaleSetting);
/* address_cs_58.Text = AppLogic.GetString("address.cs.58", SkinID, ThisCustomer.LocaleSetting);*/
requestcatalog_aspx_13.Text = AppLogic.GetString("requestcatalog.aspx.13", SkinID, ThisCustomer.LocaleSetting);
requestcatalog_aspx_15.Text = AppLogic.GetString("requestcatalog.aspx.15", SkinID, ThisCustomer.LocaleSetting);
/*requestcatalog_aspx_16.Text = AppLogic.GetString("requestcatalog.aspx.16", SkinID, ThisCustomer.LocaleSetting);*/
requestcatalog_aspx_17.Text = AppLogic.GetString("requestcatalog.aspx.17", SkinID, ThisCustomer.LocaleSetting);
/*requestcatalog_aspx_19.Text = AppLogic.GetString("requestcatalog.aspx.19", SkinID, ThisCustomer.LocaleSetting);*/
requestcatalog_aspx_21.Text = AppLogic.GetString("requestcatalog.aspx.21", SkinID, ThisCustomer.LocaleSetting);
/*requestcatalog_aspx_24.Text = AppLogic.GetString("requestcatalog.aspx.24", SkinID, ThisCustomer.LocaleSetting);*/
btnContinue.Text = AppLogic.GetString("requestcatalog.aspx.25", SkinID, ThisCustomer.LocaleSetting);
AppLogic.GetButtonDisable(btnContinue);
Address ShippingAddress = new Address();
ShippingAddress.LoadByCustomer(ThisCustomer.CustomerID,ThisCustomer.PrimaryBillingAddressID,AddressTypes.Shipping);
txtFirstName.Text = ShippingAddress.FirstName;
txtLastName.Text = ShippingAddress.LastName;
txtCompany.Text = ShippingAddress.Company;
txtAddr1.Text = ShippingAddress.Address1;
txtAddr2.Text = ShippingAddress.Address2;
txtCounty.Text = ShippingAddress.Suite;
txtCity.Text = ShippingAddress.City;
txtZip.Text = ShippingAddress.Zip;
From.Text = ShippingAddress.EMail;
/* ESE changes */
using (SqlConnection conn = DB.dbConn())
{
conn.Open();
using (IDataReader dr = DB.GetRS("select * from _eseBusiness with (NOLOCK) order by display_order, business_type", conn))
{
ddlBusinessType.DataSource = dr;
ddlBusinessType.DataTextField = "business_type";
ddlBusinessType.DataValueField = "business_type";
ddlBusinessType.DataBind();
}
}
ddlBusinessType.Items.Insert(0, new ListItem(AppLogic.GetString("requestcatalog.aspx.20", SkinID, ThisCustomer.LocaleSetting), ""));
ddlBusinessSize.Items.Insert(0, new ListItem("100+", "100+"));
ddlBusinessSize.Items.Insert(0, new ListItem("51-100", "51-100"));
ddlBusinessSize.Items.Insert(0, new ListItem("21-50", "21-50"));
ddlBusinessSize.Items.Insert(0, new ListItem("11-20", "11-20"));
ddlBusinessSize.Items.Insert(0, new ListItem("6-10", "6-10"));
ddlBusinessSize.Items.Insert(0, new ListItem("1-5", "1-5"));
ddlBusinessSize.Items.Insert(0, new ListItem(AppLogic.GetString("requestcatalog.aspx.20", SkinID, ThisCustomer.LocaleSetting), ""));
ddlYearEnd.Items.Insert(0, new ListItem("December", "December"));
ddlYearEnd.Items.Insert(0, new ListItem("November", "November"));
ddlYearEnd.Items.Insert(0, new ListItem("October", "October"));
ddlYearEnd.Items.Insert(0, new ListItem("September", "September"));
ddlYearEnd.Items.Insert(0, new ListItem("August", "August"));
ddlYearEnd.Items.Insert(0, new ListItem("July", "July"));
ddlYearEnd.Items.Insert(0, new ListItem("June", "June"));
ddlYearEnd.Items.Insert(0, new ListItem("May", "May"));
ddlYearEnd.Items.Insert(0, new ListItem("April", "April"));
ddlYearEnd.Items.Insert(0, new ListItem("March", "March"));
ddlYearEnd.Items.Insert(0, new ListItem("February", "February"));
ddlYearEnd.Items.Insert(0, new ListItem("January", "January"));
ddlYearEnd.Items.Insert(0, new ListItem(AppLogic.GetString("requestcatalog.aspx.20", SkinID, ThisCustomer.LocaleSetting), ""));
/* ESE changes */
/*
using (SqlConnection conn = DB.dbConn())
{
conn.Open();
using (IDataReader dr = DB.GetRS("select * from State with (NOLOCK) order by DisplayOrder,Name", conn))
{
ddlState.DataSource = dr;
ddlState.DataTextField = "name";
ddlState.DataValueField = "Abbreviation";
ddlState.DataBind();
}
}
ddlState.Items.Insert(0, new ListItem(AppLogic.GetString("requestcatalog.aspx.20", SkinID, ThisCustomer.LocaleSetting), "0"));
ddlState.SelectedValue = ShippingAddress.State;
using (SqlConnection conn = DB.dbConn())
{
conn.Open();
using (IDataReader dr2 = DB.GetRS("select * from Country with (NOLOCK) where Published = 1 order by DisplayOrder,Name", conn))
{
ddlCountry.DataSource = dr2;
ddlCountry.DataTextField = "Name";
ddlCountry.DataValueField = "Name";
ddlCountry.DataBind();
}
}
ddlCountry.Items.Insert(0, new ListItem(AppLogic.GetString("requestcatalog.aspx.20", SkinID, ThisCustomer.LocaleSetting), "0"));
ddlCountry.SelectedValue = ShippingAddress.Country;
*/
}
protected void ImgContinue_Click(object sender, EventArgs e)
{
Page.Validate();
if (Page.IsValid)
{
string FormInput = "<b>" + AppLogic.GetString("requestcatalog.aspx.2", SkinID, ThisCustomer.LocaleSetting) + "</b><br/><br/>";
FormInput += "Customer Name: " + txtFirstName.Text + " " + txtLastName.Text + "<br/>\n";
FormInput += "Company: " + txtCompany.Text + "<br/>\n";
FormInput += "Job Title: " + txtJobTitle.Text + "<br/>\n";
FormInput += "Address1: " + txtAddr1.Text + "<br/>\n";
FormInput += "Address2: " + txtAddr2.Text + "<br/>\n";
FormInput += "City: " + txtCity.Text + "<br/>\n";
FormInput += "County: " + txtCounty.Text + "<br/>\n";
FormInput += "Postcode: " + txtZip.Text + "<br/>\n";
FormInput += "Tel No: (" + Company_Telephone_Area.Text + ") " + Company_Telephone.Text + "<br/>\n";
FormInput += "Fax No: (" + Company_Fax_Number_Area.Text + ") " + Company_Fax_Number.Text + "<br/>\n";
FormInput += "Email: " + From.Text + "<br/>\n";
FormInput += "Type of Business: " + ddlBusinessType.SelectedItem.Text + "<br/>\n";
FormInput += "Company Year End: " + ddlYearEnd.SelectedItem.Text + "<br/>\n";
FormInput += "Business Size: " + ddlBusinessSize.SelectedItem.Text + "<br/>\n";
FormInput += "Notes: " + Notes.Text + "<br/>\n<br/>\n";
lblSuccess.Text = String.Format(AppLogic.GetString("requestcatalog.aspx.4", SkinID, ThisCustomer.LocaleSetting), AppLogic.AppConfig("SE_MetaTitle"));
pnlCatalogRequest.Visible = false;
pnlSuccess.Visible = true;
/* ESE changes */
string sql = String.Empty;
sql = String.Format("@CompanyNm={0}", cleanString(txtCompany.Text));
sql += "," + String.Format("@ContactFirst={0}", cleanString(txtFirstName.Text));
sql += "," + String.Format("@ContactLast={0}", cleanString(txtLastName.Text));
sql += "," + String.Format("@JobTtl={0}", cleanString(txtJobTitle.Text));
sql += "," + String.Format("@Addr1={0}", cleanString(txtAddr1.Text));
sql += "," + String.Format("@Addr2={0}", cleanString(txtAddr2.Text));
sql += "," + String.Format("@Town={0}", cleanString(txtCity.Text));
sql += "," + String.Format("@County={0}", cleanString(txtCounty.Text));
sql += "," + String.Format("@PCode={0}", cleanString(txtZip.Text));
sql += "," + String.Format("@TelArea={0}", cleanString(Company_Telephone_Area.Text));
sql += "," + String.Format("@TelNo={0}", cleanString(Company_Telephone.Text));
sql += "," + String.Format("@FaxArea={0}", cleanString(Company_Fax_Number_Area.Text));
sql += "," + String.Format("@FaxNo={0}", cleanString(Company_Fax_Number.Text));
sql += "," + String.Format("@Email={0}", cleanString(From.Text));
sql += "," + String.Format("@TypeBus={0}", cleanString(ddlBusinessType.SelectedItem.Value));
sql += "," + String.Format("@CompNotes={0}", cleanString(Notes.Text));
sql += "," + String.Format("@CompYrEnd={0}", cleanString(ddlYearEnd.SelectedItem.Value));
sql += "," + String.Format("@SizeBus={0}", cleanString(ddlBusinessSize.SelectedItem.Value));
sql += "," + String.Format("@ip_address={0}", cleanString(ThisCustomer.LastIPAddress));
DB.ExecuteSQL("exec _Insert_Cat_Request " + sql);
String FromAddress = "yourname@yourdomainname.com"; // reply to
String ToAddress = "yourname@yourdomainname.com"; // destination
//String BotAddress = AppLogic.AppConfig("ReceiptEMailFrom");
String BotAddress = "yourname@yourdomainname.com"; // from
String Subject = "Catalogue Request";
AppLogic.SendMail(Subject, FormInput, true, BotAddress, BotAddress, ToAddress, ToAddress, "", FromAddress, AppLogic.MailServer());
/* ESE changes */
}
else
{
InitializePageContent();
}
}
}
}
Happy customising!