1 Star 0 Fork 2

智锋科技/PIP_Demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Form1.cs 6.12 KB
一键复制 编辑 原始数据 按行查看 历史
李涛 提交于 2019-10-30 11:38 . code first基本实现
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HIS.EHC
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Helper.InitPayEnvironment();
//string url = tb_url.Text.ToString().Trim();
//string appid = tb_appid.Text.ToString().Trim();
//string appsec = tb_appsec.Text.ToString().Trim();
//string indata = "{\"transType\":\"hop.trade.setinfo\",\"param\":{\"serveraddr\":\"" + url + "\",\"appid\":\"" + appid + "\",\"appsecret\":\"" + appsec + "\"}}";
//Byte[] outdata = new Byte[2048];
//IntPtr a = Helper.payTrans(indata, ref outdata[0]);
//string strGet = System.Text.Encoding.Default.GetString(outdata, 0, outdata.Length);
//string strRet = Marshal.PtrToStringAnsi(a);
//string outstring = strRet + "\r\n" + strGet.TrimEnd('\0');
//MessageBox.Show(outstring);
}
private void button2_Click(object sender, EventArgs e)
{
//string abc= "{\"transType\":\"hop.account.info\",\"param\":{\"operatorId\":\"" + tb_operatorId.Text.ToString().Trim() + "\",\"termNo\":\"" + tb_terNo.Text.ToString().Trim() + "\",\"operatorName\":\"" + tb_operName.Text.ToString().Trim() + "\",\"cardType\":\"" + tb_cardType.Text.ToString().Trim() + "\",\"cardNo\":\"" + tb_cardNo.Text.ToString().Trim() + "\",\"accountType\":\"" + tb_accType.Text.ToString().Trim() + "\",\"idNo\":\"" + tb_idNo.Text.ToString().Trim() + "\",\"notes\":\"\"}}";
string lsh = "abc123";
string payInfo = " {\"transType\":\"hop.trade.recharge\",\"param\":{\"operatorId\":\"001\",\"termNo\":\"001\",\"operatorName\":\"张三\",\"cardType\":\"01\",\"hisCustId\":\"\",\"userName\":\"李四\",\"amount\":\"0.01\",\"outChargeNo\":\"" + lsh + "\",\"depositType\":\"all_bar\",\"PosNo\":\"\",\"HZJDFlag\":\"\",\"ShowMsg\":\"\",\"extra\":{\"hopname\":\"\",\"hopid\":\"\",\"deskflak\":\"1\"},\"cardNo\":\"1A95490805\",\"accountType\":\"01\",\"idNo\":\"340121199301154617\",\"notes\":\"\"}}";
Helper.Pay(payInfo);
}
private void buttonORM_Click(object sender, EventArgs e)
{
Helper.PayInitEnvironment();
var query = JsonHelper.DeserializeJSON<Model.query._in.query_in_Root>(richTextBox1.Text);
using (EHCEntities chis = new EHCEntities())
{
//chis.Database.Log = s => WEISHENG.COMM.LogHelper.LogToFile("ef6调试", s);
using (var dbContextTransaction = chis.Database.BeginTransaction())
{
try
{
chis.in_roots.Add(query);
chis.SaveChanges();
dbContextTransaction.Commit();
//HIS.COMM.msgHelper.BalloonShow("数据保存成功");
}
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
{
StringBuilder stringBuilder = new StringBuilder();
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
stringBuilder.Append(string.Format("Class: {0}, Property: {1}, Error: {2}",
validationErrors.Entry.Entity.GetType().FullName,
validationError.PropertyName,
validationError.ErrorMessage));
}
}
dbContextTransaction.Rollback();
//HIS.COMM.msgHelper.BalloonShow(stringBuilder.ToString());
}
catch (Exception ex)
{
string errorMsg = "错误:";
if (ex.InnerException == null)
errorMsg += ex.Message + ",";
else if (ex.InnerException.InnerException == null)
errorMsg += ex.InnerException.Message + ",";
else if (ex.InnerException.InnerException.InnerException == null)
errorMsg += ex.InnerException.InnerException.Message;
dbContextTransaction.Rollback();
//HIS.COMM.msgHelper.BalloonShow(errorMsg);
}
}
chis.Database.Log = null;
}
richTextBox2.Text = JsonHelper.SerializeJSON(query);
var str = Helper.Pay(richTextBox1.Text);
var str2 = JsonHelper.GetJsonstr(str);
Model.query._out.query_out_Root root = JsonHelper.DeserializeJSON<Model.query._out.query_out_Root>(str2);
}
private void button3_Click(object sender, EventArgs e)
{
try
{
var query = JsonHelper.DeserializeJSON<Model.mf_Root>(richTextBox2.Text);
//var queryin = JsonHelper.DeserializeJSON<Model.query._out.query_out_Root>(richTextBox1.Text);
using (EHCEntities chis = new EHCEntities())
{
chis.mf_Roots.Add(query);
//chis.in_roots.Add(queryin)
chis.SaveChanges();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button4_Click(object sender, EventArgs e)
{
EHCEntities chis = new EHCEntities();
var query2 = chis.in_roots.FirstOrDefault();
var query = chis.mf_Roots.FirstOrDefault();
//var test = query.mxlist;
richTextBox2.Text = JsonHelper.SerializeJSON(query);
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/elfbobo_admin/PIP_Demo.git
git@gitee.com:elfbobo_admin/PIP_Demo.git
elfbobo_admin
PIP_Demo
PIP_Demo
master

搜索帮助