📄 brand_edit.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 System.Text;
using Shop.Web.UI;
namespace YXShop.Web.Admin.Product
{
public partial class Brand_Edit : System.Web.UI.Page
{
protected string StairSelectList, SecondaryCategoriesList, ThirdClassCategoriesList, StairCategories;
protected string cdType, rpitchon;
YXShop.BLL.Pro_Brand ProB = new YXShop.BLL.Pro_Brand();
BasePage bp = new BasePage();
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(YXShop.Web.Admin.Product.Brand_Edit));
if (!PowerTree.PowerPass.isPass("001002004",PowerTree.PowerPanel.PowerType.update))
{
bp.PageError("对不起,你没有编辑商品品牌的权限!", "../index.aspx");
}
if (!IsPostBack && Request["id"] != null && Request["id"] != string.Empty)
{
string IDStr = Request["id"].ToString();
ViewState["CID"] = IDStr.Substring(0, IDStr.IndexOf("_", 0));
ViewState["URL"] = Request.UrlReferrer;
ViewState["ID"] = IDStr.Substring(IDStr.IndexOf("_", 0) + 1, IDStr.Length - IDStr.IndexOf("_", 0) - 1);
BrandContent(Convert.ToInt32(ViewState["ID"]));
}
}
#region 填充数据
protected void BrandContent(int id)
{
YXShop.Model.Pro_Brand modeldate = new YXShop.Model.Pro_Brand();
List<YXShop.Model.Pro_Brand> data = ProB.GetId(id);
if (data.Count > 0)
{
if (Convert.ToBoolean(data[0].Brand_WhetherCa) == true)
{
this.Prom.StrProID = id.ToString();
cdType = "<input id=\"cbType\" name=\"cbType\" type=\"checkbox\" onclick=\"javascript:this.checked==true?document.getElementById('LlCategories').style.display='':document.getElementById('LlCategories').style.display='none';\" checked/>";
}
else
{
cdType = "<input id=\"cbType\" name=\"cbType\" type=\"checkbox\" onclick=\"javascript:this.checked==true?document.getElementById('LlCategories').style.display='':document.getElementById('LlCategories').style.display='none';\"/>";
}
}
if (data[0].Brand_CategoriesID == 0)
{
this.StairCategoriesSel(0);
SecondaryCategoriesList=this.SecondaryCategories(-1);
ThirdClassCategoriesList = this.ThirdClassCategories(-1);
rpitchon = "<input id=\"rpitchon\" name=\"rpitchon\" type=\"radio\" onclick=\"javascript:document.getElementById('CategoriesValue').innerHTML='一级分类:';this.checked=true;\" checked/>";
}
else
{
List<YXShop.Model.Pro_Brand> datat = ProB.GetId(data[0].Brand_CategoriesID);
if (datat.Count > 0)
{
if (datat[0].Brand_CategoriesID.ToString() != "0")
{
this.StairCategoriesSel(Convert.ToInt32(datat[0].Brand_CategoriesID));
SecondaryCategoriesList = this.SecondaryCategories(Convert.ToInt32(datat[0].Brand_CategoriesID));
ThirdClassCategoriesList = this.ThirdClassCategories(datat[0].Brand_ID);
}
else
{
this.StairCategoriesSel(Convert.ToInt32(datat[0].Brand_ID));
SecondaryCategoriesList = this.SecondaryCategories(Convert.ToInt32(datat[0].Brand_ID));
ThirdClassCategoriesList = this.ThirdClassCategories(-1);
}
}
rpitchon="<input id=\"rpitchon\" name=\"rpitchon\" type=\"radio\" onclick=\"javascript:document.getElementById('CategoriesValue').innerHTML='一级分类:';this.checked=true;\"/>";
}
StairCategories = data[0].Brand_Name;
ViewState["Image"] = data[0].Brand_Images;
this.tbBrandProperty.SelectedValue = data[0].Brand_Attirbute;
this.tbDescription.Text = data[0].Brand_Description;
}
#endregion
#region (修改数据)
protected void Button1_Click(object sender, EventArgs e)
{
YXShop.Model.Pro_Brand data = new YXShop.Model.Pro_Brand();
data.Brand_ID = Convert.ToInt32(ViewState["ID"]);
if (Request.Form["cbType"] != "")
{
if (Request.Form["ProductCategories"] != null && Request.Form["ProductCategories"] != string.Empty)
{
data.Brand_ProCategoriesID = Request.Params["ProductCategories"].ToString();
data.Brand_WhetherCa = true;
}
}
else
{
data.Brand_ProCategoriesID = string.Empty;
data.Brand_WhetherCa = false;
}
if (Request.Form["rpitchon"] == "on")
{
data.Brand_CategoriesID = 0;
data.Brand_Name = Request.Form["StairCategories"].ToString();
}
else
{
if (Request.Params["SecondaryCategoriesSel"] != null && Request.Params["StairCategoriesSel"] != null)
{
data.Brand_CategoriesID = Convert.ToInt32(Request.Form["SecondaryCategoriesSel"]);
data.Brand_Name = Request.Form["StairCategories"].ToString();
}
else
{
data.Brand_CategoriesID = Convert.ToInt32(Request.Params["StairCategoriesSel"]);
data.Brand_Name = Request.Form["StairCategories"].ToString();
}
}
#region 图片上传
if (!string.IsNullOrEmpty(FileUpload.FileName.ToString()))
{
string fileStr = YXShop.DBUtility.UploadFile.UploadPicFile(FileUpload, "YXUploadFile/Brand", "brand");
if (fileStr.IndexOf("error") == -1)
{
data.Brand_Images = fileStr;
}
else
{
Response.Redirect("../Succeed/Error.aspx?Key= * 图片上传失败!");
}
}
else
{
data.Brand_Images = ViewState["Image"].ToString();
}
#endregion
data.Brand_Description = this.tbDescription.Text.Trim();
data.Brand_Attirbute = "0";
foreach (ListItem item in tbBrandProperty.Items)
{
if (item.Selected)
{
data.Brand_Attirbute += int.Parse(item.Value);
}
}
ProB.Amend(data);
Response.Redirect(ViewState["URL"].ToString());
this.tbDescription.Text = string.Empty;
this.lbInfo.Text = "保存成功,您可以继续新增品牌信息。";
}
#endregion
#region 品牌一级分类
protected void StairCategoriesSel(int id)
{
List<YXShop.Model.Pro_Brand> data = ProB.GetListByColumn("Brand_CategoriesID", 0);
StringBuilder shtml = new StringBuilder();
shtml.Append("<select id=\"StairCategoriesSel\" name=\"StairCategoriesSel\" size=\"8\" style=\"width:200px\" onclick=\"StairMod(this.value)\">");
if (data.Count > 0)
{
foreach (YXShop.Model.Pro_Brand ds in data)
{
List<YXShop.Model.Pro_Brand> dap = ProB.GetListByColumn("Brand_CategoriesID", Convert.ToInt32(ds.Brand_ID));
if (ds.Brand_ID.ToString() == id.ToString())
{
if (dap.Count > 0)
{
shtml.Append("<option value=" + ds.Brand_ID + " selected>" + ds.Brand_Name + "<span style='color:#303030'> >></span></option>");
}
else
{
shtml.Append("<option value=" + ds.Brand_ID + " selected>" + ds.Brand_Name + "</option>");
}
}
else
{
if (dap.Count > 0)
{
shtml.Append("<option value=" + ds.Brand_ID + " >" + ds.Brand_Name + "<span style='color:#303030'> >></span></option>");
}
else
{
shtml.Append("<option value=" + ds.Brand_ID + " >" + ds.Brand_Name + "</option>");
}
}
}
}
shtml.Append("</select>");
StairSelectList = shtml.ToString();
}
#endregion
#region 品牌二级
[AjaxPro.AjaxMethod]
public string SecondaryCategories(int CatagoriesID)
{
List<YXShop.Model.Pro_Brand> data = ProB.GetListByColumn("Brand_CategoriesID", CatagoriesID);
StringBuilder shtml = new StringBuilder();
shtml.Append("<select id=\"SecondaryCategoriesSel\" name=\"SecondaryCategoriesSel\" size=\"8\" style=\"width:200px\" onclick=\"SecondaryMod(this.value)\">");
if (data.Count > 0)
{
foreach (YXShop.Model.Pro_Brand ds in data)
{
List<YXShop.Model.Pro_Brand> dap = ProB.GetListByColumn("Brand_CategoriesID", Convert.ToInt32(ds.Brand_ID));
if (ViewState["CID"] != null)
{
if (ds.Brand_ID.ToString() == ViewState["CID"].ToString())
{
if (dap.Count > 0)
{
shtml.Append("<option value=" + ds.Brand_ID + " selected>" + ds.Brand_Name + "<span style='color:#303030'> >></span></option>");
}
else
{
shtml.Append("<option value=" + ds.Brand_ID + " selected>" + ds.Brand_Name + "</option>");
}
}
else
{
if (dap.Count > 0)
{
shtml.Append("<option value=" + ds.Brand_ID + " >" + ds.Brand_Name + "<span style='color:#303030'> >></span></option>");
}
else
{
shtml.Append("<option value=" + ds.Brand_ID + " >" + ds.Brand_Name + "</option>");
}
}
}
else
{
if (dap.Count > 0)
{
shtml.Append("<option value=" + ds.Brand_ID + " >" + ds.Brand_Name + "<span style='color:#303030'> >></span></option>");
}
else
{
shtml.Append("<option value=" + ds.Brand_ID + " >" + ds.Brand_Name + "</option>");
}
}
}
}
shtml.Append("</select>");
return shtml.ToString();
}
#endregion
#region 品牌三级
[AjaxPro.AjaxMethod]
public string ThirdClassCategories(int CatagoriesID)
{
List<YXShop.Model.Pro_Brand> data = ProB.GetListByColumn("Brand_CategoriesID", CatagoriesID);
StringBuilder shtml = new StringBuilder();
shtml.Append("<select id=\"ThirdClassCategoriesSel\" name=\"ThirdClassCategoriesSel\" size=\"8\" style=\"width:200px\">");
if (data.Count > 0)
{
foreach (YXShop.Model.Pro_Brand ds in data)
{
List<YXShop.Model.Pro_Brand> dap = ProB.GetListByColumn("Brand_CategoriesID", Convert.ToInt32(ds.Brand_ID));
if (dap.Count > 0)
{
shtml.Append("<option value=" + ds.Brand_ID + " >" + ds.Brand_Name + " >></span></option>");
}
else
{
shtml.Append("<option value=" + ds.Brand_ID + " >" + ds.Brand_Name + "</option>");
}
}
}
shtml.Append("</select>");
return shtml.ToString();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -