Esempio n. 1
0
        /// <summary>
        /// 新增保险信息
        /// </summary>
        /// <param name="insuranceInfo">保险信息对象</param>
        public void Add(InsuranceInfo insuranceInfo)
        {
            IDbTransaction transaction = null;

            string commandText = @"INSERT INTO Insurance(Id,CarNumber,FrameNumber,EngineNumber,ItemSummary,Insurant,"
                + "InsurantPhone,InsurantId,InsuranceCompany,Amount,Local,InsuranceDate,NextInsuranceDate,"
                + "RemindDate,CreateDate,UpdateDate,Creator,Operator,Valid)VALUES(@Id,@CarNumber,@FrameNumber,"
                + "@EngineNumber,@ItemSummary,@Insurant,@InsurantPhone,@InsurantId,@InsuranceCompany,@Amount,@Local,"
                + "@InsuranceDate,@NextInsuranceDate,@RemindDate,@CreateDate,@UpdateDate,@Creator,@Operator,@Valid)";

            try
            {
                transaction = base.BeginTransaction(CarManageConfig.Instance.ConnectionString);

                base.Execute(commandText, transaction:transaction, param: insuranceInfo);

                commandText = "INSERT INTO InsuranceItem(Id,InsuranceId,CarId,ItemName,ItemCode,Amount)"
                    + "VALUES(@Id,@InsuranceId,@CarId,@ItemName,@ItemCode,@Amount)";

                base.Execute(commandText, transaction: transaction, param: insuranceInfo.Items);

                base.Commit(transaction);
            }
            catch (Exception ex)
            {
                base.Rollback(transaction);
                DataAccessExceptionHandler.HandlerException("新增保险信息失败!", ex);
            }
            finally
            {
                CloseConnection(transaction.Connection);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 新增保险信息
 /// </summary>
 /// <param name="insuranceInfo">保险信息</param>
 public void Add(InsuranceInfo insuranceInfo)
 {
     try
     {
         insuranceInfo.ItemSummary = GetItemSummary(insuranceInfo.Items);
         insurance.Add(insuranceInfo);
     }
     catch (Exception ex)
     {
         BusinessExceptionHandler.HandlerException("新增保险信息失败!", ex);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 查询保险信息
        /// </summary>
        /// <returns>保险信息集合</returns>
        public List<InsuranceInfo> Search(InsuranceInfo queryInfo)
        {
            List<InsuranceInfo> insuranceList = new List<InsuranceInfo>();

            try
            {
                insuranceList = insurance.Search(queryInfo);
            }
            catch (Exception ex)
            {
                BusinessExceptionHandler.HandlerException("查询保险信息失败!", ex);
            }

            return insuranceList;
        }
Esempio n. 4
0
        public void Save()
        {
            try
            {
                InsuranceInfo insuranceInfo = new InsuranceInfo();

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

                insuranceInfo.FrameNumber = CommonUtil.FilterInput(txtFrameNumber.Text);
                insuranceInfo.EngineNumber = CommonUtil.FilterInput(txtEngineNumber.Text);
                insuranceInfo.Insurant = CommonUtil.FilterInput(txtInsurant.Text);
                insuranceInfo.InsurantPhone = CommonUtil.FilterInput(txtInsurantPhone.Text);
                insuranceInfo.InsuranceCompanyCode = cbxInsuranceCompany.SelectedValue.ToString();
                insuranceInfo.Local = chkLocal.Checked;

                foreach (ListControlItem item in chklstItems.SelectedItem)
                {
                    insuranceInfo.Items.Add(new InsuranceItemInfo()
                    {
                        Id = Guid.NewGuid().ToString(),
                        InsuranceId = insuranceInfo.Id,
                        CarId = this.CarId,
                        ItemName = item.Text,
                        ItemCode = item.Value,
                    });
                }

                insuranceInfo.Amount = ConvertUtil.ToDecimal(CommonUtil.FilterInput(txtAmount.Text));
                insuranceInfo.NextInsuranceDate = ConvertUtil.ToNullableDateTime(dtpNextInsuranceDate.Text);
                insuranceInfo.Operator = CarManageConfig.Instance.UserData.UserName;
                insuranceInfo.UpdateDate = DateTime.Now;
                insuranceInfo.Valid = true;

                if (string.IsNullOrEmpty(InsuranceId))
                {
                    insurance.Add(insuranceInfo);
                }
                else
                {
                    insurance.Update(insuranceInfo);
                }
            }
            catch (Exception ex)
            {
                UserInterfaceExceptionHandler.HandlerException("保存保险信息失败!", ref ex);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 更新保险信息
        /// </summary>
        /// <param name="insuranceInfo">保险信息对象</param>
        public void Update(InsuranceInfo insuranceInfo)
        {
            IDbTransaction transaction = base.BeginTransaction(CarManageConfig.Instance.ConnectionString);

            string commandText = "UPDATE Insurance SET "
                + "CarNumber=@CarNumber,FrameNumber=@FrameNumber,EngineNumber=@EngineNumber,ItemSummary=@ItemSummary,"
                + "Insurant=@Insurant,InsurantPhone=@InsurantPhone,InsurantId=@InsurantId,InsuranceCompany=@InsuranceCompany,"
                + "Amount=@Amount,Local=@Local,InsuranceDate=@InsuranceDate,NextInsuranceDate=@NextInsuranceDate,"
                + "RemindDate=@RemindDate,CreateDate=@CreateDate,UpdateDate=@UpdateDate,Creator=@Creator,"
                + "Operator=@Operator,Valid=@Valid WHERE Id=@Id";

            try
            {
                base.Execute(commandText, transaction: transaction, param: insuranceInfo);

                commandText = "DELETE FROM InsuranceItem WHERE InsuranceId=@InsuranceId";

                base.Execute(commandText, transaction: transaction, param: new { InsuranceId = insuranceInfo.Id });

                commandText = "INSERT INTO InsuranceItem(Id,InsuranceId,CarId,ItemNameItemCode,Amount)"
                    + "VALUES(@Id,@InsuranceId,@CarId,@ItemName,@ItemCode,@Amount)";

                base.Execute(commandText, transaction: transaction, param: insuranceInfo.Items);

                base.Commit(transaction);
            }
            catch (Exception ex)
            {
                base.Rollback(transaction);
                DataAccessExceptionHandler.HandlerException("更新保险信息失败!", ex);
            }
            finally
            {
                CloseConnection(transaction.Connection);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 获得所有保险信息集合
        /// </summary>
        /// <returns>保险信息集合</returns>
        public List<InsuranceInfo> Search(InsuranceInfo queryInfo)
        {
            IDbConnection connection = null;
            List<InsuranceInfo> insuranceList = new List<InsuranceInfo>();

            try
            {
                string field = "*";

                string table = "Insurance";
                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 Insurance {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 insuranceList;

                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);

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

            return insuranceList;
        }