public string checkLogin(string username, string password, RoleAccount roleStr) { SqlConnection conn = new SqlConnection(connStr); String sqlQuery = "select FullName, Status from UserAccount " + "where Username = @username and Password= @password and Role=@role"; SqlCommand command = new SqlCommand(sqlQuery, conn); if (roleStr.ToString().Equals("Admin")) { command.Parameters.AddWithValue("@role", 1); } else { command.Parameters.AddWithValue("@role", 0); } command.Parameters.AddWithValue("@username", username); command.Parameters.AddWithValue("@password", password); if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlDataReader dr = command.ExecuteReader(CommandBehavior.CloseConnection); if (dr.HasRows) { dr.Read(); string status = dr.GetString(1); if (status.Equals("Blocked")) { return("UserBlocked"); } else { string fullname = dr.GetString(0); return(fullname); } } return(null); }
public UserLogin(IIdentity identity, RoleAccount roles) : base(identity, new string[] { roles.ToString() }) { }