示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LearnSite.Model.TopicReply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TopicReply(");
            strSql.Append("Rtid,Rsnum,Rwords,Rtime,Rip,Rscore,Rban,Rgrade,Rterm,Rcid,Rclass,Rsid,Ryear,Redit,Ragree)");
            strSql.Append(" values (");
            strSql.Append("@Rtid,@Rsnum,@Rwords,@Rtime,@Rip,@Rscore,@Rban,@Rgrade,@Rterm,@Rcid,@Rclass,@Rsid,@Ryear,@Redit,@Ragree)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Rtid",   SqlDbType.Int,        4),
                new SqlParameter("@Rsnum",  SqlDbType.NVarChar,  50),
                new SqlParameter("@Rwords", SqlDbType.NText),
                new SqlParameter("@Rtime",  SqlDbType.DateTime),
                new SqlParameter("@Rip",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Rscore", SqlDbType.Int,        4),
                new SqlParameter("@Rban",   SqlDbType.Bit,        1),
                new SqlParameter("@Rgrade", SqlDbType.Int,        4),
                new SqlParameter("@Rterm",  SqlDbType.Int,        4),
                new SqlParameter("@Rcid",   SqlDbType.Int,        4),
                new SqlParameter("@Rclass", SqlDbType.Int,        4),
                new SqlParameter("@Rsid",   SqlDbType.Int,        4),
                new SqlParameter("@Ryear",  SqlDbType.Int,        4),
                new SqlParameter("@Redit",  SqlDbType.Int,        4),
                new SqlParameter("@Ragree", SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.Rtid;
            parameters[1].Value  = model.Rsnum;
            parameters[2].Value  = model.Rwords;
            parameters[3].Value  = model.Rtime;
            parameters[4].Value  = model.Rip;
            parameters[5].Value  = model.Rscore;
            parameters[6].Value  = model.Rban;
            parameters[7].Value  = model.Rgrade;
            parameters[8].Value  = model.Rterm;
            parameters[9].Value  = model.Rcid;
            parameters[10].Value = model.Rclass;
            parameters[11].Value = model.Rsid;
            parameters[12].Value = model.Ryear;
            parameters[13].Value = model.Redit;
            parameters[14].Value = model.Ragree;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LearnSite.Model.TopicReply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TopicReply set ");
            strSql.Append("Rtid=@Rtid,");
            strSql.Append("Rsnum=@Rsnum,");
            strSql.Append("Rwords=@Rwords,");
            strSql.Append("Rtime=@Rtime,");
            strSql.Append("Rip=@Rip,");
            strSql.Append("Rscore=@Rscore,");
            strSql.Append("Rban=@Rban,");
            strSql.Append("Rgrade=@Rgrade,");
            strSql.Append("Rterm=@Rterm");
            strSql.Append(" where Rid=@Rid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Rtid",   SqlDbType.Int,        4),
                new SqlParameter("@Rsnum",  SqlDbType.NVarChar,  50),
                new SqlParameter("@Rwords", SqlDbType.NText),
                new SqlParameter("@Rtime",  SqlDbType.DateTime),
                new SqlParameter("@Rip",    SqlDbType.NVarChar,  50),
                new SqlParameter("@Rscore", SqlDbType.Int,        4),
                new SqlParameter("@Rban",   SqlDbType.Bit,        1),
                new SqlParameter("@Rgrade", SqlDbType.Int,        4),
                new SqlParameter("@Rterm",  SqlDbType.Int,        4),
                new SqlParameter("@Rid",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Rtid;
            parameters[1].Value = model.Rsnum;
            parameters[2].Value = model.Rwords;
            parameters[3].Value = model.Rtime;
            parameters[4].Value = model.Rip;
            parameters[5].Value = model.Rscore;
            parameters[6].Value = model.Rban;
            parameters[7].Value = model.Rgrade;
            parameters[8].Value = model.Rterm;
            parameters[9].Value = model.Rid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        ///Rid 更新一条数据 Rwords Rtime Redit Ragree
        ///rtid, rsid
        /// </summary>
        public bool UpdateOne(LearnSite.Model.TopicReply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TopicReply set ");
            strSql.Append("Rwords=@Rwords,");
            strSql.Append("Rtime=@Rtime,");
            strSql.Append("Redit=@Redit,");
            strSql.Append("Ragree=@Ragree");
            strSql.Append(" where Rtid=@Rtid and Rsid=@Rsid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Rwords", SqlDbType.NText),
                new SqlParameter("@Rtime",  SqlDbType.DateTime),
                new SqlParameter("@Redit",  SqlDbType.Bit,       1),
                new SqlParameter("@Ragree", SqlDbType.Int,       4),
                new SqlParameter("@Rtid",   SqlDbType.Int,       4),
                new SqlParameter("@Rsid",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Rwords;
            parameters[1].Value = model.Rtime;
            parameters[2].Value = model.Redit;
            parameters[3].Value = model.Ragree;
            parameters[4].Value = model.Rtid;
            parameters[5].Value = model.Rsid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LearnSite.Model.TopicReply GetModel(int Rid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" Rid,Rtid,Rsnum,Rwords,Rtime,Rip,Rscore,Rban,Rgrade,Rterm,Rcid,Rclass ");
            strSql.Append(" from TopicReply ");
            strSql.Append(" where Rid=" + Rid + "");
            LearnSite.Model.TopicReply model = new LearnSite.Model.TopicReply();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Rid"].ToString() != "")
                {
                    model.Rid = int.Parse(ds.Tables[0].Rows[0]["Rid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Rtid"].ToString() != "")
                {
                    model.Rtid = int.Parse(ds.Tables[0].Rows[0]["Rtid"].ToString());
                }
                model.Rsnum  = ds.Tables[0].Rows[0]["Rsnum"].ToString();
                model.Rwords = ds.Tables[0].Rows[0]["Rwords"].ToString();
                if (ds.Tables[0].Rows[0]["Rtime"].ToString() != "")
                {
                    model.Rtime = DateTime.Parse(ds.Tables[0].Rows[0]["Rtime"].ToString());
                }
                model.Rip = ds.Tables[0].Rows[0]["Rip"].ToString();
                if (ds.Tables[0].Rows[0]["Rscore"].ToString() != "")
                {
                    model.Rscore = int.Parse(ds.Tables[0].Rows[0]["Rscore"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Rban"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Rban"].ToString() == "1") || (ds.Tables[0].Rows[0]["Rban"].ToString().ToLower() == "true"))
                    {
                        model.Rban = true;
                    }
                    else
                    {
                        model.Rban = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Rgrade"].ToString() != "")
                {
                    model.Rgrade = int.Parse(ds.Tables[0].Rows[0]["Rgrade"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Rterm"].ToString() != "")
                {
                    model.Rterm = int.Parse(ds.Tables[0].Rows[0]["Rterm"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Rcid"].ToString() != "")
                {
                    model.Rcid = int.Parse(ds.Tables[0].Rows[0]["Rcid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Rclass"].ToString() != "")
                {
                    model.Rclass = int.Parse(ds.Tables[0].Rows[0]["Rclass"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }