Example #1
0
        protected string EditChannel(HttpContext context)
        {
            string result = string.Empty;

            int    Id       = Convert.ToInt32(Common.CommFun.GetParams("Id") ?? "0");
            int    ParentId = Convert.ToInt32(Common.CommFun.GetParams("ParentId") ?? "0");
            string Title    = Common.CommFun.GetParams("Title");
            string SubTitle = Common.CommFun.GetParams("SubTitle") ?? "";
            string EnTitle  = Common.CommFun.GetParams("EnTitle") ?? "";
            string AddTime  = Common.CommFun.GetParams("AddTime") ?? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            int    SortId   = Convert.ToInt32(Common.CommFun.GetParams("SortId") ?? "100");
            int    States   = Convert.ToInt32(Common.CommFun.GetParams("States") ?? "0");
            string WebPath  = Common.CommFun.GetParams("WebPath") ?? "";

            //获取要编辑的栏目实体
            var Model = new DAL.ChannelServices().SelectChannelById(Id);

            try
            {
                if (Model != null)
                {
                    Model.ParentId = ParentId;
                    Model.Title    = Title;
                    Model.SubTitle = SubTitle;
                    Model.EnTitle  = EnTitle;
                    Model.AddTime  = DateTime.Parse(AddTime);
                    Model.SortId   = SortId;
                    Model.States   = States;
                    Model.WebPath  = WebPath;

                    if (new DAL.ChannelServices().UpdateChannel(Model))
                    {
                        result = new JavaScriptSerializer().Serialize(new { Status = 1, msg = "更新成功" });
                    }
                    else
                    {
                        result = new JavaScriptSerializer().Serialize(new { Status = 0, msg = "更新失败" });
                    }
                }
                else
                {
                    result = new JavaScriptSerializer().Serialize(new { Status = -2, msg = "该栏目不存在" });
                }
            }
            catch (Exception)
            {
                result = new JavaScriptSerializer().Serialize(new { Status = -1, msg = "操作异常,请稍后重试" });
                throw;
            }

            return(result);
        }
Example #2
0
        protected string DownChannelSortId(HttpContext context)
        {
            string result = string.Empty;

            int Id       = Convert.ToInt32(Common.CommFun.GetParams("Id") ?? "0");
            int ParentId = Convert.ToInt32(Common.CommFun.GetParams("ParentId") ?? "0");
            int SortId   = Convert.ToInt32(Common.CommFun.GetParams("SortId") ?? "0");

            //根据栏目Id查询Model实体类
            var Model = new DAL.ChannelServices().SelectChannelById(Id);

            try
            {
                if (Model != null)
                {
                    //栏目存在

                    if (new DAL.ChannelServices().IsBottomChannelSortId(Id, ParentId))
                    {
                        //已经是当前层级最靠后的栏目了
                        result = new JavaScriptSerializer().Serialize(new { Status = 0, msg = "已经是当前层级最靠后的栏目" });
                    }
                    else if (new DAL.ChannelServices().DownChannelSortId(Id, ParentId, SortId))
                    {
                        //下移成功
                        result = new JavaScriptSerializer().Serialize(new { Status = 1, msg = "下移成功" });
                    }
                    else
                    {
                        //下移失败
                        result = new JavaScriptSerializer().Serialize(new { Status = 0, msg = "下移失败" });
                    }
                }
                else
                {
                    //栏目不存在
                    result = new JavaScriptSerializer().Serialize(new { Status = -2, msg = "该栏目不存在" });
                }
            }
            catch (Exception)
            {
                result = new JavaScriptSerializer().Serialize(new { Status = -1, msg = "操作异常,请稍后重试" });
                throw;
            }

            return(result);
        }
Example #3
0
        public string CopyChannel(HttpContext context)
        {
            string result = string.Empty;

            int Id = Convert.ToInt32(Common.CommFun.GetParams("Id") ?? "0");

            //根据栏目Id查询Model实体类
            var Model = new DAL.ChannelServices().SelectChannelById(Id);

            try
            {
                if (Model != null)
                {
                    Channel NewModel = new Channel();
                    NewModel.ParentId = Model.ParentId;
                    NewModel.Title    = Model.Title;
                    NewModel.SubTitle = Model.SubTitle;
                    NewModel.EnTitle  = Model.EnTitle;
                    NewModel.AddTime  = DateTime.Now;
                    NewModel.SortId   = Model.SortId;
                    NewModel.States   = Model.States;
                    NewModel.WebPath  = Model.WebPath;

                    if (new DAL.ChannelServices().AddChannel(NewModel))
                    {
                        result = new JavaScriptSerializer().Serialize(new { Status = 1, msg = "复制成功" });
                    }
                    else
                    {
                        result = new JavaScriptSerializer().Serialize(new { Status = 0, msg = "复制失败" });
                    }
                }
                else
                {
                    //栏目不存在
                    result = new JavaScriptSerializer().Serialize(new { Status = -2, msg = "该栏目不存在" });
                }
            }
            catch (Exception)
            {
                result = new JavaScriptSerializer().Serialize(new { Status = -1, msg = "操作异常,请稍后重试" });
                throw;
            }

            return(result);
        }
Example #4
0
        protected string LockingChannel(HttpContext context)
        {
            string result = string.Empty;

            int Id     = Convert.ToInt32(Common.CommFun.GetParams("Id") ?? "0");
            int States = Convert.ToInt32(Common.CommFun.GetParams("States") ?? "0");

            //根据栏目Id查询Model实体类
            var Model = new DAL.ChannelServices().SelectChannelById(Id);

            try
            {
                if (Model != null)
                {
                    //栏目存在

                    //替换栏目状态
                    Model.States = States == 0 ? 1 : 0;
                    if (new DAL.ChannelServices().UpdateChannel(Model))
                    {
                        //锁定或解锁成功
                        result = new JavaScriptSerializer().Serialize(new { Status = 1, msg = Model.States == 0 ? "锁定成功" : "解锁成功" });
                    }
                    else
                    {
                        //锁定或解锁失败
                        result = new JavaScriptSerializer().Serialize(new { Status = 0, msg = Model.States == 0 ? "锁定失败" : "解锁失败" });
                    }
                }
                else
                {
                    //栏目不存在
                    result = new JavaScriptSerializer().Serialize(new { Status = -2, msg = "该栏目不存在" });
                }
            }
            catch (Exception)
            {
                result = new JavaScriptSerializer().Serialize(new { Status = -1, msg = "操作异常,请稍后重试" });
                throw;
            }

            return(result);
        }
Example #5
0
        public string DeleteChannel(HttpContext context)
        {
            string result = string.Empty;

            int Id = Convert.ToInt32(Common.CommFun.GetParams("Id") ?? "0");

            //根据栏目Id查询Model实体类
            var Model = new DAL.ChannelServices().SelectChannelById(Id);

            try
            {
                if (Model != null)
                {
                    //栏目存在则删除该栏目,注意这里是逻辑删除!!!即改变栏目状态States
                    Model.States = -1;
                    if (new DAL.ChannelServices().UpdateChannel(Model))
                    {
                        //删除成功
                        result = new JavaScriptSerializer().Serialize(new { Status = 1, msg = "删除成功" });
                    }
                    else
                    {
                        //删除失败
                        result = new JavaScriptSerializer().Serialize(new { Status = 0, msg = "删除失败" });
                    }
                }
                else
                {
                    //栏目不存在
                    result = new JavaScriptSerializer().Serialize(new { Status = -2, msg = "该栏目不存在" });
                }
            }
            catch (Exception)
            {
                result = new JavaScriptSerializer().Serialize(new { Status = -1, msg = "操作异常,请稍后重试" });
                throw;
            }

            return(result);
        }