示例#1
0
        protected string ViewTitle(int _kindId, int _parentId)
        {
            string str = "错误,暂无找到该信息标题!";

            switch (_kindId)
            {
            case (int)Channel.Article:
                DtCms.BLL.Article   abll   = new DtCms.BLL.Article();
                DtCms.Model.Article amodel = abll.GetModel(_parentId);
                if (amodel != null)
                {
                    str = amodel.Title;
                }
                break;

            case (int)Channel.Pictures:
                DtCms.BLL.Pictures   pbll   = new DtCms.BLL.Pictures();
                DtCms.Model.Pictures pmodel = pbll.GetModel(_parentId);
                if (pmodel != null)
                {
                    str = pmodel.Title;
                }
                break;

            case (int)Channel.Downloads:
                DtCms.BLL.Downloads   dbll   = new DtCms.BLL.Downloads();
                DtCms.Model.Downloads dmodel = dbll.GetModel(_parentId);
                if (dmodel != null)
                {
                    str = dmodel.Title;
                }
                break;
            }
            return(str);
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DtCms.Model.Downloads model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dt_Downloads(");
            strSql.Append("Title,ClassId,ImgUrl,FileType,FileSize,FilePath,Click,DownNum,Content,IsMsg,IsRed,IsLock,AddTime)");
            strSql.Append(" values (");
            strSql.Append("@Title,@ClassId,@ImgUrl,@FileType,@FileSize,@FilePath,@Click,@DownNum,@Content,@IsMsg,@IsRed,@IsLock,@AddTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",    SqlDbType.NVarChar, 100),
                new SqlParameter("@ClassId",  SqlDbType.Int,        4),
                new SqlParameter("@ImgUrl",   SqlDbType.NVarChar, 250),
                new SqlParameter("@FileType", SqlDbType.NVarChar,  30),
                new SqlParameter("@FileSize", SqlDbType.Int,        4),
                new SqlParameter("@FilePath", SqlDbType.NVarChar, 250),
                new SqlParameter("@Click",    SqlDbType.Int,        4),
                new SqlParameter("@DownNum",  SqlDbType.Int,        4),
                new SqlParameter("@Content",  SqlDbType.NText),
                new SqlParameter("@IsMsg",    SqlDbType.Int,        4),
                new SqlParameter("@IsRed",    SqlDbType.Int,        4),
                new SqlParameter("@IsLock",   SqlDbType.Int,        4),
                new SqlParameter("@AddTime",  SqlDbType.DateTime)
            };
            parameters[0].Value  = model.Title;
            parameters[1].Value  = model.ClassId;
            parameters[2].Value  = model.ImgUrl;
            parameters[3].Value  = model.FileType;
            parameters[4].Value  = model.FileSize;
            parameters[5].Value  = model.FilePath;
            parameters[6].Value  = model.Click;
            parameters[7].Value  = model.DownNum;
            parameters[8].Value  = model.Content;
            parameters[9].Value  = model.IsMsg;
            parameters[10].Value = model.IsRed;
            parameters[11].Value = model.IsLock;
            parameters[12].Value = model.AddTime;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DtCms.Model.Downloads GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Title,ClassId,ImgUrl,FileType,FileSize,FilePath,Click,DownNum,Content,IsMsg,IsRed,IsLock,AddTime from dt_Downloads ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            DtCms.Model.Downloads model = new DtCms.Model.Downloads();
            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]["ClassId"].ToString() != "")
                {
                    model.ClassId = int.Parse(ds.Tables[0].Rows[0]["ClassId"].ToString());
                }
                model.ImgUrl   = ds.Tables[0].Rows[0]["ImgUrl"].ToString();
                model.FileType = ds.Tables[0].Rows[0]["FileType"].ToString();
                if (ds.Tables[0].Rows[0]["FileSize"].ToString() != "")
                {
                    model.FileSize = int.Parse(ds.Tables[0].Rows[0]["FileSize"].ToString());
                }
                model.FilePath = ds.Tables[0].Rows[0]["FilePath"].ToString();
                if (ds.Tables[0].Rows[0]["Click"].ToString() != "")
                {
                    model.Click = int.Parse(ds.Tables[0].Rows[0]["Click"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DownNum"].ToString() != "")
                {
                    model.DownNum = int.Parse(ds.Tables[0].Rows[0]["DownNum"].ToString());
                }
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["IsMsg"].ToString() != "")
                {
                    model.IsMsg = int.Parse(ds.Tables[0].Rows[0]["IsMsg"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsRed"].ToString() != "")
                {
                    model.IsRed = int.Parse(ds.Tables[0].Rows[0]["IsRed"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsLock"].ToString() != "")
                {
                    model.IsLock = int.Parse(ds.Tables[0].Rows[0]["IsLock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
                {
                    model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DtCms.Model.Downloads model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dt_Downloads set ");
            strSql.Append("Title=@Title,");
            strSql.Append("ClassId=@ClassId,");
            strSql.Append("ImgUrl=@ImgUrl,");
            strSql.Append("FileType=@FileType,");
            strSql.Append("FileSize=@FileSize,");
            strSql.Append("FilePath=@FilePath,");
            strSql.Append("Click=@Click,");
            strSql.Append("DownNum=@DownNum,");
            strSql.Append("Content=@Content,");
            strSql.Append("IsMsg=@IsMsg,");
            strSql.Append("IsRed=@IsRed,");
            strSql.Append("IsLock=@IsLock,");
            strSql.Append("AddTime=@AddTime");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",       SqlDbType.Int,        4),
                new SqlParameter("@Title",    SqlDbType.NVarChar, 100),
                new SqlParameter("@ClassId",  SqlDbType.Int,        4),
                new SqlParameter("@ImgUrl",   SqlDbType.NVarChar, 250),
                new SqlParameter("@FileType", SqlDbType.NVarChar,  30),
                new SqlParameter("@FileSize", SqlDbType.Int,        4),
                new SqlParameter("@FilePath", SqlDbType.NVarChar, 250),
                new SqlParameter("@Click",    SqlDbType.Int,        4),
                new SqlParameter("@DownNum",  SqlDbType.Int,        4),
                new SqlParameter("@Content",  SqlDbType.NText),
                new SqlParameter("@IsMsg",    SqlDbType.Int,        4),
                new SqlParameter("@IsRed",    SqlDbType.Int,        4),
                new SqlParameter("@IsLock",   SqlDbType.Int,        4),
                new SqlParameter("@AddTime",  SqlDbType.DateTime)
            };
            parameters[0].Value  = model.Id;
            parameters[1].Value  = model.Title;
            parameters[2].Value  = model.ClassId;
            parameters[3].Value  = model.ImgUrl;
            parameters[4].Value  = model.FileType;
            parameters[5].Value  = model.FileSize;
            parameters[6].Value  = model.FilePath;
            parameters[7].Value  = model.Click;
            parameters[8].Value  = model.DownNum;
            parameters[9].Value  = model.Content;
            parameters[10].Value = model.IsMsg;
            parameters[11].Value = model.IsRed;
            parameters[12].Value = model.IsLock;
            parameters[13].Value = model.AddTime;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(DtCms.Model.Downloads model)
 {
     return(dal.Update(model));
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(DtCms.Model.Downloads model)
 {
     return(dal.Add(model));
 }