using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Configuration; using System.Data; public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString); con.Open(); string cmdStr = "select count (*) from Table1 where EmailAddress='" + TextBoxEA.Text + "'"; SqlCommand userExist = new SqlCommand(cmdStr, con); SqlCommand insertcmd = new SqlCommand("insert into Table1", con); SqlDataAdapter dap = new SqlDataAdapter(insertcmd); int temp = Convert.ToInt32(userExist.ExecuteScalar().ToString()); con.Close(); if (temp == 0) lblMessage.Text = "Invalid User Name and Password"; } } protected void Button1_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["PasswordConnectionString"].ConnectionString); con.Open(); if (true) { SqlCommand level = new SqlCommand("select accessLevel, Password, INST_ID from Table1 where EmailAddress = @EmailAddress AND Password = @Password", con); level.Parameters.Add(new SqlParameter("EmailAddress", TextBoxEA.Text)); level.Parameters.Add(new SqlParameter("Password", TextBoxPW.Text)); SqlDataReader reader = level.ExecuteReader(); DataTable dt1 = new DataTable(); dt1.Load(reader); foreach (DataRow dr1 in dt1.Rows) { int returnedLevel = Convert.ToInt32(dr1[0].ToString()); int inst_id = Convert.ToInt32(dr1[2].ToString()); Session["inst_id"] = inst_id; if (returnedLevel == 1) { Response.Redirect("FormAPublic.aspx"); } else if (returnedLevel == 2) { Response.Redirect("FormCPrivateNon.aspx"); } else if (returnedLevel == 3) { Response.Redirect("FormDPrivateFor.aspx"); } else if (returnedLevel == 7) { Response.Redirect("CEOPage.aspx"); } else if (returnedLevel == 8) { Response.Redirect("DBPage.aspx"); } else if (returnedLevel == 11) { Response.Redirect("FormAPublicL.aspx"); } else if (returnedLevel == 21) { Response.Redirect("FormCPrivateNonL.aspx"); } else if (returnedLevel == 31) { Response.Redirect("FormDPrivateForL.aspx"); } else if (returnedLevel == 0) { lblMessage.Text = "Invalid UserName and Password"; } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)