frmAliPayConfig.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.OAShopManagement
  10. {
  11. public partial class frmAliPayConfig : LYFZ.Software.UI.OAShopManagement.frmAliPayConfig
  12. {
  13. LYFZ.BLL.BLL_ErpSystemConfigure config = new BLL.BLL_ErpSystemConfigure();
  14. LYFZ.Model.Model_ErpSystemConfigure modConfig;
  15. string aliSubMchId = "";
  16. public frmAliPayConfig()
  17. {
  18. InitializeComponent();
  19. DataSet ds = config.GetSystemConfigure("*", "AliPayConfig");
  20. if (ds.Tables[0].Rows.Count == 0)
  21. {
  22. modConfig = new Model.Model_ErpSystemConfigure()
  23. {
  24. Sconfig_Code = "AliPayConfig",
  25. Sconfig_Name = "支付宝账户",
  26. Sconfig_Value = Json.JsonTool.ObjectToJson(new LYFZ.BLL.AliConfigData() { AppId = "", Key = "", MCHID = "", publicKey="", SubMchId="" })
  27. };
  28. config.Add(modConfig);
  29. }
  30. else
  31. {
  32. modConfig = config.DataRowToModel(ds.Tables[0].Rows[0]);
  33. LYFZ.BLL.AliConfigData data = new LYFZ.BLL.AliConfigData();
  34. data = (LYFZ.BLL.AliConfigData)Json.JsonTool.JsonToObject(modConfig.Sconfig_Value, data);
  35. txt_AppId.Text = data.AppId.Trim();
  36. txt_MchId.Text = data.MCHID.Trim();
  37. aliSubMchId = data.SubMchId.Trim();
  38. txt_Key.Text = data.Key;
  39. txt_PublicKey.Text = data.publicKey;
  40. }
  41. }
  42. protected override void btn_Check_Click(object sender, EventArgs e)
  43. {
  44. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\alipay_rsa_public_key.pem", txt_PublicKey.Text);
  45. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\rsa_public_key.pem", txt_PublicKey.Text);
  46. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\rsa_private_key.pem", txt_Key.Text);
  47. frmActionPay frmPay = new frmActionPay();
  48. frmPay.BindInfoData("支付宝支付", 0.01m, txt_AppId.Text.Trim(), txt_MchId.Text.Trim(), "", aliSubMchId, "");
  49. frmPay.ShowDialog();
  50. //base.btn_Cancel_Click(sender, e);
  51. }
  52. protected override void btn_OK_Click(object sender, EventArgs e)
  53. {
  54. LYFZ.BLL.AliConfigData data = new LYFZ.BLL.AliConfigData()
  55. {
  56. AppId = txt_AppId.Text.Trim(),
  57. MCHID = txt_MchId.Text.Trim(),
  58. Key = txt_Key.Text,
  59. publicKey = txt_PublicKey.Text
  60. };
  61. string strJson = Json.JsonTool.ObjectToJson(data);
  62. modConfig.Sconfig_Value = strJson;
  63. config.Update((object)modConfig, " Sconfig_Code='AliPayConfig' ", "ID");
  64. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\alipay_rsa_public_key.pem", txt_PublicKey.Text);
  65. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\rsa_public_key.pem", txt_PublicKey.Text);
  66. LYFZ.Software.MainBusiness.MultipleFileImport.FileUtil.WriteFileByASCII(Application.StartupPath + "\\RSA\\rsa_private_key.pem", txt_Key.Text);
  67. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  68. this.Close();
  69. base.btn_OK_Click(sender, e);
  70. }
  71. }
  72. }