Kaynağa Gözat

Добавьте файлы проекта.

TriPSglitch 2 yıl önce
ebeveyn
işleme
a4626f1416
60 değiştirilmiş dosya ile 4620 ekleme ve 0 silme
  1. 25 0
      Cafe.sln
  2. 22 0
      Cafe2/AddWindows/AddDishWindow.xaml
  3. 64 0
      Cafe2/AddWindows/AddDishWindow.xaml.cs
  4. 27 0
      Cafe2/AddWindows/AddEmployeeWindow.xaml
  5. 100 0
      Cafe2/AddWindows/AddEmployeeWindow.xaml.cs
  6. 30 0
      Cafe2/AddWindows/AddExchangeWindow.xaml
  7. 146 0
      Cafe2/AddWindows/AddExchangeWindow.xaml.cs
  8. 37 0
      Cafe2/AddWindows/AddOrderWindow.xaml
  9. 119 0
      Cafe2/AddWindows/AddOrderWindow.xaml.cs
  10. 23 0
      Cafe2/App.config
  11. 9 0
      Cafe2/App.xaml
  12. 17 0
      Cafe2/App.xaml.cs
  13. 16 0
      Cafe2/AuthorizationWindow.xaml
  14. 62 0
      Cafe2/AuthorizationWindow.xaml.cs
  15. 38 0
      Cafe2/Cafe.Context.cs
  16. 636 0
      Cafe2/Cafe.Context.tt
  17. 10 0
      Cafe2/Cafe.Designer.cs
  18. 9 0
      Cafe2/Cafe.cs
  19. 271 0
      Cafe2/Cafe.csproj
  20. 563 0
      Cafe2/Cafe.edmx
  21. 27 0
      Cafe2/Cafe.edmx.diagram
  22. 733 0
      Cafe2/Cafe.tt
  23. 7 0
      Cafe2/Connection.cs
  24. 32 0
      Cafe2/Dishes.cs
  25. 19 0
      Cafe2/ElementsWindows/DishWindow.xaml
  26. 31 0
      Cafe2/ElementsWindows/DishWindow.xaml.cs
  27. 27 0
      Cafe2/ElementsWindows/EmployeeWindow.xaml
  28. 63 0
      Cafe2/ElementsWindows/EmployeeWindow.xaml.cs
  29. 54 0
      Cafe2/ElementsWindows/ExchangeWindow.xaml
  30. 100 0
      Cafe2/ElementsWindows/ExchangeWindow.xaml.cs
  31. 41 0
      Cafe2/ElementsWindows/OrderWindow.xaml
  32. 92 0
      Cafe2/ElementsWindows/OrderWindow.xaml.cs
  33. 32 0
      Cafe2/EmployeesExchanges.cs
  34. 25 0
      Cafe2/Encrypt.cs
  35. 13 0
      Cafe2/ErrorWindow.xaml
  36. 21 0
      Cafe2/ErrorWindow.xaml.cs
  37. 31 0
      Cafe2/Exchange.cs
  38. 50 0
      Cafe2/ImagesManip.cs
  39. 28 0
      Cafe2/ListWindows/EmployeesListWindow.xaml
  40. 58 0
      Cafe2/ListWindows/EmployeesListWindow.xaml.cs
  41. 28 0
      Cafe2/ListWindows/ExchangesListWindow.xaml
  42. 59 0
      Cafe2/ListWindows/ExchangesListWindow.xaml.cs
  43. 28 0
      Cafe2/ListWindows/OrdersListWindow.xaml
  44. 105 0
      Cafe2/ListWindows/OrdersListWindow.xaml.cs
  45. 29 0
      Cafe2/MainWindow.xaml
  46. 72 0
      Cafe2/MainWindow.xaml.cs
  47. 24 0
      Cafe2/OrderDishes.cs
  48. 36 0
      Cafe2/Orders.cs
  49. 55 0
      Cafe2/Properties/AssemblyInfo.cs
  50. 71 0
      Cafe2/Properties/Resources.Designer.cs
  51. 117 0
      Cafe2/Properties/Resources.resx
  52. 30 0
      Cafe2/Properties/Settings.Designer.cs
  53. 7 0
      Cafe2/Properties/Settings.settings
  54. 29 0
      Cafe2/Roles.cs
  55. 121 0
      Cafe2/Style.xaml
  56. 28 0
      Cafe2/Tables.cs
  57. 8 0
      Cafe2/User.cs
  58. 37 0
      Cafe2/Users.cs
  59. 5 0
      Cafe2/packages.config
  60. 23 0
      Cafe2/sysdiagrams.cs

+ 25 - 0
Cafe.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.2.32630.192
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cafe", "Cafe2\Cafe.csproj", "{3C1FDBA5-FF5C-4343-8D21-DC14A25D653C}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{3C1FDBA5-FF5C-4343-8D21-DC14A25D653C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{3C1FDBA5-FF5C-4343-8D21-DC14A25D653C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{3C1FDBA5-FF5C-4343-8D21-DC14A25D653C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{3C1FDBA5-FF5C-4343-8D21-DC14A25D653C}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {E515DC07-AFB7-42A0-B469-F5FBC6B99692}
+	EndGlobalSection
+EndGlobal

+ 22 - 0
Cafe2/AddWindows/AddDishWindow.xaml

@@ -0,0 +1,22 @@
+<Window x:Class="Cafe.AddWindows.AddDishWindow"
+        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:Cafe.AddWindows"
+        mc:Ignorable="d"
+        Title="Добавить блюдо" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Label Content="Название:" HorizontalAlignment="Left" Margin="127,86,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36"/>
+        <TextBox x:Name="Name" HorizontalAlignment="Left" Margin="307,86,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="60" Width="730" FontSize="36"/>
+        <Label Content="Цена:" HorizontalAlignment="Left" Margin="127,180,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36" HorizontalContentAlignment="Right"/>
+        <TextBox x:Name="Price" HorizontalAlignment="Left" Margin="307,180,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="60" Width="250" FontSize="36"/>
+        <Label Content="Описание:" HorizontalAlignment="Left" Margin="127,274,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36"/>
+        <TextBox x:Name="Description" HorizontalAlignment="Left" Margin="137,350,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="328" Width="904" FontSize="36"/>
+        <Label Content="Изображение:" HorizontalAlignment="Left" Margin="127,708,0,0" VerticalAlignment="Top" Height="61" Width="260" Foreground="White" FontSize="36"/>
+        <Image x:Name="Picture" HorizontalAlignment="Left" Height="649" Margin="1129,133,0,0" VerticalAlignment="Top"  Width="411"/>
+        <Button x:Name="SelectButton" Content="Выбрать" HorizontalAlignment="Left" Margin="381,708,0,0" VerticalAlignment="Top" Height="60" Width="180" FontSize="36" Click="SelectButtonClick"/>
+        <Button x:Name="BackButton"  Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+        <Button x:Name="AddButton" Content="Добавить" HorizontalAlignment="Center" Margin="0,792,0,0" VerticalAlignment="Top" Height="60" Width="180" FontSize="36" Click="AddButtonClick"/>
+    </Grid>
+</Window>

+ 64 - 0
Cafe2/AddWindows/AddDishWindow.xaml.cs

@@ -0,0 +1,64 @@
+using System;
+using System.Windows;
+using System.Windows.Media.Imaging;
+
+namespace Cafe.AddWindows
+{
+    public partial class AddDishWindow : Window
+    {
+        public AddDishWindow()
+        {
+            InitializeComponent();
+        }
+        private void SelectButtonClick(object sender, RoutedEventArgs e)
+        {
+            BitmapImage image = new BitmapImage();
+            image = ImagesManip.SelectImage();
+            Picture.Source = image;
+        }
+
+        private void AddButtonClick(object sender, RoutedEventArgs e)
+        {
+            if (Name.Text == "" || Price.Text == "")
+            {
+                ErrorWindow errorWindow = new ErrorWindow("пустые поля");
+                errorWindow.Show();
+                return;
+            }
+
+            decimal priceResult;
+            if (!decimal.TryParse(Price.Text, out priceResult))
+            {
+                ErrorWindow errorWindow = new ErrorWindow("цена указана неверно");
+                errorWindow.Show();
+                return;
+            }
+
+            Dishes dish = new Dishes()
+            {
+                Name = Name.Text,
+                Price = Convert.ToDecimal(Price.Text)
+            };
+
+            if (Description.Text != null)
+                dish.Description = Description.Text;
+
+            if (Picture.Source != null)
+                dish.Picture = ImagesManip.BitmapSourceToByteArray((BitmapSource)Picture.Source);
+
+            Connection.db.Dishes.Add(dish);
+            Connection.db.SaveChanges();
+
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 27 - 0
Cafe2/AddWindows/AddEmployeeWindow.xaml

@@ -0,0 +1,27 @@
+<Window x:Class="Cafe.AddWindows.AddEmployeeWindow"
+        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:Cafe.AddWindows"
+        mc:Ignorable="d"
+Title="Добавление сотрудника" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Label Content="Логин:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,104,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <TextBox Name="Login" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,164,0,0" Height="60" Width="550" Background="White" FontSize="36"/>
+        <Label Content="Пароль:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,104,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <PasswordBox Name="Password" VerticalAlignment="Top" Margin="925,164,0,0" Height="60" FontSize="36" HorizontalAlignment="Left" Width="550"/>
+        <Label Content="Фамилия:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,246,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <TextBox Name="SecondName" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,306,0,0" Height="60" Width="550" Background="White" FontSize="36" TextChanged="TextChanged"/>
+        <Label Content="Имя:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,246,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <TextBox Name="FirstName" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,306,0,0" Height="60" Width="550" Background="White" FontSize="36" TextChanged="TextChanged"/>
+        <Label Content="Отчество:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,388,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <TextBox Name="MiddleName" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,448,0,0" Height="60" Width="550" Background="White" FontSize="36" TextChanged="TextChanged"/>
+        <Label Content="Почта:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,388,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <TextBox Name="Email" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,448,0,0" Height="60" Width="550" Background="White" FontSize="36"/>
+        <Button Name="RegistrationButton" Content="Зарегистрировать" VerticalAlignment="Top" HorizontalAlignment="Center" Height="60" Width="360" Margin="0,746,0,0" FontSize="36" Click="RegistrationClick"/>
+        <Button x:Name="BackButton" Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+        <Label Content="Должность:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,530,0,0" Foreground="White" Height="60" Width="200" FontSize="36"/>
+        <ComboBox x:Name="RoleBox" Height="60" Width="550" HorizontalAlignment="Left" Margin="125,590,0,0" VerticalAlignment="Top" Foreground="Black" FontSize="36"/>
+    </Grid>
+</Window>

+ 100 - 0
Cafe2/AddWindows/AddEmployeeWindow.xaml.cs

@@ -0,0 +1,100 @@
+using System;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Text.RegularExpressions;
+
+namespace Cafe.AddWindows
+{
+    public partial class AddEmployeeWindow : Window
+    {
+        public AddEmployeeWindow()
+        {
+            InitializeComponent();
+            RoleBox.ItemsSource = Connection.db.Roles.Select(item => item.RoleName).ToList();
+        }
+
+        private void RegistrationClick(object sender, RoutedEventArgs e)
+        {
+            bool regRes = Registration(Login.Text.ToString(), Password.Password.ToString(), FirstName.Text.ToString(),
+                                        SecondName.Text.ToString(), MiddleName.Text.ToString(), Email.Text.ToString());
+
+            if (regRes)
+            {
+                MainWindow mainWindow = new MainWindow();
+                mainWindow.Show();
+                this.Close();
+            }
+        }
+
+        public bool Registration(string login, string password, string Fname, string Sname, string Mname, string email)
+        {
+            if (Login.Text == "" || Password.Password == "" || FirstName.Text == "" || SecondName.Text == "" || Email.Text == "" || RoleBox.SelectedItem == null)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("пустые поля");
+                errorWindow.Show();
+                return false;
+            }
+            if (Connection.db.Users.Select(item => item.Login).Contains(Login.Text))
+            {
+                ErrorWindow errorWindow = new ErrorWindow("такой пользователь уже существует");
+                errorWindow.Show();
+                return false;
+            }
+            if (!IsValidEmail(Email.Text))
+            {
+                ErrorWindow errorWindow = new ErrorWindow("неверный формат почты");
+                errorWindow.Show();
+                return false;
+            }
+
+            string roleName = Convert.ToString(RoleBox.SelectedItem);
+            Roles role = Connection.db.Roles.Where(item => item.RoleName == roleName).FirstOrDefault();
+
+            Users user = new Users()
+            {
+                Login = Login.Text,
+                Password = Encrypt.Hash(Password.Password),
+                SecondName = SecondName.Text,
+                FirstName = FirstName.Text,
+                Email = Email.Text,
+                IDRole = role.ID,
+                IsFired = false
+            };
+            if (MiddleName.Text != "")
+            {
+                user.MiddleName = MiddleName.Text;
+            }
+
+            Connection.db.Users.Add(user);
+            Connection.db.SaveChanges();
+
+            return true;
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+
+        private bool IsValidEmail(string email)
+        {
+            string regex = @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$";
+            if (Regex.IsMatch(email, regex))
+                return true;
+            else
+                return false;
+        }
+
+        private void TextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (Regex.IsMatch((((TextBox)sender).Text).ToString(), "[^А-я-:]"))
+            {
+                ((TextBox)sender).Text = ((TextBox)sender).Text.Remove(((TextBox)sender).Text.Length - 1);
+                ((TextBox)sender).SelectionStart = ((TextBox)sender).Text.Length;
+            }
+        }
+    }
+}

+ 30 - 0
Cafe2/AddWindows/AddExchangeWindow.xaml

@@ -0,0 +1,30 @@
+<Window x:Class="Cafe.AddWindows.AddExchangeWindow"
+        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:Cafe.AddWindows"
+        mc:Ignorable="d"
+        Title="Формирование смены" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Button x:Name="BackButton" Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+        <Label Content="Дата:" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="36" Height="60" Margin="570,58,0,0" Width="130" HorizontalContentAlignment="Right"/>
+        <TextBox x:Name="Date" HorizontalAlignment="Left" Margin="702,58,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="60" Width="400" FontSize="36" TextChanged="DateTextChanged"/>
+        <Label Content="Время начала:" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="36" Height="60" Margin="64,148,0,0" Width="254" HorizontalContentAlignment="Right"/>
+        <TextBox x:Name="TimeOfBegin" HorizontalAlignment="Left" Margin="319,148,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="60" Width="400" FontSize="36" TextChanged="TimeTextChanged"/>
+        <Label Content="Время окончания:" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="36" Height="60" Margin="784,148,0,0" Width="315" HorizontalContentAlignment="Right"/>
+        <TextBox x:Name="TimeOfEnd" HorizontalAlignment="Left" Margin="1100,148,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="60" Width="400" FontSize="36" TextChanged="TimeTextChanged"/>
+        <DataGrid x:Name="EmployeesList" AutoGenerateColumns="False" Height="385" VerticalAlignment="Top" HorizontalAlignment="Center" Width="1340"
+            RowHeaderStyle="{StaticResource RowHeaderStyle}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" Margin="0,269,0,0">
+            <DataGrid.Columns>
+                <DataGridTextColumn Binding="{Binding SecondName}" Header="Фамлия" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding FirstName}" Header="Имя" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding MiddleName}" Header="Отчество" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding Roles.RoleName}" Header="Должность" Width="330" IsReadOnly="True"/>
+            </DataGrid.Columns>
+        </DataGrid>
+        <Button x:Name="AddEmployee" Content="Добавить работника" HorizontalAlignment="Left" VerticalAlignment="Top" Height="60" Width="361" FontSize="36" Click="AddEmployeeClick" Margin="53,687,0,0"/>
+        <ComboBox x:Name="EmployeeBox" Height="60" Width="450" HorizontalAlignment="Left" Margin="430,687,0,0" VerticalAlignment="Top" Foreground="Black" FontSize="36"/>
+        <Button x:Name="SaveExchange" Content="Сохранить смену" HorizontalAlignment="Center" VerticalAlignment="Top" Height="60" Width="309" FontSize="36" Click="SaveExchangeClick" Margin="0,792,0,0"/>
+    </Grid>
+</Window>

+ 146 - 0
Cafe2/AddWindows/AddExchangeWindow.xaml.cs

@@ -0,0 +1,146 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Text.RegularExpressions;
+
+namespace Cafe.AddWindows
+{
+    public partial class AddExchangeWindow : Window
+    {
+        public AddExchangeWindow()
+        {
+            InitializeComponent();
+            EmployeeBox.ItemsSource = Connection.db.Users.Where(item => item.IDRole != 1).Select(item => item.Login).ToList();
+        }
+
+        private void DateTextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (Regex.IsMatch((((TextBox)sender).Text).ToString(), "[^0-9.]"))
+            {
+                ((TextBox)sender).Text = ((TextBox)sender).Text.Remove(((TextBox)sender).Text.Length - 1);
+                ((TextBox)sender).SelectionStart = ((TextBox)sender).Text.Length;
+            }
+        }
+
+        private void TimeTextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (Regex.IsMatch((((TextBox)sender).Text).ToString(), "[^0-9:]"))
+            {
+                ((TextBox)sender).Text = ((TextBox)sender).Text.Remove(((TextBox)sender).Text.Length - 1);
+                ((TextBox)sender).SelectionStart = ((TextBox)sender).Text.Length;
+            }
+        }
+
+        private void AddEmployeeClick(object sender, RoutedEventArgs e)
+        {
+            if (EmployeeBox.SelectedItem == null)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("не выбрано работник");
+                errorWindow.Show();
+                return;
+            }
+
+            Users employee = Connection.db.Users.Where(item => item.Login == EmployeeBox.SelectedItem.ToString()).FirstOrDefault();
+
+            EmployeeBox.SelectedItem = null;
+
+            EmployeeBox.ItemsSource = Connection.db.Users.Where(item => item.Login != employee.Login && item.IDRole != 1).Select(item => item.Login).ToList();
+
+            EmployeesList.Items.Add(employee);
+        }
+
+        private void SaveExchangeClick(object sender, RoutedEventArgs e)
+        {
+            if (EmployeesList.Items == null)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("не выбрано ни одного работника");
+                errorWindow.Show();
+                return;
+            }
+
+            if (Date.Text == "" || TimeOfBegin.Text == "" || TimeOfEnd.Text == "")
+            {
+                ErrorWindow errorWindow = new ErrorWindow("не выбрано время");
+                errorWindow.Show();
+                return;
+            }
+
+            TimeSpan timeOfBeginResult;
+            if (!TimeSpan.TryParse(TimeOfBegin.Text, out timeOfBeginResult) || TimeOfBegin.Text.Count(item => item == ':') != 1)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("неверно указано время начала");
+                errorWindow.Show();
+                return;
+            }
+
+            TimeSpan timeOfEndResult;
+            if (!TimeSpan.TryParse(TimeOfEnd.Text, out timeOfEndResult) || TimeOfEnd.Text.Count(item => item == ':') != 1)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("неверно указано время окончания");
+                errorWindow.Show();
+                return;
+            }
+
+            DateTime dateResult;
+            if (!DateTime.TryParse(Date.Text, out dateResult) || Date.Text.Count(item => item == '.') != 2)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("неверно указана дата");
+                errorWindow.Show();
+                return;
+            }
+
+            List<Exchange> allExchangesOnDate = Connection.db.Exchange.Where(item => item.Date == dateResult).ToList();
+
+            if (allExchangesOnDate.Exists(item => (item.TimeOfBegin <= timeOfBeginResult && item.TimeOfEnd >= timeOfBeginResult)
+                                                   || (item.TimeOfBegin <= timeOfEndResult && item.TimeOfEnd >= timeOfEndResult)))
+            {
+                ErrorWindow errorWindow = new ErrorWindow("на это время уже запланирована смена");
+                errorWindow.Show();
+                return;
+            }
+
+            if (dateResult.Date - DateTime.Now.Date > new TimeSpan(5, 0, 0, 0))
+            {
+                ErrorWindow errorWindow = new ErrorWindow("можно сформировать рассписание тольок на 5 дней вперёд");
+                errorWindow.Show();
+                return;
+            }
+
+            Exchange exchange = new Exchange()
+            {
+                Date = dateResult.Date,
+                TimeOfBegin = timeOfBeginResult,
+                TimeOfEnd = timeOfEndResult
+            };
+
+            Connection.db.Exchange.Add(exchange);
+            Connection.db.SaveChanges();
+
+            int idExchange = Connection.db.Exchange.Select(item => item.ID).ToList().Last();
+            foreach (var item in EmployeesList.Items)
+            {
+                EmployeesExchanges employeesExchanges = new EmployeesExchanges()
+                {
+                    IDEmployee = ((Users)item).ID,
+                    IDExchange = idExchange
+                };
+
+                Connection.db.EmployeesExchanges.Add(employeesExchanges);
+                Connection.db.SaveChanges();
+            }
+
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 37 - 0
Cafe2/AddWindows/AddOrderWindow.xaml

@@ -0,0 +1,37 @@
+<Window x:Class="Cafe.AddWindows.AddOrderWindow"
+        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:Cafe.AddWindows"
+        mc:Ignorable="d"
+        Title="Новый заказ" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <ListBox Name="DishesList" VerticalAlignment="Top" HorizontalAlignment="Center" Width="1500" Height="450"
+                 ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Auto" SelectionChanged="DishesListSelectionChanged" Margin="0,100,0,0" d:ItemsSource="{d:SampleData ItemCount=5}">
+            <ListBox.ItemsPanel>
+                <ItemsPanelTemplate>
+                    <VirtualizingStackPanel IsItemsHost="True" Orientation="Horizontal"/>
+                </ItemsPanelTemplate>
+            </ListBox.ItemsPanel>
+            <ListBox.ItemTemplate>
+                <DataTemplate>
+                    <StackPanel Name="DishStack">
+                        <Image Source="{Binding Picture}" Width="250" Height="250"/>
+                        <Label Content="{Binding Name}" Width="250" Foreground="White" FontSize="25" Height="50"/>
+                        <Label Content="{Binding Price}" Width="250" Foreground="White" FontSize="25" Height="50"/>
+                        <Button Content="Убрать" Width="250" FontSize="25" Height="50" Click="DeliteDishClick"/>
+                    </StackPanel>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        <Button x:Name="BackButton" Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+        <Label Content="Сумма:" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="36" Height="60" Margin="1225,685,0,0"/>
+        <Label Name="SumOfOrder" Content="0" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="36" Height="60" Margin="1352,685,0,0" Width="200"/>
+        <Button Name="AddDish" Content="Добавить блюдо" HorizontalAlignment="Left" VerticalAlignment="Top" Height="60" Width="300" FontSize="36" Click="AddDishClick" Margin="53,687,0,0"/>
+        <Button Name="ToOrder" Content="Сделать заказ" HorizontalAlignment="Center" VerticalAlignment="Top" Height="60" Width="250" FontSize="36" Click="ToOrderClick" Margin="0,792,0,0"/>
+        <ComboBox x:Name="DishesBox" Height="60" Width="450" HorizontalAlignment="Left" Margin="400,687,0,0" VerticalAlignment="Top" Foreground="Black" FontSize="36"/>
+        <ComboBox x:Name="TablesBox" Height="60" Width="450" HorizontalAlignment="Left" Margin="400,589,0,0" VerticalAlignment="Top" Foreground="Black" FontSize="36"/>
+        <Label Content="Столик:" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="36" Height="60" Margin="266,589,0,0"/>
+    </Grid>
+</Window>

+ 119 - 0
Cafe2/AddWindows/AddOrderWindow.xaml.cs

@@ -0,0 +1,119 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using Cafe.ElementsWindows;
+
+namespace Cafe.AddWindows
+{
+    public partial class AddOrderWindow : Window
+    {
+        public AddOrderWindow()
+        {
+            InitializeComponent();
+            DishesBox.ItemsSource = Connection.db.Dishes.Select(item => item.Name).ToList();
+            TablesBox.ItemsSource = Connection.db.Tables.Select(item => item.ID).ToList();
+        }
+
+        private void DeliteDishClick(object sender, RoutedEventArgs e)
+        {
+            DishesList.Items.Remove((Dishes)DishesList.SelectedItem);
+        }
+
+        private void DishesListSelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            int idDish = Connection.db.Dishes.Where(item => item.ID == ((Dishes)DishesList.SelectedItem).ID).Select(item => item.ID).FirstOrDefault();
+            DishWindow dishWindow = new DishWindow(idDish);
+            dishWindow.Show();
+            this.Close();
+        }
+
+        private void AddDishClick(object sender, RoutedEventArgs e)
+        {
+            if (DishesBox.SelectedItem == null)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("не выбрано блюдо");
+                errorWindow.Show();
+                return;
+            }
+
+            Dishes dish = Connection.db.Dishes.Where(item => item.Name == DishesBox.SelectedItem.ToString()).FirstOrDefault();
+            DishesList.Items.Add(dish);
+
+            SumOfOrder.Content = Convert.ToString(Convert.ToDecimal(SumOfOrder.Content) + dish.Price);
+        }
+
+        private void ToOrderClick(object sender, RoutedEventArgs e)
+        {
+            if (DishesList.Items == null)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("не выбрано ни одного блюда");
+                errorWindow.Show();
+                return;
+            }
+
+            if (TablesBox.SelectedItem == null)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("не выбран столик");
+                errorWindow.Show();
+                return;
+            }
+
+            Exchange exchange = GetExchange();
+
+            if (exchange is null)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("сейчас нет смены");
+                errorWindow.Show();
+                return;
+            }
+
+            int idTable = Convert.ToInt32(TablesBox.SelectedItem.ToString());
+
+            Orders order = new Orders()
+            {
+                IDEmployeeExchange = Connection.db.EmployeesExchanges.Where(item => item.IDExchange == exchange.ID && item.IDEmployee == User.IDUser).Select(item => item.ID).FirstOrDefault(),
+                IDTable = Connection.db.Tables.Where(item => item.ID == idTable).Select(item => item.ID).FirstOrDefault(),
+                Time = DateTime.Now,
+                SumOfOrder = Convert.ToDecimal(SumOfOrder.Content),
+                IsPaid = false,
+                IsReady = false
+            };
+
+            Connection.db.Orders.Add(order);
+            Connection.db.SaveChanges();
+
+            int idOrder = Connection.db.Orders.Select(item => item.ID).ToList().Last();
+            foreach (var item in DishesList.Items)
+            {
+                OrderDishes orderDishes = new OrderDishes()
+                {
+                    IDOrder = idOrder,
+                    IDDish = ((Dishes)item).ID
+                };
+
+                Connection.db.OrderDishes.Add(orderDishes);
+                Connection.db.SaveChanges();
+            }
+
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+
+        private Exchange GetExchange()
+        {
+            DateTime now = DateTime.Now;
+
+            return Connection.db.Exchange.Where(item => item.Date == now.Date && item.TimeOfBegin <= now.TimeOfDay && item.TimeOfEnd >= now.TimeOfDay).FirstOrDefault();
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 23 - 0
Cafe2/App.config

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <configSections>
+    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+  </configSections>
+  <startup>
+    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
+  </startup>
+  <connectionStrings>
+    <add name="CafeEntities" connectionString="metadata=res://*/Cafe.csdl|res://*/Cafe.ssdl|res://*/Cafe.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DESKTOP-5285QDG;initial catalog=Cafe;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
+  </connectionStrings>
+  <entityFramework>
+    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
+      <parameters>
+        <parameter value="mssqllocaldb" />
+      </parameters>
+    </defaultConnectionFactory>
+    <providers>
+      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+    </providers>
+  </entityFramework>
+</configuration>

+ 9 - 0
Cafe2/App.xaml

@@ -0,0 +1,9 @@
+<Application x:Class="Cafe.App"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:local="clr-namespace:Cafe"
+             StartupUri="AuthorizationWindow.xaml">
+    <Application.Resources>
+        <ResourceDictionary Source="Style.xaml"/>
+    </Application.Resources>
+</Application>

+ 17 - 0
Cafe2/App.xaml.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace Cafe
+{
+    /// <summary>
+    /// Логика взаимодействия для App.xaml
+    /// </summary>
+    public partial class App : Application
+    {
+    }
+}

+ 16 - 0
Cafe2/AuthorizationWindow.xaml

@@ -0,0 +1,16 @@
+<Window x:Class="Cafe.AuthorizationWindow"
+        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:Cafe"
+        mc:Ignorable="d"
+        Title="Авторизация" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Label Name="LoginLab"  Content="Логин:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="388,329,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <TextBox Name="Login" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="567,329,0,0" Height="60" Width="550" Background="White" FontSize="36"/>
+        <Label Content="Пароль:" VerticalAlignment="Top" HorizontalAlignment="Left" Foreground="White" Margin="388,411,0,0" Height="60" Width="180" FontSize="36"/>
+        <PasswordBox Name="Password" VerticalAlignment="Top" HorizontalAlignment="Left" Height="60" Width="550" Margin="567,411,0,0" FontSize="36"/>
+        <Button Name="AuthorizeButton" Content="Войти" VerticalAlignment="Top" HorizontalAlignment="Center" Height="60" Width="360" Margin="0,746,0,0" Click="AuthorizationClick" FontSize="36"/>
+    </Grid>
+</Window>

+ 62 - 0
Cafe2/AuthorizationWindow.xaml.cs

@@ -0,0 +1,62 @@
+using System.Linq;
+using System.Windows;
+using Cafe.ListWindows;
+
+namespace Cafe
+{
+    public partial class AuthorizationWindow : Window
+    {
+        public AuthorizationWindow()
+        {
+            InitializeComponent();
+        }
+
+        private void AuthorizationClick(object sender, RoutedEventArgs e)
+        {
+            if (Authorization(Login.Text.ToString(), Password.Password.ToString()))
+            {
+                if (User.Role == 3)
+                {
+                    OrdersListWindow ordersListWindow = new OrdersListWindow();
+                    ordersListWindow.Show();
+                }
+                else
+                {
+                    MainWindow mainWindow = new MainWindow();
+                    mainWindow.Show();
+                }
+                this.Close();
+            }
+        }
+
+        public bool Authorization(string login, string password)
+        {
+            if (Login.Text == "" || Password.Password == "")
+            {
+                ErrorWindow errorWindow = new ErrorWindow("пустые поля");
+                errorWindow.Show();
+                return false;
+            }
+            if (Connection.db.Users.Select(item => item.Login + " " + item.Password).Contains(Login.Text + " " + Encrypt.Hash(Password.Password)))
+            {
+                if (Connection.db.Users.Where(users => users.Login == Login.Text).Select(users => users.IsFired).FirstOrDefault())
+                {
+                    ErrorWindow errorWindow = new ErrorWindow("сотрудник уволен");
+                    return false;
+                }
+
+                int userID = Connection.db.Users.Where(users => users.Login == Login.Text).Select(users => users.ID).FirstOrDefault();
+                int Role = Connection.db.Users.Where(users => users.ID == userID).Select(users => users.IDRole).FirstOrDefault();
+                User.Role = Role;
+                User.IDUser = userID;
+                return true;
+            }
+            else
+            {
+                ErrorWindow errorWindow = new ErrorWindow("неверный логин/пароль");
+                errorWindow.Show();
+                return false;
+            }
+        }
+    }
+}

+ 38 - 0
Cafe2/Cafe.Context.cs

@@ -0,0 +1,38 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Data.Entity;
+    using System.Data.Entity.Infrastructure;
+    
+    public partial class CafeEntities : DbContext
+    {
+        public CafeEntities()
+            : base("name=CafeEntities")
+        {
+        }
+    
+        protected override void OnModelCreating(DbModelBuilder modelBuilder)
+        {
+            throw new UnintentionalCodeFirstException();
+        }
+    
+        public virtual DbSet<Dishes> Dishes { get; set; }
+        public virtual DbSet<EmployeesExchanges> EmployeesExchanges { get; set; }
+        public virtual DbSet<Exchange> Exchange { get; set; }
+        public virtual DbSet<OrderDishes> OrderDishes { get; set; }
+        public virtual DbSet<Orders> Orders { get; set; }
+        public virtual DbSet<Roles> Roles { get; set; }
+        public virtual DbSet<sysdiagrams> sysdiagrams { get; set; }
+        public virtual DbSet<Tables> Tables { get; set; }
+        public virtual DbSet<Users> Users { get; set; }
+    }
+}

+ 636 - 0
Cafe2/Cafe.Context.tt

@@ -0,0 +1,636 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF6.Utility.CS.ttinclude"#><#@
+ output extension=".cs"#><#
+
+const string inputFile = @"Cafe.edmx";
+var textTransform = DynamicTextTransformation.Create(this);
+var code = new CodeGenerationTools(this);
+var ef = new MetadataTools(this);
+var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
+var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
+var itemCollection = loader.CreateEdmItemCollection(inputFile);
+var modelNamespace = loader.GetModelNamespace(inputFile);
+var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
+
+var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
+if (container == null)
+{
+    return string.Empty;
+}
+#>
+//------------------------------------------------------------------------------
+// <auto-generated>
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
+//
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+<#
+
+var codeNamespace = code.VsNamespaceSuggestion();
+if (!String.IsNullOrEmpty(codeNamespace))
+{
+#>
+namespace <#=code.EscapeNamespace(codeNamespace)#>
+{
+<#
+    PushIndent("    ");
+}
+
+#>
+using System;
+using System.Data.Entity;
+using System.Data.Entity.Infrastructure;
+<#
+if (container.FunctionImports.Any())
+{
+#>
+using System.Data.Entity.Core.Objects;
+using System.Linq;
+<#
+}
+#>
+
+<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
+{
+    public <#=code.Escape(container)#>()
+        : base("name=<#=container.Name#>")
+    {
+<#
+if (!loader.IsLazyLoadingEnabled(container))
+{
+#>
+        this.Configuration.LazyLoadingEnabled = false;
+<#
+}
+
+foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
+{
+    // Note: the DbSet members are defined below such that the getter and
+    // setter always have the same accessibility as the DbSet definition
+    if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
+    {
+#>
+        <#=codeStringGenerator.DbSetInitializer(entitySet)#>
+<#
+    }
+}
+#>
+    }
+
+    protected override void OnModelCreating(DbModelBuilder modelBuilder)
+    {
+        throw new UnintentionalCodeFirstException();
+    }
+
+<#
+    foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
+    {
+#>
+    <#=codeStringGenerator.DbSet(entitySet)#>
+<#
+    }
+
+    foreach (var edmFunction in container.FunctionImports)
+    {
+        WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
+    }
+#>
+}
+<#
+
+if (!String.IsNullOrEmpty(codeNamespace))
+{
+    PopIndent();
+#>
+}
+<#
+}
+#>
+<#+
+
+private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+{
+    if (typeMapper.IsComposable(edmFunction))
+    {
+#>
+
+    [DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
+    <#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
+    {
+<#+
+        codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
+#>
+        <#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
+    }
+<#+
+    }
+    else
+    {
+#>
+
+    <#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
+    {
+<#+
+        codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
+#>
+        <#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
+    }
+<#+
+        if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
+        {
+            WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
+        }
+    }
+}
+
+public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
+{
+#>
+        var <#=name#> = <#=isNotNull#> ?
+            <#=notNullInit#> :
+            <#=nullInit#>;
+
+<#+
+}
+
+public const string TemplateId = "CSharp_DbContext_Context_EF6";
+
+public class CodeStringGenerator
+{
+    private readonly CodeGenerationTools _code;
+    private readonly TypeMapper _typeMapper;
+    private readonly MetadataTools _ef;
+
+    public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
+    {
+        ArgumentNotNull(code, "code");
+        ArgumentNotNull(typeMapper, "typeMapper");
+        ArgumentNotNull(ef, "ef");
+
+        _code = code;
+        _typeMapper = typeMapper;
+        _ef = ef;
+    }
+
+    public string Property(EdmProperty edmProperty)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2} {{ {3}get; {4}set; }}",
+            Accessibility.ForProperty(edmProperty),
+            _typeMapper.GetTypeName(edmProperty.TypeUsage),
+            _code.Escape(edmProperty),
+            _code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
+            _code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
+    }
+
+    public string NavigationProperty(NavigationProperty navProp)
+    {
+        var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2} {{ {3}get; {4}set; }}",
+            AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
+            navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
+            _code.Escape(navProp),
+            _code.SpaceAfter(Accessibility.ForGetter(navProp)),
+            _code.SpaceAfter(Accessibility.ForSetter(navProp)));
+    }
+    
+    public string AccessibilityAndVirtual(string accessibility)
+    {
+        return accessibility + (accessibility != "private" ? " virtual" : "");
+    }
+    
+    public string EntityClassOpening(EntityType entity)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1}partial class {2}{3}",
+            Accessibility.ForType(entity),
+            _code.SpaceAfter(_code.AbstractOption(entity)),
+            _code.Escape(entity),
+            _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
+    }
+    
+    public string EnumOpening(SimpleType enumType)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} enum {1} : {2}",
+            Accessibility.ForType(enumType),
+            _code.Escape(enumType),
+            _code.Escape(_typeMapper.UnderlyingClrType(enumType)));
+        }
+    
+    public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
+    {
+        var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+        foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
+        {
+            var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
+            var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
+            var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
+            writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
+        }
+    }
+    
+    public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} IQueryable<{1}> {2}({3})",
+            AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+            _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+            _code.Escape(edmFunction),
+            string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
+    }
+    
+    public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
+            _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+            edmFunction.NamespaceName,
+            edmFunction.Name,
+            string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
+            _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
+    }
+    
+    public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        var returnType = _typeMapper.GetReturnType(edmFunction);
+
+        var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
+        if (includeMergeOption)
+        {
+            paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
+        }
+
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2}({3})",
+            AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+            returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+            _code.Escape(edmFunction),
+            paramList);
+    }
+    
+    public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        var returnType = _typeMapper.GetReturnType(edmFunction);
+
+        var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
+        if (includeMergeOption)
+        {
+            callParams = ", mergeOption" + callParams;
+        }
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
+            returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+            edmFunction.Name,
+            callParams);
+    }
+    
+    public string DbSet(EntitySet entitySet)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} virtual DbSet<{1}> {2} {{ get; set; }}",
+            Accessibility.ForReadOnlyProperty(entitySet),
+            _typeMapper.GetTypeName(entitySet.ElementType),
+            _code.Escape(entitySet));
+    }
+
+    public string DbSetInitializer(EntitySet entitySet)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} = Set<{1}>();",
+            _code.Escape(entitySet),
+            _typeMapper.GetTypeName(entitySet.ElementType));
+    }
+
+    public string UsingDirectives(bool inHeader, bool includeCollections = true)
+    {
+        return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
+            ? string.Format(
+                CultureInfo.InvariantCulture,
+                "{0}using System;{1}" +
+                "{2}",
+                inHeader ? Environment.NewLine : "",
+                includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
+                inHeader ? "" : Environment.NewLine)
+            : "";
+    }
+}
+
+public class TypeMapper
+{
+    private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
+
+    private readonly System.Collections.IList _errors;
+    private readonly CodeGenerationTools _code;
+    private readonly MetadataTools _ef;
+
+    public static string FixNamespaces(string typeName)
+    {
+        return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
+    }
+
+    public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
+    {
+        ArgumentNotNull(code, "code");
+        ArgumentNotNull(ef, "ef");
+        ArgumentNotNull(errors, "errors");
+
+        _code = code;
+        _ef = ef;
+        _errors = errors;
+    }
+
+    public string GetTypeName(TypeUsage typeUsage)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
+    }
+
+    public string GetTypeName(EdmType edmType)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: null);
+    }
+
+    public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, string modelNamespace)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
+    {
+        if (edmType == null)
+        {
+            return null;
+        }
+
+        var collectionType = edmType as CollectionType;
+        if (collectionType != null)
+        {
+            return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
+        }
+
+        var typeName = _code.Escape(edmType.MetadataProperties
+                                .Where(p => p.Name == ExternalTypeNameAttributeName)
+                                .Select(p => (string)p.Value)
+                                .FirstOrDefault())
+            ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
+                _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
+                _code.Escape(edmType));
+
+        if (edmType is StructuralType)
+        {
+            return typeName;
+        }
+
+        if (edmType is SimpleType)
+        {
+            var clrType = UnderlyingClrType(edmType);
+            if (!IsEnumType(edmType))
+            {
+                typeName = _code.Escape(clrType);
+            }
+
+            typeName = FixNamespaces(typeName);
+
+            return clrType.IsValueType && isNullable == true ?
+                String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
+                typeName;
+        }
+
+        throw new ArgumentException("edmType");
+    }
+    
+    public Type UnderlyingClrType(EdmType edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        var primitiveType = edmType as PrimitiveType;
+        if (primitiveType != null)
+        {
+            return primitiveType.ClrEquivalentType;
+        }
+
+        if (IsEnumType(edmType))
+        {
+            return GetEnumUnderlyingType(edmType).ClrEquivalentType;
+        }
+
+        return typeof(object);
+    }
+    
+    public object GetEnumMemberValue(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var valueProperty = enumMember.GetType().GetProperty("Value");
+        return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
+    }
+    
+    public string GetEnumMemberName(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var nameProperty = enumMember.GetType().GetProperty("Name");
+        return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
+    }
+
+    public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        var membersProperty = enumType.GetType().GetProperty("Members");
+        return membersProperty != null 
+            ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
+            : Enumerable.Empty<MetadataItem>();
+    }
+    
+    public bool EnumIsFlags(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+        
+        var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
+        return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
+    }
+
+    public bool IsEnumType(GlobalItem edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        return edmType.GetType().Name == "EnumType";
+    }
+
+    public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
+    }
+
+    public string CreateLiteral(object value)
+    {
+        if (value == null || value.GetType() != typeof(TimeSpan))
+        {
+            return _code.CreateLiteral(value);
+        }
+
+        return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
+    }
+    
+    public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
+    {
+        ArgumentNotNull(types, "types");
+        ArgumentNotNull(sourceFile, "sourceFile");
+        
+        var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
+        if (types.Any(item => !hash.Add(item)))
+        {
+            _errors.Add(
+                new CompilerError(sourceFile, -1, -1, "6023",
+                    String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
+            return false;
+        }
+        return true;
+    }
+    
+    public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
+    {
+        return GetItemsToGenerate<SimpleType>(itemCollection)
+            .Where(e => IsEnumType(e));
+    }
+    
+    public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
+    {
+        return itemCollection
+            .OfType<T>()
+            .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
+            .OrderBy(i => i.Name);
+    }
+
+    public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
+    {
+        return itemCollection
+            .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
+            .Select(g => GetGlobalItemName(g));
+    }
+
+    public string GetGlobalItemName(GlobalItem item)
+    {
+        if (item is EdmType)
+        {
+            return ((EdmType)item).Name;
+        }
+        else
+        {
+            return ((EntityContainer)item).Name;
+        }
+    }
+
+    public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+    
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+
+    public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type);
+    }
+    
+    public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
+    }
+    
+    public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
+        return returnParamsProperty == null
+            ? edmFunction.ReturnParameter
+            : ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
+    }
+
+    public bool IsComposable(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
+        return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
+    }
+
+    public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
+    {
+        return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+    }
+
+    public TypeUsage GetReturnType(EdmFunction edmFunction)
+    {
+        var returnParam = GetReturnParameter(edmFunction);
+        return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
+    }
+    
+    public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
+    {
+        var returnType = GetReturnType(edmFunction);
+        return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
+    }
+}
+
+public static void ArgumentNotNull<T>(T arg, string name) where T : class
+{
+    if (arg == null)
+    {
+        throw new ArgumentNullException(name);
+    }
+}
+#>

+ 10 - 0
Cafe2/Cafe.Designer.cs

@@ -0,0 +1,10 @@
+// Создание кода T4 для модели "C:\Users\79609\source\repos\Cafe\Cafe2\Cafe.edmx" включено. 
+// Чтобы включить формирование кода прежних версий, измените значение свойства "Стратегия создания кода" конструктора
+// на "Legacy ObjectContext". Это свойство доступно в окне "Свойства", если модель
+// открыта в конструкторе.
+
+// Если не сформированы контекст и классы сущности, возможная причина в том, что вы создали пустую модель, но
+// еще не выбрали версию Entity Framework для использования. Чтобы сформировать класс контекста и классы сущностей
+// для своей модели, откройте модель в конструкторе, щелкните правой кнопкой область конструктора и
+// выберите "Обновить модель из базы данных", "Сформировать базу данных из модели" или "Добавить элемент формирования
+// кода...".

+ 9 - 0
Cafe2/Cafe.cs

@@ -0,0 +1,9 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+

+ 271 - 0
Cafe2/Cafe.csproj

@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{3C1FDBA5-FF5C-4343-8D21-DC14A25D653C}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>Cafe2</RootNamespace>
+    <AssemblyName>Cafe2</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <WarningLevel>4</WarningLevel>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Runtime.Serialization" />
+    <Reference Include="System.Security" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xaml">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="WindowsBase" />
+    <Reference Include="PresentationCore" />
+    <Reference Include="PresentationFramework" />
+  </ItemGroup>
+  <ItemGroup>
+    <ApplicationDefinition Include="App.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </ApplicationDefinition>
+    <Compile Include="AddWindows\AddDishWindow.xaml.cs">
+      <DependentUpon>AddDishWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Cafe.Context.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Cafe.Context.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Cafe.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Cafe.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Cafe.edmx</DependentUpon>
+    </Compile>
+    <Compile Include="Dishes.cs">
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Compile Include="ElementsWindows\DishWindow.xaml.cs">
+      <DependentUpon>DishWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="EmployeesExchanges.cs">
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Exchange.cs">
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Compile Include="ImagesManip.cs" />
+    <Compile Include="OrderDishes.cs">
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Orders.cs">
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Roles.cs">
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Compile Include="sysdiagrams.cs">
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Compile Include="Tables.cs">
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Compile Include="User.cs" />
+    <Compile Include="Users.cs">
+      <DependentUpon>Cafe.tt</DependentUpon>
+    </Compile>
+    <Page Include="AddWindows\AddDishWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="AddWindows\AddEmployeeWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="AddWindows\AddExchangeWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="AddWindows\AddOrderWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="AuthorizationWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="ElementsWindows\DishWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="ElementsWindows\EmployeeWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="ElementsWindows\ExchangeWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="ElementsWindows\OrderWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="ErrorWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="ListWindows\EmployeesListWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="ListWindows\ExchangesListWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="ListWindows\OrdersListWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="MainWindow.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
+    <Compile Include="AddWindows\AddEmployeeWindow.xaml.cs">
+      <DependentUpon>AddEmployeeWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="AddWindows\AddExchangeWindow.xaml.cs">
+      <DependentUpon>AddExchangeWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="AddWindows\AddOrderWindow.xaml.cs">
+      <DependentUpon>AddOrderWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="App.xaml.cs">
+      <DependentUpon>App.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="AuthorizationWindow.xaml.cs">
+      <DependentUpon>AuthorizationWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Connection.cs" />
+    <Compile Include="ElementsWindows\EmployeeWindow.xaml.cs">
+      <DependentUpon>EmployeeWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="ElementsWindows\ExchangeWindow.xaml.cs">
+      <DependentUpon>ExchangeWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="ElementsWindows\OrderWindow.xaml.cs">
+      <DependentUpon>OrderWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Encrypt.cs" />
+    <Compile Include="ErrorWindow.xaml.cs">
+      <DependentUpon>ErrorWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="ListWindows\EmployeesListWindow.xaml.cs">
+      <DependentUpon>EmployeesListWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="ListWindows\ExchangesListWindow.xaml.cs">
+      <DependentUpon>ExchangesListWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="ListWindows\OrdersListWindow.xaml.cs">
+      <DependentUpon>OrdersListWindow.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="MainWindow.xaml.cs">
+      <DependentUpon>MainWindow.xaml</DependentUpon>
+      <SubType>Code</SubType>
+    </Compile>
+    <Page Include="Style.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs">
+      <SubType>Code</SubType>
+    </Compile>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DesignTime>True</DesignTime>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+    <EntityDeploy Include="Cafe.edmx">
+      <Generator>EntityModelCodeGenerator</Generator>
+      <LastGenOutput>Cafe.Designer.cs</LastGenOutput>
+    </EntityDeploy>
+    <None Include="Cafe.edmx.diagram">
+      <DependentUpon>Cafe.edmx</DependentUpon>
+    </None>
+    <None Include="packages.config" />
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="Cafe.Context.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <DependentUpon>Cafe.edmx</DependentUpon>
+      <LastGenOutput>Cafe.Context.cs</LastGenOutput>
+    </Content>
+    <Content Include="Cafe.tt">
+      <Generator>TextTemplatingFileGenerator</Generator>
+      <DependentUpon>Cafe.edmx</DependentUpon>
+      <LastGenOutput>Cafe.cs</LastGenOutput>
+    </Content>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 563 - 0
Cafe2/Cafe.edmx

@@ -0,0 +1,563 @@
+<?xml version="1.0" encoding="utf-8"?>
+<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
+  <!-- EF Runtime content -->
+  <edmx:Runtime>
+    <!-- SSDL content -->
+    <edmx:StorageModels>
+      <Schema Namespace="Хранилище CafeModel" 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="Dishes">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="Name" Type="nvarchar" MaxLength="200" Nullable="false" />
+          <Property Name="Description" Type="nvarchar(max)" />
+          <Property Name="Price" Type="money" Nullable="false" />
+          <Property Name="Picture" Type="image" />
+        </EntityType>
+        <EntityType Name="EmployeesExchanges">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="IDEmployee" Type="int" Nullable="false" />
+          <Property Name="IDExchange" Type="int" Nullable="false" />
+        </EntityType>
+        <EntityType Name="Exchange">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="Date" Type="date" Nullable="false" />
+          <Property Name="TimeOfBegin" Type="time" Precision="7" Nullable="false" />
+          <Property Name="TimeOfEnd" Type="time" Precision="7" Nullable="false" />
+        </EntityType>
+        <EntityType Name="OrderDishes">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="IDOrder" Type="int" Nullable="false" />
+          <Property Name="IDDish" Type="int" Nullable="false" />
+        </EntityType>
+        <EntityType Name="Orders">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="IDEmployeeExchange" Type="int" Nullable="false" />
+          <Property Name="IDTable" Type="int" Nullable="false" />
+          <Property Name="Time" Type="datetime" Nullable="false" />
+          <Property Name="SumOfOrder" Type="money" Nullable="false" />
+          <Property Name="IsPaid" Type="bit" Nullable="false" />
+          <Property Name="IsReady" Type="bit" Nullable="false" />
+        </EntityType>
+        <EntityType Name="Roles">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="RoleName" Type="nvarchar" MaxLength="50" Nullable="false" />
+        </EntityType>
+        <EntityType Name="sysdiagrams">
+          <Key>
+            <PropertyRef Name="diagram_id" />
+          </Key>
+          <Property Name="name" Type="nvarchar" MaxLength="128" Nullable="false" />
+          <Property Name="principal_id" Type="int" Nullable="false" />
+          <Property Name="diagram_id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="version" Type="int" />
+          <Property Name="definition" Type="varbinary(max)" />
+        </EntityType>
+        <EntityType Name="Tables">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="int" Nullable="false" />
+        </EntityType>
+        <EntityType Name="Users">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="Login" Type="varchar" MaxLength="50" Nullable="false" />
+          <Property Name="Password" Type="varchar" MaxLength="50" Nullable="false" />
+          <Property Name="SecondName" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="FirstName" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="MiddleName" Type="nvarchar" MaxLength="50" />
+          <Property Name="Email" Type="varchar" MaxLength="50" Nullable="false" />
+          <Property Name="IsFired" Type="bit" Nullable="false" />
+          <Property Name="IDRole" Type="int" Nullable="false" />
+        </EntityType>
+        <Association Name="FK_EmployeesExchanges_Exchange">
+          <End Role="Exchange" Type="Self.Exchange" Multiplicity="1" />
+          <End Role="EmployeesExchanges" Type="Self.EmployeesExchanges" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Exchange">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="EmployeesExchanges">
+              <PropertyRef Name="IDExchange" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_EmployeesExchanges_Users">
+          <End Role="Users" Type="Self.Users" Multiplicity="1" />
+          <End Role="EmployeesExchanges" Type="Self.EmployeesExchanges" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Users">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="EmployeesExchanges">
+              <PropertyRef Name="IDEmployee" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_OrderDishes_Dishes">
+          <End Role="Dishes" Type="Self.Dishes" Multiplicity="1" />
+          <End Role="OrderDishes" Type="Self.OrderDishes" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Dishes">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="OrderDishes">
+              <PropertyRef Name="IDDish" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_OrderDishes_Orders">
+          <End Role="Orders" Type="Self.Orders" Multiplicity="1" />
+          <End Role="OrderDishes" Type="Self.OrderDishes" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Orders">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="OrderDishes">
+              <PropertyRef Name="IDOrder" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_Orders_EmployeesExchanges">
+          <End Role="EmployeesExchanges" Type="Self.EmployeesExchanges" Multiplicity="1" />
+          <End Role="Orders" Type="Self.Orders" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="EmployeesExchanges">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="Orders">
+              <PropertyRef Name="IDEmployeeExchange" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_Orders_Tables">
+          <End Role="Tables" Type="Self.Tables" Multiplicity="1" />
+          <End Role="Orders" Type="Self.Orders" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Tables">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="Orders">
+              <PropertyRef Name="IDTable" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_Users_Roles">
+          <End Role="Roles" Type="Self.Roles" Multiplicity="1" />
+          <End Role="Users" Type="Self.Users" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Roles">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="Users">
+              <PropertyRef Name="IDRole" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <EntityContainer Name="Хранилище CafeModelContainer">
+          <EntitySet Name="Dishes" EntityType="Self.Dishes" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="EmployeesExchanges" EntityType="Self.EmployeesExchanges" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="Exchange" EntityType="Self.Exchange" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="OrderDishes" EntityType="Self.OrderDishes" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="Orders" EntityType="Self.Orders" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="Roles" EntityType="Self.Roles" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="sysdiagrams" EntityType="Self.sysdiagrams" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="Tables" EntityType="Self.Tables" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
+          <AssociationSet Name="FK_EmployeesExchanges_Exchange" Association="Self.FK_EmployeesExchanges_Exchange">
+            <End Role="Exchange" EntitySet="Exchange" />
+            <End Role="EmployeesExchanges" EntitySet="EmployeesExchanges" />
+          </AssociationSet>
+          <AssociationSet Name="FK_EmployeesExchanges_Users" Association="Self.FK_EmployeesExchanges_Users">
+            <End Role="Users" EntitySet="Users" />
+            <End Role="EmployeesExchanges" EntitySet="EmployeesExchanges" />
+          </AssociationSet>
+          <AssociationSet Name="FK_OrderDishes_Dishes" Association="Self.FK_OrderDishes_Dishes">
+            <End Role="Dishes" EntitySet="Dishes" />
+            <End Role="OrderDishes" EntitySet="OrderDishes" />
+          </AssociationSet>
+          <AssociationSet Name="FK_OrderDishes_Orders" Association="Self.FK_OrderDishes_Orders">
+            <End Role="Orders" EntitySet="Orders" />
+            <End Role="OrderDishes" EntitySet="OrderDishes" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Orders_EmployeesExchanges" Association="Self.FK_Orders_EmployeesExchanges">
+            <End Role="EmployeesExchanges" EntitySet="EmployeesExchanges" />
+            <End Role="Orders" EntitySet="Orders" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Orders_Tables" Association="Self.FK_Orders_Tables">
+            <End Role="Tables" EntitySet="Tables" />
+            <End Role="Orders" EntitySet="Orders" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Users_Roles" Association="Self.FK_Users_Roles">
+            <End Role="Roles" EntitySet="Roles" />
+            <End Role="Users" EntitySet="Users" />
+          </AssociationSet>
+        </EntityContainer>
+      </Schema>
+    </edmx:StorageModels>
+    <!-- CSDL content -->
+    <edmx:ConceptualModels>
+      <Schema Namespace="CafeModel" 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">
+        <EntityType Name="Dishes">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="Name" Type="String" MaxLength="200" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Description" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
+          <Property Name="Price" Type="Decimal" Precision="19" Scale="4" Nullable="false" />
+          <Property Name="Picture" Type="Binary" MaxLength="Max" FixedLength="false" />
+          <NavigationProperty Name="OrderDishes" Relationship="Self.FK_OrderDishes_Dishes" FromRole="Dishes" ToRole="OrderDishes" />
+        </EntityType>
+        <EntityType Name="EmployeesExchanges">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="IDEmployee" Type="Int32" Nullable="false" />
+          <Property Name="IDExchange" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="Exchange" Relationship="Self.FK_EmployeesExchanges_Exchange" FromRole="EmployeesExchanges" ToRole="Exchange" />
+          <NavigationProperty Name="Users" Relationship="Self.FK_EmployeesExchanges_Users" FromRole="EmployeesExchanges" ToRole="Users" />
+          <NavigationProperty Name="Orders" Relationship="Self.FK_Orders_EmployeesExchanges" FromRole="EmployeesExchanges" ToRole="Orders" />
+        </EntityType>
+        <EntityType Name="Exchange">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="Date" Type="DateTime" Nullable="false" Precision="0" />
+          <Property Name="TimeOfBegin" Type="Time" Nullable="false" Precision="7" />
+          <Property Name="TimeOfEnd" Type="Time" Nullable="false" Precision="7" />
+          <NavigationProperty Name="EmployeesExchanges" Relationship="Self.FK_EmployeesExchanges_Exchange" FromRole="Exchange" ToRole="EmployeesExchanges" />
+        </EntityType>
+        <EntityType Name="OrderDishes">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="IDOrder" Type="Int32" Nullable="false" />
+          <Property Name="IDDish" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="Dishes" Relationship="Self.FK_OrderDishes_Dishes" FromRole="OrderDishes" ToRole="Dishes" />
+          <NavigationProperty Name="Orders" Relationship="Self.FK_OrderDishes_Orders" FromRole="OrderDishes" ToRole="Orders" />
+        </EntityType>
+        <EntityType Name="Orders">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="IDEmployeeExchange" Type="Int32" Nullable="false" />
+          <Property Name="IDTable" Type="Int32" Nullable="false" />
+          <Property Name="Time" Type="DateTime" Nullable="false" Precision="3" />
+          <Property Name="SumOfOrder" Type="Decimal" Precision="19" Scale="4" Nullable="false" />
+          <Property Name="IsPaid" Type="Boolean" Nullable="false" />
+          <Property Name="IsReady" Type="Boolean" Nullable="false" />
+          <NavigationProperty Name="EmployeesExchanges" Relationship="Self.FK_Orders_EmployeesExchanges" FromRole="Orders" ToRole="EmployeesExchanges" />
+          <NavigationProperty Name="OrderDishes" Relationship="Self.FK_OrderDishes_Orders" FromRole="Orders" ToRole="OrderDishes" />
+          <NavigationProperty Name="Tables" Relationship="Self.FK_Orders_Tables" FromRole="Orders" ToRole="Tables" />
+        </EntityType>
+        <EntityType Name="Roles">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="RoleName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <NavigationProperty Name="Users" Relationship="Self.FK_Users_Roles" FromRole="Roles" ToRole="Users" />
+        </EntityType>
+        <EntityType Name="sysdiagrams">
+          <Key>
+            <PropertyRef Name="diagram_id" />
+          </Key>
+          <Property Name="name" Type="String" MaxLength="128" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="principal_id" Type="Int32" Nullable="false" />
+          <Property Name="diagram_id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="version" Type="Int32" />
+          <Property Name="definition" Type="Binary" MaxLength="Max" FixedLength="false" />
+        </EntityType>
+        <EntityType Name="Tables">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="Orders" Relationship="Self.FK_Orders_Tables" FromRole="Tables" ToRole="Orders" />
+        </EntityType>
+        <EntityType Name="Users">
+          <Key>
+            <PropertyRef Name="ID" />
+          </Key>
+          <Property Name="ID" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="Login" Type="String" MaxLength="50" FixedLength="false" Unicode="false" Nullable="false" />
+          <Property Name="Password" Type="String" MaxLength="50" FixedLength="false" Unicode="false" Nullable="false" />
+          <Property Name="SecondName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="FirstName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="MiddleName" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="Email" Type="String" MaxLength="50" FixedLength="false" Unicode="false" Nullable="false" />
+          <Property Name="IsFired" Type="Boolean" Nullable="false" />
+          <Property Name="IDRole" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="EmployeesExchanges" Relationship="Self.FK_EmployeesExchanges_Users" FromRole="Users" ToRole="EmployeesExchanges" />
+          <NavigationProperty Name="Roles" Relationship="Self.FK_Users_Roles" FromRole="Users" ToRole="Roles" />
+        </EntityType>
+        <Association Name="FK_OrderDishes_Dishes">
+          <End Role="Dishes" Type="Self.Dishes" Multiplicity="1" />
+          <End Role="OrderDishes" Type="Self.OrderDishes" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Dishes">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="OrderDishes">
+              <PropertyRef Name="IDDish" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_EmployeesExchanges_Exchange">
+          <End Role="Exchange" Type="Self.Exchange" Multiplicity="1" />
+          <End Role="EmployeesExchanges" Type="Self.EmployeesExchanges" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Exchange">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="EmployeesExchanges">
+              <PropertyRef Name="IDExchange" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_EmployeesExchanges_Users">
+          <End Role="Users" Type="Self.Users" Multiplicity="1" />
+          <End Role="EmployeesExchanges" Type="Self.EmployeesExchanges" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Users">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="EmployeesExchanges">
+              <PropertyRef Name="IDEmployee" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_Orders_EmployeesExchanges">
+          <End Role="EmployeesExchanges" Type="Self.EmployeesExchanges" Multiplicity="1" />
+          <End Role="Orders" Type="Self.Orders" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="EmployeesExchanges">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="Orders">
+              <PropertyRef Name="IDEmployeeExchange" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_OrderDishes_Orders">
+          <End Role="Orders" Type="Self.Orders" Multiplicity="1" />
+          <End Role="OrderDishes" Type="Self.OrderDishes" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Orders">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="OrderDishes">
+              <PropertyRef Name="IDOrder" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_Orders_Tables">
+          <End Role="Tables" Type="Self.Tables" Multiplicity="1" />
+          <End Role="Orders" Type="Self.Orders" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Tables">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="Orders">
+              <PropertyRef Name="IDTable" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_Users_Roles">
+          <End Role="Roles" Type="Self.Roles" Multiplicity="1" />
+          <End Role="Users" Type="Self.Users" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Roles">
+              <PropertyRef Name="ID" />
+            </Principal>
+            <Dependent Role="Users">
+              <PropertyRef Name="IDRole" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <EntityContainer Name="CafeEntities" annotation:LazyLoadingEnabled="true">
+          <EntitySet Name="Dishes" EntityType="Self.Dishes" />
+          <EntitySet Name="EmployeesExchanges" EntityType="Self.EmployeesExchanges" />
+          <EntitySet Name="Exchange" EntityType="Self.Exchange" />
+          <EntitySet Name="OrderDishes" EntityType="Self.OrderDishes" />
+          <EntitySet Name="Orders" EntityType="Self.Orders" />
+          <EntitySet Name="Roles" EntityType="Self.Roles" />
+          <EntitySet Name="sysdiagrams" EntityType="Self.sysdiagrams" />
+          <EntitySet Name="Tables" EntityType="Self.Tables" />
+          <EntitySet Name="Users" EntityType="Self.Users" />
+          <AssociationSet Name="FK_OrderDishes_Dishes" Association="Self.FK_OrderDishes_Dishes">
+            <End Role="Dishes" EntitySet="Dishes" />
+            <End Role="OrderDishes" EntitySet="OrderDishes" />
+          </AssociationSet>
+          <AssociationSet Name="FK_EmployeesExchanges_Exchange" Association="Self.FK_EmployeesExchanges_Exchange">
+            <End Role="Exchange" EntitySet="Exchange" />
+            <End Role="EmployeesExchanges" EntitySet="EmployeesExchanges" />
+          </AssociationSet>
+          <AssociationSet Name="FK_EmployeesExchanges_Users" Association="Self.FK_EmployeesExchanges_Users">
+            <End Role="Users" EntitySet="Users" />
+            <End Role="EmployeesExchanges" EntitySet="EmployeesExchanges" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Orders_EmployeesExchanges" Association="Self.FK_Orders_EmployeesExchanges">
+            <End Role="EmployeesExchanges" EntitySet="EmployeesExchanges" />
+            <End Role="Orders" EntitySet="Orders" />
+          </AssociationSet>
+          <AssociationSet Name="FK_OrderDishes_Orders" Association="Self.FK_OrderDishes_Orders">
+            <End Role="Orders" EntitySet="Orders" />
+            <End Role="OrderDishes" EntitySet="OrderDishes" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Orders_Tables" Association="Self.FK_Orders_Tables">
+            <End Role="Tables" EntitySet="Tables" />
+            <End Role="Orders" EntitySet="Orders" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Users_Roles" Association="Self.FK_Users_Roles">
+            <End Role="Roles" EntitySet="Roles" />
+            <End Role="Users" EntitySet="Users" />
+          </AssociationSet>
+        </EntityContainer>
+      </Schema>
+    </edmx:ConceptualModels>
+    <!-- C-S mapping content -->
+    <edmx:Mappings>
+      <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
+        <EntityContainerMapping StorageEntityContainer="Хранилище CafeModelContainer" CdmEntityContainer="CafeEntities">
+          <EntitySetMapping Name="Dishes">
+            <EntityTypeMapping TypeName="CafeModel.Dishes">
+              <MappingFragment StoreEntitySet="Dishes">
+                <ScalarProperty Name="ID" ColumnName="ID" />
+                <ScalarProperty Name="Name" ColumnName="Name" />
+                <ScalarProperty Name="Description" ColumnName="Description" />
+                <ScalarProperty Name="Price" ColumnName="Price" />
+                <ScalarProperty Name="Picture" ColumnName="Picture" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="EmployeesExchanges">
+            <EntityTypeMapping TypeName="CafeModel.EmployeesExchanges">
+              <MappingFragment StoreEntitySet="EmployeesExchanges">
+                <ScalarProperty Name="ID" ColumnName="ID" />
+                <ScalarProperty Name="IDEmployee" ColumnName="IDEmployee" />
+                <ScalarProperty Name="IDExchange" ColumnName="IDExchange" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Exchange">
+            <EntityTypeMapping TypeName="CafeModel.Exchange">
+              <MappingFragment StoreEntitySet="Exchange">
+                <ScalarProperty Name="ID" ColumnName="ID" />
+                <ScalarProperty Name="Date" ColumnName="Date" />
+                <ScalarProperty Name="TimeOfBegin" ColumnName="TimeOfBegin" />
+                <ScalarProperty Name="TimeOfEnd" ColumnName="TimeOfEnd" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="OrderDishes">
+            <EntityTypeMapping TypeName="CafeModel.OrderDishes">
+              <MappingFragment StoreEntitySet="OrderDishes">
+                <ScalarProperty Name="ID" ColumnName="ID" />
+                <ScalarProperty Name="IDOrder" ColumnName="IDOrder" />
+                <ScalarProperty Name="IDDish" ColumnName="IDDish" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Orders">
+            <EntityTypeMapping TypeName="CafeModel.Orders">
+              <MappingFragment StoreEntitySet="Orders">
+                <ScalarProperty Name="ID" ColumnName="ID" />
+                <ScalarProperty Name="IDEmployeeExchange" ColumnName="IDEmployeeExchange" />
+                <ScalarProperty Name="IDTable" ColumnName="IDTable" />
+                <ScalarProperty Name="Time" ColumnName="Time" />
+                <ScalarProperty Name="SumOfOrder" ColumnName="SumOfOrder" />
+                <ScalarProperty Name="IsPaid" ColumnName="IsPaid" />
+                <ScalarProperty Name="IsReady" ColumnName="IsReady" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Roles">
+            <EntityTypeMapping TypeName="CafeModel.Roles">
+              <MappingFragment StoreEntitySet="Roles">
+                <ScalarProperty Name="ID" ColumnName="ID" />
+                <ScalarProperty Name="RoleName" ColumnName="RoleName" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="sysdiagrams">
+            <EntityTypeMapping TypeName="CafeModel.sysdiagrams">
+              <MappingFragment StoreEntitySet="sysdiagrams">
+                <ScalarProperty Name="name" ColumnName="name" />
+                <ScalarProperty Name="principal_id" ColumnName="principal_id" />
+                <ScalarProperty Name="diagram_id" ColumnName="diagram_id" />
+                <ScalarProperty Name="version" ColumnName="version" />
+                <ScalarProperty Name="definition" ColumnName="definition" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Tables">
+            <EntityTypeMapping TypeName="CafeModel.Tables">
+              <MappingFragment StoreEntitySet="Tables">
+                <ScalarProperty Name="ID" ColumnName="ID" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Users">
+            <EntityTypeMapping TypeName="CafeModel.Users">
+              <MappingFragment StoreEntitySet="Users">
+                <ScalarProperty Name="ID" ColumnName="ID" />
+                <ScalarProperty Name="Login" ColumnName="Login" />
+                <ScalarProperty Name="Password" ColumnName="Password" />
+                <ScalarProperty Name="SecondName" ColumnName="SecondName" />
+                <ScalarProperty Name="FirstName" ColumnName="FirstName" />
+                <ScalarProperty Name="MiddleName" ColumnName="MiddleName" />
+                <ScalarProperty Name="Email" ColumnName="Email" />
+                <ScalarProperty Name="IsFired" ColumnName="IsFired" />
+                <ScalarProperty Name="IDRole" ColumnName="IDRole" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+        </EntityContainerMapping>
+      </Mapping>
+    </edmx:Mappings>
+  </edmx:Runtime>
+  <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
+  <Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
+    <Connection>
+      <DesignerInfoPropertySet>
+        <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
+      </DesignerInfoPropertySet>
+    </Connection>
+    <Options>
+      <DesignerInfoPropertySet>
+        <DesignerProperty Name="ValidateOnBuild" Value="true" />
+        <DesignerProperty Name="EnablePluralization" Value="false" />
+        <DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
+        <DesignerProperty Name="UseLegacyProvider" Value="false" />
+        <DesignerProperty Name="CodeGenerationStrategy" Value="Нет" />
+      </DesignerInfoPropertySet>
+    </Options>
+    <!-- Diagram content (shape and connector positions) -->
+    <Diagrams></Diagrams>
+  </Designer>
+</edmx:Edmx>

+ 27 - 0
Cafe2/Cafe.edmx.diagram

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
+ <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
+  <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
+    <!-- Diagram content (shape and connector positions) -->
+    <edmx:Diagrams>
+      <Diagram DiagramId="aa871df6fd0b4eda8d3bdbf1878c24c2" Name="Diagram1">
+        <EntityTypeShape EntityType="CafeModel.Dishes" Width="1.5" PointX="7.5" PointY="5.5" IsExpanded="true" />
+        <EntityTypeShape EntityType="CafeModel.EmployeesExchanges" Width="1.5" PointX="5.25" PointY="1.5" IsExpanded="true" />
+        <EntityTypeShape EntityType="CafeModel.Exchange" Width="1.5" PointX="3" PointY="5.5" IsExpanded="true" />
+        <EntityTypeShape EntityType="CafeModel.OrderDishes" Width="1.5" PointX="9.75" PointY="1.5" IsExpanded="true" />
+        <EntityTypeShape EntityType="CafeModel.Orders" Width="1.5" PointX="7.5" PointY="1.125" IsExpanded="true" />
+        <EntityTypeShape EntityType="CafeModel.Roles" Width="1.5" PointX="0.75" PointY="1.75" IsExpanded="true" />
+        <EntityTypeShape EntityType="CafeModel.sysdiagrams" Width="1.5" PointX="0.75" PointY="8.75" IsExpanded="true" />
+        <EntityTypeShape EntityType="CafeModel.Tables" Width="1.5" PointX="5.25" PointY="5.875" IsExpanded="true" />
+        <EntityTypeShape EntityType="CafeModel.Users" Width="1.5" PointX="3" PointY="1" IsExpanded="true" />
+        <AssociationConnector Association="CafeModel.FK_OrderDishes_Dishes" ManuallyRouted="false" />
+        <AssociationConnector Association="CafeModel.FK_EmployeesExchanges_Exchange" ManuallyRouted="false" />
+        <AssociationConnector Association="CafeModel.FK_EmployeesExchanges_Users" ManuallyRouted="false" />
+        <AssociationConnector Association="CafeModel.FK_Orders_EmployeesExchanges" ManuallyRouted="false" />
+        <AssociationConnector Association="CafeModel.FK_OrderDishes_Orders" ManuallyRouted="false" />
+        <AssociationConnector Association="CafeModel.FK_Orders_Tables" ManuallyRouted="false" />
+        <AssociationConnector Association="CafeModel.FK_Users_Roles" ManuallyRouted="false" />
+      </Diagram>
+    </edmx:Diagrams>
+  </edmx:Designer>
+</edmx:Edmx>

+ 733 - 0
Cafe2/Cafe.tt

@@ -0,0 +1,733 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF6.Utility.CS.ttinclude"#><#@ 
+ output extension=".cs"#><#
+
+const string inputFile = @"Cafe.edmx";
+var textTransform = DynamicTextTransformation.Create(this);
+var code = new CodeGenerationTools(this);
+var ef = new MetadataTools(this);
+var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
+var	fileManager = EntityFrameworkTemplateFileManager.Create(this);
+var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
+var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
+
+if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
+{
+    return string.Empty;
+}
+
+WriteHeader(codeStringGenerator, fileManager);
+
+foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
+{
+    fileManager.StartNewFile(entity.Name + ".cs");
+    BeginNamespace(code);
+#>
+<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
+<#=codeStringGenerator.EntityClassOpening(entity)#>
+{
+<#
+    var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
+    var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
+    var complexProperties = typeMapper.GetComplexProperties(entity);
+
+    if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
+    {
+#>
+    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+    public <#=code.Escape(entity)#>()
+    {
+<#
+        foreach (var edmProperty in propertiesWithDefaultValues)
+        {
+#>
+        this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
+<#
+        }
+
+        foreach (var navigationProperty in collectionNavigationProperties)
+        {
+#>
+        this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
+<#
+        }
+
+        foreach (var complexProperty in complexProperties)
+        {
+#>
+        this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
+<#
+        }
+#>
+    }
+
+<#
+    }
+
+    var simpleProperties = typeMapper.GetSimpleProperties(entity);
+    if (simpleProperties.Any())
+    {
+        foreach (var edmProperty in simpleProperties)
+        {
+#>
+    <#=codeStringGenerator.Property(edmProperty)#>
+<#
+        }
+    }
+
+    if (complexProperties.Any())
+    {
+#>
+
+<#
+        foreach(var complexProperty in complexProperties)
+        {
+#>
+    <#=codeStringGenerator.Property(complexProperty)#>
+<#
+        }
+    }
+
+    var navigationProperties = typeMapper.GetNavigationProperties(entity);
+    if (navigationProperties.Any())
+    {
+#>
+
+<#
+        foreach (var navigationProperty in navigationProperties)
+        {
+            if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
+            {
+#>
+    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+<#
+            }
+#>
+    <#=codeStringGenerator.NavigationProperty(navigationProperty)#>
+<#
+        }
+    }
+#>
+}
+<#
+    EndNamespace(code);
+}
+
+foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
+{
+    fileManager.StartNewFile(complex.Name + ".cs");
+    BeginNamespace(code);
+#>
+<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
+<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
+{
+<#
+    var complexProperties = typeMapper.GetComplexProperties(complex);
+    var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
+
+    if (propertiesWithDefaultValues.Any() || complexProperties.Any())
+    {
+#>
+    public <#=code.Escape(complex)#>()
+    {
+<#
+        foreach (var edmProperty in propertiesWithDefaultValues)
+        {
+#>
+        this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
+<#
+        }
+
+        foreach (var complexProperty in complexProperties)
+        {
+#>
+        this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
+<#
+        }
+#>
+    }
+
+<#
+    }
+
+    var simpleProperties = typeMapper.GetSimpleProperties(complex);
+    if (simpleProperties.Any())
+    {
+        foreach(var edmProperty in simpleProperties)
+        {
+#>
+    <#=codeStringGenerator.Property(edmProperty)#>
+<#
+        }
+    }
+
+    if (complexProperties.Any())
+    {
+#>
+
+<#
+        foreach(var edmProperty in complexProperties)
+        {
+#>
+    <#=codeStringGenerator.Property(edmProperty)#>
+<#
+        }
+    }
+#>
+}
+<#
+    EndNamespace(code);
+}
+
+foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
+{
+    fileManager.StartNewFile(enumType.Name + ".cs");
+    BeginNamespace(code);
+#>
+<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
+<#
+    if (typeMapper.EnumIsFlags(enumType))
+    {
+#>
+[Flags]
+<#
+    }
+#>
+<#=codeStringGenerator.EnumOpening(enumType)#>
+{
+<#
+    var foundOne = false;
+    
+    foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
+    {
+        foundOne = true;
+#>
+    <#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
+<#
+    }
+
+    if (foundOne)
+    {
+        this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
+    }
+#>
+}
+<#
+    EndNamespace(code);
+}
+
+fileManager.Process();
+
+#>
+<#+
+
+public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
+{
+    fileManager.StartHeader();
+#>
+//------------------------------------------------------------------------------
+// <auto-generated>
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
+//
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
+// </auto-generated>
+//------------------------------------------------------------------------------
+<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
+<#+
+    fileManager.EndBlock();
+}
+
+public void BeginNamespace(CodeGenerationTools code)
+{
+    var codeNamespace = code.VsNamespaceSuggestion();
+    if (!String.IsNullOrEmpty(codeNamespace))
+    {
+#>
+namespace <#=code.EscapeNamespace(codeNamespace)#>
+{
+<#+
+        PushIndent("    ");
+    }
+}
+
+public void EndNamespace(CodeGenerationTools code)
+{
+    if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
+    {
+        PopIndent();
+#>
+}
+<#+
+    }
+}
+
+public const string TemplateId = "CSharp_DbContext_Types_EF6";
+
+public class CodeStringGenerator
+{
+    private readonly CodeGenerationTools _code;
+    private readonly TypeMapper _typeMapper;
+    private readonly MetadataTools _ef;
+
+    public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
+    {
+        ArgumentNotNull(code, "code");
+        ArgumentNotNull(typeMapper, "typeMapper");
+        ArgumentNotNull(ef, "ef");
+
+        _code = code;
+        _typeMapper = typeMapper;
+        _ef = ef;
+    }
+
+    public string Property(EdmProperty edmProperty)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2} {{ {3}get; {4}set; }}",
+            Accessibility.ForProperty(edmProperty),
+            _typeMapper.GetTypeName(edmProperty.TypeUsage),
+            _code.Escape(edmProperty),
+            _code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
+            _code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
+    }
+
+    public string NavigationProperty(NavigationProperty navProp)
+    {
+        var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2} {{ {3}get; {4}set; }}",
+            AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
+            navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
+            _code.Escape(navProp),
+            _code.SpaceAfter(Accessibility.ForGetter(navProp)),
+            _code.SpaceAfter(Accessibility.ForSetter(navProp)));
+    }
+    
+    public string AccessibilityAndVirtual(string accessibility)
+    {
+        return accessibility + (accessibility != "private" ? " virtual" : "");
+    }
+    
+    public string EntityClassOpening(EntityType entity)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1}partial class {2}{3}",
+            Accessibility.ForType(entity),
+            _code.SpaceAfter(_code.AbstractOption(entity)),
+            _code.Escape(entity),
+            _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
+    }
+    
+    public string EnumOpening(SimpleType enumType)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} enum {1} : {2}",
+            Accessibility.ForType(enumType),
+            _code.Escape(enumType),
+            _code.Escape(_typeMapper.UnderlyingClrType(enumType)));
+        }
+    
+    public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
+    {
+        var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+        foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
+        {
+            var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
+            var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
+            var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
+            writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
+        }
+    }
+    
+    public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} IQueryable<{1}> {2}({3})",
+            AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+            _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+            _code.Escape(edmFunction),
+            string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
+    }
+    
+    public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
+            _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+            edmFunction.NamespaceName,
+            edmFunction.Name,
+            string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
+            _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
+    }
+    
+    public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        var returnType = _typeMapper.GetReturnType(edmFunction);
+
+        var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
+        if (includeMergeOption)
+        {
+            paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
+        }
+
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} {1} {2}({3})",
+            AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+            returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+            _code.Escape(edmFunction),
+            paramList);
+    }
+    
+    public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+    {
+        var parameters = _typeMapper.GetParameters(edmFunction);
+        var returnType = _typeMapper.GetReturnType(edmFunction);
+
+        var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
+        if (includeMergeOption)
+        {
+            callParams = ", mergeOption" + callParams;
+        }
+        
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
+            returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+            edmFunction.Name,
+            callParams);
+    }
+    
+    public string DbSet(EntitySet entitySet)
+    {
+        return string.Format(
+            CultureInfo.InvariantCulture,
+            "{0} virtual DbSet<{1}> {2} {{ get; set; }}",
+            Accessibility.ForReadOnlyProperty(entitySet),
+            _typeMapper.GetTypeName(entitySet.ElementType),
+            _code.Escape(entitySet));
+    }
+
+    public string UsingDirectives(bool inHeader, bool includeCollections = true)
+    {
+        return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
+            ? string.Format(
+                CultureInfo.InvariantCulture,
+                "{0}using System;{1}" +
+                "{2}",
+                inHeader ? Environment.NewLine : "",
+                includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
+                inHeader ? "" : Environment.NewLine)
+            : "";
+    }
+}
+
+public class TypeMapper
+{
+    private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
+
+    private readonly System.Collections.IList _errors;
+    private readonly CodeGenerationTools _code;
+    private readonly MetadataTools _ef;
+
+    public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
+    {
+        ArgumentNotNull(code, "code");
+        ArgumentNotNull(ef, "ef");
+        ArgumentNotNull(errors, "errors");
+
+        _code = code;
+        _ef = ef;
+        _errors = errors;
+    }
+
+    public static string FixNamespaces(string typeName)
+    {
+        return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
+    }
+
+    public string GetTypeName(TypeUsage typeUsage)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
+    }
+
+    public string GetTypeName(EdmType edmType)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: null);
+    }
+
+    public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
+    {
+        return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, string modelNamespace)
+    {
+        return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
+    }
+
+    public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
+    {
+        if (edmType == null)
+        {
+            return null;
+        }
+
+        var collectionType = edmType as CollectionType;
+        if (collectionType != null)
+        {
+            return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
+        }
+
+        var typeName = _code.Escape(edmType.MetadataProperties
+                                .Where(p => p.Name == ExternalTypeNameAttributeName)
+                                .Select(p => (string)p.Value)
+                                .FirstOrDefault())
+            ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
+                _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
+                _code.Escape(edmType));
+
+        if (edmType is StructuralType)
+        {
+            return typeName;
+        }
+
+        if (edmType is SimpleType)
+        {
+            var clrType = UnderlyingClrType(edmType);
+            if (!IsEnumType(edmType))
+            {
+                typeName = _code.Escape(clrType);
+            }
+
+            typeName = FixNamespaces(typeName);
+
+            return clrType.IsValueType && isNullable == true ?
+                String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
+                typeName;
+        }
+
+        throw new ArgumentException("edmType");
+    }
+    
+    public Type UnderlyingClrType(EdmType edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        var primitiveType = edmType as PrimitiveType;
+        if (primitiveType != null)
+        {
+            return primitiveType.ClrEquivalentType;
+        }
+
+        if (IsEnumType(edmType))
+        {
+            return GetEnumUnderlyingType(edmType).ClrEquivalentType;
+        }
+
+        return typeof(object);
+    }
+    
+    public object GetEnumMemberValue(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var valueProperty = enumMember.GetType().GetProperty("Value");
+        return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
+    }
+    
+    public string GetEnumMemberName(MetadataItem enumMember)
+    {
+        ArgumentNotNull(enumMember, "enumMember");
+        
+        var nameProperty = enumMember.GetType().GetProperty("Name");
+        return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
+    }
+
+    public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        var membersProperty = enumType.GetType().GetProperty("Members");
+        return membersProperty != null 
+            ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
+            : Enumerable.Empty<MetadataItem>();
+    }
+    
+    public bool EnumIsFlags(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+        
+        var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
+        return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
+    }
+
+    public bool IsEnumType(GlobalItem edmType)
+    {
+        ArgumentNotNull(edmType, "edmType");
+
+        return edmType.GetType().Name == "EnumType";
+    }
+
+    public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
+    {
+        ArgumentNotNull(enumType, "enumType");
+
+        return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
+    }
+
+    public string CreateLiteral(object value)
+    {
+        if (value == null || value.GetType() != typeof(TimeSpan))
+        {
+            return _code.CreateLiteral(value);
+        }
+
+        return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
+    }
+    
+    public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
+    {
+        ArgumentNotNull(types, "types");
+        ArgumentNotNull(sourceFile, "sourceFile");
+        
+        var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
+        if (types.Any(item => !hash.Add(item)))
+        {
+            _errors.Add(
+                new CompilerError(sourceFile, -1, -1, "6023",
+                    String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
+            return false;
+        }
+        return true;
+    }
+    
+    public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
+    {
+        return GetItemsToGenerate<SimpleType>(itemCollection)
+            .Where(e => IsEnumType(e));
+    }
+    
+    public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
+    {
+        return itemCollection
+            .OfType<T>()
+            .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
+            .OrderBy(i => i.Name);
+    }
+
+    public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
+    {
+        return itemCollection
+            .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
+            .Select(g => GetGlobalItemName(g));
+    }
+
+    public string GetGlobalItemName(GlobalItem item)
+    {
+        if (item is EdmType)
+        {
+            return ((EdmType)item).Name;
+        }
+        else
+        {
+            return ((EntityContainer)item).Name;
+        }
+    }
+
+    public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+    
+    public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+    }
+
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+    
+    public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
+    {
+        return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+    }
+
+    public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type);
+    }
+    
+    public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
+    {
+        return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
+    }
+    
+    public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
+        return returnParamsProperty == null
+            ? edmFunction.ReturnParameter
+            : ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
+    }
+
+    public bool IsComposable(EdmFunction edmFunction)
+    {
+        ArgumentNotNull(edmFunction, "edmFunction");
+
+        var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
+        return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
+    }
+
+    public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
+    {
+        return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+    }
+
+    public TypeUsage GetReturnType(EdmFunction edmFunction)
+    {
+        var returnParam = GetReturnParameter(edmFunction);
+        return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
+    }
+    
+    public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
+    {
+        var returnType = GetReturnType(edmFunction);
+        return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
+    }
+}
+
+public static void ArgumentNotNull<T>(T arg, string name) where T : class
+{
+    if (arg == null)
+    {
+        throw new ArgumentNullException(name);
+    }
+}
+#>

+ 7 - 0
Cafe2/Connection.cs

@@ -0,0 +1,7 @@
+namespace Cafe
+{
+    internal class Connection
+    {
+        public static CafeEntities db = new CafeEntities();
+    }
+}

+ 32 - 0
Cafe2/Dishes.cs

@@ -0,0 +1,32 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Dishes
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+        public Dishes()
+        {
+            this.OrderDishes = new HashSet<OrderDishes>();
+        }
+    
+        public int ID { get; set; }
+        public string Name { get; set; }
+        public string Description { get; set; }
+        public decimal Price { get; set; }
+        public byte[] Picture { get; set; }
+    
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<OrderDishes> OrderDishes { get; set; }
+    }
+}

+ 19 - 0
Cafe2/ElementsWindows/DishWindow.xaml

@@ -0,0 +1,19 @@
+<Window x:Class="Cafe.ElementsWindows.DishWindow"
+        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:Cafe.ElementsWindows"
+        mc:Ignorable="d"
+        Title="Блюдо" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Label Content="Название:" HorizontalAlignment="Left" Margin="127,166,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36"/>
+        <Label x:Name="Name" HorizontalAlignment="Left" Margin="307,166,0,0" VerticalAlignment="Top" Height="60" Width="730" FontSize="36" Foreground="White"/>
+        <Label Content="Цена:" HorizontalAlignment="Left" Margin="127,260,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36" HorizontalContentAlignment="Right"/>
+        <Label x:Name="Price" HorizontalAlignment="Left" Margin="307,260,0,0" VerticalAlignment="Top" Height="60" Width="250" FontSize="36" Foreground="White"/>
+        <Label Content="Описание:" HorizontalAlignment="Left" Margin="127,354,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36"/>
+        <Label x:Name="Description" HorizontalAlignment="Left" Margin="137,430,0,0" VerticalAlignment="Top" Height="328" Width="904" FontSize="36" Foreground="White"/>
+        <Image x:Name="Picture" HorizontalAlignment="Left" Height="649" Margin="1129,133,0,0" VerticalAlignment="Top"  Width="411"/>
+        <Button x:Name="BackButton"  Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+    </Grid>
+</Window>

+ 31 - 0
Cafe2/ElementsWindows/DishWindow.xaml.cs

@@ -0,0 +1,31 @@
+using System.Linq;
+using System.Windows;
+using Cafe.AddWindows;
+
+namespace Cafe.ElementsWindows
+{
+    public partial class DishWindow : Window
+    {
+        public DishWindow(int id)
+        {
+            InitializeComponent();
+
+            Dishes dish = Connection.db.Dishes.Where(item => item.ID == id).FirstOrDefault();
+
+            Name.Content = dish.Name;
+
+            Price.Content = dish.Price;
+
+            Description.Content = dish.Description;
+
+            Picture.Source = ImagesManip.NewImage(dish);
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            AddOrderWindow addOrderWindow = new AddOrderWindow();
+            addOrderWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 27 - 0
Cafe2/ElementsWindows/EmployeeWindow.xaml

@@ -0,0 +1,27 @@
+<Window x:Class="Cafe.ElementsWindows.EmployeeWindow"
+        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:Cafe.ElementsWindows"
+        mc:Ignorable="d"
+        Title="Сотрудник" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Label Content="Логин:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,188,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <Label Name="Login" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,248,0,0" Height="60" Width="550" Foreground="White" FontSize="36"/>
+        <Label Content="Должность:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,188,0,0" Foreground="White" Height="60" Width="200" FontSize="36"/>
+        <Label Name="Role" VerticalAlignment="Top" Margin="925,248,0,0" Height="60" FontSize="36" Foreground="White" HorizontalAlignment="Left" Width="550"/>
+        <Label Content="Фамилия:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,330,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <Label Name="SecondName" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,390,0,0" Height="60" Width="550" Foreground="White" FontSize="36"/>
+        <Label Content="Имя:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,330,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <Label Name="FirstName" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,390,0,0" Height="60" Width="550" Foreground="White" FontSize="36"/>
+        <Label Content="Отчество:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,472,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <Label Name="MiddleName" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,532,0,0" Height="60" Width="550" Foreground="White" FontSize="36"/>
+        <Label Content="Почта:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,472,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <Label Name="Email" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="925,532,0,0" Height="60" Width="550" Foreground="White" FontSize="36"/>
+        <Label Content="Статус:" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,614,0,0" Foreground="White" Height="60" Width="180" FontSize="36"/>
+        <Label x:Name="IsFired" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="125,674,0,0" Height="60" Width="550" Foreground="White" FontSize="36"/>
+        <Button Name="FireButton" Content="Уволить" VerticalAlignment="Top" HorizontalAlignment="Left" Height="60" Width="184" Margin="1320,766,0,0" FontSize="36" Click="FireButtonClick"/>
+        <Button x:Name="BackButton" Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+    </Grid>
+</Window>

+ 63 - 0
Cafe2/ElementsWindows/EmployeeWindow.xaml.cs

@@ -0,0 +1,63 @@
+using System.Linq;
+using System.Windows;
+using Cafe.ListWindows;
+
+namespace Cafe.ElementsWindows
+{
+    public partial class EmployeeWindow : Window
+    {
+        Users employee;
+
+        public EmployeeWindow(int id)
+        {
+            InitializeComponent();
+
+            employee = Connection.db.Users.Where(item => item.ID == id).FirstOrDefault();
+
+            Login.Content = employee.Login;
+
+            Role.Content = employee.Roles.RoleName;
+
+            SecondName.Content = employee.SecondName;
+
+            FirstName.Content = employee.FirstName;
+
+            MiddleName.Content = employee.MiddleName;
+
+            Email.Content = employee.Email;
+
+            IsFired.Content = GetFireStatus();
+
+            if (employee.IsFired)
+            {
+                FireButton.Visibility = Visibility.Hidden;
+            }
+        }
+
+        private string GetFireStatus()
+        {
+            if (employee.IsFired)
+            {
+                return "уволен";
+            }
+            else
+            {
+                return "не уволен";
+            }
+        }
+
+        private void FireButtonClick(object sender, RoutedEventArgs e)
+        {
+            employee.IsFired = true;
+
+            Connection.db.SaveChanges();
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            EmployeesListWindow employeesListWindow = new EmployeesListWindow();
+            employeesListWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 54 - 0
Cafe2/ElementsWindows/ExchangeWindow.xaml

@@ -0,0 +1,54 @@
+<Window x:Class="Cafe.ElementsWindows.ExchangeWindow"
+        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:Cafe.ElementsWindows"
+        mc:Ignorable="d"
+        Title="Смена" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid Margin="0,0,0,0">
+        <Button x:Name="BackButton" Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+        <TabControl BorderThickness="0" Margin="0,78,0,0">
+            <TabItem Header="Заказы" Height="20" Width="100" Background="#FF4F5856">
+                <Grid Margin="-3,-22,-3,-2">
+                    <DataGrid x:Name="OrdersList" AutoGenerateColumns="False" Height="600" Margin="0,158,0,0" VerticalAlignment="Top" HorizontalAlignment="Center" Width="1340"
+                        RowHeaderStyle="{StaticResource RowHeaderStyle}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}">
+                        <DataGrid.ItemContainerStyle>
+                            <Style TargetType="{x:Type DataGridRow}">
+                                <EventSetter Event="Control.MouseDoubleClick" Handler="OrdersListMouseDoubleClick"/>
+                            </Style>
+                        </DataGrid.ItemContainerStyle>
+                        <DataGrid.Columns>
+                            <DataGridTextColumn Binding="{Binding IDTable}" Header="Столик" Width="330" IsReadOnly="True"/>
+                            <DataGridTextColumn Binding="{Binding EmployeeExchanges.Users.SecondName}" Header="Официант" Width="330" IsReadOnly="True"/>
+                            <DataGridTextColumn Binding="{Binding Time}" Header="Время" Width="330" IsReadOnly="True"/>
+                            <DataGridTextColumn Binding="{Binding SumOfOrder}" Header="Сумма" Width="330" IsReadOnly="True"/>
+                        </DataGrid.Columns>
+                    </DataGrid>
+                    <TextBox x:Name="OrdersListSearch" HorizontalAlignment="Center" Margin="0,99,0,0" TextWrapping="Wrap" Text="Поиск" VerticalAlignment="Top" Width="1340" Height="30" FontSize="20" 
+                        Foreground="#FF675B5B" PreviewMouseLeftButtonUp="OrdersListSearchPreviewMouseLeftButtonUp" LostFocus="OrdersListSearchLostFocus" TextChanged="OrdersListSearchTextChanged"/>
+                </Grid>
+            </TabItem>
+            <TabItem Header="Работники" Height="20" Width="100" Background="#FF4F5856">
+                <Grid Margin="-3,-22,-3,-2">
+                    <DataGrid x:Name="EmployeesList" AutoGenerateColumns="False" Height="600" Margin="0,158,0,0" VerticalAlignment="Top" HorizontalAlignment="Center" Width="1340"
+                        RowHeaderStyle="{StaticResource RowHeaderStyle}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}">
+                        <DataGrid.ItemContainerStyle>
+                            <Style TargetType="{x:Type DataGridRow}">
+                                <EventSetter Event="Control.MouseDoubleClick" Handler="EmployeesListMouseDoubleClick"/>
+                            </Style>
+                        </DataGrid.ItemContainerStyle>
+                        <DataGrid.Columns>
+                            <DataGridTextColumn Binding="{Binding Users.SecondName}" Header="Фамлия" Width="330" IsReadOnly="True"/>
+                            <DataGridTextColumn Binding="{Binding Users.FirstName}" Header="Имя" Width="330" IsReadOnly="True"/>
+                            <DataGridTextColumn Binding="{Binding Users.MiddleName}" Header="Отчество" Width="330" IsReadOnly="True"/>
+                            <DataGridTextColumn Binding="{Binding Users.Roles.RoleName}" Header="Должность" Width="330" IsReadOnly="True"/>
+                        </DataGrid.Columns>
+                    </DataGrid>
+                    <TextBox x:Name="EmployeesListSearch" HorizontalAlignment="Center" Margin="0,99,0,0" TextWrapping="Wrap" Text="Поиск" VerticalAlignment="Top" Width="1340" Height="30" FontSize="20" 
+                        Foreground="#FF675B5B" PreviewMouseLeftButtonUp="EmployeesListSearchPreviewMouseLeftButtonUp" LostFocus="EmployeesListSearchLostFocus" TextChanged="EmployeesListSearchTextChanged"/>
+                </Grid>
+            </TabItem>
+        </TabControl>
+    </Grid>
+</Window>

+ 100 - 0
Cafe2/ElementsWindows/ExchangeWindow.xaml.cs

@@ -0,0 +1,100 @@
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using Cafe.ListWindows;
+
+namespace Cafe.ElementsWindows
+{
+    public partial class ExchangeWindow : Window
+    {
+        Exchange exchange;
+
+        public ExchangeWindow(int id)
+        {
+            exchange = Connection.db.Exchange.Where(item => item.ID == id).FirstOrDefault();
+
+            InitializeComponent();
+
+            EmployeesList.ItemsSource = Connection.db.EmployeesExchanges.Where(item => item.IDExchange == exchange.ID).ToList();
+
+            OrdersList.ItemsSource = Connection.db.Orders.Where(item => item.EmployeesExchanges.IDExchange == exchange.ID).ToList();
+        }
+
+        private void OrdersListMouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            int id = ((Orders)OrdersList.SelectedItem).ID;
+            OrderWindow orderWindow = new OrderWindow(id);
+            orderWindow.Show();
+            this.Hide();
+        }
+
+        private void OrdersListSearchPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            if (OrdersListSearch.Text == "Поиск")
+                OrdersListSearch.Text = "";
+        }
+
+        private void OrdersListSearchLostFocus(object sender, RoutedEventArgs e)
+        {
+            if (OrdersListSearch.Text == "")
+                OrdersListSearch.Text = "Поиск";
+        }
+
+        private void OrdersListSearchTextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (OrdersListSearch.Text != "" && OrdersListSearch.Text != "Поиск")
+            {
+                OrdersList.ItemsSource = Connection.db.Orders.Where(item => (item.IDTable + " " + item.EmployeesExchanges.Users.SecondName + " "
+                                                                            + item.EmployeesExchanges.Users.FirstName + " " + item.EmployeesExchanges.Users.MiddleName + " "
+                                                                            + item.Time + " " + item.SumOfOrder).Contains(OrdersListSearch.Text)
+                                                                            && item.EmployeesExchanges.IDExchange == exchange.ID).ToList();
+            }
+            else if (OrdersListSearch.Text == "" || OrdersListSearch.Text == "Поиск")
+            {
+                OrdersList.ItemsSource = Connection.db.Orders.Where(item => item.EmployeesExchanges.IDExchange == exchange.ID).ToList();
+            }
+        }
+
+        private void EmployeesListMouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            int id = Connection.db.EmployeesExchanges.Where(item => item.ID == ((EmployeesExchanges)EmployeesList.SelectedItem).ID).Select(item => item.IDEmployee).FirstOrDefault();
+            EmployeeWindow employeeWindow = new EmployeeWindow(id);
+            employeeWindow.Show();
+            this.Hide();
+        }
+
+        private void EmployeesListSearchPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            if (EmployeesListSearch.Text == "Поиск")
+                EmployeesListSearch.Text = "";
+        }
+
+        private void EmployeesListSearchLostFocus(object sender, RoutedEventArgs e)
+        {
+            if (EmployeesListSearch.Text == "")
+                EmployeesListSearch.Text = "Поиск";
+        }
+
+        private void EmployeesListSearchTextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (EmployeesListSearch.Text != "" && EmployeesListSearch.Text != "Поиск")
+            {
+                EmployeesList.ItemsSource = Connection.db.EmployeesExchanges.Where(item => (item.Users.Login + " " + item.Users.SecondName + " " + item.Users.FirstName + " "
+                                                                                   + item.Users.MiddleName + " " + item.Users.Email).Contains(EmployeesListSearch.Text)
+                                                                                   && item.IDExchange == exchange.ID).ToList();
+            }
+            else if (EmployeesListSearch.Text == "" || EmployeesListSearch.Text == "Поиск")
+            {
+                EmployeesList.ItemsSource = Connection.db.EmployeesExchanges.Where(item => item.IDExchange == exchange.ID).ToList();
+            }
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            ExchangesListWindow exchangesListWindow = new ExchangesListWindow();
+            exchangesListWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 41 - 0
Cafe2/ElementsWindows/OrderWindow.xaml

@@ -0,0 +1,41 @@
+<Window x:Class="Cafe.ElementsWindows.OrderWindow"
+        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:Cafe.ElementsWindows"
+        mc:Ignorable="d"
+        Title="Заказ" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Button Name="BackButton" Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+        <Label Content="Столик:" HorizontalAlignment="Left" Margin="140,86,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36" HorizontalContentAlignment="Right"/>
+        <Label Name="Table" HorizontalAlignment="Left" Margin="322,86,0,0" VerticalAlignment="Top" Height="60" Width="700" FontSize="36" Foreground="White"/>
+        <Label Content="Официант:" HorizontalAlignment="Left" Margin="134,176,0,0" VerticalAlignment="Top" Height="60" Width="186" Foreground="White" HorizontalContentAlignment="Right" FontSize="36"/>
+        <Label Name="Waiter" HorizontalAlignment="Left" Margin="322,176,0,0" VerticalAlignment="Top" Height="60" Width="700" FontSize="36" Foreground="White"/>
+        <Label Content="Время:" HorizontalAlignment="Left" Margin="140,266,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36" HorizontalContentAlignment="Right"/>
+        <Label Name="Time" HorizontalAlignment="Left" Margin="322,266,0,0" VerticalAlignment="Top" Height="60" Width="700" FontSize="36" Foreground="White"/>
+        <Label Content="Сумма:" HorizontalAlignment="Left" Margin="1077,86,0,0" VerticalAlignment="Top" Height="60" Width="180" Foreground="White" FontSize="36" HorizontalContentAlignment="Right"/>
+        <Label Name="SumOfOrder" HorizontalAlignment="Left" Margin="1258,86,0,0" VerticalAlignment="Top" Height="60" Width="250" FontSize="36" Foreground="White"/>
+        <Label Name="Ready" Content="Готовность:" HorizontalAlignment="Left" Margin="1052,176,0,0" VerticalAlignment="Top" Height="60" Width="205" Foreground="White" FontSize="36" HorizontalContentAlignment="Right"/>
+        <Label x:Name="IsReady" HorizontalAlignment="Left" Margin="1258,176,0,0" VerticalAlignment="Top" Height="60" Width="250" FontSize="36" Foreground="White"/>
+        <ListBox x:Name="DishesList" VerticalAlignment="Top" HorizontalAlignment="Center" Width="1500" Height="375"
+            ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Auto" d:ItemsSource="{d:SampleData ItemCount=5}" Margin="0,355,0,0">
+            <ListBox.ItemsPanel>
+                <ItemsPanelTemplate>
+                    <VirtualizingStackPanel IsItemsHost="True" Orientation="Horizontal"/>
+                </ItemsPanelTemplate>
+            </ListBox.ItemsPanel>
+            <ListBox.ItemTemplate>
+                <DataTemplate>
+                    <StackPanel x:Name="DishStack">
+                        <Image Source="{Binding Dishes.Picture}" Width="250" Height="250"/>
+                        <Label Content="{Binding Dishes.Name}" Width="250" Foreground="White" FontSize="25" Height="50"/>
+                        <Label Content="{Binding Dishes.Price}" Width="250" Foreground="White" FontSize="25" Height="50"/>
+                    </StackPanel>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        <Button x:Name="Pay" Content="Оплачено" HorizontalAlignment="Center" Margin="0,792,0,0" VerticalAlignment="Top" Height="60" Width="180" FontSize="36" Click="PayButtonClick"/>
+        <Button x:Name="ReadyButton" Content="Готово" HorizontalAlignment="Center" Margin="0,792,0,0" VerticalAlignment="Top" Height="60" Width="180" FontSize="36" Click="ReadyButtonClick"/>
+    </Grid>
+</Window>

+ 92 - 0
Cafe2/ElementsWindows/OrderWindow.xaml.cs

@@ -0,0 +1,92 @@
+using System.Linq;
+using System.Windows;
+using Cafe.ListWindows;
+
+namespace Cafe.ElementsWindows
+{
+    public partial class OrderWindow : Window
+    {
+        Orders order;
+
+        public OrderWindow(int idOrder)
+        {
+            InitializeComponent();
+            order = Connection.db.Orders.Where(item => item.ID == idOrder).FirstOrDefault();
+
+            Table.Content = order.IDTable;
+
+            Users waiter = Connection.db.Users.Where(item => item.ID == User.IDUser).FirstOrDefault();
+            Waiter.Content = waiter.SecondName + " " + waiter.FirstName + " " + waiter.MiddleName;
+
+            Time.Content = order.Time.Day + "." + order.Time.Month + "." + order.Time.Year 
+                           + " " + order.Time.Hour + ":" + order.Time.Minute;
+
+            SumOfOrder.Content = string.Format("{0:f2}", order.SumOfOrder);
+
+            DishesList.ItemsSource = Connection.db.OrderDishes.Where(item => item.IDOrder == order.ID).ToList();
+
+            IsReady.Content = GetReadyStatus();
+
+            if (User.Role != 2)
+            {
+                Ready.Visibility = Visibility.Hidden;
+                IsReady.Visibility = Visibility.Hidden;
+                Pay.Visibility = Visibility.Hidden;
+            }
+            else if (User.Role != 3)
+            {
+                ReadyButton.Visibility = Visibility.Hidden;
+            }
+        }
+
+        private string GetReadyStatus()
+        {
+            if (order.IsReady)
+            {
+                return "готово";
+            }
+            else
+            {
+                return "готовится";
+            }
+        }
+
+        private void PayButtonClick(object sender, RoutedEventArgs e)
+        {
+            order.IsPaid = true;
+
+            Connection.db.SaveChanges();
+
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+
+        private void ReadyButtonClick(object sender, RoutedEventArgs e)
+        {
+            order.IsReady = true;
+
+            Connection.db.SaveChanges();
+
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            if (User.Role == 2)
+            {
+                MainWindow mainWindow = new MainWindow();
+                mainWindow.Show();
+                this.Close();
+            }
+            else if (User.Role == 3)
+            {
+                OrdersListWindow ordersListWindow = new OrdersListWindow();
+                ordersListWindow.Show();
+                this.Close();
+            }
+        }
+    }
+}

+ 32 - 0
Cafe2/EmployeesExchanges.cs

@@ -0,0 +1,32 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class EmployeesExchanges
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+        public EmployeesExchanges()
+        {
+            this.Orders = new HashSet<Orders>();
+        }
+    
+        public int ID { get; set; }
+        public int IDEmployee { get; set; }
+        public int IDExchange { get; set; }
+    
+        public virtual Exchange Exchange { get; set; }
+        public virtual Users Users { get; set; }
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Orders> Orders { get; set; }
+    }
+}

+ 25 - 0
Cafe2/Encrypt.cs

@@ -0,0 +1,25 @@
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Cafe
+{
+    internal class Encrypt
+    {
+        public static string Hash(string password)
+        {
+            byte[] bytes = Encoding.Unicode.GetBytes(password);
+
+            MD5CryptoServiceProvider CSP = new MD5CryptoServiceProvider();
+
+            byte[] byteHash = CSP.ComputeHash(bytes);
+
+            string hash = string.Empty;
+
+            foreach (byte b in byteHash)
+            {
+                hash += string.Format("{0:x2}", b);
+            }
+            return hash;
+        }
+    }
+}

+ 13 - 0
Cafe2/ErrorWindow.xaml

@@ -0,0 +1,13 @@
+<Window x:Class="Cafe.ErrorWindow"
+        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:Cafe"
+        mc:Ignorable="d"
+        Title="Ошибка" Height="100" Width="400" WindowStartupLocation="CenterScreen" WindowStyle="None" ResizeMode="CanMinimize">
+    <Grid>
+        <Button x:Name="BackButton" Content="Назад" VerticalAlignment="Top" HorizontalAlignment="Center" Height="30" Width="130" Margin="0,57,0,0" Click="BackClick"/>
+        <Label Name="Error" Content="Ошибка: " HorizontalAlignment="Center" Margin="0,18,0,0" VerticalAlignment="Top" Height="29" Width="354" Foreground="White"/>
+    </Grid>
+</Window>

+ 21 - 0
Cafe2/ErrorWindow.xaml.cs

@@ -0,0 +1,21 @@
+using System.Windows;
+
+namespace Cafe
+{
+    /// <summary>
+    /// Логика взаимодействия для ErrorWindow.xaml
+    /// </summary>
+    public partial class ErrorWindow : Window
+    {
+        public ErrorWindow(string error)
+        {
+            InitializeComponent();
+            Error.Content = "Ошибка: " + error;
+        }
+
+        private void BackClick(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+    }
+}

+ 31 - 0
Cafe2/Exchange.cs

@@ -0,0 +1,31 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Exchange
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+        public Exchange()
+        {
+            this.EmployeesExchanges = new HashSet<EmployeesExchanges>();
+        }
+    
+        public int ID { get; set; }
+        public System.DateTime Date { get; set; }
+        public System.TimeSpan TimeOfBegin { get; set; }
+        public System.TimeSpan TimeOfEnd { get; set; }
+    
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<EmployeesExchanges> EmployeesExchanges { get; set; }
+    }
+}

+ 50 - 0
Cafe2/ImagesManip.cs

@@ -0,0 +1,50 @@
+using Microsoft.Win32;
+using System;
+using System.IO;
+using System.Windows.Media.Imaging;
+
+namespace Cafe
+{
+    internal class ImagesManip
+    {
+        public static byte[] BitmapSourceToByteArray(BitmapSource image)
+        {
+            #region Кодирование картинки
+            using (var stream = new MemoryStream())
+            {
+                var encoder = new PngBitmapEncoder();
+                encoder.Frames.Add(BitmapFrame.Create(image));
+                encoder.Save(stream);
+                return stream.ToArray();
+            }
+            #endregion
+        }
+
+        public static BitmapImage SelectImage()
+        {
+            #region Выбор картинки
+            OpenFileDialog op = new OpenFileDialog();
+            op.Title = "Выбрать изображение";
+            op.Filter = "All supported graphics|*.jpg;*.jpeg;*.png|" +
+                        "JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg|" +
+                        "Portable Network Graphic (*.png)|*.png";
+            if (op.ShowDialog() == true)
+                return new BitmapImage(new Uri(op.FileName));
+            else
+                return null;
+            #endregion
+        }
+
+        public static BitmapImage NewImage(Dishes dish)
+        {
+            #region Декодирование картинки
+            MemoryStream ms = new MemoryStream(dish.Picture);
+            BitmapImage image = new BitmapImage();
+            image.BeginInit();
+            image.StreamSource = ms;
+            image.EndInit();
+            return image;
+            #endregion
+        }
+    }
+}

+ 28 - 0
Cafe2/ListWindows/EmployeesListWindow.xaml

@@ -0,0 +1,28 @@
+<Window x:Class="Cafe.ListWindows.EmployeesListWindow"
+        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:Cafe.ListWindows"
+        mc:Ignorable="d"
+        Title="Список сотрудников" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Button x:Name="BackButton" Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+        <DataGrid x:Name="EmployeesList" AutoGenerateColumns="False" Height="600" Margin="130,158,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="1340"
+            RowHeaderStyle="{StaticResource RowHeaderStyle}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}">
+            <DataGrid.ItemContainerStyle>
+                <Style TargetType="{x:Type DataGridRow}">
+                    <EventSetter Event="Control.MouseDoubleClick" Handler="EmployeesListMouseDoubleClick"/>
+                </Style>
+            </DataGrid.ItemContainerStyle>
+            <DataGrid.Columns>
+                <DataGridTextColumn Binding="{Binding SecondName}" Header="Фамлия" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding FirstName}" Header="Имя" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding MiddleName}" Header="Отчество" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding Roles.RoleName}" Header="Должность" Width="330" IsReadOnly="True"/>
+            </DataGrid.Columns>
+        </DataGrid>
+        <TextBox x:Name="Search" HorizontalAlignment="Left" Margin="130,99,0,0" TextWrapping="Wrap" Text="Поиск" VerticalAlignment="Top" Width="1340" Height="30" FontSize="20" 
+            Foreground="#FF675B5B" PreviewMouseLeftButtonUp="SearchPreviewMouseLeftButtonUp" LostFocus="SearchLostFocus" TextChanged="SearchTextChanged"/>
+    </Grid>
+</Window>

+ 58 - 0
Cafe2/ListWindows/EmployeesListWindow.xaml.cs

@@ -0,0 +1,58 @@
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using Cafe.ElementsWindows;
+
+namespace Cafe.ListWindows
+{
+    public partial class EmployeesListWindow : Window
+    {
+        public EmployeesListWindow()
+        {
+            InitializeComponent();
+
+            EmployeesList.ItemsSource = Connection.db.Users.ToList();
+        }
+
+        private void EmployeesListMouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            int id = ((Users)EmployeesList.SelectedItem).ID;
+            EmployeeWindow employeeWindow = new EmployeeWindow(id);
+            employeeWindow.Show();
+            this.Hide();
+        }
+
+        private void SearchPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            if (Search.Text == "Поиск")
+                Search.Text = "";
+        }
+
+        private void SearchLostFocus(object sender, RoutedEventArgs e)
+        {
+            if (Search.Text == "")
+                Search.Text = "Поиск";
+        }
+
+        private void SearchTextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (Search.Text != "" && Search.Text != "Поиск")
+            {
+                EmployeesList.ItemsSource = Connection.db.Users.Where(item => (item.Login + " " + item.SecondName + " " + item.FirstName + " "
+                                                                               + item.MiddleName + " " + item.Email).Contains(Search.Text)).ToList();
+            }
+            else if (Search.Text == "" || Search.Text == "Поиск")
+            {
+                EmployeesList.ItemsSource = Connection.db.Users.ToList();
+            }
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 28 - 0
Cafe2/ListWindows/ExchangesListWindow.xaml

@@ -0,0 +1,28 @@
+<Window x:Class="Cafe.ListWindows.ExchangesListWindow"
+        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:Cafe.ListWindows"
+        mc:Ignorable="d"
+        Title="Список смен" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Button x:Name="BackButton" Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+        <DataGrid x:Name="ExchangesList" AutoGenerateColumns="False" Height="600" Margin="0,158,0,0" VerticalAlignment="Top" HorizontalAlignment="Center" Width="1340"
+            RowHeaderStyle="{StaticResource RowHeaderStyle}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}">
+            <DataGrid.ItemContainerStyle>
+                <Style TargetType="{x:Type DataGridRow}">
+                    <EventSetter Event="Control.MouseDoubleClick" Handler="ExchangesListMouseDoubleClick"/>
+                </Style>
+            </DataGrid.ItemContainerStyle>
+            <DataGrid.Columns>
+                <DataGridTextColumn Binding="{Binding ID}" Header="Номер" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding Date}" Header="Дата" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding TimeOfBegin}" Header="Время начала" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding TimeOfEnd}" Header="Время окончания" Width="330" IsReadOnly="True"/>
+            </DataGrid.Columns>
+        </DataGrid>
+        <TextBox x:Name="Search" HorizontalAlignment="Center" Margin="0,99,0,0" TextWrapping="Wrap" Text="Поиск" VerticalAlignment="Top" Width="1340" Height="30" FontSize="20" 
+            Foreground="#FF675B5B" PreviewMouseLeftButtonUp="SearchPreviewMouseLeftButtonUp" LostFocus="SearchLostFocus" TextChanged="SearchTextChanged"/>
+    </Grid>
+</Window>

+ 59 - 0
Cafe2/ListWindows/ExchangesListWindow.xaml.cs

@@ -0,0 +1,59 @@
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using Cafe.ElementsWindows;
+
+namespace Cafe.ListWindows
+{
+    public partial class ExchangesListWindow : Window
+    {
+        public ExchangesListWindow()
+        {
+            InitializeComponent();
+
+            ExchangesList.ItemsSource = Connection.db.Exchange.ToList();
+        }
+
+        private void ExchangesListMouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            int id = ((Exchange)ExchangesList.SelectedItem).ID;
+            ExchangeWindow exchangeWindow = new ExchangeWindow(id);
+            exchangeWindow.Show();
+            this.Hide();
+        }
+
+        private void SearchPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            if (Search.Text == "Поиск")
+                Search.Text = "";
+        }
+
+        private void SearchLostFocus(object sender, RoutedEventArgs e)
+        {
+            if (Search.Text == "")
+                Search.Text = "Поиск";
+        }
+
+        private void SearchTextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (Search.Text != "" && Search.Text != "Поиск")
+            {
+                ExchangesList.ItemsSource = Connection.db.EmployeesExchanges.Where(item => (item.Users.Login + " " + item.Users.SecondName + " " + item.Users.FirstName + " "
+                                                                                + item.Users.MiddleName + " " + item.Exchange.ID + " " + item.Exchange.Date + " "
+                                                                                + item.Exchange.TimeOfBegin + " " + item.Exchange.TimeOfEnd).Contains(Search.Text)).ToList();
+            }
+            else if (Search.Text == "" || Search.Text == "Поиск")
+            {
+                ExchangesList.ItemsSource = Connection.db.Exchange.ToList();
+            }
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 28 - 0
Cafe2/ListWindows/OrdersListWindow.xaml

@@ -0,0 +1,28 @@
+<Window x:Class="Cafe.ListWindows.OrdersListWindow"
+        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:Cafe.ListWindows"
+        mc:Ignorable="d"
+        Title="Список заказов" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <Button x:Name="BackButton" Content="Назад" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="39" Width="140" FontSize="25" Click="BackButtonClick"/>
+        <DataGrid x:Name="OrdersList" AutoGenerateColumns="False" Height="600" Margin="0,158,0,0" VerticalAlignment="Top" HorizontalAlignment="Center" Width="1340"
+            RowHeaderStyle="{StaticResource RowHeaderStyle}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}">
+            <DataGrid.ItemContainerStyle>
+                <Style TargetType="DataGridRow">
+                    <EventSetter Event="MouseDoubleClick" Handler="OrdersListMouseDoubleClick"/>
+                </Style>
+            </DataGrid.ItemContainerStyle>
+            <DataGrid.Columns>
+                <DataGridTextColumn Binding="{Binding IDTable}" Header="Столик" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding EmployeesExchanges.Users.SecondName}" Header="Официант" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding Time}" Header="Время" Width="330" IsReadOnly="True"/>
+                <DataGridTextColumn Binding="{Binding SumOfOrder}" Header="Сумма" Width="330" IsReadOnly="True"/>
+            </DataGrid.Columns>
+        </DataGrid>
+        <TextBox x:Name="Search" HorizontalAlignment="Center" Margin="0,99,0,0" TextWrapping="Wrap" Text="Поиск" VerticalAlignment="Top" Width="1340" Height="30" FontSize="20" 
+            Foreground="#FF675B5B" PreviewMouseLeftButtonUp="SearchPreviewMouseLeftButtonUp" LostFocus="SearchLostFocus" TextChanged="SearchTextChanged"/>
+    </Grid>
+</Window>

+ 105 - 0
Cafe2/ListWindows/OrdersListWindow.xaml.cs

@@ -0,0 +1,105 @@
+using System;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using Cafe.ElementsWindows;
+
+namespace Cafe.ListWindows
+{
+    public partial class OrdersListWindow : Window
+    {
+        Exchange exchange;
+
+        public OrdersListWindow()
+        {
+            exchange = GetExchange();
+
+            if (exchange is null)
+            {
+                ErrorWindow errorWindow = new ErrorWindow("сейчас нет смены");
+                errorWindow.Show();
+                return;
+            }
+
+            InitializeComponent();
+
+            if (User.Role == 2)
+            {
+                OrdersList.ItemsSource = Connection.db.Orders.Where(item => item.EmployeesExchanges.IDExchange == exchange.ID).ToList();
+            }
+            else if (User.Role == 3)
+            {
+                OrdersList.ItemsSource = Connection.db.Orders.Where(item => item.EmployeesExchanges.IDExchange == exchange.ID && !item.IsReady).ToList();
+                BackButton.Visibility = Visibility.Hidden;
+            }
+
+        }
+
+        private Exchange GetExchange()
+        {
+            DateTime now = DateTime.Now;
+
+            return Connection.db.Exchange.Where(item => item.Date == now.Date && item.TimeOfBegin <= now.TimeOfDay && item.TimeOfEnd >= now.TimeOfDay).FirstOrDefault();
+        }
+
+        private void OrdersListMouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            int id = ((Orders)OrdersList.SelectedItem).ID;
+            OrderWindow orderWindow = new OrderWindow(id);
+            orderWindow.Show();
+            this.Hide();
+        }
+
+        private void SearchPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            if (Search.Text == "Поиск")
+                Search.Text = "";
+        }
+
+        private void SearchLostFocus(object sender, RoutedEventArgs e)
+        {
+            if (Search.Text == "")
+                Search.Text = "Поиск";
+        }
+
+        private void SearchTextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (Search.Text != "" && Search.Text != "Поиск")
+            {
+                if (User.Role == 2)
+                {
+                    OrdersList.ItemsSource = Connection.db.Orders.Where(item => (item.IDTable + " " + item.EmployeesExchanges.Users.SecondName + " "
+                                                                                + item.EmployeesExchanges.Users.FirstName + " " + item.EmployeesExchanges.Users.MiddleName + " "
+                                                                                + item.Time + " " + item.SumOfOrder).Contains(Search.Text)
+                                                                                && item.EmployeesExchanges.IDExchange == exchange.ID).ToList();
+                }
+                else if (User.Role == 3)
+                {
+                    OrdersList.ItemsSource = Connection.db.Orders.Where(item => (item.IDTable + " " + item.EmployeesExchanges.Users.SecondName + " "
+                                                                                + item.EmployeesExchanges.Users.FirstName + " " + item.EmployeesExchanges.Users.MiddleName + " "
+                                                                                + item.Time + " " + item.SumOfOrder).Contains(Search.Text) && !item.IsReady
+                                                                                && item.EmployeesExchanges.IDExchange == exchange.ID).ToList();
+                }
+            }
+            else if (Search.Text == "" || Search.Text == "Поиск")
+            {
+                if (User.Role == 2)
+                {
+                    OrdersList.ItemsSource = Connection.db.Orders.Where(item => item.EmployeesExchanges.IDExchange == exchange.ID).ToList();
+                }
+                else if (User.Role == 3)
+                {
+                    OrdersList.ItemsSource = Connection.db.Orders.Where(item => item.EmployeesExchanges.IDExchange == exchange.ID && !item.IsReady).ToList();
+                }
+            }
+        }
+
+        private void BackButtonClick(object sender, RoutedEventArgs e)
+        {
+            MainWindow mainWindow = new MainWindow();
+            mainWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 29 - 0
Cafe2/MainWindow.xaml

@@ -0,0 +1,29 @@
+<Window x:Class="Cafe.MainWindow"
+        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:Cafe"
+        mc:Ignorable="d"
+        Title="Основное окно" Height="900" Width="1600" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize">
+    <Grid>
+        <TabControl Name="UsersTab" BorderThickness="0">
+            <TabItem Name="Waiter" Header="Официант" Height="20" Width="100" Background="#FF4F5856">
+                <Grid Margin="-3,-22,-3,-2">
+                    <Button x:Name="AddOrder" Content="Новый заказ" HorizontalAlignment="Center" Margin="0,302,0,0" VerticalAlignment="Top" Height="70" Width="530" FontSize="36" Click="AddOrderClick"/>
+                    <Button x:Name="OrdersList" Content="История заказов" HorizontalAlignment="Center" Margin="0,394,0,0" VerticalAlignment="Top" Height="70" Width="530" FontSize="36" Click="OrdersListClick"/>
+                    <!--<Button x:Name="AddWaiterReport" Content="Отчет официанта" HorizontalAlignment="Center" Margin="0,486,0,0" VerticalAlignment="Top" Height="70" Width="530" FontSize="36" Click="AddWaiterReportClick"/>-->
+                </Grid>
+            </TabItem>
+            <TabItem Name="Administrator" Header="Администратор" Height="20" Width="100" Background="#FF4F5856">
+                <Grid Margin="-3,-22,-3,-2">
+                    <Button Name="AddEmployee" Content="Зарегистрировать сотрудника" HorizontalAlignment="Center" Margin="0,218,0,0" VerticalAlignment="Top" Height="70" Width="530" Click="AddEmployeeClick" FontSize="36"/>
+                    <Button Name="EmployeesList" Content="Сотрудники" HorizontalAlignment="Center" Margin="0,310,0,0" VerticalAlignment="Top" Height="70" Width="530" FontSize="36" Click="EmployeesListClick"/>
+                    <Button Name="ExchangesList" Content="Смены" HorizontalAlignment="Center" VerticalAlignment="Top" Height="70" Width="530" FontSize="36" Click="ExchangesListClick" Margin="0,402,0,0"/>
+                    <Button Name="AddExchange" Content="Сформировать смену" HorizontalAlignment="Center" VerticalAlignment="Top" Height="70" Width="530" FontSize="36" Click="AddExchangeClick" Margin="0,494,0,0"/>
+                    <Button Name="AddDish" Content="Добавить блюдо" HorizontalAlignment="Center" VerticalAlignment="Top" Height="70" Width="530" FontSize="36" Click="AddDishClick" Margin="0,586,0,0"/>
+                </Grid>
+            </TabItem>
+        </TabControl>
+    </Grid>
+</Window>

+ 72 - 0
Cafe2/MainWindow.xaml.cs

@@ -0,0 +1,72 @@
+using System.Windows;
+using Cafe.ListWindows;
+using Cafe.AddWindows;
+
+namespace Cafe
+{
+    public partial class MainWindow : Window
+    {
+        public MainWindow()
+        {
+            InitializeComponent();
+            if (User.Role == 1)
+            {
+                Waiter.Visibility = Visibility.Hidden;
+                UsersTab.SelectedItem = Administrator;
+            }
+            else if (User.Role == 2)
+            {
+                Administrator.Visibility = Visibility.Hidden;
+                UsersTab.SelectedItem = Waiter;
+            }
+        }
+
+        private void AddEmployeeClick(object sender, RoutedEventArgs e)
+        {
+            AddEmployeeWindow addEmployeeWindow = new AddEmployeeWindow();
+            addEmployeeWindow.Show();
+            this.Close();
+        }
+        private void EmployeesListClick(object sender, RoutedEventArgs e)
+        {
+            EmployeesListWindow employeesListWindow = new EmployeesListWindow();
+            employeesListWindow.Show();
+            this.Close();
+        }
+
+        private void ExchangesListClick(object sender, RoutedEventArgs e)
+        {
+            ExchangesListWindow exchangesListWindow = new ExchangesListWindow();
+            exchangesListWindow.Show();
+            this.Close();
+        }
+
+        private void AddExchangeClick(object sender, RoutedEventArgs e)
+        {
+            AddExchangeWindow addExchangeWindow = new AddExchangeWindow();
+            addExchangeWindow.Show();
+            this.Close();
+        }
+
+        private void AddDishClick(object sender, RoutedEventArgs e)
+        {
+            AddDishWindow addDishWindow = new AddDishWindow();
+            addDishWindow.Show();
+            this.Close();
+        }
+
+        private void AddOrderClick(object sender, RoutedEventArgs e)
+        {
+            AddOrderWindow addOrderWindow = new AddOrderWindow();
+            addOrderWindow.Show();
+            this.Close();
+        }
+
+        private void OrdersListClick(object sender, RoutedEventArgs e)
+        {
+            OrdersListWindow ordersListWindow = new OrdersListWindow();
+            ordersListWindow.Show();
+            this.Close();
+        }
+    }
+}

+ 24 - 0
Cafe2/OrderDishes.cs

@@ -0,0 +1,24 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class OrderDishes
+    {
+        public int ID { get; set; }
+        public int IDOrder { get; set; }
+        public int IDDish { get; set; }
+    
+        public virtual Dishes Dishes { get; set; }
+        public virtual Orders Orders { get; set; }
+    }
+}

+ 36 - 0
Cafe2/Orders.cs

@@ -0,0 +1,36 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Orders
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+        public Orders()
+        {
+            this.OrderDishes = new HashSet<OrderDishes>();
+        }
+    
+        public int ID { get; set; }
+        public int IDEmployeeExchange { get; set; }
+        public int IDTable { get; set; }
+        public System.DateTime Time { get; set; }
+        public decimal SumOfOrder { get; set; }
+        public bool IsPaid { get; set; }
+        public bool IsReady { get; set; }
+    
+        public virtual EmployeesExchanges EmployeesExchanges { get; set; }
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<OrderDishes> OrderDishes { get; set; }
+        public virtual Tables Tables { get; set; }
+    }
+}

+ 55 - 0
Cafe2/Properties/AssemblyInfo.cs

@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// Общие сведения об этой сборке предоставляются следующим набором
+// набор атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
+// связанные со сборкой.
+[assembly: AssemblyTitle("Cafe")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Cafe")]
+[assembly: AssemblyCopyright("Copyright ©  2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
+// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
+// из модели COM, установите атрибут ComVisible для этого типа в значение true.
+[assembly: ComVisible(false)]
+
+//Чтобы начать создание локализуемых приложений, задайте
+//<UICulture>CultureYouAreCodingWith</UICulture> в файле .csproj
+//в <PropertyGroup>. Например, при использовании английского (США)
+//в своих исходных файлах установите <UICulture> в en-US.  Затем отмените преобразование в комментарий
+//атрибута NeutralResourceLanguage ниже.  Обновите "en-US" в
+//строка внизу для обеспечения соответствия настройки UICulture в файле проекта.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+    ResourceDictionaryLocation.None, //где расположены словари ресурсов по конкретным тематикам
+                                     //(используется, если ресурс не найден на странице,
+                                     // или в словарях ресурсов приложения)
+    ResourceDictionaryLocation.SourceAssembly //где расположен словарь универсальных ресурсов
+                                              //(используется, если ресурс не найден на странице,
+                                              // в приложении или в каких-либо словарях ресурсов для конкретной темы)
+)]
+
+
+// Сведения о версии для сборки включают четыре следующих значения:
+//
+//      Основной номер версии
+//      Дополнительный номер версии
+//      Номер сборки
+//      Номер редакции
+//
+// Можно задать все значения или принять номера сборки и редакции по умолчанию 
+// используя "*", как показано ниже:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
Cafe2/Properties/Resources.Designer.cs

@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код был создан программным средством.
+//     Версия среды выполнения: 4.0.30319.42000
+//
+//     Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
+//     код создан повторно.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe.Properties
+{
+
+
+    /// <summary>
+    ///   Класс ресурсов со строгим типом для поиска локализованных строк и пр.
+    /// </summary>
+    // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
+    // класс с помощью таких средств, как ResGen или Visual Studio.
+    // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
+    // с параметром /str или заново постройте свой VS-проект.
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources
+    {
+
+        private static global::System.Resources.ResourceManager resourceMan;
+
+        private static global::System.Globalization.CultureInfo resourceCulture;
+
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources()
+        {
+        }
+
+        /// <summary>
+        ///   Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Cafe.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   Переопределяет свойство CurrentUICulture текущего потока для всех
+        ///   подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
Cafe2/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 30 - 0
Cafe2/Properties/Settings.Designer.cs

@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe.Properties
+{
+
+
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+    {
+
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+        public static Settings Default
+        {
+            get
+            {
+                return defaultInstance;
+            }
+        }
+    }
+}

+ 7 - 0
Cafe2/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 29 - 0
Cafe2/Roles.cs

@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Roles
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+        public Roles()
+        {
+            this.Users = new HashSet<Users>();
+        }
+    
+        public int ID { get; set; }
+        public string RoleName { get; set; }
+    
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Users> Users { get; set; }
+    }
+}

+ 121 - 0
Cafe2/Style.xaml

@@ -0,0 +1,121 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+                    xmlns:local="clr-namespace:Cafe">
+    <!--#region Оформление окна-->
+    <Style TargetType="Grid">
+        <Setter Property="Background">
+            <Setter.Value>
+                <RadialGradientBrush MappingMode="RelativeToBoundingBox" GradientOrigin="0.9,0.2" Center="0.5,0.5" RadiusX="0.7" RadiusY="0.7">
+                    <GradientStop Color="#FF1B1B15" Offset="1"/>
+                    <GradientStop Color="#FF142F2C"/>
+                </RadialGradientBrush>
+            </Setter.Value>
+        </Setter>
+    </Style>
+    <!--#endregion-->
+
+    <!--#region Оформление листбокса-->
+    <Style TargetType="ListBox">
+        <Setter Property="Background">
+            <Setter.Value>
+                <RadialGradientBrush MappingMode="RelativeToBoundingBox" GradientOrigin="0.9,0.2" Center="0.5,0.5" RadiusX="0.7" RadiusY="0.7">
+                    <GradientStop Color="#FF1B1B15" Offset="1"/>
+                    <GradientStop Color="#FF142F2C"/>
+                </RadialGradientBrush>
+            </Setter.Value>
+        </Setter>
+    </Style>
+    <!--#endregion-->
+
+    <!--#region Стиль кнопки-->
+    <Style TargetType="Button">
+
+        <!--Текст-->
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="Button">
+                    <Grid Background="{TemplateBinding Background}">
+                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                    </Grid>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+
+        <!--Тень-->
+        <Setter Property="Effect">
+            <Setter.Value>
+                <DropShadowEffect/>
+            </Setter.Value>
+        </Setter>
+
+        <!--Скруглённые углы-->
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="Button">
+                    <Border CornerRadius="15" BorderBrush="Black">
+                        <Border.Background>
+                            <RadialGradientBrush MappingMode="RelativeToBoundingBox" GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0" RadiusY="0">
+                                <GradientStop Color="#787d7c" Offset="0"/>
+                                <GradientStop Color="#4f5856" Offset="1"/>
+                            </RadialGradientBrush>
+                        </Border.Background>
+                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
+                    </Border>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+
+        <!--Анимации-->
+        <Style.Triggers>
+
+            <!--Анимация при нажатии-->
+            <EventTrigger RoutedEvent="Button.PreviewMouseLeftButtonDown">
+                <EventTrigger.Actions>
+                    <BeginStoryboard>
+                        <Storyboard Duration="0:0:1" SpeedRatio="3" FillBehavior="HoldEnd">
+                            <!--<DoubleAnimation Storyboard.TargetName="{Binding ElementName=Border}" Storyboard.TargetProperty="Background.RadiusY" To="1.0"/>
+                            <DoubleAnimation Storyboard.TargetName="{Binding ElementName=Border}" Storyboard.TargetProperty="Background.RadiusY" To="1.0"/>-->
+                            <DoubleAnimation Storyboard.TargetProperty="Effect.Opacity" To="0"/>
+                        </Storyboard>
+                    </BeginStoryboard>
+                </EventTrigger.Actions>
+            </EventTrigger>
+
+            <!--Анимация при отпускании-->
+            <EventTrigger RoutedEvent="PreviewMouseLeftButtonUp">
+                <EventTrigger.Actions>
+                    <BeginStoryboard>
+                        <Storyboard Duration="0:0:1" SpeedRatio="3" FillBehavior="HoldEnd">
+                            <!--<DoubleAnimation Storyboard.TargetName="{Binding ElementName=Border}" Storyboard.TargetProperty="Background.RadiusX" To="0"/>
+                            <DoubleAnimation Storyboard.TargetName="{Binding ElementName=Border}" Storyboard.TargetProperty="Background.RadiusY" To="0"/>-->
+                            <DoubleAnimation Storyboard.TargetProperty="Effect.Opacity" To="1"/>
+                        </Storyboard>
+                    </BeginStoryboard>
+                </EventTrigger.Actions>
+            </EventTrigger>
+        </Style.Triggers>
+    </Style>
+    <!--#endregion-->
+
+    <!--#region Оформление датагрида-->
+    <!--Поля-->
+    <Style TargetType="DataGrid">
+        <Setter Property="FontSize" Value="20"/>
+        <Setter Property="Foreground" Value="White"/>
+        <Setter Property="RowBackground" Value="Transparent"/>
+        <Setter Property="BorderBrush" Value="Transparent"/>
+        <Setter Property="Background" Value="Transparent"/>
+    </Style>
+
+    <!--Заголовки столбцов-->
+    <Style x:Key="ColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}">
+        <Setter Property="Background" Value="Transparent" />
+        <Setter Property="FontWeight" Value="Bold"/>
+    </Style>
+
+    <!--Заголовки строк-->
+    <Style x:Key="RowHeaderStyle" TargetType="{x:Type DataGridRowHeader}">
+        <Setter Property="Background" Value="Transparent" />
+    </Style>
+    <!--#endregion-->
+</ResourceDictionary>

+ 28 - 0
Cafe2/Tables.cs

@@ -0,0 +1,28 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Tables
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+        public Tables()
+        {
+            this.Orders = new HashSet<Orders>();
+        }
+    
+        public int ID { get; set; }
+    
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Orders> Orders { get; set; }
+    }
+}

+ 8 - 0
Cafe2/User.cs

@@ -0,0 +1,8 @@
+namespace Cafe
+{
+    internal class User
+    {
+        static public int IDUser { get; set; }
+        static public int Role { get; set; }
+    }
+}

+ 37 - 0
Cafe2/Users.cs

@@ -0,0 +1,37 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Users
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+        public Users()
+        {
+            this.EmployeesExchanges = new HashSet<EmployeesExchanges>();
+        }
+    
+        public int ID { get; set; }
+        public string Login { get; set; }
+        public string Password { get; set; }
+        public string SecondName { get; set; }
+        public string FirstName { get; set; }
+        public string MiddleName { get; set; }
+        public string Email { get; set; }
+        public bool IsFired { get; set; }
+        public int IDRole { get; set; }
+    
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<EmployeesExchanges> EmployeesExchanges { get; set; }
+        public virtual Roles Roles { get; set; }
+    }
+}

+ 5 - 0
Cafe2/packages.config

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="EntityFramework" version="6.2.0" targetFramework="net472" />
+  <package id="EntityFramework.ru" version="6.2.0" targetFramework="net472" />
+</packages>

+ 23 - 0
Cafe2/sysdiagrams.cs

@@ -0,0 +1,23 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Cafe
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class sysdiagrams
+    {
+        public string name { get; set; }
+        public int principal_id { get; set; }
+        public int diagram_id { get; set; }
+        public Nullable<int> version { get; set; }
+        public byte[] definition { get; set; }
+    }
+}