예제 #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.VideoCategory DataRowToModel(DataRow row)
 {
     Maticsoft.Model.VideoCategory model = new Maticsoft.Model.VideoCategory();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["GUID"] != null)
         {
             model.GUID = row["GUID"].ToString();
         }
         if (row["VideoCategorGUID"] != null)
         {
             model.VideoCategorGUID = row["VideoCategorGUID"].ToString();
         }
         if (row["VideoCategorName"] != null)
         {
             model.VideoCategorName = row["VideoCategorName"].ToString();
         }
         if (row["VideoCategoryDescribe"] != null)
         {
             model.VideoCategoryDescribe = row["VideoCategoryDescribe"].ToString();
         }
         if (row["VideoCategoryOrder"] != null && row["VideoCategoryOrder"].ToString() != "")
         {
             model.VideoCategoryOrder = int.Parse(row["VideoCategoryOrder"].ToString());
         }
     }
     return(model);
 }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.VideoCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into VideoCategory(");
            strSql.Append("GUID,VideoCategorGUID,VideoCategorName,VideoCategoryDescribe,VideoCategoryOrder)");
            strSql.Append(" values (");
            strSql.Append("@GUID,@VideoCategorGUID,@VideoCategorName,@VideoCategoryDescribe,@VideoCategoryOrder)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GUID",                  SqlDbType.NVarChar, -1),
                new SqlParameter("@VideoCategorGUID",      SqlDbType.NVarChar, -1),
                new SqlParameter("@VideoCategorName",      SqlDbType.NVarChar, -1),
                new SqlParameter("@VideoCategoryDescribe", SqlDbType.NVarChar, -1),
                new SqlParameter("@VideoCategoryOrder",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.GUID;
            parameters[1].Value = model.VideoCategorGUID;
            parameters[2].Value = model.VideoCategorName;
            parameters[3].Value = model.VideoCategoryDescribe;
            parameters[4].Value = model.VideoCategoryOrder;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.VideoCategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update VideoCategory set ");
            strSql.Append("GUID=@GUID,");
            strSql.Append("VideoCategorGUID=@VideoCategorGUID,");
            strSql.Append("VideoCategorName=@VideoCategorName,");
            strSql.Append("VideoCategoryDescribe=@VideoCategoryDescribe,");
            strSql.Append("VideoCategoryOrder=@VideoCategoryOrder");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GUID",                  SqlDbType.NVarChar, -1),
                new SqlParameter("@VideoCategorGUID",      SqlDbType.NVarChar, -1),
                new SqlParameter("@VideoCategorName",      SqlDbType.NVarChar, -1),
                new SqlParameter("@VideoCategoryDescribe", SqlDbType.NVarChar, -1),
                new SqlParameter("@VideoCategoryOrder",    SqlDbType.Int,       4),
                new SqlParameter("@ID",                    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.GUID;
            parameters[1].Value = model.VideoCategorGUID;
            parameters[2].Value = model.VideoCategorName;
            parameters[3].Value = model.VideoCategoryDescribe;
            parameters[4].Value = model.VideoCategoryOrder;
            parameters[5].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.VideoCategory GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,GUID,VideoCategorGUID,VideoCategorName,VideoCategoryDescribe,VideoCategoryOrder from VideoCategory ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Maticsoft.Model.VideoCategory model = new Maticsoft.Model.VideoCategory();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }