Example #1
0
        public bool UpdateLastTime(int userId)
        {
            var strSql = new StringBuilder();

            strSql.Append("update T_Users set ");
            strSql.Append("LastTime=NowTime,");
            strSql.Append("NowTime=@NowTime");
            strSql.Append(" where UserId=@UserId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NowTime", SqlDbType.DateTime),
                new SqlParameter("@UserId",  SqlDbType.Int, 4)
            };
            parameters[0].Value = DateTime.Now;
            parameters[1].Value = userId;
            var rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public bool UpdateStatus(int userId, byte status)
        {
            var strSql = new StringBuilder();

            strSql.Append("update T_Users set ");
            strSql.Append("Status=@Status");
            strSql.Append(" where UserId=@UserId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Status", SqlDbType.TinyInt, 1),
                new SqlParameter("@UserId", SqlDbType.Int, 4)
            };
            parameters[0].Value = status;
            parameters[1].Value = userId;

            var rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// 更改用户密码
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="pwd">新密码</param>
        /// <returns></returns>
        public bool ChangePassword(int userId, string pwd)
        {
            var strSql = new StringBuilder();

            strSql.Append("update T_Users set ");
            strSql.Append("Pwd=@Pwd");
            strSql.Append(" where UserId=@UserId");

            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId", SqlDbType.Int,      4),
                new SqlParameter("@Pwd",    SqlDbType.NVarChar, 32)
            };
            parameters[0].Value = userId;
            parameters[1].Value = pwd;

            if (DbHelperSql.ExecuteSql(strSql.ToString(), parameters) >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.Users model)
        {
            var strSql = new StringBuilder();

            strSql.Append("update T_Users set ");
            strSql.Append("UserName=@UserName,");
            strSql.Append("Pwd=@Pwd,");
            strSql.Append("Mobile=@Mobile,");
            strSql.Append("Email=@Email,");
            strSql.Append("Status=@Status,");
            strSql.Append("RegTime=@RegTime,");
            strSql.Append("RoleId=@RoleId,");
            strSql.Append("LastTime=@LastTime,");
            strSql.Append("NowTime=@NowTime,");
            strSql.Append("ReMark=@ReMark");
            strSql.Append(" where UserId=@UserId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserName", SqlDbType.NVarChar,   50),
                new SqlParameter("@Pwd",      SqlDbType.NVarChar,   32),
                new SqlParameter("@Mobile",   SqlDbType.NVarChar,   20),
                new SqlParameter("@Email",    SqlDbType.NVarChar,  128),
                new SqlParameter("@Status",   SqlDbType.TinyInt,     1),
                new SqlParameter("@RegTime",  SqlDbType.DateTime),
                new SqlParameter("@RoleId",   SqlDbType.Int,         4),
                new SqlParameter("@LastTime", SqlDbType.DateTime),
                new SqlParameter("@NowTime",  SqlDbType.DateTime),
                new SqlParameter("@ReMark",   SqlDbType.NVarChar,   50),
                new SqlParameter("@UserId",   SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.UserName;
            parameters[1].Value  = model.Pwd;
            parameters[2].Value  = model.Mobile;
            parameters[3].Value  = model.Email;
            parameters[4].Value  = model.Status;
            parameters[5].Value  = model.RegTime;
            parameters[6].Value  = model.RoleId;
            parameters[7].Value  = model.LastTime;
            parameters[8].Value  = model.NowTime;
            parameters[9].Value  = model.ReMark;
            parameters[10].Value = model.UserId;

            var rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string idlist)
        {
            var strSql = new StringBuilder();

            strSql.Append("delete from T_ESHour ");
            strSql.Append(" where Id in (" + idlist + ")  ");
            var rows = DbHelperSql.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #6
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int userId)
        {
            var strSql = new StringBuilder();

            strSql.Append("delete from T_Users ");
            strSql.Append(" where UserId=@UserId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserId", SqlDbType.Int, 4)
            };
            parameters[0].Value = userId;

            var rows = DbHelperSql.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }