/// <summary> /// 从数据库获取自定义枚举字典。 /// </summary> /// <returns></returns> public Dictionary <string, CustomDataDomainModel> GetCustomDataDomainModelListFromDatabase() { Dictionary <string, CustomDataDomainModel> list = null; string sql = @"SELECT * FROM custom_data_info ORDER BY sort_order ASC"; DataTable dt = ExecuteDataTable(sql); if (dt != null && dt.Rows.Count > 0) { list = new Dictionary <string, CustomDataDomainModel>(); CustomDataDomainModel model = null; for (int i = 0; i < dt.Rows.Count; i++) { model = new CustomDataDomainModel(); model.DataCode = dt.Rows[i]["data_code"].ToString(); model.DataId = dt.Rows[i]["data_id"].ToString(); model.DataName = dt.Rows[i]["data_name"].ToString(); model.DataType = dt.Rows[i]["data_type"].ToString(); model.FieldName = dt.Rows[i]["field_name"].ToString(); model.FieldType = dt.Rows[i]["field_type"].ToString(); model.MaxLength = Convert.ToInt32(dt.Rows[i]["max_length"]); model.MinLength = Convert.ToInt32(dt.Rows[i]["min_length"]); model.Requested = dt.Rows[i]["requested"].ToString() == "0"; model.SortOrder = Convert.ToInt32(dt.Rows[i]["sort_order"]); model.Status = Convert.ToInt32(dt.Rows[i]["status"]); list.Add(model.DataId, model); } } return(list); }
/// <summary> /// 根据ID获取自定义枚举信息。 /// </summary> /// <param name="dataId"></param> /// <returns></returns> public CustomDataDomainModel GetCustomDataDomainModelById(string dataId, bool clear) { if (string.IsNullOrEmpty(dataId)) { return(null); } string cacheKey = CacheKey.CUSTOM_DATA_INFO_BYID.GetKeyDefine(dataId); CustomDataDomainModel model = CacheUtil.Get <CustomDataDomainModel>(cacheKey); if (model == null || clear) { model = GetCustomDataDomainModelByIdFromDatabase(dataId); if (model != null) { CacheUtil.Set(cacheKey, model); } else { CacheUtil.Remove(cacheKey); } } return(model); }
/// <summary> /// 新建自定义枚举值。 /// </summary> /// <param name="valueInfo"></param> /// <param name="dataId"></param> /// <returns></returns> public bool NewCustomDataValue(CustomDataValueDomainModel valueInfo, string dataId) { bool result = false; CustomDataDomainModel dataInfo = GetCustomDataDomainModelById(dataId, false); valueInfo.ValueId = Guid.NewGuid().ToString(); valueInfo.DataId = dataId; valueInfo.SortOrder = dataInfo.ValueList.Count + 1; CustomDataValueModel dataModel = new CustomDataValueModel(); dataModel.ValueId = valueInfo.ValueId; dataModel.DataId = dataId; dataModel.DataValue = valueInfo.DataValue; dataModel.DataValueCode = valueInfo.DataValueCode; dataModel.SortOrder = valueInfo.SortOrder; dataModel.Status = valueInfo.Status; if (CustomDataValueService.Instance.Create(dataModel) > 0) { GetCustomDataDomainModelById(dataId, true); result = true; } return(result); }
/// <summary> /// 删除指定枚举值。 /// </summary> /// <param name="dataId"></param> /// <param name="valueId"></param> /// <returns></returns> public bool DeleteCustomDataValue(string dataId, string valueId) { bool result = false; try { BeginTransaction(); if (CustomDataValueService.Instance.Delete(valueId) > 0) { CustomDataDomainModel dataInfo = GetCustomDataDomainModelById(dataId, true); string sql = @"UPDATE custom_data_value SET sort_order = $sort_order$ WHERE value_id = $value_id$"; ParameterCollection pc = new ParameterCollection(); int index = 1; foreach (CustomDataValueDomainModel item in dataInfo.ValueList.Values) { item.SortOrder = index; index++; pc.Clear(); pc.Add("value_id", item.ValueId); pc.Add("sort_order", item.SortOrder); if (ExecuteNonQuery(sql, pc) != 1) { RollbackTransaction(); return(false); } } CommitTransaction(); result = true; } RollbackTransaction(); } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("删除自定义枚举值异常", ex); throw ex; } return(result); }
/// <summary> /// 根据ID从数据库获取自定义枚举信息。 /// </summary> /// <param name="dataId"></param> /// <returns></returns> public CustomDataDomainModel GetCustomDataDomainModelByIdFromDatabase(string dataId) { CustomDataDomainModel model = null; string sql = @"SELECT * FROM custom_data_info WHERE data_id = $data_id$ ORDER BY sort_order ASC"; ParameterCollection pc = new ParameterCollection(); pc.Add("data_id", dataId); DataTable dt = ExecuteDataTable(sql, pc); if (dt != null && dt.Rows.Count > 0) { model = new CustomDataDomainModel(); for (int i = 0; i < dt.Rows.Count; i++) { model = new CustomDataDomainModel(); model.DataCode = dt.Rows[i]["data_code"].ToString(); model.DataId = dt.Rows[i]["data_id"].ToString(); model.DataName = dt.Rows[i]["data_name"].ToString(); model.DataType = dt.Rows[i]["data_type"].ToString(); model.FieldName = dt.Rows[i]["field_name"].ToString(); model.FieldType = dt.Rows[i]["field_type"].ToString(); model.MaxLength = Convert.ToInt32(dt.Rows[i]["max_length"]); model.MinLength = Convert.ToInt32(dt.Rows[i]["min_length"]); model.Requested = dt.Rows[i]["requested"].ToString() == "0"; model.SortOrder = Convert.ToInt32(dt.Rows[i]["sort_order"]); model.Status = Convert.ToInt32(dt.Rows[i]["status"]); List <CustomDataValueDomainModel> valueList = GetCustomDataValueDomainModelListByDataIdFromDatabase(model.DataId); if (valueList != null) { model.ValueList = new Dictionary <string, CustomDataValueDomainModel>(); foreach (CustomDataValueDomainModel valueItem in valueList) { model.ValueList.Add(valueItem.ValueId, valueItem); } } } } return(model); }
public JsonResult DoUpdateSalePackageInfo() { SalesPackageInfoModel package = new SalesPackageInfoModel(); CustomDataDomainModel SaleCityList = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("销售城市", false); package.SalesPackageId = GetFormData("packageId"); package.BeginTime = Convert.ToDateTime(GetFormData("beginTime")); package.EndTime = Convert.ToDateTime(GetFormData("endTime")); package.Location = GetFormData("location"); package.MonthKeepPrice = Convert.ToDecimal(GetFormData("monthKeep")); package.MonthReturnPrice = Convert.ToDecimal(GetFormData("monthReturns")); package.PackageName = GetFormData("packageName"); package.PriceTotal = Convert.ToDecimal(GetFormData("totalPrice")); package.Remark = GetFormData("remark"); package.ReturnMonths = Convert.ToInt32(GetFormData("returnMonths")); package.SalePrice = Convert.ToDecimal(GetFormData("salePrice")); package.SalesCityId = GetFormData("city"); package.SalesCityName = SaleCityList.ValueList[package.SalesCityId].DataValue; package.StagePrice = Convert.ToDecimal(GetFormData("stagePrice")); package.Stages = Convert.ToInt32(GetFormData("stages")); package.StoredPrice = Convert.ToDecimal(GetFormData("storedPrice")); if (Request.Form["chkProCat"] == null) { return(FailedJson("操作失败,请选择产品包包含的产品组成。")); } List <string> productCategoryIdList = Request.Form.GetValues("chkProCat").ToList(); string message = "操作失败,请与管理员联系"; if (SalesPackageInfoService.Instance.UpdateSalePackageInfo(package, productCategoryIdList, out message)) { return(SuccessedJson(message, "BusinessCenter_SalePackageManager", "BusinessCenter_SalePackageManager", "closeCurrent", "/businesscenter/salepackagemanager")); } else { return(FailedJson(message)); } }
public bool ImportProductCategories(DataTable categoryTable, out string importLogs, out string message) { message = "操作失败,请与管理员联系"; importLogs = ""; bool result = false; if (categoryTable == null && categoryTable.Rows.Count == 0) { message = "产品类型信息表为空,请检查Excel文件是否正确"; importLogs = message; return(false); } try { ProductCategoryInfoService.Instance.GetProductCategoryList(true); CustomDataDomainModel SaleCity = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("销售城市", false); BeginTransaction(); ProductCategoryInfoModel catInfo = null; ProductCategoryGroupInfoModel groupInfo = null; for (int i = 0; i < categoryTable.Rows.Count; i++) { catInfo = new ProductCategoryInfoModel(); catInfo.CategoryName = categoryTable.Rows[i]["产品类型名称"].ToString(); catInfo.CategoryCode = categoryTable.Rows[i]["产品类型编码"].ToString(); catInfo.Description = categoryTable.Rows[i]["描述信息"].ToString(); groupInfo = ProductCategoryGroupInfoService.Instance.GetProductCategoryGroupByName(categoryTable.Rows[i]["所属分组名称"].ToString()); if (groupInfo != null) { catInfo.GroupName = groupInfo.ProductCategoryGroupId; } else { groupInfo = new ProductCategoryGroupInfoModel(); groupInfo.Description = string.Format("【{0}】导入数据创建产品分组【{1}】", DateTime.Now, categoryTable.Rows[i]["所属分组名称"].ToString()); groupInfo.GroupName = categoryTable.Rows[i]["所属分组名称"].ToString(); groupInfo.IsItemPrice = (categoryTable.Rows[i]["是否独立价格"].ToString() == "是") ? 0 : 1; groupInfo.Status = 0; groupInfo.ProductCategoryGroupId = GetGuid(); if (ProductCategoryGroupInfoService.Instance.CreateProductCategoryGroupInfo(groupInfo, out message)) { catInfo.GroupName = groupInfo.ProductCategoryGroupId; } else { RollbackTransaction(); message = "创建产品分组失败"; return(false); } } catInfo.ProductCategoryId = GetGuid(); catInfo.ItemPrice = Convert.ToDecimal(categoryTable.Rows[i]["本类产品价格"]); catInfo.Status = (categoryTable.Rows[i]["状态"].ToString() == "启用") ? 0 : 1; foreach (CustomDataValueDomainModel item in SaleCity.ValueList.Values) { if (item.DataValue == categoryTable.Rows[i]["销售城市"].ToString()) { catInfo.SaleCity = item.ValueId; break; } } //if (string.IsNullOrEmpty(catInfo.SaleCity)) //{ // RollbackTransaction(); // message = "Excel中存在未定义的销售城市"; // return false; //} if (categoryTable.Rows[i]["操作"].ToString() == "新建") { if (ProductCategoryInfoService.Instance.CreateProductCategory(catInfo, out message) == false) { RollbackTransaction(); return(false); } } } CommitTransaction(); message = "成功导入产品类型信息表"; ProductCategoryInfoService.Instance.GetProductCategoryList(true); result = true; } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("导入产品类型信息异常", ex); throw ex; } return(result); }
/// <summary> /// 创建产品型信息。 /// </summary> /// <param name="categoryInfo"></param> /// <param name="message"></param> /// <returns></returns> public bool CreateProductCategory(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 != null) { foreach (ProductCategoryInfoModel item in dict.Values) { if (item.CategoryName == categoryInfo.CategoryName) { message = "操作失败,当前存在相同的产品类型名称"; return(false); } } } CustomDataDomainModel SaleCity = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("销售城市", false); string saleCityString = null; foreach (CustomDataValueDomainModel item in SaleCity.ValueList.Values) { saleCityString += item.DataValue + " "; } categoryInfo.ProductCategoryId = GetGuid(); categoryInfo.SortOrder = (dict == null) ? 1 : dict.Count + 1; categoryInfo.TableName = "product_info_" + CharacterUtil.ConvertToPinyin(categoryInfo.CategoryName); #region 创建表字段 List <FieldInfo> fieldList = new List <FieldInfo>(); FieldInfo field = new FieldInfo(); field.FieldName = "product_id"; field.FieldType = "varchar"; field.MinLength = 50; field.MaxLength = 50; field.IsNull = false; field.IsPrimaryKey = true; fieldList.Add(field); field = new FieldInfo(); field.FieldName = "product_category_id"; field.FieldType = "varchar"; field.MinLength = 50; field.MaxLength = 50; field.IsNull = false; field.IsPrimaryKey = false; fieldList.Add(field); field = new FieldInfo(); field.FieldName = "category_group_id"; field.FieldType = "varchar"; field.MinLength = 50; field.MaxLength = 50; field.IsNull = false; field.IsPrimaryKey = false; fieldList.Add(field); field = new FieldInfo(); field.FieldName = "item_price"; field.FieldType = "decimal"; field.MinLength = 18; field.MaxLength = 2; field.DefaultValue = "0"; field.IsNull = false; field.IsPrimaryKey = false; fieldList.Add(field); field = new FieldInfo(); field.FieldName = "created_on"; field.FieldType = "datetime"; field.IsNull = false; field.IsPrimaryKey = false; fieldList.Add(field); field = new FieldInfo(); field.FieldName = "created_by"; field.FieldType = "varchar"; field.MinLength = 50; field.MaxLength = 50; field.IsNull = false; field.IsPrimaryKey = false; fieldList.Add(field); field = new FieldInfo(); field.FieldName = "modified_on"; field.FieldType = "datetime"; field.IsNull = true; field.IsPrimaryKey = false; fieldList.Add(field); field = new FieldInfo(); field.FieldName = "modified_by"; field.FieldType = "varchar"; field.MinLength = 50; field.MaxLength = 50; field.IsNull = true; field.IsPrimaryKey = false; fieldList.Add(field); field = new FieldInfo(); field.FieldName = "status_code"; field.FieldType = "int"; field.IsNull = true; fieldList.Add(field); string createTableSql = DTableUtil.GetCreateTableSQL(categoryInfo.TableName, fieldList); #endregion try { BeginTransaction(); ExecuteNonQuery(createTableSql); if (Create(categoryInfo) == 1) { GetProductCategoryList(true); #region 创建默认字段 ProductCategoryAttributesModel att = new ProductCategoryAttributesModel(); att.AttributeName = "产品代码"; att.CategoryAttributeId = GetGuid(); att.FieldMinLength = 50; att.FieldType = "string"; att.IsDisplay = 0; att.IsRequest = 0; att.NodeId = 0; att.ProductCategoryId = categoryInfo.ProductCategoryId; att.SortOrder = 1; att.Status = 0; if (!ProductCategoryAttributesService.Instance.CreateProductCategoryAttribute(att, out message)) { RollbackTransaction(); return(false); } ProductCategoryAttributesService.Instance.GetProductCategoryAttributeList(categoryInfo.ProductCategoryId, true); att = new ProductCategoryAttributesModel(); att.AttributeName = "产品名称"; att.CategoryAttributeId = GetGuid(); att.FieldMinLength = 50; att.FieldType = "string"; att.IsDisplay = 0; att.IsRequest = 0; att.NodeId = 0; att.ProductCategoryId = categoryInfo.ProductCategoryId; att.SortOrder = 2; att.Status = 0; if (!ProductCategoryAttributesService.Instance.CreateProductCategoryAttribute(att, out message)) { RollbackTransaction(); return(false); } ProductCategoryAttributesService.Instance.GetProductCategoryAttributeList(categoryInfo.ProductCategoryId, true); att = new ProductCategoryAttributesModel(); att.AttributeName = "销售状态"; att.CategoryAttributeId = GetGuid(); att.FieldMinLength = 50; att.FieldType = "custom"; att.CustomValue = "已建档"; att.IsDisplay = 0; att.IsRequest = 0; att.NodeId = 0; att.ProductCategoryId = categoryInfo.ProductCategoryId; att.SortOrder = 3; att.Status = 0; if (!ProductCategoryAttributesService.Instance.CreateProductCategoryAttribute(att, out message)) { RollbackTransaction(); return(false); } ProductCategoryAttributesService.Instance.GetProductCategoryAttributeList(categoryInfo.ProductCategoryId, true); att = new ProductCategoryAttributesModel(); att.AttributeName = "销售城市"; att.CategoryAttributeId = GetGuid(); att.FieldMinLength = 50; att.FieldType = "custom"; att.CustomValue = "所有"; att.IsDisplay = 0; att.IsRequest = 0; att.NodeId = 0; att.ProductCategoryId = categoryInfo.ProductCategoryId; att.SortOrder = 3; att.Status = 0; if (!ProductCategoryAttributesService.Instance.CreateProductCategoryAttribute(att, out message)) { RollbackTransaction(); return(false); } ProductCategoryAttributesService.Instance.GetProductCategoryAttributeList(categoryInfo.ProductCategoryId, true); att = new ProductCategoryAttributesModel(); att.AttributeName = "销售价格"; att.CategoryAttributeId = GetGuid(); att.FieldMinLength = 18; att.FieldMaxLength = 2; att.FieldType = "decimal"; att.CustomValue = "0"; att.IsDisplay = 0; att.IsRequest = 0; att.NodeId = 0; att.ProductCategoryId = categoryInfo.ProductCategoryId; att.SortOrder = 4; att.Status = 0; if (!ProductCategoryAttributesService.Instance.CreateProductCategoryAttribute(att, out message)) { RollbackTransaction(); return(false); } ProductCategoryAttributesService.Instance.GetProductCategoryAttributeList(categoryInfo.ProductCategoryId, true); #endregion #region 创建默认的销售状态 ProductCategorySalesStatusModel saleStatus = new ProductCategorySalesStatusModel(); saleStatus.ProductCategoryId = categoryInfo.ProductCategoryId; saleStatus.SalesStatusId = GetGuid(); saleStatus.SalestatusName = "已建档"; saleStatus.SortOrder = 1; saleStatus.Status = 0; if (!ProductCategorySalesStatusService.Instance.CreateProductCategorySaleStatus(saleStatus, out message)) { RollbackTransaction(); return(false); } ProductCategorySalesStatusService.Instance.GetProductCategorySalesStatusList(categoryInfo.ProductCategoryId, true); #endregion #region 创建默认的销售城市 ProductCategorySalesStatusModel saleCityList = new ProductCategorySalesStatusModel(); saleCityList.ProductCategoryId = categoryInfo.ProductCategoryId; saleCityList.SalesStatusId = GetGuid(); saleCityList.SalestatusName = "所有"; saleCityList.SortOrder = 1; saleCityList.Status = 0; if (!ProductCategorySalesStatusService.Instance.CreateProductCategorySaleStatus(saleCityList, out message)) { RollbackTransaction(); return(false); } ProductCategorySalesStatusService.Instance.GetProductCategorySalesStatusList(categoryInfo.ProductCategoryId, true); #endregion ProductCategoryAttributesService.Instance.GetProductCategoryAttributeList(categoryInfo.ProductCategoryId, true); GetProductCategoryList(true); message = "成功创建产品类型信息"; result = true; CommitTransaction(); } else { RollbackTransaction(); message = "创建产品类型信息失败"; result = false; } } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("创建产品类型异常", ex); throw ex; } return(result); }
// 在此添加你的代码... public bool ImportSalePackageFromExcel(DataSet ds, out string importLogs, out string message) { bool result = false; importLogs = message = "操作失败,请与管理员联系"; if (ds == null && ds.Tables.Count == 0) { message = "Excel数据文件异常,请检查"; return(false); } Dictionary <string, ProductCategoryInfoModel> productCategoryList = ProductCategoryInfoService.Instance.GetProductCategoryList(false); if (productCategoryList == null || productCategoryList.Count == 0) { message = "数据库中无产品类型信息,请检查"; return(false); } ParameterCollection pc = new ParameterCollection(); CustomDataDomainModel SaleCityList = CustomDataInfoService.Instance.GetCustomDataDomainModelByName("销售城市", false); SalesPackageInfoModel salePackInfo = null; ProductCategoryInfoModel proCatInfo = null; List <string> proCatList = new List <string>(); try { BeginTransaction(); for (int t = 0; t < ds.Tables.Count; t++) { if (ds.Tables[t].TableName.Contains("-") == false) { continue; } if (ds.Tables[t].TableName.Split('-')[0] != "营销计划") { continue; } string saleCityName = ds.Tables[t].TableName.Split('-')[1]; CustomDataValueDomainModel saleCityInfo = SaleCityList.GetCustomDataValueDomainByDataValue(saleCityName); if (saleCityInfo == null) { RollbackTransaction(); message = string.Format("数据库中不存在销售城市为【{0}】的营销计划,数据导入失败", saleCityName); return(false); } for (int i = 0; i < ds.Tables[t].Rows.Count; i++) { salePackInfo = new SalesPackageInfoModel(); salePackInfo.BeginTime = Convert.ToDateTime(ds.Tables[t].Rows[i]["有效起始时间"]); salePackInfo.EndTime = Convert.ToDateTime(ds.Tables[t].Rows[i]["有效截止时间"]); salePackInfo.Location = ds.Tables[t].Rows[i]["产品定位"].ToString(); salePackInfo.MonthKeepPrice = Convert.ToDecimal(ds.Tables[t].Rows[i]["每月补存"]); salePackInfo.MonthReturnPrice = Convert.ToDecimal(ds.Tables[t].Rows[i]["每月返还"]); salePackInfo.PackageName = ds.Tables[t].Rows[i]["项目名称"].ToString(); salePackInfo.PriceTotal = Convert.ToDecimal(ds.Tables[t].Rows[i]["业务总额"]); salePackInfo.Remark = ds.Tables[t].Rows[i]["备注信息"].ToString(); salePackInfo.ReturnMonths = Convert.ToInt32(ds.Tables[t].Rows[i]["返还月数"]); salePackInfo.SalePrice = Convert.ToDecimal(ds.Tables[t].Rows[i]["购机金额"]); salePackInfo.SalesCityId = saleCityInfo.ValueId; salePackInfo.SalesCityName = saleCityInfo.DataValue; salePackInfo.SalesPackageId = GetGuid(); salePackInfo.StagePrice = Convert.ToDecimal(ds.Tables[t].Rows[i]["每期金额"]); salePackInfo.Stages = Convert.ToInt32(ds.Tables[t].Rows[i]["分期数"]); salePackInfo.Status = 0; salePackInfo.StoredPrice = Convert.ToDecimal(ds.Tables[t].Rows[i]["预存话费"]); proCatList.Clear(); string[] catNameList = ds.Tables[t].Rows[i]["包含产品"].ToString().Split(','); if (catNameList == null || catNameList.Length == 0) { RollbackTransaction(); message = string.Format("销售城市为【{0}】的营销计划中,营销项目{1}中没有设置包含产品类型名称,数据导入失败", saleCityName, salePackInfo.PackageName); return(false); } for (int j = 0; j < catNameList.Length; j++) { proCatInfo = ProductCategoryInfoService.Instance.GetProductCategoryInfoByName(catNameList[j]); if (proCatInfo == null) { RollbackTransaction(); message = string.Format("销售城市为【{0}】的营销计划中,营销项目{1}中设置包含产品类型名称{2}不存在于数据库,数据导入失败", saleCityName, salePackInfo.PackageName, catNameList[j]); return(false); } proCatList.Add(proCatInfo.ProductCategoryId); } if (SalesPackageInfoService.Instance.CreateSalePackageInfo(salePackInfo, proCatList, out message) == false) { RollbackTransaction(); message = string.Format("销售城市为【{0}】的营销计划中,营销项目{1}数据导入失败", saleCityName, salePackInfo.PackageName); return(false); } } } CommitTransaction(); } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("从Excel导入产品数据异常", ex); throw ex; } return(result); }
// 在此添加你的代码... /// <summary> /// 下移指定枚举值。 /// </summary> /// <param name="dataId"></param> /// <param name="valueId"></param> /// <param name="message"></param> /// <returns></returns> public bool MoveDownCustomDataValue(string dataId, string valueId, out string message) { bool result = false; message = "操作失败,请与管理员联系"; CustomDataDomainModel dataInfo = GetCustomDataDomainModelById(dataId, false); CustomDataValueDomainModel valueInfo = (dataInfo.ValueList.ContainsKey(valueId)) ? dataInfo.ValueList[valueId] : null; if (valueInfo == null) { message = "操作失败,该枚举值不存在"; return(false); } if (valueInfo.SortOrder == dataInfo.ValueList.Count) { message = "操作失败,该枚举值已为最下序列号"; return(false); } CustomDataValueDomainModel downValueInfo = null; foreach (CustomDataValueDomainModel item in dataInfo.ValueList.Values) { if (item.SortOrder == valueInfo.SortOrder + 1) { downValueInfo = item; } } if (downValueInfo != null) { string sql = @"UPDATE custom_data_value SET sort_order = $sort_order$ WHERE value_id = $value_id$"; try { BeginTransaction(); ParameterCollection pc = new ParameterCollection(); pc.Add("value_id", valueInfo.ValueId); pc.Add("sort_order", valueInfo.SortOrder + 1); if (ExecuteNonQuery(sql, pc) > 0) { pc.Clear(); pc.Add("value_id", downValueInfo.ValueId); pc.Add("sort_order", downValueInfo.SortOrder - 1); if (ExecuteNonQuery(sql, pc) > 0) { CommitTransaction(); GetCustomDataDomainModelById(dataId, true); message = "成功下移该自定义枚举值"; return(true); } } RollbackTransaction(); } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("下移自定义枚举信息排序索引异常", ex); throw ex; } } return(result); }