private void btnOk_Click(object sender, EventArgs e) { if (!PosServericeBll.Instance.TestConnect()) { MessageBox.Show("断网状态,操作取消!", Gattr.AppTitle); } else { if (string.IsNullOrEmpty(this.txtAmount.Text.Trim())) { MessageBox.Show("金额不能为空!"); this.txtAmount.Focus(); } else { decimal amount = 0M; amount = Convert.ToDecimal(this.txtAmount.Text.Trim()) * Convert.ToDecimal((this.cbPayName.SelectedItem as ListItem).Value.Trim()); if (amount <= 0M) { MessageBox.Show("金额必须大于零!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.txtAmount.SelectAll(); this.txtAmount.Focus(); } else if (amount > 999999999M) { MessageBox.Show("金额值过大!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.txtAmount.SelectAll(); this.txtAmount.Focus(); } else { if (this.rbPayOut.Checked) { amount = -amount; } try { string flowNo = Gfunc.GetFlowNo(); ListItem item = this.cbPayName.SelectedItem as ListItem; string pay_name = item.Key.Substring(item.Key.LastIndexOf("]") + 1); List <t_pos_payflow> _listPay = new List <t_pos_payflow>(); t_pos_payflow _pay = new t_pos_payflow(); _pay.flow_id = 1; _pay.flow_no = flowNo; _pay.branch_no = Gattr.BranchNo; _pay.sale_way = "A"; _pay.sale_amount = amount; _pay.pay_way = (this.cbPayName.SelectedItem as ListItem).Key.Substring(1, (this.cbPayName.SelectedItem as ListItem).Key.IndexOf("]") - 1); _pay.oper_date = DateTime.Now.ToString("s"); _pay.oper_id = Gattr.OperId; _pay.pos_id = Gattr.PosId; _pay.pay_amount = amount; _pay.coin_rate = 1M; _pay.convert_amt = amount; _pay.memo = this.txtMemo.Text.Trim(); _pay.coin_type = "RMB"; _pay.com_flag = "1"; _pay.pos_flag = "1"; _pay.pay_name = pay_name; _listPay.Add(_pay); Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); string pay = JsonUtility.Instance.ObjectToJson <t_pos_payflow>(_listPay); _dic.Add("pay", pay); bool isok = true; string errorMessage = string.Empty; if (PosServericeBll.Instance.TestConnect()) { string json = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/Addflow", _dic, ref isok, ref errorMessage); if (isok) { if (!string.IsNullOrEmpty(json)) { string message = string.Empty; switch (json) { case "-10": message = "参数错误"; break; case "-20": message = "权限不足"; break; case "1": //TODO :保存数据本地 _pay.com_flag = "1"; if (Gattr.Bll.SaveNonTrading(_pay)) { Gfunc.SetFlowNo(); message = "付款成功"; bool isok1 = true; if (this.rbPayOut.Checked) { isok1 = false; } this.Print(_pay.flow_no, isok1, _pay.pay_name, _pay.pay_amount.Value, _pay.memo); DialogResult = System.Windows.Forms.DialogResult.OK; //MessageBox.Show(message, Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); LoggerHelper.Log("MsmkLogger", System.DateTime.Now.ToString() + "【" + Gattr.OperId + "】进行非交易记录!" + _pay.sale_amount + "元", LogEnum.SysLog); } break; default: message = "付款失败"; break; } if (json != "1") { MessageBox.Show("付款失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("付款失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show(errorMessage, Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { if (Gattr.Bll.SaveNonTrading(_pay)) { Gfunc.SetFlowNo(); string message = "付款成功"; bool isok1 = true; if (this.rbPayOut.Checked) { isok1 = false; } this.Print(_pay.flow_no, isok1, _pay.pay_name, _pay.pay_amount.Value, _pay.memo); DialogResult = System.Windows.Forms.DialogResult.OK; MessageBox.Show(message, Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("付款失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch { MessageBox.Show("付款失败!", Gattr.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } } }