/// <summary> /// 获取付款流水 /// </summary> /// <param name="payList"></param> /// <param name="msg"></param> /// <returns></returns> public static bool GetSalSalePay(out List <TSalSalePay> payList, out string msg) { SQLiteDataReader rd; if (!DBTool.Select(string.Empty, new DBSalSalePay(), string.Empty, out rd, out msg)) { payList = null; return(false); } payList = new List <TSalSalePay>(); while (rd.Read()) { TSalSalePay pay = new TSalSalePay(); pay.ORGCODE = Convert.ToString(rd["OrgCode"]); pay.SALENO = Convert.ToString(rd["SaleNo"]); pay.SERIALNO = Convert.IsDBNull(rd["SerialNo"]) ? "0" : rd["SerialNo"].ToString(); pay.SSTOTAL = Convert.IsDBNull(rd["SsTotal"]) ? "0" : rd["SsTotal"].ToString(); pay.VIPNO = Convert.ToString(rd["VipNo"]); pay.ZFCODE = Convert.ToString(rd["ZfCode"]); pay.ZFNO = Convert.ToString(rd["ZfNo"]); pay.ZFTOTAL = string.IsNullOrEmpty(rd["ZfTotal"].ToString()) ? "0" : rd["ZfTotal"].ToString(); payList.Add(pay); } rd.Close(); return(true); }
private void button_1_Click(object sender, EventArgs e) { string msg; string refNo; decimal SsMoney = 0; if (PayTypeBox.ShowDialog() == DialogResult.OK) { //选定付款方式 TSalSalePay tSalSalePay = new TSalSalePay(); tSalSalePay.ZFCODE = PayTypeBox.PayType.PAYCODE; tSalSalePay.ZFNO = string.Empty; tSalSalePay.VIPNO = string.Empty; switch (PayTypeBox.PayType.PAYTYPE) { case "2": //银联卡 //if (!Devices.Emvpboc.SendPay(PubGlobal.Cur_Sale_YETotal, Devices.Emvpboc.ActionType.消费, out SsMoney, out msg)) //{ // MessageBox.Show("银联支付失败:" + msg); // return; //} SsMoney = PubGlobal.Cur_Sale_YETotal; if (!cEmvpbocBank.Action(Devices.CEmvpboc.ActionType.消费, ref SsMoney, out refNo, out msg)) { MessageBox.Show("银联支付失败:" + msg); return; } else { tSalSalePay.SSTOTAL = SsMoney.ToString("F2"); tSalSalePay.ZFTOTAL = SsMoney.ToString("F2"); tSalSalePay.ZFNO = refNo; } break; case "1": //储值卡 SsMoney = PubGlobal.Cur_Sale_YETotal; if (!cEmvpbocBank.Action(Devices.CEmvpboc.ActionType.消费, ref SsMoney, out refNo, out msg)) { MessageBox.Show("储值卡支付失败:" + msg); return; } else { tSalSalePay.SSTOTAL = SsMoney.ToString("F2"); tSalSalePay.ZFTOTAL = SsMoney.ToString("F2"); tSalSalePay.ZFNO = refNo; } break; default: //其他 if (EnterBox.ShowDialog() == DialogResult.OK) { try { SsMoney = decimal.Parse(EnterBox.Value); //尝试转换为数字 } catch { MessageBox.Show("输入错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); SsMoney = 0; return; } } else { return; } break; } tSalSalePay.ZFTOTAL = SsMoney.ToString("F2"); tSalSalePay.SALENO = PubGlobal.Cur_tSalSale[0].SALENO; tSalSalePay.SERIALNO = (serialno++).ToString(); tSalSalePay.ORGCODE = PubGlobal.OrgCode; PubGlobal.Cur_tSalSalePayList.Add(tSalSalePay);//输入完毕,加入付款流水 StringBuilder strBuilder = new StringBuilder(); strBuilder.AppendFormat("{0}-【{1}】 {2}元 \r\n", new string[] { tSalSalePay.SERIALNO, PayTypeBox.PayType.PAYNAME, decimal.Parse(tSalSalePay.ZFTOTAL).ToString("F2") }); tbPayList.Text += strBuilder.ToString(); strBuilder.Remove(0, strBuilder.Length); PubGlobal.Cur_TradeSucess = PubGlobal.Cur_Sale_YETotal - decimal.Parse(tSalSalePay.ZFTOTAL) <= 0; if (PubGlobal.Cur_TradeSucess) { decimal charge; if (PayTypeBox.PayType.ISCHANGE == "1") { charge = decimal.Parse(tSalSalePay.ZFTOTAL) - PubGlobal.Cur_Sale_YETotal;//找零金额 tSalSalePay.SSTOTAL = (decimal.Parse(tSalSalePay.ZFTOTAL) - charge).ToString(); //允许找零 strBuilder.AppendFormat(" 【找零】{0}元\r\n", charge.ToString("F2")); tbPayList.Text += strBuilder.ToString(); } else { tSalSalePay.SSTOTAL = decimal.Parse(tSalSalePay.ZFTOTAL).ToString(); } } else { tSalSalePay.SSTOTAL = decimal.Parse(tSalSalePay.ZFTOTAL).ToString(); } PubGlobal.Cur_Sale_PayTotal += decimal.Parse(tSalSalePay.SSTOTAL); ShowPayInfo(); } }