代码修改后的版本,全部提交
This commit is contained in:
276
Mtxfw.VipSite/Admin_Member_Products_Tree4.aspx.cs
Normal file
276
Mtxfw.VipSite/Admin_Member_Products_Tree4.aspx.cs
Normal file
@@ -0,0 +1,276 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
namespace Mtxfw.VipSite
|
||||
{
|
||||
public partial class Admin_Member_Products_Tree4 : Mtxfw.Utility.MemberBase
|
||||
{
|
||||
public Mtxfw.DAL.Ads daoAds = new Mtxfw.DAL.Ads();
|
||||
public Mtxfw.DAL.P_Product daoProduct = new Mtxfw.DAL.P_Product();
|
||||
public Mtxfw.DAL.P_Category daoCategory = new Mtxfw.DAL.P_Category();
|
||||
public Mtxfw.DAL.Article daoArt = new Mtxfw.DAL.Article();
|
||||
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config("");
|
||||
public int gtype = 0;
|
||||
#region 判断页面是否刷新
|
||||
private bool _refreshState;
|
||||
private bool _isRefresh;
|
||||
|
||||
/// <summary>
|
||||
/// 判断页面是否刷新
|
||||
/// </summary>
|
||||
public bool IsRefresh
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isRefresh;
|
||||
}
|
||||
}
|
||||
protected override void LoadViewState(object savedState)
|
||||
{
|
||||
object[] allStates = (object[])savedState;
|
||||
base.LoadViewState(allStates[0]);
|
||||
_refreshState = (bool)allStates[1];
|
||||
_isRefresh = _refreshState == (bool)Session["__ISREFRESH"];
|
||||
}
|
||||
protected override object SaveViewState()
|
||||
{
|
||||
Session["__ISREFRESH"] = _refreshState;
|
||||
object[] allStates = new object[2];
|
||||
allStates[0] = base.SaveViewState();
|
||||
allStates[1] = !_refreshState;
|
||||
return allStates;
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
string hostname = Request.Url.Host;
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
if (Session["IFPassword"] == null)
|
||||
{
|
||||
Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_Products_Tree4.aspx");
|
||||
}
|
||||
if (IFStores != 1)
|
||||
{
|
||||
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
|
||||
}
|
||||
if (MemberJS.IndexOf("商品分类管理") == -1)
|
||||
{
|
||||
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
|
||||
}
|
||||
Page.Title = "拼团商品分类 - " + GetWebName;
|
||||
Select_Bind();
|
||||
C_PARENTID.Items.Insert(0, new ListItem("顶级栏目", "0"));
|
||||
if (Request.UrlReferrer != null)
|
||||
{
|
||||
Hidd_Url.Value = Request.UrlReferrer.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
Hidd_Url.Value = "Admin_Member_Products4.aspx";
|
||||
}
|
||||
if (String.IsNullOrEmpty(Request["Action"]))
|
||||
{
|
||||
Btn_Update.Visible = false;
|
||||
if (Session["C_PARENTID"] != null)
|
||||
{
|
||||
for (int i = 0; i < C_PARENTID.Items.Count; i++)
|
||||
{
|
||||
string[] lbPid = C_PARENTID.Items[i].Value.Split('|');
|
||||
if (lbPid[0] == Session["C_PARENTID"].ToString())
|
||||
{
|
||||
C_PARENTID.Items[i].Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
C_PARENTID.Items[i].Selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
string Action = Request["Action"].ToString();
|
||||
if (Action == "Add")
|
||||
{
|
||||
if (!String.IsNullOrEmpty(Request.QueryString["ID"]))
|
||||
{
|
||||
Btn_Update.Visible = false;
|
||||
|
||||
for (int i = 0; i < C_PARENTID.Items.Count; i++)
|
||||
{
|
||||
string[] lbPid = C_PARENTID.Items[i].Value.Split('|');
|
||||
if (lbPid[0] == Request.QueryString["ID"].ToString())
|
||||
{
|
||||
C_PARENTID.Items[i].Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
C_PARENTID.Items[i].Selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Action == "Edit")
|
||||
{
|
||||
Btn_Insert.Visible = false;
|
||||
|
||||
Mtxfw.Model.P_Category model = daoCategory.GetModel(int.Parse(Request.QueryString["ID"]));
|
||||
Text_C_NAME.Text = model.C_NAME;
|
||||
for (int i = 0; i < C_PARENTID.Items.Count; i++)
|
||||
{
|
||||
string[] lbPid = C_PARENTID.Items[i].Value.Split('|');
|
||||
if (lbPid[0] == model.C_PARENTID.ToString())
|
||||
{
|
||||
C_PARENTID.Items[i].Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
C_PARENTID.Items[i].Selected = false;
|
||||
}
|
||||
}
|
||||
Text_C_LinkID.Text = model.C_LinkID.ToString();
|
||||
}
|
||||
else if (Action == "Del")
|
||||
{
|
||||
daoCategory.Delete2(int.Parse(Request.QueryString["ID"]));
|
||||
Response.Redirect("Admin_Member_Products_Tree4.aspx");
|
||||
}
|
||||
else if (Action == "UpdateLink")
|
||||
{
|
||||
daoCategory.Update(int.Parse(Request.QueryString["ID"]), "C_LinkID", int.Parse(Request.QueryString["LinkID"]));
|
||||
Response.Redirect("Admin_Member_Products_Tree4.aspx");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Btn_Insert.Click += delegate(object s, EventArgs ex)
|
||||
{
|
||||
Mtxfw.Model.P_Category model = new Mtxfw.Model.P_Category();
|
||||
model.C_NAME = Text_C_NAME.Text;
|
||||
string[] lbpid = C_PARENTID.SelectedItem.Value.Split('|');
|
||||
model.C_PARENTID = int.Parse(lbpid[0]);
|
||||
model.C_Layer = 1;
|
||||
model.C_PARENTIDs = "";
|
||||
Mtxfw.Model.P_Category model2 = daoCategory.GetModel(model.C_PARENTID);
|
||||
if (model2 != null)
|
||||
{
|
||||
if (model2.C_PARENTIDs == "")
|
||||
{
|
||||
model.C_PARENTIDs = "," + model.C_PARENTID + ",";
|
||||
}
|
||||
else
|
||||
{
|
||||
model.C_PARENTIDs = model2.C_PARENTIDs + model.C_PARENTID + ",";
|
||||
}
|
||||
model.C_Layer = model2.C_Layer + 1;
|
||||
}
|
||||
Session["C_PARENTID"] = model.C_PARENTID;
|
||||
model.C_LinkID = int.Parse(Text_C_LinkID.Text);
|
||||
model.ttype = 6;
|
||||
model.GGEnable = 0;
|
||||
model.C_images = "";
|
||||
model.gtype = gtype;
|
||||
daoCategory.Add(model);
|
||||
Response.Redirect("Admin_Member_Products_Tree4.aspx");
|
||||
};
|
||||
|
||||
Btn_Update.Click += delegate(object s, EventArgs ex)
|
||||
{
|
||||
Int32 C_ID = int.Parse(Request.QueryString["ID"]);
|
||||
Mtxfw.Model.P_Category model = daoCategory.GetModel(C_ID);
|
||||
model.C_ID = C_ID;
|
||||
model.C_NAME = Text_C_NAME.Text;
|
||||
string[] lbpid = C_PARENTID.SelectedItem.Value.Split('|');
|
||||
model.C_PARENTID = int.Parse(lbpid[0]);
|
||||
model.C_Layer = 1;
|
||||
model.C_PARENTIDs = "";
|
||||
Mtxfw.Model.P_Category model2 = daoCategory.GetModel(model.C_PARENTID);
|
||||
if (model2 != null)
|
||||
{
|
||||
if (model2.C_PARENTIDs == "")
|
||||
{
|
||||
model.C_PARENTIDs = "," + model.C_PARENTID + ",";
|
||||
}
|
||||
else
|
||||
{
|
||||
model.C_PARENTIDs = model2.C_PARENTIDs + model.C_PARENTID + ",";
|
||||
}
|
||||
model.C_Layer = model2.C_Layer + 1;
|
||||
}
|
||||
model.C_LinkID = int.Parse(Text_C_LinkID.Text);
|
||||
daoCategory.Update(model);
|
||||
Response.Redirect("Admin_Member_Products_Tree4.aspx");
|
||||
};
|
||||
}
|
||||
|
||||
protected void Select_Bind()
|
||||
{
|
||||
|
||||
// 在此处放置用户代码以初始化页面
|
||||
string remark = null;
|
||||
int lbConut2 = 0;
|
||||
DataSet ds = daoCategory.GetList("gtype=" + gtype + " and ttype=6 Order By C_Layer asc,C_LinkID asc");
|
||||
foreach (DataRowView drv2 in ds.Tables[0].DefaultView)//绑定根结点
|
||||
{
|
||||
lbConut2 = Convert.ToInt32(drv2["C_Layer"].ToString());
|
||||
string LB = drv2["C_NAME"].ToString();
|
||||
string Pid = drv2["C_PARENTID"].ToString();
|
||||
string id = drv2["C_ID"].ToString();
|
||||
remark = "";
|
||||
for (int l = 0; l < lbConut2; l++)
|
||||
{
|
||||
remark += "├";
|
||||
}
|
||||
if (lbConut2 == 1)
|
||||
{
|
||||
C_PARENTID.Items.Add(new ListItem(remark + LB, id + "|" + Pid));
|
||||
}
|
||||
else
|
||||
{
|
||||
int jj = 0;
|
||||
for (int j = 0; j < C_PARENTID.Items.Count; j++)
|
||||
{
|
||||
string[] lbpid = C_PARENTID.Items[j].Value.Split('|');
|
||||
if (lbpid.Length == 2)
|
||||
{
|
||||
if (Pid == lbpid[1])
|
||||
{
|
||||
jj += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < C_PARENTID.Items.Count; j++)
|
||||
{
|
||||
string[] lbpid = C_PARENTID.Items[j].Value.Split('|');
|
||||
if (lbpid.Length == 2)
|
||||
{
|
||||
if (Pid == lbpid[0])
|
||||
{
|
||||
if (jj != 0)
|
||||
{
|
||||
C_PARENTID.Items.Insert(j + jj + 1, new ListItem(remark + LB, id + "|" + Pid));
|
||||
}
|
||||
else
|
||||
{
|
||||
C_PARENTID.Items.Insert(j + 1, new ListItem(remark + LB, id + "|" + Pid));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ds.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user