-
Notifications
You must be signed in to change notification settings - Fork 1
/
Home.aspx.cs
43 lines (41 loc) · 1.6 KB
/
Home.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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.SqlClient;
using System.Configuration;
public partial class Home : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mycon"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = "CUS_0" + ID();
TextBox1.ReadOnly = true;
}
public int ID()
{
con.Open();
int ID = 0;
SqlCommand cmd = new SqlCommand("select count(*) from cusreg", con);
ID = Convert.ToInt32(cmd.ExecuteScalar()) + 1;
con.Close();
return ID;
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into cusreg (cusid,cusname,genderr,mailidd,mobno,statee,cityy,pinn) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + DropDownList1.SelectedItem.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox10.Text + "','" + TextBox11.Text + "','" + TextBox3.Text + "')", con);
int i = cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(Page.GetType(), "Validation", "<script language='javascript'>alert('Registered Successfully..');window.location='Customer.aspx';</script>");
}
catch (Exception)
{
Response.Write("<script>alert('Already Emailid Exist')</script>");
}
}
}