Browse Source

Дратути2

Никита Мелузов 2 years ago
parent
commit
e8155379a0

+ 12 - 1
App.xaml

@@ -4,6 +4,17 @@
              xmlns:local="clr-namespace:Namordnik"
              StartupUri="MainWindow.xaml">
     <Application.Resources>
-         
+        <Style TargetType="TextBlock">
+            <Setter Property="FontSize" Value="12"/>
+            <Setter Property="FontFamily" Value="Tw Cen MT"></Setter>
+        </Style>
+        <Style TargetType="ComboBox">
+            <Setter Property="FontFamily" Value="Tw Cen MT"></Setter>
+            <Setter Property="Background" Value="#B0E5FD"/>
+        </Style>
+        <Style TargetType="Button">
+            <Setter Property="Background" Value="#FDBD40"/>
+            <Setter Property="FontFamily" Value="Tw Cen MT"></Setter>
+        </Style>
     </Application.Resources>
 </Application>

+ 123 - 0
Class/PaginationClass.cs

@@ -0,0 +1,123 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Namordnik.Class
+{
+    class PaginationClass : INotifyPropertyChanged
+    {
+        public event PropertyChangedEventHandler PropertyChanged;
+
+        static int countitems = 4;
+        public int[] NPage { get; set; } = new int[countitems];
+        public string[] Visible { get; set; } = new string[countitems];
+        public string[] Bold { get; set; } = new string[countitems];
+        int countpages;
+
+        public int CountPages
+        {
+            get => countpages;
+            set
+            {
+                countpages = value;
+                for (int i = 1; i < countitems; i++)
+                {
+                    if (CountPages <= i)
+                    {
+                        Visible[i] = "Hidden";
+                    }
+                    else
+                    {
+                        Visible[i] = "Visible";
+                    }
+                }
+            }
+        }
+
+        int countpage;
+        public int CountPage
+        {
+            get => countpage;
+            set
+            {
+                countpage = value;
+                if (Countlist % value == 0)
+                {
+                    CountPages = Countlist / value;
+                }
+                else
+                {
+                    CountPages = Countlist / value + 1;
+                }
+            }
+        }
+
+        int countlist;
+
+        public int Countlist
+        {
+            get => countlist;
+            set
+            {
+                countlist = value;
+                if (value % CountPage == 0)
+                {
+                    CountPages = value / CountPage;
+                }
+                else
+                {
+                    CountPages = 1 + value / CountPage;
+                }
+            }
+        }
+
+        int currentpage;
+        public int CurrentPage
+        {
+            get => currentpage;
+            set
+            {
+                currentpage = value;
+                if (currentpage < 1)
+                {
+                    currentpage = 1;
+                }
+                if (currentpage >= CountPages)
+                {
+                    currentpage = CountPages;
+                }
+
+                for (int i = 0; i < countitems; i++)
+                {
+                    if (currentpage < (1 + countitems / 2) || CountPages < countitems) NPage[i] = i + 1;
+                    else if (currentpage > CountPages - (countitems / 2 + 1)) NPage[i] = CountPages - (countitems - 1) + i;
+                    else NPage[i] = currentpage + i - (countitems / 2);
+                }
+                for (int i = 0; i < countitems; i++)
+                {
+                    if (NPage[i] == currentpage) Bold[i] = "ExtraBold";
+                    else Bold[i] = "Regular";
+                }
+
+                PropertyChanged(this, new PropertyChangedEventArgs("NPage"));
+                PropertyChanged(this, new PropertyChangedEventArgs("Visible"));
+                PropertyChanged(this, new PropertyChangedEventArgs("Bold"));
+            }
+        }
+        public PaginationClass() // контруктор
+        {
+            for (int i = 0; i < countitems; i++)
+            {
+                Visible[i] = "Visible";
+                NPage[i] = i + 1;
+                Bold[i] = "Regular";
+            }
+            currentpage = 1;
+            countpage = 1;
+            countlist = 1;
+        }
+    }
+}

+ 15 - 2
Class/PartClass.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows.Media;
 
 namespace Namordnik
 {
@@ -15,7 +16,19 @@ namespace Namordnik
                 return ProductType.Title + " | " + Title;
             }
         }
-
+        public SolidColorBrush PrColor
+        {
+            get
+            {
+                SolidColorBrush bl = new SolidColorBrush(Color.FromRgb(176, 229, 253));
+                SolidColorBrush lr = new SolidColorBrush(Color.FromRgb(250, 110, 110));
+                if (MinCostForAgent > 2000)
+                {
+                    return lr;
+                }
+                else return bl;
+        }
+        }
     }
-
+   
 }

+ 2 - 1
MainWindow.xaml

@@ -5,7 +5,8 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:Namordnik"
         mc:Ignorable="d"
-        Title="Намордник" Height="450" Width="800">
+        d:DesignHeight="1000" d:DesignWidth="800"
+        Title="Намордник" MaxWidth="800" MaxHeight="1000" MinHeight="1000" MinWidth="800">
     <Grid>
         <Frame Name="MainFrame" NavigationUIVisibility="Hidden"></Frame>
     </Grid>

+ 197 - 194
Model1.edmx

@@ -4,7 +4,7 @@
   <edmx:Runtime>
     <!-- SSDL content -->
     <edmx:StorageModels>
-      <Schema Namespace="Хранилище Model" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
+    <Schema Namespace="Хранилище Model" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
         <EntityType Name="Agent">
           <Key>
             <PropertyRef Name="ID" />
@@ -82,7 +82,7 @@
           <Key>
             <PropertyRef Name="ID" />
           </Key>
-          <Property Name="ID" Type="int" Nullable="false" />
+          <Property Name="ID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
           <Property Name="Title" Type="nvarchar" MaxLength="100" Nullable="false" />
           <Property Name="ProductTypeID" Type="int" />
           <Property Name="ArticleNumber" Type="nvarchar" MaxLength="10" Nullable="false" />
@@ -257,7 +257,9 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_ProductMaterial_Product">
-          <End Role="Product" Type="Self.Product" Multiplicity="1" />
+          <End Role="Product" Type="Self.Product" Multiplicity="1">
+            <OnDelete Action="Cascade" />
+          </End>
           <End Role="ProductMaterial" Type="Self.ProductMaterial" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Product">
@@ -372,30 +374,92 @@
             <End Role="Shop" EntitySet="Shop" />
           </AssociationSet>
         </EntityContainer>
-      </Schema>
-    </edmx:StorageModels>
+      </Schema></edmx:StorageModels>
     <!-- CSDL content -->
     <edmx:ConceptualModels>
       <Schema Namespace="Model" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
+        <EntityContainer Name="Entities" annotation:LazyLoadingEnabled="true">
+          <EntitySet Name="Agent" EntityType="Model.Agent" />
+          <EntitySet Name="AgentPriorityHistory" EntityType="Model.AgentPriorityHistory" />
+          <EntitySet Name="AgentType" EntityType="Model.AgentType" />
+          <EntitySet Name="Material" EntityType="Model.Material" />
+          <EntitySet Name="MaterialCountHistory" EntityType="Model.MaterialCountHistory" />
+          <EntitySet Name="MaterialType" EntityType="Model.MaterialType" />
+          <EntitySet Name="Product" EntityType="Model.Product" />
+          <EntitySet Name="ProductCostHistory" EntityType="Model.ProductCostHistory" />
+          <EntitySet Name="ProductMaterial" EntityType="Model.ProductMaterial" />
+          <EntitySet Name="ProductSale" EntityType="Model.ProductSale" />
+          <EntitySet Name="ProductType" EntityType="Model.ProductType" />
+          <EntitySet Name="Shop" EntityType="Model.Shop" />
+          <EntitySet Name="Supplier" EntityType="Model.Supplier" />
+          <AssociationSet Name="FK_Agent_AgentType" Association="Model.FK_Agent_AgentType">
+            <End Role="AgentType" EntitySet="AgentType" />
+            <End Role="Agent" EntitySet="Agent" />
+          </AssociationSet>
+          <AssociationSet Name="FK_AgentPriorityHistory_Agent" Association="Model.FK_AgentPriorityHistory_Agent">
+            <End Role="Agent" EntitySet="Agent" />
+            <End Role="AgentPriorityHistory" EntitySet="AgentPriorityHistory" />
+          </AssociationSet>
+          <AssociationSet Name="FK_ProductSale_Agent" Association="Model.FK_ProductSale_Agent">
+            <End Role="Agent" EntitySet="Agent" />
+            <End Role="ProductSale" EntitySet="ProductSale" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Shop_Agent" Association="Model.FK_Shop_Agent">
+            <End Role="Agent" EntitySet="Agent" />
+            <End Role="Shop" EntitySet="Shop" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Material_MaterialType" Association="Model.FK_Material_MaterialType">
+            <End Role="MaterialType" EntitySet="MaterialType" />
+            <End Role="Material" EntitySet="Material" />
+          </AssociationSet>
+          <AssociationSet Name="FK_MaterialCountHistory_Material" Association="Model.FK_MaterialCountHistory_Material">
+            <End Role="Material" EntitySet="Material" />
+            <End Role="MaterialCountHistory" EntitySet="MaterialCountHistory" />
+          </AssociationSet>
+          <AssociationSet Name="FK_ProductMaterial_Material" Association="Model.FK_ProductMaterial_Material">
+            <End Role="Material" EntitySet="Material" />
+            <End Role="ProductMaterial" EntitySet="ProductMaterial" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Product_ProductType" Association="Model.FK_Product_ProductType">
+            <End Role="ProductType" EntitySet="ProductType" />
+            <End Role="Product" EntitySet="Product" />
+          </AssociationSet>
+          <AssociationSet Name="FK_ProductCostHistory_Product" Association="Model.FK_ProductCostHistory_Product">
+            <End Role="Product" EntitySet="Product" />
+            <End Role="ProductCostHistory" EntitySet="ProductCostHistory" />
+          </AssociationSet>
+          <AssociationSet Name="FK_ProductMaterial_Product" Association="Model.FK_ProductMaterial_Product">
+            <End Role="Product" EntitySet="Product" />
+            <End Role="ProductMaterial" EntitySet="ProductMaterial" />
+          </AssociationSet>
+          <AssociationSet Name="FK_ProductSale_Product" Association="Model.FK_ProductSale_Product">
+            <End Role="Product" EntitySet="Product" />
+            <End Role="ProductSale" EntitySet="ProductSale" />
+          </AssociationSet>
+          <AssociationSet Name="MaterialSupplier" Association="Model.MaterialSupplier">
+            <End Role="Material" EntitySet="Material" />
+            <End Role="Supplier" EntitySet="Supplier" />
+          </AssociationSet>
+        </EntityContainer>
         <EntityType Name="Agent">
           <Key>
             <PropertyRef Name="ID" />
           </Key>
           <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Title" Type="String" MaxLength="150" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Title" Type="String" Nullable="false" MaxLength="150" FixedLength="false" Unicode="true" />
           <Property Name="AgentTypeID" Type="Int32" Nullable="false" />
           <Property Name="Address" Type="String" MaxLength="300" FixedLength="false" Unicode="true" />
-          <Property Name="INN" Type="String" MaxLength="12" FixedLength="false" Unicode="false" Nullable="false" />
+          <Property Name="INN" Type="String" Nullable="false" MaxLength="12" FixedLength="false" Unicode="false" />
           <Property Name="KPP" Type="String" MaxLength="9" FixedLength="false" Unicode="false" />
           <Property Name="DirectorName" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
-          <Property Name="Phone" Type="String" MaxLength="20" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Phone" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="true" />
           <Property Name="Email" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
           <Property Name="Logo" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
           <Property Name="Priority" Type="Int32" Nullable="false" />
-          <NavigationProperty Name="AgentType" Relationship="Self.FK_Agent_AgentType" FromRole="Agent" ToRole="AgentType" />
-          <NavigationProperty Name="AgentPriorityHistory" Relationship="Self.FK_AgentPriorityHistory_Agent" FromRole="Agent" ToRole="AgentPriorityHistory" />
-          <NavigationProperty Name="ProductSale" Relationship="Self.FK_ProductSale_Agent" FromRole="Agent" ToRole="ProductSale" />
-          <NavigationProperty Name="Shop" Relationship="Self.FK_Shop_Agent" FromRole="Agent" ToRole="Shop" />
+          <NavigationProperty Name="AgentType" Relationship="Model.FK_Agent_AgentType" FromRole="Agent" ToRole="AgentType" />
+          <NavigationProperty Name="AgentPriorityHistory" Relationship="Model.FK_AgentPriorityHistory_Agent" FromRole="Agent" ToRole="AgentPriorityHistory" />
+          <NavigationProperty Name="ProductSale" Relationship="Model.FK_ProductSale_Agent" FromRole="Agent" ToRole="ProductSale" />
+          <NavigationProperty Name="Shop" Relationship="Model.FK_Shop_Agent" FromRole="Agent" ToRole="Shop" />
         </EntityType>
         <EntityType Name="AgentPriorityHistory">
           <Key>
@@ -405,35 +469,35 @@
           <Property Name="AgentID" Type="Int32" Nullable="false" />
           <Property Name="ChangeDate" Type="DateTime" Nullable="false" Precision="3" />
           <Property Name="PriorityValue" Type="Int32" Nullable="false" />
-          <NavigationProperty Name="Agent" Relationship="Self.FK_AgentPriorityHistory_Agent" FromRole="AgentPriorityHistory" ToRole="Agent" />
+          <NavigationProperty Name="Agent" Relationship="Model.FK_AgentPriorityHistory_Agent" FromRole="AgentPriorityHistory" ToRole="Agent" />
         </EntityType>
         <EntityType Name="AgentType">
           <Key>
             <PropertyRef Name="ID" />
           </Key>
           <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Title" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Title" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
           <Property Name="Image" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
-          <NavigationProperty Name="Agent" Relationship="Self.FK_Agent_AgentType" FromRole="AgentType" ToRole="Agent" />
+          <NavigationProperty Name="Agent" Relationship="Model.FK_Agent_AgentType" FromRole="AgentType" ToRole="Agent" />
         </EntityType>
         <EntityType Name="Material">
           <Key>
             <PropertyRef Name="ID" />
           </Key>
           <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Title" Type="String" MaxLength="100" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Title" Type="String" Nullable="false" MaxLength="100" FixedLength="false" Unicode="true" />
           <Property Name="CountInPack" Type="Int32" Nullable="false" />
-          <Property Name="Unit" Type="String" MaxLength="10" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Unit" Type="String" Nullable="false" MaxLength="10" FixedLength="false" Unicode="true" />
           <Property Name="CountInStock" Type="Double" />
           <Property Name="MinCount" Type="Double" Nullable="false" />
           <Property Name="Description" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
-          <Property Name="Cost" Type="Decimal" Precision="10" Scale="2" Nullable="false" />
+          <Property Name="Cost" Type="Decimal" Nullable="false" Precision="10" Scale="2" />
           <Property Name="Image" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
           <Property Name="MaterialTypeID" Type="Int32" Nullable="false" />
-          <NavigationProperty Name="MaterialType" Relationship="Self.FK_Material_MaterialType" FromRole="Material" ToRole="MaterialType" />
-          <NavigationProperty Name="MaterialCountHistory" Relationship="Self.FK_MaterialCountHistory_Material" FromRole="Material" ToRole="MaterialCountHistory" />
-          <NavigationProperty Name="ProductMaterial" Relationship="Self.FK_ProductMaterial_Material" FromRole="Material" ToRole="ProductMaterial" />
-          <NavigationProperty Name="Supplier" Relationship="Self.MaterialSupplier" FromRole="Material" ToRole="Supplier" />
+          <NavigationProperty Name="MaterialType" Relationship="Model.FK_Material_MaterialType" FromRole="Material" ToRole="MaterialType" />
+          <NavigationProperty Name="MaterialCountHistory" Relationship="Model.FK_MaterialCountHistory_Material" FromRole="Material" ToRole="MaterialCountHistory" />
+          <NavigationProperty Name="ProductMaterial" Relationship="Model.FK_ProductMaterial_Material" FromRole="Material" ToRole="ProductMaterial" />
+          <NavigationProperty Name="Supplier" Relationship="Model.MaterialSupplier" FromRole="Material" ToRole="Supplier" />
         </EntityType>
         <EntityType Name="MaterialCountHistory">
           <Key>
@@ -443,34 +507,34 @@
           <Property Name="MaterialID" Type="Int32" Nullable="false" />
           <Property Name="ChangeDate" Type="DateTime" Nullable="false" Precision="3" />
           <Property Name="CountValue" Type="Double" Nullable="false" />
-          <NavigationProperty Name="Material" Relationship="Self.FK_MaterialCountHistory_Material" FromRole="MaterialCountHistory" ToRole="Material" />
+          <NavigationProperty Name="Material" Relationship="Model.FK_MaterialCountHistory_Material" FromRole="MaterialCountHistory" ToRole="Material" />
         </EntityType>
         <EntityType Name="MaterialType">
           <Key>
             <PropertyRef Name="ID" />
           </Key>
           <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Title" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Title" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
           <Property Name="DefectedPercent" Type="Double" />
-          <NavigationProperty Name="Material" Relationship="Self.FK_Material_MaterialType" FromRole="MaterialType" ToRole="Material" />
+          <NavigationProperty Name="Material" Relationship="Model.FK_Material_MaterialType" FromRole="MaterialType" ToRole="Material" />
         </EntityType>
         <EntityType Name="Product">
           <Key>
             <PropertyRef Name="ID" />
           </Key>
-          <Property Name="ID" Type="Int32" Nullable="false" />
-          <Property Name="Title" Type="String" MaxLength="100" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="Title" Type="String" Nullable="false" MaxLength="100" FixedLength="false" Unicode="true" />
           <Property Name="ProductTypeID" Type="Int32" />
-          <Property Name="ArticleNumber" Type="String" MaxLength="10" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="ArticleNumber" Type="String" Nullable="false" MaxLength="10" FixedLength="false" Unicode="true" />
           <Property Name="Description" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
           <Property Name="Image" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
           <Property Name="ProductionPersonCount" Type="Int32" />
           <Property Name="ProductionWorkshopNumber" Type="Int32" Nullable="false" />
-          <Property Name="MinCostForAgent" Type="Decimal" Precision="10" Scale="2" Nullable="false" />
-          <NavigationProperty Name="ProductType" Relationship="Self.FK_Product_ProductType" FromRole="Product" ToRole="ProductType" />
-          <NavigationProperty Name="ProductCostHistory" Relationship="Self.FK_ProductCostHistory_Product" FromRole="Product" ToRole="ProductCostHistory" />
-          <NavigationProperty Name="ProductMaterial" Relationship="Self.FK_ProductMaterial_Product" FromRole="Product" ToRole="ProductMaterial" />
-          <NavigationProperty Name="ProductSale" Relationship="Self.FK_ProductSale_Product" FromRole="Product" ToRole="ProductSale" />
+          <Property Name="MinCostForAgent" Type="Decimal" Nullable="false" Precision="10" Scale="2" />
+          <NavigationProperty Name="ProductType" Relationship="Model.FK_Product_ProductType" FromRole="Product" ToRole="ProductType" />
+          <NavigationProperty Name="ProductCostHistory" Relationship="Model.FK_ProductCostHistory_Product" FromRole="Product" ToRole="ProductCostHistory" />
+          <NavigationProperty Name="ProductMaterial" Relationship="Model.FK_ProductMaterial_Product" FromRole="Product" ToRole="ProductMaterial" />
+          <NavigationProperty Name="ProductSale" Relationship="Model.FK_ProductSale_Product" FromRole="Product" ToRole="ProductSale" />
         </EntityType>
         <EntityType Name="ProductCostHistory">
           <Key>
@@ -479,8 +543,8 @@
           <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
           <Property Name="ProductID" Type="Int32" Nullable="false" />
           <Property Name="ChangeDate" Type="DateTime" Nullable="false" Precision="3" />
-          <Property Name="CostValue" Type="Decimal" Precision="10" Scale="2" Nullable="false" />
-          <NavigationProperty Name="Product" Relationship="Self.FK_ProductCostHistory_Product" FromRole="ProductCostHistory" ToRole="Product" />
+          <Property Name="CostValue" Type="Decimal" Nullable="false" Precision="10" Scale="2" />
+          <NavigationProperty Name="Product" Relationship="Model.FK_ProductCostHistory_Product" FromRole="ProductCostHistory" ToRole="Product" />
         </EntityType>
         <EntityType Name="ProductMaterial">
           <Key>
@@ -490,8 +554,8 @@
           <Property Name="ProductID" Type="Int32" Nullable="false" />
           <Property Name="MaterialID" Type="Int32" Nullable="false" />
           <Property Name="Count" Type="Double" />
-          <NavigationProperty Name="Material" Relationship="Self.FK_ProductMaterial_Material" FromRole="ProductMaterial" ToRole="Material" />
-          <NavigationProperty Name="Product" Relationship="Self.FK_ProductMaterial_Product" FromRole="ProductMaterial" ToRole="Product" />
+          <NavigationProperty Name="Material" Relationship="Model.FK_ProductMaterial_Material" FromRole="ProductMaterial" ToRole="Material" />
+          <NavigationProperty Name="Product" Relationship="Model.FK_ProductMaterial_Product" FromRole="ProductMaterial" ToRole="Product" />
         </EntityType>
         <EntityType Name="ProductSale">
           <Key>
@@ -502,43 +566,43 @@
           <Property Name="ProductID" Type="Int32" Nullable="false" />
           <Property Name="SaleDate" Type="DateTime" Nullable="false" Precision="0" />
           <Property Name="ProductCount" Type="Int32" Nullable="false" />
-          <NavigationProperty Name="Agent" Relationship="Self.FK_ProductSale_Agent" FromRole="ProductSale" ToRole="Agent" />
-          <NavigationProperty Name="Product" Relationship="Self.FK_ProductSale_Product" FromRole="ProductSale" ToRole="Product" />
+          <NavigationProperty Name="Agent" Relationship="Model.FK_ProductSale_Agent" FromRole="ProductSale" ToRole="Agent" />
+          <NavigationProperty Name="Product" Relationship="Model.FK_ProductSale_Product" FromRole="ProductSale" ToRole="Product" />
         </EntityType>
         <EntityType Name="ProductType">
           <Key>
             <PropertyRef Name="ID" />
           </Key>
           <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Title" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Title" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
           <Property Name="DefectedPercent" Type="Double" />
-          <NavigationProperty Name="Product" Relationship="Self.FK_Product_ProductType" FromRole="ProductType" ToRole="Product" />
+          <NavigationProperty Name="Product" Relationship="Model.FK_Product_ProductType" FromRole="ProductType" ToRole="Product" />
         </EntityType>
         <EntityType Name="Shop">
           <Key>
             <PropertyRef Name="ID" />
           </Key>
           <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Title" Type="String" MaxLength="150" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Title" Type="String" Nullable="false" MaxLength="150" FixedLength="false" Unicode="true" />
           <Property Name="Address" Type="String" MaxLength="300" FixedLength="false" Unicode="true" />
           <Property Name="AgentID" Type="Int32" Nullable="false" />
-          <NavigationProperty Name="Agent" Relationship="Self.FK_Shop_Agent" FromRole="Shop" ToRole="Agent" />
+          <NavigationProperty Name="Agent" Relationship="Model.FK_Shop_Agent" FromRole="Shop" ToRole="Agent" />
         </EntityType>
         <EntityType Name="Supplier">
           <Key>
             <PropertyRef Name="ID" />
           </Key>
           <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Title" Type="String" MaxLength="150" FixedLength="false" Unicode="true" Nullable="false" />
-          <Property Name="INN" Type="String" MaxLength="12" FixedLength="false" Unicode="false" Nullable="false" />
+          <Property Name="Title" Type="String" Nullable="false" MaxLength="150" FixedLength="false" Unicode="true" />
+          <Property Name="INN" Type="String" Nullable="false" MaxLength="12" FixedLength="false" Unicode="false" />
           <Property Name="StartDate" Type="DateTime" Nullable="false" Precision="0" />
           <Property Name="QualityRating" Type="Int32" />
           <Property Name="SupplierType" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
-          <NavigationProperty Name="Material" Relationship="Self.MaterialSupplier" FromRole="Supplier" ToRole="Material" />
+          <NavigationProperty Name="Material" Relationship="Model.MaterialSupplier" FromRole="Supplier" ToRole="Material" />
         </EntityType>
         <Association Name="FK_Agent_AgentType">
-          <End Role="AgentType" Type="Self.AgentType" Multiplicity="1" />
-          <End Role="Agent" Type="Self.Agent" Multiplicity="*" />
+          <End Type="Model.AgentType" Role="AgentType" Multiplicity="1" />
+          <End Type="Model.Agent" Role="Agent" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="AgentType">
               <PropertyRef Name="ID" />
@@ -549,8 +613,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_AgentPriorityHistory_Agent">
-          <End Role="Agent" Type="Self.Agent" Multiplicity="1" />
-          <End Role="AgentPriorityHistory" Type="Self.AgentPriorityHistory" Multiplicity="*" />
+          <End Type="Model.Agent" Role="Agent" Multiplicity="1" />
+          <End Type="Model.AgentPriorityHistory" Role="AgentPriorityHistory" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Agent">
               <PropertyRef Name="ID" />
@@ -561,8 +625,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_ProductSale_Agent">
-          <End Role="Agent" Type="Self.Agent" Multiplicity="1" />
-          <End Role="ProductSale" Type="Self.ProductSale" Multiplicity="*" />
+          <End Type="Model.Agent" Role="Agent" Multiplicity="1" />
+          <End Type="Model.ProductSale" Role="ProductSale" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Agent">
               <PropertyRef Name="ID" />
@@ -573,8 +637,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Shop_Agent">
-          <End Role="Agent" Type="Self.Agent" Multiplicity="1" />
-          <End Role="Shop" Type="Self.Shop" Multiplicity="*" />
+          <End Type="Model.Agent" Role="Agent" Multiplicity="1" />
+          <End Type="Model.Shop" Role="Shop" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Agent">
               <PropertyRef Name="ID" />
@@ -585,8 +649,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Material_MaterialType">
-          <End Role="MaterialType" Type="Self.MaterialType" Multiplicity="1" />
-          <End Role="Material" Type="Self.Material" Multiplicity="*" />
+          <End Type="Model.MaterialType" Role="MaterialType" Multiplicity="1" />
+          <End Type="Model.Material" Role="Material" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="MaterialType">
               <PropertyRef Name="ID" />
@@ -597,8 +661,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_MaterialCountHistory_Material">
-          <End Role="Material" Type="Self.Material" Multiplicity="1" />
-          <End Role="MaterialCountHistory" Type="Self.MaterialCountHistory" Multiplicity="*" />
+          <End Type="Model.Material" Role="Material" Multiplicity="1" />
+          <End Type="Model.MaterialCountHistory" Role="MaterialCountHistory" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Material">
               <PropertyRef Name="ID" />
@@ -609,8 +673,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_ProductMaterial_Material">
-          <End Role="Material" Type="Self.Material" Multiplicity="1" />
-          <End Role="ProductMaterial" Type="Self.ProductMaterial" Multiplicity="*" />
+          <End Type="Model.Material" Role="Material" Multiplicity="1" />
+          <End Type="Model.ProductMaterial" Role="ProductMaterial" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Material">
               <PropertyRef Name="ID" />
@@ -621,8 +685,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Product_ProductType">
-          <End Role="ProductType" Type="Self.ProductType" Multiplicity="0..1" />
-          <End Role="Product" Type="Self.Product" Multiplicity="*" />
+          <End Type="Model.ProductType" Role="ProductType" Multiplicity="0..1" />
+          <End Type="Model.Product" Role="Product" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="ProductType">
               <PropertyRef Name="ID" />
@@ -633,8 +697,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_ProductCostHistory_Product">
-          <End Role="Product" Type="Self.Product" Multiplicity="1" />
-          <End Role="ProductCostHistory" Type="Self.ProductCostHistory" Multiplicity="*" />
+          <End Type="Model.Product" Role="Product" Multiplicity="1" />
+          <End Type="Model.ProductCostHistory" Role="ProductCostHistory" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Product">
               <PropertyRef Name="ID" />
@@ -645,8 +709,10 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_ProductMaterial_Product">
-          <End Role="Product" Type="Self.Product" Multiplicity="1" />
-          <End Role="ProductMaterial" Type="Self.ProductMaterial" Multiplicity="*" />
+          <End Type="Model.Product" Role="Product" Multiplicity="1">
+            <OnDelete Action="Cascade" />
+          </End>
+          <End Type="Model.ProductMaterial" Role="ProductMaterial" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Product">
               <PropertyRef Name="ID" />
@@ -657,8 +723,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_ProductSale_Product">
-          <End Role="Product" Type="Self.Product" Multiplicity="1" />
-          <End Role="ProductSale" Type="Self.ProductSale" Multiplicity="*" />
+          <End Type="Model.Product" Role="Product" Multiplicity="1" />
+          <End Type="Model.ProductSale" Role="ProductSale" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Product">
               <PropertyRef Name="ID" />
@@ -669,73 +735,10 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="MaterialSupplier">
-          <End Role="Material" Type="Self.Material" Multiplicity="*" />
-          <End Role="Supplier" Type="Self.Supplier" Multiplicity="*" />
+          <End Type="Model.Material" Role="Material" Multiplicity="*" />
+          <End Type="Model.Supplier" Role="Supplier" Multiplicity="*" />
         </Association>
-        <EntityContainer Name="Entities" annotation:LazyLoadingEnabled="true">
-          <EntitySet Name="Agent" EntityType="Self.Agent" />
-          <EntitySet Name="AgentPriorityHistory" EntityType="Self.AgentPriorityHistory" />
-          <EntitySet Name="AgentType" EntityType="Self.AgentType" />
-          <EntitySet Name="Material" EntityType="Self.Material" />
-          <EntitySet Name="MaterialCountHistory" EntityType="Self.MaterialCountHistory" />
-          <EntitySet Name="MaterialType" EntityType="Self.MaterialType" />
-          <EntitySet Name="Product" EntityType="Self.Product" />
-          <EntitySet Name="ProductCostHistory" EntityType="Self.ProductCostHistory" />
-          <EntitySet Name="ProductMaterial" EntityType="Self.ProductMaterial" />
-          <EntitySet Name="ProductSale" EntityType="Self.ProductSale" />
-          <EntitySet Name="ProductType" EntityType="Self.ProductType" />
-          <EntitySet Name="Shop" EntityType="Self.Shop" />
-          <EntitySet Name="Supplier" EntityType="Self.Supplier" />
-          <AssociationSet Name="FK_Agent_AgentType" Association="Self.FK_Agent_AgentType">
-            <End Role="AgentType" EntitySet="AgentType" />
-            <End Role="Agent" EntitySet="Agent" />
-          </AssociationSet>
-          <AssociationSet Name="FK_AgentPriorityHistory_Agent" Association="Self.FK_AgentPriorityHistory_Agent">
-            <End Role="Agent" EntitySet="Agent" />
-            <End Role="AgentPriorityHistory" EntitySet="AgentPriorityHistory" />
-          </AssociationSet>
-          <AssociationSet Name="FK_ProductSale_Agent" Association="Self.FK_ProductSale_Agent">
-            <End Role="Agent" EntitySet="Agent" />
-            <End Role="ProductSale" EntitySet="ProductSale" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Shop_Agent" Association="Self.FK_Shop_Agent">
-            <End Role="Agent" EntitySet="Agent" />
-            <End Role="Shop" EntitySet="Shop" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Material_MaterialType" Association="Self.FK_Material_MaterialType">
-            <End Role="MaterialType" EntitySet="MaterialType" />
-            <End Role="Material" EntitySet="Material" />
-          </AssociationSet>
-          <AssociationSet Name="FK_MaterialCountHistory_Material" Association="Self.FK_MaterialCountHistory_Material">
-            <End Role="Material" EntitySet="Material" />
-            <End Role="MaterialCountHistory" EntitySet="MaterialCountHistory" />
-          </AssociationSet>
-          <AssociationSet Name="FK_ProductMaterial_Material" Association="Self.FK_ProductMaterial_Material">
-            <End Role="Material" EntitySet="Material" />
-            <End Role="ProductMaterial" EntitySet="ProductMaterial" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Product_ProductType" Association="Self.FK_Product_ProductType">
-            <End Role="ProductType" EntitySet="ProductType" />
-            <End Role="Product" EntitySet="Product" />
-          </AssociationSet>
-          <AssociationSet Name="FK_ProductCostHistory_Product" Association="Self.FK_ProductCostHistory_Product">
-            <End Role="Product" EntitySet="Product" />
-            <End Role="ProductCostHistory" EntitySet="ProductCostHistory" />
-          </AssociationSet>
-          <AssociationSet Name="FK_ProductMaterial_Product" Association="Self.FK_ProductMaterial_Product">
-            <End Role="Product" EntitySet="Product" />
-            <End Role="ProductMaterial" EntitySet="ProductMaterial" />
-          </AssociationSet>
-          <AssociationSet Name="FK_ProductSale_Product" Association="Self.FK_ProductSale_Product">
-            <End Role="Product" EntitySet="Product" />
-            <End Role="ProductSale" EntitySet="ProductSale" />
-          </AssociationSet>
-          <AssociationSet Name="MaterialSupplier" Association="Self.MaterialSupplier">
-            <End Role="Material" EntitySet="Material" />
-            <End Role="Supplier" EntitySet="Supplier" />
-          </AssociationSet>
-        </EntityContainer>
-      </Schema>
+        </Schema>
     </edmx:ConceptualModels>
     <!-- C-S mapping content -->
     <edmx:Mappings>
@@ -744,158 +747,158 @@
           <EntitySetMapping Name="Agent">
             <EntityTypeMapping TypeName="Model.Agent">
               <MappingFragment StoreEntitySet="Agent">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="Title" ColumnName="Title" />
-                <ScalarProperty Name="AgentTypeID" ColumnName="AgentTypeID" />
-                <ScalarProperty Name="Address" ColumnName="Address" />
-                <ScalarProperty Name="INN" ColumnName="INN" />
-                <ScalarProperty Name="KPP" ColumnName="KPP" />
-                <ScalarProperty Name="DirectorName" ColumnName="DirectorName" />
-                <ScalarProperty Name="Phone" ColumnName="Phone" />
-                <ScalarProperty Name="Email" ColumnName="Email" />
-                <ScalarProperty Name="Logo" ColumnName="Logo" />
                 <ScalarProperty Name="Priority" ColumnName="Priority" />
+                <ScalarProperty Name="Logo" ColumnName="Logo" />
+                <ScalarProperty Name="Email" ColumnName="Email" />
+                <ScalarProperty Name="Phone" ColumnName="Phone" />
+                <ScalarProperty Name="DirectorName" ColumnName="DirectorName" />
+                <ScalarProperty Name="KPP" ColumnName="KPP" />
+                <ScalarProperty Name="INN" ColumnName="INN" />
+                <ScalarProperty Name="Address" ColumnName="Address" />
+                <ScalarProperty Name="AgentTypeID" ColumnName="AgentTypeID" />
+                <ScalarProperty Name="Title" ColumnName="Title" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="AgentPriorityHistory">
             <EntityTypeMapping TypeName="Model.AgentPriorityHistory">
               <MappingFragment StoreEntitySet="AgentPriorityHistory">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="AgentID" ColumnName="AgentID" />
-                <ScalarProperty Name="ChangeDate" ColumnName="ChangeDate" />
                 <ScalarProperty Name="PriorityValue" ColumnName="PriorityValue" />
+                <ScalarProperty Name="ChangeDate" ColumnName="ChangeDate" />
+                <ScalarProperty Name="AgentID" ColumnName="AgentID" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="AgentType">
             <EntityTypeMapping TypeName="Model.AgentType">
               <MappingFragment StoreEntitySet="AgentType">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="Title" ColumnName="Title" />
                 <ScalarProperty Name="Image" ColumnName="Image" />
+                <ScalarProperty Name="Title" ColumnName="Title" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="Material">
             <EntityTypeMapping TypeName="Model.Material">
               <MappingFragment StoreEntitySet="Material">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="Title" ColumnName="Title" />
-                <ScalarProperty Name="CountInPack" ColumnName="CountInPack" />
-                <ScalarProperty Name="Unit" ColumnName="Unit" />
-                <ScalarProperty Name="CountInStock" ColumnName="CountInStock" />
-                <ScalarProperty Name="MinCount" ColumnName="MinCount" />
-                <ScalarProperty Name="Description" ColumnName="Description" />
-                <ScalarProperty Name="Cost" ColumnName="Cost" />
-                <ScalarProperty Name="Image" ColumnName="Image" />
                 <ScalarProperty Name="MaterialTypeID" ColumnName="MaterialTypeID" />
+                <ScalarProperty Name="Image" ColumnName="Image" />
+                <ScalarProperty Name="Cost" ColumnName="Cost" />
+                <ScalarProperty Name="Description" ColumnName="Description" />
+                <ScalarProperty Name="MinCount" ColumnName="MinCount" />
+                <ScalarProperty Name="CountInStock" ColumnName="CountInStock" />
+                <ScalarProperty Name="Unit" ColumnName="Unit" />
+                <ScalarProperty Name="CountInPack" ColumnName="CountInPack" />
+                <ScalarProperty Name="Title" ColumnName="Title" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="MaterialCountHistory">
             <EntityTypeMapping TypeName="Model.MaterialCountHistory">
               <MappingFragment StoreEntitySet="MaterialCountHistory">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="MaterialID" ColumnName="MaterialID" />
-                <ScalarProperty Name="ChangeDate" ColumnName="ChangeDate" />
                 <ScalarProperty Name="CountValue" ColumnName="CountValue" />
+                <ScalarProperty Name="ChangeDate" ColumnName="ChangeDate" />
+                <ScalarProperty Name="MaterialID" ColumnName="MaterialID" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="MaterialType">
             <EntityTypeMapping TypeName="Model.MaterialType">
               <MappingFragment StoreEntitySet="MaterialType">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="Title" ColumnName="Title" />
                 <ScalarProperty Name="DefectedPercent" ColumnName="DefectedPercent" />
+                <ScalarProperty Name="Title" ColumnName="Title" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="Product">
             <EntityTypeMapping TypeName="Model.Product">
               <MappingFragment StoreEntitySet="Product">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="Title" ColumnName="Title" />
-                <ScalarProperty Name="ProductTypeID" ColumnName="ProductTypeID" />
-                <ScalarProperty Name="ArticleNumber" ColumnName="ArticleNumber" />
-                <ScalarProperty Name="Description" ColumnName="Description" />
-                <ScalarProperty Name="Image" ColumnName="Image" />
-                <ScalarProperty Name="ProductionPersonCount" ColumnName="ProductionPersonCount" />
-                <ScalarProperty Name="ProductionWorkshopNumber" ColumnName="ProductionWorkshopNumber" />
                 <ScalarProperty Name="MinCostForAgent" ColumnName="MinCostForAgent" />
+                <ScalarProperty Name="ProductionWorkshopNumber" ColumnName="ProductionWorkshopNumber" />
+                <ScalarProperty Name="ProductionPersonCount" ColumnName="ProductionPersonCount" />
+                <ScalarProperty Name="Image" ColumnName="Image" />
+                <ScalarProperty Name="Description" ColumnName="Description" />
+                <ScalarProperty Name="ArticleNumber" ColumnName="ArticleNumber" />
+                <ScalarProperty Name="ProductTypeID" ColumnName="ProductTypeID" />
+                <ScalarProperty Name="Title" ColumnName="Title" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="ProductCostHistory">
             <EntityTypeMapping TypeName="Model.ProductCostHistory">
               <MappingFragment StoreEntitySet="ProductCostHistory">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="ProductID" ColumnName="ProductID" />
-                <ScalarProperty Name="ChangeDate" ColumnName="ChangeDate" />
                 <ScalarProperty Name="CostValue" ColumnName="CostValue" />
+                <ScalarProperty Name="ChangeDate" ColumnName="ChangeDate" />
+                <ScalarProperty Name="ProductID" ColumnName="ProductID" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="ProductMaterial">
             <EntityTypeMapping TypeName="Model.ProductMaterial">
               <MappingFragment StoreEntitySet="ProductMaterial">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="ProductID" ColumnName="ProductID" />
-                <ScalarProperty Name="MaterialID" ColumnName="MaterialID" />
                 <ScalarProperty Name="Count" ColumnName="Count" />
+                <ScalarProperty Name="MaterialID" ColumnName="MaterialID" />
+                <ScalarProperty Name="ProductID" ColumnName="ProductID" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="ProductSale">
             <EntityTypeMapping TypeName="Model.ProductSale">
               <MappingFragment StoreEntitySet="ProductSale">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="AgentID" ColumnName="AgentID" />
-                <ScalarProperty Name="ProductID" ColumnName="ProductID" />
-                <ScalarProperty Name="SaleDate" ColumnName="SaleDate" />
                 <ScalarProperty Name="ProductCount" ColumnName="ProductCount" />
+                <ScalarProperty Name="SaleDate" ColumnName="SaleDate" />
+                <ScalarProperty Name="ProductID" ColumnName="ProductID" />
+                <ScalarProperty Name="AgentID" ColumnName="AgentID" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="ProductType">
             <EntityTypeMapping TypeName="Model.ProductType">
               <MappingFragment StoreEntitySet="ProductType">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="Title" ColumnName="Title" />
                 <ScalarProperty Name="DefectedPercent" ColumnName="DefectedPercent" />
+                <ScalarProperty Name="Title" ColumnName="Title" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="Shop">
             <EntityTypeMapping TypeName="Model.Shop">
               <MappingFragment StoreEntitySet="Shop">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="Title" ColumnName="Title" />
-                <ScalarProperty Name="Address" ColumnName="Address" />
                 <ScalarProperty Name="AgentID" ColumnName="AgentID" />
+                <ScalarProperty Name="Address" ColumnName="Address" />
+                <ScalarProperty Name="Title" ColumnName="Title" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="Supplier">
             <EntityTypeMapping TypeName="Model.Supplier">
               <MappingFragment StoreEntitySet="Supplier">
-                <ScalarProperty Name="ID" ColumnName="ID" />
-                <ScalarProperty Name="Title" ColumnName="Title" />
-                <ScalarProperty Name="INN" ColumnName="INN" />
-                <ScalarProperty Name="StartDate" ColumnName="StartDate" />
-                <ScalarProperty Name="QualityRating" ColumnName="QualityRating" />
                 <ScalarProperty Name="SupplierType" ColumnName="SupplierType" />
+                <ScalarProperty Name="QualityRating" ColumnName="QualityRating" />
+                <ScalarProperty Name="StartDate" ColumnName="StartDate" />
+                <ScalarProperty Name="INN" ColumnName="INN" />
+                <ScalarProperty Name="Title" ColumnName="Title" />
+                <ScalarProperty Name="ID" ColumnName="ID" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <AssociationSetMapping Name="MaterialSupplier" TypeName="Model.MaterialSupplier" StoreEntitySet="MaterialSupplier">
-            <EndProperty Name="Material">
-              <ScalarProperty Name="ID" ColumnName="MaterialID" />
-            </EndProperty>
             <EndProperty Name="Supplier">
               <ScalarProperty Name="ID" ColumnName="SupplierID" />
             </EndProperty>
+            <EndProperty Name="Material">
+              <ScalarProperty Name="ID" ColumnName="MaterialID" />
+            </EndProperty>
           </AssociationSetMapping>
         </EntityContainerMapping>
       </Mapping>

+ 25 - 25
Model1.edmx.diagram

@@ -5,31 +5,31 @@
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
       <Diagram DiagramId="aca4d1387b5d4872999d0916f5d7c2ec" Name="Diagram1">
-        <EntityTypeShape EntityType="Model.Agent" Width="1.5" PointX="3" PointY="13.25" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.AgentPriorityHistory" Width="1.5" PointX="5.25" PointY="16.875" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.AgentType" Width="1.5" PointX="0.75" PointY="14.375" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.Material" Width="1.5" PointX="3" PointY="8.75" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.MaterialCountHistory" Width="1.5" PointX="5.25" PointY="11" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.MaterialType" Width="1.5" PointX="0.75" PointY="9.625" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.Product" Width="1.5" PointX="3" PointY="3.5" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.ProductCostHistory" Width="1.5" PointX="5.25" PointY="4.25" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.ProductMaterial" Width="1.5" PointX="5.25" PointY="1.125" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.ProductSale" Width="1.5" PointX="5.25" PointY="7" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.ProductType" Width="1.5" PointX="0.75" PointY="4.375" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.Shop" Width="1.5" PointX="5.25" PointY="19.625" IsExpanded="true" />
-        <EntityTypeShape EntityType="Model.Supplier" Width="1.5" PointX="5.25" PointY="13.75" IsExpanded="true" />
-        <AssociationConnector Association="Model.FK_Agent_AgentType" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_AgentPriorityHistory_Agent" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_ProductSale_Agent" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_Shop_Agent" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_Material_MaterialType" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_MaterialCountHistory_Material" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_ProductMaterial_Material" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_Product_ProductType" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_ProductCostHistory_Product" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_ProductMaterial_Product" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.FK_ProductSale_Product" ManuallyRouted="false" />
-        <AssociationConnector Association="Model.MaterialSupplier" ManuallyRouted="false" />
+        <EntityTypeShape EntityType="Model.Agent" Width="1.5" PointX="3" PointY="10.25" />
+        <EntityTypeShape EntityType="Model.AgentPriorityHistory" Width="1.5" PointX="5.25" PointY="18.875" />
+        <EntityTypeShape EntityType="Model.AgentType" Width="1.5" PointX="0.75" PointY="11.375" />
+        <EntityTypeShape EntityType="Model.Material" Width="1.5" PointX="3" PointY="0.75" />
+        <EntityTypeShape EntityType="Model.MaterialCountHistory" Width="1.5" PointX="5.25" PointY="15.875" />
+        <EntityTypeShape EntityType="Model.MaterialType" Width="1.5" PointX="0.75" PointY="4.125" />
+        <EntityTypeShape EntityType="Model.Product" Width="1.5" PointX="3" PointY="5.875" />
+        <EntityTypeShape EntityType="Model.ProductCostHistory" Width="1.5" PointX="5.25" PointY="9.5" />
+        <EntityTypeShape EntityType="Model.ProductMaterial" Width="1.5" PointX="5.25" PointY="6.5" />
+        <EntityTypeShape EntityType="Model.ProductSale" Width="1.5" PointX="5.25" PointY="3.375" />
+        <EntityTypeShape EntityType="Model.ProductType" Width="1.5" PointX="0.75" PointY="6.75" />
+        <EntityTypeShape EntityType="Model.Shop" Width="1.5" PointX="5.25" PointY="21.625" />
+        <EntityTypeShape EntityType="Model.Supplier" Width="1.5" PointX="5.25" PointY="12.75" />
+        <AssociationConnector Association="Model.FK_Agent_AgentType" />
+        <AssociationConnector Association="Model.FK_AgentPriorityHistory_Agent" />
+        <AssociationConnector Association="Model.FK_ProductSale_Agent" />
+        <AssociationConnector Association="Model.FK_Shop_Agent" />
+        <AssociationConnector Association="Model.FK_Material_MaterialType" />
+        <AssociationConnector Association="Model.FK_MaterialCountHistory_Material" />
+        <AssociationConnector Association="Model.FK_ProductMaterial_Material" />
+        <AssociationConnector Association="Model.FK_Product_ProductType" />
+        <AssociationConnector Association="Model.FK_ProductCostHistory_Product" />
+        <AssociationConnector Association="Model.FK_ProductMaterial_Product" />
+        <AssociationConnector Association="Model.FK_ProductSale_Product" />
+        <AssociationConnector Association="Model.MaterialSupplier" />
       </Diagram>
     </edmx:Diagrams>
   </edmx:Designer>

+ 51 - 0
Namordnik.csproj

@@ -77,6 +77,7 @@
     <Compile Include="AgentType.cs">
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
+    <Compile Include="Class\PaginationClass.cs" />
     <Compile Include="Material.cs">
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
@@ -91,9 +92,18 @@
       <DesignTime>True</DesignTime>
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
+    <Compile Include="Pages\ChangedWindow.xaml.cs">
+      <DependentUpon>ChangedWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Pages\CreateOrUpdatePage.xaml.cs">
+      <DependentUpon>CreateOrUpdatePage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Pages\MainPage.xaml.cs">
       <DependentUpon>MainPage.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Pages\Reports.xaml.cs">
+      <DependentUpon>Reports.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Product.cs">
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
@@ -130,10 +140,22 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="Pages\ChangedWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Pages\CreateOrUpdatePage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Pages\MainPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Pages\Reports.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Model1.Context.cs">
@@ -267,5 +289,34 @@
   <ItemGroup>
     <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
   </ItemGroup>
+  <ItemGroup>
+    <COMReference Include="Microsoft.Office.Core">
+      <Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid>
+      <VersionMajor>2</VersionMajor>
+      <VersionMinor>8</VersionMinor>
+      <Lcid>0</Lcid>
+      <WrapperTool>primary</WrapperTool>
+      <Isolated>False</Isolated>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </COMReference>
+    <COMReference Include="Microsoft.Office.Interop.Word">
+      <Guid>{00020905-0000-0000-C000-000000000046}</Guid>
+      <VersionMajor>8</VersionMajor>
+      <VersionMinor>7</VersionMinor>
+      <Lcid>0</Lcid>
+      <WrapperTool>primary</WrapperTool>
+      <Isolated>False</Isolated>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </COMReference>
+    <COMReference Include="VBIDE">
+      <Guid>{0002E157-0000-0000-C000-000000000046}</Guid>
+      <VersionMajor>5</VersionMajor>
+      <VersionMinor>3</VersionMinor>
+      <Lcid>0</Lcid>
+      <WrapperTool>primary</WrapperTool>
+      <Isolated>False</Isolated>
+      <EmbedInteropTypes>True</EmbedInteropTypes>
+    </COMReference>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 16 - 0
Pages/ChangedWindow.xaml

@@ -0,0 +1,16 @@
+<Window x:Class="Namordnik.Pages.ChangedWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:Namordnik.Pages"
+        mc:Ignorable="d"
+        Title="ChangedWindow" SizeToContent="WidthAndHeight">
+    <Grid>
+        <StackPanel>
+            <TextBox Name="SrCost"></TextBox>
+            <Button Name="BTChange" Click="BTChange_Click">Изменить</Button>
+        </StackPanel>
+        
+    </Grid>
+</Window>

+ 40 - 0
Pages/ChangedWindow.xaml.cs

@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Namordnik.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для ChangedWindow.xaml
+    /// </summary>
+    public partial class ChangedWindow : Window
+    {
+        public ChangedWindow(int a)
+        {
+            InitializeComponent();
+            SrCost.Text = a.ToString();
+        }
+
+        private void BTChange_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+        public int srcost
+        {
+            get
+            {
+                return Convert.ToInt32(SrCost.Text);
+            }
+        }
+    }
+}

+ 41 - 0
Pages/CreateOrUpdatePage.xaml

@@ -0,0 +1,41 @@
+<Page x:Class="Namordnik.Pages.CreateOrUpdatePage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:Namordnik.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="CreateOrUpdatePage">
+
+    <Grid>
+        <StackPanel>
+            <GroupBox Header="Выберите тип продукта">
+                <ComboBox Name="CBTypePr"></ComboBox>
+            </GroupBox>
+            <GroupBox Header="Введите наименование продукта">
+                <TextBox Name="TBNamePr" ></TextBox>
+            </GroupBox>
+            <GroupBox Header="Введите арктикул продукта">
+                <TextBox Name="TBArct"></TextBox>
+            </GroupBox>
+            <GroupBox Header="Введите кол-во человек для производства">
+                <TextBox Name="TBKolvo" ></TextBox>
+            </GroupBox>
+            <GroupBox Header="Введите номер производственного цеха">
+                <TextBox Name="TBNumder" ></TextBox>
+            </GroupBox>
+            <GroupBox Header="Введите мнимальную стоимость для агента">
+                <TextBox Name="TBMinCost" ></TextBox>
+            </GroupBox>
+            <Image Name="ImagePr" Width="80" Height="80"/>
+            <Button Name="BtnSetPhoto" Click="BtnSetPhoto_Click">Выберите фото продукта</Button>
+            <GroupBox Header="Выберите материал">
+                <ComboBox Name="CBMaterial" IsEditable="True"></ComboBox>
+            </GroupBox>
+            <ListBox Name="LBMaterail" ></ListBox>
+            <Button Name="BtnAddRed" Click="BtnAddRed_Click">Добавить\Редактировать</Button>
+            <Button Name="BtnDel" Uid="{Binding ID}" Click="BtnDel_Click" Visibility="Collapsed">Удалить</Button>
+        </StackPanel>
+    </Grid>
+</Page>

+ 168 - 0
Pages/CreateOrUpdatePage.xaml.cs

@@ -0,0 +1,168 @@
+using Microsoft.Win32;
+using Namordnik.Class;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Namordnik.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для CreateOrUpdatePage.xaml
+    /// </summary>
+    public partial class CreateOrUpdatePage : Page
+    {
+        List<ProductType> PT = BaseClass.Base.ProductType.ToList();
+        List<Material> M = BaseClass.Base.Material.ToList();
+        List<ProductSale> PrSale = BaseClass.Base.ProductSale.ToList();
+        Product PROD = new Product();
+        string path;
+        bool flag;
+        bool artnum;
+        bool del;
+        public CreateOrUpdatePage()
+        {                
+            InitializeComponent();
+            flag = true;
+            CBTypePr.Items.Add("Выберите тип");            
+            for (int i = 0; i < PT.Count; i++)
+            {
+                CBTypePr.Items.Add(PT[i].Title);
+            }            
+            CBTypePr.SelectedIndex = 0;            
+            for (int i = 0; i < M.Count; i++)
+            {
+                CBMaterial.Items.Add(M[i].Title);
+            }
+           
+        }
+        public CreateOrUpdatePage(Product PrUpdate) 
+        {
+            InitializeComponent();
+            if (flag == false)
+            {
+                BtnDel.Visibility = Visibility.Visible;
+            }
+            CBTypePr.Items.Add("Выберите тип");
+            for (int i = 0; i < PT.Count; i++)
+            {
+                CBTypePr.Items.Add(PT[i].Title);
+            }
+
+            PROD = PrUpdate;
+            CBTypePr.SelectedIndex = (int)PrUpdate.ProductTypeID;
+            TBNamePr.Text = PrUpdate.Title;
+            TBArct.Text = PrUpdate.ArticleNumber;
+            TBKolvo.Text = Convert.ToString(PrUpdate.ProductionPersonCount);
+            TBNumder.Text = Convert.ToString(PrUpdate.ProductionWorkshopNumber);
+            TBMinCost.Text = Convert.ToString(PrUpdate.MinCostForAgent);
+            path = PrUpdate.Image;
+            if (path!=null)
+            {
+                BitmapImage BI = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute));
+                ImagePr.Source = BI;
+            }
+
+        }
+
+            private void BtnSetPhoto_Click(object sender, RoutedEventArgs e)
+        {
+            OpenFileDialog OFD = new OpenFileDialog();  
+            OFD.ShowDialog();  
+            path = OFD.FileName;  
+            int n = path.IndexOf("products");  
+            path ="\\" + path.Substring(n);
+            if (path != null)
+            {
+                BitmapImage BI = new BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute));
+                ImagePr.Source = BI;
+            }
+        }
+
+        private void BtnAddRed_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                int IdType = 0;
+                if (CBTypePr.SelectedIndex != 0)
+                {
+                    IdType = CBTypePr.SelectedIndex;
+                }
+                PROD.ProductTypeID = IdType;
+                PROD.Title = TBNamePr.Text;
+                PROD.ArticleNumber = TBArct.Text;
+                PROD.ProductionPersonCount = Convert.ToInt32(TBKolvo.Text);
+                PROD.ProductionWorkshopNumber = Convert.ToInt32(TBNumder.Text);
+                PROD.MinCostForAgent = Convert.ToInt32(TBMinCost.Text);
+                PROD.Image = path;
+
+                //for (int i = 0; i <= PROD.ID; i++)
+                //{
+                //    if (TBArct.Text == PROD.ArticleNumber)
+                //    {
+                //        artnum = true;
+                //    }
+                //}
+                if (artnum == true)
+                {
+                    MessageBox.Show("Данные не записаны:\nАртикул не может повторяться");
+                }
+                else if (Convert.ToInt32(TBMinCost.Text) < 0)
+                {
+                    MessageBox.Show("Данные не записаны:\nЦена не может быть отрицательной");
+                }                
+                else
+                {
+                    if (flag == true)
+                    {
+                        BaseClass.Base.Product.Add(PROD);
+                    }
+                    BaseClass.Base.SaveChanges();
+                    MessageBox.Show("Данные записаны");
+                    FrameClass.FrameMain.Navigate(new MainPage());
+                }
+                
+            }
+            catch
+            {
+                MessageBox.Show("Данные не записаны");
+            }
+        }
+
+        private void BtnDel_Click(object sender, RoutedEventArgs e)
+        {
+            
+            foreach(ProductSale item in PrSale)
+            {
+                if(PROD.ID == item.ProductID)
+                {
+                    del = true;
+                }
+            }
+            if(del == true)
+            {
+                MessageBox.Show("Данные не записаны:\nТовар продан агентом");
+            }
+            else
+            {
+                int ind = PROD.ID;
+                Product PrDel = BaseClass.Base.Product.FirstOrDefault(y => y.ID == ind);
+                BaseClass.Base.Product.Remove(PrDel);
+                BaseClass.Base.SaveChanges();
+                MessageBox.Show("Запись удалена");
+                FrameClass.FrameMain.Navigate(new MainPage());
+            }
+            
+        }
+    }
+}

+ 29 - 10
Pages/MainPage.xaml

@@ -6,29 +6,34 @@
       xmlns:local="clr-namespace:Namordnik.Pages"
       mc:Ignorable="d" 
        d:DesignHeight="900" d:DesignWidth="750"
-      Title="Page1" MaxWidth="750" MaxHeight="900" MinHeight="900" MinWidth="750">
+      Title="MainPage" MaxWidth="750" MaxHeight="900" MinHeight="900" MinWidth="750">
     <Page.Resources>
         <BitmapImage x:Key="defaulimage" UriSource="/Resources/picture.png"></BitmapImage>
     </Page.Resources>
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="150"></RowDefinition>
+            <RowDefinition Height="170"></RowDefinition>
+            <RowDefinition Height="470" ></RowDefinition>
             <RowDefinition ></RowDefinition>
         </Grid.RowDefinitions>
-        <StackPanel   Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center">
+        <StackPanel   Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Center">
             <Image Source="/Resources/Намордник.png" Height="80" Width="80"></Image>
-            <TextBlock  VerticalAlignment="Center" Margin="30,0,0,0">Намордник</TextBlock>
+            <TextBlock  VerticalAlignment="Center" HorizontalAlignment="Center" >Намордник</TextBlock>
         </StackPanel>
         <StackPanel  Height="50" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0,25" Orientation="Horizontal">
             <TextBox Name="TBFilter" TextChanged="TBFilter_TextChanged" Width="380" Height="25" Margin="10,0,30,0"></TextBox>
             <ComboBox Name="CBSort" Width="150" Height="25" Margin="0,0,30,0"></ComboBox>
             <ComboBox Name="CBFilter" SelectionChanged="CBFilter_SelectionChanged" Width="150" Height="25" Margin="0,0,0,0"></ComboBox>
         </StackPanel>
-        <StackPanel VerticalAlignment="Bottom" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,180,0">
+        <StackPanel VerticalAlignment="Bottom" Orientation="Horizontal" HorizontalAlignment="Right" >
+            <Button  Width="380" Height="25" Margin="0,0,30,0" Name="WRDoc" Click="WRDoc_Click" Visibility="Visible">Экспрот в Word</Button>
+            <Button Width="380" Height="25" Margin="0,0,30,0" Name="Changed" Click="Changed_Click" Visibility="Collapsed">Изменить стоимость на...</Button>
             <Button Width="60" Height="25" Margin="0,0,30,0" Name="BtnSortUp" Click="BtnSortUp_Click">По возр.</Button>
-            <Button Width="60" Height="25" Name="BtnSortDown" Click="BtnSortDown_Click">По убыв.</Button>
+            <Button Width="60" Height="25" Margin="0,0,30,0" Name="BtnSortDown" Click="BtnSortDown_Click">По убыв.</Button>
+            <Button Width="150" Height="25" Name="BtnAdd" Click="BtnAdd_Click">Добавить продукцию</Button>
         </StackPanel>
-        <ListView Name="LVProdMat"  ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.Row="1" BorderThickness="0">
+
+        <ListView Name="LVProdMat" SelectionMode="Multiple" SelectionChanged="LVProdMat_SelectionChanged" ScrollViewer.HorizontalScrollBarVisibility="Disabled"  Grid.Row="1" BorderThickness="0">
             <ListView.ItemsPanel >
                 <ItemsPanelTemplate>
                     <WrapPanel HorizontalAlignment="Center"></WrapPanel>
@@ -36,23 +41,37 @@
             </ListView.ItemsPanel>
             <ListView.ItemTemplate>
                 <DataTemplate>
-                    <Border Padding="5" CornerRadius="5" BorderThickness="1" BorderBrush="#FDBD40" Background="#B0E5FD">
-                        <Grid Width="700" Height="50">
+                    <Border Padding="5" CornerRadius="5" BorderThickness="1" BorderBrush="#FDBD40" Background="{Binding PrColor}">
+                        <Grid Width="700" Height="65">
                             <StackPanel Orientation="Horizontal">
                                 <Image Margin="0,0,20,0" Source="{Binding Image,TargetNullValue={StaticResource defaulimage}}" Height="50" Width="70"/>
                                 <StackPanel Orientation="Vertical">
                                     <TextBlock Text="{Binding Header}"></TextBlock>
                                     <TextBlock Text="{Binding ArticleNumber, StringFormat={}Артикул: {0}}"></TextBlock>
-                                    <TextBlock Loaded="TextBlock_Loaded" Uid="{Binding ID}" Width="550" TextWrapping="Wrap"></TextBlock>
+                                    <TextBlock Loaded="TextBlock_Loaded" Uid="{Binding ID}" Width="520" TextWrapping="Wrap"></TextBlock>
                                 </StackPanel>
                             </StackPanel>
                             <StackPanel HorizontalAlignment="Right">
                                 <TextBlock Loaded="TextBlock_Loaded_1" Uid="{Binding ID}"></TextBlock>
                             </StackPanel>
+                            <StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right">
+                                <Button Name="BtnRed" Uid="{Binding ID}" Click="BtnRed_Click"  Width="90" Height="20" >Редактировать</Button>
+                                
+                            </StackPanel>
                         </Grid>
                     </Border>
                 </DataTemplate>
             </ListView.ItemTemplate>
         </ListView>
+       <StackPanel Grid.Row="2">
+        <WrapPanel Orientation="Horizontal" HorizontalAlignment="Center">
+            <TextBlock Name="txtPrev" Uid="prev" Text=" Пред." MouseDown="GoPage_MouseDown" />
+            <TextBlock Name="txt1" Uid="1" Text="{Binding  Path = NPage[0], StringFormat={}{0,3}}" Visibility="{Binding Visible[0]}" FontWeight="{Binding Bold[0]}" MouseDown="GoPage_MouseDown" />
+            <TextBlock Name="txt2" Uid="2" Text="{Binding  Path = NPage[1], StringFormat={}{0,3}}" Visibility="{Binding Visible[1]}" FontWeight="{Binding Bold[1]}" MouseDown="GoPage_MouseDown" />
+            <TextBlock Name="txt3" Uid="3" Text="{Binding  Path = NPage[2], StringFormat={}{0,3}}" Visibility="{Binding Visible[2]}" FontWeight="{Binding Bold[2]}" MouseDown="GoPage_MouseDown" />
+            <TextBlock Name="txt4" Uid="4" Text="{Binding  Path = NPage[3], StringFormat={}{0,3}}" Visibility="{Binding Visible[3]}" FontWeight="{Binding Bold[3]}" MouseDown="GoPage_MouseDown" />
+            <TextBlock Name="txtNext" Uid="next" Text=" След." MouseDown="GoPage_MouseDown" />
+        </WrapPanel>
+       </StackPanel>
     </Grid>
 </Page>

+ 80 - 1
Pages/MainPage.xaml.cs

@@ -14,6 +14,7 @@ using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
 
+
 namespace Namordnik.Pages
 {
     /// <summary>
@@ -22,6 +23,7 @@ namespace Namordnik.Pages
     public partial class MainPage : Page
     {
         List<Product> ProductStart = BaseClass.Base.Product.ToList();
+        PaginationClass pg = new PaginationClass();
         List<Product> PRFilter;
         public MainPage()
         {
@@ -39,6 +41,10 @@ namespace Namordnik.Pages
                 CBFilter.Items.Add(PT[i].Title);
             }
             CBFilter.SelectedIndex = 0;
+            DataContext = pg;
+            pg.CountPage = 15;
+            pg.Countlist = PRFilter.Count;
+            LVProdMat.ItemsSource = PRFilter.Skip(0).Take(pg.CountPage).ToList();
         }
         private void TextBlock_Loaded(object sender, RoutedEventArgs e)
         {
@@ -65,12 +71,14 @@ namespace Namordnik.Pages
             TextBlock tb = (TextBlock)sender;
             int index = Convert.ToInt32(tb.Uid);
             List<ProductMaterial> PT = BaseClass.Base.ProductMaterial.Where(x => x.ProductID == index).ToList();
-
+            
             int cost = 0;
 
             foreach (ProductMaterial item in PT)
             {
+               
                 cost += (int)item.Material.Cost;
+                
             }
             tb.Text = cost + " руб.";
         }
@@ -145,5 +153,76 @@ namespace Namordnik.Pages
             }
 
         }
+
+        private void LVProdMat_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (LVProdMat.SelectedIndex != -1)
+            {
+                Changed.Visibility = Visibility.Visible;
+                WRDoc.Visibility = Visibility.Collapsed;
+            }
+            else
+            {
+                Changed.Visibility = Visibility.Collapsed;
+                WRDoc.Visibility = Visibility.Visible;
+            }
+        }
+
+        private void Changed_Click(object sender, RoutedEventArgs e)
+        {
+            var list = LVProdMat.SelectedItems;
+            int sum = 0;
+            foreach (Product PR in list)
+            {
+                sum += (int)PR.MinCostForAgent;
+            }
+            sum = sum / LVProdMat.SelectedItems.Count;
+            ChangedWindow changedWindow = new ChangedWindow(sum);
+            changedWindow.ShowDialog();
+
+            foreach (Product PR in list)
+            {
+                PR.MinCostForAgent += changedWindow.srcost;
+            }
+            LVProdMat.Items.Refresh();
+
+        }
+  
+
+        private void BtnAdd_Click(object sender, RoutedEventArgs e)
+        {
+            FrameClass.FrameMain.Navigate(new CreateOrUpdatePage());
+        }
+
+        private void BtnRed_Click(object sender, RoutedEventArgs e)
+        {
+            Button B = (Button)sender;  
+            int ind = Convert.ToInt32(B.Uid);  
+            Product PrUpdate = BaseClass.Base.Product.FirstOrDefault(y => y.ID == ind);  
+            FrameClass.FrameMain.Navigate(new CreateOrUpdatePage(PrUpdate));
+        }
+
+        private void GoPage_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            TextBlock tb = (TextBlock)sender;
+            switch (tb.Uid)  // определяем, куда конкретно было сделано нажатие
+            {
+                case "prev":
+                    pg.CurrentPage--;
+                    break;
+                case "next":
+                    pg.CurrentPage++;
+                    break;
+                default:
+                    pg.CurrentPage = Convert.ToInt32(tb.Text);
+                    break;
+            }
+            LVProdMat.ItemsSource = PRFilter.Skip(pg.CurrentPage * pg.CountPage - pg.CountPage).Take(pg.CountPage).ToList();
+        }
+
+        private void WRDoc_Click(object sender, RoutedEventArgs e)
+        {
+            FrameClass.FrameMain.Navigate(new Reports());
+        }
     }
 }

+ 18 - 0
Pages/Reports.xaml

@@ -0,0 +1,18 @@
+<Page x:Class="Namordnik.Pages.Reports"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:Namordnik.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="Reports">
+
+    <Grid>
+        <StackPanel> 
+            <Button Name="BtnRepProd" Click="BtnRepProd_Click" Width="250">Экспорт отчета по продукции в Word/PDF </Button>
+            <Button Name="BtnRepMat" Click="BtnRepMat_Click" Width="250">Экспорт отчета по материалам в Word/PDF</Button>
+        </StackPanel>
+        
+    </Grid>
+</Page>

+ 96 - 0
Pages/Reports.xaml.cs

@@ -0,0 +1,96 @@
+using Namordnik.Class;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using Word = Microsoft.Office.Interop.Word;
+
+namespace Namordnik.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для Reports.xaml
+    /// </summary>
+    public partial class Reports : Page
+    {
+        public Reports()
+        {
+            InitializeComponent();
+        }        
+
+        private void BtnRepProd_Click(object sender, RoutedEventArgs e)
+        {
+            List<Product> PR = BaseClass.Base.Product.ToList(); 
+            
+            var application = new Word.Application();
+
+            Word.Document document = application.Documents.Add();
+
+            foreach(var product  in PR)
+            {
+                Word.Paragraph prodParagraf = document.Paragraphs.Add();
+                Word.Range prodTitleRange = prodParagraf.Range;
+                prodTitleRange.Text = product.Title;
+
+                prodTitleRange.InsertParagraphAfter();
+
+                Word.Paragraph paragraphTable = document.Paragraphs.Add();
+                Word.Range rangeTable = paragraphTable.Range;
+                Word.Table paymentsTable = document.Tables.Add(rangeTable, 2,3);
+                paymentsTable.Borders.InsideLineStyle = paymentsTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
+                paymentsTable.Range.Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;
+
+                Word.Range cellRange;
+
+                cellRange = paymentsTable.Cell(1, 1).Range;
+                cellRange.Text = "Изображение продукции";
+                cellRange = paymentsTable.Cell(1, 2).Range;
+                cellRange.Text = "Тип продукции";
+                cellRange = paymentsTable.Cell(1, 3).Range;
+                cellRange.Text = "Артикул";              
+
+                paymentsTable.Rows[1].Range.Bold = 1;
+                paymentsTable.Rows[1].Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
+                string path = "/Resources/picture.png";
+                cellRange = paymentsTable.Cell(2, 1).Range;
+                    if (product.Image != null)
+                    {
+                        Word.InlineShape ImageShape = cellRange.InlineShapes.AddPicture(AppDomain.CurrentDomain.BaseDirectory + "..\\.." + product.Image);
+                        cellRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
+                        ImageShape.Width = ImageShape.Height = 50;
+                    }
+                    else
+                    {
+                        Word.InlineShape ImageShape = cellRange.InlineShapes.AddPicture(AppDomain.CurrentDomain.BaseDirectory + "..\\.." + path);
+                        cellRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;
+                        ImageShape.Width = ImageShape.Height = 50;
+                    }
+                
+                cellRange = paymentsTable.Cell(2, 2).Range;
+                    cellRange.Text = product.ProductType.Title;
+                    cellRange = paymentsTable.Cell(2, 3).Range;
+                    cellRange.Text = product.ArticleNumber;
+                
+                
+                
+            }
+            application.Visible = true;
+
+            //document.SaveAs2(@"\\main\RDP\43П\мелузовна\Desktop\Практика\Test.docx");
+        }
+
+        private void BtnRepMat_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+    }
+}