/// <summary>
        /// 根据ID删除客户属性信息。
        /// </summary>
        /// <param name="departmentId"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool DeleteCustomerAttributeById(string extattributeid, out string message)
        {
            message = "操作失败,请与管理员联系";
            bool result = false;
            CustomerExtAttributesModel model = GetCustomerAttributeById(extattributeid, true);


            Dictionary <string, CustomerAttributeGroupInfoModel> dict = CustomerAttributeGroupInfoService.Instance.GetCustomeGroupInfoList(true);

            CustomerAttributeGroupInfoModel oldInfo = dict[model.GroupId];

            try
            {
                BeginTransaction();
                string TableName      = "customer_info_" + CharacterUtil.ConvertToPinyin(oldInfo.GroupName);
                string deleteFieldSQL = DTableUtil.GetDeleteFieldSQL(TableName, model.AttributeName);

                ExecuteNonQuery(deleteFieldSQL);
                if (Delete(extattributeid) > 0)
                {
                    CommitTransaction();
                    result  = true;
                    message = "成功删除客户属性信息";
                    GetCustomerAttributeList(extattributeid, true);
                }
                else
                {
                    RollbackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollbackTransaction();
                LogUtil.Error("删除删除客户属性信息异常", ex);
                throw ex;
            }

            return(result);
        }
Beispiel #2
0
        public bool DeleteProductCategoryAttribute(string productCategoryId, string productAttributeId, out string message)
        {
            bool result = false;

            message = "操作失败,请与管理员联系";

            Dictionary <string, ProductCategoryAttributesModel> dict = GetProductCategoryAttributeList(productCategoryId, false);

            if (dict == null)
            {
                message = "操作失败,不存在的产品类型ID";
                return(false);
            }

            ProductCategoryAttributesModel currInfo = GetProductCategoryAttributeById(productCategoryId, productAttributeId);

            if (currInfo == null)
            {
                message = "操作失败,不存在的产品类型属性ID";
                return(false);
            }

            ProductCategoryInfoModel catInfo = ProductCategoryInfoService.Instance.GetProductCategoryInfoById(currInfo.ProductCategoryId);

            if (catInfo == null)
            {
                message = "操作失败,不存在的产品类型ID";
                return(false);
            }

            try
            {
                BeginTransaction();

                foreach (ProductCategoryAttributesModel item in dict.Values)
                {
                    if (item.SortOrder > currInfo.SortOrder)
                    {
                        item.SortOrder = item.SortOrder + 1;
                        if (Update(item) != 1)
                        {
                            message = "更新产品属性排序索引失败,请与管理员联系";
                            RollbackTransaction();
                            return(false);
                        }
                    }
                }

                string deleteFieldSQL = DTableUtil.GetDeleteFieldSQL(catInfo.TableName, currInfo.AttributeName);

                ExecuteNonQuery(deleteFieldSQL);

                if (Delete(currInfo.CategoryAttributeId) == 1)
                {
                    CommitTransaction();
                    message = "成功删除选中产品属性";
                    GetProductCategoryAttributeList(currInfo.ProductCategoryId, true);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                RollbackTransaction();
                LogUtil.Error("删除选中产品类型属性异常", ex);
                result  = false;
                message = "操作失败,删除选中产品类型属性异常";
            }

            return(result);
        }