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 ChangeProductSaleStatus(string productCategoryId, string productId, string statusName) { bool result = false; ProductCategoryDomainModel category = GetProductCategoryDomainModelById(productCategoryId); if (category == null) { return(false); } ProductInfoDomainModel product = GetProductDomainInfoByProductId(productId, false); if (product == null) { return(false); } if (product.BasicInfo.SalesStatus == statusName) { return(true); } product.BasicInfo.SalesStatus = statusName; //product.AttributeList[""] = statusName; try { BeginTransaction(); if (ProductInfoService.Instance.Update(product.BasicInfo) != 1) { RollbackTransaction(); return(false); } string sql = string.Format(@" UPDATE [{0}] SET [销售状态] = $statusName$, [modified_on] = GETDATE(), [modified_by] = $modifiedBy$ WHERE product_id = $productId$", category.BasicInfo.TableName); ParameterCollection pc = new ParameterCollection(); pc.Add("statusName", statusName); pc.Add("modifiedBy", SessionUtil.Current.UserId); pc.Add("productId", product.BasicInfo.ProductId); if (DbUtil.IBPDBManager.IData.ExecuteNonQuery(sql, pc) == 0) { RollbackTransaction(); return(false); } CommitTransaction(); GetProductDomainInfoByProductId(product.BasicInfo.ProductId, true); result = true; } catch (Exception ex) { RollbackTransaction(); LogUtil.Error(ex.Message, ex); throw ex; } return(result); }