public static bool SaveChanges(this MDPart part, EplPartProperties eplPartProperties)
        {
            try
            {
                part.GenericProductGroup = MDPartsDatabaseItem.Enums.ProductTopGroup.Electric;
                part.ProductGroup        = MDPartsDatabaseItem.Enums.ProductGroup.Common;
                part.ProductSubGroup     = MDPartsDatabaseItem.Enums.ProductSubGroup.Common;

                part.Properties.ARTICLE_SUPPLIER          = eplPartProperties.Supplier;
                part.Properties.ARTICLE_NOTE              = eplPartProperties.Description;
                part.Properties.ARTICLE_MANUFACTURER      = eplPartProperties.Manufacturer;
                part.Properties.ARTICLE_ORDERNR           = eplPartProperties.OrderNumber;
                part.Properties.ARTICLE_QUANTITYUNIT      = eplPartProperties.Unit;
                part.Properties.ARTICLE_PACKAGINGQUANTITY = eplPartProperties.Quantity;
                part.Properties.ARTICLE_MACRO             = eplPartProperties.Macro;

                if (eplPartProperties.PartFreeProperties != null)
                {
                    for (int i = 0; i < eplPartProperties.PartFreeProperties.Count; i++)
                    {
                        part.Properties.ARTICLE_FREE_DATA_DESCRIPTION[i + 1] = eplPartProperties.PartFreeProperties[i].Description;
                        part.Properties.ARTICLE_FREE_DATA_VALUE[i + 1]       = eplPartProperties.PartFreeProperties[i].Value;
                        part.Properties.ARTICLE_FREE_DATA_UNIT[i + 1]        = eplPartProperties.PartFreeProperties[i].Unit;
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Logger.WriteLine("Save part", ex);
                return(false);
            }
        }
        public static void Remove(this EplPartProperties eplPartProperties)
        {
            var part = GetMDPart(eplPartProperties);

            if (part != null)
            {
                mDPartsDatabase.RemovePart(part);
            }
        }
 private void Remove_Click(object sender, EventArgs e)
 {
     foreach (var item in PartViewer.SelectedRows)
     {
         EplPartProperties part = (item as DataGridViewRow).DataBoundItem as EplPartProperties;
         EplControlExtension.Remove(part.PartNumber);
         var p = EplPartProperties.Where(i => i.PartNumber == part.PartNumber).FirstOrDefault();
         EplPartProperties.Remove(p);
     }
     BindingPartSource();
     EplControlExtension.CloseDb();
 }
 private void BindingPartSource()
 {
     try
     {
         if (EplPartProperties != null)
         {
             EplPartProperties = EplPartProperties
                                 .OrderBy(i => i.PartNumber)
                                 .ToList();
             PartsDataSource.DataSource = EplPartProperties;
         }
     }
     catch { }
 }
        public static MDPart GetMDPart(this EplPartProperties eplPartProperties)
        {
            if (mDPartsManagement == null)
            {
                mDPartsManagement = new MDPartsManagement();
            }

            if (mDPartsDatabase == null || !mDPartsDatabase.IsOpen)
            {
                mDPartsDatabase = mDPartsManagement.OpenDatabase();
            }

            var part = mDPartsDatabase.Parts.Where(i => i.PartNr == eplPartProperties.PartNumber).FirstOrDefault();

            return(part);
        }
        public PartFreePropertiesForm(EplPartProperties eplPartProperties)
        {
            InitializeComponent();
            EplPartProperties = eplPartProperties;

            var mdPart = EplPartProperties.GetMDPart();

            for (int i = 0; i < 10; i++)
            {
                if (mdPart.Properties.ARTICLE_FREE_DATA_DESCRIPTION[i + 1].IsEmpty)
                {
                    break;
                }
                EplPartProperties.PartFreeProperties.Add(new PartFreeProperties
                {
                    Description = mdPart.Properties.ARTICLE_FREE_DATA_DESCRIPTION[i + 1],
                    Unit        = mdPart.Properties.ARTICLE_FREE_DATA_UNIT,
                    Value       = mdPart.Properties.ARTICLE_FREE_DATA_VALUE,
                });
            }

            FreePropertiesSource.DataSource = EplPartProperties.PartFreeProperties;
        }