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_add10 : 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=""; 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_Products10.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_Products10.aspx"; } } if (Request.QueryString["action"] == "add") { strTitle = "添加补贴专区商品"; if (!IsPostBack) { Btn_Update.Visible = false; } 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 += ""; //guige += "
  • "; } } 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 += ""; //guige += "
  • "; } } ds.Clear(); strBody = model.P_DESCRIPTION; } } if (hiddenphotos.Value != "") { string[] strjiaoyouPhotoA = hiddenphotos.Value.Split('|'); for (int i = 0; i < strjiaoyouPhotoA.Length; i++) { if (strjiaoyouPhotoA[i] != "") { string[] strPhoto = strjiaoyouPhotoA[i].Split(','); strimg += "
  • 删除"; if (i == 0) { strimg += " 已设为封面"; } else { strimg += " 设为封面"; } strimg += "
  • "; } } } 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 (b) { if (daoProduct.GetCount("utype='0' 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 = 0; model.P_State = "已处理"; model.P_CATEGORY = 0; model.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); } 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 = "12"; 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; 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='0' 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; 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; 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("\r\n"); } return sb.ToString(); } } }