Final Project
| Registration form project |
CODING-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class RegPage : System.Web.UI.Page
{
SqlConnection cn;
SqlCommand cm;
SqlDataReader dr;
FinalClass fc = new FinalClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
statedisplay();
}
}
protected void connect()
{
string s = ConfigurationManager.AppSettings["Ch_Db"];
cn = new SqlConnection(s);
cn.Open();
}
protected void statedisplay()
{
connect();
string q = fc.sel_reg_state();
cm = new SqlCommand(q,cn);
dr = cm.ExecuteReader();
StateDropDownList.DataSource = dr;
StateDropDownList.DataTextField = "state";
StateDropDownList.DataBind();
StateDropDownList.Items.Insert(0, "Select");
}
protected void city_add()
{
connect();
string q = fc.sel_reg_state_All() + " " + "state= '" + StateDropDownList.Text + "'";
cm = new SqlCommand(q,cn);
dr = cm.ExecuteReader();
CityDropDownList.DataSource = dr;
CityDropDownList.DataTextField = "city";
CityDropDownList.DataBind();
}
protected void id_generate()
{
connect();
string q =fc.id_gen();
cm = new SqlCommand(q,cn);
}
protected void Button2_Click(object sender, EventArgs e)
{
if (CheckBox1.Checked == false)
{
Response.Write("Accept all the policies");
}
else
{
connect();
id_generate();
string k = "REG-2021-00" + cm.ExecuteScalar();
idtxt.Text = k;
string q = fc.ins_regdb() + "('"+cm.ExecuteScalar()+"',@name1,'" + txtemail.Text + "','" + txtmobile.Text + "','" + StateDropDownList.Text + "','" + CityDropDownList.Text + "','" + lblpass.Text + "','" + k + "')";
cm = new SqlCommand(q, cn);
cm.Parameters.AddWithValue("name1", txtname.Text);
cm.ExecuteNonQuery();
}
}
protected void StateDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
city_add();
}
protected void uploadbtn_Click(object sender, EventArgs e)
{
FileUpload1.SaveAs(Server.MapPath("~") + "//upload//" + FileUpload1.FileName);
lblpass.Text = FileUpload1.FileName;
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("login.aspx");
}
}
| Grid View Project |
CODING-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class GridViewTest : System.Web.UI.Page
{
SqlConnection cn;
SqlCommand cm;
SqlDataReader dr;
FinalClass fc = new FinalClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
display();
}
}
protected void connect()
{
string s = ConfigurationManager.AppSettings["Ch_Db"];
cn = new SqlConnection(s);
cn.Open();
}
protected void display()
{
connect();
string q = fc.sel_regdb();
cm = new SqlCommand(q, cn);
dr = cm.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
dr.Close();
}
protected void id_generate()
{
connect();
string q = fc.id_gen();
cm = new SqlCommand(q, cn);
}
protected void edit_click(object sender, EventArgs e)
{
connect();
GridViewRow gr1 = ((Button)sender).NamingContainer as GridViewRow;
Button b1 = (Button)gr1.FindControl("editbtn");
TextBox t1 = (TextBox)gr1.FindControl("NameTextBox");
TextBox t2 = (TextBox)gr1.FindControl("EmailTextBox");
TextBox t3 = (TextBox)gr1.FindControl("MobileTextBox");
TextBox t4 = (TextBox)gr1.FindControl("StateTextBox");
TextBox t5 = (TextBox)gr1.FindControl("CityTextBox");
t1.ReadOnly = false;
t2.ReadOnly = false;
t3.ReadOnly = false;
t4.ReadOnly = false;
t5.ReadOnly = false;
}
protected void update_click(object sender, EventArgs e)
{
connect();
GridViewRow gr1 = ((Button)sender).NamingContainer as GridViewRow;
Button b1 = (Button)gr1.FindControl("updbtn");
TextBox t1 = (TextBox)gr1.FindControl("NameTextBox");
TextBox t2 = (TextBox)gr1.FindControl("EmailTextBox");
TextBox t3 = (TextBox)gr1.FindControl("MobileTextBox");
TextBox t4 = (TextBox)gr1.FindControl("StateTextBox");
TextBox t5 = (TextBox)gr1.FindControl("CityTextBox");
string q = fc.upd_regdb()+ " " + "name='" + t1.Text + "',mobile='" + t3.Text + "',state='" + t4.Text + "',city='" + t5.Text + "' where email = '" + t2.Text + "'";
cm = new SqlCommand(q, cn);
cm.ExecuteNonQuery();
display();
}
protected void del_click(object sender, EventArgs e)
{
connect();
GridViewRow gr1 = ((Button)sender).NamingContainer as GridViewRow;
Button b1 = (Button)gr1.FindControl("updbtn");
TextBox t1 = (TextBox)gr1.FindControl("NameTextBox");
TextBox t2 = (TextBox)gr1.FindControl("EmailTextBox");
TextBox t3 = (TextBox)gr1.FindControl("MobileTextBox");
TextBox t4 = (TextBox)gr1.FindControl("StateTextBox");
TextBox t5 = (TextBox)gr1.FindControl("CityTextBox");
string q = fc.del_regdb() + " " + "email = '" + t2.Text + "'";
cm = new SqlCommand(q, cn);
cm.ExecuteNonQuery();
display();
}
protected void footer_btn(object sender, EventArgs e)
{
connect();
id_generate();
string k = "REG-2021-00" + cm.ExecuteScalar();
GridViewRow gr1 = ((Button)sender).NamingContainer as GridViewRow;
Button b1 = (Button)gr1.FindControl("addbtn");
TextBox t1 = (TextBox)gr1.FindControl("txtfootname");
TextBox t2 = (TextBox)gr1.FindControl("txtfootemail");
TextBox t3 = (TextBox)gr1.FindControl("txtfootmobile");
TextBox t4 = (TextBox)gr1.FindControl("txtfootstate");
TextBox t5 = (TextBox)gr1.FindControl("txtfootcity");
string q = fc.ins_regdb_few() + "('"+cm.ExecuteScalar()+"',@name1,'" + t2.Text + "','" + t3.Text + "','" + t4.Text + "','" + t5.Text + "','"+k+"')";
cm = new SqlCommand(q, cn);
cm.Parameters.AddWithValue("name1", t1.Text);
cm.ExecuteNonQuery();
display();
}
}
LOGIN PAGE CODING_
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
public partial class login : System.Web.UI.Page
{
SqlConnection cn;
SqlCommand cm;
SqlDataReader dr;
static int count;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void connect()
{
string s = ConfigurationManager.AppSettings["Ch_Db"];
cn = new SqlConnection(s);
cn.Open();
}
protected void pass_check()
{
connect();
string q = "select * from Reg_ChitranshDb where email = '" + txtemail.Text + "' and pass='" + lblpass.Text + "'";
cm = new SqlCommand(q, cn);
dr = cm.ExecuteReader();
}
protected void count_pick(int count)
{
if (count == 1)
{
Response.Write("You have 1 chance left");
txtemail.Text = "";
lblpass.Text = "";
}
else if (count == 2)
{
Response.Write("Password locked");
txtemail.Enabled = false;
FileUpload1.Enabled = false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
count = 0;
pass_check();
if (dr.Read())
{
Response.Write("Successfully login");
count = 0;
}
else
{
count++;
Response.Write("Login failed ");
if (count == 1)
{
count_pick(count);
Button1.Visible = true;
logbtn.Enabled = false;
}
}
}
protected void upload_btn_Click(object sender, EventArgs e)
{
lblpass.Text = FileUpload1.FileName;
}
protected void Button1_Click1(object sender, EventArgs e)
{
pass_check();
if (dr.Read())
{
Response.Write("success");
}
else
{
count = 2;
count_pick(count);
}
}
}
Comments
Post a Comment