示例#1
0
        public bool Register(RegisterPackage package)
        {
            if (null != package.Phone && "" != package.Phone)
            {
                string sql_checkphone = "select * from " +
                                        DBStaticData.DataBaseUserTableName +
                                        " where " +
                                        DBStaticData.DataBaseUserTablePhoneField + " = '" + package.Phone + "'";
                if (ExecuteNonDataSet(sql_checkphone, out DataSet set))
                {
                    if (0 != set.Tables.Count)
                    {
                        if (0 != set.Tables[0].Rows.Count)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            string token = DBStaticMethod.GetToken();
            string sql   = string.Format
                           (
                "insert into {0} values ('{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', {8})",
                DBStaticData.DataBaseUserTableName,
                package.ID,
                DBStaticMethod.SHA256(package.Password, token),
                token,
                package.Name,
                package.Email,
                package.Phone,
                package.Describe,
                package.Photo.ToString()
                           );

            if (!ExecuteNonQuery(sql))
            {
                return(false);
            }
            return(true);
        }
示例#2
0
        public bool UpdatePassword(string email, string npw)
        {
            string token = DBStaticMethod.GetToken();
            string sql   = string.Format
                           (
                "update {0} set {1} = '{2}', {3} = '{4}' where {5} = '{6}'",
                DBStaticData.DataBaseUserTableName,
                DBStaticData.DataBaseUserTableTokenField,
                token,
                DBStaticData.DataBaseUserTablePasswordField,
                DBStaticMethod.SHA256(npw, token),
                DBStaticData.DataBaseUserTableEmailField,
                email
                           );

            return(ExecuteNonQuery(sql));
        }