/// <summary> /// 收取卡片的停车费 /// </summary> /// <param name="info">缴费卡片,为空值时从数据库中获取,主要用于写卡模式时读取到卡片的数据</param> /// <param name="payment">缴费记录</param> /// <returns></returns> public CommandResult PayParkFee(CardInfo info, CardPaymentInfo payment) { if (info != null) { LDB_CardPaymentInfo ldbRecord = LDB_InfoFactory.CreateLDBCardPaymentInfo(payment); CommandResult result = _Provider.Insert(ldbRecord); if (result.Result == ResultCode.Successful) { if (payment.PaymentMode == PaymentMode.Prepay) { info.Balance -= payment.Paid; } //只有卡片在场或可重复出场,并且与缴费记录的进场时间相同,才会更新卡片信息 if ((info.IsInPark || info.CanRepeatOut) && payment.EnterDateTime.HasValue && info.LastDateTime == payment.EnterDateTime.Value) { //设置卡片缴费信息 info.SetPaidData(payment); } } return(result); } return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); }
public CommandResult Delete(TInfo info) { CommandResult result; try { ParkDataContext parking = ParkDataContextFactory.CreateParking(ConnectStr); if (parking == null) { result = new CommandResult(ResultCode.CannotConnectServer, ResultCodeDecription.GetDescription(ResultCode.CannotConnectServer)); } else { DeletingItem(info, parking); parking.SubmitChanges(); result = new CommandResult(ResultCode.Successful, successMsg); } } catch (SqlException ex) { result = new CommandResult(ResultCodeResolver.GetFromSqlExceptionNumber(ex.Number), ex.Message); ExceptionPolicy.HandleException(ex, this.GetType().FullName + "." + "Delete()"); } catch (Exception ex) { result = new CommandResult(ResultCode.Fail, ex.Message); ExceptionPolicy.HandleException(ex, this.GetType().FullName + "." + "Delete()"); } return(result); }
/// <summary> /// 修改卡片信息 /// </summary> /// <returns></returns> public CommandResult UpdateCardAll(CardInfo info) { CardInfo original = _Provider.GetByID(info.CardID).QueryObject; if (original != null) { return(_Provider.Update(info, original)); } return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); }
public CommandResult Update(RoleInfo newVal) { RoleInfo original = GetRoleInfoByID(newVal.RoleID).QueryObject; if (original != null) { return(provider.Update(newVal, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
public CommandResult Update(WorkStationInfo curVal) { WorkStationInfo original = GetWorkStationByID(curVal.StationID); if (original != null) { return(provider.Update(curVal, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
/// <summary> /// 修改优惠信息 /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult Update(PREPreferentialInfo info) { PREPreferentialInfo original = GetByID(info.PreferentialID.ToString()).QueryObject; if (original != null) { return(provider.Update(info, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
public CommandResult Update(AttendanceResult info) { AttendanceResult org = ProviderFactory.Create <IAttendanceResultProvider>(_RepoUri).GetByID(info.ID).QueryObject; if (org != null) { return(ProviderFactory.Create <IAttendanceResultProvider>(_RepoUri).Update(info, org)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
public CommandResult Update(DeptInfo newVal) { DeptInfo original = GetDeptInfoByID(newVal.DeptID.ToString()).QueryObject; if (original != null) { return(provider.Update(newVal, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
public CommandResult Update(YCTBlacklist newVal) { YCTBlacklist original = _Provider.GetByID(newVal.LCN).QueryObject; if (original != null) { return(_Provider.Update(newVal, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
public CommandResult Update(StaffCategory info) { StaffCategory original = ProviderFactory.Create <IStaffCategoryProvider>(_RepoUri).GetByID(info.ID).QueryObject; if (original != null) { return(ProviderFactory.Create <IStaffCategoryProvider>(_RepoUri).Update(info, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
public CommandResult Update(PREBusinesses newVal) { PREBusinesses original = GetBusinessesByID(newVal.BusinessesID.ToString()).QueryObject; if (original != null) { return(provider.Update(newVal, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
public CommandResult Commit() { try { LDB.SubmitChanges(); return(new CommandResult(ResultCode.Successful, ResultCodeDecription.GetDescription(ResultCode.Successful))); } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, "LDB_UnitWork.Commit()"); return(new CommandResult(ResultCode.Fail, ex.Message)); } }
/// <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))); }
public CommandResult Add(ShiftArrange info) { IShiftArrangeProvider provider = ProviderFactory.Create <IShiftArrangeProvider>(_RepoUri); ShiftArrangeID id = new ShiftArrangeID(info.StaffID, info.ShiftID, info.ShiftDate); ShiftArrange item = provider.GetByID(id).QueryObject; if (item == null) { IUnitWork unitWork = ProviderFactory.Create <IUnitWork>(_RepoUri); provider.Insert(info, unitWork); return(unitWork.Commit()); } else //如果已经存在则直接返回 { return(new CommandResult(ResultCode.Successful, ResultCodeDecription.GetDescription(ResultCode.Successful))); } }
public CommandResult Update(Shift info) { Shift original = ProviderFactory.Create <IShiftProvider>(_RepoUri).GetByID(info.ID).QueryObject; if (original != null) { if (info.Items != null && info.Items.Count > 0) { info.Items.ForEach(item => item.ShiftID = info.ID); } return(ProviderFactory.Create <IShiftProvider>(_RepoUri).Update(info, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
/// <summary> /// 修改操作员,如果操作员编号已被使用,抛出InvalidOperationException /// </summary> /// <param name="info"></param> /// <returns></returns> public CommandResult Update(Operator info) { List <Operator> allOpt = GetAllOperators().QueryObjects; if (allOpt.Exists(opt => opt.ID != info.ID && opt.Name == info.Name)) { throw new InvalidOperationException(string.Format(Resource1.OperatorBll_NamebeUsed, info.Name)); } Operator original = GetByID(info.ID).QueryObject; if (original != null) { return(provider.Update(info, original)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } }
/// <summary> /// 修改卡片信息,此方法不会修改卡片的运行状态(如入场时间,卡片出入场状态等)也不能修改卡片的有效期,余额等 /// </summary> /// <returns></returns> public CommandResult UpdateCard(CardInfo info) { CardInfo original = _Provider.GetByID(info.CardID).QueryObject; if (original != null) { //运行状态不能修改 info.ParkingStatus = original.ParkingStatus; info.LastDateTime = original.LastDateTime; info.LastEntrance = original.LastEntrance; info.LastCarPlate = original.LastCarPlate; info.LastNestParkDateTime = original.LastNestParkDateTime; //这些参数也不能修改 info.ValidDate = original.ValidDate; info.Deposit = original.Deposit; info.Balance = original.Balance; return(_Provider.Update(info, original)); } return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); }
public CommandResult Update(RoadWayInfo curVal) { QueryResult <RoadWayInfo> original = provider.GetByID(curVal.RoadID); if (original.Result == ResultCode.Successful) { if (original.QueryObject != null) { return(provider.Update(curVal, original.QueryObject)); } else { return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord))); } } else { return(new CommandResult(original.Result)); } }
public CommandResult Commit() { try { if (Parking != null) { Parking.SubmitChanges(); return(new CommandResult(ResultCode.Successful, ResultCodeDecription.GetDescription(ResultCode.Successful))); } else { return(new CommandResult(ResultCode.CannotConnectServer, ResultCodeDecription.GetDescription(ResultCode.CannotConnectServer))); } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, "UnitWork.Commit()"); return(new CommandResult(ResultCode.Fail, ex.Message)); } }
public QueryResult <TInfo> GetByID(TID id) { QueryResult <TInfo> result; try { ParkDataContext parking = ParkDataContextFactory.CreateParking(ConnectStr); if (parking == null) { result = new QueryResult <TInfo>(ResultCode.CannotConnectServer, ResultCodeDecription.GetDescription(ResultCode.CannotConnectServer), null); } else { TInfo info = GetingItemByID(id, parking); if (info != null) { result = new QueryResult <TInfo>(ResultCode.Successful, successMsg, info); } else { result = new QueryResult <TInfo>(ResultCode.Fail, ResultCodeDecription.GetDescription(ResultCode.Fail), info); } } } catch (SqlException ex) { result = new QueryResult <TInfo>(ResultCodeResolver.GetFromSqlExceptionNumber(ex.Number), ex.Message, null); ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "GetByID()"); } catch (Exception ex) { result = new QueryResult <TInfo>(ResultCode.Fail, ex.Message, null); ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "GetByID()"); } return(result); }
///// <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))); }
public QueryResultList <TInfo> GetAll() { QueryResultList <TInfo> result; try { ParkDataContext parking = ParkDataContextFactory.CreateParking(ConnectStr); if (parking == null) { result = new QueryResultList <TInfo>(ResultCode.CannotConnectServer, ResultCodeDecription.GetDescription(ResultCode.CannotConnectServer), new List <TInfo>()); } else { List <TInfo> infoes = GetingAllItems(parking); result = new QueryResultList <TInfo>(ResultCode.Successful, successMsg, infoes); } } catch (SqlException ex) { result = new QueryResultList <TInfo>(ResultCodeResolver.GetFromSqlExceptionNumber(ex.Number), ex.Message, new List <TInfo>()); ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "GetAll()"); } catch (Exception ex) { result = new QueryResultList <TInfo>(ResultCode.Fail, ex.Message, new List <TInfo>()); ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "GetAll()"); } return(result); }
public CommandResult(ResultCode code) { this._ret = code; this._msg = ResultCodeDecription.GetDescription(code); }
public QueryResultList(ResultCode code, List <T> list) { this._result = code; this._msg = ResultCodeDecription.GetDescription(code); this.QueryObjects = list; }
public QueryResult(ResultCode code, T obj) { this._result = code; this._msg = ResultCodeDecription.GetDescription(code); this._queryObject = obj; }