/// <summary> /// 添加产品 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddMSProduct(MSProduct model) { string sql = @"INSERT INTO [MS_Product] ([ID],[CustomerID],[SiteCode],[SID],[Cid],[Ptitle],[Pcontent],[Price],[IsSecHand], [Pstate],[Review],[ZipCode],[AddTime]) VALUES (@ID,@CustomerID,@SiteCode,@SID,@Cid,@Ptitle,@Pcontent,@Price,@IsSecHand,@Pstate,@Review,@ZipCode,@AddTime)"; System.Data.SqlClient.SqlParameter[] paras = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@ID", model.ID), new System.Data.SqlClient.SqlParameter("@CustomerID", model.CustomerID), new System.Data.SqlClient.SqlParameter("@SiteCode", model.SiteCode), new System.Data.SqlClient.SqlParameter("@SID", model.SID), new System.Data.SqlClient.SqlParameter("@Cid", model.Cid), new System.Data.SqlClient.SqlParameter("@Ptitle", model.Ptitle), new System.Data.SqlClient.SqlParameter("@Pcontent", model.Pcontent), new System.Data.SqlClient.SqlParameter("@Price", model.Price), new System.Data.SqlClient.SqlParameter("@IsSecHand", (model.IsSecHand == 1?1:0)), new System.Data.SqlClient.SqlParameter("@Pstate", (model.Pstate == 1?1:0)), new System.Data.SqlClient.SqlParameter("@Review", (model.Review == 1?1:0)), new System.Data.SqlClient.SqlParameter("@ZipCode", model.ZipCode), 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 (pname.Text.Trim() != null && pname.Text.Trim() != "" && price.Text.Trim() != null && price.Text.Trim() != "") { MSProductDAL productdal = new MSProductDAL(); MSProduct productmodel = new MSProduct(); productmodel.Pstate = 0; productmodel.ID = strID; productmodel.Ptitle = pname.Text; productmodel.Price = decimal.Parse(price.Text); productmodel.Pcontent = hd_content.Value; productmodel.IsSecHand = isstateno.Checked ? 0 : 1; if (productdal.UpdateMSProduct(productmodel)) { 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 (ddlshoplist.SelectedValue.Trim() != null && ddlshoplist.SelectedValue.Trim() != "" && setoptionvalue.Value.Trim() != null && setoptionvalue.Value.Trim() != "") { if (pname.Text.Trim() != null && pname.Text.Trim() != "" && price.Text.Trim() != null && price.Text.Trim() != "") { MSProductDAL productdal = new MSProductDAL(); if (productdal.ExistMSProduct(pname.Text, setoptionvalue.Value, ddlshoplist.SelectedValue)) { MessageBox.Show(this, "该商品已经存在!"); } else { MSProduct productmodel = new MSProduct(); productmodel.Pstate = 0; productmodel.ID = Guid.NewGuid().ToString("N").ToUpper(); productmodel.Ptitle = pname.Text; productmodel.Price = decimal.Parse(price.Text); productmodel.SID = ddlshoplist.SelectedValue; productmodel.Pcontent = hd_content.Value; productmodel.Cid = setoptionvalue.Value; productmodel.IsSecHand = isstateno.Checked ? 0 : 1; if (productdal.AddMSProduct(productmodel)) { MessageBox.Show(this, "操作成功!"); } else { MessageBox.Show(this, "操作失败!"); } } } else { MessageBox.Show(this, "请输入相应标题或价格!"); } } else { MessageBox.Show(this, "请选择相应店铺和类别!"); } } else { return; } }
/// <summary> /// 产品信息修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateMSProduct(MSProduct model) { string safeslq = ""; safeslq = "UPDATE MS_Product SET "; if (model.SiteCode != null && model.SiteCode != "") { safeslq += "SiteCode='" + model.SiteCode + "',"; } if (model.CustomerID != null && model.CustomerID != "") { safeslq += "CustomerID='" + model.CustomerID + "',"; } if (model.SID != null && model.SID != "") { safeslq += "SID='" + model.SID + "',"; } if (model.Cid != null && model.Cid.ToString() != "") { safeslq += "Cid='" + model.Cid + "',"; } if (model.Ptitle != null && model.Ptitle != "") { safeslq += "Ptitle='" + model.Ptitle + "',"; } if (model.Pcontent != null && model.Pcontent != "") { safeslq += "Pcontent='" + model.Pcontent + "',"; } if (model.Price != null && model.Price.ToString() != "") { safeslq += "Price='" + model.Price + "',"; } if (model.ZipCode != null && model.ZipCode.ToString() != "") { safeslq += "ZipCode='" + model.ZipCode + "',"; } safeslq += " Pstate=" + (model.Pstate == 1?1 :0) + " "; safeslq += " where ID='" + model.ID + "'"; int rowsAffected = DbHelperSQL.ExecuteSql(safeslq.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
void showdetailinfo() { MSProductDAL productDal = new MSProductDAL(); DataSet productDs = productDal.GetProductDetail(strID); MSProduct productModel = DataConvert.DataRowToModel <MSProduct>(productDs.Tables[0].Rows[0]); price.Text = productModel.Price.ToString(); pname.Text = productModel.Ptitle; hd_content.Value = productModel.Pcontent; if (productModel.IsSecHand == 0) { isstateno.Checked = true; } else { isstateyes.Checked = true; } if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } MSProductAtlasDAL atlasDal = new MSProductAtlasDAL(); DataSet atlasds = atlasDal.GetProductAtlasByPID(strID); if (atlasds != null && atlasds.Tables.Count > 0 && atlasds.Tables[0].Rows.Count > 0) { atlaslist = ""; string atlasimg = string.Empty; for (int i = 0; i < atlasds.Tables[0].Rows.Count; i++) { atlasimg = atlasds.Tables[0].Rows[i]["PimgUrl"].ToString(); atlaslist += "<img src=\"../../PalmShop/ShopCode/" + atlasimg + "\" />"; } } MSShopContactsDAL contactDal = new MSShopContactsDAL(); DataSet contactDs = contactDal.GetContactDetailByPID(strID); if (contactDs != null && contactDs.Tables.Count > 0 && contactDs.Tables[0].Rows.Count > 0) { string uphone = string.Empty; string uname = string.Empty; uphone = contactDs.Tables[0].Rows[0]["Phone"].ToString(); uname = contactDs.Tables[0].Rows[0]["NickName"].ToString(); UserContact.Text = "联系电话:" + uphone + " " + "联系人:" + uname; } }
void showdetailinfo() { MSProductDAL productDal = new MSProductDAL(); DataSet productDs = productDal.GetProductDetail(strID); MSProduct productModel = DataConvert.DataRowToModel <MSProduct>(productDs.Tables[0].Rows[0]); price.Text = productModel.Price.ToString(); pname.Text = productModel.Ptitle; hd_content.Value = productModel.Pcontent; if (productModel.IsSecHand == 0) { isstateno.Checked = true; } else { isstateyes.Checked = true; } if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } MSProductAtlasDAL AtlasDal = new MSProductAtlasDAL(); DataSet atlasds = AtlasDal.GetProductAtlasList(" AND PID='" + strID + "' "); if (atlasds != null && atlasds.Tables.Count > 0 && atlasds.Tables[0].Rows.Count > 0) { pataslist = ""; string atlasimg = ""; for (int i = 0; i < atlasds.Tables[0].Rows.Count; i++) { atlasimg = atlasds.Tables[0].Rows[i]["PimgUrl"].ToString(); pataslist += "<img src=\"../../PalmShop/ShopCode/" + atlasimg + "\" />"; } } }
static void Main(string[] args) { //Interface MSOffice MSOffice office = new MSExcel(); //Interface MSProduct MSProduct product = new MSExcel(); MSExcel excel = new MSExcel(); excel.Print(); office.NewFile(); excel.NavigationBar(); MSProduct msProduct = (MSProduct)office; msProduct.NavigationBar(); ((MSProduct)office).NavigationBar(); product.NavigationBar(); }
/// <summary> /// 产品发布 /// </summary> void PublicProduct() { string cid = string.Empty; string ptitle = string.Empty; string pcontent = string.Empty; string price = string.Empty; string zipcode = string.Empty; string isnull = ""; #region --------------获取值-------------------- try { cid = HttpContext.Current.Request.Form.Get("setoptionvalue").ToString(); } catch (Exception) { cid = isnull; } try { ptitle = HttpContext.Current.Request.Form.Get("ptitle").ToString(); } catch (Exception) { ptitle = isnull; } try { pcontent = HttpContext.Current.Request.Form.Get("pdesc").ToString(); } catch (Exception) { pcontent = isnull; } try { price = HttpContext.Current.Request.Form.Get("price").ToString(); } catch (Exception) { price = isnull; } try { price = HttpContext.Current.Request.Form.Get("price").ToString(); } catch (Exception) { price = isnull; } try { zipcode = HttpContext.Current.Request.Form.Get("zipcode").ToString(); } catch (Exception) { zipcode = isnull; } #endregion Random random = new Random(); int r1 = (int)(random.Next(0, 9)); int r2 = (int)(random.Next(0, 9)); string now = DateTime.Now.ToString("yyMMddhhmmssf"); String paymentID = r1.ToString() + r2.ToString() + now; pid = "R" + paymentID; if (ptitle != null && ptitle != "") { MSProduct ProductModel = new MSProduct(); MSProductDAL ProductDal = new MSProductDAL(); ProductModel.ID = pid; ProductModel.Cid = cid; ProductModel.Ptitle = ptitle; ProductModel.Pcontent = pcontent; if (price != null && price != "") { ProductModel.Price = decimal.Parse(price); } ProductModel.CustomerID = customerid; ProductModel.SiteCode = ""; ProductModel.SID = sid; ProductModel.IsSecHand = 0; ProductModel.Pstate = 0; ProductModel.Review = 1; ProductModel.ZipCode = (zipcode == "" || zipcode == null ? "包邮" : zipcode); if (SaveImages() && AddProductModel() && ProductDal.AddMSProduct(ProductModel)) { errorscript = JQDialog.alertOKMsgBox(3, "操作成功!", "MyShop.aspx", "succeed"); } else { errorscript = JQDialog.alertOKMsgBox(3, "操作失败<br/>请核对后再操作!", "", "error"); } } }
protected void uploadbtn_Click(object sender, EventArgs e) { #region 信息判断 if (Session["customerID"] == null || Session["customerID"].ToString() == "") { JQDialog.SetCookies("pageurl", "PubSecHand.aspx?ishand=" + ishand, 2); errorscript = JQDialog.alertOKMsgBox(5, "操作失败<br/>请登录后再操作!", "UserLogin.aspx", "error"); return; } MSProduct productModel = new MSProduct(); if (setpvalue.Value.Trim() != null && setpvalue.Value.Trim() != "") { productModel.Cid = setpvalue.Value; } if (pdesc.Value.Trim() != null && pdesc.Value.Trim() != "") { productModel.Pcontent = pdesc.Value; } if (price.Value.Trim() != null && price.Value.Trim() != "") { productModel.Price = Convert.ToDecimal(price.Value); } if (ptitle.Value.Trim() != null && ptitle.Value.Trim() != "") { productModel.Ptitle = ptitle.Value; } if (price.Value.Trim() != null && price.Value.Trim() != "") { productModel.Price = Convert.ToDecimal(price.Value); } #endregion Random random = new Random(); int r1 = (int)(random.Next(0, 9)); //产生2个0-9的随机数 int r2 = (int)(random.Next(0, 9)); string now = DateTime.Now.ToString("yyMMddhhmmssf"); //一个13位的时间戳 String paymentID = r1.ToString() + r2.ToString() + now; pid = "R" + paymentID; productModel.ID = pid; productModel.IsSecHand = ishand; productModel.Pstate = 0; productModel.Review = 1; productModel.CustomerID = Session["customerID"].ToString(); MSProductDAL productDal = new MSProductDAL(); MSShopContacts contactModel = new MSShopContacts(); MSShopContactsDAL contactDal = new MSShopContactsDAL(); contactModel.ID = Guid.NewGuid().ToString("N").ToUpper(); contactModel.PID = pid; contactModel.IsDel = 0; contactModel.SID = ""; contactModel.NickName = UserName.Value; contactModel.Phone = UserPhone.Value; string pageurl = "NewProduct.aspx?ishand=" + ishand; if (productDal.AddMSProduct(productModel) && SaveImages() && contactDal.AddMSSContacts(contactModel)) { if (ishand == 1) { pageurl = "MySecHand.aspx"; } errorscript = JQDialog.alertOKMsgBox(5, "操作成功!", pageurl, "succeed"); } else { errorscript = JQDialog.alertOKMsgBox(3, "操作失败<br/>请核对后再操作!", "", "error"); return; } }
void GetProductDetail() { string ptitle = string.Empty; string shopID = string.Empty; string puid = string.Empty; int paracount = 0; #region 产品详细 MSProductDAL productDal = new MSProductDAL(); MSProduct productModel = new MSProduct(); DataSet productds = productDal.GetProductDetail(strpid); if (null != productds && productds.Tables.Count > 0 && productds.Tables[0].Rows.Count > 0) { productModel = DataConvert.DataRowToModel <MSProduct>(productds.Tables[0].Rows[0]); ptitle = productModel.Ptitle; puid = productModel.CustomerID; if (productModel.SID != null && productModel.SID != "") { shopID = productModel.SID; } } #endregion #region 店铺详细 MSShop shopModel = new MSShop(); if (shopID != null && shopID != "") { MSShopDAL shopDal = new MSShopDAL(); DataSet shopds = shopDal.GetMSShopDetail(shopID); if (shopds != null && shopds.Tables.Count > 0 && shopds.Tables[0].Rows.Count > 0) { shopModel = DataConvert.DataRowToModel <MSShop>(shopds.Tables[0].Rows[0]); } } #endregion #region 图集列表 MSProductAtlasDAL atlasDal = new MSProductAtlasDAL(); List <MSProductAtlas> AtlasListModel = new List <MSProductAtlas>(); DataSet atlasds = atlasDal.GetProductAtlasByPID(strpid); if (null != atlasds && atlasds.Tables.Count > 0 && atlasds.Tables[0].Rows.Count > 0) { foreach (DataRow row in atlasds.Tables[0].Rows) { MSProductAtlas atlasModel = DataConvert.DataRowToModel <MSProductAtlas>(row); AtlasListModel.Add(atlasModel); } } #endregion #region 产品参数列表 //MSProductParaDAL paraDal = new MSProductParaDAL(); //DataSet paramds = paraDal.GetProductParamByPID(strpid); //string paramlist = string.Empty; //if (null != paramds && paramds.Tables.Count > 0 && paramds.Tables[0].Rows.Count > 0) //{ // for (int i = 0; i < paramds.Tables[0].Rows.Count; i++) // { // paramlist += "<tr>\r\n"; // string paraname = paramds.Tables[0].Rows[i]["ParName"].ToString(); // string paravalue = paramds.Tables[0].Rows[i]["ParValue"].ToString(); // paramlist += "<td class=\"td_title\">" + paraname + "</td><td>" + paravalue + "</td>\r\n"; // try // { // i = i + 1; // paraname = paramds.Tables[0].Rows[i]["ParName"].ToString(); // paravalue = paramds.Tables[0].Rows[i]["ParValue"].ToString(); // paramlist += "<td class=\"td_title\">" + paraname + "</td><td>" + paravalue + "</td>\r\n"; // } // catch (Exception) // { // paramlist += "<td class=\"td_title\"> </td><td> </td>\r\n"; // } // paramlist += "</tr>\r\n"; // } //} #endregion #region -------获取产品型号及价格------------ ProductPara ParaModel = new ProductPara(); List <MSProductPara> paralistmodel = new List <MSProductPara>(); MSProductParaDAL paraDal = new MSProductParaDAL(); DataSet parads = paraDal.GetMaxMinPrice(strpid); if (parads != null && parads.Tables.Count > 0 && parads.Tables[0].Rows.Count > 0) { paracount = parads.Tables[0].Rows.Count; ParaModel = DataConvert.DataRowToModel <ProductPara>(parads.Tables[0].Rows[0]); } parads = null; parads = paraDal.GetProductParamByPID(strpid); if (parads != null && parads.Tables.Count > 0 && parads.Tables[0].Rows.Count > 0) { foreach (DataRow item in parads.Tables[0].Rows) { MSProductPara paramodel = DataConvert.DataRowToModel <MSProductPara>(item); paralistmodel.Add(paramodel); } } #endregion #region ----------------根据产品编号获取联系方式-------------------- MSShopContactsDAL contactDal = new MSShopContactsDAL(); MSShopContacts contactModel = new MSShopContacts(); DataSet contactDs = contactDal.GetContactDetailByPID(strpid); MSCustomersDAL CustomerDal = new MSCustomersDAL(); MSCustomers CustomerModel = new MSCustomers(); DataSet PuidDs = null; int contactcount = 0; if (contactDs != null && contactDs.Tables.Count > 0 && contactDs.Tables[0].Rows.Count > 0) { contactModel = DataConvert.DataRowToModel <MSShopContacts>(contactDs.Tables[0].Rows[0]); contactcount = 1; } else { if (puid != null && puid != "") { PuidDs = CustomerDal.GetCustomerDetail(puid); } if (PuidDs != null && PuidDs.Tables.Count > 0 && PuidDs.Tables[0].Rows.Count > 0) { CustomerModel = DataConvert.DataRowToModel <MSCustomers>(PuidDs.Tables[0].Rows[0]); } } #endregion string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/Product_detail.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["title"] = ptitle; if (shopModel != null) { context.TempData["shopdetail"] = shopModel; } context.TempData["productdetail"] = productModel; context.TempData["atlaslist"] = AtlasListModel; if (contactcount > 0) { context.TempData["contactdetail"] = contactModel; } else { context.TempData["contactdetail"] = CustomerModel; } context.TempData["customid"] = customid; //context.TempData["paramlist"] = paramlist; context.TempData["paracount"] = paracount; context.TempData["paramodel"] = ParaModel; 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); }
/// <summary> /// 获取购物信息 /// </summary> void GetInfo() { #region 产品详细 MSProductDAL productDal = new MSProductDAL(); MSProduct productModel = new MSProduct(); DataSet productds = productDal.GetProductDetail(strpid); MSProductAtlasDAL atlasDal = new MSProductAtlasDAL(); MSProductAtlas atlasdetailmodel = null; DataSet atlasDs = null; if (null != productds && productds.Tables.Count > 0 && productds.Tables[0].Rows.Count > 0) { productModel = DataConvert.DataRowToModel <MSProduct>(productds.Tables[0].Rows[0]); } #endregion #region 获取产品默认展示图 atlasDs = atlasDal.GetDefaultAtlasByPid(strpid); foreach (DataRow atlasrow in atlasDs.Tables[0].Rows) { atlasdetailmodel = DataConvert.DataRowToModel <MSProductAtlas>(atlasrow); } #endregion #region -----------获取型号尺码---------------- MSProductPara paraModel = new MSProductPara(); MSProductParaDAL paraDal = new MSProductParaDAL(); DataSet parads = paraDal.GetParaDetail(mid); if (parads != null && parads.Tables.Count > 0 && parads.Tables[0].Rows.Count > 0) { paraModel = DataConvert.DataRowToModel <MSProductPara>(parads.Tables[0].Rows[0]); } #endregion #region 获取收货地址 MSDeliveryAddressDAL addressDal = new MSDeliveryAddressDAL(); MSDeliveryAddress defaultadModel = new MSDeliveryAddress(); List <MSDeliveryAddress> damodellist = new List <MSDeliveryAddress>(); string stradwhere = string.Empty; stradwhere = "and [UID]='" + customid + "' "; DataSet addressds = addressDal.GetDAList(3, stradwhere); if (null != addressds && addressds.Tables.Count > 0 && addressds.Tables[0].Rows.Count > 0) { foreach (DataRow row in addressds.Tables[0].Rows) { MSDeliveryAddress damodel = DataConvert.DataRowToModel <MSDeliveryAddress>(row); damodellist.Add(damodel); } } #endregion string customerphone = string.Empty; MSCustomers customerModel = new MSCustomers(); if (customid != null && customid != "") { MSCustomersDAL CustomerDal = new MSCustomersDAL(); DataSet customerds = CustomerDal.GetCustomerDetail(customid); if (customerds != null && customerds.Tables.Count > 0 && customerds.Tables[0].Rows.Count > 0) { customerModel = DataConvert.DataRowToModel <MSCustomers>(customerds.Tables[0].Rows[0]); } } string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/setOrder.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["productdetail"] = productModel; context.TempData["atlas"] = atlasdetailmodel; context.TempData["paramodel"] = paraModel; context.TempData["errorscript"] = errorscript; context.TempData["dalist"] = damodellist; context.TempData["customer"] = customerModel; context.TempData["openid"] = openid; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
/// <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); }
/// <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); }
void ProductEdite() { string cid = string.Empty; string ptitle = string.Empty; string pcontent = string.Empty; string price = string.Empty; string zipcode = string.Empty; string isnull = ""; #region --------------获取值-------------------- try { cid = HttpContext.Current.Request.Form.Get("setoptionvalue").ToString(); } catch (Exception) { cid = isnull; } try { ptitle = HttpContext.Current.Request.Form.Get("ptitle").ToString(); } catch (Exception) { ptitle = isnull; } try { pcontent = HttpContext.Current.Request.Form.Get("pdesc").ToString(); } catch (Exception) { pcontent = isnull; } try { price = HttpContext.Current.Request.Form.Get("price").ToString(); } catch (Exception) { price = isnull; } try { price = HttpContext.Current.Request.Form.Get("price").ToString(); } catch (Exception) { price = isnull; } try { zipcode = HttpContext.Current.Request.Form.Get("zipcode").ToString(); } catch (Exception) { zipcode = isnull; } #endregion if (ptitle != null && ptitle != "") { MSProduct ProductModel = new MSProduct(); MSProductDAL ProductDal = new MSProductDAL(); ProductModel.ID = pid; ProductModel.Cid = cid; ProductModel.Ptitle = ptitle; ProductModel.Pcontent = pcontent; if (price != null && price != "") { ProductModel.Price = decimal.Parse(price); } ProductModel.CustomerID = customerid; ProductModel.SiteCode = ""; ProductModel.SID = sid; ProductModel.IsSecHand = 0; ProductModel.Pstate = 0; ProductModel.ZipCode = (zipcode == "" || zipcode == null ? "包邮" : zipcode); if (EditeProductModel() && SaveImages() && ProductDal.UpdateMSProduct(ProductModel)) { errorscript = JQDialog.alertOKMsgBox(3, "操作成功!", "MyShop.aspx", "succeed"); } else { errorscript = JQDialog.alertOKMsgBox(3, "操作失败<br/>请核对后再操作!", "", "error"); } } }
/// <summary> /// 获取类别 /// </summary> void getinfo() { #region -----------一级导航绑定----------- ddlbigcategorylist.Items.Clear(); MSProductCategoryDAL categoryDal = new MSProductCategoryDAL(); DataSet ds = new DataSet(); ds = categoryDal.GetSecHandCategoryList(" and UpID='' and CsecHand=" + ishand); ddlbigcategorylist.DataSource = ds.Tables[0].DefaultView; ddlbigcategorylist.DataTextField = "Cname"; ddlbigcategorylist.DataValueField = "ID"; ddlbigcategorylist.DataBind(); #endregion string cid = string.Empty; string bigcid = string.Empty; if (pid.Trim() != null && pid.Trim() != "") { MSProductDAL productDal = new MSProductDAL(); DataSet productds = productDal.GetProductDetail(pid); MSProduct productModel = DataConvert.DataRowToModel <MSProduct>(productds.Tables[0].Rows[0]); cid = productModel.Cid; ptitle.Value = productModel.Ptitle; pdesc.Value = productModel.Pcontent; price.Value = productModel.Price.ToString(); Review = productModel.Review; #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; } setpvalue.Value = cid; } #endregion ddlbigcategorylist.SelectedIndex = ddlbigcategorylist.Items.IndexOf(ddlbigcategorylist.Items.FindByValue(bigcid)); #region ------------二级导航绑定------------------ if (bigcid != null && bigcid != "") { ddlsmallcategorylist.Items.Clear(); ds = categoryDal.GetSecHandCategoryList(" and UpID='" + bigcid + "' "); ddlsmallcategorylist.DataSource = ds.Tables[0].DefaultView; ddlsmallcategorylist.DataTextField = "Cname"; ddlsmallcategorylist.DataValueField = "ID"; ddlsmallcategorylist.DataBind(); if (cid != null && cid != "") { ddlsmallcategorylist.SelectedIndex = ddlsmallcategorylist.Items.IndexOf(ddlsmallcategorylist.Items.FindByValue(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 datacount=\"" + rowcount + "\">\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 ----------------根据产品编号获取联系方式-------------------- MSShopContactsDAL contactDal = new MSShopContactsDAL(); DataSet contactDs = contactDal.GetContactDetailByPID(pid); if (contactDs != null && contactDs.Tables.Count > 0 && contactDs.Tables[0].Rows.Count > 0) { string uphone = string.Empty; string uname = string.Empty; uphone = contactDs.Tables[0].Rows[0]["Phone"].ToString(); uname = contactDs.Tables[0].Rows[0]["NickName"].ToString(); contactID = contactDs.Tables[0].Rows[0]["ID"].ToString(); UserPhone.Value = uphone; UserName.Value = uname; } #endregion } }
protected void uploadbtn_Click(object sender, EventArgs e) { #region 信息判断 if (Session["customerID"] != null && Session["customerID"].ToString() != "") { MSCustomersDAL customerDal = new MSCustomersDAL(); phone = customerDal.GetCustomerValueByID("phone", Session["customerID"].ToString()).ToString(); } else { JQDialog.SetCookies("pageurl", "PubSecHandEdit.aspx?ishand=" + ishand, 2); errorscript = JQDialog.alertOKMsgBox(5, "操作失败<br/>请登录后再操作!", "UserLogin.aspx", "error"); return; } MSProduct productModel = new MSProduct(); if (setpvalue.Value.Trim() != null && setpvalue.Value.Trim() != "") { productModel.Cid = setpvalue.Value; } if (pdesc.Value.Trim() != null && pdesc.Value.Trim() != "") { productModel.Pcontent = pdesc.Value; } if (price.Value.Trim() != null && price.Value.Trim() != "") { productModel.Price = Convert.ToDecimal(price.Value); } if (ptitle.Value.Trim() != null && ptitle.Value.Trim() != "") { productModel.Ptitle = ptitle.Value; } if (price.Value.Trim() != null && price.Value.Trim() != "") { productModel.Price = Convert.ToDecimal(price.Value); } #endregion productModel.ID = pid; productModel.IsSecHand = ishand; productModel.Pstate = 0; productModel.Review = Review; productModel.CustomerID = Session["customerID"].ToString(); MSProductDAL productDal = new MSProductDAL(); MSShopContacts contactModel = new MSShopContacts(); MSShopContactsDAL contactDal = new MSShopContactsDAL(); contactModel.PID = pid; contactModel.IsDel = 0; contactModel.SID = ""; contactModel.NickName = UserName.Value; contactModel.Phone = UserPhone.Value; bool contactflag = false; if (contactDal.ExistContact("", "", "", pid)) { contactModel.ID = contactID; contactflag = contactDal.UpdateMSSContacts(contactModel); } else { contactModel.ID = Guid.NewGuid().ToString("N").ToUpper(); contactflag = contactDal.AddMSSContacts(contactModel); } if (productDal.UpdateMSProduct(productModel) && SaveImages()) { errorscript = JQDialog.alertOKMsgBox(3, "操作成功!", "MySecHand.aspx", "error"); } else { errorscript = JQDialog.alertOKMsgBox(4, "操作失败,请核对后再操作!", "", "error"); return; } }