📄 brand_add.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 Pro_Brand_Add : System.Web.UI.Page
{
protected string StairSelectList;
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.Pro_Brand_Add));
if (!PowerTree.PowerPass.isPass("001002002",PowerTree.PowerPanel.PowerType.add))
{
bp.PageError("对不起,你没有添加商品品牌的权限!", "../index.aspx");
}
StairCategoriesSel();
}
protected void Button1_Click(object sender, EventArgs e)
{
YXShop.Model.Pro_Brand data = new YXShop.Model.Pro_Brand();
if (Request.Form["cbType"] != "")
{
if (Request.Form["ProductCategories"] != null && Request.Form["ProductCategories"] != string.Empty)
{
data.Brand_ProCategoriesID = Request.Params["ProductCategories"];
data.Brand_WhetherCa = true;
}
}
else
{
data.Brand_ProCategoriesID = "";
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();
}
}
data.Brand_Description = this.tbDescription.Text.Trim();
#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
{
bp.PageError("图片上传失败!", "Brand_List.aspx");
Response.End();
}
}
else
{
bp.PageError("图你设置该品牌图片为:包含缩略图片,但你当前尚未选择所要上传的图片或直接在 [缩略图片路径]中输入指定图片路径,请检查!", "Brand_List.aspx");
Response.End();
}
#endregion
foreach (ListItem item in tbBrandProperty.Items)
{
if (item.Selected)
{
data.Brand_Attirbute += int.Parse(item.Value);
}
else
{
data.Brand_Attirbute = "0";
}
}
if (ProB.Create(data) > 0)
{
bp.PageRight("商品品牌添加成功。<li><a href='Brand_Add.aspx'>继续添加</a></li>", "Brand_List.aspx");
}
else
{
bp.PageError("商品品牌添加失败!", "Brand_List.aspx");
}
this.tbDescription.Text = string.Empty;
StairCategoriesSel();
}
#region 品牌一级分类
protected void StairCategoriesSel()
{
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=\"Stair(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 (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=\"Secondary(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 (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
#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 + -