コード例 #1
0
ファイル: KitForm.cs プロジェクト: mkbiltek2019/Cas
        private void KitDeleted(object sender, EventArgs e)
        {
            KitFormItem control = (KitFormItem)sender;

            AbstractAccessory kit = control.Kit;

            GlobalObjects.CasEnvironment.Manipulator.Delete(kit);
            _kitParentObject.Kits.Remove((AccessoryRequired)control.Kit);
            _kitControls.Remove(control);
            flowLayoutPanelCharts.Controls.Remove(control);
        }
コード例 #2
0
ファイル: KitsCore.cs プロジェクト: mgladilov/Cas
        ///<summary>
        /// Проставляет товар и стандарт для комплектующего
        ///</summary>
        ///<returns>true - если удалось определеить и проставить продукт и стандарт для комплектующего</returns>
        public bool SetStandartAndProduct(AbstractAccessory accessory, string standartName)
        {
            if (accessory == null)
            {
                throw new ArgumentException("must be not null", "accessory");
            }

            if (accessory.Product != null && accessory.Product.ItemId > 0)
            {
                return(true);
            }

            return(SetStandartAndProduct(accessory, standartName, accessory.PartNumber, accessory.Description,
                                         accessory.Remarks, accessory.Manufacturer,
                                         accessory.GoodsClass, accessory.Measure, accessory.CostNew,
                                         accessory.CostOverhaul, accessory.CostServiceable,
                                         accessory.Suppliers));
        }
コード例 #3
0
ファイル: ProductBindForm.cs プロジェクト: mkbiltek2019/Cas
 public ProductBindForm(AbstractAccessory currentKit) : this()
 {
     _currentKit = currentKit;
 }
コード例 #4
0
 private string GetAccessoryTypeString(AbstractAccessory accessory)
 {
     return(accessory.GoodsClass.ToString());
 }
コード例 #5
0
ファイル: KitForm.cs プロジェクト: mkbiltek2019/Cas
 ///<summary>
 ///</summary>
 public KitForm(AbstractAccessory kit) : this()
 {
     _currentKit = kit;
     UpdateControl();
 }
コード例 #6
0
 ///<summary>
 /// Конструктор, принимающий KIT для отображения
 ///</summary>
 public KitFormItem(AbstractAccessory currentKit) : this()
 {
     _currentKit = currentKit;
     UpdateInformation();
 }
コード例 #7
0
ファイル: KitsCore.cs プロジェクト: mgladilov/Cas
        ///<summary>
        /// Проставляет товар и стандарт для комплектующего
        ///</summary>
        ///<returns>true - если удалось определеить и проставить продукт и стандарт для комплектующего</returns>
        public bool SetStandartAndProduct(AbstractAccessory accessory,
                                          string standartName, string partialNumber, string description, string remarks, string manufacturer,
                                          GoodsClass goodsClass, Measure measure,
                                          double costNew, double costOverhaul, double costServiceable,
                                          IEnumerable <Supplier> suppliers)
        {
            if (accessory == null)
            {
                throw new ArgumentException("must be not null", "accessory");
            }

            if (accessory.Product != null && accessory.Product.ItemId > 0)
            {
                return(true);
            }

            string       standart            = standartName.Replace(" ", "").ToLower();
            string       partNumber          = partialNumber.Replace(" ", "").ToLower();
            bool         needToSaveAccessory = false;
            bool         result       = true;
            GoodStandart goodStandart = null;

            List <GoodStandart> goodStandarts = _loader.GetObjectList <GoodStandart>();
            List <Product>      products;

            if (accessory is Entities.General.Accessory.Component)
            {
                products = new List <Product>(_loader.GetObjectList <ComponentModel>(loadChild: true).ToArray());
            }
            else
            {
                products = _loader.GetObjectList <Product>(loadChild: true);
            }
            if (goodStandarts != null && !string.IsNullOrEmpty(standart))
            {
                goodStandart = goodStandarts
                               .FirstOrDefault(ad => ad.PartNumber.Replace(" ", "").ToLower() == partNumber &&
                                               ad.FullName.Replace(" ", "").ToLower() == standart);
                if (goodStandart == null)
                {
                    goodStandart = new GoodStandart
                    {
                        GoodsClass  = goodsClass,
                        PartNumber  = partialNumber,
                        Description = description,
                        FullName    = standartName,
                        //CostNew = costNew,
                        //CostServiceable = costServiceable,
                        //CostOverhaul = costOverhaul,
                        Remarks = remarks,
                        //Measure = measure
                    };

                    _newKeeper.Save(goodStandart);
                }
                accessory.Standart = goodStandart;

                needToSaveAccessory = true;
            }
            if ((manufacturer != "" || suppliers != null && suppliers.Any()) && products != null)
            {
                Product product = products
                                  .FirstOrDefault(p => p.PartNumber.Replace(" ", "").ToLower() == partNumber &&
                                                  p.Standart != null && p.Standart.FullName.Replace(" ", "").ToLower() == standart);
                if (product == null)
                {
                    if (accessory is Entities.General.Accessory.Component)
                    {
                        ComponentModel dm = new ComponentModel
                        {
                            BatchNumber     = "",
                            CostNew         = costNew,
                            CostOverhaul    = costOverhaul,
                            CostServiceable = costServiceable,
                            Description     = description,
                            GoodsClass      = goodsClass,
                            Manufacturer    = manufacturer,
                            Measure         = measure,
                            PartNumber      = partNumber,
                            Remarks         = remarks,
                        };
                        product = dm;
                    }
                    else
                    {
                        product = new Product
                        {
                            GoodsClass      = goodsClass,
                            PartNumber      = partialNumber,
                            Description     = description,
                            Manufacturer    = manufacturer,
                            Standart        = goodStandart,
                            CostNew         = costNew,
                            CostServiceable = costServiceable,
                            CostOverhaul    = costOverhaul,
                            Remarks         = remarks,
                            Measure         = measure
                        };
                    }

                    _newKeeper.Save(product);

                    if (goodStandart != null && goodStandart.DefaultProductId <= 0)
                    {
                        goodStandart.DefaultProductId = product.ItemId;
                        _newKeeper.Save(goodStandart);
                    }

                    product.SupplierRelations.Clear();
                    foreach (KitSuppliersRelation ksr in accessory.SupplierRelations)
                    {
                        if (ksr.SupplierId != 0)
                        {
                            product.SupplierRelations.Add(ksr);
                            ksr.KitId        = product.ItemId;
                            ksr.ParentTypeId = product.SmartCoreObjectType.ItemId;

                            _newKeeper.Save(ksr);
                        }
                    }
                }

                Entities.General.Accessory.Component component = accessory as Entities.General.Accessory.Component;
                if (component != null)
                {
                    component.Model = product as ComponentModel;
                }
                else
                {
                    accessory.Product = product;
                }

                needToSaveAccessory = true;
            }
            else
            {
                accessory.Product = null;
                result            = false;
            }

            if (needToSaveAccessory)
            {
                _newKeeper.Save(accessory);
            }

            return(result);
        }