Esempio n. 1
0
        /// <summary>
        /// 保存卡片与卡片事件信息(用于停车场产生事件时更新卡片状态并保存事件)
        /// </summary>
        /// <param name="card"></param>
        /// <param name="report"></param>
        /// <returns></returns>
        public CommandResult SaveCardAndEvent(CardInfo card, CardEventReport report)
        {
            IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri);

            if (card.CardType == CardType.Ticket && report.IsExitEvent)  ////纸票出场后将其删除
            {
                _Provider.Delete(card, unitWork);
            }
            else
            {
                CardInfo info = card.Clone();
                //卡片状态保持用数据库中的状态
                info.ParkingStatus = report.ParkingStatus;
                info.LastDateTime  = report.EventDateTime;
                info.LastEntrance  = report.EntranceID;
                info.LastCarPlate  = report.CarPlate;
                if (report.LimitationRemain != info.LimitationRemain)
                {
                    info.LimitationRemain    = report.LimitationRemain;
                    info.LimitationTimestamp = report.EventDateTime;
                }
                //入口刷卡事件时,将缴费时间,停车费用,累计停车费用清空
                if (!report.IsExitEvent)
                {
                    info.ClearPaidData();
                }
                _Provider.Update(info, card, unitWork);
            }
            ICardEventProvider icp = ProviderFactory.Create <ICardEventProvider>(_RepoUri);

            icp.Insert((new CardEventRecord(report)), unitWork);

            if (report.IsExitEvent && report.Limitation > 0) //出场事件且有限时停车的记录才要记录到上传表中。
            {
                ECardRecord ecr = new ECardRecord()
                {
                    SheetID          = card.SheetID,
                    Carplate         = report.CarPlate,
                    CardID           = report.CardID,
                    EventDt          = report.EventDateTime,
                    EnterDt          = report.LastDateTime,
                    Limitation       = report.Limitation,
                    LimitationRemain = report.LimitationRemain
                };
                IECardRecordProvider iecr = ProviderFactory.Create <IECardRecordProvider>(_RepoUri);
                iecr.Insert(ecr, unitWork);
            }
            CommandResult ret = unitWork.Commit();

            if (ret.Result == ResultCode.Successful) //如果成功,则改变卡片状态
            {
                //卡片状态保持用数据库中的状态
                card.ParkingStatus    = report.ParkingStatus;
                card.LastDateTime     = report.EventDateTime;
                card.LastEntrance     = report.EntranceID;
                card.LastCarPlate     = report.CarPlate;
                card.LimitationRemain = report.LimitationRemain;
                //入口刷卡事件时,将缴费时间,停车费用,累计停车费用清空
                if (!report.IsExitEvent)
                {
                    card.ClearPaidData();
                }
            }
            return(ret);
        }
Esempio n. 2
0
        private void btnRepay_Click(object sender, EventArgs e)
        {
            if (_cardInfo != null)
            {
                if (_cardInfo.LastPayment != null)
                {
                    if (_cardInfo.LastPayment.SettleDateTime == null)
                    {
                        bool hadCard = true;
                        //写卡模式时,需要删除卡片内的缴费数据,重新写入缴费数据
                        if (AppSettings.CurrentSetting.EnableWriteCard && !_cardInfo.OnlineHandleWhenOfflineMode)
                        {
                            hadCard = CardOperationManager.Instance.CheckCard(_cardInfo.CardID) == CardOperationResultCode.Success;
                            if (!hadCard)
                            {
                                if (MessageBox.Show(Resource1.FrmCardCenterCharge_NotCard, Resource1.Form_Query,
                                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                                {
                                    return;
                                }
                            }
                        }
                        if (MessageBox.Show(Resource1.FrmCardPaying_CancelPaymentQuey, Resource1.Form_Query,
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                        {
                            //CardPaymentRecordBll cprbll = new CardPaymentRecordBll(AppSettings.CurrentSetting.ParkConnect);
                            //CommandResult result = cprbll.Delete(_cardInfo.LastPayment);
                            CommandResult result = _CardBll.DeleteLastPayment(_cardInfo);
                            if (result.Result == ResultCode.Successful)
                            {
                                AlarmInfo alarm = new AlarmInfo();
                                alarm.AlarmDateTime = DateTime.Now;
                                alarm.AlarmType     = AlarmType.CancelCardPayment;
                                alarm.OperatorID    = OperatorInfo.CurrentOperator.OperatorName;
                                alarm.AlarmDescr    = string.Format(Resource1.FrmCardPaying_CancelPaymentAlarm, _cardInfo.LastPayment.CardID,
                                                                    _cardInfo.LastPayment.ChargeDateTime.ToString("yyyy-MM-dd HH:mm:ss"), _cardInfo.LastPayment.EnterDateTime.Value.ToString("yyyy-MM-dd HH;mm:ss"),
                                                                    _cardInfo.LastPayment.Accounts);
                                (new AlarmBll(AppSettings.CurrentSetting.ParkConnect)).Insert(alarm);

                                //写卡模式时,需要删除卡片内的缴费数据,重新写入缴费数据
                                if (hadCard &&
                                    AppSettings.CurrentSetting.EnableWriteCard &&
                                    !_cardInfo.OnlineHandleWhenOfflineMode)
                                {
                                    CardOperationManager.Instance.WriteCardLoop(_cardInfo);
                                }
                                ReadCardIDHandler(_cardInfo.CardID, _cardInfo);
                            }
                            else
                            {
                                MessageBox.Show(result.Message);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(Resource1.FrmCenterCharge_RecordHandled, Resource1.Form_Alert);
                    }
                }
                else if (_cardInfo.IsCompletedPaid)
                {
                    //如果卡片有缴费信息,但数据库没有缴费记录,可清除卡片的缴费记录
                    if (MessageBox.Show(Resource1.FrmCardCenterCharge_DeletePayment, Resource1.Form_Query,
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                    {
                        CardInfo info = _cardInfo.Clone();
                        info.ClearPaidData();
                        CommandResult result = _CardBll.UpdateCard(info);
                        if (result.Result == ResultCode.Successful)
                        {
                            //写卡模式并且不按在线处理时,需写入卡片
                            if (AppSettings.CurrentSetting.EnableWriteCard && !_cardInfo.OnlineHandleWhenOfflineMode)
                            {
                                CardOperationManager.Instance.WriteCardLoop(info);
                            }
                            _cardInfo.ClearPaidData();
                            ReadCardIDHandler(_cardInfo.CardID, _cardInfo);
                        }
                        else
                        {
                            MessageBox.Show(result.Message);
                        }
                    }
                }
            }
        }