-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserList.aspx.cs
More file actions
97 lines (86 loc) · 2.78 KB
/
userList.aspx.cs
File metadata and controls
97 lines (86 loc) · 2.78 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class UserMaintenance : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["admin"] == null)
{
Response.Redirect("home.aspx");
}
if (!IsPostBack)
{
LoadUserGridview();
if (Request.QueryString["src"] != null)
{
LoadAlertMessage(Request.QueryString["src"].ToString());
}
}
}
protected void LoadUserGridview()
{
gdvUsers.DataSource = UserDB.GetAllUsers();
gdvUsers.DataBind();
}
protected void LoadAlertMessage(string messagetype)
{
if (messagetype == "update")
{
litMessage.Text =
"<div class='alert alert-info'>" +
"<button type='button' class='close' data-dismiss='alert'>×</button>" +
"User updated." +
"</div>";
}
else if (messagetype == "delete")
{
litMessage.Text =
"<div class='alert alert-info'>" +
"<button type='button' class='close' data-dismiss='alert'>×</button>" +
"User deleted." +
"</div>";
}
else if (messagetype == "added")
{
litMessage.Text =
"<div class='alert alert-info'>" +
"<button type='button' class='close' data-dismiss='alert'>×</button>" +
"User added." +
"</div>";
}
litMessage.Visible = true;
}
protected void gdvUsers_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Edits")
{
int index = Convert.ToInt32(e.CommandArgument);
string userID = gdvUsers.Rows[index].Cells[0].Text;
Response.Redirect("usermaintenance.aspx?src=edit&userID=" + userID);
}
}
protected void gdvUsers_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gdvUsers.PageIndex = e.NewPageIndex;
gdvUsers.DataBind();
}
protected void btnSearch_Click(object sender, EventArgs e)
{
string selectStatement =
"SELECT Users.UserID, Users.UserName, UserType.UserType " +
"FROM Users " +
"LEFT OUTER JOIN UserType ON Users.UserTypeID = UserType.UserTypeID ";
if (txtUsername.Text != "")
{
selectStatement += "WHERE Users.UserName = '" + txtUsername.Text + "' ";
}
DataTable results = SearchDB.GenericSearch(selectStatement);
gdvUsers.DataSource = results;
gdvUsers.DataBind();
}
}