public async Task <IActionResult> Edit(int id, [Bind("ShopId,NameShop,IsDeliver,OpenHourId,AddressId")] TShop tShop) { if (id != tShop.ShopId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tShop); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TShopExists(tShop.ShopId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tShop)); }
/// <summary> /// 获取指定商铺的json字符串 /// </summary> /// <param name="keyword"></param> /// <returns></returns> public string GetShopJsonByKeyWord(string keyword) { NameValueCollection nvc = new NameValueCollection(); nvc.Add("@keyword", "%" + keyword.Trim() + "%"); StringBuilder sb = new StringBuilder(); dh.Open(); DataTable dt = dh.GetDataTable(CommandType.Text, "Select top 100 ShopID from T_Shop where ShopTitle like @keyword or ShopETitle like @keyword order by SortID asc,ShopID desc", nvc); dh.Close(); List <TModel.json.J_shop> T_list = new List <TModel.json.J_shop>(); TModel.json.J_shop jshopnull = new TModel.json.J_shop(); jshopnull.ShopID = "-1"; jshopnull.ShopTitle = "暂无商家"; T_list.Add(jshopnull); for (int i = 0; i < dt.Rows.Count; i++) { int id = 0; Int32.TryParse(dt.Rows[i]["ShopID"].ToString().Trim(), out id); TShop shop = GetShopByID(id); TModel.json.J_shop jshop = new TModel.json.J_shop(); jshop.ShopID = shop.ShopID.ToString(); jshop.ShopTitle = shop.ShopTitle; T_list.Add(jshop); } dt.Dispose(); return(CommonLibrary.CommOperate.ToJson(T_list)); }
/// <summary> /// 更新商家信息 /// </summary> /// <param name="ShopID"></param> /// <param name="Shop"></param> /// <returns></returns> public int UpdateShop(int ShopID, TShop Shop) { int stat = 0; NameValueCollection nvc = new NameValueCollection(); nvc.Add("@ShopTitle", Shop.ShopTitle); nvc.Add("@ShopETitle", Shop.ShopETitle); nvc.Add("@ShopPic", Shop.ShopPic); nvc.Add("@ShopMemo", Shop.ShopMemo); nvc.Add("@ShopProvince", Shop.ShopProvince); nvc.Add("@ShopCity", Shop.ShopCity); nvc.Add("@ShopArea", Shop.ShopArea); nvc.Add("@ShopLongitude", Shop.ShopLongitude); nvc.Add("@ShopLatitude", Shop.ShopLatitude); nvc.Add("@ShopRoute", Shop.ShopRoute); nvc.Add("@ShopOpenTime", Shop.ShopOpenTime); nvc.Add("@ShopTemplate", Shop.ShopTemplate); nvc.Add("@ShopAddtime", Shop.ShopAddtime.ToString()); nvc.Add("@ShopAdder", Shop.ShopAdder); nvc.Add("@SortID", Shop.SortID.ToString()); nvc.Add("@IsRecom", Shop.IsRecom.ToString()); nvc.Add("@IsHtml", Shop.IsHtml.ToString()); nvc.Add("@HtmlPath", Shop.HtmlPath); nvc.Add("@ShopID", ShopID.ToString()); nvc.Add("@IsRemote", Shop.IsRemote.ToString()); dh.Open(); stat = dh.ExecuteNonQuery(CommandType.Text, "Update T_Shop set ShopTitle=@ShopTitle,ShopETitle=@ShopETitle,ShopPic=@ShopPic,ShopMemo=@ShopMemo,ShopProvince=@ShopProvince,ShopCity=@ShopCity,ShopArea=@ShopArea,ShopLongitude=@ShopLongitude,ShopLatitude=@ShopLatitude,ShopRoute=@ShopRoute,ShopOpenTime=@ShopOpenTime,ShopTemplate=@ShopTemplate,ShopAddtime=@ShopAddtime,ShopAdder=@ShopAdder,SortID=@SortID,IsRecom=@IsRecom,IsHtml=@IsHtml,HtmlPath=@HtmlPath,IsRemote=@IsRemote where ShopID=@ShopID ", nvc); dh.Close(); return(stat); }
/// <summary> /// 插入商家信息 /// </summary> /// <param name="Shop"></param> /// <returns></returns> public int AddShop(TShop Shop) { int stat = 0; NameValueCollection nvc = new NameValueCollection(); nvc.Add("@ShopTitle", Shop.ShopTitle); nvc.Add("@ShopETitle", Shop.ShopETitle); nvc.Add("@ShopPic", Shop.ShopPic); nvc.Add("@ShopMemo", Shop.ShopMemo); nvc.Add("@ShopProvince", Shop.ShopProvince); nvc.Add("@ShopCity", Shop.ShopCity); nvc.Add("@ShopArea", Shop.ShopArea); nvc.Add("@ShopLongitude", Shop.ShopLongitude); nvc.Add("@ShopLatitude", Shop.ShopLatitude); nvc.Add("@ShopRoute", Shop.ShopRoute); nvc.Add("@ShopOpenTime", Shop.ShopOpenTime); nvc.Add("@ShopTemplate", Shop.ShopTemplate); nvc.Add("@ShopAddtime", Shop.ShopAddtime.ToString()); nvc.Add("@ShopAdder", Shop.ShopAdder); nvc.Add("@SortID", Shop.SortID.ToString()); nvc.Add("@IsRecom", Shop.IsRecom.ToString()); nvc.Add("@IsHtml", Shop.IsHtml.ToString()); nvc.Add("@HtmlPath", Shop.HtmlPath); nvc.Add("@IsRemote", Shop.IsRemote.ToString()); dh.Open(); stat = dh.ExecuteNonQuery(CommandType.Text, "Insert into T_Shop(ShopTitle,ShopETitle,ShopPic,ShopMemo,ShopProvince,ShopCity,ShopArea,ShopLongitude,ShopLatitude,ShopRoute,ShopOpenTime,ShopTemplate,ShopAddtime,ShopAdder,SortID,IsRecom,IsHtml,HtmlPath,IsRemote) values(@ShopTitle,@ShopETitle,@ShopPic,@ShopMemo,@ShopProvince,@ShopCity,@ShopArea,@ShopLongitude,@ShopLatitude,@ShopRoute,@ShopOpenTime,@ShopTemplate,@ShopAddtime,@ShopAdder,@SortID,@IsRecom,@IsHtml,@HtmlPath,@IsRemote)", nvc); dh.Close(); return(stat); }
protected void UpdateSortID(int id, int sortid) { ShopBLL spdll = new ShopBLL(); TShop tshop = spdll.GetShop(id); tshop.SortID = sortid; spdll.UpdateShop(tshop, id); }
public async Task <IActionResult> Create([Bind("ShopId,NameShop,IsDeliver,OpenHourId,AddressId")] TShop tShop) { if (ModelState.IsValid) { _context.Add(tShop); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tShop)); }
protected void DeleteShop(int ShopID) { TShop shop = shopbll.GetShop(ShopID); if (shop.ShopPic.Trim() != "") { CommonLibrary.CommOperate.DeleteFile(Server.MapPath(shop.ShopPic)); } ImageOperate.DeleteMemoImage(shop.ShopMemo); shopbll.DeleteShop(ShopID); }
/// <summary> /// 根据shopid获取商家 /// </summary> /// <param name="id"></param> /// <returns></returns> public TShop GetShopByID(int id) { NameValueCollection nvc = new NameValueCollection(); TShop ts = new TShop(); nvc.Add("@ShopID", id.ToString()); dh.Open(); using (DbDataReader dr = dh.ExecuteReader(CommandType.Text, SelectShop + " and ShopID=@ShopID", nvc)) { if (dr.HasRows) { dr.Read(); ts.ShopID = id; ts.ShopTitle = dr["ShopTitle"].ToString(); ts.ShopETitle = dr["ShopETitle"].ToString(); ts.ShopPic = dr["ShopPic"].ToString(); ts.ShopMemo = dr["ShopMemo"].ToString(); ts.ShopProvince = dr["ShopProvince"].ToString(); ts.ShopCity = dr["ShopCity"].ToString(); ts.ShopArea = dr["ShopArea"].ToString(); ts.ShopLongitude = dr["ShopLongitude"].ToString(); ts.ShopLatitude = dr["ShopLatitude"].ToString(); ts.ShopRoute = dr["ShopRoute"].ToString(); ts.ShopOpenTime = dr["ShopOpenTime"].ToString(); ts.ShopTemplate = dr["ShopTemplate"].ToString(); DateTime Addtime; DateTime.TryParse(dr["ShopAddtime"].ToString(), out Addtime); ts.ShopAddtime = Addtime; ts.ShopAdder = dr["ShopAdder"].ToString(); int SortID = 0; Int32.TryParse(dr["SortID"].ToString(), out SortID); ts.SortID = SortID; bool IsRecom; bool.TryParse(dr["IsRecom"].ToString(), out IsRecom); ts.IsRecom = IsRecom; bool IsHtml; bool.TryParse(dr["IsHtml"].ToString(), out IsHtml); ts.IsHtml = IsHtml; ts.HtmlPath = dr["HtmlPath"].ToString(); bool IsRemote; bool.TryParse(dr["IsRemote"].ToString(), out IsRemote); ts.IsRemote = IsRemote; } } dh.Close(); return(ts); }
public int UpdateShop(TShop sp, int id) { return(ShopOperate.UpdateShop(id, sp)); }
public int AddShop(TShop shop) { return(ShopOperate.AddShop(shop)); }
protected void Button1_Click(object sender, EventArgs e) { #region 变量 string ShopTitle = tbx_title.Text.Trim(); string ShopETitle = Tbx_Identifier.Text.Trim(); string ShopPic = CommonLibrary.CommOperate.GetStrFromRequestForm("CatePic"); string ShopMemo = ContentHolder.Value; string ShopProvince = CommonLibrary.CommOperate.GetStrFromRequestForm("Sel_Province"); if (ShopProvince.Equals("-1")) { CommonLibrary.RunJs.AlertAndBack("请选择省"); } string ShopCity = CommonLibrary.CommOperate.GetStrFromRequestForm("Sel_City"); if (ShopCity.Equals("-1")) { CommonLibrary.RunJs.AlertAndBack("请选择市"); } string ShopArea = CommonLibrary.CommOperate.GetStrFromRequestForm("Sel_Area"); if (ShopArea.Equals("-1")) { CommonLibrary.RunJs.AlertAndBack("请选择区"); } string ShopLongitude = tbx_ShopLongitude.Text.Trim(); //经度 string ShopLatitude = tbx_ShopLatitude.Text.Trim(); //纬度 string ShopRoute = tbx_ShopRoute.Text.Trim(); //交通路线 string ShopOpenTime = tbx_ShopOpenTime.Text.Trim(); //开业时间 string ShopTemplate = Tbx_ShopTemplate.Text.Trim(); //商场模板 DateTime ShopAddtime; DateTime.TryParse(Tbx_Addtime.Text.Trim(), out ShopAddtime); string ShopAdder = H_Adder.Value; int SortID = 0; Int32.TryParse(tbx_SortId.Text, out SortID); bool IsRecom = false; bool.TryParse(CommonLibrary.CommOperate.GetStrFromRequestForm("Chk_tuijian"), out IsRecom); bool IsHtml = false; string HtmlPath = Tbx_htmlpath.Text.Trim(); bool IsRemote = false;//是否远程,获取图片,默认为否 bool.TryParse(CommonLibrary.CommOperate.GetStrFromRequestForm("Chk_Remote"), out IsRemote); #endregion TShop ts = new TShop(); ts.ShopTitle = ShopTitle; ts.ShopETitle = ShopETitle; ts.ShopPic = ShopPic; if (IsRemote == true) { ts.ShopMemo = ImageOperate.GetRemoteImage(ShopMemo, "/uploadfile/remote/"); } else { ts.ShopMemo = ShopMemo; } ts.ShopProvince = ShopProvince; ts.ShopCity = ShopCity; ts.ShopArea = ShopArea; ts.ShopLongitude = ShopLongitude; ts.ShopLatitude = ShopLatitude; ts.ShopRoute = ShopRoute; ts.ShopOpenTime = ShopOpenTime; ts.ShopTemplate = ShopTemplate; ts.ShopAddtime = ShopAddtime; ts.ShopAdder = ShopAdder; ts.SortID = SortID; ts.IsRecom = IsRecom; ts.IsHtml = IsHtml; ts.HtmlPath = HtmlPath; ts.IsRemote = IsRemote; TBLL.ShopBLL shopbll = new ShopBLL(); shopbll.AddShop(ts); int lastid = shopbll.GetLastShopID(); CommonLibrary.RunJs.PageReplace("Shop_UpdateManage.aspx?LastID=" + lastid); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int shopid = 0; Int32.TryParse(CommonLibrary.CommOperate.GetStrFromRequestQueryString("id"), out shopid); TShop tshop = new TShop(); ShopBLL spbll = new ShopBLL(); tshop = spbll.GetShop(shopid); tbx_title.Text = tshop.ShopTitle; Tbx_Identifier.Text = tshop.ShopETitle; ContentHolder.Value = tshop.ShopMemo; tbx_ShopLongitude.Text = tshop.ShopLongitude; tbx_ShopLatitude.Text = tshop.ShopLatitude; tbx_ShopRoute.Text = tshop.ShopRoute; tbx_ShopOpenTime.Text = tshop.ShopOpenTime; Tbx_ShopTemplate.Text = tshop.ShopTemplate; Tbx_Addtime.Text = tshop.ShopAddtime.ToString("yyyy-MM-dd hh:mm:ss"); Tbx_Adder.Text = this.LoginUser.Admin_RealName; H_Adder.Value = LoginUser.Admin_ID.ToString(); tbx_SortId.Text = tshop.SortID.ToString(); if (tshop.IsRecom == true) { L_IsRecoom.Text = "<input type=\"checkbox\" id=\"Chk_tuijian\" name=\"Chk_tuijian\" Checked=Checked value=\"true\" />"; } else { L_IsRecoom.Text = "<input type=\"checkbox\" id=\"Chk_tuijian\" name=\"Chk_tuijian\" value=\"true\" />"; } Tbx_htmlpath.Text = tshop.HtmlPath; #region 省 市 地区 string ShopProvince = string.Empty; ShopProvince = tshop.ShopProvince; string ShopCity = string.Empty; ShopCity = tshop.ShopCity; string ShopArea = string.Empty; ShopArea = tshop.ShopArea; AddressBLL addbll = new AddressBLL(); StringBuilder sb = new StringBuilder(); #region 省 using (DataTable dtprovince = addbll.GetAllProvince()) { sb.Append("<option value=\"-1\">请选择...</option"); if (dtprovince.Rows.Count > 0) { for (int i = 0; i < dtprovince.Rows.Count; i++) { if (dtprovince.Rows[i]["code"].ToString().Equals(ShopProvince)) { sb.Append("<option value='" + dtprovince.Rows[i]["code"] + "' selected=selected>" + dtprovince.Rows[i]["name"] + "</option>"); } else { sb.Append("<option value='" + dtprovince.Rows[i]["code"] + "'>" + dtprovince.Rows[i]["name"] + "</option>"); } } } } L_province.Text = sb.ToString(); sb.Length = 0; #endregion #region 市 using (DataTable dtcity = addbll.GetCityByProvince(ShopProvince)) { sb.Append("<option value='-1'>市</option>"); if (dtcity.Rows.Count > 0) { for (int i = 0; i < dtcity.Rows.Count; i++) { if (dtcity.Rows[i]["code"].ToString().Equals(ShopCity)) { sb.Append("<option value='" + dtcity.Rows[i]["code"].ToString() + "' selected=selected>" + dtcity.Rows[i]["name"].ToString() + "</option>"); } else { sb.Append("<option value='" + dtcity.Rows[i]["code"].ToString() + "'>" + dtcity.Rows[i]["name"].ToString() + "</option>"); } } } } L_City.Text = sb.ToString(); #endregion sb.Length = 0; #region 地区 using (DataTable dtarea = addbll.GetAreaByCity(ShopCity)) { sb.Append("<option value='-1'>地区</option>"); for (int i = 0; i < dtarea.Rows.Count; i++) { if (dtarea.Rows[i]["code"].ToString().Equals(ShopArea)) { sb.Append("<option value='" + dtarea.Rows[i]["code"].ToString() + "' selected=selected>" + dtarea.Rows[i]["name"].ToString() + "</option>"); } else { sb.Append("<option value='" + dtarea.Rows[i]["code"].ToString() + "' >" + dtarea.Rows[i]["name"].ToString() + "</option>"); } } } L_Area.Text = sb.ToString(); #endregion #endregion #region 是否获取远程图片 if (tshop.IsRemote == true) { L_isRemote.Text = "<input type=\"checkbox\" id=\"Chk_Remote\" name=\"Chk_Remote\" value=\"true\" Checked=Checked />"; } else { L_isRemote.Text = "<input type=\"checkbox\" id=\"Chk_Remote\" name=\"Chk_Remote\" value=\"true\" />"; } #endregion #region 图片列表 L_selpic.Text = ImageOperate.GetImageSelect(tshop.ShopMemo, tshop.ShopPic); #endregion } }