Files
g.hnyhua.cn/Mtxfw.VipSite/Admin_Member_Products1.aspx.cs
2026-02-07 15:48:27 +08:00

415 lines
17 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using System.IO;
namespace Mtxfw.VipSite
{
public partial class Admin_Member_Products1 : 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_Products1.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();
Data_Bind();
}
MyPager.PageChanged += delegate(object s, EventArgs ex)
{
Data_Bind();
};
}
protected void Data_Bind()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.Text.StringBuilder sb2 = new System.Text.StringBuilder();
String cls = Request.QueryString["cls"];
String cls2 = Request.QueryString["cls2"];
String key = HttpUtility.UrlDecode(Request.QueryString["key"]);
String state = HttpUtility.UrlDecode(Request.QueryString["state"]);
sb2.Append("gtype=" + gtype + " and utype='2' And IFDelete=0");
if (MemberuLevel29 > 0)
{
sb.Append(" And P_UserID=" + MemberShippingID);
seclect_Drop.Items.Remove(new ListItem("设为已处理", "0"));
seclect_Drop.Items.Remove(new ListItem("设为未处理", "1"));
seclect_Drop.Items.Remove(new ListItem("设为推荐", "2"));
seclect_Drop.Items.Remove(new ListItem("取消推荐", "3"));
seclect_Drop.Items.Remove(new ListItem("设为热销", "6"));
seclect_Drop.Items.Remove(new ListItem("取消热销", "7"));
seclect_Drop.Items.Remove(new ListItem("修改排序", "12"));
}
else
{
sb.Append(" And P_UserID=0");
}
if (!String.IsNullOrEmpty(cls) && cls != "-1")
{
Drop_Cls.SelectedValue = cls;
cls = cls.Split('|')[0];
sb.Append("and (P_CATEGORY=" + cls + " Or P_CATEGORYs like '%," + cls + ",%')");
}
if (!String.IsNullOrEmpty(state) && state != "所有状态")
{
if (state == "已处理" || state == "未处理")
{
sb.Append("and P_State='" + state + "'");
}
if (state == "推荐")
{
sb.Append("and P_COMMENDF=1");
}
if (state == "限时抢购")
{
sb.Append("and P_qgproduct=1");
}
if (state == "热销")
{
sb.Append("and P_ppproduct=1");
}
if (state == "特色优选")
{
sb.Append("and P_jpproduct=1");
}
if (state == "每日上新")
{
sb.Append("and P_cjproduct=1");
}
if (state == "置顶")
{
sb.Append("and P_IFTop=1");
}
Drop_State.Text = state;
}
if (!String.IsNullOrEmpty(key))
{
sb.Append("and P_NAME like '%" + key + "%'");
}
MyPager.PageSize = 100;
MyPager.RecordCount = daoProduct.GetCount(sb2.ToString() + sb.ToString());
Mtxfw.Utility.Tools.ToBind(Repeater1, daoProduct.GetPager(MyPager, "", sb2.ToString() + sb.ToString() + " Order by P_HITED desc"));
}
protected void Select_Bind()
{
string remark = null;
int lbConut2 = 0;
DataSet ds = daoCategory.GetList("gtype=" + gtype + " and ttype=2 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)
{
Drop_Cls.Items.Add(new ListItem(remark + LB, id + "|" + Pid));
}
else
{
int jj = 0;
for (int j = 0; j < Drop_Cls.Items.Count; j++)
{
string[] lbpid = Drop_Cls.Items[j].Value.Split('|');
if (lbpid.Length == 2)
{
if (Pid == lbpid[1])
{
jj += 1;
}
}
}
for (int j = 0; j < Drop_Cls.Items.Count; j++)
{
string[] lbpid = Drop_Cls.Items[j].Value.Split('|');
if (lbpid.Length == 2)
{
if (Pid == lbpid[0])
{
if (jj != 0)
{
Drop_Cls.Items.Insert(j + jj + 1, new ListItem(remark + LB, id + "|" + Pid));
}
else
{
Drop_Cls.Items.Insert(j + 1, new ListItem(remark + LB, id + "|" + Pid));
}
}
}
}
}
}
ds.Clear();
Drop_Cls.Items.Insert(0, new ListItem("==请选择分类==", ""));
}
protected void Delete_Click(object s, CommandEventArgs ex)
{
Int32 ID = int.Parse(ex.CommandName);
Mtxfw.Model.P_Product model = daoProduct.GetModel(ID);
if (model != null)
{
daoCategory.Update2(model.P_CATEGORY, -1);
daoProduct.UpdateIFDelete(1, DateTime.Now.ToString(), ID);
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
Cache.Remove(CacheEnum.Key.ToString());
}
if (model.P_NAME2 != "")
{
try
{
string yvideo = model.P_NAME2;
File.Delete(Server.MapPath(yvideo));
model.P_NAME2 = "";
daoProduct.Update(model);
}
catch
{
}
}
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "删除精选商品" + model.P_NAME;
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
}
Response.Redirect(Request.Url.AbsoluteUri);
}
protected void Run_Click(object s, System.EventArgs e)
{
CheckBox Check = new CheckBox();
string strs = seclect_Drop.SelectedItem.Value;
foreach (RepeaterItem Item in Repeater1.Items)
{
//在行中查找到该单选框
Check = (CheckBox)Item.FindControl("checka");
int strID = int.Parse(Check.CssClass);
if (Check.Checked == true)
{
Mtxfw.Model.P_Product model = daoProduct.GetModel(strID);
if (model != null)
{
if (strs == "0")
{
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "已处理精选商品" + model.P_NAME;
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
daoProduct.Update(strID, "P_State", "已处理");
}
else if (strs == "1")
{
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "未处理精选商品" + model.P_NAME;
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
daoProduct.Update(strID, "P_State", "未处理");
}
else if (strs == "2")
{
daoProduct.Update(strID, "P_COMMENDF", "True");
}
else if (strs == "3")
{
daoProduct.Update(strID, "P_COMMENDF", "False");
}
else if (strs == "4")
{
daoProduct.Update(strID, "P_qgproduct", "True");
}
else if (strs == "5")
{
daoProduct.Update(strID, "P_qgproduct", "False");
}
else if (strs == "6")
{
daoProduct.Update(strID, "P_ppproduct", "True");
}
else if (strs == "7")
{
daoProduct.Update(strID, "P_ppproduct", "False");
}
else if (strs == "8")
{
daoProduct.Update(strID, "P_jpproduct", "True");
}
else if (strs == "9")
{
daoProduct.Update(strID, "P_jpproduct", "False");
}
else if (strs == "10")
{
daoProduct.Update(strID, "P_cjproduct", "True");
}
else if (strs == "11")
{
daoProduct.Update(strID, "P_cjproduct", "False");
}
else if (strs == "12")
{
TextBox LinkID = (TextBox)Item.FindControl("txtLinkID");
if (!System.Text.RegularExpressions.Regex.IsMatch(LinkID.Text, @"^-?\d+$"))
{
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('" + model.P_NAME + "的排序ID填写错误');</script>");
}
else
{
daoProduct.Update(strID, "P_HITED", LinkID.Text);
}
}
else if (strs == "13")
{
daoProduct.Update(strID, "P_HITED", "0");
}
else if (strs == "14")
{
daoCategory.Update2(model.P_CATEGORY, -1);
if (model.P_NAME2 != "")
{
try
{
string yvideo = model.P_NAME2;
File.Delete(Server.MapPath(yvideo));
model.P_NAME2 = "";
daoProduct.Update(model);
}
catch
{
}
}
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "删除精选商品" + model.P_NAME;
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
daoProduct.UpdateIFDelete(1, DateTime.Now.ToString(), strID);
}
}
}
}
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
Cache.Remove(CacheEnum.Key.ToString());
}
Createtopproduct();
Response.Redirect(Request.Url.AbsoluteUri);
}
public void Createtopproduct()
{
}
protected string getje(Double je,int P_Inventory, int id)
{
string strje = "";
DataSet ds = new DAL.P_Guige().GetList("ttype=0 And G_PID=" + id);
if (ds.Tables[0].Rows.Count > 0)
{
strje +="";
foreach (System.Data.DataRow Dr in ds.Tables[0].Rows)
{
int G_ID = int.Parse(Dr["G_ID"].ToString());
string G_Name = Dr["G_Name"].ToString();
Double G_JG = Double.Parse(Dr["G_JG"].ToString());
int G_KC = int.Parse(Dr["G_KC"].ToString());
strje += G_Name + "&nbsp;" + G_JG + "元/" + G_KC + "<br>";
}
strje += "</td>";
}
else
{
strje += je.ToString("f2") + "元/" + P_Inventory;
}
ds.Clear();
return strje;
}
}
}