private void webKitBrowser1_DocumentTitleChanged(object sender, EventArgs e) { if (isPaying) { isPaying = false; //充值返回了数据 try { Message msg = JsonConvert.DeserializeObject <Message>(this.webKitBrowser1.DocumentTitle); if (msg.Result) { //充值成功,提示打印票据 PayResult pay = JsonConvert.DeserializeObject <PayResult>(msg.TxtMessage); Print(pay); using (CompanyAccountServiceBF bf = new CompanyAccountServiceBF()) { Iot_TopUpRecord topUpRecord = new Iot_TopUpRecord() { ID = pay.ID, Address = this._user.Address, Amount = pay.Amount, Context = pay.Context, MeterID = pay.MeterID, MeterNo = pay.MeterNo, Oper = pay.Oper, OrgCode = "", PayType = pay.PayType, Ser = pay.Ser, CompanyID = "", State = (char)pay.State, TaskID = pay.TaskID, TopUpDate = pay.TopUpDate, TopUpType = (char)pay.TopUpType, UserID = pay.UserID, UserName = _user.UserName }; bf.ICompanyAccount.AddTopUpRecord(topUpRecord); } } else { //充值失败 this.btnClose.Enabled = true; this.btnPay.Enabled = true; MessageBox.Show("充值失败,原因:" + msg.TxtMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ee) { this.btnClose.Enabled = true; this.btnPay.Enabled = true; MessageBox.Show("充值失败,原因:服务器返回错误数据。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public PrintTicket(TicketPrinter printer, PayResult result, User user, bool isPrev) { InitializeComponent(); this.pay = result; this.user = user; this.isPrev = isPrev; ticketPrinter = printer; id = result.ID; strURL = string.Format("{0}/IotM/SFXT/Payment.html", LoginChecker.getInstance().CompanyAccount.ServiceURL); this.webKitBrowser1.Url = new System.Uri(strURL, System.UriKind.Absolute); }