コード例 #1
0
        public void UpdateTypeCategory1(int _id, string _ct)
        {
            //验证是否登陆
            IsLogin();

            //获取当前登陆用户的session
            int _loginId = (Session["ULogin"] as ULogin).ULogin_Id;

            //是否获取到要操作的类别编号
            if (_id != 0)
            {
                if (DTO_Category.IsContains(_loginId, _id, _ct))
                {
                    int count = DTO_Category.UpdateCategory(new Category()
                    {
                        Category_Id = _id, Category_Type = _ct
                    });

                    if (count > 0)
                    {
                        //返回类别名称修改成功
                        Response.Write(JsonConvert.SerializeObject(new DTO_Result()
                        {
                            Result_Code = "000000", Result_Title = "修改成功"
                        }));
                    }
                    else
                    {
                        //返回自定义类别修改失败
                        Response.Write(JsonConvert.SerializeObject(new DTO_Result()
                        {
                            Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "修改失败"
                        }));
                    }
                }
                else
                {
                    Response.Write(JsonConvert.SerializeObject(new DTO_Result()
                    {
                        Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "\"" + _ct + "\"已存在,修改失败"
                    }));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 名称:添加个人类别
        /// 时间:18-1-19
        /// 作者:
        /// </summary>
        /// <param name="_ct"></param>
        public void AddCategory1(string _ct)
        {
            IsLogin();
            //获取当前登陆用户的session
            int _loginId = (Session["ULogin"] as ULogin).ULogin_Id;

            if (DTO_Category.IsContains(_loginId, _ct))
            {
                //创建要添加的数据
                Category _ca = new Category()
                {
                    Category_Type = _ct, Category_Reception = 0, ULogin_Id = _loginId
                };

                int _saveval = DTO_Category.AddCategory(_ca);

                if (_saveval > 0)
                {
                    //返回类别添加成功,返回码000000
                    Response.Write(JsonConvert.SerializeObject(new DTO_Result()
                    {
                        Result_Code = "000000", Result_Title = "添加成功", value = _saveval.ToString()
                    }));
                }
                else
                {
                    //返回类别添加失败
                    Response.Write(JsonConvert.SerializeObject(new DTO_Result()
                    {
                        Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "添加失败"
                    }));
                }
            }
            else
            {
                //返回类别已存在提示
                Response.Write(JsonConvert.SerializeObject(new DTO_Result()
                {
                    Result_Code = new Random().Next(100000, 999999).ToString(), Result_Title = "‘" + _ct + "’已存在"
                }));
            }
        }