protected void btnAdd_OnClick(object sender, EventArgs e) { var addrs = UserBll.GetUserAddressesByUserId(YeUser.UserID); if (addrs.Count == 3) { WebUtil.Alert("You have got 3 Addresses!It\\'s Limited.", this); return; } if (UserBll.AddUserAddress(new Ye_UserAddress() { UserID = YeUser.UserID, Address = tbxAddress.Text, Zip = "", AptSuite = "", Receiver = tbxReceiver.Text, Mobile = tbxMobile.Text, IsDefault = addrs.Count == 0 })) { WebUtil.AlertAndRedirect("Success", "UserAddressList.aspx"); } else { WebUtil.AlertAndRedirect("Sorry,something wrong happens.", "UserAddressList.aspx"); } }
protected void btnAdd2Collction_OnClick(object sender, ImageClickEventArgs e) { if (Session["YeUser"] == null) { WebUtil.AlertAndRedirect("Please login first.", "UserLogin.aspx"); } else { var user = (Ye_User)Session["YeUser"]; if (UserBll.GetUserCollectionsByUserId(user.UserID).Count(p => p.ShopID == VisitingShop.ShopID) > 0) { WebUtil.AlertAndReload("You had collected the shop."); } else { if (UserBll.AddUserCollection(new Ye_UserCollection() { UserID = user.UserID, ShopID = VisitingShop.ShopID, IsCollecting = true })) { WebUtil.AlertAndReload("Collect the shop successfully"); } else { WebUtil.AlertAndReload("Failed to Collect the shop "); } } } }
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"); } }
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 admin = AdministratorBll.Login(tbxAccount.Text.Trim(), DESUtil.Encrypt(tbxPassword.Text)); if (admin != null) { AdministratorBll.AddAdminLog(new Ye_AdminLog() { AdminID = admin.AdministratorID, LogTypeName = LogType.登录系统.ToString(), CreateTime = DateTime.Now }); Session["YeAdministratorId"] = admin.AdministratorID; Cache["YeAdministrator"] = admin; Response.Redirect("~/YellEatAdmin/Default.aspx", true); } else { WebUtil.AlertAndRedirect("用户名或密码不正确!", "Login.aspx"); } }
protected void btnAddCoupon_OnClick(object sender, EventArgs e) { if (Session["YeUser"] == null) { WebUtil.AlertAndRedirect("Please login first,then get the coupon!", "UserLogin.aspx"); return; } var user = (Ye_User)Session["YeUser"]; //TODO:确定优惠券规则,使用一次还是使用多次 if (UserCouponBll.ExistsShopCoupon(user.UserID, YeShopCoupon.CouponID)) { WebUtil.AlertAndReload("You have got the coupon."); } else { if (UserCouponBll.AddShopCoupon4User(new Ye_UserCoupon() { ShopId = VisitingShop.ShopID, CouponId = YeShopCoupon.CouponID, IsUsed = false, UserId = user.UserID })) { WebUtil.AlertAndReload("Get the coupon successfully."); } else { WebUtil.AlertAndReload("Failed to get the coupon."); } } }
protected void btnSave_OnClick(object sender, EventArgs e) { if (ddl.SelectedValue == YeAdministratorId.ToString()) { WebUtil.Alert("您无法修改自身的权限!"); } else { var list = new List <int>(); for (int i = 1; i < 12; i++) { var c = this.FindControl("cbx" + i.ToString()) as CheckBox; if (c.Checked) { list.Add(i); } } if (AdministratorBll.UpdateAdminPower(YeAdministratorId, list)) { AdministratorBll.AddAdminLog(new Ye_AdminLog() { AdminID = YeAdministratorId, LogTypeName = LogType.修改权限.ToString(), CreateTime = DateTime.Now }); WebUtil.AlertAndRedirect("权限更新成功!", ""); } } }
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 btnOK_OnClick(object sender, EventArgs e) { byte byteDeliveryStar = 1; byte byteEatingStar = 1; byte.TryParse(hfDeliveryStar.Value, out byteDeliveryStar); byte.TryParse(hfEatingStar.Value, out byteEatingStar); if (OrderBll.AddOrderResult(new Ye_OrderResult() { OrderID = Convert.ToInt32(Request.QueryString["orderId"]), ShopID = ShopId, UserID = YeUser.UserID, EvaluationContent = tbxContent.Text, DeliveryStar = byteDeliveryStar, //待修改 EatingStar = byteEatingStar, //待修改 CreateTime = DateTime.Now })) { WebUtil.AlertAndRedirect("感谢您的支持!", "UserOrders.aspx"); } else { WebUtil.AlertAndRedirect("用餐评价失败!", "UserOrders.aspx"); } }
protected override void OnLoad(EventArgs e) { if (Session["YeShopId"] == null) { WebUtil.AlertAndRedirect("对不起,您登录超时了!请重新登录!", "Login.aspx"); } (this.Master.FindControl("ltlCurrentShop") as Literal).Text = YeShop.ShopAccount; base.OnLoad(e); }
//protected void btnSendSMS_OnClick(object sender, EventArgs e) //{ //} protected void btnRegister_OnClick(object sender, EventArgs e) { var user = new Ye_User() { Address = tbxAddress.Text.Trim(), UserName = tbxName.Text.Trim(), Zip = tbxZip.Text.Trim(), AptSuite = tbxAptSuite.Text.Trim(), Mobile = tbxPhone.Text.Trim(), Password = DESUtil.Encrypt(tbxPassword.Text.Trim()), Email = tbxEmail.Text.Trim(), FaceBookID = "", QQ = "", WxID = "", Status = 0, LastLoginTime = DateTime.Now, RegisterTime = DateTime.Now }; if (UserBll.GetUsers().SingleOrDefault(u => u.UserName == user.UserName) != null) { WebUtil.Alert("The username is used,please change a new username.");//当前用户已经存在!请使用其他用户名注册! return; } if (UserBll.AddUser(user)) { Session["YeUser"] = UserBll.Login(user.UserName, user.Password); if (Request.Cookies["location"] == null) { var cookie = new HttpCookie("location", user.Address); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Response.Cookies["location"].Value = user.Address; } if (Request.Cookies["username"] == null) { var cookie = new HttpCookie("username", user.UserName); cookie.Expires = DateTime.MaxValue; Response.Cookies.Add(cookie); } else { Request.Cookies["username"].Value = user.UserName; } WebUtil.AlertAndRedirect("Register successfully", "Home.aspx"); } else { WebUtil.Alert("Failed to register."); } }
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 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(); } }
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; } }
protected void btnUpdate_OnClick(object sender, EventArgs e) { if (UserBll.UpdateUserAddress(new Ye_UserAddress() { UserAddressID = Convert.ToInt32(hfAddressId.Value), UserID = YeUser.UserID, Address = tbxUpdateAddress.Text, Mobile = tbxUpdteMobile.Text, IsDefault = true, Receiver = tbxUpdateReceiver.Text })) { WebUtil.AlertAndRedirect("信息修改成功", "UserAddressList.aspx"); } else { WebUtil.AlertAndRedirect("信息修改失败", "UserAddressList.aspx"); } }
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 Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (string.IsNullOrEmpty(Request.Form["hdUpdateId"]) || Request.Form["hdUpdateId"] == "0") { WebUtil.AlertAndRedirect("页面过期失效", "UserAddressList.aspx"); return; } int addressId = 0; int.TryParse(Request.Form["hdUpdateId"], out addressId); Ye_UserAddress address = UserBll.GetUserAddressById(addressId); if (address == null) { WebUtil.AlertAndRedirect("该地址不存在", "UserAddressList.aspx"); return; } tbxUpdateReceiver.Text = address.Receiver; tbxUpdteMobile.Text = address.Mobile; tbxUpdateAddress.Text = address.Address; hfAddressId.Value = addressId.ToString(); } }
protected void btnOK_OnClick(object sender, EventArgs e) { if (Convert.ToDateTime(tbxBeginDate.Text) > Convert.ToDateTime(tbxEndDate.Text)) { WebUtil.Alert("优惠结束日期必须在优惠开始日期之后"); return; } if (ShopCouponBll.AddShopCoupon(new Ye_ShopCoupon() { ShopID = YeShopId, CouponCode = tbxCouponCode.Text, BeginDate = Convert.ToDateTime(tbxBeginDate.Text), EndDate = Convert.ToDateTime(tbxEndDate.Text), UnitCost = Convert.ToDecimal(tbxUnitCost.Text), CouponContent = "" })) { WebUtil.AlertAndRedirect("添加优惠券成功!", "ShopCouponList.aspx"); } else { WebUtil.Alert("优惠券添加失败!"); } }
//提交订单 protected void btnOK_OnClick(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbxReceiver.Text)) { WebUtil.Alert("请输入收货人!"); return; } if (string.IsNullOrWhiteSpace(tbxAddress.Text)) { WebUtil.Alert("请输入收货地址!"); return; } if (string.IsNullOrWhiteSpace(tbxMobile.Text)) { WebUtil.Alert("请输入收货人地址!"); return; } if (Convert.ToDecimal(hfTotalPrice.Value) <= 0) { WebUtil.Alert("请先选好数量!"); return; } //订单信息 var order = new Ye_Order() { UserID = YeUser.UserID, ShopID = OrderingShop.ShopID, OrderSN = lblOrderSN.Text, OrderDesc = tbxOrderDesc.Text, OrderCreateTime = DateTime.Now, OrderCheckTime = null, OrderPayTime = null, IsUserDeleted = false, IsShopDeleted = false, Receiver = tbxReceiver.Text, ReceiveAddress = tbxAddress.Text, ReceiverMobile = tbxMobile.Text, TotalPrice = Convert.ToDecimal(hfTotalPrice.Value), Tax = Convert.ToDecimal(hfFax.Value), OrderStatus = (int)OrderStatus.已下单 }; if (!string.IsNullOrWhiteSpace(tbxCode.Text)) { var coupon = ShopCouponBll.GetShopCouponsByShopId(OrderingShop.ShopID) .SingleOrDefault( s => s.BeginDate <DateTime.Now && s.EndDate> DateTime.Now && s.CouponCode == tbxCode.Text); if (coupon == null) { WebUtil.Alert("优惠券验证码无效!"); return; } else { var userCoupon = UserCouponBll.GetUserCouponsByUserId(YeUser.UserID) .SingleOrDefault(p => p.CouponId == coupon.CouponID); if (userCoupon == null) { WebUtil.Alert("您没有该验证码的使用权限!"); return; } else { if (userCoupon.IsUsed) { WebUtil.Alert("该验证码已被使用作废!"); return; } else { UserCouponBll.UseCoupon(YeUser.UserID, userCoupon.UserCouponId); order.ShopCouponID = coupon.CouponID; order.UnitCouponCost = coupon.UnitCost; } } } // } var orderDetails = new List <Ye_OrderDetail>();//获取订单详情 rptProduct.Controls.OfType <RepeaterItem>().ToList().ForEach(p => { var lbl = p.FindControl("lblAmount") as Label; var hf = p.FindControl("hfAmount") as HiddenField; orderDetails.Add(new Ye_OrderDetail() { ProductID = Convert.ToInt32(lbl.Attributes["data-pid"]), Quantity = Convert.ToInt32(hf.Value), UnitCost = Convert.ToDecimal(lbl.Attributes["data-unitcost"]) }); }); if (OrderBll.AddOrder(order, orderDetails)) { Response.Cookies["shop_" + OrderingShop.ShopID.ToString()].Expires = DateTime.Now.AddDays(-1);//清空Cookie信息 //WebUtil.AlertAndRedirect("您的订单已提交,请等候我们的回复!","ShopDetail.aspx?shopid="+OrderingShop.ShopID); WebUtil.AlertAndRedirect("您的订单已提交,请等候我们的回复!", "UserOrders.aspx"); } }