using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace store_2
{
public partial class regc : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["registrationconnectionString"].ConnectionString);
con.Open();
string checkuser = "select count(*)from the customertable where the User_name='" + TextBoxusername.Text + "'";
SqlCommand com = new SqlCommand(checkuser, con);
int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
if (temp == 1)
{
Response.Write("User alredy exixts");
}
con.Close();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["registrationconnectionString"].ConnectionString);
con.Open();
string insertQuery = "insert into customertable(User_name,Name,Gender,Adress,City,State,Pin_code,mobile_no,Email_id,Password,product_id,Product_Quntity) values (@User_name,@Name,@Gender,@Adress,@City,@State,@Pin_code,@mobile_no,@Email_id,@Password,@product_id,@Product_Quntity)";
SqlCommand com = new SqlCommand(insertQuery, con);
com.Parameters.AddWithValue("@User_name", TextBoxusername.Text);
com.Parameters.AddWithValue("@Name", TextBoxname.Text);
com.Parameters.AddWithValue("@Gender", TextBoxname.Text);
com.Parameters.AddWithValue("@Adress", TextBoxadress.Text);
com.Parameters.AddWithValue("@City", DropDownListcity.SelectedItem.ToString());
com.Parameters.AddWithValue("@State", DropDownListstate.SelectedItem.ToString());
com.Parameters.AddWithValue("@Pin_code", TextBoxpincode.Text);
com.Parameters.AddWithValue("@mobile_no", TextBoxmobno.Text);
com.Parameters.AddWithValue("@Email_id", TextBoxemail.Text);
com.Parameters.AddWithValue("@Password", TextBoxpassword.Text);
com.ExecuteNonQuery();
Response.Redirect("admin.aspx");
Response.Write("Registration Is Successful");
con.Close();
}
catch (Exception ex)
{
Response.Write("Error:" + ex.ToString());
}
}
}
}