Beispiel #1
0
        public static ReservationsEntity GetReservationsByID(long rid)
        {
            ReservationsRepository rr   = new ReservationsRepository();
            ReservationsInfo       info = rr.GetReservationsInfoByID(rid);

            return(TranslateReservationsEntity(info));
        }
Beispiel #2
0
        public int CreateNew(ReservationsInfo info)
        {
            DataCommand command = new DataCommand(ConnectionString, GetDbCommand(ReservationsStatement.InsertSql, "Text"));

            command.AddInputParameter("@CustomerID", DbType.Int64, info.CustomerID);
            command.AddInputParameter("@CustomerName", DbType.String, info.CustomerName);
            command.AddInputParameter("@RType", DbType.String, info.RType);
            command.AddInputParameter("@PayType", DbType.Int32, info.PayType);
            command.AddInputParameter("@CarID", DbType.Int32, info.CarID);
            command.AddInputParameter("@LeaseTime", DbType.Int32, info.LeaseTime);
            command.AddInputParameter("@Price", DbType.Decimal, info.Price);
            command.AddInputParameter("@Remark", DbType.String, info.Remark);
            command.AddInputParameter("@RDate", DbType.DateTime, info.RDate);
            command.AddInputParameter("@Status", DbType.Int32, info.Status);
            command.AddInputParameter("@CreateDate", DbType.DateTime, info.CreateDate);

            return(command.ExecuteNonQuery());
        }
Beispiel #3
0
        private static ReservationsInfo TranslateReservationsInfo(ReservationsEntity reservationsEntity)
        {
            ReservationsInfo info = new ReservationsInfo();

            if (reservationsEntity != null)
            {
                info.ID           = reservationsEntity.ID;
                info.CustomerID   = reservationsEntity.CustomerID;
                info.CustomerName = reservationsEntity.CustomerName;
                info.RType        = reservationsEntity.RType;
                info.PayType      = reservationsEntity.PayType;
                info.CarID        = reservationsEntity.CarID;
                info.LeaseTime    = reservationsEntity.LeaseTime;
                info.Price        = reservationsEntity.Price;
                info.Remark       = reservationsEntity.Remark;
                info.RDate        = reservationsEntity.RDate;
                info.Status       = reservationsEntity.Status;
            }

            return(info);
        }
Beispiel #4
0
        private static ReservationsEntity TranslateReservationsEntity(ReservationsInfo info)
        {
            ReservationsEntity reservationsEntity = new ReservationsEntity();

            if (info != null)
            {
                reservationsEntity.ID           = info.ID;
                reservationsEntity.CustomerID   = info.CustomerID;
                reservationsEntity.CustomerName = info.CustomerName;
                reservationsEntity.RType        = info.RType;
                reservationsEntity.PayType      = info.PayType;
                reservationsEntity.CarID        = info.CarID;
                reservationsEntity.LeaseTime    = info.LeaseTime;
                reservationsEntity.Price        = info.Price;
                reservationsEntity.Remark       = info.Remark;
                reservationsEntity.RDate        = info.RDate;
                reservationsEntity.Status       = info.Status;

                CustomerEntity customer = null;//CustomerService.GetCustomerByID(info.CustomerID);
                reservationsEntity.Customer = customer;

                if (info.RType == "SJ" || info.RType == "ZL")//汽车预约
                {
                    CarEntity car = CarService.GetCarEntityById(info.CarID);
                    reservationsEntity.Car = car;
                }
                else if (info.RType == "DZ")//充电桩预约
                {
                    ChargingPileEntity chargingPile = ChargeService.GetChargingPileEntityById(info.CarID);
                    reservationsEntity.ChargingPile = chargingPile;
                }

                BaseDataEntity pay = BaseDataService.GetBaseDataByPCode("P00").FirstOrDefault(t => t.TypeCode == info.PayType) ?? new BaseDataEntity();
                reservationsEntity.PayTypeInfo = pay;//支付信息
            }

            return(reservationsEntity);
        }
Beispiel #5
0
        public static bool AddReservations(ReservationsEntity entity)
        {
            int result = 0;
            ReservationsRepository rR = new ReservationsRepository();

            if (entity != null)
            {
                ReservationsInfo info = new ReservationsInfo();
                info.CarID        = entity.CarID;
                info.CreateDate   = DateTime.Now;
                info.CustomerID   = entity.CustomerID;
                info.CustomerName = entity.CustomerName;
                info.LeaseTime    = entity.LeaseTime;
                info.PayType      = entity.PayType;
                info.Price        = entity.Price;
                info.RDate        = DateTime.Now;
                info.Remark       = entity.Remark;
                info.RType        = entity.RType;
                info.Status       = entity.Status;
                result            = rR.CreateNew(info);
            }
            return(result > 0);
        }