341 lines
13 KiB
C#
341 lines
13 KiB
C#
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_Products4 : 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_Products4.aspx");
|
||
}
|
||
if (IFStores != 1)
|
||
{
|
||
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
|
||
}
|
||
if (MemberJS.IndexOf("视频管理") == -1)
|
||
{
|
||
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
|
||
}
|
||
Page.Title = "品牌展示列表 - " + GetWebName;
|
||
|
||
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 key = HttpUtility.UrlDecode(Request.QueryString["key"]);
|
||
String state = HttpUtility.UrlDecode(Request.QueryString["state"]);
|
||
|
||
|
||
sb2.Append("gtype=" + gtype + " and utype='6' And IFDelete=0 and P_UserID=0");
|
||
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 + "%' or P_bianhao 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 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_IFTop", "1");
|
||
}
|
||
else if (strs == "14")
|
||
{
|
||
daoProduct.Update(strID, "P_IFTop", "0");
|
||
}
|
||
else if (strs == "15")
|
||
{
|
||
|
||
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());
|
||
Double G_JF = Double.Parse(Dr["G_JF"].ToString());
|
||
int G_KC = int.Parse(Dr["G_KC"].ToString());
|
||
strje += G_Name + " " + G_JG + "元/" + G_KC + "<br>";
|
||
}
|
||
strje += "</td>";
|
||
}
|
||
else
|
||
{
|
||
strje += je.ToString("f2") + "元/" + P_Inventory;
|
||
}
|
||
ds.Clear();
|
||
return strje;
|
||
}
|
||
}
|
||
} |