public FuncMenuCollection GetMenuByUserID(string UserID) { FuncMenuCollection collection = new FuncMenuCollection(); string connectionString = ConfigurationManager.ConnectionStrings["AccountDataBase"].ConnectionString; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SP_SEL_Users_Menu"; SqlParameter _param = command.Parameters.Add("@User_ID", System.Data.SqlDbType.Int); _param.Value = UserID; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { FuncMenu menu = new FuncMenu(); menu.ItemID = int.Parse(reader["ID"].ToString()); menu.Text = reader["Text"].ToString(); menu.Sort = int.Parse(reader["Sort"].ToString()); menu.ParentID = int.Parse(reader["ParentID"].ToString()); menu.Path = reader["Path"].ToString(); collection.Add(menu); } } reader.Close(); } return collection; }
public FuncMenuCollection GetMenu(User user) { FuncMenuCollection collection = new FuncMenuCollection(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SP_Frank_TEST"; SqlParameter ColumnParam = command.Parameters.Add("@User_ID", System.Data.SqlDbType.Int); ColumnParam.Value = user.UserID; command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { FuncMenu menu = new FuncMenu(); menu.ItemID = Convert.ToInt32(reader["Menu_ID"]); menu.Text = reader["Text"].ToString(); menu.Path = reader["Path"].ToString(); menu.ParentID = Convert.ToInt32(reader["ParentID"]); menu.Sort = Convert.ToInt32(reader["Sort"]); collection.Add(menu); } } return collection; } }