public bool UpdateGroupInfo(CustomerAttributeGroupInfoModel model, out string message)
        {
            bool result = false;

            message       = "操作失败,请与管理员联系";
            model.Tabname = "customer_info_" + CharacterUtil.ConvertToPinyin(model.GroupName);
            Dictionary <string, CustomerAttributeGroupInfoModel> dict = GetCustomeGroupInfoList(true);

            CustomerAttributeGroupInfoModel oldInfo = dict[model.GroupId];

            try
            {
                BeginTransaction();

                if (oldInfo.GroupName != model.GroupName)
                {
                    string NewsTableName = "customer_info_" + CharacterUtil.ConvertToPinyin(model.GroupName);
                    string TableName     = "customer_info_" + CharacterUtil.ConvertToPinyin(oldInfo.GroupName);
                    string renSQL        = DTableUtil.GetRenameTableSQL(TableName, NewsTableName);
                    ExecuteNonQuery(renSQL);
                }

                if (Update(model) == 1)
                {
                    GetGroupInfoById(model.GroupId, true);
                    message = "成功更新客户分组属性";
                    result  = true;

                    CommitTransaction();
                }
                else
                {
                    RollbackTransaction();
                    message = "更新产客户分组属性失败,请与管理员联系";
                    result  = false;
                }
            }
            catch (Exception ex)
            {
                RollbackTransaction();
                LogUtil.Error("更新客户分组属性异常", ex);
                throw ex;
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// 更新产品信息。
        /// </summary>
        /// <param name="categoryInfo"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public bool UpdateProductCategory(ProductCategoryInfoModel categoryInfo, out string message)
        {
            bool result = false;

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

            if (categoryInfo == null || string.IsNullOrEmpty(categoryInfo.CategoryName))
            {
                message = "缺少参数,请与管理员联系";
                return(false);
            }

            Dictionary <string, ProductCategoryInfoModel> dict = GetProductCategoryList(false);

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

            foreach (ProductCategoryInfoModel item in dict.Values)
            {
                if (item.CategoryName == categoryInfo.CategoryName && item.ProductCategoryId != categoryInfo.ProductCategoryId)
                {
                    message = "操作失败,当前存在相同的产品类型名称";
                    return(false);
                }
            }

            ProductCategoryInfoModel oldCatInfo = dict[categoryInfo.ProductCategoryId];

            try
            {
                BeginTransaction();

                if (oldCatInfo.CategoryName != categoryInfo.CategoryName)
                {
                    categoryInfo.TableName = "product_info_" + CharacterUtil.ConvertToPinyin(categoryInfo.CategoryName);
                    string renSQL = DTableUtil.GetRenameTableSQL(oldCatInfo.TableName, categoryInfo.TableName);
                    ExecuteNonQuery(renSQL);
                }

                if (Update(categoryInfo) == 1)
                {
                    CommitTransaction();
                    GetProductCategoryList(true);
                    message = "成功更新产品类型信息";
                    result  = true;
                }
                else
                {
                    RollbackTransaction();
                    message = "更新产品类型信息失败";
                    result  = true;
                }
            }
            catch (Exception ex)
            {
                RollbackTransaction();
                LogUtil.Error("更新产品类型信息异常", ex);
                throw ex;
            }

            return(result);
        }