static void ucPayButton_threadPayFinshed(PayMethod_Config config, object sender) { PayMethod_Config m_PayConfig = config; UCPayMode2 uPayMode = (UCPayMode2)sender; //接收支付线程消息 PAY_THREAD paythread = GetPayThreadInfo(m_PayConfig.PayMethodID); if (paythread != null && paythread.PayMethodID != -1) { //支付完成 if (paythread.Succeed) { //m_PayConfig.ProcStep = paythread.ProcStep; uPayMode.PayValue = decimal.Round(paythread.PayFee, 2);//显示在控件上 uPayMode.TicketNo = paythread.TicketNo; CostFee.SetPayModeFee(m_PayConfig.PayMethodID, paythread.TicketNo, decimal.Round(paythread.PayFee, 2)); //CostFee.ChangeValue(m_UCPayModes);//测试 SetCashValue(CostFee.ChangeFee); switch (m_PayConfig.InputFrom) { case PAY_FEE_FROM.pffManualInput: //手工输入 break; case PAY_FEE_FROM.pffAutoCalculate: //自动计算支付金额 switch (paythread.ProcStep) { case PAY_PROCSTEP.ppsHandFinsed: uPayMode.btnPay.Text = "获取"; uPayMode.btnPay.Visible = true; uPayMode.btnPay.Enabled = true; break; case PAY_PROCSTEP.ppsAutoFinshed: uPayMode.btnPay.Visible = false; break; } break; default: break; } } else { MessageBox.Show("计算错误:" + paythread.LastErrorMessage); } } }
static void ucPayButton_btnPayClick(PayMethod_Config config, object sender, EventArgs e) { PayMethod_Config m_PayConfig = config; UCPayMode2 uPayMode = (UCPayMode2)sender; //接收支付线程消息 PAY_THREAD paythread = (PAY_THREAD)GetPayThreadInfo(m_PayConfig.PayMethodID).Clone(); if (paythread != null) { StartPay(ref paythread, m_PayConfig); } uPayMode.btnPay.Enabled = false; CashFocus(); }
/// <summary> /// 第二步:创建控件后开始计算支付金额 /// </summary> /// <param name="totalFee">总金额</param> /// <param name="zyDepositFee">预交金总额</param> /// <param name="_paymentCalculate">支付方式计算</param> /// <param name="_setFeeValue">显示支付金额</param> /// <param name="_defaultCash">现金项默认</param> public static void StartExecPay(decimal totalFee, decimal zyDepositFee, AsynPaymentCalculate _paymentCalculate, SetFeeValueDelegate _setFeeValue, bool _defaultCash) { CostFee.InitFee(totalFee, zyDepositFee, m_UCPayModes); UCPayMode2 change_uPayMode = m_UCPayModes.Find(x => x._config.PayMethodID == -1); change_uPayMode.PayValue = CostFee.ChangeFee;//显示找零金额 paymentCalculate = _paymentCalculate; setFeeValue = _setFeeValue; if (setFeeValue != null) { //给界面显示金额 setFeeValue(CostFee); } defaultCash = _defaultCash; if (m_PayConfigs != null) { m_PayThreads = null;//清空线程 //SetCashValue(CostFee.ChangeFee); for (int i = 0; i < m_PayConfigs.Count; i++) { PayMethod_Config m_PayConfig = m_PayConfigs[i]; //m_PayConfig.ProcStep = PAY_PROCSTEP.ppsHandFinsed;//开始 PAY_THREAD paythread = new PAY_THREAD(); //paythread.iPatType = m_PayConfig.PatientType; //paythread.iPatLstID = patListID; //paythread.FeeIDs = feeIDs; //paythread.PayType = iPatType; //paythread.SoCityNum = ""; paythread.PayMethodID = m_PayConfig.PayMethodID; paythread.InputFrom = m_PayConfig.InputFrom; //paythread.ProcStep = m_PayConfig.ProcStep; paythread.Handle = m_PayConfig.Handle; paythread.paymentCalculate = paymentCalculate; //启动后台线程开始支付 bool bSucceed = false; bSucceed = StartPay(ref paythread, m_PayConfig); if (bSucceed == false) { //执行支付失败 //m_PayConfig.ProcStep = PAY_PROCSTEP.ppsHandFinsed; } } } }
/// <summary> /// 第一步:创建支付方式对象 /// </summary> /// <param name="WorkID">医疗机构ID</param> /// <param name="flpPayCtrl">支付对象容器</param> /// <param name="iPatType">病人类型</param> /// <param name="iUseType">病人来源: 0-门诊 1-住院</param> /// <param name="totalFee">处方金额</param> /// <param name="zyDepositFee">住院预交金</param> /// <param name="_setFeeValue">回调返回金额</param> /// <returns>支付方式个数</returns> public static int InitUCPayModeControl(int WorkID, FlowLayoutPanel flpPayCtrl, int iPatType, int iUseType) { workID = WorkID; CostFee = new CostFeeStyle(); m_PayConfigs = new List <PayMethod_Config>(); m_UCPayModes = new List <UCPayMode2>(); //根据支付方式动态创建支付控件到 flpPayCtrl List <PayMethod_Config> rows = GetPatientPayMethodConfig(iPatType, (PAY_USERTYPE)iUseType); if (rows == null) { return(0); } flpPayCtrl.Controls.Clear(); flpPayCtrl.SuspendLayout(); int iTabStopIndex = 0; foreach (PayMethod_Config row in rows) { UCPayMode2 ucPayButton = new UCPayMode2(row); ucPayButton.TabIndex = iTabStopIndex++; ucPayButton.Margin = new Padding(0, 0, 0, 0); //ucPayButton.Dock = DockStyle.Top; ucPayButton.Width = flpPayCtrl.Width - 20; ucPayButton.btnPayClick += new btnPayClickEventHandler(ucPayButton_btnPayClick); ucPayButton.diPayMoneyTextChanged += new diPayMoneyTextChangedEventHandler(ucPayButton_diPayMoneyTextChanged); ucPayButton.threadPayFinshed += new threadPayFinshedEventHandler(ucPayButton_threadPayFinshed); flpPayCtrl.Controls.Add(ucPayButton); if (row.PayMethodID == -1) { ucPayButton.diPayMoney.MinValue = -1000000000; //找零可以为负数 } m_UCPayModes.Add(ucPayButton); //控件集合 PayMethod_Config config = row; config.Handle = ucPayButton.Handle; m_PayConfigs.Add(config); } flpPayCtrl.ResumeLayout(false); return(rows.Count); }
static void ucPayButton_diPayMoneyTextChanged(PayMethod_Config config, object sender, EventArgs e) { UCPayMode2 uPayMode = (UCPayMode2)sender; //找零的值不执行下面代码 if (config.PayMethodID == -1) { return; } CostFee.ChangeValue(m_UCPayModes); //其他支付方式值改变会自动触发 自动计算支付金额 与 总金额优惠自动计算 //if (config.InputFrom != PAY_FEE_FROM.pffAutoCalculate) //{ // for (int i = m_UCPayModes.Count - 1; i >= 0; i--) // { // if (m_UCPayModes[i]._config.InputFrom == PAY_FEE_FROM.pffAutoCalculate) // { // if (m_UCPayModes[i].btnPay.Visible && m_UCPayModes[i].btnPay.Enabled) // m_UCPayModes[i].btnPay.PerformClick(); // } // } //} //显示找零 UCPayMode2 change_uPayMode = m_UCPayModes.Find(x => x._config.PayMethodID == -1); change_uPayMode.PayValue = CostFee.ChangeFee;//显示找零金额 if (config.PayMethodID != 1002) { //补充支付方式数据 CostFee.SetPayModeFee(config.PayMethodID, uPayMode.TicketNo, uPayMode.PayValue); } else//更新现金支付方式1002 { CostFee.SetPayModeFee(config.PayMethodID, uPayMode.TicketNo, CostFee.CashFee); } //结算面板显示对应金额 setFeeValue(CostFee); }