protected void btnOk_Click(object sender, EventArgs e)
{
string roleName = InputHelper.CleanInputString(txtRoleName.Value);
RoleInfo role = new RoleInfo
{
RoleName = roleName
};
string id = Request["id"];
//修改时操作
if (!string.IsNullOrWhiteSpace(id))
{
if (btnOk.CommandName.Equals("update"))
{
role.ID = int.Parse(id);
bll.UpdateRoleInfo(role);
}
}
else//此处为添加
{
bll.AddRoleInfo(role);
}
Response.Redirect("AddListRole.aspx");
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DoInit();
}
}
#region 修改 页面初始化
private void DoInit()
{
string id = Request["id"];
if (!string.IsNullOrWhiteSpace(id))
{
id = InputHelper.CleanInputString(id);
int funcId = 0;
if (int.TryParse(id, out funcId))
{
var role = bll.FindById(funcId);
if (role != null)
{
txtRoleName.Value = role.RoleName;
btnOk.CommandName = "update";
}
}
}
}
#endregion
//记录总数
public int totalcounts = 0;
//页码大小
public int pageSize = 30;
//总页数
public int totalPage = 0;
//上一页
public int previosPgIndex = 1;
//下一页
public int nextPgIndex = 1;
//页数
public int pgindex = 1;
public RoleBLL bll = new RoleBLL();
public List<RoleInfo> rlist=new List<RoleInfo>();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rlist = bll.FindListPage(pgindex, pageSize, out totalcounts);
//计算出总页数
totalPage = (totalcounts + pageSize - 1) / pageSize;
//计算上一页 页数
if (pgindex - 1 > 0)
{
previosPgIndex = pgindex - 1;
}
//计算下一页 页数
if (pgindex + 1 <= totalPage)
{
nextPgIndex = pgindex + 1;
}
if (pgindex == totalPage)
{
nextPgIndex = pgindex;
}
}
}
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="20">
</td>
</tr>
<tr>
<td height="40" class="font42">
<table width="100%" border="0" id="listShow" cellpadding="4" cellspacing="1" bgcolor="#464646"
class="newfont03">
<tr bgcolor="#EEEEEE">
<td width="5%" height="30">ID</td>
<td width="5%">角色名称</td>
<td width="5%">权限</td>
<td width="12%">操作</td>
</tr>
<% if (rlist.Any())
{
foreach (var r in rlist)
{
%>
<tr bgcolor="#FFFFFF">
<td height="30"><%=r.ID%></td>
<td><%=r.RoleName%></td>
<td width="5%"><a href="RoleFunction.aspx?roleId=<%=r.ID %>">权限</a></td>
<td><a href="AddListRole.aspx?id=<%=r.ID %>">编辑|</a>
<a href="#" id="<%=r.ID %>" class="del">删除</a></td>
</td>
</tr>
<%}
}%>
</table>
</td>
</tr>
</table>
string id = context.Request["id"];
int funcid = 0;
if (int.TryParse(id, out funcid))
{
RoleBLL rolebll = new RoleBLL();
if (rolebll.DeleteById(funcid) > 0)
{
context.Response.Write(jsonback + "({\"html\":\"删除成功!\",\"status\":\"1\"})");
}
else
{
context.Response.Write(jsonback + "({\"html\":\"发生了异常!\",\"status\":\"0\"})");
}
}
else
{
context.Response.Write(jsonback + "({\"html\":\"发生了异常!\",\"status\":\"0\"})");
}
欢迎光临 苏飞论坛 (http://www.sufeinet.com/) | Powered by Discuz! X3.4 |