Exemple #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!CheckInput())
            {
                return;
            }

            CardBll       bll = new CardBll(AppSettings.CurrentSetting.ParkConnect);
            CommandResult result;

            if (LossRestoreCard.Status == CardStatus.Loss)
            {
                result = bll.CardRestore(LossRestoreCard, this.txtMemo.Text, !AppSettings.CurrentSetting.EnableWriteCard);
            }
            else
            {
                if (chkPayParkFee.Checked && _ParkPayment != null)
                {
                    _ParkPayment.Paid     = txtParkFee.DecimalValue;
                    _ParkPayment.Discount = _ParkPayment.Accounts - _ParkPayment.Paid;
                    result = bll.CardLoss(LossRestoreCard, this.txtMemo.Text, txtCardCost.DecimalValue, comPaymentMode.SelectedPaymentMode, _ParkPayment);
                }
                else
                {
                    result = bll.CardLoss(LossRestoreCard, this.txtMemo.Text, txtCardCost.DecimalValue, comPaymentMode.SelectedPaymentMode);
                }
            }
            if (result.Result == ResultCode.Successful)
            {
                //写卡模式时,将卡片信息写入卡片,这里会使用循环写卡,直到成功或用户取消
                if (this.chkWriteCard.Checked)
                {
                    //恢复时才将卡片信息写入,挂失时不写入
                    if (LossRestoreCard.Status == CardStatus.Enabled)
                    {
                        CardOperationManager.Instance.WriteCardLoop(LossRestoreCard);
                    }
                }

                if (this.ItemUpdated != null)
                {
                    this.ItemUpdated(this, new ItemUpdatedEventArgs(LossRestoreCard));
                }

                if (DataBaseConnectionsManager.Current.StandbyConnected)
                {
                    //备用数据连上时,同步到备用数据库
                    bll.SyncCardToDatabaseWithoutPaymentInfo(LossRestoreCard, AppSettings.CurrentSetting.CurrentStandbyConnect);
                }

                this.Close();
            }
            else
            {
                MessageBox.Show(result.Message);
            }
        }