示例#1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //这里先停止读卡是为了防止有些读卡器会不停读卡,在卡片操作过程中,读卡器又读到卡片,影响操作
            CardReaderManager.GetInstance(UserSetting.Current.WegenType).StopReadCard();
            try
            {
                ReleasingCard = this.ucCard1.Card;
                if (ReleasingCard != null)
                {
                    if (CheckInput())
                    {
                        if (txtRecieveMoney.DecimalValue <= 0)
                        {
                            if (MessageBox.Show(Resources.Resource1.FrmCardPaying_MoneyLittleQuery, Resources.Resource1.Form_Alert,
                                                MessageBoxButtons.YesNo) == DialogResult.No)
                            {
                                CardReaderManager.GetInstance(UserSetting.Current.WegenType).BeginReadCard();
                                return;
                            }
                        }

                        CardBll       bll    = new CardBll(AppSettings.CurrentSetting.ParkConnect);
                        CommandResult result = null;
                        if (ReleasingCard.ListType == CardListType.Card)
                        {
                            result = bll.CardRelease(ReleasingCard, txtRecieveMoney.DecimalValue, comPaymentMode.SelectedPaymentMode, txtMemo.Text.Trim());
                        }
                        else
                        {
                            //发行车牌名单,生成卡号最多重试10次
                            result = bll.CarPlateRelease(ReleasingCard, txtRecieveMoney.DecimalValue, comPaymentMode.SelectedPaymentMode, txtMemo.Text.Trim(), 10);
                        }
                        if (result.Result == ResultCode.Successful)
                        {
                            //写卡模式时,将卡片信息写入卡片,这里会使用循环写卡,直到成功或用户取消
                            if (this.chkWriteCard.Checked)
                            {
                                CardOperationManager.Instance.WriteCardLoop(ReleasingCard);
                            }

                            if (!_isAdding)
                            {
                                if (ItemUpdated != null)
                                {
                                    ItemUpdated(this, new ItemUpdatedEventArgs(ReleasingCard));
                                }
                            }
                            else
                            {
                                if (ItemAdded != null)
                                {
                                    ItemAdded(this, new ItemAddedEventArgs(ReleasingCard));
                                }
                            }
                            this.ucCard1.Clear();
                            this.txtRecieveMoney.DecimalValue = 0;

                            if (DataBaseConnectionsManager.Current.StandbyConnected)
                            {
                                //备用数据连上时,同步到备用数据库
                                bll.SyncCardToDatabaseWithoutPaymentInfo(ReleasingCard, AppSettings.CurrentSetting.CurrentStandbyConnect);
                            }
                        }
                        else
                        {
                            MessageBox.Show(result.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            CardReaderManager.GetInstance(UserSetting.Current.WegenType).BeginReadCard();
        }