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

604 lines
29 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
namespace Mtxfw.VipSite
{
public partial class Admin_Member_Products_add12 : Mtxfw.Utility.MemberBase
{
public Mtxfw.DAL.P_Guige daoGuige = new Mtxfw.DAL.P_Guige();
public Mtxfw.DAL.P_Category daoCategory = new Mtxfw.DAL.P_Category();
public Mtxfw.DAL.P_Product daoProduct = new Mtxfw.DAL.P_Product();
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config("");
public String strTitle = "", strBody = "", guige="", ProductLB1 = "", ProductLB2 = "", ProductLB3 = "";
public string strimg = "", selyanse = "", strdisplay = "", strInventory = "库存";
public int gtype = 0;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
string hostname = Request.Url.Host;
if (Session["IFPassword"] == null)
{
Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_Products12.aspx");
}
if (IFStores != 1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
if (MemberJS.IndexOf("门店商品列表") == -1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
string stryanseoption = "";
if (!IsPostBack)
{
if (Request.UrlReferrer != null)
{
Hidd_Url.Value = Request.UrlReferrer.ToString();
}
else
{
Hidd_Url.Value = "Admin_Member_Products12.aspx";
}
}
if (Request.QueryString["action"] == "add")
{
strTitle = "添加门店商品";
if (!IsPostBack)
{
Btn_Update.Visible = false;
}
if (Session["P_CATEGORY1"] != null)
{
ProductLB1 = Session["P_CATEGORY1"].ToString();
}
if (Session["P_CATEGORY2"] != null)
{
ProductLB2 = Session["P_CATEGORY2"].ToString();
}
if (Session["P_CATEGORY3"] != null)
{
ProductLB3 = Session["P_CATEGORY3"].ToString();
}
if (!IsPostBack)
{
Session["jiaoyouPhoto"] = "";
}
DataSet ds = daoGuige.GetList("ttype=0 And G_PID=0");
if (ds.Tables[0].Rows.Count > 0)
{
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_JG0 = Double.Parse(Dr["G_JG0"].ToString());
Double G_JG1 = Double.Parse(Dr["G_JG1"].ToString());
Double G_JG2 = Double.Parse(Dr["G_JG2"].ToString());
Double G_JG3 = Double.Parse(Dr["G_JG3"].ToString());
Double G_JF = Double.Parse(Dr["G_JF"].ToString());
Double G_ZL = Double.Parse(Dr["G_ZL"].ToString());
int G_KC = int.Parse(Dr["G_KC"].ToString());
string colors = Dr["G_Color"].ToString();
string tps = Dr["G_Images"].ToString();
guige += "<ul class=\"addggbox_box addggbox_boxed\" id=\"addggbox_box" + G_ID + "\"><li class=\"textgg\"><input id=\"textgg\" type=\"text\" value=\"" + G_Name + "\" /></li><li class=\"textjg2\"><input id=\"textjg2\" type=\"text\" value=\"" + G_JG2 + "\" /></li><li class=\"textjg\"><input id=\"textjg\" type=\"text\" value=\"" + G_JG + "\" /></li><li class=\"textjg\"><input id=\"textjf\" type=\"text\" value=\"" + G_JF + "\" /></li><li class=\"textjg\"><input id=\"textjg3\" type=\"text\" value=\"" + G_JG3 + "\" /></li><li class=\"textzl\"><input id=\"textzl\" type=\"text\" value=\"" + G_ZL + "\" /></li><li class=\"textkc\"><input id=\"textkc\" type=\"text\" value=\"" + G_KC + "\" /></li><li class=\"textcolor\" colors=\"" + colors + "\" onclick=\"showcolor(" + G_ID + ")\">#颜色#</li><li class=\"texttp\" tps=\"" + tps + "\" onclick=\"showtp(" + G_ID + ")\">#图片#</li><li class=\"textcz\"><input id=\"editbtn\" class=\"abtn\" onclick=\"showedit(" + G_ID + ")\" type=\"button\" value=\"编辑\" /><input id=\"delbtn\" onclick=\"ondelgg(" + G_ID + ")\" class=\"abtn\" type=\"button\" value=\"删除\" /></li></ul>";
//guige += "<li class=\"textjg\"><input id=\"textjg3\" type=\"text\" value=\"" + G_JG3 + "\" /></li><li class=\"textjg\"><input id=\"textjg0\" type=\"text\" value=\"" + G_JG0 + "\" /></li><li class=\"textjg\"><input id=\"textjg1\" type=\"text\" value=\"" + G_JG1 + "\" /></li><li class=\"textjf\"><input id=\"textjf\" type=\"text\"value=\"" + G_JF + "\" /></li>";
}
}
ds.Clear();
if (!IsPostBack)
{
Text_bianhao.Text = "A" + Mtxfw.Utility.Common.CreatenTimestamp(DateTime.Now);
}
}
else
{
strTitle = "修改门店商品";
if (!IsPostBack)
{
Btn_Insert.Visible = false;
}
if (!IsPostBack)
{
hidpid.Value = Request.QueryString["ID"].ToString();
}
Mtxfw.Model.P_Product model = daoProduct.GetModel(int.Parse(hidpid.Value));
if (model != null)
{
if (model.P_ppproduct)
{
strdisplay = " style=\" display:none;\"";
strInventory = "今日赠送份数";
}
if (!IsPostBack)
{
Text_P_NAME.Text = model.P_NAME;
hidden_video.Text = model.P_NAME2;
hiddenyanse.Value = model.P_yanse;
hiddenphotos.Value = model.P_images;
P_Market_P.Text = model.P_Market_P.ToString();
P_VIP_P.Text = model.P_VIP_P.ToString();
P_VIP_P1.Text = model.P_VIP_P1.ToString();
P_VIP_P2.Text = model.P_VIP_P2.ToString();
P_M_P.Text = model.P_M_P.ToString();
P_CB_P.Text = model.P_CB_P.ToString();
P_YH_P.Text = model.P_YH_P.ToString();
P_M_Web.Text = model.P_M_Web;
P_JiangLi.Text = model.P_JiangLi.ToString();
P_JiangLi2.Text = model.P_JiangLi2.ToString();
//P_JiangLi3.Text = model.P_JiangLi3.ToString();
txtContent.Text = model.P_DESCRIPTION1;
txtContent2.Text = model.P_DESCRIPTION2;
Text_bianhao.Text = model.P_bianhao;
}
DataSet ds = daoGuige.GetList("ttype=0 And G_PID=" + model.P_ID);
if (ds.Tables[0].Rows.Count > 0)
{
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_JG0 = Double.Parse(Dr["G_JG0"].ToString());
Double G_JG1 = Double.Parse(Dr["G_JG1"].ToString());
Double G_JG2 = Double.Parse(Dr["G_JG2"].ToString());
Double G_JG3 = Double.Parse(Dr["G_JG3"].ToString());
Double G_JF = Double.Parse(Dr["G_JF"].ToString());
Double G_ZL = Double.Parse(Dr["G_ZL"].ToString());
int G_KC = int.Parse(Dr["G_KC"].ToString());
string colors = Dr["G_Color"].ToString();
string tps = Dr["G_Images"].ToString();
guige += "<ul class=\"addggbox_box addggbox_boxed\" id=\"addggbox_box" + G_ID + "\"><li class=\"textgg\"><input id=\"textgg\" type=\"text\" value=\"" + G_Name + "\" /></li><li class=\"textjg2\"><input id=\"textjg2\" type=\"text\"value=\"" + G_JG2 + "\" /></li><li class=\"textjg\"><input id=\"textjg\" type=\"text\" value=\"" + G_JG + "\" /></li><li class=\"textjg\"><input id=\"textjf\" type=\"text\" value=\"" + G_JF + "\" /></li><li class=\"textjg\"><input id=\"textjg3\" type=\"text\" value=\"" + G_JG3 + "\" /></li><li class=\"textzl\"><input id=\"textzl\" type=\"text\" value=\"" + G_ZL + "\" /></li><li class=\"textkc\"><input id=\"textkc\" type=\"text\" value=\"" + G_KC + "\" /></li><li class=\"textcolor\" colors=\"" + colors + "\" onclick=\"showcolor(" + G_ID + ")\">#颜色#</li><li class=\"texttp\" tps=\"" + tps + "\" onclick=\"showtp(" + G_ID + ")\">#图片#</li><li class=\"textcz\"><input id=\"editbtn\" class=\"abtn\" onclick=\"showedit(" + G_ID + ")\" type=\"button\" value=\"编辑\" /><input id=\"delbtn\" onclick=\"ondelgg(" + G_ID + ")\" class=\"abtn\" type=\"button\" value=\"删除\" /></li></ul>";
//guige += "<li class=\"textjg\"><input id=\"textjg3\" type=\"text\" value=\"" + G_JG3 + "\" /></li><li class=\"textjg\"><input id=\"textjg0\" type=\"text\" value=\"" + G_JG0 + "\" /></li><li class=\"textjg\"><input id=\"textjg1\" type=\"text\" value=\"" + G_JG1 + "\" /></li><li class=\"textjf\"><input id=\"textjf\" type=\"text\"value=\"" + G_JF + "\" /></li>";
}
}
ds.Clear();
string[] ACATEGORYs = model.P_CATEGORYs.Split(',');
if (ACATEGORYs.Length > 1)
{
ProductLB1 = ACATEGORYs[1];
}
if (ACATEGORYs.Length > 2)
{
ProductLB2 = ACATEGORYs[2];
}
if (ACATEGORYs.Length > 3)
{
ProductLB3 = ACATEGORYs[3];
}
strBody = model.P_DESCRIPTION;
}
}
Btn_Insert.Click += delegate(object s, EventArgs ex)
{
bool b = true;
if (Text_P_NAME.Text.Trim() == "")
{
b = false;
Mtxfw.Utility.Tools.Message("商品名称不能为空");
}
string strguige="", strProductLB1 = "", strProductLB2 = "", strProductLB3 = "";
if (Request.Form["select_p1"] != null)
{
string[] strp = Request.Form["select_p1"].ToString().Split('|');
strProductLB1 = strp[0];
if (strp.Length >1)
{
strguige = strp[1];
}
}
if (Request.Form["select_p2"] != null)
{
strProductLB2 = Request.Form["select_p2"].ToString();
}
if (Request.Form["select_p3"] != null)
{
strProductLB3 = Request.Form["select_p3"].ToString();
}
if (b)
{
if (daoProduct.GetCount("utype='14' and P_UserID=0 And P_bianhao='" + Text_bianhao.Text + "'") > 0)
{
b = false;
Mtxfw.Utility.Tools.Message("商品编号已存在");
}
}
if (b)
{
Mtxfw.Model.P_Product model = new Mtxfw.Model.P_Product();
model.P_NAME = Text_P_NAME.Text;
model.P_ENAME = "";
model.P_NAME2 = hidden_video.Text;
model.P_UserID = (MemberuLevel29 > 0 ? MemberShippingID : 0);
model.P_State = (MemberuLevel29 > 0 ? "未处理" : "已处理");
model.P_CATEGORY = 0;
string P_CATEGORYs = "," + strProductLB1 + ",";
if (strProductLB2 != "")
{
P_CATEGORYs += strProductLB2 + ",";
}
if (strProductLB3 != "")
{
P_CATEGORYs += strProductLB3 + ",";
}
model.P_CATEGORYs = P_CATEGORYs;
Session["P_CATEGORY1"] = strProductLB1;
Session["P_CATEGORY2"] = strProductLB2;
Session["P_CATEGORY3"] = strProductLB3;
if (!String.IsNullOrEmpty(P_Market_P.Text))
{
model.P_Market_P = Convert.ToDouble(P_Market_P.Text);
}
if (!String.IsNullOrEmpty(P_VIP_P.Text))
{
model.P_VIP_P = Convert.ToDouble(P_VIP_P.Text);
}
if (!String.IsNullOrEmpty(P_VIP_P1.Text))
{
model.P_VIP_P1 = Convert.ToDouble(P_VIP_P1.Text);
}
if (!String.IsNullOrEmpty(P_VIP_P2.Text))
{
model.P_VIP_P2 = Convert.ToDouble(P_VIP_P2.Text);
}
if (!String.IsNullOrEmpty(P_M_P.Text))
{
model.P_M_P = int.Parse(P_M_P.Text);
}
if (!String.IsNullOrEmpty(P_CB_P.Text))
{
model.P_CB_P = Convert.ToDouble(P_CB_P.Text);
}
if (!String.IsNullOrEmpty(P_YH_P.Text))
{
model.P_YH_P = Convert.ToDouble(P_YH_P.Text);
}
else
{
model.P_YH_P = 0;
}
model.P_M_Web = P_M_Web.Text;
model.P_DESCRIPTION = Hidd_myEditor.Value;
model.P_COMMENDF = false;
model.P_Orders = 0;
model.P_ADDATE = DateTime.Now;
model.P_HITED = 0;
model.utype = "14";
model.utype0 = MemberuLevel29;
model.Province = "0";
model.City = "0";
model.County = "0";
model.P_JiangLi = int.Parse(P_JiangLi.Text);
model.P_JiangLi2 = int.Parse(P_JiangLi2.Text);
model.P_JiangLi3 = 0;
model.P_peitype = 1;
model.P_peitype0 = 1;
string selyanse = hiddenyanse.Value;
string strPhotos = "";
if (hiddenphotos.Value != "")
{
string[] strjiaoyouPhotoA = hiddenphotos.Value.Split('|');
int j = 0;
for (int i = 0; i < strjiaoyouPhotoA.Length; i++)
{
if (strjiaoyouPhotoA[i] != "")
{
string[] strPhoto = strjiaoyouPhotoA[i].Split(',');
string P_yanse = "";
if (Request.Form["select_yanse_" + j] != null)
{
P_yanse = Request.Form["select_yanse_" + j].ToString();
}
if (P_yanse != "")
{
try
{
strPhotos += strPhoto[0] + "," + P_yanse + "|";
}
catch
{
strPhotos += strPhoto[0] + "|";
}
}
else
{
strPhotos += strPhoto[0] + "|";
}
j += 1;
}
}
}
model.P_yanse = selyanse;
model.P_images = strPhotos;
model.P_DESCRIPTION1 = txtContent.Text;
model.P_DESCRIPTION2 = txtContent2.Text;
model.P_EDESCRIPTION = "";
model.P_bianhao = Text_bianhao.Text;
model.gtype = gtype;
int returnid = daoProduct.Add(model);
string strzd = daoProduct.Getzd("max(P_HITED)", "utype='0'").ToString();
if (strzd != "")
{
daoProduct.Update(returnid, "P_HITED", (Convert.ToInt32(strzd)+1).ToString());
}
new DAL.P_Guige().Update(returnid);
daoCategory.Update2(model.P_CATEGORY, 1);
if (Session["UploadFileIng"] != null)
{
string[] stra = Session["UploadFileIng"].ToString().Split(',');
foreach (string str in stra)
{
if (str.Trim() != "")
{
if (model.P_DESCRIPTION.IndexOf(str.Trim()) == -1)
{
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
{
System.IO.File.Delete(Server.MapPath(str.Trim()));
}
}
}
}
Session.Remove("UploadFileIng");
}
if (Session["UploadFileIng0"] != null)
{
string[] stra = Session["UploadFileIng0"].ToString().Split(',');
foreach (string str in stra)
{
if (str.Trim() != "")
{
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
{
System.IO.File.Delete(Server.MapPath(str.Trim()));
}
}
}
Session.Remove("UploadFileIng0");
}
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
Cache.Remove(CacheEnum.Key.ToString());
}
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(Hidd_Url.Value);
}
};
Btn_Update.Click += delegate(object s, EventArgs ex)
{
bool b = true;
string strguige = "",strProductLB1 = "", strProductLB2 = "", strProductLB3 = "";
if (Request.Form["select_p1"] != null)
{
string[] strp = Request.Form["select_p1"].ToString().Split('|');
strProductLB1 = strp[0];
if (strp.Length > 1)
{
strguige = strp[1];
}
}
if (Request.Form["select_p2"] != null)
{
strProductLB2 = Request.Form["select_p2"].ToString();
}
if (Request.Form["select_p3"] != null)
{
strProductLB3 = Request.Form["select_p3"].ToString();
}
if (strProductLB1 == "")
{
b = false;
Mtxfw.Utility.Tools.Message("分类必须选择");
}
if (b)
{
if (Text_P_NAME.Text.Trim() == "")
{
b = false;
Mtxfw.Utility.Tools.Message("商品名称不能为空");
}
}
Int32 P_ID = int.Parse(Request.QueryString["ID"]);
if (b)
{
if (daoProduct.GetCount("utype='14' and P_UserID=0 And P_bianhao='" + Text_bianhao.Text + "' And P_ID<>" + P_ID) > 0)
{
b = false;
Mtxfw.Utility.Tools.Message("商品编号已存在");
}
}
if (b)
{
Mtxfw.Model.P_Product model = daoProduct.GetModel(P_ID);
model.P_ID = P_ID;
model.P_NAME = Text_P_NAME.Text;
model.P_NAME2 = hidden_video.Text;
string P_CATEGORYs = "," + strProductLB1 + ",";
if (strProductLB2 != "")
{
P_CATEGORYs += strProductLB2 + ",";
}
if (strProductLB3 != "")
{
P_CATEGORYs += strProductLB3 + ",";
}
model.P_CATEGORYs = P_CATEGORYs;
if (!String.IsNullOrEmpty(P_Market_P.Text))
{
model.P_Market_P = Convert.ToDouble(P_Market_P.Text);
}
if (!String.IsNullOrEmpty(P_VIP_P.Text))
{
model.P_VIP_P = Convert.ToDouble(P_VIP_P.Text);
}
if (!String.IsNullOrEmpty(P_VIP_P1.Text))
{
model.P_VIP_P1 = Convert.ToDouble(P_VIP_P1.Text);
}
if (!String.IsNullOrEmpty(P_VIP_P2.Text))
{
model.P_VIP_P2 = Convert.ToDouble(P_VIP_P2.Text);
}
if (!String.IsNullOrEmpty(P_M_P.Text))
{
model.P_M_P = int.Parse(P_M_P.Text);
}
if (!String.IsNullOrEmpty(P_CB_P.Text))
{
model.P_CB_P = Convert.ToDouble(P_CB_P.Text);
}
if (!String.IsNullOrEmpty(P_YH_P.Text))
{
model.P_YH_P = Convert.ToDouble(P_YH_P.Text);
}
model.P_Inventory = 0;
model.P_M_Web = P_M_Web.Text;
model.P_DESCRIPTION = Hidd_myEditor.Value;
if (MemberuLevel29 > 0)
{
model.P_State = "未处理";
model.P_qgproduct = false;
}
model.P_JiangLi = int.Parse(P_JiangLi.Text);
model.P_JiangLi2 = int.Parse(P_JiangLi2.Text);
string selyanse = hiddenyanse.Value;
string strPhotos = "";
if (hiddenphotos.Value != "")
{
string[] strjiaoyouPhotoA = hiddenphotos.Value.Split('|');
int j = 0;
for (int i = 0; i < strjiaoyouPhotoA.Length; i++)
{
if (strjiaoyouPhotoA[i] != "")
{
string[] strPhoto = strjiaoyouPhotoA[i].Split(',');
string P_yanse = "";
if (Request.Form["select_yanse_" + j] != null)
{
P_yanse = Request.Form["select_yanse_" + j].ToString();
}
if (P_yanse != "")
{
try
{
strPhotos += strPhoto[0] + "," + P_yanse + "|";
}
catch
{
strPhotos += strPhoto[0] + "|";
}
}
else
{
strPhotos += strPhoto[0] + "|";
}
j += 1;
}
}
}
model.P_yanse = selyanse;
model.P_images = strPhotos;
model.P_DESCRIPTION1 = txtContent.Text;
model.P_DESCRIPTION2 = txtContent2.Text;
model.P_bianhao = Text_bianhao.Text;
daoProduct.Update(model);
if (Session["UploadFileIng"] != null)
{
string[] stra = Session["UploadFileIng"].ToString().Split(',');
foreach (string str in stra)
{
if (str.Trim() != "")
{
if (model.P_DESCRIPTION.IndexOf(str.Trim()) == -1)
{
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
{
System.IO.File.Delete(Server.MapPath(str.Trim()));
}
}
}
}
Session.Remove("UploadFileIng");
}
if (Session["UploadFileIng0"] != null)
{
string[] stra = Session["UploadFileIng0"].ToString().Split(',');
foreach (string str in stra)
{
if (str.Trim() != "")
{
if (System.IO.File.Exists(Server.MapPath(str.Trim())))
{
System.IO.File.Delete(Server.MapPath(str.Trim()));
}
}
}
Session.Remove("UploadFileIng0");
}
System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator();
while (CacheEnum.MoveNext())
{
Cache.Remove(CacheEnum.Key.ToString());
}
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(Hidd_Url.Value);
}
};
}
protected string getProductLB()
{
StringBuilder sb = new StringBuilder();
Mtxfw.DAL.province daoPro = new Mtxfw.DAL.province();
System.Data.DataSet Ds = daoCategory.GetList("gtype=" + gtype + " and ttype=0 And C_Layer=1 Order By C_Layer asc,C_LinkID asc"); ;
System.Data.DataTable Dt = (Ds != null && Ds.Tables[0] != null) ? Ds.Tables[0] : null;
foreach (System.Data.DataRow Dr in Dt.Rows)
{
sb.Append("<option value=\"" + Dr["C_ID"] + "\">" + Dr["C_NAME"] + "</option>\r\n");
}
return sb.ToString();
}
}
}