温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:简单用户管理源码(入门级)
当前文件:
SimpleUserManager/show.aspx.cs,打开代码结构图
SimpleUserManager/show.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
12
public partial class show : System.Web.UI.Page 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
17
UserLogin.LoginNo(); 18
if (!Page.IsPostBack) 19
{ 20
Getinfo(); 21
Panel2.Visible = false; 22
if (Request.QueryString["ac"]=="edit") 23
{ 24
Panel2.Visible = true; 25
} 26
} 27
28
29
} 30
protected void Getinfo() 31
{ 32
string urlid = Request.QueryString["id"]; 33
string urlac=Request.QueryString["ac"]; 34
if (urlid != string.Empty) 35
{ 36
Info info = new Info(); 37
info.ID = Convert.ToInt32(urlid); 38
Dal dal = new Dal(); 39
DataTable Dt = dal.Getinfo(info); 40
if (urlac != "edit") 41
{ 42
Panel1.Visible = true; 43
Panel2.Visible = false; 44
name.Text = Dt.Rows[0]["I_UserName"].ToString(); 45
pwd.Text = Dt.Rows[0]["I_Userpwd"].ToString(); 46
isadmin.Text = Dt.Rows[0]["I_IsAdmin"].ToString(); 47
} 48
else if (urlac == "edit") 49
{ 50
Panel2.Visible = true; 51
Panel1.Visible = false; 52
nametext.Text = Dt.Rows[0]["I_UserName"].ToString(); 53
pwdtext.Text = Dt.Rows[0]["I_Userpwd"].ToString(); 54
admintext.Text = Dt.Rows[0]["I_IsAdmin"].ToString(); 55
} 56
} 57
else 58
{ 59
Response.Write("没有任何值!"); 60
} 61
} 62
protected void Button2_Click(object sender, EventArgs e) 63
{ 64
string url=Request.RawUrl; 65
Panel1.Visible = false; 66
Response.Redirect(url+"&ac=edit"); 67
} 68
protected void Button1_Click(object sender, EventArgs e) 69
{ 70
string _id = Request.QueryString["id"]; 71
Info user = new Info(); 72
Dal work = new Dal(); 73
user.ID=Convert.ToInt32(_id); 74
user.Name = nametext.Text; 75
user.Pwd = pwdtext.Text; 76
user.IsAdmin = admintext.Text; 77
int result= work.Update(user); 78
if (result!=0) 79
{ 80
string js = "show.aspx?id=" + Request.QueryString["id"]; 81
Panel1.Visible = true; 82
Panel2.Visible = false; 83
Jscript.AlertAndRedirect("修改成功!", js); 84
} 85
else 86
{ 87
Jscript.AlertAndRedirect("修改失败!", Request.RawUrl); 88
} 89
90
91
} 92
protected void Button3_Click(object sender, EventArgs e) 93
{ 94
//Response.Write("单击了"); 95
string _id = Request.QueryString["id"]; 96
Info deluser = new Info(); 97
Dal Del= new Dal(); 98
deluser.ID = Convert.ToInt32(_id); 99
int result = Del.Delete(deluser); 100
if (result != 0) 101
{ 102
Jscript.AlertAndRedirect("删除成功!,返回列表页面","View.aspx"); 103
} 104
else 105
{ 106
Jscript.AlertAndRedirect("删除失败!,返回", "View.aspx"); 107
} 108
} 109
} 110





}
}