pay.aspx.cs
来自「数字图书馆网站」· CS 代码 · 共 119 行
CS
119 行
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
using System.Configuration;
using DigitalLibrary.CreditCardValidator;
namespace DigitalLibrary
{
/// <summary>
/// Summary description for Pay.
/// </summary>
public class Pay : System.Web.UI.Page
{
protected System.Web.UI.HtmlControls.HtmlForm frmPay;
protected System.Web.UI.HtmlControls.HtmlGenericControl Div1;
protected System.Web.UI.WebControls.Label lblMessage;
protected System.Web.UI.WebControls.TextBox txtCreditNo;
protected System.Web.UI.WebControls.TextBox txtEmailID;
protected System.Web.UI.WebControls.Button btnPay;
protected System.Web.UI.WebControls.Button btnOK;
protected System.Web.UI.WebControls.Image imgImage;
protected System.Web.UI.WebControls.Panel pnlPay;
protected System.Web.UI.WebControls.RequiredFieldValidator rfvCCNO;
protected System.Web.UI.WebControls.RegularExpressionValidator revEmail;
protected System.Web.UI.WebControls.Label lblLogin;
protected System.Web.UI.WebControls.Label lblPrice;
protected System.Web.UI.WebControls.Button btnBack;
protected System.Web.UI.WebControls.Label lblTitle;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
this.lblLogin.Text = Convert.ToString(Session["Login"]);
SqlConnection objConnection = new SqlConnection(ConfigurationSettings.AppSettings["DatabaseConnection"]);
SqlDataAdapter objAdapter = new SqlDataAdapter("SELECT Price FROM PayableArticles WHERE ArticleID = "+Request.QueryString.Get("ArticleID"),objConnection);
DataSet objDataSet = new DataSet();
objAdapter.Fill(objDataSet,"Price");
if (objDataSet.Tables["Price"].Rows.Count>0)
{
this.lblPrice.Text = objDataSet.Tables["Price"].Rows[0][0].ToString();
this.lblPrice.Visible=true;
}
else
{
this.lblPrice.Visible=false;
}
objConnection.Close();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
this.btnPay.Click += new System.EventHandler(this.btnPay_Click);
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnOK_Click(object sender, System.EventArgs e)
{
Response.Redirect("Library.aspx");
}
private void btnPay_Click(object sender, System.EventArgs e)
{
//Declare an object to consume the web method
CCValidator objCCValidator = new CCValidator();
bool IsValid = objCCValidator.Validate(txtCreditNo.Text);
if (IsValid)
{
SqlConnection objConnection = new SqlConnection(ConfigurationSettings.AppSettings["DatabaseConnection"]);
SqlCommand objCommand = new SqlCommand("INSERT INTO ArticlesPurchased Values ("+Request.QueryString.Get("ArticleID")+" , '"+Request.QueryString.Get("Login")+"','"+this.txtCreditNo.Text+"','"+this.txtEmailID.Text+"','Y')",objConnection);
objConnection.Open();
objCommand.ExecuteNonQuery();
objConnection.Close();
Session["Login"]=Request.QueryString.Get("Login");
this.lblMessage.Text = "您的文章已被激活!单击“确定”,然后单击该文章,以便从图书馆中浏览该文章!";
}
else
{
this.lblMessage.Text = "您的请求无效!单击“确定”浏览更多文章或重试!";
}
this.lblMessage.Visible = true;
this.btnOK.Visible = true;
}
private void btnBack_Click(object sender, System.EventArgs e)
{
Response.Redirect("Library.aspx");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?