Example #1
0
        protected void submit_Click(object sender, EventArgs e)
        {
            Users _user = new Users();

            _user.FirstName    = fName.Value;
            _user.LastName     = lName.Value;
            _user.EmailAddress = email.Value;
            _user.Password     = pwd.Value;
            _user.Birthday     = DateTime.Parse(dob.Value);

            if (!DoesUserExist(_user.EmailAddress))
            {
                UsersDb _usersDb = new UsersDb();

                if (pwd.Value == cpwd.Value)
                {
                    int userId = _usersDb.AddUser(_user);

                    Random   rnd      = new Random();
                    decimal  _balance = rnd.Next(100, 1000000);
                    Accounts _account = new Accounts();
                    _account.AccountNumber = Convert.ToInt32(accountNum.Value.ToString());
                    _account.AccountType   = accounttype.Value;
                    _account.Fk_UserId     = userId;
                    _account.Balance       = _balance;

                    AccountDb _accountDb = new AccountDb();
                    int       account    = _accountDb.AddAccount(_account);
                    _user.Id = userId;


                    Session["LoggedIn"] = _user.Id.ToString();
                    Response.Redirect("/Index.aspx");
                }
                else
                {
                    this.error.Visible   = true;
                    this.error.InnerText = "Password and Confirm Password must match.";
                }
            }
            else
            {
                this.error.Visible   = true;
                this.error.InnerText = "Email Address is already in use.";
            }
        }