Browse Source

Интерфейс звонка, лида

gr671_kyaa 5 years ago
parent
commit
38e9c0a31e

+ 1 - 0
LoadedToTheGills/Call.cs

@@ -19,6 +19,7 @@ namespace LoadedToTheGills
         public Nullable<int> LongCall { get; set; }
         public Nullable<int> idLead { get; set; }
         public Nullable<int> idUser { get; set; }
+        public string Comment { get; set; }
     
         public virtual Lead Lead { get; set; }
         public virtual Users Users { get; set; }

+ 38 - 2
LoadedToTheGills/CallWindow.xaml

@@ -5,6 +5,42 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:LoadedToTheGills"
         mc:Ignorable="d"
-        Title="CallWindow" Height="450" Width="367">
-    <Grid/>
+        Title="CallWindow" WindowStartupLocation="CenterScreen" Height="450" Width="648" Loaded="Window_Loaded">
+    <Grid Margin="0">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="70"/>
+            <RowDefinition/>
+            <RowDefinition Height="50"/>
+        </Grid.RowDefinitions>
+        <Rectangle Fill="#FF3F3FA8" Stroke="Black" Grid.Row="2"/>
+        <Rectangle Fill="#FF3F3FA8" Stroke="Black" Margin="0"/>
+        <Grid Height="279" Margin="10,10,10,0" Grid.Row="1" VerticalAlignment="Top">
+            <Grid.RowDefinitions>
+                <RowDefinition/>
+                <RowDefinition/>
+                <RowDefinition Height="40"/>
+            </Grid.RowDefinitions>
+            <DataGrid x:Name="callChange" Height="120" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16" AutoGenerateColumns="False">
+                <DataGrid.Columns>
+                    <DataGridTextColumn Binding="{Binding CallDate}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="CallDate"/>
+                    <DataGridTextColumn Binding="{Binding LongCall}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="LongTime"/>
+                    <DataGridTextColumn Binding="{Binding Lead.idLead}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="IdLead"/>
+                    <DataGridTextColumn Binding="{Binding Lead.StatusLead}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="LeadStatus"/>
+                    <DataGridTextColumn Binding="{Binding Users.Login}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="User"/>
+                    <DataGridTextColumn Binding="{Binding Comment}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Comment"/>
+                </DataGrid.Columns>
+            </DataGrid>
+            <Label Content="Дата звонка:" HorizontalAlignment="Left" Margin="25,5,0,0" Grid.Row="1" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16"/>
+            <Label Content="Длительность:" HorizontalAlignment="Left" Margin="10,33,0,0" Grid.Row="1" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16"/>
+            <Label Content="Номер лида:" HorizontalAlignment="Left" Margin="25,61,0,0" Grid.Row="1" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16"/>
+            <Label Content="Комментарий:" HorizontalAlignment="Left" Margin="13,89,0,0" Grid.Row="1" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16"/>
+            <TextBox x:Name="txtBoxDate" HorizontalAlignment="Left" Height="23" Margin="125,10,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="485" FontFamily="Times New Roman" FontSize="14"/>
+            <TextBox x:Name="txtBoxLong" HorizontalAlignment="Left" Height="23" Margin="125,38,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="485" FontFamily="Times New Roman" FontSize="14"/>
+            <TextBox x:Name="txtBoxLead" HorizontalAlignment="Left" Height="23" Margin="125,66,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="485" FontFamily="Times New Roman" FontSize="14"/>
+            <TextBox x:Name="txtBoxComm" HorizontalAlignment="Left" Height="23" Margin="125,94,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="485" FontFamily="Times New Roman" FontSize="14"/>
+            <Button Content="Update" HorizontalAlignment="Left" Margin="479,8,0,0" Grid.Row="2" VerticalAlignment="Top" Width="131" FontFamily="Times New Roman" FontSize="16" Height="26" Click="Button_Click"/>
+        </Grid>
+        <Button Content="Back" HorizontalAlignment="Left" Margin="491,10,0,0" Grid.Row="2" VerticalAlignment="Top" Width="130" Height="30" FontFamily="Times New Roman" FontSize="16" Click="Button_Click_1"/>
+    </Grid>
 </Window>
+ 

+ 41 - 0
LoadedToTheGills/CallWindow.xaml.cs

@@ -19,9 +19,50 @@ namespace LoadedToTheGills
     /// </summary>
     public partial class CallWindow : Window
     {
+        gr671_kyaaEntities Entity;
+
+        public Int32 IdLabel { get; set; }
+
         public CallWindow()
         {
             InitializeComponent();
+            Entity = new gr671_kyaaEntities();
+           
+         }
+
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            int id_ = IdLabel;
+            var calls = Entity.Call.ToList();
+            callChange.ItemsSource = calls.Where(id => id.idCall == id_);
+            txtBoxDate.Text = DateTime.Now.ToString();
+           
+        }
+
+        
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            int id_ = IdLabel;
+            var calls = Entity.Call.ToList();
+            var idRow = Entity.Call.Where(grechka => grechka.idCall == id_).FirstOrDefault();
+            idRow.CallDate = Convert.ToDateTime(txtBoxDate.Text);
+            idRow.LongCall = Convert.ToInt32(txtBoxLong.Text);
+            idRow.idLead = Convert.ToInt32(txtBoxLead.Text);
+            idRow.Comment = txtBoxComm.Text;
+            Entity.SaveChanges();
+            callChange.ItemsSource = calls.Where(id => id.idCall == id_);
+        }
+
+        private void Button_Click_1(object sender, RoutedEventArgs e)
+        {
+            int id_ = IdLabel;
+            Menu main = new Menu();
+            var userId = Entity.Call.Where(x => x.idCall == id_).Select(y => y.idUser).FirstOrDefault();
+            var Login = Entity.Users.Where(x => x.idUser == userId).Select(y => y.Login).FirstOrDefault();
+            main.LabelText = Convert.ToString(Login);
+            main.Show();
+            this.Hide();
         }
     }
 }

+ 4 - 0
LoadedToTheGills/Lead.cs

@@ -25,10 +25,14 @@ namespace LoadedToTheGills
         public string StatusLead { get; set; }
         public int idClient { get; set; }
         public int idProduct { get; set; }
+        public string Comment { get; set; }
+        public Nullable<int> idUser { get; set; }
+        public bool IsCalled { get; set; }
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Call> Call { get; set; }
         public virtual Clients Clients { get; set; }
         public virtual Products Products { get; set; }
+        public virtual Users Users { get; set; }
     }
 }

+ 52 - 0
LoadedToTheGills/LeadWindow.xaml

@@ -0,0 +1,52 @@
+<Window x:Class="LoadedToTheGills.LeadWindow"
+        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:LoadedToTheGills"
+        mc:Ignorable="d"
+        Title="LeadWindow" WindowStartupLocation="CenterScreen" Height="450" Width="657.902" Loaded="Window_Loaded">
+    <Grid Margin="0">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="70"/>
+            <RowDefinition/>
+            <RowDefinition Height="50"/>
+        </Grid.RowDefinitions>
+        <Rectangle Fill="#FF3F3FA8" Stroke="Black" Grid.Row="2"/>
+        <Rectangle Fill="#FF3F3FA8" Stroke="Black" Margin="0"/>
+        <Grid Height="279" Margin="10,10,10,0" Grid.Row="1" VerticalAlignment="Top">
+            <Grid.RowDefinitions>
+                <RowDefinition/>
+                <RowDefinition/>
+                <RowDefinition Height="40"/>
+            </Grid.RowDefinitions>
+            <DataGrid x:Name="leadChange" Height="120" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16" AutoGenerateColumns="False">
+                <DataGrid.Columns>
+                    <DataGridTextColumn Binding="{Binding idLead}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Id"/>
+                    <DataGridTextColumn Binding="{Binding idUser}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="LeadOwner"/>
+                    <DataGridTextColumn Binding="{Binding LeadStart}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="LeadStart"/>
+                    <DataGridTextColumn Binding="{Binding Clients.PhoneNumbers}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="ClientPhone"/>
+                    <DataGridTextColumn Binding="{Binding StatusLead}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Status"/>
+                    <DataGridTextColumn Binding="{Binding Products.ProductTitle}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Product"/>
+                    <DataGridTextColumn Binding="{Binding IsCalled}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="IsCalled"/>
+                    <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Skills"/>
+                    <DataGridTextColumn Binding="{Binding Comment}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Comment"/>
+                </DataGrid.Columns>
+            </DataGrid>
+            <Label Content="Дата лида:" HorizontalAlignment="Left" Margin="38,5,0,0" Grid.Row="1" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16"/>
+            <Label Content="Статус:" HorizontalAlignment="Left" Margin="59,33,0,0" Grid.Row="1" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16"/>
+            <Label Content="Пользователь:" HorizontalAlignment="Left" Margin="13,61,0,0" Grid.Row="1" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16"/>
+            <Label Content="Комментарий:" HorizontalAlignment="Left" Margin="13,89,0,0" Grid.Row="1" VerticalAlignment="Top" FontFamily="Times New Roman" FontSize="16"/>
+            <TextBox x:Name="txtBoxDate" HorizontalAlignment="Left" Height="23" Margin="125,10,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="485" FontFamily="Times New Roman" FontSize="14"/>
+            <TextBox x:Name="txtBoxComm" HorizontalAlignment="Left" Height="23" Margin="125,94,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" Width="485" FontFamily="Times New Roman" FontSize="14"/>
+            <ComboBox x:Name="userBox" ItemsSource="{Binding Users}" DisplayMemberPath="Login" SelectedValuePath="idUser" HorizontalAlignment="Left" Margin="125,67,0,0" Grid.Row="1" VerticalAlignment="Top" Width="485" SelectionChanged="UserBox_SelectionChanged"/>
+            <Button Content="Update" Name ="updateButton"  HorizontalAlignment="Left" Margin="482,6,0,0" Grid.Row="2" FontFamily="Times New Roman" FontSize="16" VerticalAlignment="Top" Width="128" Height="30" Click="UpdateButton_Click"/>
+            <ComboBox x:Name="leadStatus" HorizontalAlignment="Left" Margin="125,38,0,0" Grid.Row="1" VerticalAlignment="Top" Width="485">
+                <ListBoxItem Content="Активный"/>
+                <ListBoxItem Content="Неактивный"/>
+            </ComboBox>
+        </Grid>
+        <Button Content="Back" HorizontalAlignment="Left" Margin="491,10,0,0" Grid.Row="2" VerticalAlignment="Top" Width="130" Height="30" FontFamily="Times New Roman" FontSize="16" Click="Button_Click_1"/>
+        <Label x:Name="LoginLabel" Content="*LOGIN*" HorizontalAlignment="Left" Margin="502,19,0,0" VerticalAlignment="Top" Foreground="White" FontFamily="Times New Roman" FontSize="20" Width="138"/>
+    </Grid>
+</Window>

+ 93 - 0
LoadedToTheGills/LeadWindow.xaml.cs

@@ -0,0 +1,93 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace LoadedToTheGills
+{
+    /// <summary>
+    /// Логика взаимодействия для LeadWindow.xaml
+    /// </summary>
+    public partial class LeadWindow : Window
+    {
+
+        gr671_kyaaEntities Entity;
+
+        private int IdToLogin = 0;
+        private string login;
+
+        public Int32 IdLabel { get; set; }
+        public String LogLabel { get; set; }
+
+        public LeadWindow()
+        {
+            InitializeComponent();
+            Entity = new gr671_kyaaEntities();
+            
+        }
+
+        private void Button_Click_1(object sender, RoutedEventArgs e)
+        {
+            int id_ = IdLabel;
+            Menu main = new Menu();
+            main.LabelText = Convert.ToString(login);
+            main.Show();
+            this.Hide();
+        }
+
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            int id = IdLabel;
+            login = LogLabel;
+            LoginLabel.Content = login;
+            var users = Entity.Users.ToList();
+            var leads = Entity.Lead.ToList();
+            userBox.ItemsSource = users;
+            leadChange.ItemsSource = leads.Where(x => x.idLead == id);
+        }
+
+        private void UpdateButton_Click(object sender, RoutedEventArgs e)
+        {
+            int id_ = IdLabel;
+            var calls = Entity.Lead.ToList();
+            var idRow = Entity.Lead.Where(grechka => grechka.idLead == id_).FirstOrDefault();
+            if (IdToLogin == 0)
+            {
+                MessageBox.Show("Не выбран пользователь");
+                return;
+            }
+            else
+            {
+                var _IsCalled = Entity.Lead.Where(x => x.idLead == id_).Select(y => y.IsCalled).FirstOrDefault();
+                if (_IsCalled == true)
+                {
+                    idRow.StatusLead = leadStatus.Text;
+                    idRow.Comment = txtBoxComm.Text;
+                    idRow.idUser = IdToLogin;
+                    Entity.SaveChanges();
+                    leadChange.ItemsSource = calls.Where(id => id.idLead == id_);
+                }
+                else
+                {
+                    MessageBox.Show("По данному лиду не было совершенно звонков");
+                    return;
+                }
+            }
+        }
+
+        private void UserBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            IdToLogin = (userBox.SelectedItem as Users).idUser;
+            
+        }
+    }
+}

+ 10 - 3
LoadedToTheGills/LoadedToTheGills.csproj

@@ -64,6 +64,9 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="auth.cs">
+      <DependentUpon>Model1.tt</DependentUpon>
+    </Compile>
     <Compile Include="Call.cs">
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
@@ -76,6 +79,9 @@
     <Compile Include="Lead.cs">
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
+    <Compile Include="LeadWindow.xaml.cs">
+      <DependentUpon>LeadWindow.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Menu.xaml.cs">
       <DependentUpon>Menu.xaml</DependentUpon>
     </Compile>
@@ -90,9 +96,6 @@
     <Compile Include="signup.xaml.cs">
       <DependentUpon>signup.xaml</DependentUpon>
     </Compile>
-    <Compile Include="sysdiagrams.cs">
-      <DependentUpon>Model1.tt</DependentUpon>
-    </Compile>
     <Compile Include="Users.cs">
       <DependentUpon>Model1.tt</DependentUpon>
     </Compile>
@@ -100,6 +103,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="LeadWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>

+ 1 - 1
LoadedToTheGills/MainWindow.xaml

@@ -5,7 +5,7 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:LoadedToTheGills"
         mc:Ignorable="d"
-        Title="MainWindow" Height="383" Width="290">
+        Title="MainWindow" WindowStartupLocation="CenterScreen" Height="383" Width="290">
     <Grid>
         <Rectangle Fill="#FF3F3FA8" HorizontalAlignment="Left" Height="63" Stroke="Black" VerticalAlignment="Top" Width="282"/>
         <Label Content="Авторизация" FontFamily="Times New Roman" FontSize="24" Margin="73,10,38,289" BorderBrush="Black" Foreground="White">

+ 36 - 16
LoadedToTheGills/Menu.xaml

@@ -5,7 +5,7 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:LoadedToTheGills"
         mc:Ignorable="d"
-        Title="Menu" Height="450" Width="918" Loaded="Window_Loaded">
+        Title="Menu" Height="450" WindowStartupLocation="CenterScreen" Width="918" Loaded="Window_Loaded">
     <Grid>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="153*"/>
@@ -13,23 +13,12 @@
         </Grid.ColumnDefinitions>
         <Rectangle Fill="#FF3F3FA8" HorizontalAlignment="Left" Height="56" Stroke="Black" VerticalAlignment="Top" Width="910" Grid.ColumnSpan="2"/>
         <Rectangle Fill="#FF3F3FA8" HorizontalAlignment="Left" Height="56" Stroke="Black" VerticalAlignment="Top" Width="910" Margin="0,363,0,0" Grid.ColumnSpan="2"/>
-        <DataGrid x:Name="callGrid" HorizontalAlignment="Left" Height="307" Margin="0,56,0,0" AutoGenerateColumns="False" VerticalAlignment="Top" Width="567" Grid.ColumnSpan="2">
-            <DataGrid.Columns>
-                <DataGridTextColumn Binding="{Binding idCall}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Id"/>
-                <DataGridTextColumn Binding="{Binding CallDate}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Дата звонка"/>
-                <DataGridTextColumn Binding="{Binding Users.Login}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Пользователь"/>
-                <DataGridTextColumn Binding="{Binding Lead.StatusLead}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Контакт Лида"/>
-                <DataGridTextColumn Binding="{Binding LongCall}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Длительность"/>
-            </DataGrid.Columns>
-        </DataGrid>
-        <Button x:Name="btnDelete" Content="Удалить" HorizontalAlignment="Left" Margin="111,62,0,0" VerticalAlignment="Top" Width="100" Height="31" FontFamily="Times New Roman" FontSize="16" Click="BtnDelete_Click" Grid.Column="1"/>
-        <Button x:Name="btnAdd" Content="Добавить" HorizontalAlignment="Left" Margin="216,62,0,0" VerticalAlignment="Top" Width="100" Height="31" FontFamily="Times New Roman" FontSize="16" Click="BtnAdd_Click" Grid.Column="1"/>
-        <Button x:Name="btnUpdate" Content="Обновить" HorizontalAlignment="Left" Margin="321,62,0,0" VerticalAlignment="Top" Width="100" Height="31" FontFamily="Times New Roman" FontSize="16" Click="BtnUpdate_Click" Grid.Column="1"/>
+        <Button x:Name="btnDelete" Content="Удалить" HorizontalAlignment="Left" Margin="271,62,0,0" VerticalAlignment="Top" Width="150" Height="31" FontFamily="Times New Roman" FontSize="16" Click="BtnDelete_Click" Grid.Column="1"/>
+        <Button x:Name="btnAdd" Content="Добавить" HorizontalAlignment="Left" Margin="111,62,0,0" VerticalAlignment="Top" Width="150" Height="31" FontFamily="Times New Roman" FontSize="16" Click="BtnAdd_Click" Grid.Column="1"/>
         <TextBox x:Name="txtBoxCallDate" HorizontalAlignment="Left" Height="23" Margin="111,103,0,0" TextWrapping="Wrap" Text="2019-03-01 20:35:00" VerticalAlignment="Top" Width="310" Grid.Column="1"/>
         <TextBox x:Name="txtBoxUser" HorizontalAlignment="Left" Height="23" Margin="111,131,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="310" Grid.Column="1"/>
-        <TextBox x:Name="txtBoxLeadStart" HorizontalAlignment="Left" Height="23" Margin="111,159,0,0" TextWrapping="Wrap" Text="LeadStart" VerticalAlignment="Top" Width="310" Grid.Column="1"/>
         <TextBox x:Name="txtBoxLong" HorizontalAlignment="Left" Height="23" Margin="111,187,0,0" TextWrapping="Wrap" Text="LongTime" VerticalAlignment="Top" Width="310" Grid.Column="1"/>
-        <Rectangle Grid.Column="1" Fill="White" HorizontalAlignment="Left" Height="36" Margin="111,9,0,0" Stroke="Black" VerticalAlignment="Top" Width="309" RenderTransformOrigin="0.5,0.5">
+        <Rectangle Grid.Column="1" Fill="White" HorizontalAlignment="Left" Height="36" Margin="111,9,0,0" Stroke="Black" VerticalAlignment="Top" Width="310" RenderTransformOrigin="0.5,0.5">
             <Rectangle.RenderTransform>
                 <TransformGroup>
                     <ScaleTransform ScaleY="-1"/>
@@ -40,8 +29,39 @@
             </Rectangle.RenderTransform>
         </Rectangle>
         <Label x:Name="lblName" Content="Username" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Column="1" Margin="150,10,0,0" Height="33" Width="143" FontFamily="Times New Roman" FontSize="16"/>
-        <ComboBox x:Name="usersBox" ItemsSource="{Binding Users}" DisplayMemberPath="Login" SelectedValuePath="idUser" Grid.Column="1" HorizontalAlignment="Left" Margin="111,215,0,0" VerticalAlignment="Top" Width="310" SelectionChanged="UsersBox_SelectionChanged"/>
+        <ComboBox x:Name="usersBox" ItemsSource="{Binding Users}" DisplayMemberPath="Login" SelectedValuePath="idUser" Grid.Column="1" HorizontalAlignment="Left" Margin="111,288,0,0" VerticalAlignment="Top" Width="310" SelectionChanged="UsersBox_SelectionChanged"/>
         <Image Grid.Column="1" HorizontalAlignment="Left" Height="33" Margin="111,10,0,0" VerticalAlignment="Top" Width="39"/>
+        <Button x:Name="callButton" Content="Перейти к звонку" Grid.Column="1" HorizontalAlignment="Left" Margin="111,216,0,0" VerticalAlignment="Top" Width="310" Height="31" FontFamily="Times New Roman" FontSize="16" Click="CallButton_Click"/>
+        <TabControl HorizontalAlignment="Left" Height="302" Margin="0,56,0,0" VerticalAlignment="Top" Width="576" Grid.ColumnSpan="2">
+            <TabItem Header="Calls" FontFamily="Times New Roman" FontSize="16" Margin="-2,-2,-72,0">
+                <Grid Background="#FFE5E5E5">
+                    <DataGrid x:Name="callGrid" HorizontalAlignment="Left" Height="274" AutoGenerateColumns="False" VerticalAlignment="Top" Width="570">
+                        <DataGrid.Columns>
+                            <DataGridTextColumn Binding="{Binding idCall}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Id"/>
+                            <DataGridTextColumn Binding="{Binding CallDate}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Дата звонка"/>
+                            <DataGridTextColumn Binding="{Binding Users.Login}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Пользователь"/>
+                            <DataGridTextColumn Binding="{Binding Lead.StatusLead}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Контакт Лида"/>
+                            <DataGridTextColumn Binding="{Binding LongCall}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Длительность"/>
+                        </DataGrid.Columns>
+                    </DataGrid>
+                </Grid>
+            </TabItem>
+            <TabItem Header="Leads" FontFamily="Times New Roman" FontSize="16" Margin="72,-2,-143,0">
+                <Grid Background="#FFE5E5E5">
+                    <DataGrid x:Name="leadGrid" AutoGenerateColumns="False" HorizontalAlignment="Left" Height="272" VerticalAlignment="Top" Width="570">
+                        <DataGrid.Columns>
+                            <DataGridTextColumn Binding="{Binding idLead}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Id"/>
+                            <DataGridTextColumn Binding="{Binding LeadStart}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="LeadStart"/>
+                            <DataGridTextColumn Binding="{Binding Users.Login}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="LeadOwner"/>
+                            <DataGridTextColumn Binding="{Binding StatusLead}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="LeadStatus"/>
+                            <DataGridTextColumn Binding="{x:Null}" ClipboardContentBinding="{x:Null}" FontSize="16" FontFamily="Times New Roman" Header="Skills"/>
+                        </DataGrid.Columns>
+                    </DataGrid>
+                </Grid>
+            </TabItem>
+        </TabControl>
+        <Button x:Name="leadButton" Content="Перейти к лиду" Grid.Column="1" HorizontalAlignment="Left" Margin="111,252,0,0" FontFamily="Times New Roman" FontSize="16" VerticalAlignment="Top" Width="310" Height="31" Click="LeadButton_Click"/>
+        <ComboBox x:Name="leadBox" Grid.Column="1" HorizontalAlignment="Left" ItemsSource="{Binding Lead}" DisplayMemberPath="idLead" SelectedValuePath="idLead" Margin="111,160,0,0" FontFamily="Times New Roman" FontSize="16" VerticalAlignment="Top" Width="310"/>
 
     </Grid>
 </Window>

+ 54 - 32
LoadedToTheGills/Menu.xaml.cs

@@ -22,12 +22,10 @@ namespace LoadedToTheGills
         gr671_kyaaEntities Entity = new gr671_kyaaEntities();
        // public List<Users> userList { get; set; } 
         public String LabelText { get; set; }
+        
         public Menu()
         {
             InitializeComponent();
-
-
-
             
         }
 
@@ -36,8 +34,12 @@ namespace LoadedToTheGills
             var calls = Entity.Call.ToList();
             var users = Entity.Users.ToList();
             var leads = Entity.Lead.ToList();
+            var _leads = Entity.Lead.ToList().Where(x => x.StatusLead == "Неактивный");
 
             usersBox.ItemsSource = users;
+            leadBox.ItemsSource = _leads;
+
+            leadGrid.ItemsSource = leads.ToList();
 
             txtBoxCallDate.Text = DateTime.Now.ToString();
             txtBoxCallDate.IsReadOnly = true;
@@ -51,7 +53,7 @@ namespace LoadedToTheGills
                 callGrid.ItemsSource = calls.ToList();
                 btnAdd.IsEnabled = false;
                 btnDelete.IsEnabled = false;
-                btnUpdate.IsEnabled = false;
+                
             }
 
             if (txtBoxUser.Text != "0")
@@ -99,7 +101,7 @@ namespace LoadedToTheGills
         {
             var calls = Entity.Call.ToList();
 
-            if(txtBoxCallDate.Text == "" || txtBoxLeadStart.Text == "" || txtBoxLong.Text == "" || txtBoxUser.Text == "")
+            if(txtBoxCallDate.Text == "" || leadBox.Text == "" || txtBoxLong.Text == "" || txtBoxUser.Text == "")
             {
                 MessageBox.Show("Заполнены не все данные");
                 return;
@@ -110,43 +112,23 @@ namespace LoadedToTheGills
                 {
                     CallDate = Convert.ToDateTime(txtBoxCallDate.Text),
                     LongCall = Convert.ToInt32(txtBoxLong.Text),
-                    idLead = Convert.ToInt32(txtBoxLeadStart.Text),
+                    idLead = Convert.ToInt32(leadBox.Text),
                     idUser = Convert.ToInt32(txtBoxUser.Text)
                 };
                 
                 Entity.Call.Add(call);
+                int LeadId = (leadBox.SelectedItem as Lead).idLead;
+                var NewStatus = Entity.Lead.Where(x => x.idLead == LeadId).FirstOrDefault();
+                NewStatus.IsCalled = true;
                 Entity.SaveChanges();
                 var idUser_ = Entity.Users.Where(user => user.Login == (String)lblName.Content).Select(id => id.idUser).FirstOrDefault();
                 int id_ = idUser_;
                 callGrid.ItemsSource = calls.Where(id => id.idUser == id_);
-                
-            }
-        }
 
-        private void BtnUpdate_Click(object sender, RoutedEventArgs e)
-        {
-            var calls = Entity.Call.ToList();
-            int num = (callGrid.SelectedItem as Call).idCall;
-            var idRow = Entity.Call.Where(grechka => grechka.idCall == num).FirstOrDefault();
-            var idUser_ = Entity.Users.Where(user => user.Login == (String)lblName.Content).Select(id => id.idUser).FirstOrDefault();
-            int id_ = idUser_;
-
-            if (txtBoxCallDate.Text == "" || txtBoxLeadStart.Text == "" || txtBoxLong.Text == "" || txtBoxUser.Text == "")
-            {
-                MessageBox.Show("Заполнены не все данные");
-                return;
-            }
-            else
-            {
-                idRow.CallDate = Convert.ToDateTime(txtBoxCallDate.Text);
-                idRow.LongCall = Convert.ToInt32(txtBoxLong.Text);
-                idRow.idLead = Convert.ToInt32(txtBoxLeadStart.Text);
-                idRow.idUser = Convert.ToInt32(txtBoxUser.Text);
-                Entity.SaveChanges();
-                callGrid.ItemsSource = calls.Where(id => id.idUser == id_);
             }
         }
 
+
         private void UsersBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             var calls = Entity.Call.ToList();
@@ -157,14 +139,54 @@ namespace LoadedToTheGills
             {
                 btnAdd.IsEnabled = false;
                 btnDelete.IsEnabled = false;
-                btnUpdate.IsEnabled = false;
+                callButton.IsEnabled = false;
+               
             }
             if(txtBoxUser.Text == num_)
             {
                 btnAdd.IsEnabled = true;
                 btnDelete.IsEnabled = true;
-                btnUpdate.IsEnabled = true;
+                callButton.IsEnabled = true;
+            }
+        }
+  
+        private void LeadButton_Click(object sender, RoutedEventArgs e)
+        {
+            LeadWindow lw = new LeadWindow();
+            int _num;
+            if (leadGrid.SelectedItem == null)
+            {
+                MessageBox.Show("Не выбран лид");
+                return;
+            }
+            else
+            {
+                _num = (leadGrid.SelectedItem as Lead).idLead;
+                lw.IdLabel = _num;
+                lw.LogLabel = (String)lblName.Content;
+                lw.Show();
+                this.Hide();
             }
         }
+
+        private void CallButton_Click(object sender, RoutedEventArgs e)
+        {
+            CallWindow cw = new CallWindow();
+            int num;
+            if (callGrid.SelectedItem == null)
+            {
+                MessageBox.Show("Не выбран звонок");
+                return;
+            }
+            else
+            {
+                num = (callGrid.SelectedItem as Call).idCall;
+                cw.IdLabel = num;
+                cw.Show();
+                this.Hide();
+            }
+        }
+
+        
     }
 }

+ 1 - 1
LoadedToTheGills/Model1.Context.cs

@@ -25,11 +25,11 @@ namespace LoadedToTheGills
             throw new UnintentionalCodeFirstException();
         }
     
+        public virtual DbSet<auth> auth { get; set; }
         public virtual DbSet<Call> Call { get; set; }
         public virtual DbSet<Clients> Clients { get; set; }
         public virtual DbSet<Lead> Lead { get; set; }
         public virtual DbSet<Products> Products { get; set; }
-        public virtual DbSet<sysdiagrams> sysdiagrams { get; set; }
         public virtual DbSet<Users> Users { get; set; }
     }
 }

+ 161 - 105
LoadedToTheGills/Model1.edmx

@@ -4,7 +4,18 @@
   <edmx:Runtime>
     <!-- SSDL content -->
     <edmx:StorageModels>
-      <Schema Namespace="Хранилище gr671_kyaaModel" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
+    <Schema Namespace="Хранилище gr671_kyaaModel" 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="auth">
+          <Key>
+            <PropertyRef Name="id" />
+          </Key>
+          <Property Name="id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="login" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="pass" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="surname" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="name" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="midname" Type="nvarchar" MaxLength="50" />
+        </EntityType>
         <EntityType Name="Call">
           <Key>
             <PropertyRef Name="idCall" />
@@ -14,6 +25,7 @@
           <Property Name="LongCall" Type="int" />
           <Property Name="idLead" Type="int" />
           <Property Name="idUser" Type="int" />
+          <Property Name="Comment" Type="nvarchar(max)" />
         </EntityType>
         <EntityType Name="Clients">
           <Key>
@@ -31,6 +43,9 @@
           <Property Name="StatusLead" Type="nvarchar" MaxLength="50" Nullable="false" />
           <Property Name="idClient" Type="int" Nullable="false" />
           <Property Name="idProduct" Type="int" Nullable="false" />
+          <Property Name="Comment" Type="nvarchar(max)" />
+          <Property Name="idUser" Type="int" />
+          <Property Name="IsCalled" Type="bit" Nullable="false" />
         </EntityType>
         <EntityType Name="Products">
           <Key>
@@ -40,16 +55,6 @@
           <Property Name="ProductTitle" Type="nvarchar" MaxLength="50" Nullable="false" />
           <Property Name="ProductType" 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="Users">
           <Key>
             <PropertyRef Name="idUser" />
@@ -77,7 +82,9 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Call_Users">
-          <End Role="Users" Type="Self.Users" Multiplicity="0..1" />
+          <End Role="Users" Type="Self.Users" Multiplicity="0..1">
+            <OnDelete Action="Cascade" />
+          </End>
           <End Role="Call" Type="Self.Call" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Users">
@@ -89,7 +96,9 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Lead_Clients">
-          <End Role="Clients" Type="Self.Clients" Multiplicity="1" />
+          <End Role="Clients" Type="Self.Clients" Multiplicity="1">
+            <OnDelete Action="Cascade" />
+          </End>
           <End Role="Lead" Type="Self.Lead" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Clients">
@@ -101,7 +110,9 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Lead_Products">
-          <End Role="Products" Type="Self.Products" Multiplicity="1" />
+          <End Role="Products" Type="Self.Products" Multiplicity="1">
+            <OnDelete Action="Cascade" />
+          </End>
           <End Role="Lead" Type="Self.Lead" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Products">
@@ -112,12 +123,26 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_Lead_Users">
+          <End Role="Users" Type="Self.Users" Multiplicity="0..1">
+            <OnDelete Action="Cascade" />
+          </End>
+          <End Role="Lead" Type="Self.Lead" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Users">
+              <PropertyRef Name="idUser" />
+            </Principal>
+            <Dependent Role="Lead">
+              <PropertyRef Name="idUser" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <EntityContainer Name="Хранилище gr671_kyaaModelContainer">
+          <EntitySet Name="auth" EntityType="Self.auth" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Call" EntityType="Self.Call" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Clients" EntityType="Self.Clients" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Lead" EntityType="Self.Lead" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Products" EntityType="Self.Products" Schema="dbo" store:Type="Tables" />
-          <EntitySet Name="sysdiagrams" EntityType="Self.sysdiagrams" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
           <AssociationSet Name="FK_Call_Lead" Association="Self.FK_Call_Lead">
             <End Role="Lead" EntitySet="Lead" />
@@ -135,12 +160,54 @@
             <End Role="Products" EntitySet="Products" />
             <End Role="Lead" EntitySet="Lead" />
           </AssociationSet>
+          <AssociationSet Name="FK_Lead_Users" Association="Self.FK_Lead_Users">
+            <End Role="Users" EntitySet="Users" />
+            <End Role="Lead" EntitySet="Lead" />
+          </AssociationSet>
         </EntityContainer>
-      </Schema>
-    </edmx:StorageModels>
+      </Schema></edmx:StorageModels>
     <!-- CSDL content -->
     <edmx:ConceptualModels>
       <Schema Namespace="gr671_kyaaModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
+        <EntityContainer Name="gr671_kyaaEntities" annotation:LazyLoadingEnabled="true">
+          <EntitySet Name="auth" EntityType="gr671_kyaaModel.auth" />
+          <EntitySet Name="Call" EntityType="gr671_kyaaModel.Call" />
+          <EntitySet Name="Clients" EntityType="gr671_kyaaModel.Clients" />
+          <EntitySet Name="Lead" EntityType="gr671_kyaaModel.Lead" />
+          <EntitySet Name="Products" EntityType="gr671_kyaaModel.Products" />
+          <EntitySet Name="Users" EntityType="gr671_kyaaModel.Users" />
+          <AssociationSet Name="FK_Call_Lead" Association="gr671_kyaaModel.FK_Call_Lead">
+            <End Role="Lead" EntitySet="Lead" />
+            <End Role="Call" EntitySet="Call" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Call_Users" Association="gr671_kyaaModel.FK_Call_Users">
+            <End Role="Users" EntitySet="Users" />
+            <End Role="Call" EntitySet="Call" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Lead_Clients" Association="gr671_kyaaModel.FK_Lead_Clients">
+            <End Role="Clients" EntitySet="Clients" />
+            <End Role="Lead" EntitySet="Lead" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Lead_Products" Association="gr671_kyaaModel.FK_Lead_Products">
+            <End Role="Products" EntitySet="Products" />
+            <End Role="Lead" EntitySet="Lead" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Lead_Users" Association="gr671_kyaaModel.FK_Lead_Users">
+            <End Role="Users" EntitySet="Users" />
+            <End Role="Lead" EntitySet="Lead" />
+          </AssociationSet>
+        </EntityContainer>
+        <EntityType Name="auth">
+          <Key>
+            <PropertyRef Name="id" />
+          </Key>
+          <Property Name="id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="login" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="pass" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="surname" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="name" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="midname" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
+        </EntityType>
         <EntityType Name="Call">
           <Key>
             <PropertyRef Name="idCall" />
@@ -150,16 +217,17 @@
           <Property Name="LongCall" Type="Int32" />
           <Property Name="idLead" Type="Int32" />
           <Property Name="idUser" Type="Int32" />
-          <NavigationProperty Name="Lead" Relationship="Self.FK_Call_Lead" FromRole="Call" ToRole="Lead" />
-          <NavigationProperty Name="Users" Relationship="Self.FK_Call_Users" FromRole="Call" ToRole="Users" />
+          <Property Name="Comment" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
+          <NavigationProperty Name="Lead" Relationship="gr671_kyaaModel.FK_Call_Lead" FromRole="Call" ToRole="Lead" />
+          <NavigationProperty Name="Users" Relationship="gr671_kyaaModel.FK_Call_Users" FromRole="Call" ToRole="Users" />
         </EntityType>
         <EntityType Name="Clients">
           <Key>
             <PropertyRef Name="idClient" />
           </Key>
           <Property Name="idClient" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="PhoneNumbers" Type="Decimal" Precision="18" Scale="0" Nullable="false" />
-          <NavigationProperty Name="Lead" Relationship="Self.FK_Lead_Clients" FromRole="Clients" ToRole="Lead" />
+          <Property Name="PhoneNumbers" Type="Decimal" Nullable="false" Precision="18" Scale="0" />
+          <NavigationProperty Name="Lead" Relationship="gr671_kyaaModel.FK_Lead_Clients" FromRole="Clients" ToRole="Lead" />
         </EntityType>
         <EntityType Name="Lead">
           <Key>
@@ -167,50 +235,45 @@
           </Key>
           <Property Name="idLead" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
           <Property Name="LeadStart" Type="DateTime" Nullable="false" Precision="3" />
-          <Property Name="StatusLead" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="StatusLead" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
           <Property Name="idClient" Type="Int32" Nullable="false" />
           <Property Name="idProduct" Type="Int32" Nullable="false" />
-          <NavigationProperty Name="Call" Relationship="Self.FK_Call_Lead" FromRole="Lead" ToRole="Call" />
-          <NavigationProperty Name="Clients" Relationship="Self.FK_Lead_Clients" FromRole="Lead" ToRole="Clients" />
-          <NavigationProperty Name="Products" Relationship="Self.FK_Lead_Products" FromRole="Lead" ToRole="Products" />
+          <Property Name="Comment" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
+          <Property Name="idUser" Type="Int32" />
+          <NavigationProperty Name="Call" Relationship="gr671_kyaaModel.FK_Call_Lead" FromRole="Lead" ToRole="Call" />
+          <NavigationProperty Name="Clients" Relationship="gr671_kyaaModel.FK_Lead_Clients" FromRole="Lead" ToRole="Clients" />
+          <NavigationProperty Name="Products" Relationship="gr671_kyaaModel.FK_Lead_Products" FromRole="Lead" ToRole="Products" />
+          <NavigationProperty Name="Users" Relationship="gr671_kyaaModel.FK_Lead_Users" FromRole="Lead" ToRole="Users" />
+          <Property Name="IsCalled" Type="Boolean" Nullable="false" />
         </EntityType>
         <EntityType Name="Products">
           <Key>
             <PropertyRef Name="idProduct" />
           </Key>
           <Property Name="idProduct" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="ProductTitle" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
-          <Property Name="ProductType" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
-          <NavigationProperty Name="Lead" Relationship="Self.FK_Lead_Products" FromRole="Products" ToRole="Lead" />
-        </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" />
+          <Property Name="ProductTitle" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="ProductType" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <NavigationProperty Name="Lead" Relationship="gr671_kyaaModel.FK_Lead_Products" FromRole="Products" ToRole="Lead" />
         </EntityType>
         <EntityType Name="Users">
           <Key>
             <PropertyRef Name="idUser" />
           </Key>
           <Property Name="idUser" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
-          <Property Name="Login" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
-          <Property Name="Password" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
-          <Property Name="Surname" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
-          <Property Name="Name" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
+          <Property Name="Login" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="Password" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="Surname" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="Name" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
           <Property Name="Midname" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
           <Property Name="WorkingOp" Type="Double" Nullable="false" />
           <Property Name="SkillSales" Type="Double" Nullable="false" />
           <Property Name="SProduct" Type="Double" Nullable="false" />
-          <NavigationProperty Name="Call" Relationship="Self.FK_Call_Users" FromRole="Users" ToRole="Call" />
+          <NavigationProperty Name="Call" Relationship="gr671_kyaaModel.FK_Call_Users" FromRole="Users" ToRole="Call" />
+          <NavigationProperty Name="Lead" Relationship="gr671_kyaaModel.FK_Lead_Users" FromRole="Users" ToRole="Lead" />
         </EntityType>
         <Association Name="FK_Call_Lead">
-          <End Role="Lead" Type="Self.Lead" Multiplicity="0..1" />
-          <End Role="Call" Type="Self.Call" Multiplicity="*" />
+          <End Type="gr671_kyaaModel.Lead" Role="Lead" Multiplicity="0..1" />
+          <End Type="gr671_kyaaModel.Call" Role="Call" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Lead">
               <PropertyRef Name="idLead" />
@@ -221,8 +284,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Call_Users">
-          <End Role="Users" Type="Self.Users" Multiplicity="0..1" />
-          <End Role="Call" Type="Self.Call" Multiplicity="*" />
+          <End Type="gr671_kyaaModel.Users" Role="Users" Multiplicity="0..1" />
+          <End Type="gr671_kyaaModel.Call" Role="Call" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Users">
               <PropertyRef Name="idUser" />
@@ -233,8 +296,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Lead_Clients">
-          <End Role="Clients" Type="Self.Clients" Multiplicity="1" />
-          <End Role="Lead" Type="Self.Lead" Multiplicity="*" />
+          <End Type="gr671_kyaaModel.Clients" Role="Clients" Multiplicity="1" />
+          <End Type="gr671_kyaaModel.Lead" Role="Lead" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Clients">
               <PropertyRef Name="idClient" />
@@ -245,8 +308,8 @@
           </ReferentialConstraint>
         </Association>
         <Association Name="FK_Lead_Products">
-          <End Role="Products" Type="Self.Products" Multiplicity="1" />
-          <End Role="Lead" Type="Self.Lead" Multiplicity="*" />
+          <End Type="gr671_kyaaModel.Products" Role="Products" Multiplicity="1" />
+          <End Type="gr671_kyaaModel.Lead" Role="Lead" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Products">
               <PropertyRef Name="idProduct" />
@@ -256,98 +319,91 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <EntityContainer Name="gr671_kyaaEntities" annotation:LazyLoadingEnabled="true">
-          <EntitySet Name="Call" EntityType="Self.Call" />
-          <EntitySet Name="Clients" EntityType="Self.Clients" />
-          <EntitySet Name="Lead" EntityType="Self.Lead" />
-          <EntitySet Name="Products" EntityType="Self.Products" />
-          <EntitySet Name="sysdiagrams" EntityType="Self.sysdiagrams" />
-          <EntitySet Name="Users" EntityType="Self.Users" />
-          <AssociationSet Name="FK_Call_Lead" Association="Self.FK_Call_Lead">
-            <End Role="Lead" EntitySet="Lead" />
-            <End Role="Call" EntitySet="Call" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Call_Users" Association="Self.FK_Call_Users">
-            <End Role="Users" EntitySet="Users" />
-            <End Role="Call" EntitySet="Call" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Lead_Clients" Association="Self.FK_Lead_Clients">
-            <End Role="Clients" EntitySet="Clients" />
-            <End Role="Lead" EntitySet="Lead" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Lead_Products" Association="Self.FK_Lead_Products">
-            <End Role="Products" EntitySet="Products" />
-            <End Role="Lead" EntitySet="Lead" />
-          </AssociationSet>
-        </EntityContainer>
+        <Association Name="FK_Lead_Users">
+          <End Type="gr671_kyaaModel.Users" Role="Users" Multiplicity="0..1" />
+          <End Type="gr671_kyaaModel.Lead" Role="Lead" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Users">
+              <PropertyRef Name="idUser" />
+            </Principal>
+            <Dependent Role="Lead">
+              <PropertyRef Name="idUser" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
       </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="Хранилище gr671_kyaaModelContainer" CdmEntityContainer="gr671_kyaaEntities">
+          <EntitySetMapping Name="auth">
+            <EntityTypeMapping TypeName="gr671_kyaaModel.auth">
+              <MappingFragment StoreEntitySet="auth">
+                <ScalarProperty Name="midname" ColumnName="midname" />
+                <ScalarProperty Name="name" ColumnName="name" />
+                <ScalarProperty Name="surname" ColumnName="surname" />
+                <ScalarProperty Name="pass" ColumnName="pass" />
+                <ScalarProperty Name="login" ColumnName="login" />
+                <ScalarProperty Name="id" ColumnName="id" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
           <EntitySetMapping Name="Call">
             <EntityTypeMapping TypeName="gr671_kyaaModel.Call">
               <MappingFragment StoreEntitySet="Call">
-                <ScalarProperty Name="idCall" ColumnName="idCall" />
-                <ScalarProperty Name="CallDate" ColumnName="CallDate" />
-                <ScalarProperty Name="LongCall" ColumnName="LongCall" />
-                <ScalarProperty Name="idLead" ColumnName="idLead" />
+                <ScalarProperty Name="Comment" ColumnName="Comment" />
                 <ScalarProperty Name="idUser" ColumnName="idUser" />
+                <ScalarProperty Name="idLead" ColumnName="idLead" />
+                <ScalarProperty Name="LongCall" ColumnName="LongCall" />
+                <ScalarProperty Name="CallDate" ColumnName="CallDate" />
+                <ScalarProperty Name="idCall" ColumnName="idCall" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="Clients">
             <EntityTypeMapping TypeName="gr671_kyaaModel.Clients">
               <MappingFragment StoreEntitySet="Clients">
-                <ScalarProperty Name="idClient" ColumnName="idClient" />
                 <ScalarProperty Name="PhoneNumbers" ColumnName="PhoneNumbers" />
+                <ScalarProperty Name="idClient" ColumnName="idClient" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="Lead">
             <EntityTypeMapping TypeName="gr671_kyaaModel.Lead">
               <MappingFragment StoreEntitySet="Lead">
-                <ScalarProperty Name="idLead" ColumnName="idLead" />
-                <ScalarProperty Name="LeadStart" ColumnName="LeadStart" />
-                <ScalarProperty Name="StatusLead" ColumnName="StatusLead" />
-                <ScalarProperty Name="idClient" ColumnName="idClient" />
+                <ScalarProperty Name="IsCalled" ColumnName="IsCalled" />
+                <ScalarProperty Name="idUser" ColumnName="idUser" />
+                <ScalarProperty Name="Comment" ColumnName="Comment" />
                 <ScalarProperty Name="idProduct" ColumnName="idProduct" />
+                <ScalarProperty Name="idClient" ColumnName="idClient" />
+                <ScalarProperty Name="StatusLead" ColumnName="StatusLead" />
+                <ScalarProperty Name="LeadStart" ColumnName="LeadStart" />
+                <ScalarProperty Name="idLead" ColumnName="idLead" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="Products">
             <EntityTypeMapping TypeName="gr671_kyaaModel.Products">
               <MappingFragment StoreEntitySet="Products">
-                <ScalarProperty Name="idProduct" ColumnName="idProduct" />
-                <ScalarProperty Name="ProductTitle" ColumnName="ProductTitle" />
                 <ScalarProperty Name="ProductType" ColumnName="ProductType" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
-          <EntitySetMapping Name="sysdiagrams">
-            <EntityTypeMapping TypeName="gr671_kyaaModel.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" />
+                <ScalarProperty Name="ProductTitle" ColumnName="ProductTitle" />
+                <ScalarProperty Name="idProduct" ColumnName="idProduct" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="Users">
             <EntityTypeMapping TypeName="gr671_kyaaModel.Users">
               <MappingFragment StoreEntitySet="Users">
-                <ScalarProperty Name="idUser" ColumnName="idUser" />
-                <ScalarProperty Name="Login" ColumnName="Login" />
-                <ScalarProperty Name="Password" ColumnName="Password" />
-                <ScalarProperty Name="Surname" ColumnName="Surname" />
-                <ScalarProperty Name="Name" ColumnName="Name" />
-                <ScalarProperty Name="Midname" ColumnName="Midname" />
-                <ScalarProperty Name="WorkingOp" ColumnName="WorkingOp" />
-                <ScalarProperty Name="SkillSales" ColumnName="SkillSales" />
                 <ScalarProperty Name="SProduct" ColumnName="SProduct" />
+                <ScalarProperty Name="SkillSales" ColumnName="SkillSales" />
+                <ScalarProperty Name="WorkingOp" ColumnName="WorkingOp" />
+                <ScalarProperty Name="Midname" ColumnName="Midname" />
+                <ScalarProperty Name="Name" ColumnName="Name" />
+                <ScalarProperty Name="Surname" ColumnName="Surname" />
+                <ScalarProperty Name="Password" ColumnName="Password" />
+                <ScalarProperty Name="Login" ColumnName="Login" />
+                <ScalarProperty Name="idUser" ColumnName="idUser" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>

+ 11 - 10
LoadedToTheGills/Model1.edmx.diagram

@@ -5,16 +5,17 @@
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
       <Diagram DiagramId="7d60d01da4944a77a19d98a5a2d3aec7" Name="Diagram1">
-        <EntityTypeShape EntityType="gr671_kyaaModel.Call" Width="1.5" PointX="5.25" PointY="1" IsExpanded="true" />
-        <EntityTypeShape EntityType="gr671_kyaaModel.Clients" Width="1.5" PointX="0.75" PointY="1.375" IsExpanded="true" />
-        <EntityTypeShape EntityType="gr671_kyaaModel.Lead" Width="1.5" PointX="3" PointY="1" IsExpanded="true" />
-        <EntityTypeShape EntityType="gr671_kyaaModel.Products" Width="1.5" PointX="0.75" PointY="5.375" IsExpanded="true" />
-        <EntityTypeShape EntityType="gr671_kyaaModel.sysdiagrams" Width="1.5" PointX="5.75" PointY="4.75" IsExpanded="true" />
-        <EntityTypeShape EntityType="gr671_kyaaModel.Users" Width="1.5" PointX="3" PointY="4.75" IsExpanded="true" />
-        <AssociationConnector Association="gr671_kyaaModel.FK_Call_Lead" ManuallyRouted="false" />
-        <AssociationConnector Association="gr671_kyaaModel.FK_Call_Users" ManuallyRouted="false" />
-        <AssociationConnector Association="gr671_kyaaModel.FK_Lead_Clients" ManuallyRouted="false" />
-        <AssociationConnector Association="gr671_kyaaModel.FK_Lead_Products" ManuallyRouted="false" />
+        <EntityTypeShape EntityType="gr671_kyaaModel.auth" Width="1.5" PointX="0.75" PointY="7.25" />
+        <EntityTypeShape EntityType="gr671_kyaaModel.Call" Width="1.5" PointX="3" PointY="3.5" />
+        <EntityTypeShape EntityType="gr671_kyaaModel.Clients" Width="1.5" PointX="3.75" PointY="0.75" />
+        <EntityTypeShape EntityType="gr671_kyaaModel.Lead" Width="1.5" PointX="8.75" PointY="4.375" />
+        <EntityTypeShape EntityType="gr671_kyaaModel.Products" Width="1.5" PointX="3.75" PointY="7.125" />
+        <EntityTypeShape EntityType="gr671_kyaaModel.Users" Width="1.5" PointX="0.75" PointY="3.25" />
+        <AssociationConnector Association="gr671_kyaaModel.FK_Call_Lead" />
+        <AssociationConnector Association="gr671_kyaaModel.FK_Call_Users" />
+        <AssociationConnector Association="gr671_kyaaModel.FK_Lead_Clients" />
+        <AssociationConnector Association="gr671_kyaaModel.FK_Lead_Products" />
+        <AssociationConnector Association="gr671_kyaaModel.FK_Lead_Users" />
       </Diagram>
     </edmx:Diagrams>
   </edmx:Designer>

+ 3 - 0
LoadedToTheGills/Users.cs

@@ -18,6 +18,7 @@ namespace LoadedToTheGills
         public Users()
         {
             this.Call = new HashSet<Call>();
+            this.Lead = new HashSet<Lead>();
         }
     
         public int idUser { get; set; }
@@ -32,5 +33,7 @@ namespace LoadedToTheGills
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Call> Call { get; set; }
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Lead> Lead { get; set; }
     }
 }

+ 6 - 5
LoadedToTheGills/sysdiagrams.cs

@@ -12,12 +12,13 @@ namespace LoadedToTheGills
     using System;
     using System.Collections.Generic;
     
-    public partial class sysdiagrams
+    public partial class auth
     {
+        public int id { get; set; }
+        public string login { get; set; }
+        public string pass { get; set; }
+        public string surname { get; set; }
         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; }
+        public string midname { get; set; }
     }
 }