protected void Page_Load(object sender, EventArgs e) { if (Request["action"] == "CheckPassword") { string oldPass = Request["oldpassword"]; if (oldPass == LoginUser.Passwd) { Response.Write("1"); } else { Response.Write("0"); } Response.End(); } if (yeyRequest.Params("haddinfo") == "1") { userModel.ID = LoginUser.ID; userModel.Passwd = Request["txtNewPassword"]; userModel.AssocNo = LoginUser.AssocNo; LoginUser.Passwd = userModel.Passwd; Session["LoginUser"] = LoginUser; servComm.AddOrUpdate(userModel); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ((HtmlContainerControl)Master.FindControl("HTitle")).InnerText = IsCN ? "用户个人信息" : "User Center"; } if (Session["NickName"] == null) { Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + "//Weixinclient//WXLogin.aspx"); } if (Request["action"] == "CheckPassword") { string oldPass = Request["oldpassword"]; if (oldPass == LoginUser.Passwd) { Response.Write("1"); } else { Response.Write("0"); } Response.End(); } if (yeyRequest.Params("haddinfo") == "1") { userModel.ID = LoginUser.ID; userModel.Passwd = Request["txtNewPassword"]; userModel.AssocNo = LoginUser.AssocNo; LoginUser.Passwd = userModel.Passwd; Session["LoginUser"] = LoginUser; servComm.AddOrUpdate(userModel); } else if (yeyRequest.Params("haddinfo") == "2") { Session["UserName"] = null; if (LoginUser.UserName.ToUpper().Contains("KQW")) { Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + "//Weixinclient//WXKQLogin.aspx"); } else { Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + "//Weixinclient//WXLogin.aspx"); } } }
protected void btnConsume_Click(object sender, EventArgs e) { ccWhere.Clear(); ccWhere.AddComponent("JGCBM", LoginUser.BelongFactory, SearchComponent.Equals, SearchPad.NULL); JX_USERS jxUser = servComm.GetEntity <JX_USERS>(null, ccWhere); if (!String.IsNullOrEmpty(jxUser.PayNoCardMerId) && Request["paymethod"] == "1" || Request["paymethod"] != "1" && !String.IsNullOrEmpty(jxUser.PayB2CMerId)) { //Dictionary<string, string> param = new Dictionary<string, string>(); //// 随机构造一个订单号(演示用) Random rnd = new Random(); string orderID = DateTime.Now.ToString("yyyyMMddHHmmss") + ((rnd.Next(900) + 100).ToString() + "0").Substring(0, 2).Trim(); ////填写参数 //param["version"] = "5.0.0";//版本号 //param["encoding"] = "UTF-8";//编码方式 //param["certId"] = CertUtil.GetSignCertId(); //证书ID //param["txnType"] = "01";//交易类型 //param["txnSubType"] = "01";//交易子类 //param["bizType"] = "000201";//业务类型 //param["frontUrl"] = "http://localhost:58826/BankPay/FrontRcvResponse.aspx?type=BankPay"; //前台通知地址 //param["backUrl"] = "http://222.222.222.222:8080/demo/utf8/BackRcvResponse.aspx"; //后台通知地址,改自己的外网地址 //param["signMethod"] = "01";//签名方法 //param["channelType"] = "08";//渠道类型,07-PC,08-手机 //param["accessType"] = "0";//接入类型 //param["merId"] = "481601512173917";//商户号,请改成自己的商户号 481601512173917,777290058110097 //param["orderId"] = orderID;//商户订单号,可任意修改 //param["txnTime"] = DateTime.Now.ToString("yyyyMMddHHmmss");//订单发送时间 //param["txnAmt"] = "1";//交易金额,单位分 //param["currencyCode"] = "156";//交易币种 ////param["orderDesc"] = "订单描述";//订单描述,暂时不会起作用 //param["reqReserved"] = "透传信息";//请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 //SDKUtil.Sign(param, Encoding.UTF8); //// 将SDKUtil产生的Html文档写入页面,从而引导用户浏览器重定向 //string html = SDKUtil.CreateAutoSubmitForm(SDKConfig.FrontTransUrl, param, Encoding.UTF8); //Response.ContentEncoding = Encoding.UTF8; // 指定输出编码 //Response.Write(html); Hashtable myMap = new Hashtable(); //无卡支付 string payAmount = Request["actualAmount"]; myMap.Add("MerOrderNo", orderID); myMap.Add("TranDate", DateTime.Now.ToString("yyyyMMdd")); myMap.Add("TranTime", DateTime.Now.ToString("hhmmss")); myMap.Add("OrderAmt", (int)(decimal.Parse(payAmount) * 100)); //myMap.Add("OrderAmt", 1); myMap.Add("BusiType", "0001"); myMap.Add("AccessType", "0"); myMap.Add("AcqCode", "000000000000014"); myMap.Add("MerPageUrl", Request.Url.GetLeftPart(UriPartial.Authority) + "/BankPay/FrontRcvResponse.aspx?type=BankPay"); myMap.Add("MerBgUrl", Request.Url.GetLeftPart(UriPartial.Authority) + "/BankPay/BgRcvResponse.aspx?type=BankPay"); myMap.Add("CurryNo", "CNY"); //myMap.Add("SplitType", ""); //myMap.Add("SplitMethod", ""); //myMap.Add("MerSplitMsg", ""); //myMap.Add("PayTimeOut", "145"); myMap.Add("Version", "20140728"); //myMap.Add("CommodityMsg", "ChinaPay测试-商品信息"); //myMap.Add("MerResv", "ChinaPay测试-商户保留域"); //myMap.Add("TranReserved", "{\"Referred\":\"www.chinapay.com\",\"BusiId\":\"0001\",\"TimeStamp\":\"1438915150976\",\"Remoteputr\":\"172.16.9.44\"}"); myMap.Add("TranType", "0001"); SecssUtil obj = new SecssUtil(); WNetPay payModel = new WNetPay(); //TODO 其他特殊用法请查看 pages/api_01_gateway/special_use_purchase.htm if (Request["paymethod"] == "1") { payModel.PayMethod = "0"; myMap.Add("MerId", jxUser.PayNoCardMerId); obj.init(Request.PhysicalApplicationPath + "/ChinaPay/" + jxUser.PayNoCardMerId + "/security.properties"); //初始化安全控件: } else { payModel.PayMethod = "1"; //B2C支付 //myMap.Add("BankInstNo", "700000000000010"); myMap.Add("MerId", jxUser.PayB2CMerId); obj.init(Request.PhysicalApplicationPath + "/ChinaPay/" + jxUser.PayB2CMerId + "/securityb2c.properties"); //初始化安全控件: } //bool ee = obj.sign(myMap); String chkValue = obj.getSign(); myMap.Add("Signature", chkValue); //obj.verify(myMap); if ("00" != obj.getErrCode()) { } payModel.OrderID = orderID; payModel.UserID = CurrentUserID; payModel.PayAmount = decimal.Parse(payAmount); payModel.JGCBM = LoginUser.BelongFactory; payModel.SubmitDateTime = DateTime.Now; payModel.PayStatus = "0"; payModel.Remark = "Remark"; servComm.AddOrUpdate(payModel); //chkValue = DelegatePay(orderID); // SDKUtil.Sign(param, System.Text.Encoding.UTF8); myMap["Signature"] = chkValue; string html = SDKUtil.CreateAutoSubmitFormHash(SDKConfig.FrontTransUrl, myMap, System.Text.Encoding.UTF8); // 将SDKUtil产生的Html文档写入页面,从而引导用户浏览器重定向 Response.ContentEncoding = Encoding.UTF8; // 指定输出编码 Response.Write(html); Response.End(); } else { Response.Write("请配置支付参数"); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { if (Request["action"] == "CheckJGCBM") { string txtJGCBM = Request["JGCBM"]; ccWhere.AddComponent("JGCBM", txtJGCBM, SearchComponent.Equals, SearchPad.NULL); if (!String.IsNullOrEmpty(Request["ID"])) { ccWhere.AddComponent("ID", Request["ID"], SearchComponent.UnEquals, SearchPad.And); } if (servComm.GetListTop(1, "JX_USERS", ccWhere).Rows.Count > 0) { Response.Write("1"); } else { Response.Write("0"); } Response.End(); } if (Request["action"] == "CheckConnection") { string txtJGCBM = Request["JGCBM"]; string txtDBUser = Request["DBUser"]; string txtDBPassword = Request["DBPassword"]; string txtDBServerIP = Request["DBServerIP"]; string strConnection = String.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", txtDBServerIP, "JJ2011", txtDBUser, txtDBPassword); if (Request["SameJGCBM"] == "true") { strConnection = String.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", txtDBServerIP, txtJGCBM, txtDBUser, txtDBPassword); } SqlConnection connection = new SqlConnection(strConnection); try { connection.Open(); } catch (Exception) { Response.Write("1"); Response.End(); } Response.Write("0"); Response.End(); } if (Request["action"] == "CheckMerID") { string txtNoCardMerId = Request["NoCardMerId"]; string txtB2CMerId = Request["B2CMerId"]; if (!String.IsNullOrEmpty(txtNoCardMerId.Trim())) { ccWhere.Clear(); ccWhere.AddComponent("PayNoCardMerId", txtNoCardMerId, SearchComponent.Equals, SearchPad.Ex); ccWhere.AddComponent("PayB2CMerId", txtNoCardMerId, SearchComponent.Equals, SearchPad.OrExB); if (!String.IsNullOrEmpty(Request["ID"])) { ccWhere.AddComponent("ID", Request["ID"], SearchComponent.UnEquals, SearchPad.And); } if (servComm.GetListTop(1, "JX_USERS", ccWhere).Rows.Count > 0) { Response.Write("2"); Response.End(); } } if (!String.IsNullOrEmpty(txtB2CMerId.Trim())) { ccWhere.Clear(); ccWhere.AddComponent("PayNoCardMerId", txtB2CMerId, SearchComponent.Equals, SearchPad.Ex); ccWhere.AddComponent("PayB2CMerId", txtB2CMerId, SearchComponent.Equals, SearchPad.OrExB); if (!String.IsNullOrEmpty(Request["ID"])) { ccWhere.AddComponent("ID", Request["ID"], SearchComponent.UnEquals, SearchPad.And); } if (servComm.GetListTop(1, "JX_USERS", ccWhere).Rows.Count > 0) { Response.Write("3"); Response.End(); } } Response.Write("0"); Response.End(); } if (!IsPostBack) { if (!String.IsNullOrEmpty(Request["ID"])) { jxuserModel = servComm.GetEntity <JX_USERS>(Request["ID"]); } } if (yeyRequest.Params("haddinfo") == "1") { string NoCardMerIdPass = Request["txtNoCardMerIdPass"]; string txtNoCardMerId = Request["txtNoCardMerId"]; string noCardCPPath = ""; string noCardSignPath = ""; if (GetFileExtends(this.NoCardCP.FileName) == "cer" && GetFileExtends(this.NoCardSign.FileName) == "pfx" && this.NoCardCP.HasFile && this.NoCardSign.HasFile && !String.IsNullOrEmpty(txtNoCardMerId) && !String.IsNullOrEmpty(NoCardMerIdPass)) { noCardSignPath = Request.PhysicalApplicationPath + "certs\\" + txtNoCardMerId + "_Sign.pfx"; noCardCPPath = Request.PhysicalApplicationPath + "certs\\" + txtNoCardMerId + "_Cp.cer"; this.NoCardCP.SaveAs(noCardCPPath); this.NoCardSign.SaveAs(noCardSignPath); string filePath = Request.PhysicalApplicationPath + "/ChinaPay/" + txtNoCardMerId + "/security.properties"; if (File.Exists(filePath)) { File.Delete(filePath); } else { Directory.CreateDirectory(Request.PhysicalApplicationPath + "/ChinaPay/" + txtNoCardMerId); Stream fileStream = File.Create(filePath); fileStream.Dispose(); fileStream.Close(); } FileStream stream = new FileStream(filePath, FileMode.Create); //fileMode指定是读取还是写入 StreamWriter writer = new StreamWriter(stream, Encoding.Default); writer.WriteLine("[CHINAPAY]"); //写入一行,写完后会自动换行 writer.WriteLine("sign.file=" + noCardSignPath); writer.WriteLine("sign.file.password="******"sign.cert.type=PKCS12"); writer.WriteLine("sign.invalid.fields=Signature,CertId"); writer.WriteLine("verify.file=" + noCardCPPath); writer.Write("signature.field=Signature"); //写完后不会换行 writer.Close(); //释放内存 stream.Close(); //释放内存 //保存文件时没有指定编码格式,所以出现了乱码,只要在StreamWriter writer = new StreamWriter(stream, Encoding.Default); 指定了编码为Encoding.Default文件乱码的问题就解决了 } string B2CMerIdPass = Request["txtB2CMerIdPass"]; string txtB2CMerId = Request["txtB2CMerId"]; string B2CCPPath = ""; string B2CSignPath = ""; if (GetFileExtends(this.B2CCP.FileName) == "cer" && GetFileExtends(this.B2CSign.FileName) == "pfx" && this.B2CCP.HasFile && this.B2CSign.HasFile && !String.IsNullOrEmpty(txtB2CMerId) && !String.IsNullOrEmpty(B2CMerIdPass)) { B2CSignPath = Request.PhysicalApplicationPath + "certs\\" + txtB2CMerId + "_Sign.pfx"; B2CCPPath = Request.PhysicalApplicationPath + "certs\\" + txtB2CMerId + "_Cp.cer"; this.B2CCP.SaveAs(B2CCPPath); this.B2CSign.SaveAs(B2CSignPath); string filePath = Request.PhysicalApplicationPath + "/ChinaPay/" + txtB2CMerId + "/securityb2c.properties"; if (File.Exists(filePath)) { File.Delete(filePath); } else { Directory.CreateDirectory(Request.PhysicalApplicationPath + "/ChinaPay/" + txtB2CMerId); Stream fileStream = File.Create(filePath); fileStream.Dispose(); fileStream.Close(); } FileStream stream = new FileStream(filePath, FileMode.Create); //fileMode指定是读取还是写入 StreamWriter writer = new StreamWriter(stream, Encoding.Default); writer.WriteLine("[CHINAPAY]"); //写入一行,写完后会自动换行 writer.WriteLine("sign.file=" + B2CSignPath); writer.WriteLine("sign.file.password="******"sign.cert.type=PKCS12"); writer.WriteLine("sign.invalid.fields=Signature,CertId"); writer.WriteLine("verify.file=" + B2CCPPath); writer.Write("signature.field = Signature"); //写完后不会换行 writer.Close(); //释放内存 stream.Close(); //释放内存 //保存文件时没有指定编码格式,所以出现了乱码,只要在StreamWriter writer = new StreamWriter(stream, Encoding.Default); 指定了编码为Encoding.Default文件乱码的问题就解决了 } if (!String.IsNullOrEmpty(Request["ID"])) { jxuserModel.ID = int.Parse(Request["ID"]); } jxuserModel.JGCBM = Request["txtJGCBM"]; jxuserModel.JGCName = Request["txtJGCName"]; jxuserModel.Contact = Request["txtContact"]; jxuserModel.Address = Request["txtAddress"]; jxuserModel.ContactQQ = Request["txtContactQQ"]; jxuserModel.DBPassword = Request["txtDBPassword"]; jxuserModel.DBUser = Request["txtDBUser"]; jxuserModel.DBServerIP = Request["txtDBServerIP"]; jxuserModel.Email = Request["txtEmail"]; jxuserModel.Telephone = Request["txtTelephone"]; jxuserModel.WeiXin = Request["txtWeiXin"]; jxuserModel.Remark = Request["txtRemark"]; jxuserModel.LastModifyBy = LoginUser.UserName; jxuserModel.LastModifyTime = DateTime.Now; jxuserModel.UserPasswd = Request["txtUserPasswd"]; jxuserModel.DBsameJGCBM = Request["SameJGCBM"] == "on"?"Y":"N"; jxuserModel.PayNoCardMerId = txtNoCardMerId; jxuserModel.PayNoCardPass = NoCardMerIdPass; jxuserModel.PayNoCardSignPath = noCardSignPath; jxuserModel.PayNocardCPPath = noCardCPPath; jxuserModel.PayB2CMerId = txtB2CMerId; jxuserModel.PayB2CPass = B2CMerIdPass; jxuserModel.PayB2CSignPath = B2CSignPath; jxuserModel.PayB2CCPPath = B2CCPPath; servComm.AddOrUpdate(jxuserModel); Response.Redirect("JGCList.aspx?type=System"); } }