Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Entity.BASE_EVENTWORD entity)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Base_EventWord(");
            strSql.Append("EventID,WordID");
            strSql.Append(") values (");
            strSql.Append("@EventID,@WordID");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EventID", SqlDbType.Int, 4),
                new SqlParameter("@WordID",  SqlDbType.Int, 4)
            };

            parameters[0].Value = entity.EventID;
            parameters[1].Value = entity.WordID;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Entity.BASE_EVENTWORD entity)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Base_EventWord set ");

            strSql.Append(" EventID = @EventID , ");
            strSql.Append(" WordID = @WordID  ");
            strSql.Append(" where EventWordID=@EventWordID ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@EventWordID", SqlDbType.Int, 4),
                new SqlParameter("@EventID",     SqlDbType.Int, 4),
                new SqlParameter("@WordID",      SqlDbType.Int, 4)
            };

            parameters[2].Value = entity.EventWordID;
            parameters[3].Value = entity.EventID;
            parameters[4].Value = entity.WordID;
            int rows = SqlServerHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Entity.BASE_EVENTWORD GetEntity(int EventWordID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select EventWordID, EventID, WordID  ");
            strSql.Append("  from Base_EventWord ");
            strSql.Append(" where EventWordID=@EventWordID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EventWordID", SqlDbType.Int, 4)
            };
            parameters[0].Value = EventWordID;


            Entity.BASE_EVENTWORD entity = new Entity.BASE_EVENTWORD();
            DataSet ds = SqlServerHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["EventWordID"].ToString() != "")
                {
                    entity.EventWordID = int.Parse(ds.Tables[0].Rows[0]["EventWordID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EventID"].ToString() != "")
                {
                    entity.EventID = int.Parse(ds.Tables[0].Rows[0]["EventID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WordID"].ToString() != "")
                {
                    entity.WordID = int.Parse(ds.Tables[0].Rows[0]["WordID"].ToString());
                }

                return(entity);
            }
            else
            {
                return(null);
            }
        }