Esempio n. 1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (this.ucPMPicker.SelectedPMSysNo == null)
            {
                CPApplication.Current.CurrentPage.Context.Window.Alert("请选择PM!", MessageType.Warning);
                return;
            }
            //查询空二级类得时候才会显示Domain列表
            BatchUpdatePMReq req = new BatchUpdatePMReq
            {
                ProductDomainSysNo = cmbDomains.Visibility == System.Windows.Visibility.Visible ? int.Parse(cmbDomains.SelectedValue.ToString()) : default(int?),
                PMSysNo            = ucPMPicker.SelectedPMSysNo
            };

            this.CategoryList.ForEach(p =>
            {
                var category = new ProductDepartmentCategory {
                    SysNo = p.SysNo, C2SysNo = p.C2SysNo
                };
                req.DepartmentCategoryList.Add(category);
            });

            new ProductDomainFacade(this.Page).BatchUpdatePM(req, (obj, args) =>
            {
                this.Dialog.ResultArgs = new ResultEventArgs {
                    DialogResult = DialogResultType.OK
                };
                this.Dialog.Close();
            });
        }
Esempio n. 2
0
        public virtual ProductDepartmentCategory CreateDepartmentCategory(ProductDepartmentCategory entity)
        {
            ValidateProductDepartmentCategory(entity);

            var repeatedCategories = da.GetExistingProductCategories(new List <int> {
                entity.C2SysNo.Value,
            }, 0);

            //指定的二级类是否在其他Domain存在
            if (repeatedCategories.Any(e => e.ProductDomainSysNo != entity.ProductDomainSysNo && e.C2SysNo == entity.C2SysNo))
            {
                throw new BizException(ResouceManager.GetMessageString("IM.Product", "ProductDomainCreateDepartmentCategory1"));
            }
            //是否会导致新分类重复
            if (repeatedCategories.Any(e => e.C2SysNo == entity.C2SysNo && e.BrandSysNo == entity.BrandSysNo))
            {
                throw new BizException(ResouceManager.GetMessageString("IM.Product", "ProductDomainCreateDepartmentCategory2"));
            }

            using (TransactionScope scope = new TransactionScope())
            {
                da.CreateDepartmentCategory(entity);

                da.CreateProductDomainChangePool(entity.ProductDomainSysNo.Value);

                scope.Complete();
            }

            return(entity);
        }
Esempio n. 3
0
        public DataTable GetTheCountOfDepartmentCategoryRelatedInfo(ProductDepartmentCategory entity)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("ProductDomain_GetTheCountOfDepartmentCategoryReltedInfo");

            cmd.SetParameterValue("@PMSysNo", entity.PMSysNo);
            cmd.SetParameterValue("@BrandSysNo", entity.BrandSysNo);
            cmd.SetParameterValue("@C2SysNo", entity.C2SysNo);

            return(cmd.ExecuteDataSet().Tables[0]);
        }
Esempio n. 4
0
        public void UpdateDepartmentCategory(ProductDepartmentCategory entity)
        {
            DataCommand cmd = DataCommandManager.GetDataCommand("ProductDomain_UpdateDepartmentCategory");

            cmd.SetParameterValue("@SysNo", entity.SysNo);
            cmd.SetParameterValue("@C2SysNo", entity.C2SysNo);
            cmd.SetParameterValue("@BrandSysNo", entity.BrandSysNo);
            cmd.SetParameterValue("@PMSysNo", entity.PMSysNo);

            cmd.ExecuteNonQuery();
        }
Esempio n. 5
0
        public virtual void UpdateDepartmentCategory(ProductDepartmentCategory entity)
        {
            ValidateProductDepartmentCategory(entity);
            ValidateUpdateProductDepartmentCateogry(entity);
            using (TransactionScope scope = new TransactionScope())
            {
                da.UpdateDepartmentCategory(entity);

                da.CreateProductDomainChangePool(entity.ProductDomainSysNo.Value);

                scope.Complete();
            }
        }
Esempio n. 6
0
        public void CreateDepartmentCategory(ProductDepartmentCategory category)
        {
            var c = DataCommandManager.GetDataCommand("ProductDomain_CreateDepartmentCategory");

            c.SetParameterValue <ProductDepartmentCategory>(category);
            var sysNo = c.ExecuteScalar();

            if (sysNo is System.DBNull || sysNo == null)
            {
                return;
            }
            category.SysNo = System.Convert.ToInt32(sysNo);
        }
Esempio n. 7
0
        private void ValidateProductDepartmentCategory(ProductDepartmentCategory entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }
            if (entity.C2SysNo == null)
            {
                throw new ArgumentNullException("entity.C2SysNo");
            }
            if (entity.PMSysNo == null)
            {
                throw new ArgumentNullException("entity.PMSysNo");
            }
            if (entity.ProductDomainSysNo == null)
            {
                throw new ArgumentNullException("entity.ProductDomainSysNo");
            }
            var productDomain = LoadBySysNo(entity.ProductDomainSysNo.Value);

            if (productDomain == null)
            {
                throw new BizException(ResouceManager.GetMessageString("IM.Product", "ProductDomainValidateProductDepartmentCategoryResult1"));
            }
            var dtInfo  = da.GetTheCountOfDepartmentCategoryRelatedInfo(entity);
            var message = new List <string>();

            if ((int)dtInfo.Rows[0]["IsValidC2SysNo"] == 0)
            {
                message.Add(ResouceManager.GetMessageString("IM.Product", "ProductDomainValidateProductDepartmentCategoryResult2"));
            }
            if (entity.BrandSysNo.HasValue && (int)dtInfo.Rows[0]["IsValidBrandSysNo"] == 0)
            {
                message.Add(ResouceManager.GetMessageString("IM.Product", "ProductDomainValidateProductDepartmentCategoryResult3"));
            }
            if ((int)dtInfo.Rows[0]["IsValidPMSysNo"] == 0)
            {
                message.Add(ResouceManager.GetMessageString("IM.Product", "ProductDomainValidateProductDepartmentCategoryResult4"));
            }
            if (message.Any())
            {
                throw new BizException(ResouceManager.GetMessageString("IM.Product", "ProductDomainValidateProductDepartmentCategoryResult5") + message.Join(","));
            }
        }
Esempio n. 8
0
        private void ValidateUpdateProductDepartmentCateogry(ProductDepartmentCategory entity)
        {
            var existsingCategory = da.LoadDepartmentCategoryBySysNo(entity.SysNo.Value);

            if (existsingCategory == null)
            {
                throw new BizException(ResouceManager.GetMessageString("IM.Product", "PorductDomainValidateUpdateProductDepartmentCateogry1"));
            }

            //如果没有修改过二级类及品牌, 直接允许通过
            if (entity.C2SysNo == existsingCategory.C2SysNo && entity.BrandSysNo == existsingCategory.BrandSysNo)
            {
                return;
            }

            var repeatedCategories = da.GetExistingProductCategories(new List <int> {
                entity.C2SysNo.Value, existsingCategory.C2SysNo.Value
            }, 0);

            repeatedCategories = repeatedCategories.Where(e => e.SysNo != entity.SysNo).ToList();
            //指定的二级类是否在其他Domain存在
            if (repeatedCategories.Any(e => e.ProductDomainSysNo != entity.ProductDomainSysNo && e.C2SysNo == entity.C2SysNo))
            {
                throw new BizException(ResouceManager.GetMessageString("IM.Product", "PorductDomainValidateUpdateProductDepartmentCateogry2"));
            }

            //是否会导致新分类重复
            if (repeatedCategories.Any(e => e.C2SysNo == entity.C2SysNo && e.BrandSysNo == entity.BrandSysNo))
            {
                throw new BizException(ResouceManager.GetMessageString("IM.Product", "PorductDomainValidateUpdateProductDepartmentCateogry3"));
            }
            //不重复, 将新数据插入列表, 模拟最后的结果集,验证之
            repeatedCategories.Add(entity);

            var oldCatgeories = repeatedCategories.Where(e => e.C2SysNo == existsingCategory.C2SysNo).ToList();

            //如果会导致原分类丢失PM
            ValidateDepartmentCategories(oldCatgeories, existsingCategory.C2SysNo.Value);
        }
Esempio n. 9
0
 public virtual void UpdateDepartmentCategory(ProductDepartmentCategory entity)
 {
     ObjectFactory <ProductDomainProcessor> .Instance.UpdateDepartmentCategory(entity);
 }
Esempio n. 10
0
 public virtual ProductDepartmentCategory CreateDepartmentCategory(ProductDepartmentCategory entity)
 {
     return(ObjectFactory <ProductDomainProcessor> .Instance.CreateDepartmentCategory(entity));
 }