Beispiel #1
0
        public static bool Delete(string employeeId)
        {
            if (string.IsNullOrWhiteSpace(employeeId))
            {
                throw new ArgumentNullException("employeeId");
            }
            IBaseEmployee  factory      = BaseEmployeeFactory.GetFactory();
            IEmployeePlate platefactory = EmployeePlateFactory.GetFactory();

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();
                    //删除车牌
                    bool result = platefactory.DeleteByEmployeeId(employeeId, dbOperator);
                    if (!result)
                    {
                        throw new MyException("删除车牌失败");
                    }
                    //删授权表
                    result = factory.Delete(employeeId, dbOperator);
                    if (!result)
                    {
                        throw new MyException("删除人员信息失败");
                    }
                    dbOperator.CommitTransaction();
                    return(result);
                }
                catch {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
        }
Beispiel #2
0
        public static EmployeePlate Query(string plateId)
        {
            if (string.IsNullOrWhiteSpace(plateId))
            {
                throw new ArgumentNullException("plateId");
            }

            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            return(factory.Query(plateId));
        }
Beispiel #3
0
        public static List <EmployeePlate> QueryByEmployeeId(string employeeId)
        {
            if (string.IsNullOrWhiteSpace(employeeId))
            {
                throw new ArgumentNullException("employeeId");
            }

            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            return(factory.QueryByEmployeeId(employeeId));
        }
Beispiel #4
0
        public static bool Update(EmployeePlate model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            return(factory.Update(model));
        }
Beispiel #5
0
        public static List <EmployeePlate> GetGrantPlateNumberListByLike(string vid, string plateNumber, out string ErrorMessage)
        {
            if (plateNumber.IsEmpty())
            {
                throw new ArgumentNullException("plateNumber");
            }

            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            return(factory.GetGrantPlateNumberListByLike(vid, plateNumber, out ErrorMessage));
        }
Beispiel #6
0
        public static EmployeePlate GetPlateNumber(string vid, string plateID, out string ErrorMessage)
        {
            if (plateID.IsEmpty())
            {
                throw new ArgumentNullException("plateID");
            }

            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            return(factory.GetPlateNumber(vid, plateID, out ErrorMessage));
        }
Beispiel #7
0
        public static bool Add(EmployeePlate model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.PlateID = GuidGenerator.GetGuidString();
            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            return(factory.Add(model));
        }
Beispiel #8
0
        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));
            }
        }
Beispiel #9
0
        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;
                }
            }
        }
Beispiel #10
0
        public static EmployeePlate QueryByEmployeeIdAndPlateNumber(string employeeId, string plateNumber)
        {
            if (string.IsNullOrWhiteSpace(employeeId))
            {
                throw new ArgumentNullException("employeeId");
            }
            if (string.IsNullOrWhiteSpace(plateNumber))
            {
                throw new ArgumentNullException("plateNumber");
            }

            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            return(factory.QueryByEmployeeIdAndPlateNumber(employeeId, plateNumber));
        }
Beispiel #11
0
        public static bool Update(string plateId, string plateNumber, PlateColor color)
        {
            if (string.IsNullOrWhiteSpace(plateId))
            {
                throw new ArgumentNullException("plateId");
            }
            if (string.IsNullOrWhiteSpace(plateNumber))
            {
                throw new ArgumentNullException("plateNumber");
            }

            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            using (DbOperator dbOperator = ConnectionManager.CreateReadConnection())
            {
                return(factory.Update(plateId, plateNumber, color, dbOperator));
            }
        }
Beispiel #12
0
        public static bool AddOrUpdateEmployeePlate(EmployeePlate plate, DbOperator dbOperator)
        {
            IEmployeePlate plateFactory = EmployeePlateFactory.GetFactory();
            EmployeePlate  oldPlate     = plateFactory.Query(plate.PlateID);

            if (oldPlate == null)
            {
                return(plateFactory.Add(plate, dbOperator));
            }
            else
            {
                oldPlate.Color      = plate.Color;
                oldPlate.PlateNo    = plate.PlateNo;
                oldPlate.EmployeeID = plate.EmployeeID;
                plate = oldPlate;
                return(plateFactory.Update(plate, dbOperator));
            }
        }