📄 singlereckoningr.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
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.Data.OleDb;
using System.Web.Security;
namespace SCard.admin
{
/// <summary>
/// singleReckoningR 的摘要说明。
/// </summary>
public class singleReckoningR : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblOrder;
protected System.Web.UI.WebControls.Label lblMerchant_id;
protected System.Web.UI.WebControls.Label lblOrderid;
protected System.Web.UI.WebControls.Label lblAmount;
protected System.Web.UI.WebControls.Label lblDate;
protected System.Web.UI.WebControls.Label lblMerchant_param;
protected System.Web.UI.WebControls.Label lblSucceed;
private void Page_Load(object sender, System.EventArgs e)
{
/* 不能设权限..因为是 .. 快钱转载
//权限检查
if( Session["adminName"]==null || Session["adminName"].ToString() == String.Empty )
{
Response.Write("<font color=#ff0000 style='FONT-SIZE: 12px'>对不起,您没足够权限访问此页!!</font><br>");
Response.Write("<a href=index.aspx target=_top style='FONT-SIZE: 12px'>重新登陆</a><br>");
Response.End();
return;
}
*/
if( !IsPostBack )
{
if ( Request.QueryString["order"] == null || Request.QueryString["merchant_id"] == null
|| Request.QueryString["orderid"] == null || Request.QueryString["amount"] == null
|| Request.QueryString["date"] == null || Request.QueryString["merchant_param"] == null
|| Request.QueryString["succeed"] == null || Request.QueryString["mac"] == null )
{
Response.Write("返回结果出错!!!<br>");
Response.End();
return;
}
string strOrder = Request.QueryString["order"].ToString(); //查询情况 “0”表示没有查到,”1”表示查到
string strMerchant_id = Request.QueryString["merchant_id"].ToString(); //商户编号*
string strOrderid = Request.QueryString["orderid"].ToString(); //订单编号*
string strAmount = Request.QueryString["amount"].ToString(); //订单金额*
string strDate = Request.QueryString["date"].ToString(); //交易日期
string strMerchant_param = Request.QueryString["merchant_param"].ToString(); //附加信息 商户自定义参数。
string strSucceed = Request.QueryString["succeed"].ToString(); //交易结果 * “Y”:支付成功,“N”:支付失败
string strMac = Request.QueryString["mac"].ToString(); //MAC校验域
string strKey = getMerchantKey();//获取 私钥值
string strSac = "merchant_id=" + strMerchant_id + "&orderid=" + strOrderid + "&amount=" + strAmount +
"&date=" + strDate + "&succeed=" + strSucceed + "&merchant_key=" + strKey;
//md5加密
strSac = FormsAuthentication.HashPasswordForStoringInConfigFile( strSac ,"MD5");
//mac值校验
if ( strSac.Equals( strMac ) )
{ /************** 校验成功 ***********/
if( strOrder.Equals("1") )
{
strOrder = "<font color=#0000ff>查到</font>";
}
else
{
strOrder = "<font color=#ff0000>没有查到</font>";
}
if( strSucceed.Equals("Y") )
{
strSucceed = "<font color=#0000ff>支付成功</font>";
}
else
{
strSucceed = "<font color=#ff0000>支付失败</font>";
}
lblOrder.Text = strOrder;
lblMerchant_id.Text = strMerchant_id;
lblOrderid.Text = strOrderid;
if( strAmount != String.Empty ) //查不到 金额为空
{
lblAmount.Text = double.Parse(strAmount).ToString("C");
}
lblDate.Text = strDate;
//lblMerchant_param.Text = strMerchant_param; //附加信息
lblSucceed.Text = strSucceed;
}
else
{ /************** 校验失败 ***********/
Response.Write("Mac不正确<br>");
Response.End();
return;
}
}
}
private string getMerchantKey()//获取 私钥值
{
string s = "";
DBConn myDB = new DBConn();
string mySql="select [text] from [wangguan] where [id]='1'";
OleDbDataReader mydr = myDB.getDataReader( mySql );
if( mydr.Read() )
{
s = mydr["text"].ToString();
}
mydr.Close();
myDB.Close();
//加密对象
DCard.Encode myEncode = new DCard.Encode();
try
{
s = myEncode.DecryptString( s );
}
catch
{
//如果不是已加密字符串 就会出错
}
return s;
}
/*
private string getMerchantID()//获取 商户编号
{
string s = "";
DBConn myDB = new DBConn();
string mySql="select [text] from [wangguan] where [id]='0'";
OleDbDataReader mydr = myDB.getDataReader( mySql );
if( mydr.Read() )
{
s = mydr["text"].ToString();
}
mydr.Close();
myDB.Close();
return s;
}
*/
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -