Beispiel #1
0
        private int addcata(long cid, string title, int parentid)
        {
            int calssid = 0;
            int classLayer = 1;                                         //栏目深度
            string classList = "";



            int sort = new Spread.BLL.Catalog().GetMaxSortID(parentid);

            Spread.BLL.Catalog bll = new Spread.BLL.Catalog();

            Spread.Model.Catalog model = new Spread.Model.Catalog();
            model.CatalogID = cid;
            model.Title = title;
            model.ParentId = parentid;
            model.ClassList = "";
            model.ClassOrder = sort;
            model.IsShow = true;
            model.IsLock = false;
            model.IsMenu = false;


            //添加栏目
            calssid = bll.Add(model);
            //修改栏目的下属栏目ID列表
            if (parentid > 0)
            {
                DataSet ds = bll.GetCatalogListByClassId(parentid);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    classList = dr["ClassList"].ToString().Trim() + calssid + ",";
                    classLayer = Convert.ToInt32(dr["ClassLayer"]) + 1;
                }
            }
            else
            {
                classList = "," + calssid + ",";
                classLayer = 1;
            }
            model.Id = calssid;
            model.ClassList = classList;
            model.ClassLayer = classLayer;
            new Spread.BLL.Catalog().Update(model);

            return calssid;
        }
Beispiel #2
0
 public int classId;    //ID
 protected void Page_Load(object sender, EventArgs e)
 {
     chkLoginLevel("editCatalog");
     //取得栏目传参
     if ( int.TryParse(Request.Params["classId"], out classId))
     {
         model = bll.GetModel(classId);
         if (!Page.IsPostBack)
         {
             ShowInfo();
         }
     }
     else
     {
         JscriptMsg(350, 230, "错误提示", "<b>出现错误啦!</b>您要修改类别的编号不明确或参数不正确。", "back", "Error");
     }
 }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Spread.Model.Catalog GetModel(int Id)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,CatalogID,Title,ParentId,ClassList,ClassLayer,ClassOrder,IsShow,IsLock,IsMenu from [Catalog] ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)};
            parameters[0].Value = Id;

            Spread.Model.Catalog model = new Spread.Model.Catalog();
            DataSet ds = DbHelper.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CatalogID"].ToString() != "")
                {
                    model.CatalogID = long.Parse(ds.Tables[0].Rows[0]["CatalogID"].ToString());
                }
                model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                if (ds.Tables[0].Rows[0]["ParentId"].ToString() != "")
                {
                    model.ParentId = int.Parse(ds.Tables[0].Rows[0]["ParentId"].ToString());
                }
                model.ClassList = ds.Tables[0].Rows[0]["ClassList"].ToString();
                if (ds.Tables[0].Rows[0]["ClassLayer"].ToString() != "")
                {
                    model.ClassLayer = int.Parse(ds.Tables[0].Rows[0]["ClassLayer"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ClassOrder"].ToString() != "")
                {
                    model.ClassOrder = int.Parse(ds.Tables[0].Rows[0]["ClassOrder"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsShow"].ToString() != "")
                {
                    model.IsShow = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsShow"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsLock"].ToString() != "")
                {
                    model.IsLock = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsLock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsMenu"].ToString() != "")
                {
                    model.IsMenu = Convert.ToBoolean(ds.Tables[0].Rows[0]["IsMenu"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }