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.Web.Configuration; using System.Data.SqlClient; public partial class MasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } protected void SignUpButton_Click(object sender, EventArgs e) { Response.Redirect("~/SignUp.aspx"); } protected void LoginButton_Click(object sender, EventArgs e) { string con = WebConfigurationManager.ConnectionStrings["ConnectionStringMovies"].ConnectionString; SqlConnection connection = new SqlConnection(con); SqlCommand command = new SqlCommand("FindUser", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@LoginName", SqlDbType.NVarChar, 50)); command.Parameters.Add(new SqlParameter("@Password", SqlDbType.NVarChar, 100)); command.Parameters["@LoginName"].Value = UserName.Text; command.Parameters["@Password"].Value = Password.Text; try { string role = ""; ArrayList list= new ArrayList(1) ; connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { for (int i = 0; i < reader.FieldCount; i++) { list.Add(reader.GetValue(i)); } } Session["UserId"] = list[0]; role = (string)list[1]; Session["Role"] = list[1]; if ( role.StartsWith ("User")) { LblError.Text = "Welcome " + UserName.Text + " your login success :))"; } else if (role.StartsWith ("Admin")) { Response.Redirect("~/Manage.aspx"); } } else { LblError.Text = "Login Name or password is incorrect"; } reader.Close(); } catch { LblError.Text = "There is a problem try again:(("; } finally { connection.Close(); } } protected void DlsCategory_SelectedIndexChanged(object sender, EventArgs e) { DlsCategory.DataBind(); Session["CategoryId"]=DlsCategory.SelectedValue .ToString (); Response .Redirect ("~/Movies.aspx"); } }