public static bool Delete(string plateId) { if (string.IsNullOrWhiteSpace(plateId)) { throw new ArgumentNullException("plateId"); } IEmployeePlate factory = EmployeePlateFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateReadConnection()) { return(factory.Delete(plateId, dbOperator)); } }
public static bool CancelParkGrant(string grantId) { if (grantId.IsEmpty()) { throw new ArgumentNullException("grantId"); } IParkGrant factory = ParkGrantFactory.GetFactory(); IBaseCard cardFactory = BaseCardFactory.GetFactory(); IEmployeePlate plateFactory = EmployeePlateFactory.GetFactory(); using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { ParkGrant grant = factory.QueryByGrantId(grantId); dbOperator.BeginTransaction(); bool result = plateFactory.Delete(grant.PlateID, dbOperator); if (!result) { throw new MyException("删除车牌失败"); } result = cardFactory.Delete(grant.CardID, dbOperator); if (!result) { throw new MyException("删除卡失败"); } result = factory.Delete(grantId, dbOperator); if (!result) { throw new MyException("删除授权失败"); } dbOperator.CommitTransaction(); if (result) { OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("grantId:{0}", grantId)); } return(result); } catch { dbOperator.RollbackTransaction(); throw; } } }