private void lblCashStored_Click(object sender, EventArgs e)
        {
            btnEnd.Enabled = false;
            WaitDialogForm form = new WaitDialogForm("正在存钞中,请稍候...", "正在组织数据,请稍候......", new Size(240, 60));

            try
            {
                MoneyServer.NotAllowCashin();

                //拍照,纸币器
                switch (AutoHostConfig.ReadCardType)
                {
                case "XUHUI":
                    AutoServiceSDK.SdkService.Common_XH camera = new AutoServiceSDK.SdkService.Common_XH();
                    camera.TakeCameraEnd();
                    camera.DoorLightClose(LightTypeenum.纸币器);
                    break;

                default:
                    break;
                }

                timer2.Stop();
                timer1.Stop();

                #region 休眠3秒以后重新获取纸币金额
                Thread.Sleep(5000);
                Skynet.LoggingService.LogService.GlobalInfoMessage("在结束预存之后休眠2秒重新获取存钞明细");
                int InMoney = MoneyServer.GetInMoney(AutoHostConfig.Machineno, SysOperatorInfo.OperatorID);
                Skynet.LoggingService.LogService.GlobalInfoMessage("在结束预存之后重新获取存钞明细金额:" + InMoney);
                if (InMoney > 0)
                {
                    //投入数量
                    int intOld = Convert.ToInt32(lblAmount.Text) + 1;
                    lblAmount.Text = intOld.ToString();

                    //投入金额
                    RechargeMoney += Convert.ToDecimal(InMoney);
                    RechargeMoney  = DecimalRound.Round(RechargeMoney, 2);
                    lblMoney.Text  = RechargeMoney.ToString();
                }
                #endregion

                if (RechargeMoney == 0)
                {
                    btnClose_Click(null, null);
                    return;
                }

                lblNoPaymentCharge.Enabled = true;
                ucTime1.timer1.Stop();
                if (eCardSavingFacade == null)
                {
                    eCardSavingFacade = new CardSavingFacade();
                }
                if (eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows.Count <= 0)
                {
                    MyAlert frm = new MyAlert(AlertTypeenum.信息, "此操作没有找到所要充值的卡信息!");
                    frm.ShowDialog();
                    return;
                }
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0].BeginEdit();
                //卡号
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_CARDID] = SkyComm.cardInfoStruct.CardNo;
                //充值时间
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_OPERATETIME] = new CommonFacade().GetServerDateTime();
                ////操作员
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_OPERATOR] = SysOperatorInfo.OperatorID;
                ////充值类型
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_SAVINGMODE] = 1;
                ////Add money

                Skynet.LoggingService.LogService.GlobalInfoMessage("现金发卡保存数据设置押金之前");
                if (CallType == 2)
                {
                    Decimal deposit = Convert.ToDecimal(SkyComm.getvalue("发卡工本费"));
                    eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_ADDMONEY] = RechargeMoney - Convert.ToDecimal(SkyComm.dsCardType.Tables[0].Rows[0]["FEES"]) - deposit;
                }
                else
                {
                    eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_ADDMONEY] = RechargeMoney;
                }
                Skynet.LoggingService.LogService.GlobalInfoMessage("现金发卡保存数据设置押金之后");
                //业务类型
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_BUSSNESSTYPE] = "充值";
                //支付方式
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_MODETYPE] = SkyComm.AddMoneyCashMode;
                //单位
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_UNIT] = "";
                //支票号
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_CHECKLOT] = "";

                //充值数据来源
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_ADDMONEYSOURCE] = AutoHostConfig.BankName;

                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0].EndEdit();

                ReckonAccountTimeFacade reckonAccountsTimeFacade = new ReckonAccountTimeFacade();
                DateTime accountTime = reckonAccountsTimeFacade.GetEndTime(SysOperatorInfo.OperatorID, "门诊");
                if (Convert.ToDateTime(eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_OPERATETIME]) < accountTime)
                {
                    SkyComm.ShowMessageInfo("该时间段已经结帐,不能办理预交金业务,请重试!");
                    return;
                }

                DataSet cardSavingData = eCardSavingFacade.insertEntity(eCardAuthorizationData);
                SkyComm.GetCardBalance();
                Skynet.LoggingService.LogService.GlobalInfoMessage("充值成功,调用类型:" + CallType);
                Savingsucceed = 1;
                if (CallType != 2)
                {
                    //打印充值凭证
                    PrintInfo("自助充值凭证", cardSavingData.Tables[0].Rows[0]["TRANSACTION_ID"].ToString(), RechargeMoney.ToString());
                }
            }
            catch (Exception ex)
            {
                SkyComm.ShowMessageInfo("存钞失败:" + ex.Message);
                Skynet.LoggingService.LogService.GlobalInfoMessage("存钞失败:" + ex.Message);
            }
            finally
            {
                MoneyServer.ClosePort();
                form.Close();
                form.Dispose();

                btnEnd.Enabled = true;
            }

            Skynet.LoggingService.LogService.GlobalInfoMessage("充值成功,调用类型:" + CallType);
            if (CallType == 0)
            {
                FrmRechargeSuccessful frmRecharge = new FrmRechargeSuccessful();
                frmRecharge.RechargeMoney = RechargeMoney;
                frmRecharge.ShowDialog(this);
                frmRecharge.Dispose();
                SkyComm.CloseWin(this);
            }
            else if (CallType == 2)
            {
                SkyComm.CloseWin(this);
            }
            else
            {
                SkyComm.ShowMessageInfo("您成功充值" + RechargeMoney + "元!卡中余额" + SkyComm.cardBlance.ToString() + "");
                SkyComm.CloseWin(this);
            }
            //GetMoeny();
        }
Ejemplo n.º 2
0
        private void btnApliPay_Click(object sender, EventArgs e)
        {
            this.ucTime1.timer1.Stop();

            if (string.IsNullOrEmpty(SkyComm.cardInfoStruct.CardNo))
            {
                FrmMain frmM = new FrmMain();

                int intResult = SkyComm.ReadCard("支付宝预存");

                if (intResult == 0)
                {
                    this.ucTime1.timer1.Start();
                    return;
                }
            }

            //            FrmChooseMoney mChooseMoneyFrm = new FrmChooseMoney();
            FrmMoneyInput mChooseMoneyFrm = new FrmMoneyInput();

            if (mChooseMoneyFrm.ShowDialog() == DialogResult.OK)//确认了金额
            {
                //                decimal mChooseMoney = mChooseMoneyFrm.ChooseMoney;//所选金额
                string  mMoney       = mChooseMoneyFrm.inputMoney.ToString() + ".00";
                decimal mChooseMoney = Math.Round(Convert.ToDecimal(mMoney), 2);//所选金额

                if (!string.IsNullOrEmpty(SkyComm.getvalue("微信交易测试")))
                {
                    mChooseMoney = Math.Round(Convert.ToDecimal("0.01"), 2);//所选金额
                }

                FrmNetPay payFrm = new FrmNetPay();

                payFrm.PayMoney = mChooseMoney;

                payFrm.ServiceType = serviceType;

                payFrm.PayMethod = "2";//支付宝

                switch (CallType)
                {
                case 0:
                    payFrm.PayType = "充值";
                    break;

                case 1:
                    payFrm.PayType = "缴费";
                    break;

                case 2:
                    payFrm.PayType = "办卡";
                    break;

                default:
                    payFrm.PayType = "";
                    break;
                }

                DialogResult mDialogResult = payFrm.ShowDialog();

                if (mDialogResult == DialogResult.OK)
                {
                    Savingsucceed = 1;
                    RechargeMoney = mChooseMoney;
                    //                    SkyComm.ShowMessageInfo(payFrm.PayType + "成功!");

                    FrmRechargeSuccessful frmRecharge = new FrmRechargeSuccessful();
                    frmRecharge.RechargeMoney = mChooseMoney;
                    frmRecharge.ShowDialog(this);
                    frmRecharge.Dispose();
                }
                else
                {
                    this.ucTime1.timer1.Start();//计时器动
                }
            }
            else
            {
                this.ucTime1.timer1.Start();//计时器动
            }
        }
        private void Saving(decimal money)
        {
            if (eCardSavingFacade == null)
            {
                eCardSavingFacade = new CardSavingFacade();
            }

            if (SkyComm.eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows.Count <= 0)
            {
                MyAlert frm = new MyAlert(AlertTypeenum.信息, "此操作没有找到所要充值的卡信息!");
                frm.ShowDialog();
                return;
            }

            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0].BeginEdit();
            //卡号
            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_CARDID] = SkyComm.cardInfoStruct.CardNo;
            //充值时间
            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_OPERATETIME] = new CommonFacade().GetServerDateTime();
            ////操作员
            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_OPERATOR] = SysOperatorInfo.OperatorID;
            ////充值类型
            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_SAVINGMODE] = 1;

            Skynet.LoggingService.LogService.GlobalInfoMessage("发卡保存数据设置押金之前");
            ////Add money
            if (CallType == 2)
            {
                Decimal deposit = Convert.ToDecimal(SkyComm.getvalue("发卡工本费"));
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_ADDMONEY] = money - Convert.ToDecimal(SkyComm.dsCardType.Tables[0].Rows[0]["FEES"]) - deposit;
            }
            else
            {
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_ADDMONEY] = money;  //此处需调接口
            }
            Skynet.LoggingService.LogService.GlobalInfoMessage("发卡保存数据设置押金之后");
            //业务类型
            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_BUSSNESSTYPE] = "充值";
            //支付方式
            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_MODETYPE] = SkyComm.AddMoneyPosMode;
            //单位
            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_UNIT] = "";
            //支票号
            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_CHECKLOT] = "";

            //充值数据来源
            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_ADDMONEYSOURCE] = AutoHostConfig.BankName;

            eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0].EndEdit();

            ReckonAccountTimeFacade reckonAccountsTimeFacade = new ReckonAccountTimeFacade();
            DateTime accountTime = reckonAccountsTimeFacade.GetEndTime(SysOperatorInfo.OperatorID, "门诊");

            if (Convert.ToDateTime(eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_OPERATETIME]) < accountTime)
            {
                SkyComm.ShowMessageInfo("该时间段已经结帐,不能办理预交金业务,请重试!");
                return;
            }
            DataSet cardSavingData = new DataSet();
            POSBase Posfac         = IPOSFactory.CreateIPOS(AutoHostConfig.PosInterfaceType);

            if (Posfac == null)
            {
                SkyComm.ShowMessageInfo("银联POS接口配置不正确,请与管理员联系!");
                return;
            }
            ValidateCode vc       = new ValidateCode();
            string       HisSeqNo = string.Empty;

            HisSeqNo = DateTime.Now.ToString("yyMMddHHmmss") + SysOperatorInfo.OperatorID + vc.GenValidateCode(4);
            Hashtable BankTranht = new Hashtable();

            BankTranht.Add("SEQNO", HisSeqNo);
            BankTranht.Add("MONEY", money);
            BankTranht.Add("OPERATORID", SysOperatorInfo.OperatorCode);
            BankTranht.Add("POSNO", AutoHostConfig.PosNo);
            BankTranht.Add("DIAGNOSEID", SkyComm.DiagnoseID);
            BankTranht.Add("CARDID", SkyComm.cardInfoStruct.CardNo);
            Posfac.Trans("1", BankTranht);
            if (BankTranht["CARDNO"] != null)
            {
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_CHECKLOT]    = BankTranht["CARDNO"].ToString();
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_BANKCARDNO]  = BankTranht["CARDNO"].ToString();
                eCardAuthorizationData.Tables["T_CARD_AUTHORIZATION"].Rows[0][CardAuthorizationData.T_CARD_AUTHORIZATION_BANKTRANSNO] = BankTranht["BANKSEQNO"].ToString();
            }

            try
            {
                //if (SkynetMessage.MsgInfo("是否要充值成功?", true) == false)
                //{
                //    throw new Exception("操作操作测试放弃充值!");
                //}
                cardSavingData = eCardSavingFacade.insertEntity(eCardAuthorizationData);
                Posfac.Trans("2", BankTranht);
                Savingsucceed = 1;
            }
            catch (Exception ex)
            {
                Skynet.LoggingService.LogService.GlobalInfoMessage("POS接口调用成功,HIS保存失败:" + ex.Message + "\r\n开始调用撤消方法");
                SkynetMessage.MsgInfo("HIS充值失败,需要撤消银行交易,请按POS机提示操作!");
                Posfac.Trans("-2", BankTranht);
                Skynet.LoggingService.LogService.GlobalInfoMessage("POS接口调用成功,HIS失败,调用银行撤消完成!");
                //SkynetMessage.MsgInfo("HIS充值失败:"+ex.Message);
                return;
            }
            SkyComm.GetCardBalance();

            if (CallType != 2)
            {
                //打印充值凭证
                PrintInfo("自助充值凭证", cardSavingData.Tables[0].Rows[0]["TRANSACTION_ID"].ToString(), money.ToString());

                if (CallType == 0)
                {
                    FrmRechargeSuccessful frmRecharge = new FrmRechargeSuccessful();
                    frmRecharge.RechargeMoney = money;
                    frmRecharge.ShowDialog(this);
                    frmRecharge.Dispose();
                    SkyComm.CloseWin(this);
                }
                else
                {
                    SkyComm.ShowMessageInfo("您成功充值" + money + "元!卡中余额" + SkyComm.cardBlance.ToString() + "");
                    SkyComm.CloseWin(this);
                }
            }
            else
            {
                DialogResult = System.Windows.Forms.DialogResult.OK;
                SkyComm.CloseWin(this);
            }
            //GetMoeny();
        }