/// <summary> /// 修改数据库中的卡片,不会修改卡片的运行状态 /// </summary> private bool UpdateCard(CardInfo info, IUnitWork unitWork) { QueryResult <CardInfo> result = _Provider.GetByID(info.CardID); if (result.Result == ResultCode.Successful) { CardInfo original = result.QueryObject; //卡片状态保持用数据库中的状态 info.ParkingStatus = original.ParkingStatus; info.LastDateTime = original.LastDateTime; info.LastEntrance = original.LastEntrance; info.LastCarPlate = original.LastCarPlate; _Provider.Update(info, original, unitWork); return(true); } return(false); }
/// <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); } } }
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); } } }
/// <summary> /// 保存车单 /// </summary> /// <param name="sheetID"></param> /// <param name="employeeNum"></param> /// <param name="employeeName"></param> /// <param name="telPhone"></param> /// <param name="department"></param> /// <param name="carPlate"></param> /// <param name="status"></param> /// <param name="activationDate"></param> /// <param name="accessID"></param> /// <returns></returns> private InterfaceReturnCode _SaveSheet(string sheetID, string employeeNum, string employeeName, string telPhone, string department, string carPlate, byte status, string activationDate, string places, bool enableLimitation, double limitation) { DateTime activation; if (string.IsNullOrEmpty(employeeNum) || !DateTime.TryParse(activationDate, out activation)) { return(InterfaceReturnCode.ParameterError); } //卡片状态 = 1 Enabled 已发行, = 3 Disabled 禁用, byte cardStatus = (byte)(status == 0 ? 3 : 1); //先查询停车地点的权限组 int accessID = GetAccessID(places); if (accessID == -1) { accessID = 0; } ICardProvider provider = ProviderFactory.Create <ICardProvider>(AppConifg.Current.ParkingConnection); CardInfo info = null; QueryResult <CardInfo> find = provider.GetByID(employeeNum); if (find.Result == ResultCode.Successful || find.Result == ResultCode.NoRecord) { if (find.QueryObject != null) { info = find.QueryObject.Clone(); } } else { return(CreateInterfaceReturnCode(find.Result)); } if (info == null) { info = new CardInfo(); //以下为卡片默认设置 info.CardType = Ralid.Park.BusinessModel.Enum.CardType.MonthRentCard; info.CanRepeatOut = false; info.CanRepeatIn = false; info.HolidayEnabled = true; info.WithCount = true; info.OnlineHandleWhenOfflineMode = false; info.CanEnterWhenFull = true; info.EnableWhenExpired = true; info.ValidDate = new DateTime(2099, 12, 31); } info.CardID = employeeNum; info.OwnerName = employeeName; info.Telphone = telPhone; info.CardCertificate = department; info.CarPlate = carPlate; info.Status = (Ralid.Park.BusinessModel.Enum.CardStatus)cardStatus; info.ActivationDate = activation; info.EnableLimitation = enableLimitation; info.LimitationRemain = (decimal)limitation; info.AccessID = (byte)accessID; info.SheetID = sheetID; CommandResult result = null; if (find.QueryObject == null) { result = provider.Insert(info); } else { result = provider.Update(info, find.QueryObject); } return(CreateInterfaceReturnCode(result.Result)); }
//保存卡片信息,如果存在则直接覆盖 public InterfaceReturnCode SaveCard(string cardID, short cardNum, byte carType, byte status, short index, int lastEntrance, string activationDate, DateTime validDate, decimal balance, decimal deposit, int discountHour, int options) { DateTime activation; if (!DateTime.TryParse(activationDate, out activation)) { return(InterfaceReturnCode.ParameterError); } //卡片状态 = 1 Enabled 已发行, = 3 Disabled 禁用 byte cardStatus = (byte)(status == 0 ? 3 : 1); ICardProvider provider = ProviderFactory.Create <ICardProvider>(AppConifg.Current.ParkingConnection); CardInfo info = null; QueryResult <CardInfo> find = provider.GetByID(cardID); if (find.Result == ResultCode.Successful || find.Result == ResultCode.NoRecord) { if (find.QueryObject != null) { info = find.QueryObject.Clone(); } } else { return(CreateInterfaceReturnCode(find.Result)); } if (info == null) { info = new CardInfo(); //以下为卡片默认设置 info.CardType = Ralid.Park.BusinessModel.Enum.CardType.MonthRentCard;//卡片类型定位月卡 info.CanRepeatOut = false; info.CanRepeatIn = false; info.HolidayEnabled = true; info.WithCount = true; info.OnlineHandleWhenOfflineMode = false; info.CanEnterWhenFull = true; info.EnableWhenExpired = true; info.ValidDate = new DateTime(2099, 12, 31); } info.CardID = cardID; info.CardNum = cardNum; info.AccessID = 0;//表示所有权限 info.CarType = carType; info.Index = index; info.ParkingStatus = ParkingStatus.Out; info.LastDateTime = DateTime.Now; info.LastEntrance = lastEntrance; info.Status = (Ralid.Park.BusinessModel.Enum.CardStatus)cardStatus; info.ActivationDate = activation; CommandResult result = null; if (find.QueryObject == null) { result = provider.Insert(info); } else { result = provider.Update(info, find.QueryObject); } return(CreateInterfaceReturnCode(result.Result)); }