I have created one inventry application.In that i have created login form.But in login form i want to login locationwise that mumbai,pune,banglore etc....means mumbai person have diffent login ,pune person have different login....Please suggest code for this...It is on high priority....
ThanksDiv
Amol SonavanePosted May 14, 2015, 7:47 AM
Amol SonavanePosted May 14, 2015, 7:44 AM
Munesh SharmaPosted May 14, 2015, 7:42 AM
here location you can give in Dropdown also,
And at the time of Login you can check with location
Dipankar BiswasPosted May 14, 2015, 7:22 AM
try it..
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select * from employee where username=@username and password=@password", con);
cmd.Parameters.AddWithValue("@username", TextBox1.Text);
cmd.Parameters.AddWithValue("@password", TextBox2.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
string type = (dt.Rows[0]["type"]).ToString().Trim() ;
// store your type row cell value in variable to check condition
if (type =="Manager")
{
Session["USERID"] = TextBox1.Text;
Response.Redirect("Manager.aspx");
}
else if (type =="Salesperson")
{
Session["USERID"] = TextBox1.Text;
Response.Redirect("Salesperson.aspx");
}
else if (type =="SoftwareEngineer")
{
Session["USERID"] = TextBox1.Text;
Response.Redirect("Engineer.aspx");
}
else
{
Response.Write("Not Exists");
}
}
else
{
ClientScript.RegisterStartupScript(Page.GetType(),
"validation", "");
}
see details....http://www.c-sharpcorner.com/Blogs/14469/
Khargesh RajputPosted May 14, 2015, 7:13 AM
and at the login time you have to check
loginanme from textbox
password from textbox
location from dropdownlist
select * from table where username="loginname" and password="pwd" and location="location"
here you may pass location directly or use another table for location and from login table you can select locationid with reference to location table
also refer below tutorial
here add location field according to your choice
http://www.msdotnet.co.in/2013/04/how-to-make-registration-and-login-form.html#.VVSFnJOO7cc