//绑定数据 private void BindData() { foreach (string cookie in Request.Cookies) { string[] str = Regex.Split(cookie, "shop_", RegexOptions.IgnoreCase); if (str.Length == 2) { keys.Add(new Tuple <int[], string>(new int[2] { Convert.ToInt32(str[0]), Convert.ToInt32(str[1]) }, Request.Cookies[cookie].Value)); } } var shop = from s in ShopBll.GetCheckedShop().ToList() join k in (from s in keys group s by s.Item1[0] into g select new { key = g.Key }) on s.ShopID equals k.key select new Ye_Shop() { ShopID = s.ShopID, ShopName = s.ShopName }; rpt.DataSource = shop.ToList(); rpt.DataBind(); }
protected void btnUpdateShop_Click(object sender, EventArgs e) { int shopId; int.TryParse(hfShopId.Value, out shopId); Ye_Shop tempShop = ShopBll.GetShopById(shopId); if (tempShop == null) { WebUtil.AlertAndRedirect("修改失败", "ShopList.aspx"); return; } tempShop.ShopAddress = txtShopAddress.Text; tempShop.ShopZip = txtShopZip.Text; tempShop.ShopMobile = txtShopMobile.Text; tempShop.ShopEmail = txtShopEmail.Text; tempShop.ShopQQ = txtShopQQ.Text; tempShop.ShopFax = txtShopFax.Text; if (ShopBll.UpdateShopInfo(tempShop)) { WebUtil.AlertAndRedirect("修改成功", "ShopList.aspx"); } else { WebUtil.AlertAndRedirect("修改失败", "ShopList.aspx"); } }
protected void btnLogin_OnClick(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbxAccount.Text)) { WebUtil.Alert("用户名不能为空!"); return; } if (string.IsNullOrWhiteSpace(tbxPassword.Text)) { WebUtil.Alert("密码不能为空!"); return; } var shop = ShopBll.Login(tbxAccount.Text.Trim(), DESUtil.Encrypt(tbxPassword.Text)); if (shop != null) { Session["YeShopId"] = shop.ShopID; Cache["Ye_Shop"] = shop; Response.Redirect("Default.aspx", true); } else { WebUtil.AlertAndRedirect("用户名或密码不正确!", "Login.aspx"); } }
private void BindData() { pager1.DataItemCount = ShopBll.GetShops().Count(); rpt.DataSource = ShopBll.GetShops().OrderBy(shop => shop.ShopID).Skip(pager1.PageSize * pager1.CurrentPagerIndex).Take(pager1.PageSize).ToArray(); rpt.DataBind(); pager1.SetPagerControlState(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var idstr = Request.QueryString["shopid"]; int id; if (idstr == null || !int.TryParse(idstr, out id)) { Response.Redirect("ShopList.aspx"); return; } VisitingShop = ShopBll.GetShopById(id); if (VisitingShop == null) { Response.Redirect("ShopList.aspx"); return; } YeShopCoupon = ShopCouponBll.GetShopCouponsByShopId(VisitingShop.ShopID).FirstOrDefault(c => c.BeginDate <DateTime.Now && c.EndDate> DateTime.Now); var sb = new StringBuilder(); for (int i = 0; i < VisitingShop.Rank; i++) { sb.Append("<i class='fa fa-star' style='color:#F07202'></i>"); } ltlRank.Text = sb.ToString(); rptProducts.DataSource = ProductBll.GetProductsByShopId(VisitingShop.ShopID).OrderBy(p => p.RecommendLevel).Take(10).ToList(); rptProducts.DataBind(); rptProductTypes.DataSource = ProductBll.GetProductTypesByShopId(VisitingShop.ShopID).Take(2).ToList(); rptProductTypes.DataBind(); } }
/// <summary> /// 数据绑定并过滤 /// </summary> /// <param name="pagerIndex">分页索引</param> /// <param name="rank">餐馆等级</param> /// <param name="clicks">餐馆点击次数</param> /// <param name="minDeliveryPrice">最小送餐价格</param> /// <param name="shopTypeIds">餐馆类型 Id 列表</param> /// <param name="condition">关键字查询</param> /// <param name="pageSize">页大小</param> private void BindData(int pagerIndex, int rank = 1, int clicks = 0, int minDeliveryPrice = 0, List <int> shopTypeIds = null, string condition = "", int pageSize = 10) { IQueryable <Ye_Shop> query = ShopBll.GetCheckedShop(); if (rank != 1) { query = query.Where(shop => shop.Rank > rank); } if (clicks != 0) { query = query.Where(shop => shop.Clicks >= clicks); } if (minDeliveryPrice != 0) { query = query.Where(shop => shop.DeliveryMinPrice <= minDeliveryPrice); } if (shopTypeIds != null) { query = query.Where(shop => shopTypeIds.Contains(shop.ShopID)); } if (!string.IsNullOrWhiteSpace(condition)) { query = query.Where(shop => shop.ShopName.IndexOf(condition) > -1); } var data = query.OrderBy(p => p.RecommendLevel).Skip(pagerIndex * pageSize).Take(pageSize + 1).ToList(); btnMore.Visible = data.Count > pageSize; rptShopList.DataSource = data.Take(pageSize); rptShopList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { tbxShopName.Text = YeShop.ShopName; tbxShopDesc.Text = YeShop.ShopDesc; tbxLatitude.Text = YeShop.Latitude.ToString(); tbxLongitude.Text = YeShop.Longitude.ToString(); tbxShopAdderss.Text = YeShop.ShopAddress; tbxShopEmail.Text = YeShop.ShopEmail; tbxShopFax.Text = YeShop.ShopFax; tbxShopMobile.Text = YeShop.ShopMobile; tbxShopQQ.Text = YeShop.ShopQQ; tbxShopZip.Text = YeShop.ShopZip; ddlDeliveryTime.DataSource = new[] { new { key = 0, value = "平均送达时间 30 min" }, new { key = 1, value = "平均送达时间 45 min" }, new { key = 2, value = "平均送达时间 60 min" } }; ddlDeliveryTime.DataTextField = "value"; ddlDeliveryTime.DataValueField = "key"; ddlDeliveryTime.DataBind(); ddlDeliveryTime.Items.FindByText(YeShop.DeliveryTime).Selected = true; tbxStartHour.Text = (YeShop.OpeningBeginMinute / 60).ToString(); tbxStartMinute.Text = (YeShop.OpeningBeginMinute % 60).ToString(); tbxEndHour.Text = (YeShop.OpeningEndMinute / 60).ToString(); tbxEndMinute.Text = (YeShop.OpeningEndMinute % 60).ToString(); if (YeShop.OpeningBeginMinute2 != null && YeShop.OpeningEndMinute2 != null) { tbxStartHour2.Text = (YeShop.OpeningBeginMinute2 / 60).ToString(); tbxStartMinute2.Text = (YeShop.OpeningBeginMinute2 % 60).ToString(); tbxEndHour2.Text = (YeShop.OpeningEndMinute2 / 60).ToString(); tbxEndMinute2.Text = (YeShop.OpeningEndMinute2 % 60).ToString(); } if (!string.IsNullOrWhiteSpace(YeShop.ShopLogoImg)) { imgLogo.ImageUrl = YeShop.ShopLogoImg; } else { imgLogo.Visible = false; } if (!string.IsNullOrWhiteSpace(YeShop.ShopMainImg)) { imgMain.ImageUrl = YeShop.ShopMainImg; } else { imgMain.Visible = false; } var shopTypes = ShopBll.GetCheckedShopTypesByShopId(YeShopId); cblShopTypes.DataSource = ShopBll.ShopTypes; cblShopTypes.DataTextField = "ShopTypeName"; cblShopTypes.DataValueField = "ShopTypeId"; cblShopTypes.DataBind(); foreach (ListItem item in cblShopTypes.Items) { if (shopTypes.FirstOrDefault(type => type.ShopTypeId.ToString() == item.Value) != null) { item.Selected = true; } } } }
public void ProcessRequest(HttpContext context) { var shopAccount = context.Request["tbxUserName"]; context.Response.Write(ShopBll.GetShops().SingleOrDefault(s => s.ShopAccount == shopAccount) == null ? "0" : "1"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var orderId = Convert.ToInt32(Request.QueryString["orderId"]); var order = OrderBll.GetOrderByID(Convert.ToInt32(orderId)); Shop = ShopBll.GetShopById(order.ShopID); ShopId = Shop.ShopID; } }
private void BindData() { pager1.DataItemCount = ShopBll.GetShopFeedbacks().Count(); rptShopFeedBack.DataSource = ShopBll.GetShopFeedbacks() .OrderBy(p => p.CreateTime) .Skip(pager1.PageSize * pager1.CurrentPagerIndex) .Take(pager1.PageSize).ToArray(); rptShopFeedBack.DataBind(); pager1.SetPagerControlState(); }
private void BindData() { pager1.DataItemCount = ShopBll.GetShopFeedbacksByShopId(YeShopId).Count(p => p.IsShopDeleted == false); rptShopFeedBack.DataSource = ShopBll.GetShopFeedbacksByShopId(YeShopId) .Where(o => o.IsShopDeleted == false) .OrderBy(p => p.CreateTime) .Skip(pager1.PageSize * pager1.CurrentPagerIndex) .Take(pager1.PageSize).ToArray(); rptShopFeedBack.DataBind(); pager1.SetPagerControlState(); }
public async Task <IActionResult> PutShop(int id, ShopBll shop) { if (id != shop.ShopId) { return(BadRequest()); } await _shopService.PutShop(id, shop); return(NoContent()); }
protected void btnOK_OnClick(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(tbxFeedbackContent.Text)) { if (ShopBll.AddShopFeedback(YeShopId, tbxFeedbackContent.Text)) { WebUtil.AlertAndRedirect("感谢您的意见反馈,请耐心等待我们的回复!", "FeedbackList.aspx"); } else { WebUtil.Alert("提交意见反馈时出错"); } } }
protected void rptShopFeedBack_OnItemCommand(object source, RepeaterCommandEventArgs e) { switch (e.CommandName) { case "del": { var id = Convert.ToInt32(e.CommandArgument.ToString()); ShopBll.ShopDeleteShopFeedback(id); pager1.CurrentPagerIndex = 0; BindData(); break; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CheckPower(AdminPower.加盟餐馆管理); var id = Convert.ToInt32(Request.QueryString["id"]); var data = from shop in ShopBll.GetShops() join feedback in ShopBll.GetShopFeedbacks() on shop.ShopID equals feedback.ShopId where feedback.ShopFeedbackID == id select new { shop, feedback }; Feedback = data.First().feedback; FeedbackShop = data.First().shop; } }
public ShopBll GetShop(int id) { var efShop = _context.Shops.Find(id); var retShop = new ShopBll { ShopId = efShop.ShopId, Name = efShop.Name, ContactNumber = efShop.ContactNumber, Address = efShop.Address, Lat = efShop.Lat, Long = efShop.Long }; return(retShop); }
public async Task PostShop(ShopBll shop) { //Todo ensure this method runs correctly im not great with async calls var efShop = new Shop { ShopId = shop.ShopId, Name = shop.Name, ContactNumber = shop.ContactNumber, Address = shop.Address, Lat = shop.Lat, Long = shop.Long }; _context.Shops.Add(efShop); await _context.SaveChangesAsync(); }
protected void btnOK_OnClick(object sender, EventArgs e) { if (ShopBll.HandleShopFeedback(Convert.ToInt32(Request.QueryString["id"]), tbxFeedbackAnswer.Text)) { AdministratorBll.AddAdminLog(new Ye_AdminLog() { AdminID = YeAdministratorId, LogTypeName = LogType.餐馆管理.ToString(), CreateTime = DateTime.Now }); WebUtil.AlertAndRedirect("反馈处理已提交保存!", "ShopFeedbackList.aspx"); } else { WebUtil.Alert("反馈意见保存失败!"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Location = Request.QueryString["location"]; if (Location == null) { WebUtil.AlertAndRedirect("非法请求!", "Home.aspx"); } CurrentPageIndex = 0; rptShopTypes.DataSource = ShopBll.GetShopTypes(); rptShopTypes.DataBind(); BindData(0); ShopCartNum shopCartNum = new ShopCartNum(); cartNum = shopCartNum.GetShopCartNum(); } }
public async Task PutShop(int id, ShopBll shop) { //Todo ensure this method runs correctly im not great with async calls var efShop = _context.Shops.Find(id); if (efShop != null) { efShop.Name = shop.Name; efShop.ContactNumber = shop.ContactNumber; efShop.Address = shop.Address; efShop.Lat = shop.Lat; efShop.Long = shop.Long; } _context.Shops.Update(efShop); await _context.SaveChangesAsync(); }
protected void rpt_OnItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "del") { var typeId = Convert.ToInt32(e.CommandArgument.ToString()); if (ShopBll.DeleteShopType(typeId)) { WebUtil.Alert("删除成功", this.Page); ShopTypes = ShopBll.GetShopTypes(); pager1.CurrentPagerIndex = 0; BindData(); } else { WebUtil.Alert("删除失败!", this.Page); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CheckPower(AdminPower.加盟餐馆管理); var idstr = Request.QueryString["id"]; int id; if (!int.TryParse(idstr, out id)) { WebUtil.AlertAndRedirect("非法请求", "Default.aspx"); } var data = from shop in ShopBll.GetShops() join feedback in ShopBll.GetShopFeedbacks() on shop.ShopID equals feedback.ShopId where feedback.ShopFeedbackID == id select new { shop, feedback }; Feedback = data.First().feedback; FeedbackShop = data.First().shop; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); if (string.IsNullOrEmpty(context.Request.Form["shopId"])) { return; } int shopId = Convert.ToInt32(context.Request.Form["shopId"]); Ye_Shop shop = ShopBll.GetShopById(shopId); if (shop == null) { return; } string strJson = JsonConvert.SerializeObject(shop); context.Response.Write(strJson); }
protected void btnRegister_OnClick(object sender, EventArgs e) { var shop = new Ye_Shop() { ShopAccount = tbxUserName.Text.Trim(), ShopPassword = DESUtil.Encrypt(tbxUserPwd.Text.Trim()), RegisterTime = DateTime.Now, LastLoginTime = DateTime.Now, ShopName = tbxShopName.Text, ShopAddress = tbxAddr.Text, ShopMobile = tbxShopMobile.Text, ShopEmail = tbxShopEmail.Text, ShopFax = tbxShopFax.Text, ShopZip = tbxShopZip.Text, ShopDesc = "", ShopLogoImg = "", ShopMainImg = "", ShopQQ = "", ShopQRCodeImg = "", Longitude = 0, Latitude = 0, DeliveryTime = "", DeliveryMinPrice = 0, RecommendLevel = 0, IsChecked = false, OpeningBeginMinute = 0, OpeningEndMinute = 0, Rank = 3, Clicks = 0, }; if (ShopBll.AddShop(shop)) { WebUtil.AlertAndRedirect("您的餐馆已成功注册,请耐心等待审核!", "Login.aspx"); } else { WebUtil.Alert("餐馆注册失败!"); } }
protected void btnAddShopType_OnClick(object sender, EventArgs e) { if (ShopTypes.SingleOrDefault(p => p.ShopTypeName == tbxAddShopType.Text.Trim()) != null) { WebUtil.Alert("该餐馆类型已存在", this.Page); return; } else { if (ShopBll.AddShopType(tbxAddShopType.Text.Trim())) { ShopTypes = ShopBll.GetShopTypes(); pager1.CurrentPagerIndex = 0; BindData(); } else { WebUtil.Alert("添加餐馆类型已存在", this.Page); return; } } }
// 绑定数据,分页索引从 0 开始 protected void BindData() { pager1.DataItemCount = ShopTypes.Count; var count = from shop2shoptype in ShopBll.GetShop2ShopTypes() group shop2shoptype by shop2shoptype.ShopTypeID; var query = from shoptype in ShopTypes join g in count.ToArray() on shoptype.ShopTypeId equals g.Key into g select new { shoptype.ShopTypeId, shoptype.ShopTypeName, ShopCount = g == null?0:g.Count() }; //var query = ShopTypes.Join(count.ToArray(),o=>o.ShopTypeId,p=>p); rpt.DataSource = query.Skip(pager1.CurrentPagerIndex * pager1.PageSize).Take(pager1.PageSize); rpt.DataBind(); pager1.SetPagerControlState(); }
//更新餐馆 protected void btnUpdateShopType_OnClick(object sender, EventArgs e) { if (ShopTypes.SingleOrDefault(p => p.ShopTypeName == tbxUpdateShopType.Text.Trim()) != null) { WebUtil.Alert("该餐馆类型已存在", this.Page); return; } else { if (ShopBll.UpdateShopType(Convert.ToInt32(hf.Value), tbxUpdateShopType.Text.Trim())) { ShopTypes = ShopBll.GetShopTypes(); pager1.CurrentPagerIndex = 0; BindData(); } else { WebUtil.Alert("修改餐馆类型失败", this.Page); return; } } }
protected void btnOK_OnClick(object sender, EventArgs e) { if (YeShop.ShopPassword != DESUtil.Encrypt(tbxOldPwd.Text)) { WebUtil.Alert("您输入的当期登录密码不正确!"); tbxOldPwd.Focus(); return; } else { var newPwd = DESUtil.Encrypt(tbxNewPwd1.Text.Trim()); if (ShopBll.ChangePassword(YeShopId, newPwd)) { WebUtil.Alert("密码修改成功!"); YeShop.ShopPassword = newPwd; } else { WebUtil.Alert("密码修改失败!"); } } }
protected void rpt_OnItemCommand(object source, RepeaterCommandEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { switch (e.CommandName) { case "sh": { var shop = e.CommandArgument.ToString().Split(','); ShopBll.SetShopCheckState(Convert.ToInt32(shop[0]), !Convert.ToBoolean(shop[1])); pager1.CurrentPagerIndex = 0; BindData(); AdministratorBll.AddAdminLog(new Ye_AdminLog() { AdminID = YeAdministratorId, LogTypeName = LogType.餐馆管理.ToString(), CreateTime = DateTime.Now }); break; } } } }
protected void btnOK_OnClick(object sender, EventArgs e) { int?tmpBeginMinute2; int?tmpEndMinute2; if (string.IsNullOrEmpty(tbxStartHour2.Text) || string.IsNullOrEmpty(tbxStartMinute2.Text) || string.IsNullOrEmpty(tbxEndHour2.Text) || string.IsNullOrEmpty(tbxEndMinute2.Text)) { tmpBeginMinute2 = null; tmpEndMinute2 = null; } else { tmpBeginMinute2 = Convert.ToInt32(tbxStartHour2.Text) * 60 + Convert.ToInt32(tbxStartMinute2.Text); tmpEndMinute2 = Convert.ToInt32(tbxEndHour2.Text) * 60 + Convert.ToInt32(tbxEndMinute2.Text); } var shop = new Ye_Shop() { ShopID = YeShopId, DeliveryTime = ddlDeliveryTime.SelectedItem.Text, ShopDesc = tbxShopDesc.Text, ShopZip = tbxShopZip.Text, ShopFax = tbxShopFax.Text, ShopMobile = tbxShopMobile.Text, ShopEmail = tbxShopEmail.Text, ShopAddress = tbxShopAdderss.Text, ShopName = tbxShopName.Text, Longitude = Convert.ToDecimal(tbxLongitude.Text), Latitude = Convert.ToDecimal(tbxLatitude.Text), ShopQQ = tbxShopQQ.Text, OpeningBeginMinute = Convert.ToInt32(tbxStartHour.Text) * 60 + Convert.ToInt32(tbxStartMinute.Text), OpeningEndMinute = Convert.ToInt32(tbxEndHour.Text) * 60 + Convert.ToInt32(tbxEndMinute.Text), OpeningBeginMinute2 = tmpBeginMinute2, OpeningEndMinute2 = tmpEndMinute2, ShopLogoImg = imgLogo.ImageUrl, ShopMainImg = imgMain.ImageUrl }; var str = ""; if (fupShopLogoImg.HasFile) { if (fupShopLogoImg.FileBytes.Length > 1024 * 10240) { WebUtil.Alert("餐馆 Logo 图片不能超过 10 M!"); return; } if (WebUtil.UploadImage(fupShopLogoImg, "../upload/", new [] { ".gif", ".jpg", ".png", ".jpeg" }, out str)) { shop.ShopLogoImg = "/upload/" + str; } else { WebUtil.Alert("餐馆 Logo 图片格式不被支持!"); return; } } if (fupShopMainImg.HasFile) { if (fupShopMainImg.FileBytes.Length > 1024 * 10240) { WebUtil.Alert("餐馆图片不能超过 10 M!"); return; } if (WebUtil.UploadImage(fupShopMainImg, "../upload/", new [] { ".gif", ".jpg", ".png", ".jpeg" }, out str)) { shop.ShopMainImg = "/upload/" + str; } else { WebUtil.Alert("餐馆主图 图片格式不被支持!"); return; } } var f1 = ShopBll.UpdateShopInfo(shop); var list = new List <int>(); foreach (ListItem item in cblShopTypes.Items) { if (item.Selected) { list.Add(Convert.ToInt32(item.Value)); } } var f2 = ShopBll.SetShopTypeChecked(YeShopId, list); if (f1 || f2) { WebUtil.AlertAndReload("餐馆信息修改成功!"); } else { WebUtil.AlertAndReload("餐馆信息修改失败!"); } }