📄 shopmanager.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 System.Collections.Generic;
using YXShop.Web.Admin.Control;
using Shop.Web.UI;
namespace YXShop.Web.Admin.Shop
{
public partial class ShopManager : System.Web.UI.Page
{
YXShop.BLL.YXShop_Shop sBll = new YXShop.BLL.YXShop_Shop();
BasePage bp = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!PowerTree.PowerPass.isPass("014003000", PowerTree.PowerPanel.PowerType.look))
{
bp = new BasePage();
bp.PageError("对不起,你没有查看此页面的权限!", "../index.aspx");
}
if (!PowerTree.PowerPass.isPass("014003006", PowerTree.PowerPanel.PowerType.other))
{
Button5.Enabled = false;
Button5.ToolTip = "对不起,你没有分类查询店铺信息的权限!";
}
this.PageNavigator1.OnPageChange += new PageChangeHandler(PageNavigator1_OnPageChange);
if (Request.Form["Option"] != null && !Request.Form["Option"].Trim().Equals("")
&& Request.Form["ID"] != null && !Request.Form["ID"].Trim().Equals(""))
{
string types = Request.Form["Option"].Trim();
if (types == "del")
{
string id = Request.Form["ID"].Trim();
del(id);
}
Response.End();
return;
}
if (!Page.IsPostBack)
{
StartLoad(1);
}
}
void PageNavigator1_OnPageChange(object send, int nPageIndex)
{
StartLoad(nPageIndex);
}
protected void StartLoad(int PageIndex)
{
int i = 0;
int j = 0;
string whereStr = "";
if (ViewState["key"] != null)
{
whereStr = ViewState["key"].ToString();
}
List<YXShop.Model.YXShop_Shop> data = sBll.GetPages(whereStr, PageIndex, 20, out i, out j);
this.PageNavigator1.PageCount = j;
this.PageNavigator1.PageIndex = PageIndex;
this.PageNavigator1.RecordCount = i;
Repeater1.DataSource = data; //设置datalist数据源
Repeater1.DataBind();
}
/// <summary>
/// 查询用户名
/// </summary>
/// <param name="UserID"></param>
/// <returns></returns>
public string UserName(int UserID)
{
string str = "";
YXShop.BLL.UserCommon ucBll = new YXShop.BLL.UserCommon();
List<YXShop.Model.UserCommon> ucList = ucBll.GetListByColumn("UID", UserID);
if (ucList.Count > 0)
{
str = ucList[0].UserName;
}
return str;
}
protected void Button5_Click(object sender, EventArgs e)
{
string whereStr = "";
Label1.Text = "查询条件:" + GetKeyValue(CheckBoxList1, out whereStr);
ViewState["key"] = whereStr;
StartLoad(1);
}
private string GetKeyValue(CheckBoxList cbl, out string whereStr)
{
string reStr = "";
int w1 = -1;
string w2 = "";
string tempStr = "";
if (cbl.Items.Count == 7)
{
for (int i = 0; i < cbl.Items.Count; i++)
{
if (i == 3)
{
w1 = cbl.Items[i].Selected ? 1 : 0;
tempStr = cbl.Items[i].Selected ? "√" : "×";
reStr += cbl.Items[i].Text + "<font style='color:red'>" + tempStr + "</font> ";
tempStr = "";
continue;
}
else
{
tempStr = cbl.Items[i].Selected ? "√" : "⊙";
reStr += cbl.Items[i].Text + "<font style='color:red'>" + tempStr + "</font> ";
w2 += cbl.Items[i].Selected ? "1," : "[0,1],";
tempStr = "";
}
}
w2 = w2.TrimEnd(',');
}
whereStr = string.Format("state ='{0}' and Attribute like '{1}'", w1, w2);
return reStr;
}
public string CheckState(object obj)
{
string reStr = "否";
if (YXShop.Common.WebUtility.isNumeric(obj))
{
if (Convert.ToInt32(obj) == 1)
reStr = "是";
}
return reStr;
}
#region 删除信息
private void del(string sid)
{
string[] id = sid.Split(',');
int ln = id.Length;
int n = 0;
YXShop.Model.YXShop_Shop sModel = new YXShop.Model.YXShop_Shop();
for (int i = 0; i < id.Length; i++)
{
if (YXShop.Common.WebUtility.isNumeric(id[i].Trim()))
{
try
{
sModel.SID = Convert.ToInt32(id[i]);
sBll.Delete(sModel);
n++;
}
catch
{
continue;
}
}
}
Response.Write(n + "%成功删除" + n + "条数据!");
}
#endregion
#region 判断是否具有删除权限
/// <summary>
/// 判断是否具有删除权限
/// </summary>
/// <param name="powertype"></param>
/// <returns></returns>
public string GetPowerStr(string powertype)
{
string reStr = "";
switch (powertype)
{
case "del":
reStr = PowerTree.PowerPass.isPass("014003003", PowerTree.PowerPanel.PowerType.del) ? "t" : "f";
break;
}
return reStr;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -