Exemple #1
0
 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 ");
             }
         }
     }
 }
Exemple #2
0
        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.");
                }
            }
        }
Exemple #3
0
 protected void btnOK_OnClick(object sender, EventArgs e)
 {
     if (AdministratorBll.GetAdministrators().SingleOrDefault(a => a.Account == tbxAccount.Text) != null)
     {
         WebUtil.Alert("该用户名已存在!");
         return;
     }
     else
     {
         if (AdministratorBll.AddAdministrator(new Ye_Administrator()
         {
             Account = tbxAccount.Text.Trim(),
             Password = DESUtil.Encrypt(tbxPwd1.Text.Trim()),
             CreateTime = DateTime.Now,
             LastLoginTime = DateTime.Now
         }))
         {
             AdministratorBll.AddAdminLog(new Ye_AdminLog()
             {
                 AdminID     = YeAdministratorId,
                 LogTypeName = LogType.添加管理员.ToString(),
                 CreateTime  = DateTime.Now
             });
             WebUtil.AlertAndReload("成功添加管理员!");
         }
         else
         {
             WebUtil.Alert("创建新管理员时出错!");
         }
     }
 }
Exemple #4
0
        protected void btnOk_OnClick(object sender, EventArgs e)
        {
            if (ProductBll.GetProducts().Count(p => p.ShopID == YeShopId && p.ProductNo == tbxProductNO.Text.Trim()) > 0)
            {
                WebUtil.Alert("菜单编号重复,请重新填写菜单编号!");
                return;
            }
            var product = new Ye_Product()
            {
                ProductDesc   = tbxProductDesc.Text,
                Price         = Convert.ToDecimal(tbxPrice.Text),
                ShopID        = YeShopId,
                ProductName   = tbxProductName.Text,
                ProductNo     = tbxProductNO.Text,
                ProductTypeID = Convert.ToInt32(ddlProductTypes.SelectedValue),
                UnitId        = Convert.ToInt32(ddlUnits.SelectedValue),
                CreateDate    = DateTime.Now,
            };
            var fileName = string.Empty;

            if (!fupProductImage.HasFile)
            {
                WebUtil.Alert("请上传产品图片!");
                return;
            }
            else if (fupProductImage.FileBytes.Length > 1024 * 5120)
            {
                WebUtil.Alert("菜单图片不能超过 5 M!");
                return;
            }
            if (WebUtil.UploadImage(fupProductImage, "../upload/", new [] { ".png", ".jpeg", ".jpg" }, out fileName))
            {
                product.ProductImage = "/upload/" + fileName;
            }
            else
            {
                WebUtil.Alert("上传图片失败,请重试。支持 jpg、png 格式!");
                return;
            }

            if (ProductBll.AddProduct(product))
            {
                WebUtil.AlertAndReload("添加菜单成功!");
            }
            else
            {
                WebUtil.AlertAndReload("添加菜单失败!");
            }
        }
Exemple #5
0
        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("餐馆信息修改失败!");
            }
        }