Exemplo n.º 1
0
        public int Register(string UserName, string Password)
        {
            BaseDatabaseWarpper.CheckParamter("userName", UserName);
            BaseDatabaseWarpper.CheckParamter("password", Password);
            using (var Warpper = this.CreateDatabaseWarpper())
            {
                var trans = Warpper.Connection.BeginTransaction();
                try
                {
                    if (Warpper.ContainsUserNameWorkProc(UserName, trans))
                    {
                        throw new RegisterUserSameNameException();
                    }

                    Warpper.ExcuteCommand(CreateRegisterUserInsertSql(UserName, Password), trans);
                }
                catch (RegisterUserSameNameException ex)
                {
                    trans.Rollback();
                    LogUtil.Error(ex.Message, ex);
                    throw ex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogUtil.Error(ex.Message, ex);
                    throw ex;
                }
                trans.Commit();
                return(0);
            }
        }
Exemplo n.º 2
0
        public static string CreateRegisterUserInsertSql(string userName, string Password)
        {
            BaseDatabaseWarpper.CheckParamter("userName", userName);
            BaseDatabaseWarpper.CheckParamter("Password", Password);

            return(string.Format("INSERT INTO USER_TABLE (USERID,PASSWORD) VALUES ({0},{1})", BaseDatabaseWarpper.GetSafeString(userName), BaseDatabaseWarpper.GetSafeString(getSafePassword(Password))));
        }