📄 adminlist.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using YXShop.Common;
using System.Collections.Generic;
using Shop.Web.UI;
namespace YXShop.Web.Admin.Consumer
{
public partial class AdminList : System.Web.UI.Page
{
YXShop.BLL.Administrators bll = new YXShop.BLL.Administrators();
public PageSet ps; BasePage bp = null;
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(YXShop.Web.Admin.Consumer.AdminList));
if (!PowerTree.PowerPass.isPass("007001000",PowerTree.PowerPanel.PowerType.look))
{
bp = new BasePage();
bp.PageError("对不起,你没有查看此页面的权限!", "../index.aspx");
}
if ((!IsPostBack) || ((Request["Event"] != null) && (Request["Event"] != "")))
{
Bind();
}
}
private void Bind()
{
int pageIndex = Request["pageIndex"] == null ? 0 : int.Parse(Request["pageIndex"]);
if (pageIndex < 0)
{
pageIndex = 0;
}
if ((Request["Event"] == null) || (Request["Event"] == ""))
{
pageIndex = 0;
}
List<YXShop.Model.Administrators> datas = bll.GetList();
GridView1.DataSource = datas;
ps = new PageSet(datas.Count, PageSet.PageSize, pageIndex);
if (ps.PageCount <= pageIndex + 1)
{
pageIndex = ps.PageCount - 1;
}
GridView1.PageSize = PageSet.PageSize;
GridView1.PageIndex = pageIndex;
if (datas.Count < 1)
{
GridView1.BackColor = System.Drawing.Color.White;
}
GridView1.DataBind();
}
protected void dgTBMemberAdmin_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (!(e.Row.DataItem is YXShop.Model.Administrators))
{
return;
}
YXShop.Model.Administrators data = (e.Row.DataItem as YXShop.Model.Administrators);
if (data != null)
{
List<YXShop.Model.Administrators> datas = bll.GetListByColumn("Admin_ID", data.Admin_ID);
if (datas.Count > 0)
{
if (data.Admin_ID.ToString() == Session["AdminID"].ToString() || datas[0].Admin_Name == "Admin")
{
e.Row.Cells[0].Text = "";
}
else
{
e.Row.Cells[0].Text = "<input type=\"checkbox\" name=\"cbID\" value=\"" + data.Admin_ID + "\" />";
}
}
}
}
protected string DelPutout(string ID)
{
string str = "";
List<YXShop.Model.Administrators> datas = bll.GetListByColumn("Admin_ID", ID);
if (datas.Count > 0)
{
if (ID == Session["AdminID"].ToString() || datas[0].Admin_Name == "Admin")
{
str = " <a href=\"AdminModify.aspx?ID="+ID+"\">编辑</a> <span style='color:#CCCCCC'>删除</span>";
}
else
{
str = " <a href=\"AdminModify.aspx?ID="+ID+"\">编辑</a> <a href=\"#\" onclick=\"AdminDel('" + ID + "','"+GetPowerStr("del")+"')\">删除</a>";
}
}
return str;
}
#region 单个删除与批量删除
[AjaxPro.AjaxMethod]
public string BetchDel(string id)
{
if (!PowerTree.PowerPass.isPass("007001003", PowerTree.PowerPanel.PowerType.del))
{
return "false";
}
string strID = "";
if (id.IndexOf(",") > 0)
{
strID = id.Substring(0, (id.Length - 1));
}
else
{
strID = id;
}
YXShop.BLL.Communal data = new YXShop.BLL.Communal();
data.BatchDelect("YXShop_Administrators", "Admin_ID", strID);
return string.Empty;
}
#endregion
[AjaxPro.AjaxMethod]
public bool isNumeric(string num)
{
if (num.Length == 0)
{
return false;
}
System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("^[0-9]+$");
return r.IsMatch(num);
}
public string TranState(object obj)
{
string str = string.Empty;
if (obj != null)
{
if (isNumeric(obj.ToString()))
{
if (int.Parse(obj.ToString()) == 1)
{
str = "是";
}
else
{
str = "否";
}
}
}
return str;
}
#region 判断是否具有删除权限
/// <summary>
/// 判断是否具有删除权限
/// </summary>
/// <param name="powertype"></param>
/// <returns></returns>
public string GetPowerStr(string powertype)
{
string reStr = "";
switch (powertype)
{
case "del":
reStr = PowerTree.PowerPass.isPass("007001003", PowerTree.PowerPanel.PowerType.del) ? "t" : "f";
break;
}
return reStr;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -