示例#1
0
文件: Car.cs 项目: wxll1120/c585b99f
 /// <summary>
 /// 新增车辆信息
 /// </summary>
 /// <param name="carInfo">车辆信息</param>
 public void Add(CarInfo carInfo)
 {
     try
     {
         SetGuaratee(carInfo);
         car.Add(carInfo);
     }
     catch (Exception ex)
     {
         BusinessExceptionHandler.HandlerException("新增车辆信息失败!", ex);
     }
 }
示例#2
0
文件: Car.cs 项目: wxll1120/c585b99f
        /// <summary>
        /// 新增车辆信息
        /// </summary>
        /// <param name="carInfo">车辆信息对象</param>
        public void Add(CarInfo carInfo)
        {
            string commandText = "INSERT INTO Car(Id,CustomerId,Number,Brand,Model,Displacement,"
                + "FrameNumber,EngineNumber,BodyColor,InteriorColor,InvoiceDate,BuyMileage,"
                + "RegisterDate,Mileage,MaintenancePeriod,MaintenanceMileage,NextMaintenanceDate,"
                + "NextMaintenanceMileage,GuaranteePeriod,GuaranteeMileage,ActualGuaranteeDate,"
                + "ActualGuaranteeMileage,CreateDate,UpdateDate,Creator,Operator,Valid)"
                + " VALUES(@Id,@CustomerId,@Number,@Brand,@Model,@Displacement,@FrameNumber,"
                + "@EngineNumber,@BodyColor,@InteriorColor,@InvoiceDate,@BuyMileage,@RegisterDate,"
                + "@Mileage,@MaintenancePeriod,@MaintenanceMileage,@NextMaintenanceDate,"
                + "@NextMaintenanceMileage,@GuaranteePeriod,@GuaranteeMileage,@ActualGuaranteeDate,"
                + "@ActualGuaranteeMileage,@CreateDate,@UpdateDate,@Creator,@Operator,@Valid)";

            try
            {
                base.Execute(commandText, connectionString: CarManageConfig.Instance.ConnectionString,
                    param: carInfo);
            }
            catch (Exception ex)
            {
                DataAccessExceptionHandler.HandlerException("新增车辆信息失败!", ex);
            }
        }
示例#3
0
文件: Car.cs 项目: wxll1120/c585b99f
        /// <summary>
        /// 更新车辆信息
        /// </summary>
        /// <param name="carInfo">车辆信息对象</param>
        public void Update(CarInfo carInfo)
        {
            string commandText = "UPDATE Car SET " +
                "CustomerId=@CustomerId,Number=@Number,Brand=@Brand,Model=@Model,Displacement=@Displacement,"
                + "FrameNumber=@FrameNumber,EngineNumber=@EngineNumber,BodyColor=@BodyColor,"
                + "InteriorColor=@InteriorColor,InvoiceDate=@InvoiceDate,BuyMileage=@BuyMileage,"
                + "RegisterDate=@RegisterDate,Mileage=@Mileage,MaintenancePeriod=@MaintenancePeriod,"
                + "MaintenanceMileage=@MaintenanceMileage,NextMaintenanceDate=@NextMaintenanceDate,"
                + "NextMaintenanceMileage=@NextMaintenanceMileage,GuaranteePeriod=@GuaranteePeriod,"
                + "GuaranteeMileage=@GuaranteeMileage,ActualGuaranteeDate=@ActualGuaranteeDate,"
                + "ActualGuaranteeMileage=@ActualGuaranteeMileage,CreateDate=@CreateDate,"
                + "UpdateDate=@UpdateDate,Creator=@Creator,Operator=@Operator,Valid=@Valid "
                + "WHERE Id=@Id";

            try
            {
                base.Execute(commandText, connectionString: CarManageConfig.Instance.ConnectionString,
                    param: carInfo);
            }
            catch (Exception ex)
            {
                DataAccessExceptionHandler.HandlerException("更新车辆信息失败!", ex);
            }
        }
示例#4
0
文件: Car.cs 项目: wxll1120/c585b99f
        /// <summary>
        /// 获得所有车辆信息集合
        /// </summary>
        /// <returns>车辆信息集合</returns>
        public List<CarInfo> Search(CarInfo queryInfo)
        {
            IDbConnection connection = null;
            List<CarInfo> carList = new List<CarInfo>();

            try
            {
                string field = "*";

                string table = "Car";
                string order = "ORDER BY Id";

                StringBuilder filter = new StringBuilder();

                #region 查询条件

                #endregion

                string filterText = string.Empty;

                if (filter.Length > 0)
                {
                    filterText = filter.ToString().TrimStart(' ').Remove(0, 3).Insert(0, " WHERE ");
                }

                string commandText = string.Format("SELECT COUNT(*) FROM Car {0}", filterText);

                connection = base.CreateConnection(CarManageConfig.Instance.ConnectionString);

                queryInfo.TotalCount = base.ExecuteObject<int>(commandText: commandText,
                    connection: connection, param: queryInfo);

                if (queryInfo.TotalCount.Equals(0))
                    return carList;

                int pageCount = queryInfo.TotalCount / queryInfo.PageSize + 1;

                if (queryInfo.TotalCount % queryInfo.PageSize != 0)
                    pageCount++;

                int startIndex = queryInfo.PageIndex * queryInfo.PageSize;

                commandText = string.Format("SELECT {0} FROM {1} WHERE {2} ORDER BY {3} LIMIT {4},{5}",
                    field, table, filterText, order, startIndex, queryInfo.PageSize);

                carList = base.Query<CarInfo>(commandText, connection, param: queryInfo).ToList();
            }
            catch (Exception ex)
            {
                DataAccessExceptionHandler.HandlerException(
                    "查询车辆信息失败!", ex);
            }
            finally
            {
                CloseConnection(connection);
            }

            return carList;
        }
示例#5
0
        public void Save()
        {
            CarInfo carInfo = new CarInfo();

            if (string.IsNullOrEmpty(CarId))
            {
                carInfo.Id = Guid.NewGuid().ToString();
                carInfo.CreateDate = DateTime.Now;
                carInfo.Creator = CarManageConfig.Instance.UserData.UserName;
            }
            else
            {
                carInfo = car.Load(CarId);
            }

            carInfo.CustomerId = CustomerId;
            carInfo.Number = CommonUtil.FilterInput(txtNumber.Text);
            carInfo.Brand = CommonUtil.FilterInput(txtBrand.Text);
            carInfo.Model = CommonUtil.FilterInput(txtModel.Text);
            carInfo.Displacement = ConvertUtil.ToNullableDecimal(CommonUtil.FilterInput(txtDisplacement.Text));
            carInfo.FrameNumber = CommonUtil.FilterInput(txtFrameNumber.Text);
            carInfo.EngineNumber = CommonUtil.FilterInput(txtEngineNumber.Text);
            carInfo.BodyColor = CommonUtil.FilterInput(txtBodyColor.Text);
            carInfo.InteriorColor = CommonUtil.FilterInput(txtInteriorColor.Text);
            carInfo.InvoiceDate = ConvertUtil.ToNullableDateTime(dtpInvoiceDate.Text);
            carInfo.BuyMileage = ConvertUtil.ToNullableInt32(CommonUtil.FilterInput(txtBuyMileage.Text));
            carInfo.RegisterDate = ConvertUtil.ToNullableDateTime(dtpRegisterDate.Text);
            carInfo.Mileage = Convert.ToInt32(CommonUtil.FilterInput(txtMileage.Text));
            carInfo.MaintenancePeriod = ConvertUtil.ToInt32(cbxMaintenancePeriod.SelectedValue);
            carInfo.MaintenanceMileage = ConvertUtil.ToInt32(cbxMaitenanceMileage.SelectedValue);
            carInfo.NextMaintenanceDate = ConvertUtil.ToNullableDateTime(dtpNextMaintenanceDate.Text);
            carInfo.NextMaintenanceMileage = ConvertUtil.ToNullableInt32(CommonUtil.FilterInput(txtNextMaintenanceMileage.Text));
            carInfo.GuaranteePeriod = ConvertUtil.ToNullableInt32(CommonUtil.FilterInput(txtGuaranteePeriod.Text));
            carInfo.GuaranteeMileage = ConvertUtil.ToNullableInt32(CommonUtil.FilterInput(txtGuaranteeMileage.Text));
            carInfo.UpdateDate = DateTime.Now;
            carInfo.Operator = CarManageConfig.Instance.UserData.UserName;
            carInfo.Valid = true;

            if (string.IsNullOrEmpty(CarId))
            {
                car.Add(carInfo);
                CarId = carInfo.Id;
            }
            else
            {
                car.Update(carInfo);
            }
        }
示例#6
0
文件: Car.cs 项目: wxll1120/c585b99f
        /// <summary>
        /// 设置实际质保到期日期及里程
        /// </summary>
        /// <param name="carInfo">车辆信息对象</param>
        private void SetGuaratee(CarInfo carInfo)
        {
            if (carInfo.InvoiceDate.HasValue && carInfo.GuaranteePeriod.HasValue)
            {
                carInfo.ActualGuaranteeDate = carInfo.InvoiceDate.Value.AddYears(carInfo.GuaranteePeriod.Value);
            }

            if (carInfo.GuaranteeMileage.HasValue)
                carInfo.ActualGuaranteeMileage = carInfo.GuaranteeMileage.Value;
        }
示例#7
0
文件: Car.cs 项目: wxll1120/c585b99f
 /// <summary>
 /// 更新车辆信息
 /// </summary>
 /// <param name="carInfo">车辆信息信息对象</param>
 public void Update(CarInfo carInfo)
 {
     try
     {
         SetGuaratee(carInfo);
         car.Update(carInfo);
     }
     catch (Exception ex)
     {
         BusinessExceptionHandler.HandlerException("更新车辆信息失败!", ex);
     }
 }
示例#8
0
文件: Car.cs 项目: wxll1120/c585b99f
        /// <summary>
        /// 查询车辆信息
        /// </summary>
        /// <returns>车辆信息集合</returns>
        public List<CarInfo> Search(CarInfo queryInfo)
        {
            List<CarInfo> carList = new List<CarInfo>();

            try
            {
                carList = car.Search(queryInfo);
            }
            catch (Exception ex)
            {
                BusinessExceptionHandler.HandlerException("查询车辆信息失败!", ex);
            }

            return carList;
        }