-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.aspx.cs
63 lines (60 loc) · 2.24 KB
/
search.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net.Mail;
using System.ServiceModel.Security;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.KatomBook;
using Newtonsoft.Json;
public partial class api_search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request.Params["term"]))
{
string term = Request.QueryString["term"];
string returnValue = "[";
DataTable result = MyAdoHelper.ExecuteDataTable("SELECT * FROM `tblUsers` WHERE `fldFullName` LIKE '%" + term + "%' ORDER BY `fldIndex` ASC;");
for (int i = 0; i < result.Rows.Count; i++)
{
Result temp = new Result();
temp.id = result.Rows[i]["fldIndex"].ToString();
temp.value = result.Rows[i]["fldFullName"].ToString();
returnValue = returnValue + JsonConvert.SerializeObject(temp) + ",";
}
returnValue = returnValue.Substring(0, returnValue.Length - 1);
returnValue += "]";
Response.Write(returnValue);
}
else
{
if (!string.IsNullOrEmpty(Request.Params["profileName"]))
{
if (MyAdoHelper.IsExist("Select * FROM `tblUsers` WHERE `fldFullName` ='" + Request.Form["profileName"] + "';"))
{
DataTable userFound = MyAdoHelper.ExecuteDataTable("Select * FROM `tblUsers` WHERE `fldFullName` ='" + Request.Form["profileName"] + "';");
string id = userFound.Rows[0]["fldIndex"].ToString();
Response.Redirect("/profile.aspx?id=" + id, false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
else
{
Response.Redirect("/Default.aspx?m=found", false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
}
else
{
Response.Write("Invalid Parameters!");
}
}
}
public class Result
{
public string id;
public string value;
}
}