/// <summary> /// 店铺添加 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddMSShop(MSShop model) { string sql = @"INSERT INTO [MS_Shop] ([ID],[UID],[ShopName],[WXName],[WXNum],[ShopLogo],[ShopBackImg],[ShopDesc],[ShopState],[AddTime]) VALUES (@ID,@UID,@ShopName,@WXName,@WXNum,@ShopLogo,@ShopBackImg,@ShopDesc,@ShopState,@AddTime)"; System.Data.SqlClient.SqlParameter[] paras = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@ID", model.ID), new System.Data.SqlClient.SqlParameter("@UID", model.UID), new System.Data.SqlClient.SqlParameter("@ShopName", model.ShopName), new System.Data.SqlClient.SqlParameter("@WXName", model.WXName), new System.Data.SqlClient.SqlParameter("@WXNum", model.WXNum), new System.Data.SqlClient.SqlParameter("@ShopLogo", model.ShopLogo), new System.Data.SqlClient.SqlParameter("@ShopBackImg", model.ShopBackImg), new System.Data.SqlClient.SqlParameter("@ShopDesc", model.ShopDesc), new System.Data.SqlClient.SqlParameter("@ShopState", (model.ShopState == 1?1:0)), 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() { MSShopDAL shopdal = new MSShopDAL(); DataSet ds = shopdal.GetMSShopDetail(strID); MSShop shopmodel = DataConvert.DataRowToModel <MSShop>(ds.Tables[0].Rows[0]); hd_content.Value = shopmodel.ShopDesc; MSCustomersDAL customerDal = new MSCustomersDAL(); userphone.Text = customerDal.GetCustomerValueByID("Phone", shopmodel.UID).ToString(); shopname.Text = shopmodel.ShopName; if (shopmodel.ShopLogo != null && shopmodel.ShopLogo != "") { img0.Src = "../../PalmShop/ShopCode/" + shopmodel.ShopLogo; oldimg = shopmodel.ShopLogo; } if (shopmodel.ShopBackImg != null && shopmodel.ShopBackImg != "") { img1.Src = "../../PalmShop/ShopCode/" + shopmodel.ShopBackImg; oldbackimg = shopmodel.ShopBackImg; } wxname.Text = shopmodel.WXName; wxnum.Text = shopmodel.WXNum; if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } }
/// <summary> /// 店铺更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateMSShop(MSShop model) { string safeslq = ""; safeslq = "UPDATE MS_Shop SET "; if (model.UID != null && model.UID != "") { safeslq += "[UID]='" + model.UID + "',"; } if (model.ShopName != null && model.ShopName != "") { safeslq += "ShopName='" + model.ShopName + "',"; } if (model.WXName != null && model.WXName != "") { safeslq += "WXName='" + model.WXName + "',"; } if (model.WXNum != null && model.WXNum != "") { safeslq += "WXNum='" + model.WXNum + "',"; } if (model.ShopLogo != null && model.ShopLogo.ToString() != "") { safeslq += "ShopLogo='" + model.ShopLogo + "',"; } if (model.ShopBackImg != null && model.ShopBackImg.ToString() != "") { safeslq += "ShopBackImg='" + model.ShopBackImg + "',"; } if (model.ShopDesc != null && model.ShopDesc != "") { safeslq += "ShopDesc='" + model.ShopDesc + "',"; } safeslq += " ShopState=" + (model.ShopState == 1 ? 1 : 0) + " "; safeslq += " where ID='" + model.ID + "'"; int rowsAffected = DbHelperSQL.ExecuteSql(safeslq.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
void GetHtmlPage() { MSShop shopModel = new MSShop(); MSCustomers UserModel = new MSCustomers(); #region -----------------店铺详情----------------------- if (strSID != null && strSID != "") { MSShopDAL shopDal = new MSShopDAL(); DataSet shopds = shopDal.GetMSShopDetail(strSID); if (shopds != null && shopds.Tables.Count > 0 && shopds.Tables[0].Rows.Count > 0) { shopModel = DataConvert.DataRowToModel <MSShop>(shopds.Tables[0].Rows[0]); } } #endregion #region ---------------店铺用户资料详情-------------------- if (strUid != null && strUid != "") { MSCustomersDAL UserDal = new MSCustomersDAL(); DataSet userds = UserDal.GetCustomerDetail(strUid); if (userds != null && userds.Tables.Count > 0 && userds.Tables[0].Rows.Count > 0) { UserModel = DataConvert.DataRowToModel <MSCustomers>(userds.Tables[0].Rows[0]); } } #endregion string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/ApplyShop.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["footer"] = "奥琦微商易"; context.TempData["errorscript"] = errorscript; context.TempData["shopdetail"] = shopModel; context.TempData["usredetail"] = UserModel; context.TempData["action"] = action; context.TempData["sid"] = strSID; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }
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); }
void RegOrUpdateShop() { string shopname = string.Empty; string wxname = string.Empty; string wxnum = string.Empty; string isnull = ""; string ShopLogo = string.Empty; string ShopBackImg = string.Empty; string RealName = string.Empty; string IDnum = string.Empty; string IDimg = string.Empty; #region --------------------获取请求参数值------------------------------- try { shopname = Request.Form.Get("shopname").ToString(); } catch (Exception) { shopname = isnull; } try { wxname = Request.Form.Get("wxname").ToString(); } catch (Exception) { wxname = isnull; } try { wxnum = Request.Form.Get("wxnum").ToString(); } catch (Exception) { wxnum = isnull; } try { ShopLogo = Request.Files.Get("logoimg").FileName.ToString(); } catch (Exception) { ShopLogo = isnull; } try { ShopBackImg = Request.Files.Get("backimg").FileName.ToString(); } catch (Exception) { ShopBackImg = isnull; } try { RealName = Request.Files.Get("realname").FileName.ToString(); } catch (Exception) { RealName = isnull; } try { IDnum = Request.Form.Get("idnum").ToString(); } catch (Exception) { IDnum = isnull; } try { IDimg = Request.Files.Get("idimg").FileName.ToString(); } catch (Exception) { IDimg = isnull; } #endregion #region ---------------------获取图像--------------------------- if (ShopLogo != null && ShopLogo != "") { ShopLogo = "ShopLogo/" + UploadImg("logoimg"); } if (ShopBackImg != null && ShopBackImg != "") { ShopBackImg = "ShopLogo/" + UploadImg("backimg"); } if (IDimg != null && IDimg != "") { IDimg = "ShopLogo/" + UploadImg("idimg"); } #endregion MSShop shopModel = new MSShop(); MSShopDAL shopDal = new MSShopDAL(); #region ----------------------设置Model值----------------------------------- if (shopname != null && shopname != "") { shopModel.ShopName = shopname; } shopModel.WXName = wxname; shopModel.WXNum = wxnum; shopModel.ShopLogo = ShopLogo; shopModel.ShopBackImg = ShopBackImg; string regSid = string.Empty; if (strUid != null && strUid != "") { shopModel.UID = strUid; } if (strSID != null && strSID != "") { shopModel.ID = strSID; } else { regSid = Guid.NewGuid().ToString("N").ToUpper(); shopModel.ID = regSid; } #endregion #region ------------------更新注册店铺用户身份信息--------------------------- if (strUid != null && strUid != "") { MSCustomersDAL UserDal = new MSCustomersDAL(); UserDal.UpdateUserIDnum(strUid, RealName, IDnum, IDimg); } #endregion #region ---------------------更新或注册店铺信息-------------------------------------- if (strSID != null && strSID != "" && action == "uedite") { if (shopDal.UpdateMSShop(shopModel)) { errorscript = JQDialog.alertOKMsgBox(3, "操作成功!", "MyShop.aspx", "succeed"); } else { errorscript = JQDialog.alertOKMsgBox(3, "操作失败,请核对后再操作!", "ApplyShop.aspx", "error"); } } else { if (!shopDal.ExistMSShop(shopname, strUid)) { if (shopDal.AddMSShop(shopModel)) { Session["SID"] = regSid; errorscript = JQDialog.alertOKMsgBox(3, "操作成功!", "MyShop.aspx", "succeed"); } else { errorscript = JQDialog.alertOKMsgBox(3, "操作失败,请核对后再操作!", "ApplyShop.aspx", "error"); } } else { JQDialog.SetCookies("pageurl", "MyShop.aspx", 2); errorscript = JQDialog.alertOKMsgBox(3, "改店铺已经存在,请登录后操作", "UserLogin.aspx", "error"); } } #endregion }
/// <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 GetHtmlpage() { #region --------------------------判断是否为手机端浏览-------------------------- //判断是否为手机端浏览 //string u = Request.ServerVariables["HTTP_USER_AGENT"]; //Regex b = new Regex(@"(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino", RegexOptions.IgnoreCase | RegexOptions.Multiline); //Regex v = new Regex(@"1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-", RegexOptions.IgnoreCase | RegexOptions.Multiline); //if (!(b.IsMatch(u) || v.IsMatch(u.Substring(0, 4)))) //{ // return; //} #endregion string strSiteCode = string.Empty; string strOpenID = string.Empty; #region -------------------获取用户OpenID--------------- if (Request["state"] != null && Request["state"] != "") { strSiteCode = Common.Common.NoHtml(Request.QueryString["state"].ToString()); Session["strSiteCode"] = strSiteCode; } string code = Request.QueryString["code"] as string; if (!string.IsNullOrEmpty(code)) { WXConfigDAL dal = new WXConfigDAL(); Model.WeiXin.WXConfig wxConfig = dal.GetWXConfigBySiteCode(strSiteCode); if (wxConfig != null) { WeiXinCore.Models.WeiXinConfig weixinConfig = new WeiXinCore.Models.WeiXinConfig() { ID = wxConfig.WXID, Name = wxConfig.WXName, Token = wxConfig.WXToken, AppId = wxConfig.WXAppID, AppSecret = wxConfig.WXAppSecret }; WeiXinCore.WeiXin weixin = new WeiXinCore.WeiXin(weixinConfig); Oauth2AccessToken oauth2AccessToken = weixin.GetOauth2AccessToken(code); if (oauth2AccessToken != null) { strOpenID = oauth2AccessToken.OpenID; } } else { strOpenID = code; } } #endregion List <MSShop> shoplist = new List <MSShop>(); #region -------------获取最新店铺列表----------------- MSShopDAL shopDal = new MSShopDAL(); DataSet shopds = shopDal.GetShopList(20, ""); if (shopds != null && shopds.Tables.Count > 0 && shopds.Tables[0].Rows.Count > 0) { foreach (DataRow row in shopds.Tables[0].Rows) { MSShop shopModel = DataConvert.DataRowToModel <MSShop>(row); shoplist.Add(shopModel); } } #endregion if (strOpenID != null && strOpenID != "") { Session["OpenID"] = strOpenID; } string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/index.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["shoplist"] = shoplist; context.TempData["uid"] = uid; context.TempData["OpenID"] = strOpenID; context.TempData["errormsg"] = errowmsg; context.TempData["title"] = "最新店铺"; 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 (shopname.Text.Trim() != null && shopname.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("~") + @"/ShopLogo")) { System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/ShopLogo"); } if (!System.IO.Directory.Exists(String.Format(@"{0}/PalmShop/ShopCode/ShopLogo/{1}", Server.MapPath("~"), userphone.Text))) { System.IO.Directory.CreateDirectory(String.Format(@"{0}/PalmShop/ShopCode/ShopLogo/{1}", Server.MapPath("~"), userphone.Text)); } 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/ShopLogo/{1}/{2}", Server.MapPath("~"), userphone.Text, newName); strIconSaveFileName = String.Format(@"ShopLogo/{0}/{1}", userphone.Text, newName); file0.PostedFile.SaveAs(strIconFileName); if (oldimg.Trim() != null && oldimg.Trim() != "" && oldimg.Trim().ToLower() != "shoplogo/default.png") { System.IO.File.Delete(String.Format(@"{0}PalmShop/ShopCode/{1}", Server.MapPath("~"), oldimg)); } } } catch (Exception ex) { MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString()); } //上传背景图像 string strbackimgFileName = string.Empty; //图像路径 string strbackimgSaveFileName = string.Empty; //网址路径 try { if (this.file1.PostedFile.FileName == "") { strbackimgSaveFileName = ""; } else { if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/ShopLogo")) { System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/ShopLogo"); } if (!System.IO.Directory.Exists(String.Format(@"{0}/PalmShop/ShopCode/ShopLogo/{1}", Server.MapPath("~"), userphone.Text))) { System.IO.Directory.CreateDirectory(String.Format(@"{0}/PalmShop/ShopCode/ShopLogo/{1}", Server.MapPath("~"), userphone.Text)); } string orignalName = this.file1.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, file1.PostedFile.ContentLength + "backimg", extendName);//对文件进行重命名 strbackimgFileName = String.Format(@"{0}PalmShop/ShopCode/ShopLogo/{1}/{2}", Server.MapPath("~"), userphone.Text, newName); strbackimgSaveFileName = String.Format(@"ShopLogo/{0}/{1}", userphone.Text, newName); file1.PostedFile.SaveAs(strbackimgFileName); if (oldbackimg.Trim() != null && oldbackimg.Trim() != "" && oldbackimg.Trim().ToLower() != "shoplogo/default.png") { System.IO.File.Delete(String.Format(@"{0}PalmShop/ShopCode/{1}", Server.MapPath("~"), oldbackimg)); } } } catch (Exception ex) { MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString()); } MSShopDAL shopdal = new MSShopDAL(); MSShop shopmodel = new MSShop(); shopmodel.ShopName = shopname.Text; shopmodel.ShopDesc = hd_content.Value; shopmodel.ShopState = 0; shopmodel.ID = strID; if (wxname.Text != null && wxname.Text != "") { shopmodel.WXName = wxname.Text; } else { shopmodel.WXName = ""; } if (wxnum.Text != null && wxnum.Text != "") { shopmodel.WXNum = wxnum.Text; } else { shopmodel.WXNum = ""; } if (strIconSaveFileName.Trim() != null && strIconSaveFileName.Trim() != "") { shopmodel.ShopLogo = strIconSaveFileName; } if (strbackimgSaveFileName.Trim() != null && strbackimgSaveFileName.Trim() != "") { shopmodel.ShopBackImg = strbackimgSaveFileName; } if (shopdal.UpdateMSShop(shopmodel)) { MessageBox.Show(this, "操作成功!"); } else { MessageBox.Show(this, "操作失败!"); } } else { MessageBox.Show(this, "请输入相应店铺名称或电话!"); } } else { return; } }