//Show searched records public void OnPostSearch() { String Search_User = Request.Form["Search_User"]; String Exception = ""; String Current_User = HttpContext.Session.GetString("User_Name"); int OFFSET = 50; Boolean CheckConnection = MyOwnMySQLConnectionClass.LoadConnection(ref Exception); MySqlCommand MySQLQuery = new MySqlCommand(); MySqlDataReader UserReader; UserList = new List <String> { }; if (Search_User != null || Search_User.CompareTo("") != 0) { HttpContext.Session.SetString("Search_User", Search_User); HttpContext.Session.SetString("OFFSET", OFFSET.ToString()); SessionSearchUser = Search_User; MySQLQuery = new MySqlCommand(); MySQLQuery.Parameters.Clear(); MySQLQuery.CommandText = "SELECT `User_Name` FROM `User` WHERE `User_Name`!='@Current_User' AND `User_Name` LIKE '%@Search_User%' LIMIT 50"; MySQLQuery.Parameters.Add("@Search_User", MySqlDbType.Text).Value = Search_User; MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); UserReader = MySQLQuery.ExecuteReader(); while (UserReader.Read()) { UserList.Add(UserReader.GetValue(0).ToString()); } MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); } }
//Show previous records public void OnPostPrevious() { String User = HttpContext.Session.GetString("Search_User"); String OFFSETString = HttpContext.Session.GetString("OFFSET"); String Exception = ""; String Current_User = HttpContext.Session.GetString("User_Name"); Boolean CheckConnection = MyOwnMySQLConnectionClass.LoadConnection(ref Exception); MySqlCommand MySQLQuery = new MySqlCommand(); MySqlDataReader UserReader; UserList = new List <String> { }; int OFFSET = 0; SessionSearchUser = User; if (User != null && OFFSETString != null) { OFFSET = int.Parse(OFFSETString); if (OFFSET != 0) { OFFSET -= 50; } MySQLQuery.CommandText = "SELECT `User_Name` FROM `User` WHERE `User_Name`!='@Current_User' AND `User_Name` LIKE '%@Search_User%' LIMIT 50 OFFSET " + OFFSET.ToString(); MySQLQuery.Parameters.Add("@Search_User", MySqlDbType.Text).Value = User; MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); UserReader = MySQLQuery.ExecuteReader(); while (UserReader.Read()) { UserList.Add(UserReader.GetValue(0).ToString()); } MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); HttpContext.Session.SetString("OFFSET", OFFSET.ToString()); } else if (User == null && OFFSETString != null) { OFFSET = int.Parse(OFFSETString); if (OFFSET != 0) { OFFSET -= 50; } MySQLQuery.CommandText = "SELECT `User_Name` FROM `User` WHERE `User_Name`!='@Current_User' LIMIT 50 OFFSET " + OFFSET.ToString(); MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User; MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection; MySQLQuery.Prepare(); UserReader = MySQLQuery.ExecuteReader(); while (UserReader.Read()) { UserList.Add(UserReader.GetValue(0).ToString()); } MyOwnMySQLConnectionClass.MyMySQLConnection.Close(); HttpContext.Session.SetString("OFFSET", OFFSET.ToString()); } }