Example #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.GroupUsers GetModel(int GroupId, int UserId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 GroupId,UserId from GroupUsers ");
            strSql.Append(" where GroupId=@GroupId and UserId=@UserId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GroupId", SqlDbType.Int, 4),
                new SqlParameter("@UserId",  SqlDbType.Int, 4)
            };
            parameters[0].Value = GroupId;
            parameters[1].Value = UserId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["GroupId"].ToString() != "")
                {
                    model.GroupId = int.Parse(ds.Tables[0].Rows[0]["GroupId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(LPWeb.Model.GroupUsers model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update GroupUsers set ");
            strSql.Append("GroupId=@GroupId,");
            strSql.Append("UserId=@UserId");
            strSql.Append(" where GroupId=@GroupId and UserId=@UserId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GroupId", SqlDbType.Int, 4),
                new SqlParameter("@UserId",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.GroupId;
            parameters[1].Value = model.UserId;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(LPWeb.Model.GroupUsers model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into GroupUsers(");
            strSql.Append("GroupId,UserId)");
            strSql.Append(" values (");
            strSql.Append("@GroupId,@UserId)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GroupId", SqlDbType.Int, 4),
                new SqlParameter("@UserId",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.GroupId;
            parameters[1].Value = model.UserId;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }