zoukankan      html  css  js  c++  java
  • JQuery仿淘宝商家后台管理 之 管理添加分类

    先看一下效果图:

    JQuery 仿淘宝后台管理分类

    实现功能:

    1、打开时加载分类信息,折叠所有分类

    2、动态添加子类和父类

    3、顺序的调整

    4、无刷新删除,添加

    5、保存到数据库

    下面是HTML代码 :


    后台数据一般处理程序代码:

    添加

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    namespace FM.Web.AdminView.ashx
    {
        /// <summary>
        /// UpdateClasses 的摘要说明
        /// </summary>
        public class UpdateClasses : IHttpHandler
        {
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
                string strClass = context.Request["strClass"].TrimEnd(',');
                string strChilds = context.Request["strChilds"].TrimEnd(',');
    
                BLL.ClassInfo bll = new BLL.ClassInfo();
                BLL.ClassChild bllChild = new BLL.ClassChild();
    
                if (strClass.Length > 0 || strChilds.Length > 0)
                {
                    try
                    {
                        string[] classes = strClass.Split(',');
                        string[] childs = strChilds.Split(',');
                        //读取父类数据 保存到数据库中
                        foreach (string item in classes)
                        {
                            string[] classInfo = item.Split('&');
                            string classID = classInfo[0];
                            string className = classInfo[1];
                            bll.CheckAndAddClass(classID, className);
                        }
    
                        //读取子类数据 保存到数据库中
                        foreach (string item in childs)
                        {
                            string[] childrenInfo = item.Split('&');
                            string classID = childrenInfo[0];
                            string childClassName = childrenInfo[1];
    
                            bllChild.CheckAndAddClassChild(classID, childClassName);
                        }
                        context.Response.Write("OK");
                    }
                    catch
                    {
                        context.Response.Write("error");
                    }
                }
                else
                {
                    context.Response.Write("error");
                }
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }

    删除

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    namespace FM.Web.AdminView.ashx
    {
        /// <summary>
        /// DeletClass 的摘要说明
        /// </summary>
        public class DeletClass : IHttpHandler
        {
            BLL.ClassInfo bllClass = new BLL.ClassInfo();
            BLL.ClassChild bllChild = new BLL.ClassChild();
    
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
                if (!string.IsNullOrEmpty(context.Request["Action"]))
                {
                    if (context.Request["Action"] == "Delete")
                    {
                        string ID = context.Request["ClassID"] == null ? "-1" : context.Request["ClassID"];
                        string DelObj = context.Request["DelObj"];
                        int delID = int.Parse(ID);
                        if (DelObj == "F")//父类
                        {
                            //根据ID查询父类的排序ID,再删除子类和父类
                            Model.ClassInfo modelClass = bllClass.GetModel(delID);
                            string classID = modelClass.ClassID;
                            if (bllChild.DeleteList("ClassID like '" + classID + "-%" + "'"))
                            {
                                if (bllClass.Delete(delID))
                                { 
                                    context.Response.Write("OK");
                                    return;
                                }
                            }
                            context.Response.Write("error");
                        }
                        else if (DelObj == "C")//子类
                        {
                            if (bllChild.Delete(delID))
                            {
                                context.Response.Write("OK");
                                return;
                            }
                            context.Response.Write("error");
                        }
                        else
                        {
                            context.Response.Write("error");
                        }
                    }
                    else
                    {
                        context.Response.Write("error");
                    }
                }
                else
                {
                    context.Response.Write("error");
                }
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
  • 相关阅读:
    公司实习职位与要求
    段子
    Python 练习项目1 弹球游戏
    精准控制PWM脉冲的频率和数量
    ST Link 调试问题总结
    验证
    大道至简(第六章)读后感
    动手动脑
    大道至简(第五i章)读后感
    数组课后作业
  • 原文地址:https://www.cnblogs.com/lt-style/p/3413501.html
Copyright © 2011-2022 走看看