📄 shop.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 Shop.Web.UI;
using System.Collections.Generic;
using System.Data.SqlClient;
namespace YXShop.Web.Admin.Shop
{
public partial class Shop : System.Web.UI.Page
{
BasePage bp = new BasePage();
private static int sid = 0;
YXShop.BLL.YXShop_Shop sBll = new YXShop.BLL.YXShop_Shop();
protected void Page_Load(object sender, EventArgs e)
{
if (!PowerTree.PowerPass.isPass("014003001", PowerTree.PowerPanel.PowerType.look))
{
bp = new BasePage();
bp.PageError("对不起,你没有查看店铺信息的权限!", "../index.aspx");
}
if (!PowerTree.PowerPass.isPass("014003004", PowerTree.PowerPanel.PowerType.update))
{
Btn1.Enabled = false;
Btn1.ToolTip = "对不起,你没有修改店铺信息的权限!";
}
if (!Page.IsPostBack)
{
if (YXShop.Common.WebUtility.isNumeric(Request.QueryString["ID"]))
{
int id = Convert.ToInt32(Request.QueryString["ID"]);
sid = id;
BindShopInfo(id);
}
else
{
bp.PageError("没有找到指定的店铺信息!", "");
}
}
}
/// <summary>
/// 初始化信息
/// </summary>
/// <param name="sID"></param>
private void BindShopInfo(int sID)
{
List<YXShop.Model.YXShop_Shop> sList = sBll.GetListByColumn("SID", sID);
if (sList.Count == 1)
{
YXShop.BLL.UserCommon ucBll = new YXShop.BLL.UserCommon();
SqlDataReader sqlDr = ucBll.GetRealName(Convert.ToInt32(sList[0].UID));
while (sqlDr.Read())
{
Label7.Text = sqlDr["cHomePhone"].ToString();
Label8.Text = sqlDr["post"].ToString();
Label9.Text = sqlDr["cMobilePhone"].ToString();
Label10.Text = sqlDr["UEmail"].ToString();
Label11.Text = sqlDr["cAddrInfo"].ToString();
}
sqlDr.Dispose();
sqlDr.Close();
Btn1.CommandArgument = sID.ToString();
BindDropDownList(DropDownList1, Convert.ToInt32(sList[0].ShopType));
Label1.Text = sList[0].ShopName;
Label2.Text = sList[0].AddTime.ToString();
Label6.Text = sList[0].PrestigeRank.ToString();
Label3.Text = "";
Label4.Text = sList[0].VisitNo.ToString();
int blInt = YXShop.Common.WebUtility.isNumeric(sList[0].State) ? Convert.ToInt32(sList[0].State) : 0;
Label5.Text = blInt == 1 ? "是" : "否";
TextBox1.Text = sList[0].PrestigeRank.ToString();
TextBox2.Text = sList[0].VisitNo.ToString();
string[] arr = sList[0].Attribute.Split(',');
BindCheckBoxList(CheckBoxList1, arr, blInt);
}
}
private void BindCheckBoxList(CheckBoxList cbl, string[] arr, int bl)
{
if (cbl.Items.Count == 7)
{
if (arr.Length != 6)
return;
for (int i = 0; i < cbl.Items.Count; i++)
{
if (i < 3)//012
{
if (Convert.ToInt32(arr[i]) > 0)
cbl.Items[i].Selected = true;
else
cbl.Items[i].Selected = false;
}
else if (i == 3)//3
{
if (bl == 1)
cbl.Items[i].Selected = true;
else
cbl.Items[i].Selected = false;
}
else//4,5
{
if (Convert.ToInt32(arr[i - 1]) > 0)
cbl.Items[i].Selected = true;
else
cbl.Items[i].Selected = false;
}
}
}
}
private string getCheckBoxListValue(CheckBoxList cbl)
{
string reStr = "";
if (cbl.Items.Count == 7)
{
for (int i = 0; i < cbl.Items.Count;i++ )
{
if (i == 3)
{
continue;
}
reStr += cbl.Items[i].Selected ? "1," : "0,";
}
//0,0,0,0,
reStr = reStr.TrimEnd(',');
}
return reStr;
}
private void BindDropDownList(DropDownList ddl, int TypeID)
{
YXShop.BLL.ShopCategory scBll = new YXShop.BLL.ShopCategory();
List<YXShop.Model.ShopCategory> scList = scBll.GetAll();
ListItem lItem = null;
ddl.Items.Clear();
foreach (YXShop.Model.ShopCategory scModel in scList)
{
lItem = new ListItem();
lItem.Value = scModel.scID.ToString();
lItem.Text = scModel.scName;
if (TypeID == scModel.scID)
{
lItem.Selected = true;
}
ddl.Items.Add(lItem);
lItem = null;
}
}
protected void Btn1_Click(object sender, EventArgs e)
{
int sid = getID((Button)sender);
List<YXShop.Model.YXShop_Shop> sList = sBll.GetListByColumn("SID", sid);
if (sList.Count == 1)
{
sList[0].ShopType = Convert.ToInt32(DropDownList1.SelectedValue);
sList[0].PrestigeRank =Convert.ToInt32(TextBox1.Text.Trim());
sList[0].VisitNo = Convert.ToInt32(TextBox2.Text.Trim());
sList[0].State = CheckBoxList1.Items[3].Selected ? 1 : 0;
sList[0].Attribute = getCheckBoxListValue(CheckBoxList1);
try
{
sBll.Amend(sList[0]);
bp.PageRight("店铺信息修改成功!", "ShopManager.aspx");
}
catch
{
//bp.PageError("店铺信息修改失败!", "Shop.aspx?ID=" + sid);
}
}
else
{
bp.PageError("店铺信息修改失败!", "Shop.aspx?ID=" + sid);
}
}
private int getID(Button btn)
{
int reInt = -1;
if (YXShop.Common.WebUtility.isNumeric(btn.CommandArgument))
{
reInt = Convert.ToInt32(btn.CommandArgument);
}
return reInt;
}
protected void Btn2_Click(object sender, EventArgs e)
{
Response.Redirect("ShopManager.aspx", true);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -