/// <summary> /// 保存卡片以及嵌套车场进出事件 /// </summary> /// <param name="card"></param> /// <param name="report"></param> /// <returns></returns> public CommandResult SaveCardAndNestedEvent(CardInfo card, CardEventReport report) { //内嵌车场事件只改变卡片的停车状态 IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); CardInfo info = card.Clone(); //卡片状态保持用数据库中的状态 info.ParkingStatus = report.ParkingStatus; if (!report.IsExitEvent) { info.LastNestParkDateTime = report.EventDateTime; //如果是入场事件,则更新卡片的最后进入内车场时间 } _Provider.Update(info, card, unitWork); ICardEventProvider icp = ProviderFactory.Create <ICardEventProvider>(_RepoUri); if (report.IsExitEvent) //如果是入内车场,则不记录最后刷卡时间,如果是出内车场,则保存上次时间 { report.LastDateTime = card.LastNestParkDateTime; } else { report.LastDateTime = null; } icp.Insert((new CardEventRecord(report)), unitWork); CommandResult ret = unitWork.Commit(); if (ret.Result == ResultCode.Successful) //如果成功,则改变卡片状态 { //卡片状态保持用数据库中的状态 card.ParkingStatus = report.ParkingStatus; } return(ret); }
///// <summary> ///// 脱机模式时按在线模式处理的检验 ///// </summary> ///// <param name="card"></param> ///// <param name="msg"></param> ///// <returns></returns> //private bool OnlineHandleWhenOfflineModeCheck(CardInfo card, out string msg) //{ // if (AppSettings.CurrentSetting.EnableWriteCard // && !card.OnlineHandleWhenOfflineMode)//脱机模式时,按脱机模式处理 // { // if (!DataBaseConnectionsManager.Current.BothCconnectedOrNoStandby) // { // msg = "与主数据库或备用数据库连接失败!"; // return false; // } // if (DataBaseConnectionsManager.Current.StandbyConnected) // { // //与备用数据库连接上时,检查主数据库与备用数据库的数据是否一致 // CardBll scbll = new CardBll(AppSettings.CurrentSetting.CurrentStandbyConnect); // CardInfo scard = scbll.GetCardByID(card.CardID).QueryObject; // if (scard == null // || scard.ParkingStatus != card.ParkingStatus //停车状态 // || scard.LastDateTime != card.LastDateTime //最近一次刷卡时间 // ||scard.PaidDateTime!=card.PaidDateTime //缴费时间 // ||scard.TotalPaidFee!=card.TotalPaidFee) //已缴费用 // { // msg = "主数据库与备用数据库信息不一致!"; // return false; // } // } // } // msg = string.Empty; // return true; //} /// <summary> /// 获取卡片详细信息 /// </summary> /// <param name="offlineHandleCard">是否脱机处理的卡片</param> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> /// <param name="card">返回的卡片</param> /// <param name="msg">返回的错误信息</param> /// <returns></returns> private bool GetCardDetail(bool offlineHandleCard, string cardID, CardInfo info, out CardInfo card, out string msg) { card = null; if (DataBaseConnectionsManager.Current.MasterConnected || DataBaseConnectionsManager.Current.StandbyConnected) { CardInfo mastercard = null; CardInfo standbycard = null; if (DataBaseConnectionsManager.Current.MasterConnected) { CardBll mcbll = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); mastercard = mcbll.GetCardDetail(cardID); } if (DataBaseConnectionsManager.Current.StandbyConnected) { //需要获取备用数据库的卡片信息进行比对 //通信工作站如果没有连接上主数据库,需要从备用数据库中获取卡片信息 CardBll scbll = new CardBll(AppSettings.CurrentSetting.CurrentStandbyConnect); standbycard = scbll.GetCardDetail(cardID); } //在线处理的卡片,主数据库连上,有备份数据库的,需要与获取备用数据库的卡片信息进行比对 if (!offlineHandleCard && DataBaseConnectionsManager.Current.MasterConnected && WorkStationInfo.CurrentStation.HasStandbyDatabase) { if (mastercard == null && standbycard == null) { //没有该卡片 } else if (mastercard == null || standbycard == null || !mastercard.CompareChargeInfo(standbycard)) { msg = "主数据库与备用数据库信息不一致!"; return(false); } } if (mastercard != null) { card = mastercard; } else if (WorkStationInfo.CurrentStation.IsHostWorkstation || offlineHandleCard) { card = standbycard; } } else if (offlineHandleCard) { //与主数据库和备用连接断开时,如果是脱机处理的卡片,获取的为读到的卡片信息 card = info.Clone(); } msg = string.Empty; return(true); }
public override CardInfo_Equip GetCurrentCardInfo() { CardInfo_Equip currentCI = (CardInfo_Equip)CardInfo.Clone(); currentCI.ShieldInfo.Armor = M_ShieldArmor; currentCI.ShieldInfo.Shield = M_ShieldShield; return(currentCI); }
public override CardInfo_Equip GetCurrentCardInfo() { CardInfo_Equip currentCI = (CardInfo_Equip)CardInfo.Clone(); currentCI.WeaponInfo.Attack = M_WeaponAttack; currentCI.WeaponInfo.Energy = M_WeaponEnergy; currentCI.WeaponInfo.EnergyMax = M_WeaponEnergyMax; return(currentCI); }
private void btnCardOk_Click(object sender, EventArgs e) { if (_processingEvent != null) { if (_processingEvent.CardType.IsPrepayCard && txtPaid.DecimalValue <= _processingEvent.Balance) //储值卡且实收小于或等于余额,则只是扣除余额 { if (CheckWriteCard()) { CommandResult result = SaveCardPayment(_processingEvent.CardPaymentInfo, PaymentMode.Prepay); if (result.Result != ResultCode.Successful) { MessageBox.Show(result.Message); return; } } else { return; } } else if (_processingEvent.IsExitEvent && UserSetting.Current.OneKeyOpenDoor) //如果启用一键开闸,则按卡片有效按钮时先要保存卡片费用明细 { if (!btnCashHandle()) { return; } } if (!_processingEvent.ChargeAsTempCard) { //写卡模式并且不是按在线模式处理时需要写入卡片已出场 if (AppSettings.CurrentSetting.EnableWriteCard && _cardInfo != null && !_processingEvent.OnlineHandleWhenOfflineMode) { _cardInfo.IsInPark = false;//标记已出场 CardOperationManager.Instance.WriteCardLoop(_cardInfo); } } EventValidNotify n = new EventValidNotify(_processingEvent.EntranceID, OperatorInfo.CurrentOperator, WorkStationInfo.CurrentStation.StationName, this.txtPaid.DecimalValue); if (ParkingAdapterManager.Instance[_processingEvent.ParkID] != null) { ParkingAdapterManager.Instance[_processingEvent.ParkID].EventValid(n); } if (_cardInfo != null) { CardInfo cardclone = _cardInfo.Clone(); ClearCardEvent(); _cardInfo = cardclone; } else { ClearCardEvent(); } } }
private CardInfo _OriginalCard; //卡片原始信息 #region 私有方法 /// <summary> /// 读取到卡号处理 /// </summary> /// <param name="cardID">卡号</param> /// <param name="info">从卡片扇区数据中读取到的卡片信息</param> private void ReadCardIDHandler(string cardID, CardInfo info) { txtCardID.TextChanged -= txtCardID_TextChanged; this.txtCardID.Text = cardID; this.txtCardID.ReadOnly = true; string msg = string.Empty; bool offlineHandleCard = AppSettings.CurrentSetting.EnableWriteCard && info != null && !info.OnlineHandleWhenOfflineMode; CardBll bll = new CardBll(AppSettings.CurrentSetting.CurrentMasterConnect); //如果只是免费授权,卡片信息只要从主数据库获取就可以了 CardInfo card = bll.GetCardDetail(cardID); if (card == null && offlineHandleCard) { card = info.Clone(); } if (!WorkStationInfo.CurrentStation.CanFreeAuthorization(offlineHandleCard, out msg)) { //该工作站不能进行授权 } else if (card == null) { msg = CardInvalidDescripition.GetDescription(EventInvalidType.INV_UnRegister); } else if (AppSettings.CurrentSetting.EnableWriteCard && !card.OnlineHandleWhenOfflineMode && !CardDateResolver.Instance.CopyPaidDataToCard(card, info))//只复制缴费相关的信息,如果复制了所有的信息,会覆盖数据库内的卡片状态,如挂失,禁用等状态 //&& !CardDateResolver.Instance.CopyCardDataToCard(card, info)) { //写卡模式时,卡片信息从扇区数据中获取 msg = Resource1.FrmCardCenterCharge_CardDataErr; } else if (!ValidateCard(card, out msg)) { //卡片无效 } else { _cardInfo = card; _OriginalCard = card.Clone(); ShowCardInfo(_cardInfo); } if (!string.IsNullOrEmpty(msg)) { if (AppSettings.CurrentSetting.EnableTTS) { TTSSpeech.Instance.Speek(msg); } ClearInput(); this.txtCardID.Text = cardID; MessageBox.Show(msg); } txtCardID.TextChanged += txtCardID_TextChanged; }
private void btnOK_Click(object sender, EventArgs e) { if (_ChargeRecord == null) { return; } decimal paid = 0; try { paid = decimal.Parse(txtPaid.Text); if (paid > _ChargeRecord.Accounts) { MessageBox.Show("实收金额不能大于应收金额"); return; } } catch { MessageBox.Show("输入的实收金额不是有效的数字"); return; } CardInfo card = _Card.Clone(); //先保存一个克隆版 _ChargeRecord.Paid = paid; _ChargeRecord.Discount = _ChargeRecord.Accounts - paid; _ChargeRecord.Operator = OperatorInfo.CurrentOperator.OperatorName; string appPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); string mdf = Path.Combine(appPath, "Record.txt"); //初始化所有配置参数 CardPaymentInfoProvider provider = new CardPaymentInfoProvider(); bool ret = provider.Add(_ChargeRecord); //保存数据 if (ret) { card.SetPaidData(_ChargeRecord); //更新卡片状态 FrmCardWrite frm = new FrmCardWrite(); frm.Location = new Point(0, this.btnOK.Top - 10); frm.Card = card; frm.CardReader = _CardReader; if (frm.ShowDialog() == DialogResult.OK) { provider.SaveToFile(_ChargeRecord, mdf); Clear(); } else //// 写卡不成功,将保存的数据删除 { provider.Delete(_ChargeRecord); } } }
/// <summary> /// 收取卡片的停车费 /// </summary> /// <param name="info">缴费卡片,为空值时从数据库中获取,主要用于写卡模式时读取到卡片的数据</param> /// <param name="payment">缴费记录</param> /// <returns></returns> public CommandResult PayParkFee(CardInfo info, CardPaymentInfo payment) { CardInfo original = GetCardByID(payment.CardID).QueryObject; if (original != null) { CardInfo card = original.Clone(); if (info != null) { //复制卡片缴费信息 CardDateResolver.Instance.CopyPaidDataToCard(card, info); } IUnitWork uw = ProviderFactory.Create <IUnitWork>(_RepoUri); if (payment.PaymentMode == PaymentMode.Prepay) { card.Balance -= payment.Paid; } //只有卡片在场或可重复出场,并且与缴费记录的进场时间相同,才会更新卡片信息 if ((card.IsInPark || card.CanRepeatOut) && payment.EnterDateTime.HasValue && card.LastDateTime == payment.EnterDateTime.Value) { //设置卡片缴费信息 card.SetPaidData(payment); _Provider.Update(card, original, uw); } (ProviderFactory.Create <ICardPaymentRecordProvider>(_RepoUri)).Insert(payment, uw); CommandResult result = uw.Commit(); if (result.Result == ResultCode.Successful && info != null) { //修改卡片实体类信息 CardDateResolver.Instance.CopyPaidDataToCard(info, card); //info.Balance = card.Balance; //info.ParkingStatus = card.ParkingStatus; //info.ParkFee = card.ParkFee; //info.PaidDateTime = card.PaidDateTime; //info.TotalFee = card.TotalFee; } return(result); } return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); }
/// <summary> /// 卡片挂失,除了收取了卡片工本费还收取了卡片在场内的停车费用,并把卡片置为出场 /// </summary> /// <param name="info"></param> /// <param name="reason"></param> /// <param name="lostCardCost"></param> /// <param name="paymode"></param> /// <param name="parkFee"></param> /// <returns></returns> public CommandResult CardLoss(CardInfo info, string reason, decimal lostCardCost, PaymentMode paymode, CardPaymentInfo parkFee) { string op = OperatorInfo.CurrentOperator.OperatorName; string station = WorkStationInfo.CurrentStation.StationName; IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); CardLostRestoreRecord record = new CardLostRestoreRecord { CardID = info.CardID, OwnerName = info.OwnerName, CardCertificate = info.CardCertificate, CarPlate = info.CarPlate, CardStatus = (byte)info.Status, //保存卡片的原有卡状态 LostDateTime = DateTime.Now, LostOperator = op, LostStation = station, LostMemo = reason, LostCardCost = lostCardCost, PaymentMode = paymode }; ICardLostRestoreRecordProvider lostProvider = ProviderFactory.Create <ICardLostRestoreRecordProvider>(_RepoUri); lostProvider.Insert(record, unitWork); if (parkFee != null) { parkFee.OperatorID = op; parkFee.StationID = station; parkFee.PaymentMode = paymode; parkFee.Memo = "卡片挂失"; ICardPaymentRecordProvider icpp = ProviderFactory.Create <ICardPaymentRecordProvider>(_RepoUri); icpp.Insert(parkFee, unitWork); } //卡片置为挂失并出场 CardInfo original = info.Clone(); info.Status = CardStatus.Loss; info.ParkingStatus = ParkingStatus.Out; ICardProvider icp = ProviderFactory.Create <ICardProvider>(_RepoUri); icp.Update(info, original, unitWork); return(unitWork.Commit()); }
private void btnCancel_Click(object sender, EventArgs e) {//取消优惠的代码逻辑 if (CheckInput()) { IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(AppSettings.CurrentSetting.ParkConnect); //1.删除优惠信息表的此项数据 IPREPreferentialProvider preProvider = ProviderFactory.Create <IPREPreferentialProvider>(AppSettings.CurrentSetting.ParkConnect); preProvider.Delete(_CurrentPreInfo, unitWork); //2.将Card表的优惠时数减去 ICardProvider cardProvider = ProviderFactory.Create <ICardProvider>(AppSettings.CurrentSetting.ParkConnect); CardInfo card = cardProvider.GetByID(_CurrentPreInfo.CardID).QueryObject; CardInfo newVal = card.Clone(); newVal.DiscountHour -= _CurrentPreInfo.PreferentialHour; if (newVal.DiscountHour < 0) { newVal.DiscountHour = 0; } cardProvider.Update(newVal, card, unitWork); //3.保存优惠操作记录 IPREPreferentialLogProvider preLogProvider = ProviderFactory.Create <IPREPreferentialLogProvider>(AppSettings.CurrentSetting.ParkConnect); PREPreferentialLog log = _CurrentPreInfo.CreateLog(); log.OperatorTime = DateTime.Now; log.IsCancel = 1; log.CancelReason = this.txtCancelReason.Text.Trim(); log.WorkstationID = PRESysOptionSetting.Current.PRESysOption.CurrentWorkstationID; log.WorkstationName = PRESysOptionSetting.Current.PRESysOption.CurrentWorkstation; log.OperatorID = PREOperatorInfo.CurrentOperator.OperatorID; preLogProvider.Insert(log, unitWork); CommandResult result = unitWork.Commit(); if (result.Result == ResultCode.Successful) { MessageBox.Show("取消成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearCardInfo(); ClearInput(); btnCancel.Enabled = false; } else { MessageBox.Show(result.Message); } } }
public void CloneTest() { CardInfo card = new CardInfo(); card.CardID = "12359"; card.AccessID = 5; card.Balance = 15; card.CardType = Ralid.Park.BusinessModel.Enum.CardType.PrePayCard; card.CarType = CarTypeSetting.DefaultCarType; card.LastEntrance = 2; card.LastDateTime = new DateTime(2011, 3, 23, 12, 5, 0); card.ParkingStatus = Ralid.Park.BusinessModel.Enum.ParkingStatus.In; card.Status = Ralid.Park.BusinessModel.Enum.CardStatus.Enabled; card.CarPlate = "粤A15944"; card.Memo = "sss"; card.OwnerName = "李建华"; CardInfo clone = card.Clone(); AssertEqual(card, clone); }
private void btnOK_Click(object sender, EventArgs e) { if (CheckInput()) { PREPreferentialInfo info = GetItemFromInput(); //1.插入优惠信息 IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(AppSettings.CurrentSetting.ParkConnect); IPREPreferentialProvider preProvider = ProviderFactory.Create <IPREPreferentialProvider>(AppSettings.CurrentSetting.ParkConnect); preProvider.Insert(info, unitWork); //2.更新卡片的优惠信息 ICardProvider cardProvider = ProviderFactory.Create <ICardProvider>(AppSettings.CurrentSetting.ParkConnect); CardInfo card = cardProvider.GetByID(info.CardID).QueryObject; if (card == null) { MessageBox.Show("没有此卡片!"); return; } CardInfo newCard = card.Clone(); newCard.DiscountHour += info.PreferentialHour; newCard.PreferentialTime = info.PreferentialTime; cardProvider.Update(newCard, card, unitWork); //3.保存优惠操作记录 IPREPreferentialLogProvider logProvider = ProviderFactory.Create <IPREPreferentialLogProvider>(AppSettings.CurrentSetting.ParkConnect); PREPreferentialLog log = info.CreateLog(); log.OperatorTime = DateTime.Now; logProvider.Insert(log, unitWork); CommandResult result = unitWork.Commit(); if (result.Result == ResultCode.Successful) { MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearInput(); } else { MessageBox.Show(result.Message); } } }
private void btnCardOk_Click(object sender, EventArgs e) { if (_processingEvent != null) { if (_processingEvent.CardType.IsPrepayCard && txtPaid.DecimalValue <= _processingEvent.Balance) //储值卡且实收小于或等于余额,则只是扣除余额 { CommandResult result = SaveCardPayment(_processingEvent.CardPaymentInfo, PaymentMode.Prepay); if (result.Result != ResultCode.Successful) { MessageBox.Show(result.Message); return; } } else if (_processingEvent.IsExitEvent && UserSetting.Current.OneKeyOpenDoor) //如果启用一键开闸,则按卡片有效按钮时先要保存卡片费用明细 { if (!btnCashHandle()) { return; } } EventValidNotify n = new EventValidNotify(_processingEvent.EntranceID, OperatorInfo.CurrentOperator, WorkStationInfo.CurrentStation.StationName, this.txtPaid.DecimalValue); if (ParkingAdapterManager.Instance[_processingEvent.ParkID] != null) { ParkingAdapterManager.Instance[_processingEvent.ParkID].EventValid(n); } if (_cardInfo != null) { CardInfo cardclone = _cardInfo.Clone(); ClearCardEvent(); _cardInfo = cardclone; } else { ClearCardEvent(); } } }
/// <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); }
public override CardInfo_Equip GetCurrentCardInfo() { CardInfo_Equip currentCI = (CardInfo_Equip)CardInfo.Clone(); return(currentCI); }
private void ReadCardHandler(object sender, CardReadEventArgs args) { Action action = delegate() { CardInfo readcard = CardDateResolver.Instance.GetCardInfoFromData(args.CardID, args[GlobalVariables.ParkingSection]); foreach (DataGridViewRow row in this.dataGridView1.Rows) { bool success = false; CardInfo orginal = row.Tag as CardInfo; CardInfo card = orginal.Clone(); if (card == null) { continue; } if (this.chkHandleMode.Checked) { card.OnlineHandleWhenOfflineMode = this.rdbOnlineHandle.Checked; } if (card.CardID == args.CardID) { if (rdToCard.Checked) { if (ConvertToCard(card)) { if (this.chkHandleMode.Checked && orginal.OnlineHandleWhenOfflineMode != card.OnlineHandleWhenOfflineMode) { success = ConvertToDatabase(card); } else { success = true; } } } else if (rdToDatabase.Checked) { if (CardDateResolver.Instance.CopyCardDataToCard(card, readcard) && ConvertToDatabase(card)) { if (this.chkHandleMode.Checked && orginal.OnlineHandleWhenOfflineMode != card.OnlineHandleWhenOfflineMode) { success = ConvertToCard(card); } else { success = true; } } } } if (success) { row.Tag = card; this.dataGridView1.FirstDisplayedScrollingRowIndex = row.Index; row.DefaultCellStyle.ForeColor = Color.Green; SelectSingleRow(row); if (this.ItemUpdated != null) { this.ItemUpdated(this, new ItemUpdatedEventArgs(card)); } } } }; if (this.InvokeRequired) { this.Invoke(action); } else { action(); } }
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); } } } } }
///// <summary> ///// 卡片出内车场费用后的卡片信息(将费用累加到累计停车费用) ///// </summary> ///// <param name="info">卡片</param> ///// <param name="ts">费率</param> ///// <param name="carType">车型</param> ///// <param name="chargeDateTime">缴费时间</param> ///// <returns></returns> //private void CardPayNestedParkFee(CardInfo card, TariffSetting ts, Byte carType, DateTime chargeDateTime) //{ // ParkAccountsInfo parkFee = ts.CalculateCardNestedParkFee(card, carType, chargeDateTime); // ////不产生费用的,不记录缴费时间和累计停车费用,只更新内车场累计停车时间 // //if (parkFee.Accounts > 0) // //{ // // card.TotalFee += parkFee.Accounts; // // card.IsIndoorPaid = true;//更新内车场缴费标识 // // card.PaidDateTime = chargeDateTime;//记录缴费时间 // //} // card.TotalFee += parkFee.Accounts; // if (card.IsIndoorPaid && ts.IsInFreeTime(card.PaidDateTime.Value, chargeDateTime)) // { // //已缴费,并且处于缴费后免费时间的,不记录缴费时间 // //(防止下面这种情况出现:中央收费后设置允许15分钟内可以免费出场,则有些车主在入场后每隔15分钟去刷一次卡交费, // //这样出场时就不会产生费用) // } // else // { // card.PaidDateTime = chargeDateTime;//记录缴费时间 // } // card.IsInNestedPark = false ;//出内车场状态 // card.IsIndoorPaid = true;//更新内车场缴费标识 // card.UpdateIndoorTimeInterval(chargeDateTime);//更新内车场累计停车时间 //} ///// <summary> ///// 卡片进入内车场 ///// </summary> ///// <param name="info">卡片</param> ///// <param name="enterDateTime">进入时间</param> ///// <returns>进行后的卡片信息</returns> //private void CardEnterNestedPark(CardInfo info, DateTime enterDateTime) //{ // info.IsIndoorPaid = false ;//清除内车场缴费标识 // info.IsInNestedPark = true; // info.IndoorInDateTime = enterDateTime; //} #endregion #region 公共方法 ///// <summary> ///// 更新卡片写卡模式的相关数据(包括卡格式版本、室内停车场的进入时间、 ///// 室内停车场累计停车时间、缴费时间、当前车场已收的停车费用、累计停车费用、停车状态等) ///// </summary> ///// <param name="info"></param> ///// <returns></returns> //public CommandResult UpdateOffLineCardData(CardInfo info) //{ // CardInfo original = _Provider.GetByID(info.CardID).QueryObject; // if (original != null) // { // CardInfo card = original.Clone(); // //只更新写卡模式相关的属性 // card.CardVersion = info.CardVersion; // card.IndoorInDateTime = info.IndoorInDateTime; // card.IndoorTimeInterval = info.IndoorTimeInterval; // card.PaidDateTime = info.PaidDateTime; // card.ParkFee = info.ParkFee; // card.TotalFee = info.TotalFee; // //收费时需要更停车状态 // card.ParkingStatus = info.ParkingStatus; // return _Provider.Update(card, original); // } // return new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord)); //} /// <summary> /// 删除卡片最近的一条缴费记录 /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult DeleteLastPayment(CardInfo info) { if (info.LastPayment != null) { CardInfo card = info.Clone(); CardPaymentInfo paymentInfo = info.LastPayment; //CardPaymentInfo record = null; IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); ICardPaymentRecordProvider recordProvider = ProviderFactory.Create <ICardPaymentRecordProvider>(_RepoUri); ////重新设置卡片费用信息 ////card.TotalFee += paymentInfo.Paid + paymentInfo.Discount;//加上删除的收费费用和折扣 //if (!string.IsNullOrEmpty(paymentInfo.LastStationID) // || paymentInfo.LastTotalPaid != 0 // || paymentInfo.LastTotalDiscount != 0) //{ // //有上上次的缴费记录 // //先查找卡片是否有多条缴费记录 // CardPaymentRecordSearchCondition con = new CardPaymentRecordSearchCondition(); // con.CardID = card.CardID; // con.EnterDateTime = card.LastDateTime; // List<CardPaymentInfo> records = recordProvider.GetItems(con).QueryObjects; // if (records.Count > 1)//有多条缴费记录 // { // records = (from r in records // orderby r.ChargeDateTime descending // select r).ToList(); // record = records[1];//获取第二近的缴费记录 // } //} //if (record != null) //{ // //删除的记录的车场停车费用比上一条记录的停车费用多,说明两条记录之间有费用产生 // if (paymentInfo.ParkFee > record.ParkFee) // { // //如果两条记录相隔缴费时间内有产生费用,累计费用需要减去产生的费用 // card.TotalFee -= paymentInfo.ParkFee - record.ParkFee; // card.ParkFee = record.ParkFee;//重新设置外车场费用 // } // card.PaidDateTime = record.ChargeDateTime;//重新设置收费时间 // card.IsPaid = true; //} //else //{ // //没有上上次的缴费记录 // card.TotalFee -= paymentInfo.Accounts;//减去应缴费用 // card.TotalFee = card.TotalFee < 0 ? 0 : card.TotalFee; // card.ParkFee = 0; // card.IsPaid = false;//设置为未缴费 // card.PaidDateTime = null; //} //已缴费用减去记录收取的费用和折扣费用 card.TotalPaidFee -= paymentInfo.Paid + paymentInfo.Discount; if (card.TotalPaidFee < 0) { card.TotalPaidFee = 0; } _Provider.Update(card, info, unitWork); recordProvider.Delete(paymentInfo); CommandResult result = unitWork.Commit(); if (result.Result == ResultCode.Successful) { //删除成功,更新卡片信息 //info.ParkingStatus = card.ParkingStatus; //info.TotalFee = card.TotalFee; //info.PaidDateTime = card.PaidDateTime; //info.ParkFee = card.ParkFee; info.TotalPaidFee = card.TotalPaidFee; } return(result); } return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); }
private string CardOut(CardBll bll, CardInfo card) { ParkInfo park = this.ucEntrance1.SelectedPark; EntranceInfo entrance = this.ucEntrance1.SelectedEntrance; //手动生成出场事件 CardEventReport report = CardEventReport.CreateExitEvent(card, entrance.ParkID, entrance.EntranceID, entrance.EntranceName, park.WorkMode, card.CarType, TariffSetting.Current, DateTime.Now); report.EventStatus = CardEventStatus.Valid; report.OperatorID = OperatorInfo.CurrentOperator.OperatorName; report.StationID = WorkStationInfo.CurrentStation.StationName; report.UpdateFlag = true;//先标识为已上传 CardInfo origal = card.Clone(); ////卡片出场 //card.ParkingStatus = ParkingStatus.Out; //card.LastDateTime = DateTime.Now; bool offlineHandleCard = AppSettings.CurrentSetting.EnableWriteCard && card != null && !card.OnlineHandleWhenOfflineMode; //CommandResult result = bll.UpdateCardAll(card); CommandResult result = bll.SaveCardAndEvent(card, report); //写卡模式需要将收费信息写入卡片扇区 if (result.Result == ResultCode.Successful && offlineHandleCard) { if (CardOperationManager.Instance.WriteCardLoop(card) != CardOperationResultCode.Success) { //写入失败时,需将数据库卡片状态还原及删除出场事件 bll.UpdateCardAll(origal); (new CardEventBll(AppSettings.CurrentSetting.ParkConnect)).Delete(new CardEventRecord(report)); result = new CommandResult(ResultCode.Fail); } } if (result.Result == ResultCode.Successful) { if (string.IsNullOrEmpty(AppSettings.CurrentSetting.CurrentStandbyConnect)) { //更新到备用数据库 CardBll standbybll = new CardBll(AppSettings.CurrentSetting.CurrentStandbyConnect); //standbybll.UpdateCardAll(card); standbybll.SaveCardAndEvent(card, report); } string msg = string.Format("{0}:[{1}] {2}:[{3}]", Resource1.FrmCardOut_CardID, card.CardID, Resource1.FrmCardOut_InDateTime, origal.LastDateTime.ToString("yyyy-MM-dd HH:mm:ss")); //插入卡片直接出场报警记录 AlarmInfo alarm = new AlarmInfo(); alarm.AlarmDateTime = card.LastDateTime; alarm.AlarmType = AlarmType.CardOutAnomaly; alarm.OperatorID = OperatorInfo.CurrentOperator.OperatorName; alarm.AlarmDescr = msg + string.Format(" {0}:[{1}]", Resource1.FrmCardOut_OutReason, this.txtMemo.Text.Trim()); new AlarmBll(AppSettings.CurrentSetting.ParkConnect).Insert(alarm); if (!_OutCardsWitPark.ContainsKey(park)) { _OutCardsWitPark.Add(park, 0); } //该停车场出场卡片数加1 _OutCardsWitPark[park] += 1; this.txtCount.Text = _OutCardsWitPark[park].ToString(); return(msg); } return(result.Message); }