Артем Гавриленко 3 年 前
コミット
7778fa676a

+ 7 - 7
Kusach/Kusach.csproj

@@ -67,6 +67,9 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="Pages\DispatcherListPage.xaml.cs">
+      <DependentUpon>DispatcherListPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Pages\DriversListPage.xaml.cs">
       <DependentUpon>DriversListPage.xaml</DependentUpon>
     </Compile>
@@ -153,9 +156,6 @@
     <Compile Include="RegWindow.xaml.cs">
       <DependentUpon>RegWindow.xaml</DependentUpon>
     </Compile>
-    <Compile Include="TestPGPage.xaml.cs">
-      <DependentUpon>TestPGPage.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Windows\DriverEditWindow.xaml.cs">
       <DependentUpon>DriverEditWindow.xaml</DependentUpon>
     </Compile>
@@ -168,6 +168,10 @@
     <Compile Include="Windows\TransportEditWindow.xaml.cs">
       <DependentUpon>TransportEditWindow.xaml</DependentUpon>
     </Compile>
+    <Page Include="Pages\DispatcherListPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Pages\DriversListPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -228,10 +232,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="TestPGPage.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="Windows\DriverEditWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 1 - 1
Kusach/MainWindow.xaml.cs

@@ -39,7 +39,7 @@ namespace Kusach
 
         private void UsersButton_Click(object sender, RoutedEventArgs e)
         {
-            MainFrame.Content = new TestPGPage();
+            MainFrame.Content = new Pages.DispatcherListPage();
         }
         #endregion
 

+ 92 - 0
Kusach/Pages/DispatcherListPage.xaml

@@ -0,0 +1,92 @@
+<Page x:Class="Kusach.Pages.DispatcherListPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:Kusach.Pages"
+      mc:Ignorable="d"
+      d:DesignHeight="419"
+      d:DesignWidth="692"
+      Title="DispatcherListPage">
+    <Grid 
+        Background="White" 
+        Margin="25">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="4*"/>
+            <RowDefinition Height="21*"/>
+        </Grid.RowDefinitions>
+        <StackPanel Orientation="Horizontal">
+            <TextBox
+                Name="SearchBox"
+                PreviewMouseLeftButtonUp="SearchBoxPreviewMouseLeftButtonUp"
+                LostFocus="SearchLostFocus"
+                TextChanged="SearchTextChanged"
+                FontSize="14"
+                TextWrapping="Wrap"
+                Text="Поиск..." 
+                Width="120"/>
+            <Button
+                Width="120"
+                Content="Создать"
+                Click="AddDispatcherButton_Click"/>
+            <Button
+                Width="120"
+                Content="Удалить"
+                Click="DeleteDispatcherButton_Click"/>
+            <Button
+                Width="120"
+                Content="Обновить"
+                Click="UpdateDispatcherButton_Click"/>
+        </StackPanel>
+        <DataGrid
+            Name="DispatcherList" 
+            Grid.Row="1"
+            AutoGenerateColumns="False" 
+            VerticalAlignment="Top" 
+            HorizontalAlignment="Left" 
+            CanUserAddRows="false" Width="642">
+            <DataGrid.ItemContainerStyle>
+                <Style TargetType="DataGridRow">
+                    <EventSetter 
+                        Event="MouseDoubleClick" 
+                        Handler="DataGridRow_MouseDoubleClick"/>
+                </Style>
+            </DataGrid.ItemContainerStyle>
+            <DataGrid.Columns>
+                <DataGridTextColumn 
+                    Binding="{Binding IdDispatcher}" 
+                    Header="Номер"  
+                    Width="50" 
+                    IsReadOnly="True"/>
+                <DataGridTextColumn 
+                    Binding="{Binding Login}" 
+                    Header="Логин" 
+                    IsReadOnly="True"/>
+                <DataGridTextColumn 
+                    Binding="{Binding Password}" 
+                    Header="Пароль" 
+                    IsReadOnly="True"/>
+                <DataGridTextColumn 
+                    Binding="{Binding Surname}" 
+                    Header="Фамилия" 
+                    IsReadOnly="True"/>
+                <DataGridTextColumn 
+                    Binding="{Binding Name}" 
+                    Header="Имя" 
+                    IsReadOnly="True"/>
+                <DataGridTextColumn 
+                    Binding="{Binding Patronymic}" 
+                    Header="Отчество" 
+                    IsReadOnly="True"/>
+                <DataGridTextColumn 
+                    Binding="{Binding Birthday}" 
+                    Header="День рождения" 
+                    IsReadOnly="True"/>
+                <DataGridTextColumn 
+                    Binding="{Binding PhoneNumber}" 
+                    Header="Номер телефона" 
+                    IsReadOnly="True"/>
+            </DataGrid.Columns>
+        </DataGrid>
+    </Grid>
+</Page>

+ 67 - 0
Kusach/Pages/DispatcherListPage.xaml.cs

@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Kusach.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для DispatcherListPage.xaml
+    /// </summary>
+    public partial class DispatcherListPage : Page
+    {
+        public DispatcherListPage()
+        {
+            InitializeComponent();
+            DispatcherList.ItemsSource = cnt.db.Dispatcher.ToList();
+        }
+        private void DataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+        {
+            
+        }
+
+        #region Поиск
+        private void SearchBoxPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            if (SearchBox.Text == "Поиск...")
+                SearchBox.Text = "";
+        }
+        private void SearchLostFocus(object sender, RoutedEventArgs e)
+        {
+            if (SearchBox.Text == "")
+                SearchBox.Text = "Поиск...";
+        }
+        private void SearchTextChanged(object sender, TextChangedEventArgs e)
+        {
+            if (SearchBox.Text != "" && SearchBox.Text != "Поиск...")
+                DispatcherList.ItemsSource = cnt.db.Dispatcher.Where(item => (item.IdDispatcher + " " + item.Login + " " + item.Surname + " " + item.Name + " " + item.Patronymic + " " + item.Birthday + " " + item.PhoneNumber).Contains(SearchBox.Text)).ToList();
+            else
+                cnt.db.Dispatcher.ToList();
+        }
+        #endregion
+        private void AddDispatcherButton_Click(object sender, RoutedEventArgs e)
+        {
+            
+        }
+
+        private void DeleteDispatcherButton_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void UpdateDispatcherButton_Click(object sender, RoutedEventArgs e)
+        {
+            DispatcherList.ItemsSource = cnt.db.Dispatcher.ToList();
+        }
+    }
+}

+ 0 - 19
Kusach/TestPGPage.xaml

@@ -1,19 +0,0 @@
-<Page x:Class="Kusach.TestPGPage"
-      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-      xmlns:local="clr-namespace:Kusach"
-      mc:Ignorable="d" 
-      d:DesignHeight="450" 
-      d:DesignWidth="800"
-      Title="TestPGPage">
-
-    <Grid Background="White">
-        <StackPanel Margin="5">
-            <Label Margin="5">Пример обычной страницы</Label>
-            <Button Margin="5,0,5,0" Padding="5">OK</Button>
-            <Button Padding="5" Margin="5">Close</Button>
-        </StackPanel>
-    </Grid>
-</Page>

+ 0 - 15
Kusach/TestPGPage.xaml.cs

@@ -1,15 +0,0 @@
-using System.Windows.Controls;
-
-namespace Kusach
-{
-    /// <summary>
-    /// Логика взаимодействия для TestPGPage.xaml
-    /// </summary>
-    public partial class TestPGPage : Page
-    {
-        public TestPGPage()
-        {
-            InitializeComponent();
-        }
-    }
-}