Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.MediaRelationship model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "MediaRelationship set ");

            strSql.Append(" MediaId = @MediaId , ");
            strSql.Append(" MediaRelationshipCategoryId = @MediaRelationshipCategoryId  ");
            strSql.Append(" where MediaCategoryRelationshipId=@MediaCategoryRelationshipId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@MediaCategoryRelationshipId", SqlDbType.Int, 4),
                new SqlParameter("@MediaId",                     SqlDbType.Int, 4),
                new SqlParameter("@MediaRelationshipCategoryId", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.MediaCategoryRelationshipId;
            parameters[1].Value = model.MediaId;
            parameters[2].Value = model.MediaRelationshipCategoryId;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DTcms.Model.MediaRelationship model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "MediaRelationship(");
            strSql.Append("MediaId,MediaRelationshipCategoryId");
            strSql.Append(") values (");
            strSql.Append("@MediaId,@MediaRelationshipCategoryId");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MediaId",                     SqlDbType.Int, 4),
                new SqlParameter("@MediaRelationshipCategoryId", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.MediaId;
            parameters[1].Value = model.MediaRelationshipCategoryId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <DTcms.Model.MediaRelationship> DataTableToList(DataTable dt)
        {
            List <DTcms.Model.MediaRelationship> modelList = new List <DTcms.Model.MediaRelationship>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                DTcms.Model.MediaRelationship model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new DTcms.Model.MediaRelationship();

                    if (dt.Rows[n]["MediaCategoryRelationshipId"].ToString() != "")
                    {
                        model.MediaCategoryRelationshipId = int.Parse(dt.Rows[n]["MediaCategoryRelationshipId"].ToString());
                    }

                    if (dt.Rows[n]["MediaId"].ToString() != "")
                    {
                        model.MediaId = int.Parse(dt.Rows[n]["MediaId"].ToString());
                    }

                    if (dt.Rows[n]["MediaRelationshipCategoryId"].ToString() != "")
                    {
                        model.MediaRelationshipCategoryId = int.Parse(dt.Rows[n]["MediaRelationshipCategoryId"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DTcms.Model.MediaRelationship GetModel(int MediaCategoryRelationshipId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select MediaCategoryRelationshipId, MediaId, MediaRelationshipCategoryId  ");
            strSql.Append("  from " + databaseprefix + "MediaRelationship ");
            strSql.Append(" where MediaCategoryRelationshipId=@MediaCategoryRelationshipId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MediaCategoryRelationshipId", SqlDbType.Int, 4)
            };
            parameters[0].Value = MediaCategoryRelationshipId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["MediaCategoryRelationshipId"].ToString() != "")
                {
                    model.MediaCategoryRelationshipId = int.Parse(ds.Tables[0].Rows[0]["MediaCategoryRelationshipId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MediaId"].ToString() != "")
                {
                    model.MediaId = int.Parse(ds.Tables[0].Rows[0]["MediaId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MediaRelationshipCategoryId"].ToString() != "")
                {
                    model.MediaRelationshipCategoryId = int.Parse(ds.Tables[0].Rows[0]["MediaRelationshipCategoryId"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(DTcms.Model.MediaRelationship model)
 {
     return(dal.Update(model));
 }
Exemple #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(DTcms.Model.MediaRelationship model)
 {
     return(dal.Add(model));
 }