/// <summary> /// 更新图像 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateMSProductAtlas(MSProductAtlas model) { string safeslq = ""; safeslq = "UPDATE MS_ProductAtlas SET "; if (model.PID != null && model.PID != "") { safeslq += "PID='" + model.PID + "',"; } if (model.AtlasName != null && model.AtlasName != "") { safeslq += "AtlasName='" + model.AtlasName + "',"; } if (model.PimgUrl != null && model.PimgUrl != "") { safeslq += "PimgUrl='" + model.PimgUrl + "',"; } safeslq += " ImgState=" + (model.ImgState == 1 ? 1 : 0) + ", "; safeslq += " IsDefault=" + (model.IsDefault == 1 ? 1 : 0) + " "; 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 AddMSProductAtlas(MSProductAtlas model) { string sql = @"INSERT INTO [MS_ProductAtlas] ([ID],[PID],[AtlasName],[PimgUrl],[ImgState],[IsDefault],[AddTime]) VALUES (@ID,@PID,@AtlasName,@PimgUrl,@ImgState,@IsDefault,@AddTime)"; System.Data.SqlClient.SqlParameter[] paras = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@ID", model.ID), new System.Data.SqlClient.SqlParameter("@PID", model.PID), new System.Data.SqlClient.SqlParameter("@AtlasName", model.AtlasName), new System.Data.SqlClient.SqlParameter("@PimgUrl", model.PimgUrl), new System.Data.SqlClient.SqlParameter("@ImgState", (model.ImgState == 0?0:1)), new System.Data.SqlClient.SqlParameter("@IsDefault", (model.IsDefault == 0?0:1)), new System.Data.SqlClient.SqlParameter("@AddTime", DateTime.Now) }; int rowsAffected = DbHelperSQL.ExecuteSql(sql.ToString(), paras); if (rowsAffected > 0) { return(true); } else { return(false); } }
void showdetailinfo() { MSProductAtlasDAL AtlasDal = new MSProductAtlasDAL(); DataSet AtlasDs = AtlasDal.GetAtlasDetail(strID); MSProductAtlas AtlasModel = DataConvert.DataRowToModel <MSProductAtlas>(AtlasDs.Tables[0].Rows[0]); atlasname.Text = AtlasModel.AtlasName; string img = string.Empty; string sid = string.Empty; img = AtlasModel.PimgUrl; pid = AtlasModel.PID; MSProductDAL productDal = new MSProductDAL(); MSShopDAL shopDal = new MSShopDAL(); if (AtlasModel.IsDefault == 0) { isno.Checked = true; } else { isyes.Checked = true; } if (pid.Trim() != null && pid.Trim() != "") { sid = productDal.GetMSProductVaueByID("[SID]", pid).ToString(); } if (sid.Trim() != null && sid.Trim() != "") { ShopPhone = shopDal.GetMSShopValueByID("Phone", sid).ToString(); } else { ShopPhone = pid; } if (ShopPhone.Trim() == null || ShopPhone.Trim() == "") { ShopPhone = AtlasModel.ID; } if (img.Trim() != null && img.Trim() != "") { img0.Src = "../../PalmShop/ShopCode/" + img; oldimg = img; } if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } }
/// <summary> /// 图集上传 /// </summary> /// <returns></returns> bool SaveImages() { bool result = false; if (customerid != null && customerid != "") { MSCustomersDAL customer = new MSCustomersDAL(); phone = customer.GetCustomerValueByID("Phone", customerid).ToString() + "/"; } HttpFileCollection files = HttpContext.Current.Request.Files; try { MSProductAtlas atlasModel = new MSProductAtlas(); MSProductAtlasDAL atlasDal = new MSProductAtlasDAL(); atlasModel.PID = pid; for (int iFile = 0; iFile < files.Count; iFile++) { //检查文件扩展名字 HttpPostedFile postedFile = files[iFile]; string fileName, fileExtension, file_oldid, file_id; //取出精确到毫秒的时间做文件的名称 string my_file_id = DateTime.Now.ToString("yyyyMMddHHmmssfff") + iFile.ToString(); fileName = System.IO.Path.GetFileName(postedFile.FileName); fileExtension = System.IO.Path.GetExtension(fileName); file_id = my_file_id + fileExtension; if (fileName != "" && fileName != null) { fileExtension = System.IO.Path.GetExtension(fileName); string saveurl, modelimgurl; saveurl = modelimgurl = "Atlas/" + phone; saveurl = Server.MapPath(saveurl); if (!Directory.Exists(saveurl)) { Directory.CreateDirectory(saveurl); } int length = postedFile.ContentLength; if (length > 512000) { file_oldid = "old" + file_id; postedFile.SaveAs(saveurl + file_oldid); JQDialog.ystp(saveurl + file_oldid, saveurl + file_id, 15); File.Delete(saveurl + file_oldid); } else { postedFile.SaveAs(saveurl + file_id); } atlasModel.ID = Guid.NewGuid().ToString("N").ToUpper(); if (iFile == 0) { if (!atlasDal.IsExitDefaultImg(pid)) { atlasModel.IsDefault = 1; } } atlasModel.ImgState = 0; atlasModel.PimgUrl = modelimgurl + file_id; atlasModel.AtlasName = ""; if (atlasDal.AddMSProductAtlas(atlasModel)) { result = true; } } } } catch (System.Exception Ex) { result = false; } return(result); }
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); }
protected void btnSave_Click(object sender, EventArgs e) { if (Session["strLoginName"].ToString() != null && Session["strLoginName"].ToString() != "") { if (atlasname.Text.Trim() != null && atlasname.Text.Trim() != "") { //上传图像 string strIconFileName = string.Empty; //图像路径 string strIconSaveFileName = string.Empty; //网址路径 try { if (this.file0.PostedFile.FileName == "") { strIconSaveFileName = ""; } else { if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Atlas")) { System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Atlas"); } if (!System.IO.Directory.Exists(String.Format(@"{0}/PalmShop/ShopCode/Atlas/{1}", Server.MapPath("~"), ShopPhone))) { System.IO.Directory.CreateDirectory(String.Format(@"{0}/PalmShop/ShopCode/Atlas/{1}", Server.MapPath("~"), ShopPhone)); } string orignalName = this.file0.PostedFile.FileName; //获取客户机上传文件的文件名 string extendName = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名 if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png") { MessageBox.Show(this, "文件格式有误!"); return; }//检查文件格式 string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名 strIconFileName = String.Format(@"{0}PalmShop/ShopCode/Atlas/{1}/{2}", Server.MapPath("~"), ShopPhone, newName); strIconSaveFileName = String.Format(@"Atlas/{0}/{1}", ShopPhone, newName); file0.PostedFile.SaveAs(strIconFileName); if (oldimg.Trim() != null && oldimg.Trim() != "") { System.IO.File.Delete(String.Format(@"{0}PalmShop/ShopCode/{1}", Server.MapPath("~"), oldimg)); } } } catch (Exception ex) { MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString()); } MSProductAtlasDAL AtlasDal = new MSProductAtlasDAL(); MSProductAtlas AtlasModel = new MSProductAtlas(); AtlasModel.PID = pid; AtlasModel.AtlasName = atlasname.Text; AtlasModel.ImgState = 0; if (strIconSaveFileName.Trim() != null && strIconSaveFileName.Trim() != "") { AtlasModel.PimgUrl = strIconSaveFileName; } AtlasModel.ID = strID; AtlasModel.IsDefault = isyes.Checked ? 1 : 0; if (AtlasDal.UpdateMSProductAtlas(AtlasModel)) { MessageBox.Show(this, "操作成功!"); } else { MessageBox.Show(this, "操作失败!"); } } else { MessageBox.Show(this, "请输入相应名称!"); } } else { return; } }