Beispiel #1
0
        public int UserLogin(string username, string password)
        {
            string sqlStr = "select count(*) from Users where UserName = @username and Password = @password";

            SqlParameter[] sqlParam =
            {
                new SqlParameter("@username", SqlDbType.NVarChar, 20),
                new SqlParameter("@password", SqlDbType.NVarChar, 50)
            };
            sqlParam[0].Value = username;
            sqlParam[1].Value = EncryptUtil.CreateSHA256HashString(password);

            object result = SqlHelper.ExcuteScalar(CommandType.Text, sqlStr, sqlParam);
            int    i      = Convert.ToInt32(result);

            return(i);
        }
Beispiel #2
0
        public void CreateUser(string username, string nickname, string password, string mail)
        {
            string sqlStr = "INSERT INTO Users(UserName,NickName,Password,Email,CreateDate,UpdateDate) VALUES (@Username,@Nickname,@Password,@Email,@CreateDate,@UpdateDate)";

            SqlParameter[] sqlParam =
            {
                new SqlParameter("@Username",   SqlDbType.NVarChar,  20),
                new SqlParameter("@Nickname",   SqlDbType.NVarChar,  20),
                new SqlParameter("@Password",   SqlDbType.NVarChar,  50),
                new SqlParameter("@Email",      SqlDbType.NVarChar,  20),
                new SqlParameter("@CreateDate", SqlDbType.DateTime),
                new SqlParameter("@UpdateDate", SqlDbType.DateTime)
            };
            sqlParam[0].Value = username;
            sqlParam[1].Value = nickname;
            sqlParam[2].Value = EncryptUtil.CreateSHA256HashString(password);
            sqlParam[3].Value = mail;
            sqlParam[4].Value = DateTime.Now;
            sqlParam[5].Value = DateTime.Now;

            SqlHelper.ExcuteNonQuery(CommandType.Text, sqlStr, sqlParam);
        }