/// <summary> /// 更新产品类别 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateMSPCategory(MSProductCategory model) { string safeslq = ""; safeslq = "UPDATE MS_ProductCategory SET "; if (model.SID != null && model.SID != "") { safeslq += "[SID]='" + model.SID + "',"; } if (model.UpID != null) { safeslq += "[UpID]='" + model.UpID + "',"; } if (model.Cname != null && model.Cname != "") { safeslq += "Cname='" + model.Cname + "',"; } if (model.CsecHand != null) { safeslq += " CsecHand=" + (model.CsecHand == 1 ? 1 : 0) + ", "; } safeslq += " Cstate=" + (model.Cstate == 1 ? 1 : 0) + ", "; safeslq += " Sortin=" + (model.Sortin != 1 ? model.Sortin : 1) + " "; safeslq += " where ID='" + model.ID + "'"; int rowsAffected = DbHelperSQL.ExecuteSql(safeslq.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 添加产品类别 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddMSPCategory(MSProductCategory model) { string sql = @"INSERT INTO [MS_ProductCategory] ([ID],[SID],[UpID],[Cname],[CsecHand],[Cstate],[Sortin],[AddTime]) VALUES (@ID,@SID,@UpID,@Cname,@CsecHand,@Cstate,@Sortin,@AddTime)"; System.Data.SqlClient.SqlParameter[] paras = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@ID", model.ID), new System.Data.SqlClient.SqlParameter("@SID", model.SID), new System.Data.SqlClient.SqlParameter("@UpID", model.UpID), new System.Data.SqlClient.SqlParameter("@Cname", model.Cname), new System.Data.SqlClient.SqlParameter("@CsecHand", (model.CsecHand == 1?1:0)), new System.Data.SqlClient.SqlParameter("@Cstate", (model.Cstate == 1?1:0)), new System.Data.SqlClient.SqlParameter("@Sortin", (model.Sortin != 1?model.Sortin:1)), new System.Data.SqlClient.SqlParameter("@AddTime", DateTime.Now) }; int rowsAffected = DbHelperSQL.ExecuteSql(sql.ToString(), paras); if (rowsAffected > 0) { return(true); } else { return(false); } }
protected void btnSave_Click(object sender, EventArgs e) { if (Session["strLoginName"].ToString() != null && Session["strLoginName"].ToString() != "") { if (ddlcategorylist.SelectedValue.Trim() != null && ddlcategorylist.SelectedValue.Trim() != "") { if (cname.Text.Trim() != null && cname.Text.Trim() != "") { MSProductCategoryDAL categoryDal = new MSProductCategoryDAL(); if (categoryDal.ExistMSPC("", ddlcategorylist.SelectedValue.Trim(), cname.Text)) { MessageBox.Show(this, "该类别已经存在!"); } else { MSProductCategory categoryModel = new MSProductCategory(); string parm = ""; categoryModel.SID = parm; if (sch != null && sch != "") { categoryModel.CsecHand = Convert.ToInt32(sch); } if (ddlcategorylist.SelectedValue.Trim() != "0") { parm = ddlcategorylist.SelectedValue; } categoryModel.UpID = parm; if (sortin.Text.Trim() != null && sortin.Text.Trim() != "") { categoryModel.Sortin = Convert.ToInt32(sortin.Text); } categoryModel.Cname = cname.Text; categoryModel.Cstate = 0; categoryModel.ID = Guid.NewGuid().ToString("N").ToUpper(); if (categoryDal.AddMSPCategory(categoryModel)) { MessageBox.Show(this, "操作成功!"); } else { MessageBox.Show(this, "操作失败!"); } } } else { MessageBox.Show(this, "请输入相应名称!"); } } else { MessageBox.Show(this, "请选择相应的类别!"); } } else { return; } }
protected void btnSave_Click(object sender, EventArgs e) { if (Session["strLoginName"].ToString() != null && Session["strLoginName"].ToString() != "") { if (cname.Text.Trim() != null && cname.Text.Trim() != "") { MSProductCategoryDAL categoryDal = new MSProductCategoryDAL(); MSProductCategory categoryModel = new MSProductCategory(); categoryModel.Cname = cname.Text; string parm = ""; categoryModel.SID = parm; if (ddlcategorylist.SelectedValue.Trim() != "0") { parm = ddlcategorylist.SelectedValue; } categoryModel.UpID = parm; if (sortin.Text.Trim() != null && sortin.Text.Trim() != "") { categoryModel.Sortin = Convert.ToInt32(sortin.Text); } categoryModel.Cstate = 0; categoryModel.ID = strID; if (sch != null && sch != "") { categoryModel.CsecHand = Convert.ToInt32(sch); } if (categoryDal.UpdateMSPCategory(categoryModel)) { MessageBox.Show(this, "操作成功!"); } else { MessageBox.Show(this, "操作失败!"); } } else { MessageBox.Show(this, "请输入相应名称或店铺!"); } } else { return; } }
void showdetailinfo() { ddlcategorylist.Items.Clear(); MSProductCategoryDAL selectcategoryDal = new MSProductCategoryDAL(); DataSet ds = new DataSet(); ds = selectcategoryDal.GetCategoryList(" and UpID='' and [SID]!='' "); DataTable dt = ds.Tables[0]; DataRow dr = ds.Tables[0].NewRow(); DataRow firstdr = ds.Tables[0].NewRow(); firstdr["ID"] = "0"; firstdr["Cname"] = "顶级导航"; dt.Rows.InsertAt(firstdr, 0); ddlcategorylist.DataSource = ds.Tables[0].DefaultView; ddlcategorylist.DataTextField = "Cname"; ddlcategorylist.DataValueField = "ID"; ddlcategorylist.DataBind(); MSProductCategoryDAL categoryDal = new MSProductCategoryDAL(); DataSet categoryDs = categoryDal.GetCategoryDetail(strID); MSProductCategory categoryModel = DataConvert.DataRowToModel <MSProductCategory>(categoryDs.Tables[0].Rows[0]); cname.Text = categoryModel.Cname; string parm = string.Empty; if (categoryModel.UpID.Trim() != null && categoryModel.UpID.Trim() != "") { parm = categoryModel.UpID; } else { parm = "0"; } ddlcategorylist.SelectedIndex = ddlcategorylist.Items.IndexOf(ddlcategorylist.Items.FindByValue(parm)); sortin.Text = categoryModel.Sortin.ToString(); if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } }
/// <summary> /// 获取店铺商品信息 /// </summary> void GetInfo() { #region 获取店铺详细 MSShopDAL shopdal = new MSShopDAL(); DataSet shopds = shopdal.GetMSShopDetail(shopid); MSShop shopmodel = new MSShop(); string pagetitle = string.Empty; if (null != shopds && shopds.Tables.Count > 0 && shopds.Tables[0].Rows.Count > 0) { shopmodel = DataConvert.DataRowToModel <MSShop>(shopds.Tables[0].Rows[0]); pagetitle = shopmodel.ShopName; } #endregion List <MSProduct> ProductModel = new List <MSProduct>(); MSProductDAL productdal = new MSProductDAL(); MSProductAtlasDAL atlasDal = new MSProductAtlasDAL(); List <MSProductAtlas> AtlasModel = new List <MSProductAtlas>(); List <ProductPara> ParaListModel = new List <ProductPara>(); MSProductParaDAL paraDal = new MSProductParaDAL(); string thpid = string.Empty; #region 获取产品列表 DataSet productds = null; string cid = string.Empty; string like = string.Empty; if (Request["cid"] != null && Request["cid"] != "") { cid = Common.Common.NoHtml(Request["cid"]); } if (cid.Trim() != null && cid.Trim() != "") { cid = " and a.[CID]='" + cid + "' "; } if (Request["like"] != null && Request["like"] != "") { like = Common.Common.NoHtml(Request["like"]); } if (like.Trim() != null && like.Trim() != "") { like = " and a.Ptitle like '%" + like + "%' "; } productds = productdal.GetProductList(" and a.[SID]='" + shopid + "' " + cid + like); DataSet atlasDs = null; foreach (DataRow row in productds.Tables[0].Rows) { MSProduct model = DataConvert.DataRowToModel <MSProduct>(row); string pdesc = model.Pcontent; pdesc = JQDialog.GetTextFromHTML(pdesc); if (pdesc.Length > 50) { pdesc = pdesc.ToString().Substring(0, 50) + "..."; } model.Pcontent = pdesc; ProductModel.Add(model); thpid = model.ID; #region 获取产品默认展示图 atlasDs = atlasDal.GetDefaultAtlasByPid(thpid); foreach (DataRow atlasrow in atlasDs.Tables[0].Rows) { MSProductAtlas atlasdetailmodel = DataConvert.DataRowToModel <MSProductAtlas>(atlasrow); AtlasModel.Add(atlasdetailmodel); } #endregion #region -------获取产品型号及价格------------ DataSet parads = paraDal.GetMaxMinPrice(thpid); if (parads != null && parads.Tables.Count > 0 && parads.Tables[0].Rows.Count > 0) { foreach (DataRow pararow in parads.Tables[0].Rows) { ProductPara paramodel = DataConvert.DataRowToModel <ProductPara>(pararow); ParaListModel.Add(paramodel); } } #endregion } #endregion #region 获取产品类别 List <MSProductCategory> CategoryModel = new List <MSProductCategory>(); MSProductCategoryDAL categorydal = new MSProductCategoryDAL(); DataSet categoryds = categorydal.GetMSPCList(" and a.[SID]='" + shopid + "' "); foreach (DataRow row in categoryds.Tables[0].Rows) { MSProductCategory model = DataConvert.DataRowToModel <MSProductCategory>(row); CategoryModel.Add(model); } #endregion string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/MyShop.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["title"] = pagetitle; context.TempData["ShopDetail"] = shopmodel; context.TempData["shopid"] = shopid; context.TempData["productlist"] = ProductModel; context.TempData["defaultatlas"] = AtlasModel; context.TempData["categorylist"] = CategoryModel; context.TempData["paralist"] = ParaListModel; context.TempData["errormsg"] = errormsg; context.TempData["customerid"] = customerid; if (Session["customerID"] != null && Session["customerID"].ToString() != "") { context.TempData["uid"] = Session["customerID"].ToString(); } context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
void GetCategoryList() { #region -------------------获取类别--------------------- MSProductCategory CategoryModel = new MSProductCategory(); MSProductCategoryDAL CategoryDal = new MSProductCategoryDAL(); DataSet BigCategoryds = CategoryDal.GetSecHandCategoryList(" and UpID='' and CsecHand=1 "); DataSet SmallCategoryds = null; if (BigCategoryds != null && BigCategoryds.Tables.Count > 0 && BigCategoryds.Tables[0].Rows.Count > 0) { categoryhtml = ""; for (int i = 0; i < BigCategoryds.Tables[0].Rows.Count; i++) { string bigcname = BigCategoryds.Tables[0].Rows[i]["cname"].ToString(); string bigID = BigCategoryds.Tables[0].Rows[i]["ID"].ToString(); categoryhtml += "<ul class=\"list-unstyled pro_list\">"; categoryhtml += "\r\n<h4 class=\"col-lg-12\">" + bigcname + "</h4>"; SmallCategoryds = CategoryDal.GetSecHandCategoryList(" and UpID='" + bigID + "' "); if (SmallCategoryds != null && SmallCategoryds.Tables.Count > 0 && SmallCategoryds.Tables[0].Rows.Count > 0) { for (int j = 0; j < SmallCategoryds.Tables[0].Rows.Count; j++) { string smallcname = SmallCategoryds.Tables[0].Rows[j]["cname"].ToString(); string smallID = SmallCategoryds.Tables[0].Rows[j]["ID"].ToString(); categoryhtml += "\r\n<li class=\"col-lg-4 col-md-4 col-sm-4 col-xs-4 text-center\">\r\n" + "<a href=\"SecHandList.aspx?scid=" + smallID + "\">" + smallcname + "</a>\r\n" + "</li>"; } categoryhtml += "</ul>"; } } } #endregion #region -----------------获取最新发布的产品列表------------- MSProductDAL productDal = new MSProductDAL(); DataSet productds = productDal.GetProductByTop(30, " and a.IsSecHand=1 "); if (productds != null && productds.Tables.Count > 0 && productds.Tables[0].Rows.Count > 0) { string newpubpid = string.Empty; string newpubpname = string.Empty; string newpubdate; newpublist = ""; for (int i = 0; i < productds.Tables[0].Rows.Count; i++) { newpubpid = newpubpname = newpubdate = ""; newpubpid = productds.Tables[0].Rows[i]["ID"].ToString(); newpubpname = productds.Tables[0].Rows[i]["Ptitle"].ToString(); newpubdate = productds.Tables[0].Rows[i]["AddTime"].ToString(); newpubdate = Convert.ToDateTime(newpubdate).ToString("yy-MM-dd mm:ss"); newpubpname = Common.Common.NoHtml(newpubpname); if (newpubpname.ToString().Length > 15) { newpubpname = newpubpname.ToString().Substring(0, 13) + "..."; } newpublist += "<li title=\"" + newpubpname + "\">\r\n<a href=\"Product_detail.aspx?pid=" + newpubpid + "\">" + newpubpname + "<span>" + newpubdate + "</span></a>\r\n</li>\r\n"; } } #endregion }
/// <summary> /// 输出到页面 /// </summary> void GetHtmlInfo() { MSProduct ProductModel = new MSProduct(); MSProductDAL ProductDal = new MSProductDAL(); MSProductCategory categoryModel = new MSProductCategory(); MSProductCategoryDAL categoryDal = new MSProductCategoryDAL(); DataSet detailds = null; string cid = string.Empty; string bigcid = string.Empty; #region ------------------产品详细------------------------- if (pid.Trim() != null && pid.Trim() != "") { detailds = ProductDal.GetProductDetail(pid); if (detailds != null && detailds.Tables.Count > 0 && detailds.Tables[0].Rows.Count > 0) { ProductModel = DataConvert.DataRowToModel <MSProduct>(detailds.Tables[0].Rows[0]); cid = ProductModel.Cid; } } #endregion #region -----------类别绑定--------------- if (cid != null && cid != "") { string upid = string.Empty; try { upid = categoryDal.GetMSPCategoryValueByID("UpID", cid).ToString(); } catch (Exception) { } if (upid != null && upid != "") { bigcid = upid; } else { bigcid = cid; } } #endregion #region -------------获取图集--------------- MSProductAtlasDAL atlasDal = new MSProductAtlasDAL(); DataSet atlasDs = atlasDal.GetProductAtlasByPID(pid); int rowcount = 0; atlaslist = ""; if (atlasDs != null && atlasDs.Tables.Count > 0 && atlasDs.Tables[0].Rows.Count > 0) { rowcount = atlasDs.Tables[0].Rows.Count; for (int i = 0; i < rowcount; i++) { string imgurl = atlasDs.Tables[0].Rows[i]["PimgUrl"].ToString(); string imgid = atlasDs.Tables[0].Rows[i]["ID"].ToString(); string datarow = string.Empty; atlaslist += "\r\n<dd type=\"image\">\r\n" + "<input type=\"file\" accept=\"image/jpg, image/jpeg, image/png\" " + "onchange=\"form_pics.addImg(this);\" name=\"pics" + i + "\"><img dataid=\"" + imgid + "\" src=\"" + imgurl + "\">" + "\r\n<span onclick=\"form_pics.removeImg(this);\"> </span>\r\n" + "</dd>"; } } if (rowcount < 8) { atlaslist += "\r\n<dd>\r\n" + "<input type=\"file\" accept=\"image/jpg, image/jpeg, image/png\" " + "onchange=\"form_pics.addImg(this);\" name=\"pics" + rowcount + "\"><img src=\"images/upload.png\">" + "\r\n<span onclick=\"form_pics.removeImg(this);\"> </span>\r\n" + "</dd>"; } altascount = rowcount; #endregion #region ------------------绑定型号------------------ List <MSProductPara> paralistmodel = new List <MSProductPara>(); MSProductParaDAL paraDal = new MSProductParaDAL(); DataSet parads = paraDal.GetProductParamByPID(pid); if (parads != null && parads.Tables.Count > 0 && parads.Tables[0].Rows.Count > 0) { foreach (DataRow row in parads.Tables[0].Rows) { MSProductPara paramodel = DataConvert.DataRowToModel <MSProductPara>(row); paralistmodel.Add(paramodel); } } #endregion string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/EditeProduct.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["customid"] = customerid; context.TempData["atlaslist"] = atlaslist; context.TempData["altascount"] = altascount; context.TempData["cid"] = cid; context.TempData["bigcid"] = bigcid; context.TempData["pdetail"] = ProductModel; context.TempData["paralist"] = paralistmodel; context.TempData["footer"] = "奥琦微商易"; context.TempData["errorscript"] = errorscript; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }