예제 #1
0
        public void GetMenu(HttpContext context)
        {
            context.Response.ContentType = "application/json;charset=utf-8";
            context.Response.Charset     = "utf-8";
            string       str          = "{";
            ShopMenuInfo shopMenuInfo = new ShopMenuInfo();
            int          menuId       = 0;

            if (!int.TryParse(context.Request["MenuId"], out menuId))
            {
                str = "\"status\":\"1\"";
            }
            else
            {
                shopMenuInfo = ShopMenuHelper.GetMenu(menuId);
                if (shopMenuInfo != null)
                {
                    str += "\"status\":\"0\",\"data\":[";
                    str  = str + "{\"menuid\": \"" + shopMenuInfo.MenuId + "\",";
                    str  = str + "\"type\": \"" + shopMenuInfo.Type + "\",";
                    str  = str + "\"name\": \"" + shopMenuInfo.Name + "\",";
                    str  = str + "\"shopmenupic\": \"" + shopMenuInfo.ShopMenuPic + "\",";
                    str  = str + "\"content\": \"" + shopMenuInfo.Content + "\"}";
                    str += "]";
                }
                str += "}";
                context.Response.Write(str);
            }
        }
예제 #2
0
        public static bool SaveMenu(ShopMenuInfo menu)
        {
            ShopMenuDao shopMenuDao = new ShopMenuDao();

            ShopMenuHelper.RemoveMenuCache(menu);
            return(shopMenuDao.SaveMenu(menu));
        }
예제 #3
0
        public static bool UpdateMenu(ShopMenuInfo menu)
        {
            ShopMenuDao shopMenuDao = new ShopMenuDao();

            ShopMenuHelper.RemoveMenuCache(menu);
            return(shopMenuDao.Update(menu, null));
        }
예제 #4
0
        public void AddMenus(HttpContext context)
        {
            context.Response.ContentType = "application/json;charset=utf-8";
            context.Response.Charset     = "utf-8";
            string       s            = "{\"status\":\"1\"}";
            ShopMenuInfo shopMenuInfo = new ShopMenuInfo();

            shopMenuInfo.Content = context.Request["Content"].Trim();
            shopMenuInfo.Name    = Globals.UrlDecode(context.Request["Name"].Trim());
            if (context.Request["ParentMenuId"] != null)
            {
                shopMenuInfo.ParentMenuId = ((!(context.Request["ParentMenuId"] == "")) ? int.Parse(context.Request["ParentMenuId"]) : 0);
            }
            else
            {
                shopMenuInfo.ParentMenuId = 0;
            }
            shopMenuInfo.Type        = context.Request["Type"];
            shopMenuInfo.ClientType  = context.Request["clientType"].ToInt(0);
            shopMenuInfo.ShopMenuPic = this.SaveMenuPic(context.Request["ShopMenuPic"]);
            if (ShopMenuHelper.CanAddMenu(shopMenuInfo.ParentMenuId, 0))
            {
                if (ShopMenuHelper.SaveMenu(shopMenuInfo))
                {
                    s = "{\"status\":\"0\"}";
                }
            }
            else
            {
                s = "{\"status\":\"2\"}";
            }
            context.Response.Write(s);
        }
예제 #5
0
        public void updatename(HttpContext context)
        {
            context.Response.ContentType = "application/json;charset=utf-8";
            context.Response.Charset     = "utf-8";
            string s   = "{\"status\":\"1\"}";
            int    num = 0;

            if (!int.TryParse(context.Request["MenuId"], out num))
            {
                s = "{\"status\":\"1\"}";
            }
            else
            {
                if (num > 0)
                {
                    ShopMenuInfo menu = ShopMenuHelper.GetMenu(num);
                    menu.Name   = context.Request["Name"];
                    menu.MenuId = num;
                    if (ShopMenuHelper.UpdateMenu(menu))
                    {
                        s = "{\"status\":\"0\"}";
                    }
                }
                context.Response.Write(s);
            }
        }
예제 #6
0
        public void EditMenus(HttpContext context)
        {
            context.Response.ContentType = "application/json;charset=utf-8";
            context.Response.Charset     = "utf-8";
            string       s            = "{\"status\":\"1\"}";
            ShopMenuInfo shopMenuInfo = new ShopMenuInfo();

            shopMenuInfo.Content = context.Request["Content"];
            shopMenuInfo.Name    = context.Request["Name"];
            shopMenuInfo.Type    = context.Request["Type"];
            if (!string.IsNullOrEmpty(context.Request["ParentMenuId"]))
            {
                shopMenuInfo.ParentMenuId = int.Parse(context.Request["ParentMenuId"]);
            }
            else
            {
                shopMenuInfo.ParentMenuId = 0;
            }
            int menuId = 0;

            if (!int.TryParse(context.Request["MenuId"], out menuId))
            {
                s = "{\"status\":\"1\"}";
            }
            else
            {
                shopMenuInfo.MenuId      = menuId;
                shopMenuInfo.ShopMenuPic = this.SaveMenuPic(context.Request["ShopMenuPic"]);
                if (ShopMenuHelper.UpdateMenu(shopMenuInfo))
                {
                    s = "{\"status\":\"0\"}";
                }
                context.Response.Write(s);
            }
        }
예제 #7
0
        public static bool DeleteMenu(int menuId)
        {
            ShopMenuInfo menu = ShopMenuHelper.GetMenu(menuId);

            if (menu == null)
            {
                return(false);
            }
            ShopMenuDao shopMenuDao = new ShopMenuDao();
            bool        result      = shopMenuDao.DeleteMenu(menuId);

            ShopMenuHelper.RemoveMenuCache(menu);
            return(result);
        }
예제 #8
0
 private static void RemoveMenuCache(ShopMenuInfo menu)
 {
     HiCache.Remove($"DataCache-ShopMenuCacheKey-{menu.ClientType}");
     HiCache.Remove($"DataCache-FooterMenuCacheKey-{menu.ClientType}");
 }
예제 #9
0
        public bool SaveMenu(ShopMenuInfo menu)
        {
            int num = menu.DisplaySequence = this.GetAllMenusCount(menu.ClientType);

            return(this.Add(menu, null) > 0);
        }
 public static ShopMenuInfo GetShopMenuInfo(string ShopMenutId)
 {
     DbCommand comm = DataAccessClass.CreateCommand();
     comm.CommandText = "StoreGetShopMenuDetails";
     DbParameter param = comm.CreateParameter();
     param.ParameterName = "@ShopMenuID";
     param.Value = ShopMenutId;
     param.DbType = DbType.Int32;
     comm.Parameters.Add(param);
     DataTable table = DataAccessClass.ExecuteSelectCommand(comm);
     // wrap retrieved data into a ShopMenuInfo object
     ShopMenuInfo info = new ShopMenuInfo();
     if (table.Rows.Count > 0)
     {
         info.ShopMenuName = table.Rows[0]["ShopMenuName"].ToString();
         info.ShopMenuDescription = table.Rows[0]["ShopMenuDescription"].ToString();
     }
     return info;
 }