Артем Гавриленко 3 vuotta sitten
vanhempi
commit
1dad1b80a6

+ 0 - 51
Kusach/AddPointWindow.xaml.cs

@@ -1,51 +0,0 @@
-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 Kusach
-{
-    /// <summary>
-    /// Логика взаимодействия для AddPointWindow.xaml
-    /// </summary>
-    public partial class AddPointWindow : Window
-    {
-        public AddPointWindow()
-        {
-            InitializeComponent();
-        }
-
-        private void BackButton_Click(object sender, RoutedEventArgs e)
-        {
-            this.Close();
-        }
-
-        private void AddPointButton_Click(object sender, RoutedEventArgs e)
-        {
-            if (NameBox.Text == "" || LocationBox.Text == "")
-                MessageBox.Show("Поля не могут быть пустыми.");
-            else
-            {
-                Points newPoint = new Points()
-                {
-                    IdPoint = cnt.db.Points.Count() + 1,
-                    Name = NameBox.Text,
-                    location = LocationBox.Text
-                };
-                cnt.db.Points.Add(newPoint);
-                cnt.db.SaveChanges();
-                MessageBox.Show("Точка остановки успешно создана.");
-                this.Close();
-            }
-        }
-    }
-}

+ 5 - 5
Kusach/Kusach.csproj

@@ -70,7 +70,7 @@
     <Compile Include="AddDriverWindow.xaml.cs">
       <DependentUpon>AddDriverWindow.xaml</DependentUpon>
     </Compile>
-    <Compile Include="AddPointWindow.xaml.cs">
+    <Compile Include="Windows\AddPointWindow.xaml.cs">
       <DependentUpon>AddPointWindow.xaml</DependentUpon>
     </Compile>
     <Compile Include="Dispatcher.cs">
@@ -147,14 +147,14 @@
     <Compile Include="TestPGPage.xaml.cs">
       <DependentUpon>TestPGPage.xaml</DependentUpon>
     </Compile>
-    <Compile Include="TestRouteEditWindow.xaml.cs">
-      <DependentUpon>TestRouteEditWindow.xaml</DependentUpon>
+    <Compile Include="Windows\RouteEditWindow.xaml.cs">
+      <DependentUpon>RouteEditWindow.xaml</DependentUpon>
     </Compile>
     <Page Include="AddDriverWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="AddPointWindow.xaml">
+    <Page Include="Windows\AddPointWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
@@ -202,7 +202,7 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="TestRouteEditWindow.xaml">
+    <Page Include="Windows\RouteEditWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>

+ 2 - 2
Kusach/Pages/RoutesListPage.xaml.cs

@@ -27,8 +27,8 @@ namespace Kusach.Pages
         }
         private void DataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e)
         {
-            TestRouteEditWindow trew = new TestRouteEditWindow(((Routes)RoutesList.SelectedItem).IdRoute);
-            trew.Show();
+            Windows.RouteEditWindow rew = new Windows.RouteEditWindow(((Routes)RoutesList.SelectedItem).IdRoute);
+            rew.Show();
         }
 
         #region Поиск

+ 3 - 3
Kusach/RegWindow.xaml.cs

@@ -29,9 +29,9 @@ namespace Kusach
                         IdDispatcher = cnt.db.Dispatcher.Count() + 1,
                         Login = logbox.Text,
                         Password = Encrypt.GetHash(passbox.Text),
-                        FName = FNameBox.Text,
-                        LName = LNameBox.Text,
-                        MName = MNameBox.Text,
+                        Surname = FNameBox.Text,
+                        Name = LNameBox.Text,
+                        Patronymic = MNameBox.Text,
                         Birthday = Convert.ToDateTime(BirthdayBox.Text),
                         PhoneNumber = PhoneBox.Text
                     };

+ 0 - 44
Kusach/TestRouteEditWindow.xaml.cs

@@ -1,44 +0,0 @@
-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 Kusach
-{
-    /// <summary>
-    /// Логика взаимодействия для TestRouteEditWindow.xaml
-    /// </summary>
-    public partial class TestRouteEditWindow : Window
-    {
-        Routes route;
-        public TestRouteEditWindow(int id)
-        {
-            InitializeComponent();
-            RouteNameBox.Text = cnt.db.Routes.Where(item => item.IdRoute == id).Select(item => item.Name).FirstOrDefault();
-            
-            
-            PointsListDataGrid.ItemsSource = cnt.db.PointsList.Where(item => item.IdRoute == id).ToList();
-        }
-        private void DataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e)
-        {
-            if(((PointsList)PointsListDataGrid.SelectedItem) != null)
-            MessageBox.Show("cell: " + ((PointsList)PointsListDataGrid.SelectedItem).IdPoint);
-        }
-
-        private void Button_Click(object sender, RoutedEventArgs e)
-        {
-            //TestWindow tw = new TestWindow();
-            //tw.Show();
-            //this.Close();
-        }
-    }
-}

+ 3 - 3
Kusach/AddPointWindow.xaml

@@ -6,7 +6,7 @@
         xmlns:local="clr-namespace:Kusach"
         mc:Ignorable="d"
         Title="AddPointWindow" 
-        Height="250" 
+        Height="210" 
         Width="300"
         ResizeMode="NoResize"
         WindowStyle="None"
@@ -44,7 +44,7 @@
         <Button 
             Content="Создать &#xD;&#xA;место остановки" 
             HorizontalAlignment="Left"
-            Margin="170,200,0,0" 
+            Margin="170,160,0,0" 
             VerticalAlignment="Top" 
             Height="40" 
             Width="120" 
@@ -52,7 +52,7 @@
         <Button 
             Content="Отмена"
             HorizontalAlignment="Left" 
-            Margin="10,200,0,0" 
+            Margin="10,160,0,0" 
             VerticalAlignment="Top" 
             Height="40" 
             Width="120" 

+ 70 - 0
Kusach/Windows/AddPointWindow.xaml.cs

@@ -0,0 +1,70 @@
+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 Kusach
+{
+    /// <summary>
+    /// Логика взаимодействия для AddPointWindow.xaml
+    /// </summary>
+    public partial class AddPointWindow : Window
+    {
+        int RouteId;
+        public AddPointWindow(int id = -1)
+        {
+            InitializeComponent();
+            RouteId = id;
+        }
+
+        private void BackButton_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+
+        private void AddPointButton_Click(object sender, RoutedEventArgs e)
+        {
+            if (NameBox.Text == "" || LocationBox.Text == "")
+                MessageBox.Show("Поля не могут быть пустыми.");
+            else
+            {
+                try
+                {
+                    Points newPoint = new Points()
+                    {
+                        IdPoint = cnt.db.Points.Count() + 1,
+                        Name = NameBox.Text,
+                        location = LocationBox.Text
+                    };
+                    cnt.db.Points.Add(newPoint);
+                    if(RouteId != -1)
+                    {
+                        PointsList newPointRoute = new PointsList()
+                        {
+                            Id = cnt.db.PointsList.Count() + 1,
+                            IdPoint = cnt.db.Points.Count(),
+                            IdRoute = RouteId
+                        };
+                        cnt.db.PointsList.Add(newPointRoute);
+                    }
+                    cnt.db.SaveChanges();
+                    this.Close();
+                }
+                catch
+                {
+                    MessageBox.Show("Ошибка создания остановки.");
+                    this.Close();
+                }
+            }
+        }
+    }
+}

+ 34 - 25
Kusach/TestRouteEditWindow.xaml

@@ -1,24 +1,27 @@
-<Window x:Class="Kusach.TestRouteEditWindow"
+<Window x:Class="Kusach.Windows.RouteEditWindow"
         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:Kusach"
+        xmlns:local="clr-namespace:Kusach.Windows"
         mc:Ignorable="d"
-        Title="TestRouteEditWindow" Height="450" Width="800">
+        Title="Управление маршрутом" 
+        Height="450" 
+        Width="800"
+        WindowStartupLocation="CenterScreen">
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition Height="65*"/>
             <RowDefinition Height="354*"/>
         </Grid.RowDefinitions>
         <Button
-            Content="Назад" 
+            Content="Выход" 
             HorizontalAlignment="Left" 
             VerticalAlignment="Top" 
             Margin="10,10,0,0" 
             Width="90" 
             Height="50" 
-            Click="Button_Click"/>
+            Click="ExitButton_Click"/>
         <TextBox
             Name="RouteNameBox"
             Margin="105,10,10,5"
@@ -61,12 +64,13 @@
                             VerticalAlignment="Stretch" 
                             HorizontalAlignment="Stretch"
                             Margin="-3,-3,-3,0"
-                            Grid.Row="0">
+                            Grid.Row="0"
+                            CanUserAddRows="False">
                             <DataGrid.ItemContainerStyle>
                                 <Style TargetType="DataGridRow">
                                     <EventSetter 
                                         Event="MouseDoubleClick" 
-                                        Handler="DataGridRow_MouseDoubleClick"/>
+                                        Handler="PointsDataGridRow_MouseDoubleClick"/>
                                 </Style>
                             </DataGrid.ItemContainerStyle>
                             <DataGrid.Columns>
@@ -91,16 +95,17 @@
                             Orientation="Horizontal"
                             Grid.Row="1">
                             <Button
-                            Content="Добавить"
-                            Width="90"
-                            Height="30"
-                            Margin="0,0,10,0">
+                                Content="Добавить"
+                                Width="90"
+                                Height="30"
+                                Margin="0,0,10,0"
+                                Click="AddPoint_Click">
                             </Button>
                             <Button
-                            Content="Удалить"
-                            Grid.Row="1"
-                            Width="90"
-                            Height="30">
+                                Content="Удалить"
+                                Grid.Row="1"
+                                Width="90"
+                                Height="30">
                             </Button>
                         </StackPanel>
                     </Grid>
@@ -125,12 +130,13 @@
                             VerticalAlignment="Stretch" 
                             HorizontalAlignment="Stretch"
                             Margin="-3,-3,-3,0"
-                            Grid.Row="0">
+                            Grid.Row="0"
+                            CanUserAddRows="False">
                             <DataGrid.ItemContainerStyle>
                                 <Style TargetType="DataGridRow">
                                     <EventSetter 
                                         Event="MouseDoubleClick" 
-                                        Handler="DataGridRow_MouseDoubleClick"/>
+                                        Handler="DriversDataGridRow_MouseDoubleClick"/>
                                 </Style>
                             </DataGrid.ItemContainerStyle>
                             <DataGrid.Columns>
@@ -142,12 +148,18 @@
                                 <DataGridTextColumn 
                                     Binding="{Binding Drivers.IdTransport}" 
                                     Header="Name" 
-                                    Width="100" 
                                     IsReadOnly="True"/>
                                 <DataGridTextColumn 
-                                    Binding="{Binding Points.location}" 
-                                    Header="location" 
-                                    Width="100"
+                                    Binding="{Binding Drivers.Surname}" 
+                                    Header="Surname" 
+                                    IsReadOnly="True"/>
+                                <DataGridTextColumn 
+                                    Binding="{Binding Drivers.Name}" 
+                                    Header="Name" 
+                                    IsReadOnly="True"/>
+                                <DataGridTextColumn 
+                                    Binding="{Binding Drivers.Patronymic}" 
+                                    Header="Patronymic" 
                                     IsReadOnly="True"/>
                             </DataGrid.Columns>
                         </DataGrid>
@@ -171,8 +183,5 @@
                 </TabItem>
             </TabControl>
         </Grid>
-
-
-
     </Grid>
-</Window>
+</Window>

+ 48 - 0
Kusach/Windows/RouteEditWindow.xaml.cs

@@ -0,0 +1,48 @@
+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 Kusach.Windows
+{
+    /// <summary>
+    /// Логика взаимодействия для RouteEditWindow.xaml
+    /// </summary>
+    public partial class RouteEditWindow : Window
+    {
+        public RouteEditWindow(int id)
+        {
+            InitializeComponent(); 
+            RouteNameBox.Text = cnt.db.Routes.Where(item => item.IdRoute == id).Select(item => item.Name).FirstOrDefault();
+            PointsListDataGrid.ItemsSource = cnt.db.PointsList.Where(item => item.IdRoute == id).ToList();
+            DriversListDataGrid.ItemsSource = cnt.db.DriversList.Where(item => item.IdRoute == id).ToList();
+
+        }
+        private void PointsDataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            MessageBox.Show("cell: " + ((PointsList)PointsListDataGrid.SelectedItem).IdPoint);
+        }
+        private void DriversDataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            MessageBox.Show("cell: " + ((DriversList)DriversListDataGrid.SelectedItem).IdDriver);
+        }
+        private void AddPoint_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void ExitButton_Click(object sender, RoutedEventArgs e)
+        {
+            this.Close();
+        }
+    }
+}

+ 1 - 1
Kusach/cnt.cs

@@ -2,6 +2,6 @@
 {
     class cnt
     {
-        public static gr692_gavEntities db = new gr692_gavEntities();
+        public static EDMEntities db = new EDMEntities();
     }
 }