Beispiel #1
0
        public ActionResult ModifyPackageCate()
        {
            if (!AppData.IsManagerLogin)
            {
                return(Json(new { success = false, msg = "您未登录后台或会话已过期" }));
            }
            if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 702))
            {
                return(Json(new { success = false, msg = "您没有执行该操作的权限" }));
            }

            Validation     validation     = new Validation();
            int            categoryID     = validation.GetInt("categoryID");
            PackageBLL     packageBLL     = new PackageBLL();
            PackageCateObj packageCateObj = packageBLL.GetPackageCate(categoryID);

            if (packageCateObj != null)
            {
                packageCateObj.CategoryName = validation.Get("categoryName", false, "分类名称不可为空!");
                packageCateObj.Sort         = validation.GetInt("sort");
                if (validation.HasError)
                {
                    return(Json(new { success = false, msg = validation.GetError() }));
                }
                packageBLL.ModifyPackageCate(packageCateObj);
                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { success = false, msg = "该类别不存在!" }));
            }
        }
Beispiel #2
0
        public ActionResult AddPackageCate()
        {
            if (!AppData.IsManagerLogin)
            {
                return(Json(new { success = false, msg = "您未登录后台或会话已过期" }));
            }
            if (PrivilegeBLL.HasNotPrivilege(AppData.SessionUserID, 701))
            {
                return(Json(new { success = false, msg = "您没有执行该操作的权限" }));
            }

            Validation vld = new Validation();

            PackageCateObj packageCateObj = new PackageCateObj();

            packageCateObj.CategoryName = vld.Get("categoryName", false, "类别名不可为空!");
            packageCateObj.Sort         = vld.GetInt("sort");
            packageCateObj.ParentID     = vld.GetInt("categoryID");

            if (vld.HasError)
            {
                return(Json(new { success = false, msg = vld.GetError() }));
            }

            PackageBLL packageBLL = new PackageBLL();

            packageBLL.AddPackageCate(packageCateObj);

            return(Json(new { success = true }));
        }
Beispiel #3
0
        public void ModifyPackageCate(PackageCateObj packageCateObj)
        {
            using (helper = new SqlHelper())
            {
                helper.AddIntParameter("@CategoryID", packageCateObj.CategoryID);
                helper.AddStringParameter("@CategoryName", 50, packageCateObj.CategoryName);
                helper.AddIntParameter("@ParentID", packageCateObj.ParentID);
                helper.AddIntParameter("@Sort", packageCateObj.Sort);

                helper.ExecuteNonQuery("update PackageCates set CategoryName=@CategoryName,ParentID=@ParentID,Sort=@Sort where CategoryID=@CategoryID", CommandType.Text);
            }
        }
Beispiel #4
0
        public void AddPackageCate(PackageCateObj packageCateObj)
        {
            using (helper = new SqlHelper())
            {
                helper.AddStringParameter("@CategoryName", 50, packageCateObj.CategoryName);
                helper.AddIntParameter("@ParentID", packageCateObj.ParentID);
                helper.AddIntParameter("@Sort", packageCateObj.Sort);

                packageCateObj.CategoryID = helper.GetIntValue("select Max(CategoryID) from PackageCates", CommandType.Text) + 1;
                helper.AddIntParameter("@CategoryID", packageCateObj.CategoryID);

                helper.ExecuteNonQuery("insert into PackageCates (CategoryID,CategoryName,ParentID,Sort) values (@CategoryID,@CategoryName,@ParentID,@Sort)", CommandType.Text);
            }
        }
Beispiel #5
0
        public PackageCateObj GetPackageCate(int categoryID)
        {
            using (SqlHelper helper = new SqlHelper())
            {
                helper.AddIntParameter("@CategoryID", categoryID);
                using (SqlDataReader dr = helper.ExecuteReader("select CategoryName,ParentID,Sort from PackageCates where CategoryID=@CategoryID", CommandType.Text))
                {
                    if (dr.HasRows && dr.Read())
                    {
                        PackageCateObj cateObj = new PackageCateObj();
                        cateObj.CategoryID   = categoryID;
                        cateObj.CategoryName = (string)dr[0];
                        cateObj.ParentID     = (int)dr[1];
                        cateObj.Sort         = dr[2] == DBNull.Value ? 0 : (int)dr[2];

                        return(cateObj);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Beispiel #6
0
 public void ModifyPackageCate(PackageCateObj packageCateObj)
 {
     dal.ModifyPackageCate(packageCateObj);
 }
Beispiel #7
0
 public void AddPackageCate(PackageCateObj packageCateObj)
 {
     dal.AddPackageCate(packageCateObj);
 }