Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(HYTCWeiBo.Model.FansMarks model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update FansMarks set ");

            strSql.Append(" markId = @markId , ");
            strSql.Append(" onselfName = @onselfName , ");
            strSql.Append(" otherName = @otherName , ");
            strSql.Append(" createTime = @createTime  ");
            strSql.Append(" where markId=@markId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@markId",     SqlDbType.Int,      4),
                new SqlParameter("@onselfName", SqlDbType.VarChar, 20),
                new SqlParameter("@otherName",  SqlDbType.VarChar, 20),
                new SqlParameter("@createTime", SqlDbType.DateTime)
            };

            parameters[0].Value = model.markId;
            parameters[1].Value = model.onselfName;
            parameters[2].Value = model.otherName;
            parameters[3].Value = model.createTime;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HYTCWeiBo.Model.FansMarks GetModel(int markId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select markId, onselfName, otherName, createTime  ");
            strSql.Append("  from FansMarks ");
            strSql.Append(" where markId=@markId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@markId", SqlDbType.Int, 4)
            };
            parameters[0].Value = markId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["markId"].ToString() != "")
                {
                    model.markId = int.Parse(ds.Tables[0].Rows[0]["markId"].ToString());
                }
                model.onselfName = ds.Tables[0].Rows[0]["onselfName"].ToString();
                model.otherName  = ds.Tables[0].Rows[0]["otherName"].ToString();
                if (ds.Tables[0].Rows[0]["createTime"].ToString() != "")
                {
                    model.createTime = DateTime.Parse(ds.Tables[0].Rows[0]["createTime"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(HYTCWeiBo.Model.FansMarks model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into FansMarks(");
            strSql.Append("markId,onselfName,otherName,createTime");
            strSql.Append(") values (");
            strSql.Append("@markId,@onselfName,@otherName,@createTime");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@markId",     SqlDbType.Int,      4),
                new SqlParameter("@onselfName", SqlDbType.VarChar, 20),
                new SqlParameter("@otherName",  SqlDbType.VarChar, 20),
                new SqlParameter("@createTime", SqlDbType.DateTime)
            };

            parameters[0].Value = model.markId;
            parameters[1].Value = model.onselfName;
            parameters[2].Value = model.otherName;
            parameters[3].Value = model.createTime;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HYTCWeiBo.Model.FansMarks GetModel(int markId)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select markId, onselfName, otherName, createTime  ");
            strSql.Append("  from FansMarks ");
            strSql.Append(" where markId=@markId ");
                        SqlParameter[] parameters = {
                    new SqlParameter("@markId", SqlDbType.Int,4)			};
            parameters[0].Value = markId;

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

            if(ds.Tables[0].Rows.Count>0)
            {
                                                if(ds.Tables[0].Rows[0]["markId"].ToString()!="")
                {
                    model.markId=int.Parse(ds.Tables[0].Rows[0]["markId"].ToString());
                }
                                                                                                                                                model.onselfName= ds.Tables[0].Rows[0]["onselfName"].ToString();
                                                                                                                                model.otherName= ds.Tables[0].Rows[0]["otherName"].ToString();
                                                                                                                if(ds.Tables[0].Rows[0]["createTime"].ToString()!="")
                {
                    model.createTime=DateTime.Parse(ds.Tables[0].Rows[0]["createTime"].ToString());
                }

                return model;
            }
            else
            {
                return null;
            }
        }