using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Net.Mail;
using System.Net.Sockets;
namespace Datamationinternational
{
public partial class GuestRegistration : System.Web.UI.Page
{
string strConnection;
OleDbConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnsubmit_Click(object sender, EventArgs e)
{
string valid = string.Empty;
if (txtname.Text == "" || txtcity.Text == "" || ddlcountry.Text == "" || txtphone.Text == "" || txtemail.Text == "")
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "scriptkey", "alert('Enter Name');");
}
else
{
try
{
strConnection = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString.ToString();
conn = new OleDbConnection(strConnection);
string ck1val, ck2val, ck3val, ck4val, ck5val, ck6val, ck7val, ck8val, ck9val, ck10val, ck11val, ck12val, ck13val, ck14val, ck15val, ck16val, ck17val, ck18val;
if (ck1.Checked == true)
{
ck1val = "1";
}
else
{
ck1val = "0";
}
if (ck2.Checked == true)
{
ck2val = "1";
}
else
{
ck2val = "0";
}
if (ck3.Checked == true)
{
ck3val = "1";
}
else
{
ck3val = "0";
}
if (ck4.Checked == true)
{
ck4val = "1";
}
else
{
ck4val = "0";
}
if (ck5.Checked == true)
{
ck5val = "1";
}
else
{
ck5val = "0";
}
if (ck6.Checked == true)
{
ck6val = "1";
}
else
{
ck6val = "0";
}
if (ck7.Checked == true)
{
ck7val = "1";
}
else
{
ck7val = "0";
}
if (ck8.Checked == true)
{
ck8val = "1";
}
else
{
ck8val = "0";
}
if (ck9.Checked == true)
{
ck9val = "1";
}
else
{
ck9val = "0";
}
if (ck10.Checked == true)
{
ck10val = "1";
}
else
{
ck10val = "0";
}
if (ck11.Checked == true)
{
ck11val = "1";
}
else
{
ck11val = "0";
}
if (ck12.Checked == true)
{
ck12val = "1";
}
else
{
ck12val = "0";
}
if (ck13.Checked == true)
{
ck13val = "1";
}
else
{
ck13val = "0";
}
if (ck14.Checked == true)
{
ck14val = "1";
}
else
{
ck14val = "0";
}
if (ck15.Checked == true)
{
ck15val = "1";
}
else
{
ck15val = "0";
}
if (ck16.Checked == true)
{
ck16val = "1";
}
else
{
ck16val = "0";
}
if (ck17.Checked == true)
{
ck17val = "1";
}
else
{
ck17val = "0";
}
if (ck18.Checked == true)
{
ck18val = "1";
}
else
{
ck18val = "0";
}
string strquery = "Insert into GuestRegistration(Name, JobTitle, Company, Address, City, State, Zip, Country, Phone, Email, OrganizationIndustry, OrganizationSize, FindOutDatamation, Datamation_Newsletters, Application_Development, Learn_About_DataMation, InfornationProcessingManagement, ScanningDataCapture, DocumentRecordManagement, ContentDocumentManagement, DigitalDirectPromotions, CMR, MarketResearch, BusinessProcessManagement, SocioEconomicResearch, ConsultingServices, FieldSurveys, ProcessImprovement, TranningCapacity, EvaluationsAssesment, DataAnalytics, Message) Values ('" + txtname.Text + "', '" + txtjobtitle.Text + "', '" + txtcompany.Text + "', '" + txtAddress.Text + "', '" + txtcity.Text + "', '" + ddlstate.SelectedItem.Text + "', '" + txtzip.Text + "', '" + ddlcountry.SelectedItem.Text + "', '" + txtphone.Text + "', '" + txtemail.Text + "', '" + txtorgindustry.Text + "', '" + txtorgsize.Text + "', '" + txtfindout.Text + "', '" + ck1val + "','" + ck2val + "','" + ck3val + "','" + ck4val + "','" + ck5val + "','" + ck6val + "','" + ck7val + "','" + ck8val + "','" + ck9val + "','" + ck10val + "','" + ck11val + "','" + ck12val + "','" + ck13val + "','" + ck14val + "','" + ck15val + "','" + ck16val + "','" + ck17val + "','" + ck18val + "','" + txtmessage.Text + "')";
//string strquery = "Insert into GuestRegistration(Name, JobTitle, Company, Address, City, State, Zip, Country, Phone, Email, OrganizationIndustry, FindOutDatamation) Values ('" + txtname.Text + "', '" + txtjobtitle.Text + "', '" + txtcompany.Text + "', '" + txtAddress.Text + "', '" + txtcity.Text + "', '" + ddlstate.SelectedItem.Text + "', '" + txtzip.Text + "', '" + ddlcountry.SelectedItem.Text + "', '" + txtphone.Text + "', '" + txtemail.Text + "', '" + txtorgindustry.Text + "', '" + txtorgsize.Text + "', '" + txtfindout.Text + "')";
conn.Open();
OleDbCommand cmd = new OleDbCommand(strquery, conn);
cmd.ExecuteNonQuery();
valid = "Y";
}
catch (Exception ex)
{
lblstatus.Text = ex.Message;
lblstatus.ForeColor = System.Drawing.Color.Red;
}
finally
{
conn.Close();
}
}
if (valid == "Y")
{
lblname.Text = "Thank You" + " " + txtname.Text +".";
lblstatus.Text = "Your message has been sent successfully.";
lblstatus.ForeColor = System.Drawing.Color.Green;
sendEmail();
clearField();
}
}
public void clearField()
{
txtname.Text = "";
txtjobtitle.Text = "";
txtcompany.Text = "";
txtAddress.Text = "";
txtcity.Text = "";
ddlstate.Text = "State";
txtzip.Text = "";
ddlcountry.Text = "India";
txtphone.Text = "";
txtemail.Text = "";
txtorgindustry.Text = "";
txtorgsize.Text = "";
txtfindout.Text = "";
ck1.Checked = false;
ck2.Checked = false;
ck3.Checked = false;
ck4.Checked = false;
ck5.Checked = false;
ck6.Checked = false;
ck7.Checked = false;
ck8.Checked = false;
ck9.Checked = false;
ck10.Checked = false;
ck11.Checked = false;
ck12.Checked = false;
ck13.Checked = false;
ck14.Checked = false;
ck15.Checked = false;
ck16.Checked = false;
ck17.Checked = false;
ck18.Checked = false;
txtmessage.Text = "";
}
public void sendEmail()
{
try
{
MailMessage mail = new MailMessage();
mail.To.Add("******@datamationinternational.com.Text");
mail.From = new MailAddress("******@datamationinternational.com");
mail.Subject = "Guest Registration at DataMation";
string Body = "Thank You" + " " + txtname.Text + " " + "For Registration at DataMation Group.";
//string Body = "@<table><tr><td>Thank You " + txtname.Text + "</td></tr><tr><td> Thanks & Regards</td></tr><tr><td> DataMation Group</td></tr></table>";
mail.Body = Body;
SmtpClient client =new SmtpClient();
smtp.Host = "touran.websitewelcome.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = true;
smtp.Credentials = new System.Net.NetworkCredential("******@datamationinternational.com", "datamation361");
smtp.EnableSsl = true;
smtp.Send(mail);
lblstatus.Text = "Email has been sent successfully !";
lblstatus.ForeColor = System.Drawing.Color.Green;
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}
}
}