📄 userinfo.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Model;
using BLL;
using BLL.interfaces;
public partial class userInfo : System.Web.UI.Page
{
IUsers userMessage = Factory.greatUsers();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//if (Session["userId"] == null)
// Response.Redirect("login.aspx");
if (Request["id"] == null)
Response.Redirect("error.aspx");
ViewState["id"] = int.Parse(Request["id"].ToString());
show();
}
}
private void show()
{
List<Users> list = new List<Users>();
list = userMessage.selOnly((int)ViewState["id"]);
if (list == null)
Response.Redirect("error.aspx");
dlvuserInfo.DataSource = list;
dlvuserInfo.DataBind();
foreach (Users u in list)
{
DropDownList cboRole = dlvuserInfo.FindControl("cboRole") as DropDownList;
cboRole.SelectedIndex = u.UserRoleId-1;
RadioButtonList rdblst = dlvuserInfo.FindControl("rdblst") as RadioButtonList;
rdblst.SelectedIndex = u.UserStateId - 1;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (userMessage.delUser(ViewState["id"].ToString()))
{
Response.Write("<script>alert('服务器已经接受您的请求!')</script>");
Response.Redirect("userlist.aspx");
}
else
{
Response.Redirect("error.aspx");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Users user = new Users();
user.Id = (int)ViewState["id"];
DropDownList cboRole = dlvuserInfo.FindControl("cboRole") as DropDownList;
user.UserRoleId = cboRole.SelectedIndex+1;
RadioButtonList rdblst = dlvuserInfo.FindControl("rdblst") as RadioButtonList;
user.UserStateId = rdblst.SelectedIndex+1;
if (userMessage.updateUser(user))
{
Response.Write("<script>alert('服务器已经接受您的请求!')</script>");
}
else
{
Response.Redirect("error.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -