Exemplo n.º 1
0
 /// <summary>
 /// 新增客户信息
 /// </summary>
 /// <param name="customerInfo">客户信息</param>
 public void Add(CustomerInfo customerInfo)
 {
     try
     {
         customer.Add(customerInfo);
     }
     catch (Exception ex)
     {
         BusinessExceptionHandler.HandlerException("新增客户信息失败!", ex);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 新增客户信息
        /// </summary>
        /// <param name="customerInfo">客户信息对象</param>
        public void Add(CustomerInfo customerInfo)
        {
            string commandText = "INSERT INTO Customer(Id,Owner,OwnerAddress,UserName,Sex,Alias,Tel,Mobile,"
                + "UserAddress,Email,WeChat,FreeTime,PreferSupport,PreferSale,PreferDrink,Character,SaleType,"
                + "CreateDate,UpdateDate,Creator,Operator,Valid)VALUES(@Id,@Owner,@OwnerAddress,@UserName,"
                + "@Sex,@Alias,@Tel,@Mobile,@UserAddress,@Email,@WeChat,@FreeTime,@PreferSupport,@PreferSale,"
                + "@PreferDrink,@Character,@SaleType,@CreateDate,@UpdateDate,@Creator,@Operator,@Valid)";

            try
            {
                base.Execute(commandText, connectionString: CarManageConfig.Instance.ConnectionString,
                    param: customerInfo);
            }
            catch (Exception ex)
            {
                DataAccessExceptionHandler.HandlerException("新增客户信息失败!", ex);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新客户信息
 /// </summary>
 /// <param name="customerInfo">客户信息信息对象</param>
 public void Update(CustomerInfo customerInfo)
 {
     try
     {
         customer.Update(customerInfo);
     }
     catch (Exception ex)
     {
         BusinessExceptionHandler.HandlerException("更新客户信息失败!", ex);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 查询客户信息
        /// </summary>
        /// <returns>客户信息集合</returns>
        public List<CustomerInfo> Search(CustomerInfo queryInfo)
        {
            List<CustomerInfo> customerList = new List<CustomerInfo>();

            try
            {
                customerList = customer.Search(queryInfo);
            }
            catch (Exception ex)
            {
                BusinessExceptionHandler.HandlerException("查询客户信息失败!", ex);
            }

            return customerList;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新客户信息
        /// </summary>
        /// <param name="customerInfo">客户信息对象</param>
        public void Update(CustomerInfo customerInfo)
        {
            string commandText = "UPDATE Customer SET "
                + "Owner=@Owner,OwnerAddress=@OwnerAddress,UserName=@UserName,Sex=@Sex,Alias=@Alias,Tel=@Tel,"
                + "Mobile=@Mobile,UserAddress=@UserAddress,Email=@Email,WeChat=@WeChat,FreeTime=@FreeTime,"
                + "PreferSupport=@PreferSupport,PreferSale=@PreferSale,PreferDrink=@PreferDrink,Character=@Character,"
                + "SaleType=@SaleType,CreateDate=@CreateDate,UpdateDate=@UpdateDate,Creator=@Creator,Operator=@Operator,"
                + "Valid=@Valid  WHERE Id=@Id";

            try
            {
                base.Execute(commandText, connectionString: CarManageConfig.Instance.ConnectionString,
                    param: customerInfo);
            }
            catch (Exception ex)
            {
                DataAccessExceptionHandler.HandlerException("更新客户信息失败!", ex);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获得所有客户信息集合
        /// </summary>
        /// <returns>客户信息集合</returns>
        public List<CustomerInfo> Search(CustomerInfo queryInfo)
        {
            IDbConnection connection = null;
            List<CustomerInfo> customerList = new List<CustomerInfo>();

            try
            {
                string field = "*";

                string table = "Customer";
                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 Customer {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 customerList;

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

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

            return customerList;
        }
Exemplo n.º 7
0
        public void Save()
        {
            CustomerInfo customerInfo = new CustomerInfo();

            if (!string.IsNullOrEmpty(CustomerId))
                customerInfo = customer.Load(CustomerId);
            else
            {
                customerInfo.Id = Guid.NewGuid().ToString();
                customerInfo.CreateDate = DateTime.Now;
                customerInfo.Creator = CarManageConfig.Instance.UserData.UserName;
            }

            customerInfo.Owner = CommonUtil.FilterInput(txtOwner.Text);
            customerInfo.OwnerAddress = CommonUtil.FilterInput(txtOwnerAddress.Text);
            customerInfo.UserName = CommonUtil.FilterInput(txtUserName.Text);
            customerInfo.UserAddress = CommonUtil.FilterInput(txtUserAddress.Text);

            if (!CommonUtil.IsNullOrEmpty(cbxSex.SelectedValue))
                customerInfo.Sex = ConvertUtil.ToEnum<Sex>(cbxSex.SelectedValue);

            if (!CommonUtil.IsNullOrEmpty(cbxAlias.SelectedValue))
                customerInfo.Alias = cbxAlias.SelectedValue.ToString();

            customerInfo.Tel = CommonUtil.FilterInput(txtTel.Text);
            customerInfo.Mobile = CommonUtil.FilterInput(txtMobile.Text);
            customerInfo.Email = CommonUtil.FilterInput(txtEmail.Text);
            customerInfo.WeChat = CommonUtil.FilterInput(txtWeChat.Text);

            if (!CommonUtil.IsNullOrEmpty(cbxFreeTime.SelectedValue))
                customerInfo.FreeTime = ConvertUtil.ToEnum<FreeTime>(cbxFreeTime.SelectedValue);

            if (!CommonUtil.IsNullOrEmpty(cbxPreferSupport.SelectedValue))
                customerInfo.PreferSupport = cbxPreferSupport.SelectedValue.ToString();

            if (!CommonUtil.IsNullOrEmpty(cbxPreferSale.SelectedValue))
                customerInfo.PreferSale = cbxPreferSale.SelectedValue.ToString();

            if (!CommonUtil.IsNullOrEmpty(cbxPreferDrink.SelectedValue))
                customerInfo.PreferDrink = cbxPreferSale.SelectedValue.ToString();

            if (!CommonUtil.IsNullOrEmpty(cbxCharacter.SelectedValue))
                customerInfo.Character = ConvertUtil.ToEnum<CustomerCharacter>(cbxCharacter.SelectedValue);

            if (!CommonUtil.IsNullOrEmpty(cbxSaleType.SelectedValue))
                customerInfo.SaleType = cbxSaleType.SelectedValue.ToString();

            customerInfo.UpdateDate = DateTime.Now;
            customerInfo.Operator = CarManageConfig.Instance.UserData.UserName;

            if (string.IsNullOrEmpty(CustomerId))
                customer.Add(customerInfo);
            else
                customer.Update(customerInfo);
        }