/// <summary> /// 卡片发行 /// </summary> /// <param name="info"></param> /// <param name="releaseMoney"></param> /// <param name="paymentMode"></param> /// <param name="memo"></param> /// <param name="keepParkingStatus">是否保持卡片运行状态</param> /// <returns></returns> public CommandResult CardRelease(CardInfo info, decimal releaseMoney, PaymentMode paymentMode, string memo, bool keepParkingStatus) { string op = OperatorInfo.CurrentOperator.OperatorName; string station = WorkStationInfo.CurrentStation.StationName; IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); //工作单元 CardReleaseRecord record = new CardReleaseRecord { CardID = info.CardID, OwnerName = info.OwnerName, CardCertificate = info.CardCertificate, CarPlate = info.CarPlate, ReleaseDateTime = DateTime.Now, CardType = info.CardType, ReleaseMoney = releaseMoney, PaymentMode = paymentMode, Balance = info.Balance, ActivationDate = info.ActivationDate, ValidDate = info.ValidDate, HolidayEnabled = info.HolidayEnabled, Deposit = info.Deposit, OperatorID = op, StationID = station, Memo = memo }; ProviderFactory.Create <ICardReleaseRecordProvider>(_RepoUri).Insert(record, unitWork); info.Release(); ICardProvider icp = ProviderFactory.Create <ICardProvider>(_RepoUri); CardInfo origial = icp.GetByID(info.CardID).QueryObject; if (origial == null) { icp.Insert(info, unitWork); } else if (keepParkingStatus) { UpdateCard(info, unitWork); } else { UpdateCardAll(info, 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> 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="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)); }