Esempio n. 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Maticsoft.Model.CMS_Column> DataTableToList(DataTable dt)
        {
            List <Maticsoft.Model.CMS_Column> modelList = new List <Maticsoft.Model.CMS_Column>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Maticsoft.Model.CMS_Column model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Maticsoft.Model.CMS_Column();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    model.Title = dt.Rows[n]["Title"].ToString();
                    if (dt.Rows[n]["ParentId"].ToString() != "")
                    {
                        model.ParentId = int.Parse(dt.Rows[n]["ParentId"].ToString());
                    }
                    model.Code    = dt.Rows[n]["Code"].ToString();
                    model.GotoUrl = dt.Rows[n]["GotoUrl"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Esempio n. 2
0
        public string SearchColumnName(int Id) //生成静态页的时候用 CreateHtml
        {
            CMS_Column col = new CMS_Column();

            col = CMS_Column.GetModel(Id);
            return(col.Title);
        }
Esempio n. 3
0
        //自编方法
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static CMS_Column GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id,Title,ParentId,Code,GotoUrl,IsNavigator ");
            strSql.Append(" FROM CMS_Column ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;
            CMS_Column model = new CMS_Column();
            DataSet    ds    = DbHelperSQL.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());
                }
                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());
                }
                if (ds.Tables[0].Rows[0]["GotoUrl"].ToString() != "")
                {
                    model.GotoUrl = ds.Tables[0].Rows[0]["GotoUrl"].ToString();
                }
                model.Code        = ds.Tables[0].Rows[0]["Code"].ToString();
                model.IsNavigator = int.Parse(ds.Tables[0].Rows[0]["IsNavigator"].ToString());
            }
            return(model);
        }
Esempio n. 4
0
        /// <summary>
        /// 新Code
        /// </summary>
        /// <returns></returns>
        public string NewCode()
        {
            object tmp     = DbHelperSQL.GetSingle("Select top 1 Code from CMS_Column where ParentId=" + ParentId + " order by Code desc");
            string newCode = "";

            if (tmp == null)
            {
                newCode = "0001";
            }
            else
            {
                string maxCode = tmp.ToString();
                maxCode = maxCode.Substring(maxCode.Length - 4);
                int intcode = int.Parse(maxCode) + 1;
                newCode = intcode.ToString().PadLeft(4, '0');
            }

            if (ParentId == 0)
            {
                return(newCode);
            }
            else
            {
                CMS_Column parent = GetModel(ParentId);
                return(parent.Code + newCode);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Maticsoft.Model.CMS_Column model)
 {
     return(dal.Update(model));
 }
Esempio n. 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Maticsoft.Model.CMS_Column model)
 {
     return(dal.Add(model));
 }
Esempio n. 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Maticsoft.Model.CMS_Column model, bool ChangeParent, int oldParentId)
 {
     return(dal.Update(model, ChangeParent, oldParentId));
 }