예제 #1
0
        /// <summary>
        /// 修改密码
        /// </summary>
        public bool ModifyPwd(Model.Users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Users set ");
            strSql.Append("uPwd=@uPwd ");
            strSql.Append(" where uId=@uId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@uPwd", SqlDbType.Char, 32),
                new SqlParameter("@uId",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.uPwd;
            parameters[1].Value = model.uId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int EditUser(Model.Users model, int roleId)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@uName",        SqlDbType.NVarChar,  20),
                new SqlParameter("@uLoginName",   SqlDbType.NVarChar,  20),
                new SqlParameter("@Sex",          SqlDbType.Bit,        1),
                new SqlParameter("@Telephone",    SqlDbType.NVarChar,  11),
                new SqlParameter("@Email",        SqlDbType.NVarChar,  30),
                new SqlParameter("@Birthday",     SqlDbType.DateTime),
                new SqlParameter("@PowerLevelID", SqlDbType.Int,        4),
                new SqlParameter("@Department",   SqlDbType.NVarChar,  50),
                new SqlParameter("@RoleID",       SqlDbType.Int,        4),
                new SqlParameter("@uId",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.uName;
            parameters[1].Value = model.uLoginName;
            parameters[2].Value = model.Sex;
            parameters[3].Value = model.Telephone;
            parameters[4].Value = model.Email;
            parameters[5].Value = model.Birthday;
            parameters[6].Value = model.PowerLevelID;
            parameters[7].Value = model.Department;
            parameters[8].Value = roleId;
            parameters[9].Value = model.uId;
            int result = 0;

            return(DbHelperSQL.RunProcedure("ModifyUser", parameters, out result));
        }
예제 #3
0
파일: DBUser.cs 프로젝트: palasa/asp.net
        /// <summary>
        /// 更新用户实体
        /// </summary>
        /// <param name="model">用户实体,填充所有属性</param>
        /// <returns>受影响的行数</returns>
        public int Update(Model.Users model)
        {
            string SqlStr = string.Format("update users set [username]='{0}' , [password]='{1}' where [userid]='{2}'"
                                          , model.UserName
                                          , model.UserPwd
                                          , model.UserId);

            return(DBUtility.SQLDbHelper.ExecuteSql(SqlStr));
        }
예제 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int AddNewUser(Model.Users model, int roleId)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@uName",        SqlDbType.NVarChar,  20),
                new SqlParameter("@uLoginName",   SqlDbType.NVarChar,  20),
                new SqlParameter("@uPwd",         SqlDbType.Char,      32),
                new SqlParameter("@uAddtime",     SqlDbType.DateTime),
                new SqlParameter("@uIsDel",       SqlDbType.Bit,        1),
                new SqlParameter("@Sex",          SqlDbType.Bit,        1),
                new SqlParameter("@Telephone",    SqlDbType.NVarChar,  11),
                new SqlParameter("@Email",        SqlDbType.NVarChar,  30),
                new SqlParameter("@Birthday",     SqlDbType.DateTime),
                new SqlParameter("@AccountState", SqlDbType.TinyInt,    1),
                new SqlParameter("@PowerLevelID", SqlDbType.Int,        4),
                new SqlParameter("@Department",   SqlDbType.NVarChar,  50),
                new SqlParameter("@RoleID",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.uName;
            parameters[1].Value  = model.uLoginName;
            parameters[2].Value  = model.uPwd;
            parameters[3].Value  = model.uAddtime;
            parameters[4].Value  = model.uIsDel;
            parameters[5].Value  = model.Sex;
            parameters[6].Value  = model.Telephone;
            parameters[7].Value  = model.Email;
            parameters[8].Value  = model.Birthday;
            parameters[9].Value  = model.AccountState;
            parameters[10].Value = model.PowerLevelID;
            parameters[11].Value = model.Department;
            parameters[12].Value = roleId;
            int    result = 0;
            object obj    = DbHelperSQL.RunProcedure("AddNewUser", parameters, out result);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #5
0
        /// <summary>
        /// 满足用户名和用户密码查询
        /// </summary>
        /// <param name="model">填充用户名和用户密码</param>
        /// <returns>用户实体</returns>
        public Model.Users GetUserModelInfo(Model.Users model)
        {
            string SqlStr = string.Format("select * from [users] where [username]='{0}' and [userpwd]='{1}' ");

            using (SqlDataReader sr = DBUtility.SQLDbHelper.ExecuteReader(SqlStr))
            {
                if (sr.Read())
                {
                    return(new Model.Users()
                    {
                        UserId = sr.GetString(0),
                        UserName = sr.GetString(1),
                        UserPwd = sr.GetString(2)
                    });
                }
            }

            return(null);
        }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Users GetModel(int uId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 uId,uName,uLoginName,uPwd,uAddtime,uIsDel,Sex,Telephone,Email,Birthday,AccountState,PowerLevelID from Users ");
            strSql.Append(" where uId=@uId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@uId", SqlDbType.Int, 4)
            };
            parameters[0].Value = uId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.Users DataRowToModel(DataRow row)
 {
     Model.Users model = new Model.Users();
     if (row != null)
     {
         if (row["uId"] != null && row["uId"].ToString() != "")
         {
             model.uId = int.Parse(row["uId"].ToString());
         }
         if (row["uName"] != null)
         {
             model.uName = row["uName"].ToString();
         }
         if (row["uLoginName"] != null)
         {
             model.uLoginName = row["uLoginName"].ToString();
         }
         if (row["uPwd"] != null)
         {
             model.uPwd = row["uPwd"].ToString();
         }
         if (row["uAddtime"] != null && row["uAddtime"].ToString() != "")
         {
             model.uAddtime = DateTime.Parse(row["uAddtime"].ToString());
         }
         if (row["uIsDel"] != null && row["uIsDel"].ToString() != "")
         {
             if ((row["uIsDel"].ToString() == "1") || (row["uIsDel"].ToString().ToLower() == "true"))
             {
                 model.uIsDel = true;
             }
             else
             {
                 model.uIsDel = false;
             }
         }
         if (row["Sex"] != null && row["Sex"].ToString() != "")
         {
             if ((row["Sex"].ToString() == "1") || (row["Sex"].ToString().ToLower() == "true"))
             {
                 model.Sex = true;
             }
             else
             {
                 model.Sex = false;
             }
         }
         if (row["Telephone"] != null)
         {
             model.Telephone = row["Telephone"].ToString();
         }
         if (row["Email"] != null)
         {
             model.Email = row["Email"].ToString();
         }
         if (row["Birthday"] != null && row["Birthday"].ToString() != "")
         {
             model.Birthday = DateTime.Parse(row["Birthday"].ToString());
         }
         if (row["AccountState"] != null && row["AccountState"].ToString() != "")
         {
             model.AccountState = int.Parse(row["AccountState"].ToString());
         }
         if (row["PowerLevelID"] != null && row["PowerLevelID"].ToString() != "")
         {
             model.PowerLevelID = int.Parse(row["PowerLevelID"].ToString());
         }
     }
     return(model);
 }
예제 #8
0
파일: DBUser.cs 프로젝트: palasa/asp.net
 public int Add(Model.Users model)
 {
     throw new NotImplementedException();
 }