public CategoriesWindow(ObservableCollection <Сategories> list, Сategories cat, Entities dataEntities)
        {
            InitializeComponent();

            this.entities       = dataEntities;
            this.listCategories = list;
            if (cat != null)
            {
                create = false;
                CategoriesTitle.Content = "Изменение  категории";
                createCategory.Content  = "изменить";
                this.category           = cat;
                name = cat.name_category;
                nameCategoryTextBox.Text = cat.name_category;
                new TextRange(descriptionCategoryTextBox.Document.ContentStart, descriptionCategoryTextBox.Document.ContentEnd).Text = cat.description_category;
            }
        }
        private void createCategory_Click(object sender, RoutedEventArgs e)
        {
            if (nameCategoryTextBox.Text != null)
            {
                try
                {
                    category = new Сategories();
                    category.name_category        = nameCategoryTextBox.Text;
                    category.description_category = new TextRange(descriptionCategoryTextBox.Document.ContentStart, descriptionCategoryTextBox.Document.ContentEnd).Text;


                    if (create)
                    {
                        entities.Сategories.Add(category);
                    }
                    else
                    {
                        foreach (Сategories c in listCategories)
                        {
                            if (c.name_category == name)
                            {
                                c.name_category        = category.name_category;
                                c.description_category = category.description_category;
                            }
                        }
                    }
                    entities.SaveChanges();
                    this.DialogResult = true;
                }
                catch (Exception ex)
                {
                    this.ShowMessageAsync("Ошибка", ex.ToString());
                }
            }
            else
            {
                this.ShowMessageAsync("Ошибка", "Возможно, вы не заполнили некоторые обязательные поля");
            }
        }
        public void Do()
        {
            try
            {
                equipment = new Equipment();
                equipment.code_equipment        = codeEquipmentTextBox.Text;
                equipment.name_equipment        = nameEquipmentTextBox.Text;
                equipment.description_equipment = new TextRange(descriptionEquipmentTextBox.Document.ContentStart, descriptionEquipmentTextBox.Document.ContentEnd).Text;
                Fabricator fabricator = fabricatorEquipmentComboBox.SelectedItem as Fabricator;
                equipment.fabricator_equipment = fabricator.id_fabricator;
                Сategories category = categoriesEquipmentComboBox.SelectedItem as Сategories;
                equipment.category_equipment = category.id_category;
                equipment.price_equipment    = Convert.ToDecimal(priceEquipmentTextBox.Text);

                WrapPanel[]      w     = attributesPanel.Children.OfType <WrapPanel>().ToArray();
                TextBox[]        t     = new TextBox[w.Count()];
                AttributeArray[] array = new AttributeArray[w.Count()];
                for (int i = 0; i < w.Count(); i++)
                {
                    t        = w[i].Children.OfType <TextBox>().ToArray();
                    array[i] = new AttributeArray(t[0].Name, t[0].Text);
                }

                foreach (Attribute item in ListAttributes)
                {
                    for (int i = 0; i < array.Count(); i++)
                    {
                        if (item.name_attribute == array[i].name)
                        {
                            Attributes_Values av = new Attributes_Values();
                            av.value_aValues     = array[i].value;
                            av.attribute_aValues = item.id_attribute;
                            if (id != 0)
                            {
                                av.equipment_aValues = id;
                            }
                            else
                            {
                                av.equipment_aValues = equipment.id_equipment;
                            }
                            equipment.Attributes_Values.Add(av);
                            item.Attributes_Values.Add(av);
                        }
                    }
                }

                if (create)
                {
                    equipment.col_equipment = 0;
                    entities.Equipments.Add(equipment);
                }
                else
                {
                    foreach (Equipment eq in ListEquipment)
                    {
                        if (eq.name_equipment == name)
                        {
                            eq.name_equipment        = equipment.name_equipment;
                            eq.code_equipment        = equipment.code_equipment;
                            eq.description_equipment = equipment.description_equipment;
                            eq.fabricator_equipment  = equipment.fabricator_equipment;
                            eq.category_equipment    = equipment.category_equipment;
                            eq.price_equipment       = equipment.price_equipment;
                            eq.Attributes_Values     = equipment.Attributes_Values;
                        }
                    }
                }
                entities.SaveChanges();
                this.DialogResult = true;
            }
            catch (Exception ex)
            {
                this.ShowMessageAsync("Ошибка", ex.ToString());
            }
        }