Example #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            switch (_curStep)
            {
            case step_welcome:
                _curStep++;
                break;

            case step_input:
                if (CheckInput())
                {
                    _curStep++;
                }
                break;

            case step_readCard:
                _curStep++;
                break;

            case step_excute:
                List <CardInfo> cards = cardView.CardSource;
                if (cards != null && cards.Count > 0)
                {
                    CardBll bll = new CardBll(AppSettings.CurrentSetting.ParkConnect);
                    this.progressBar1.Maximum = cards.Count;
                    this.progressBar1.Value   = 0;
                    //bool download = true;
                    foreach (CardInfo card in cards)
                    {
                        CommandResult ret = null;
                        if (card.Status == CardStatus.Enabled)
                        {
                            ret = bll.CardRelease(card, 0, PaymentMode.Cash, string.Empty);
                        }
                        else
                        {
                            ret = bll.AddCard(card);
                        }
                        if (ret.Result == ResultCode.Successful)
                        {
                            this.CardAdded(this, new ItemAddedEventArgs(card));
                        }
                        progressBar1.Value++;
                        lblStatus.Text = string.Format(Resources.Resource1.FrmAddCards_Processing,
                                                       progressBar1.Value, progressBar1.Maximum);
                        lblStatus.Refresh();
                    }
                }
                lblAlarm.Text = string.Format(Resources.Resource1.FrmAddCards_CardCount, 0);
                _curStep++;
                break;

            case step_recycle:
                _curStep = step_welcome;
                InitCardGrid();
                this.progressBar1.Value = 0;
                break;
            }
            ShowNextStep(_curStep);
        }
Example #2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            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)
                        {
                            return;
                        }
                    }

                    CardBll       bll    = new CardBll(AppSettings.CurrentSetting.ParkConnect);
                    CommandResult result = bll.CardRelease(ReleasingCard, txtRecieveMoney.DecimalValue, comPaymentMode.SelectedPaymentMode, txtMemo.Text.Trim());
                    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);
                    }
                }
            }
        }
Example #3
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();
        }