コード例 #1
0
        protected void btnSignUpCustomer_Click(object sender, EventArgs e)
        {
            if (ValidateCustomerSignUp())
            {
                DataSet ds;
                string  firstName       = txtSUCFirstName.Text;
                string  lastName        = txtSUCLastName.Text;
                string  email           = txtSUCEmail.Text;
                string  password        = txtSUCPassword.Text;
                string  phoneNumber     = txtSUCPhoneNumber.Text;
                string  deliveryAddress = txtSUCDeliveryAddress.Text;
                string  billingAddress  = txtSUCBillingAddress.Text;
                string  bankingAccount  = txtSUCAccount.Text;
                string  bankingRoute    = txtSUCRouting.Text;

                ds = gd.GetProfile(email);
                //Makes sure that the email is not already in use
                if (ds.Tables[0].Rows.Count == 0)
                {
                    sd.CreateCustomer(email, password, "Customer", firstName, lastName, phoneNumber, deliveryAddress, billingAddress);

                    DataSet user   = gd.GetProfile(email);
                    string  userid = user.Tables[0].Rows[0]["userID"].ToString();

                    try
                    {
                        int walletID = apic.CreateWalletUser(userid, email, password, bankingAccount, bankingRoute);
                        sd.AddWalletID(int.Parse(userid), walletID);
                    }
                    catch
                    {
                        ErrorLabel.FillError("Unable to create virtual wallet. Please contact your chosen restaurant about payment");
                    }

                    LogInAsCustomer(email);
                }
                else
                {
                    ErrorLabel.FillError("That email is already connected to an account");
                }
            }
        }