⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkout.aspx.cs

📁 The purpose of this code is to assist developers get some good ideas for how to build a PayPal shop
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class CheckOut : System.Web.UI.Page
{

    private Invoice _selectedInvoice = new Invoice();
    public Invoice SelectedInvoice
    {
        get
        {
            if (_selectedInvoice.InvoiceId == "")
            {
                try
                {
                    _selectedInvoice = (Invoice)Session["Invoice"];
                }
                catch { }
            }
            return _selectedInvoice;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (SelectedInvoice.InvoiceItems.Count == 0)
        {
            Response.Redirect("ViewCart.aspx");
        }
    }


    protected void chkSameAsBilling_CheckedChanged(object sender, EventArgs e)
    {
        if (chkSameAsBilling.Checked)
        {
            //copy billing info into shipping info
            this.txtShipToName.Text = this.txtBillingName.Text;
            this.txtShipToAddress1.Text = this.txtBillingAddress1.Text;
            this.txtShipToAddress2.Text = this.txtBillingAddress2.Text;
            this.txtShipToCity.Text = this.txtBillingCity.Text;
            this.txtShipToZip.Text = this.txtBillingZip.Text;
            
            this.cboShipToState.SelectedIndex = this.cboBillingState.SelectedIndex;
            this.cboShipToState.Visible = this.cboBillingState.Visible;
        }
        Page.Validate();
    }

    
    protected void btnPaypalCheckout_Click(object sender, EventArgs e)
    {
        Page.Validate();
        if (Page.IsValid)
        {
            //store data
            SelectedInvoice.ContactName = this.txtBillingName.Text;
            SelectedInvoice.ContactPhone = this.txtBillingPhone.Text;
            SelectedInvoice.ContactEmail = this.txtBillingEmail.Text;

            SelectedInvoice.ContactAddress1 = this.txtBillingAddress1.Text;
            SelectedInvoice.ContactAddress2 = this.txtBillingAddress2.Text;
            SelectedInvoice.ContactCity = this.txtBillingCity.Text;
            SelectedInvoice.ContactStateProvince = this.cboBillingState.SelectedValue;
            SelectedInvoice.ContactZip = this.txtBillingZip.Text;

            SelectedInvoice.ShipToAddress1 = this.txtShipToAddress1.Text;
            SelectedInvoice.ShipToAddress2 = this.txtShipToAddress2.Text;
            SelectedInvoice.ShipToCity = this.txtShipToCity.Text;
            SelectedInvoice.ShipToStateProvince = this.cboShipToState.SelectedValue;
            SelectedInvoice.ShipToZip = this.txtShipToZip.Text;

            SelectedInvoice.CustomerComments = this.txtCustomerComments.Text;

            Session["Invoice"] = SelectedInvoice;

            //redirect
            Response.Redirect("PayPalProcessing.aspx");
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -