protected void CreatePayee_Click(object sender, EventArgs e)
        {
            // Check to see if Payee exists

            Payee newPayee = new Payee();

            // If payee not exists, create new payee
            if (String.IsNullOrEmpty(hdnExistingPayeeId.Value))
            {
                newPayee.PayeeId                 = System.Guid.NewGuid().ToString().ToUpper();
                newPayee.DefaultName             = txtName.Text;
                newPayee.DefaultStreetAddress    = txtStreetAddress.Text;
                newPayee.DefaultStreetAddressTwo = txtStreetAddress2.Text;
                newPayee.DefaultCity             = txtCity.Text;
                newPayee.DefaultPostalCode       = txtPostalCode.Text;
                newPayee.DefaultRegion           = ddlRegion.SelectedValue;
                newPayee.DefaultCountry          = ddlCountry.Text; // Should be converted to a DDL in the future when more countries supported

                // Store into DB
                PayeeDb.InsertPayee(newPayee);
            }

            // Create UserPayee Association
            UserPayee newUserPayee = new UserPayee();

            newUserPayee.UserPayeeId        = System.Guid.NewGuid().ToString().ToUpper();
            newUserPayee.UserId             = User.Identity.GetUserId();
            newUserPayee.PayeeId            = String.IsNullOrEmpty(hdnExistingPayeeId.Value) ? newPayee.PayeeId : hdnExistingPayeeId.Value;
            newUserPayee.Nickname           = txtNickname.Text;
            newUserPayee.PayeeAccountNumber = txtAccountNumber.Text;

            // Store into DB
            UserPayeeDb.InsertUserPayee(newUserPayee);

            // Trigger confirmation Modal

            // Clear Values from Form
            txtName.Text            = "";
            txtStreetAddress.Text   = "";
            txtStreetAddress2.Text  = "";
            txtCity.Text            = "";
            txtPostalCode.Text      = "";
            ddlRegion.SelectedIndex = 0;
            txtNickname.Text        = "";
            txtAccountNumber.Text   = "";

            // Reset GridView1 and search query just in case
            txtSearchQuery.Text = "";
            GridView1.DataBind();
        }
Example #2
0
        protected void GridView1_PayeeResultCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                // Grab the index of the selected row
                int index = Convert.ToInt32(e.CommandArgument);

                // Grab the UserPayeeId selected and query the DB again for it
                String selectedUserPayeeId = GridView1.DataKeys[index]["UserPayeeId"].ToString();

                // Set the UserPayeeId into a session and redirect to Payment.aspx
                Session["PaymentInProgress_payee"] = UserPayeeDb.GetUserPayeeById(selectedUserPayeeId);

                Response.Redirect("/Account/Payment");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // Check if UserID is returned, thus authenticated session is still set
            if (string.IsNullOrEmpty(User.Identity.GetUserId()))
            {
                Response.Redirect("/Account/Login.aspx"); // This sends a 302, should send a 301
            }

            // Set/Overload the UserId for the Select query that will render FundingSources for User
            //ObjectDataSource1.SelectParameters["UserId"].DefaultValue = User.Identity.GetUserId();

            if (!IsPostBack)
            {
                // Generate Repeater Links
                List <UserPayee> payees = UserPayeeDb.GetUserPayees(User.Identity.GetUserId());

                PayeeList.DataSource = payees;
                PayeeList.DataBind();
            }
        }