public ProductCategoryDomainModel GetProductCategoryDomainModelById(string productCategoryId) { ProductCategoryDomainModel result = null; ProductCategoryInfoModel basicInfo = ProductCategoryInfoService.Instance.GetProductCategoryInfoById(productCategoryId); ProductCategoryGroupInfoModel groupInfo = null; if (basicInfo != null) { groupInfo = ProductCategoryGroupInfoService.Instance.GetProductCategoryGroupById(basicInfo.GroupName); } Dictionary <string, ProductCategoryAttributesModel> AttributeList = ProductCategoryAttributesService.Instance.GetProductCategoryAttributeList(productCategoryId, true); Dictionary <string, ProductCategorySalesStatusModel> SalestatusList = ProductCategorySalesStatusService.Instance.GetProductCategorySalesStatusList(productCategoryId, true); if (basicInfo == null || groupInfo == null || AttributeList == null || SalestatusList == null) { return(null); } result = new ProductCategoryDomainModel(); result.BasicInfo = basicInfo; result.GroupInfo = groupInfo; result.AttributeList = AttributeList; result.SalestatusList = SalestatusList; return(result); }
public bool UpdateProductCategoryGroupInfo(ProductCategoryGroupInfoModel groupInfo, out string message) { bool result = false; message = "操作失败,请与管理员联系"; if (groupInfo == null) { message = "参数错误,请检查输入"; return(false); } if (Update(groupInfo) != 1) { message = "更新产品分组信息失败,请与管理员联系"; result = false; } else { message = "成功更新产品分组"; GetProductCategoryGroupList(true); result = true; } return(result); }
// 在此添加你的代码... public bool CreateProductCategoryGroupInfo(ProductCategoryGroupInfoModel groupInfo, out string message) { bool result = false; message = "操作失败,请与管理员联系"; if (groupInfo == null) { message = "参数错误,请检查输入"; return(false); } if (GetProductCategoryGroupByName(groupInfo.GroupName) != null) { message = "数据库中已经存在相同名字的产品分组名称,请检查输入"; return(false); } //groupInfo.ProductCategoryGroupId = GetGuid(); if (Create(groupInfo) != 1) { message = "创建产品分组失败,请与管理员联系"; result = false; } else { GetProductCategoryGroupList(true); message = "成功创建产品分组"; result = true; } return(result); }
public ProductCategoryGroupInfoModel GetProductCategoryGroupByCategoryId(string productCategoryId) { ProductCategoryGroupInfoModel result = null; ProductCategoryInfoModel catInfo = ProductCategoryInfoService.Instance.GetProductCategoryInfoById(productCategoryId); if (catInfo == null) { return(null); } Dictionary <string, ProductCategoryGroupInfoModel> dict = GetProductCategoryGroupList(false); if (dict != null) { foreach (ProductCategoryGroupInfoModel item in dict.Values) { if (item.ProductCategoryGroupId == catInfo.GroupName) { result = item; break; } } } return(result); }
/// <summary> /// 删除 /// </summary> /// <param name="pc">pc</param> /// <returns>影响的记录行数</returns> public int DeleteMultiple(ParameterCollection pc) { int ret = 0; ProductCategoryGroupInfoModel productcategorygroupinfo = new ProductCategoryGroupInfoModel(); ret = DbUtil.Current.DeleteMultiple(productcategorygroupinfo, pc); return(ret); }
/// <summary> /// 更新 /// </summary> /// <param name="productcategorygroupinfo">实体</param> /// <param name="pc">pc</param> /// <returns>影响的记录行数</returns> public int UpdateMultiple(ProductCategoryGroupInfoModel productcategorygroupinfo, ParameterCollection pc) { int ret = 0; productcategorygroupinfo.ModifiedBy = SessionUtil.Current.UserId; productcategorygroupinfo.ModifiedOn = DateTime.Now; ret = DbUtil.Current.UpdateMultiple(productcategorygroupinfo, pc); return(ret); }
/// <summary> /// 更新 /// </summary> /// <param name="productcategorygroupinfo">实体</param> /// <returns>影响的记录行数</returns> public int Update(ProductCategoryGroupInfoModel productcategorygroupinfo) { int ret = 0; productcategorygroupinfo.ModifiedBy = SessionUtil.Current.UserId; productcategorygroupinfo.ModifiedOn = DateTime.Now; ret = DbUtil.Current.Update(productcategorygroupinfo); return(ret); }
/// <summary> /// 删除 /// </summary> /// <param name="productcategorygroupid"></param> /// <returns>影响的记录行数</returns> public int Delete(string productcategorygroupid) { int ret = 0; ProductCategoryGroupInfoModel productcategorygroupinfo = new ProductCategoryGroupInfoModel(); productcategorygroupinfo.ProductCategoryGroupId = productcategorygroupid; ret = DbUtil.Current.Delete(productcategorygroupinfo); return(ret); }
/// <summary> /// 根据条件获取实体集合 /// </summary> /// <param name="pc">pc</param> /// <param name="obc">obc</param> /// <returns>实体</returns> public List <ProductCategoryGroupInfoModel> RetrieveMultiple(ParameterCollection pc, OrderByCollection obc) { List <ProductCategoryGroupInfoModel> productcategorygroupinfos = new List <ProductCategoryGroupInfoModel>(); ProductCategoryGroupInfoModel productcategorygroupinfo = new ProductCategoryGroupInfoModel(); DataTable dt = DbUtil.Current.RetrieveMultiple(productcategorygroupinfo, pc, obc); for (int i = 0; i < dt.Rows.Count; i++) { productcategorygroupinfo = new ProductCategoryGroupInfoModel(); productcategorygroupinfo.ConvertFrom(dt, i); productcategorygroupinfos.Add(productcategorygroupinfo); } return(productcategorygroupinfos); }
/// <summary> /// 根据主键获取实体 /// </summary> /// <param name="productcategorygroupid"></param> /// <returns>实体</returns> public ProductCategoryGroupInfoModel Retrieve(string productcategorygroupid) { ProductCategoryGroupInfoModel productcategorygroupinfo = new ProductCategoryGroupInfoModel(); productcategorygroupinfo.ProductCategoryGroupId = productcategorygroupid; DataTable dt = DbUtil.Current.Retrieve(productcategorygroupinfo); if (dt.Rows.Count < 1) { return(null); } productcategorygroupinfo.ConvertFrom(dt); return(productcategorygroupinfo); }
public ProductCategoryGroupInfoModel GetProductCategoryGroupById(string groupId) { ProductCategoryGroupInfoModel result = null; Dictionary <string, ProductCategoryGroupInfoModel> dict = GetProductCategoryGroupList(false); if (dict != null) { foreach (ProductCategoryGroupInfoModel item in dict.Values) { if (item.ProductCategoryGroupId == groupId) { result = item; break; } } } return(result); }
public JsonResult DoUpdateProductCategoryGroup() { ProductCategoryGroupInfoModel groupInfo = new ProductCategoryGroupInfoModel(); groupInfo.ProductCategoryGroupId = GetFormData("categoryGroupId"); groupInfo.GroupName = GetFormData("groupName"); groupInfo.IsItemPrice = (GetFormData("isItemPrice") != null) ? ((GetFormData("isItemPrice") == "0") ? 0 : 1) : 1; groupInfo.SortOrder = Convert.ToInt32(GetFormData("sortOrder")); groupInfo.Status = Convert.ToInt32(GetFormData("Status")); groupInfo.Description = GetFormData("categoryGroupDesc"); string message = "操作失败,请与管理员联系"; if (ProductCategoryGroupInfoService.Instance.UpdateProductCategoryGroupInfo(groupInfo, out message)) { return(SuccessedJson(message, "ProductCenter_ProductCategoryGroupMgr", "ProductCenter_ProductCategoryGroupMgr", "closeCurrent", "/productcenter/productcategorygroupmgr")); } else { return(FailedJson(message)); } }
public bool ImportProductCategoryAttributes(DataTable attTable, out string importLogs, out string message) { bool result = false; message = "操作失败,请与管理员联系"; importLogs = ""; if (attTable == null && attTable.Rows.Count == 0) { message = "产品类型属性信息表为空,请检查Excel文件是否正确"; importLogs = message; return(false); } Dictionary <string, ProductCategoryInfoModel> categoryList = ProductCategoryInfoService.Instance.GetProductCategoryList(true); //Dictionary<string, ProductCategoryGroupInfoModel> groupList = ProductCategoryGroupInfoService.Instance.GetProductCategoryGroupList(true); ProductCategoryGroupInfoModel groupInfo = null; if (categoryList == null || categoryList.Count == 0) { message = "数据库中产品类型信息表为空,请检查"; importLogs = message; return(false); } try { BeginTransaction(); ProductCategoryAttributesModel attInfo = null; string[] defaultListValue = null; for (int i = 0; i < attTable.Rows.Count; i++) { if (string.IsNullOrEmpty(attTable.Rows[i]["操作"].ToString())) { continue; } try { attInfo = new ProductCategoryAttributesModel(); defaultListValue = attTable.Rows[i]["属性名称"].ToString().Split(','); attInfo.AttributeName = attTable.Rows[i]["属性名称"].ToString(); if (attInfo.AttributeName == "销售状态" || attInfo.AttributeName == "产品代码" || attInfo.AttributeName == "产品名称") { continue; } attInfo.Description = attTable.Rows[i]["描述信息"].ToString(); attInfo.FieldMaxLength = (attTable.Rows[i]["最大长度"] == DBNull.Value) ? 50 : Convert.ToInt32(attTable.Rows[i]["最大长度"]); attInfo.FieldMinLength = (attTable.Rows[i]["最小长度"] == DBNull.Value) ? 4 : Convert.ToInt32(attTable.Rows[i]["最小长度"]); attInfo.IsDisplay = 0; attInfo.IsRequest = (attTable.Rows[i]["是否必填项"].ToString() == "是") ? 0 : 1; attInfo.Status = (attTable.Rows[i]["状态"].ToString() == "启用") ? 0 : 1; attInfo.NodeId = 0; attInfo.ParentNode = 0; attInfo.GroupName = attTable.Rows[i]["产品类型分组名称"].ToString(); switch (attTable.Rows[i]["字段类型"].ToString()) { case "字符串": attInfo.FieldType = "string"; //attInfo.DefaultValue = (string.IsNullOrEmpty(attTable.Rows[i]["默认值"].ToString()) || attTable.Rows[i]["默认值"] == DBNull.Value) ? null : attTable.Rows[i]["默认值"].ToString(); if (attInfo.FieldMaxLength <= attInfo.FieldMinLength) { RollbackTransaction(); message = string.Format("操作失败,Excel中产品属性【{0}】【{1}】最大长度与最小长度设置错误", attTable.Rows[i]["产品类型分组名称"], attTable.Rows[i]["属性名称"]); return(false); } break; case "数值": attInfo.FieldType = "decimal"; attInfo.FieldMaxLength = (attTable.Rows[i]["最大长度"] == DBNull.Value) ? 12 : Convert.ToInt32(attTable.Rows[i]["最大长度"]); attInfo.FieldMinLength = (attTable.Rows[i]["最小长度"] == DBNull.Value) ? 4 : Convert.ToInt32(attTable.Rows[i]["最小长度"]); break; case "日期时间": attInfo.FieldType = "datetime"; break; case "自定义枚举": attInfo.FieldType = "custom"; attInfo.FieldMaxLength = -1; break; case "长文本": attInfo.FieldType = "text"; attInfo.FieldMaxLength = -1; break; default: break; } if (defaultListValue != null && defaultListValue.Length > 0) { for (int j = 0; j < defaultListValue.Length; j++) { attInfo.CustomValue += defaultListValue[j] + "\n"; } } if (attTable.Rows[i]["操作"].ToString() == "新建") { foreach (ProductCategoryInfoModel catInfo in categoryList.Values) { if (catInfo.GroupName == ProductCategoryGroupInfoService.Instance.GetProductCategoryGroupByName(attTable.Rows[i]["产品类型分组名称"].ToString()).ProductCategoryGroupId) { attInfo.CategoryAttributeId = GetGuid(); attInfo.ProductCategoryId = catInfo.ProductCategoryId; #region 创建产品类型属性 Dictionary <string, ProductCategoryAttributesModel> dict = ProductCategoryAttributesService.Instance.GetProductCategoryAttributeList(attInfo.ProductCategoryId, false); if (dict == null) { message = "操作失败,不存在的产品类型ID"; return(false); } bool execute = true; foreach (ProductCategoryAttributesModel item in dict.Values) { if (item.AttributeName == attInfo.AttributeName) { message = "操作失败,本产品类型存在相同名称属性"; execute = false; break; } } if (execute) { if (ProductCategoryAttributesService.Instance.CreateProductCategoryAttribute(attInfo, out message) == false) { RollbackTransaction(); return(false); } } #endregion } } } } catch (Exception ex2) { RollbackTransaction(); throw ex2; } } CommitTransaction(); } catch (Exception ex) { RollbackTransaction(); LogUtil.Error("导入产品类型属性异常", ex); throw ex; } return(result); }
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); }