Beispiel #1
0
 /// <summary>
 /// 检查是否重复
 /// </summary>
 /// <param name="Model.Car"></param>
 /// <returns></returns>
 public static bool CheckRepeatForVin(Model.Car model)
 {
     try
     {
         string         sql  = "select * from Car where Vin = @Vin and Id <> @Id";
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Vin", model.Vin.Trim()),
             new SqlParameter("@Id", model.Id)
         };
         DataTable temp = DBHelper.ExecuteGetDataTable(CommandType.Text, sql, para);
         if (temp.Rows.Count > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         ErrorLog e = new ErrorLog();
         e.TargetIds = model.Id.ToString();
         e.CodeTag   = "CheckRepeat";
         e.LogName   = "检查是否重复-ForCarVin";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Car>(e, model);
         return(true);
     }
 }
Beispiel #2
0
 private void CalculateEnemiesBehind(Car self, Game game)
 {
     foreach (var car in this.enemiesCars)
     {
         if (!car.IsFinishedTrack && car.Durability > 0.0)
         {
             var currentPosition = new PointF((float)car.X, (float)car.Y);
             var nextPosition = new PointF((float)car.X + (float)car.SpeedX, (float)car.Y + (float)car.SpeedY);
             var futurePosition = new PointF(
                 (float)car.X + PredictionCount * (float)car.SpeedX,
                 (float)car.Y + PredictionCount * (float)car.SpeedY);
             var xOffset =
                 (float)
                 (Math.Cos(self.Angle) * (game.CarHeight + game.OilSlickInitialRange + game.OilSlickRadius));
             var yOffset =
                 (float)
                 (Math.Sin(self.Angle) * (game.CarHeight + game.OilSlickInitialRange + game.OilSlickRadius));
             var oilPosition = new PointF((float)self.X + xOffset, (float)self.Y - yOffset);
             float distance = MathHelper.DistanceToLine(oilPosition, currentPosition, futurePosition);
             if (distance < game.OilSlickRadius + game.CarWidth / 2
                 && MathHelper.Distance(currentPosition, oilPosition)
                 < game.OilSlickRadius + PredictionCount * car.GetSpeed()
                 && MathHelper.Distance(currentPosition, oilPosition)
                 > MathHelper.Distance(nextPosition, oilPosition))
             {
                 this.enemyBehind = true;
                 break;
             }
         }
     }
 }
Beispiel #3
0
 static void Main(string[] args)
 {
     Car car = new Car("Lada", "D") { Color = Color.DarkMagenta };
     try
     {
         Console.WriteLine(car.CarPassport.Owner.Name);
     }
     catch (NullReferenceException)
     {
         Console.WriteLine("Нет имени владельца");
     }
     Driver driver = new Driver(new DateTime(1990, 10, 10), "Вольдемар") { Category = "BC" };
     try
     {
         car.ChangeOwner(driver, "о777оо");
     }
     catch (CarException carException)
     {
         Console.WriteLine(carException.Message);
     }
     driver.Category = driver.Category.Insert(2, "D");
     car.ChangeOwner(driver, "о777оо");
     Console.WriteLine(driver.Car.CarNumber);
     Console.WriteLine(car.CarPassport.Owner.Name);
     Console.ReadKey();
 }
Beispiel #4
0
        public HttpResponseMessage Get(int id)
        {
            string errMsg = "";

            Model.Car      car = BLL.CarManager.GetCarById(id, out errMsg);
            HttpStatusCode status;
            string         json;

            //errMsg = "网络繁忙,请稍稍再度";
            if (errMsg.Length > 0)
            {
                status = (HttpStatusCode)422;
                var msg = new
                {
                    errors = new
                    {
                        ServerSideError = errMsg
                    }
                };
                json = JsonConvert.SerializeObject(msg);
            }
            else
            {
                status = HttpStatusCode.OK;
                var msg2 = new
                {
                    car = car
                };
                json = JsonConvert.SerializeObject(msg2);
            }
            return(new HttpResponseMessage(status)
            {
                Content = new StringContent(json, System.Text.Encoding.GetEncoding("UTF-8"), "application/json")
            });
        }
 /// <summary>
 /// 根据条件查询
 /// </summary>
 /// <param name="car"></param>
 public DataTable SelectbyCar(Car car)
 {
     string sql = "select  ID ,PlateNumber,Color ,Brand ,UseYear ,MotorcyleType,CarResource  from TB_Car where 1=1  ";
     if (!string.IsNullOrEmpty(car.PlateNumber) || car.PlateNumber!="")
     {
         sql += "and PlateNumber like '%" + car.PlateNumber + "%'";
     }
     if (!string.IsNullOrEmpty(car.Color) || car.Color != "")
     {
         sql += "and Color like'%" + car.Color + "%'";
     }
     if (!string.IsNullOrEmpty(car.Brand) || car.Brand != "")
     {
         sql += "and Brand like'%" + car.Brand + "%'";
     }
     if (!string.IsNullOrEmpty(car.UseYear) || car.UseYear != "")
     {
         sql += "and UseYear like'%" + car.UseYear + "%'";
     }
     if (!string.IsNullOrEmpty(car.MotorcyleType) || car.MotorcyleType != "")
     {
         sql += "and MotorcyleType like'%" + car.MotorcyleType + "%'";
     }
     if (!string.IsNullOrEmpty(car.CarResource) || car.CarResource != "")
     {
         sql += "and CarResource like'%" + car.CarResource + "%'";
     }
     return AccessHelper.GetDataSet(sql);
 }
 /// <summary>
 /// 新增单个数据
 /// </summary>
 /// <param name="driverAbnormalNameList"></param>
 /// <returns></returns>
 public bool InsertObject(Car car)
 {
     string sql = "insert into TB_Car (PlateNumber,Color,Brand,UseYear,MotorcyleType) values('" +
         car.PlateNumber + "','" + car.Color + "','" + car.Brand + "','" +
         car.UseYear + "','" + car.MotorcyleType + "' )";
     return AccessHelper.SQLExecute(sql);
 }
Beispiel #7
0
        static void Main(string[] args)
        {
            Car car= new Car("Lada", "D");
            car.Color= Color.Brown;

            try
            {
                Console.WriteLine(car.CarPassport.Owner.Name);
            }
            catch (NullReferenceException)
            {
                Console.WriteLine("Водитель не назначен");
            }

            Driver dr= new Driver(new DateTime(1998, 11, 22), "Voldemar");
            dr.Category= new List<string>() {"B", "C"};
            try
            {
                car.ChangeOwner(dr, "o777oo");
            }
            catch (NoCategoryException ex)
            {

                Console.WriteLine(ex.Message);
            }

            dr.Category.Add("D");
            car.ChangeOwner(dr, "o777oo");
            Console.WriteLine(dr.Car.CarNumber);
            Console.WriteLine(car.CarPassport.Owner.Name);

            Console.ReadKey();
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            var firstCar = new Car("Лада", 'D')
            {
                Color = Color.BlueViolet
            };
            Console.WriteLine("Приобретена машина {0}, " +
                  "категории: {1}, цвет: {2}",
                  firstCar.Model, firstCar.Category, firstCar.Color);
            try
            {
                Console.WriteLine("Имя владельца: " + firstCar.CarPassport.Owner.Name);
            }
            catch (Exception)
            {
                Console.WriteLine("Ошибка! У владельца отсутствует имя");
            }

            var firstDriver = new Driver(new DateTime(2014, 7, 15), "Вольдемар")
            {
                Category = new [] {'B', 'C'}
            };

            firstCar.ChangeOwner(firstDriver, "oo777o");
            firstDriver.Category = new [] {'B','C','D'};
            firstCar.ChangeOwner(firstDriver, "oo777o");
            Console.WriteLine("Номер машины: " + firstCar.CarNumber);
            Console.WriteLine("Имя водителя Лады: " + firstDriver.Name);
            Console.ReadKey();
        }
 public void Move(Car self, World world, Game game, Move move)
 {
     if (IsActivated)
     {
         if (this.step1)
         {
             if (self.EnginePower <= -1.0f)
             {
                 this.hack++;
                 if (this.hack >= 5)
                 {
                     this.step1 = false;
                     this.step2 = true;
                     this.hack = 0;
                 }
             }
         }
         else if (this.step2)
         {
             if (self.EnginePower >= 0.2f)
             {
                 this.step2 = false;
                 IsActivated = false;
                 this.lastUsedTick = world.Tick;
             }
         }
     }
 }
Beispiel #10
0
        private bool tryValidate(Model.Car model, out string errMsg)
        {
            errMsg = "";
            bool re = true;

            if (model.Number == null || model.Number.Length == 0 || model.Number.Length > 20 ||
                model.Vin == null || model.Vin.Length == 0 || model.Vin.Length > 100 ||
                model.Model.Length > 20 ||
                model.Description.Length > 200)
            {
                errMsg = "输入数据不合法";
                re     = false;
            }
            if (re && CarManager.CheckRepeatForNumber(model))
            {
                errMsg = "内部编号不能重复";
                re     = false;
            }
            if (re && CarManager.CheckRepeatForVin(model))
            {
                errMsg = "Vin不能重复";
                re     = false;
            }
            if (re && model.Modifier != auth.UserId)
            {
                errMsg = "登录信息异常,请刷新浏览器以重启应用(APP请退出应用后重新打开)";
                re     = false;
            }
            return(re);
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            var car = new Car("Лада", "D");
            car.Color = Color.Purple;

            try
            {
                Console.WriteLine("Владелец - " + car.CarPassport.Owner.Name);
            }
            catch (Exception)
            {
                Console.WriteLine("Имя владельца лады не задано!");
            }

            var driver = new Driver("23.11.2015", "Вольдемар");
            driver.Category = "BC";

            try
            {
                car.ChangeOnwer("o777oo", driver);
            }
            catch (Exception)
            {

                Console.WriteLine("Ошибка!");
            }

            driver.Category += "D";
            car.ChangeOnwer("o777oo", driver);

            Console.WriteLine("Владелец машины: " + driver.Name);
            Console.WriteLine("Номер машины: " + car.CarNumber);

            Console.ReadKey();
        }
Beispiel #12
0
 public void PostMove(Car self, World world, Game game, Move move)
 {
     if (this.gameStarted)
     {
         move.IsThrowProjectile = this.enemyInFront;
         move.IsSpillOil = this.enemyBehind;
     }
 }
Beispiel #13
0
 public void PreMove(Car self, World world, Game game, Move move)
 {
     this.gameStarted = world.Tick > game.InitialFreezeDurationTicks;
     this.enemiesCars.Clear();
     this.enemiesCars.AddRange(world.Cars.Where(car => !car.IsTeammate));
     this.enemyBehind = false;
     this.enemyInFront = false;
 }
Beispiel #14
0
 public void OwnCar(Car car)
 {
     if (Category.Contains(car.Category)) Car = car;
     else
     {
         throw new CategoryException();
     }
 }
Beispiel #15
0
 /// <summary>
 /// Устанавливает машину, которой в данный момент управляет водитель
 /// </summary>
 /// <param name="car">Передаёт информацию о машине, которая будет приписана к водителю</param>
 public void OwnCar(Car car)
 {
     if (!Category.Contains(car.Category)) throw new NoCategoryException("Нет нужной категории");
     else
     {
         Car = car;
     }
 }
Beispiel #16
0
 public void Move(Car self, World world, Game game, Move move)
 {
     if (!BackMovingModule.IsActivated)
     {
         this.distance = MathHelper.Distance(new PointF((float)self.X, (float)self.Y), this.nextPoint);
         this.desiredAngle = self.GetAngleTo(this.nextPoint.X, this.nextPoint.Y);
     }
 }
 public void PreMove(Car self, World world, Game game, Move move)
 {
     if (!IsActivated && self.GetSpeed() < 0.75f
         && (this.IsFaceObstacle(self, world, game)
             || (self.EnginePower >= 0.5f && world.Tick > 190 && world.Tick > this.lastUsedTick + 60)))
     {
         IsActivated = true;
         this.step1 = true;
     }
 }
Beispiel #18
0
        static void Main(string[] args)
        {
            // Console.OutputEncoding = Encoding.UTF8;
            var carLada = new Car("2107", "D");
            carLada.Color = Color.Indigo; // вроде этот цвет похож на баклажановый
            if (carLada.carPassport.Owner != null)
            {
                Console.WriteLine(" Владелец машины {0}",carLada.carPassport.Owner.Name);
            }
            else
            {
                Console.WriteLine("У машины еще нет владельца");
            }

            Console.WriteLine("----------------------------------------");

            var driver = new Driver(new DateTime(2014, 12, 30), "Вольдемар") {Category = "BC"};

            try
            {
                carLada.ChangeOwner(driver, "o777oo");
                Console.WriteLine("водитель успешно сменен");
            }
            catch (MyException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("----------------------------------------");

            driver.Category = driver.Category + "D";

            try
            {
                carLada.ChangeOwner(driver, "o777oo");
                Console.WriteLine("водитель успешно сменен");
            }
            catch (MyException ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("----------------------------------------");

            Console.WriteLine("номер машины {1}а: {0}",driver.Car.CarNumber, driver.Name);

            Console.WriteLine("----------------------------------------");

            if (carLada.carPassport.Owner != null)
            {
                Console.WriteLine("владелец машины {0} - {1}", carLada.Model, carLada.carPassport.Owner.Name);
            }

            Console.ReadKey();
        }
Beispiel #19
0
 public void OwnCar(Car car)
 {
     if (Category.Contains(car.Category))
     {
         Car = car;
     }
     else
     {
         throw new Exception("Нет категории!");
     }
 }
Beispiel #20
0
 public void OwnCar(Car car)
 {
     if (Category.Contains(car.Category))
     {
         Car = car;
     }
     else
     {
         throw new Exception($"У водителя {Name} нет прав на вождение автомобилей категории {car.Category}");
     }
 }
Beispiel #21
0
 public void OwnCar(Car car)
 {
     if (!Category.Contains(car.Category))
     {
         throw new CategoryNotFoundException("Водитель: " + Name + " не обладает категорией " + car.Category);
     }
     else
     {
         Car = car;
     }
 }
Beispiel #22
0
 public void OwnCar(Car car)
 {
     if (Category.Contains(car.Category))
     {
         Car = car;
     }
     else
     {
         Console.WriteLine("Категория водителя не подходит к категории автомобиля");
     }
 }
Beispiel #23
0
 public void OwnCar(Car car)
 {
     if (Category.Contains(car.Category))
     {
         Car = car;
     }
     else
     {
         throw new CategoryException("В правах водителя нет категории данной машины");
     }
 }
Beispiel #24
0
 public void OwnCar(Car car)
 {
     if (Category.Contains(car.Category))
     {
         Car = car;
     }
     else
     {
         throw new CarException("Водитель не обладает нужной категорией");
     }
 }
Beispiel #25
0
 public void OwnCar(Car car)
 {
     if (Category.Contains(car.Category))
     {
         Car = car;
     }
     else
     {
         throw new CarCategoryException($"Водитель {Name} не соответствует категории машины т.е. категории {car.Category}");
     }
 }
Beispiel #26
0
        public void OwnCar(Car car)
        {
            if (Category.Contains(car.Categor))
                {
                    Car = car;

                }
                else
                {
                    throw new NoCategoryException($"Водитель {Name} не имеет нужной категории {car.Categor}");
                }
        }
Beispiel #27
0
        public void OwnCar(Car car)
        {
            if (Category.Contains(car.Category))
            {
                Car = car;
            }

            else
            {
                throw new MyException(string.Format("{0} не обладает категорией {1} ", Name, car.Category));
            }
        }
Beispiel #28
0
        static void Main(string[] args)
        {
            //FR001
            var model = "Лада";
            var category = 'D';
            var car = new Car(model, category) {Color = Color.DarkMagenta};

            //FR002
            try
            {
                Console.WriteLine("Имя владельца {0}: {1}", car.Model,car.CarPassport.Owner.Name);
            }
            catch (NullReferenceException exeption)
            {
                Console.WriteLine("Владельца {0} не существует! Сообщение об ошибке: {1}", car.Model, exeption.Message);
            }

            //FR003
            var driverName = "Вольдемар";
            var driverCategory = "BC";
            var driver = new Driver(new DateTime(2010,11,20), driverName) {Category = driverCategory};

            //FR004
            var carNumber = "o777oo";
            try
            {
                car.ChangeOwner(driver, carNumber);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

            //FR005
            if (!driverCategory.Contains('D')) driver.Category += "D";
            try
            {
                car.ChangeOwner(driver, carNumber);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }

            //FR006
            Console.WriteLine("Номер машины {0}: {1}", driver.Name, driver.Car.CarNumber);

            //FR007
            Console.WriteLine("Имя владельца {0}: {1}", car.Model, car.CarPassport.Owner.Name);

            Console.ReadKey();
        }
Beispiel #29
0
        private bool tryPut(ref Model.Car model, out string errMsg)
        {
            errMsg = "";
            bool re = false;

            model.Modifier     = this.auth.UserId;
            model.ModifiedDate = DateTime.Now;
            if (CarManager.ModifyCarById(ref model, out errMsg))
            {
                re = true;
            }
            return(re);
        }
Beispiel #30
0
 // ссылка на объект
 // methode:
 public void OwnCar(Car car)
 {
     //исключение:
     if (Category.Contains(car.Category)) // определяет, все ли элемены есть в списке
     {
         Car = car;
     }
     else
     {
         CategoryOfDriverException exc = new CategoryOfDriverException("Driver has no needed category!");
         throw exc;
     }
 }
Beispiel #31
0
 /// <summary>
 /// 添加车辆
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddCar(ref Model.Car model, out string errMsg)
 {
     errMsg = "";
     try
     {
         model.Number      = model.Number.Trim();
         model.Vin         = model.Vin.Trim();
         model.Model       = model.Model.Trim();
         model.Description = model.Description.Trim();
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Number", model.Number),
             new SqlParameter("@Vin", model.Vin),
             new SqlParameter("@Model", model.Model),
             new SqlParameter("@Description", model.Description),
             new SqlParameter("@Creater", model.Creater),
             new SqlParameter("@CreatedDate", model.CreatedDate),
             new SqlParameter("@Modifier", model.Modifier),
             new SqlParameter("@ModifiedDate", model.ModifiedDate),
             new SqlParameter("@return", SqlDbType.Int)
         };
         para[8].Direction = ParameterDirection.ReturnValue;
         int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_CarInsert", para);
         if (i > 0)
         {
             model.Id = int.Parse(para[8].Value.ToString());
             EventLog e = new EventLog();
             e.TargetIds = para[8].Value.ToString();
             e.CodeTag   = "AddCar";
             e.LogName   = "添加车辆";
             EventLogService.AddEventLog <Model.Car>(e, model);
             return(true);
         }
         else
         {
             errMsg = "添加记录失败,受影响行数为0";
             return(false);
         }
     }
     catch (Exception ex)
     {
         errMsg = ex.Message;
         ErrorLog e = new ErrorLog();
         e.TargetIds = "0";
         e.CodeTag   = "AddCar";
         e.LogName   = "添加车辆";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Car>(e, model);
         return(false);
     }
 }
Beispiel #32
0
 private void CalculateEnemiesInFront(Car self, Game game)
 {
     foreach (var car in this.enemiesCars)
     {
         if (car.Type == CarType.Buggy)
         {
             if (!car.IsFinishedTrack && car.Durability > 0.0)
             {
                 var currentEnemyPosition = new PointF((float)car.X, (float)car.Y);
                 var nextEnemyPosition = new PointF(
                     (float)car.X + (float)car.SpeedX,
                     (float)car.Y + (float)car.SpeedY);
                 var futureEnemyPosition = new PointF(
                     (float)car.X + PredictionCount * (float)car.SpeedX,
                     (float)car.Y + PredictionCount * (float)car.SpeedY);
                 var currentWasherPosition = new PointF((float)self.X, (float)self.Y);
                 var nextWasherPosition =
                     new PointF(
                         (float)self.X + (float)self.SpeedX / self.GetSpeed() * (float)game.WasherInitialSpeed,
                         (float)self.Y + (float)self.SpeedY / self.GetSpeed() * (float)game.WasherInitialSpeed);
                 var futureWasherPosition =
                     new PointF(
                         (float)self.X
                         + PredictionCount * (float)self.SpeedX / self.GetSpeed()
                         * (float)game.WasherInitialSpeed,
                         (float)self.Y
                         + PredictionCount * (float)self.SpeedY / self.GetSpeed()
                         * (float)game.WasherInitialSpeed);
                 PointF? intersectsPoint = MathHelper.PointOfIntersection(
                     currentWasherPosition,
                     futureWasherPosition,
                     currentEnemyPosition,
                     futureEnemyPosition);
                 if (intersectsPoint.HasValue
                     && MathHelper.Distance(intersectsPoint.Value, currentWasherPosition)
                     / (float)game.WasherInitialSpeed <= PredictionCount
                     && MathHelper.Distance(currentWasherPosition, currentEnemyPosition)
                     > MathHelper.Distance(nextWasherPosition, nextEnemyPosition)
                     && Math.Abs(
                         MathHelper.Distance(intersectsPoint.Value, currentWasherPosition)
                         / (float)game.WasherInitialSpeed
                         - MathHelper.Distance(intersectsPoint.Value, currentEnemyPosition) / car.GetSpeed())
                     < WasherPredictionError)
                 {
                     this.enemyInFront = true;
                     break;
                 }
             }
         }
     }
 }
 public void PostMove(Car self, World world, Game game, Move move)
 {
     if (IsActivated)
     {
         move.WheelTurn = 0.0f;
         if (this.step1)
         {
             move.EnginePower = -1.0f;
         }
         else if (this.step2)
         {
             move.EnginePower = 1.0f;
         }
     }
 }
Beispiel #34
0
 public void OwnCar(Car car)
 {
     try
     {
         if (!Category.Contains(car.Category.ToString()))
         {
             throw new System.Exception();
         }
         Car = car;
     }
     catch (Exception)
     {
         Console.WriteLine("Категория прав и машины не совпадают!");
     }
 }
        public void OwnCar(Car car)
        {
            Car temp = null;
            if (_category.Contains(car.Categorie))
            {
                temp = car;
                Console.WriteLine("Машина закреплена за водителем.");
            }
            else
            {
                throw new System.ArgumentException("У предлагаемого владельца нет прав для управления данной машиной");
            }

            PropsCar = temp;
        }
Beispiel #36
0
 /// <summary>
 /// 根据id修改车辆
 /// </summary>
 /// <param name="Model.Car"></param>
 /// <returns></returns>
 public static bool ModifyCarById(ref Model.Car model, out string errMsg)
 {
     errMsg = "";
     try
     {
         model.Number      = model.Number.Trim();
         model.Vin         = model.Vin.Trim();
         model.Model       = model.Model.Trim();
         model.Description = model.Description.Trim();
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Id", model.Id),
             new SqlParameter("@Number", model.Number),
             new SqlParameter("@Vin", model.Vin),
             new SqlParameter("@Model", model.Model),
             new SqlParameter("@Description", model.Description),
             new SqlParameter("@Modifier", model.Modifier),
             new SqlParameter("@ModifiedDate", model.ModifiedDate)
         };
         int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_CarByIdUpdate", para);
         if (i > 0)
         {
             EventLog e = new EventLog();
             e.TargetIds = model.Id.ToString();
             e.CodeTag   = "ModifyCarById";
             e.LogName   = "修改车辆";
             EventLogService.AddEventLog <Model.Car>(e, model);
             return(true);
         }
         else
         {
             errMsg = "该记录已被删除,不能修改!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         errMsg = ex.Message;
         ErrorLog e = new ErrorLog();
         e.TargetIds = model.Id.ToString();
         e.CodeTag   = "ModifyCarById";
         e.LogName   = "修改车辆";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Car>(e, model);
         return(false);
     }
 }
Beispiel #37
0
 /// <summary>
 /// 根据id修改车辆
 /// </summary>
 /// <param name="Model.Car"></param>
 /// <returns></returns>
 public static bool ModifyCarById(ref Model.Car model, out string errMsg)
 {
     return(CarService.ModifyCarById(ref model, out errMsg));
 }
Beispiel #38
0
 /// <summary>
 /// 获取单个车辆
 /// </summary>
 /// <param name="id"></param>
 /// <param name="errMsg"></param>
 /// <returns></returns>
 public static Model.Car GetCarById(int id, out string errMsg)
 {
     errMsg = "";
     try
     {
         string         sql  = "";
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Id", id)
         };
         sql = "select * from [Car] where Id = @Id";
         DataTable dt  = DBHelper.ExecuteGetDataTable(CommandType.Text, sql, para);
         Model.Car car = null;
         if (dt.Rows.Count > 0)
         {
             DataRow dr = dt.Rows[0];
             car               = new Car();
             car.Id            = (int)dr["Id"];
             car.Number        = (string)dr["Number"];
             car.Vin           = (string)dr["Vin"];
             car.Model         = (string)dr["Model"];
             car.IsArchived    = (bool)dr["IsArchived"];
             car.InstanceCount = (int)dr["InstanceCount"];
             car.BillCount     = (int)dr["BillCount"];
             if (DBNull.Value.Equals(dr["PreviousOil"]))
             {
                 car.PreviousOil = null;
             }
             else
             {
                 car.PreviousOil = new int?((int)dr["PreviousOil"]);
             }
             if (DBNull.Value.Equals(dr["LastOil"]))
             {
                 car.LastOil = null;
             }
             else
             {
                 car.LastOil = new int?((int)dr["LastOil"]);
             }
             car.LastVolume   = (double)dr["LastVolume"];
             car.LastMileage  = (double)dr["LastMileage"];
             car.LastRate     = (double)dr["LastRate"];
             car.Description  = (string)dr["Description"];
             car.Creater      = (int)dr["Creater"];
             car.CreatedDate  = (DateTime)dr["CreatedDate"];
             car.Modifier     = (int)dr["Modifier"];
             car.ModifiedDate = (DateTime)dr["ModifiedDate"];
         }
         else
         {
             errMsg = "该车辆不存在或已被删除";
         }
         return(car);
     }
     catch (Exception ex)
     {
         errMsg = ex.Message;
         return(null);
     }
 }
Beispiel #39
0
 /// <summary>
 /// 检查是否重复
 /// </summary>
 /// <param name="Model.Car"></param>
 /// <returns></returns>
 public static bool CheckRepeatForVin(Model.Car model)
 {
     return(CarService.CheckRepeatForVin(model));
 }
Beispiel #40
0
 /// <summary>
 /// 添加车辆
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddCar(ref Model.Car model, out string errMsg)
 {
     return(CarService.AddCar(ref model, out errMsg));
 }