Browse Source

Добавлен просмотр услуг и страница добавления

Igor 7 tháng trước cách đây
mục cha
commit
a4c39e0c56

+ 16 - 0
src/DontHarmDesktop/DontHarmDesktop.csproj

@@ -86,8 +86,16 @@
       <SubType>Designer</SubType>
     </ApplicationDefinition>
     <Compile Include="AuthState.cs" />
+    <Compile Include="Pages\ServiceAdd.xaml.cs">
+      <DependentUpon>ServiceAdd.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Pages\Services.xaml.cs">
+      <DependentUpon>Services.xaml</DependentUpon>
+    </Compile>
     <Compile Include="ViewModels\AuthViewModel.cs" />
     <Compile Include="ViewModels\MainViewModel.cs" />
+    <Compile Include="ViewModels\ServiceAddViewModel.cs" />
+    <Compile Include="ViewModels\ServicesViewModel.cs" />
     <Page Include="Dictionaries\BrushesStyle.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -116,6 +124,14 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Pages\ServiceAdd.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Pages\Services.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Pages\UserInfoPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 3 - 1
src/DontHarmDesktop/MainWindow.xaml

@@ -32,6 +32,8 @@
                 VerticalAlignment="Center"
                 FontSize="18">Не навреди</TextBlock>
             <Button
+                Foreground="White"
+                Background="{StaticResource AccentColor}"
                 Command="{Binding LogoutCmd}"
                 Grid.Column="2"
                 Height="32"
@@ -48,7 +50,7 @@
         <!-- Body end -->
         
         <!-- Footer start -->
-        <Grid Background="{StaticResource SecondaryColor}" Grid.Row="2">
+        <Grid Background="{StaticResource AccentColor}" Grid.Row="2">
             <TextBlock 
                 Grid.Row="2"
                 x:Name="TimerTextBlock" 

+ 34 - 0
src/DontHarmDesktop/Pages/ServiceAdd.xaml

@@ -0,0 +1,34 @@
+<Page x:Class="DontHarmDesktop.Pages.ServiceAdd"
+      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:DontHarmDesktop.Pages" xmlns:viewmodels="clr-namespace:DontHarmDesktop.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:ServiceAddViewModel}"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="ServiceAdd">
+
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="Auto"/>
+            <ColumnDefinition Width="*"/>
+        </Grid.ColumnDefinitions>
+
+        <Grid.RowDefinitions>
+            <RowDefinition Height="32"/>
+            <RowDefinition Height="32"/>
+            <RowDefinition Height="32"/>
+            <RowDefinition Height="32"/>
+        </Grid.RowDefinitions>
+
+        <TextBlock Text="Наименование" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" />
+        <TextBlock Text="Цена" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" />
+        <TextBlock Text="Код" Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" />
+
+        <TextBox Grid.Row="0" Grid.Column="1" Margin="4" Text="{Binding Name}" />
+        <TextBox Grid.Row="1" Grid.Column="1" Margin="4" Text="{Binding Price}"/>
+        <TextBox Grid.Row="2" Grid.Column="1" Margin="4" Text="{Binding Code}"/>
+
+        <Button Grid.Row="3" Grid.Column="1" Margin="4" Background="{StaticResource SecondaryColor}">Сохранить</Button>
+    </Grid>
+</Page>

+ 28 - 0
src/DontHarmDesktop/Pages/ServiceAdd.xaml.cs

@@ -0,0 +1,28 @@
+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 DontHarmDesktop.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для ServiceAdd.xaml
+    /// </summary>
+    public partial class ServiceAdd : Page
+    {
+        public ServiceAdd()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 43 - 0
src/DontHarmDesktop/Pages/Services.xaml

@@ -0,0 +1,43 @@
+<Page x:Class="DontHarmDesktop.Pages.Services"
+      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:DontHarmDesktop.Pages" xmlns:viewmodels="clr-namespace:DontHarmDesktop.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:ServicesViewModel}"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="Services">
+
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*"/>
+            <RowDefinition Height="32"/>
+        </Grid.RowDefinitions>
+
+        <DataGrid Grid.Row="0" ItemsSource="{Binding Services}" AutoGenerateColumns="False" IsReadOnly="True">
+            <DataGrid.Columns>
+                <DataGridTextColumn Header="Наименование" Binding="{Binding name}"/>
+                <DataGridTextColumn Header="Цена" Binding="{Binding price}"/>
+                <DataGridTextColumn Header="Код услуги" Binding="{Binding code}"/>
+                <DataGridTemplateColumn>
+                    <DataGridTemplateColumn.CellTemplate>
+                        <DataTemplate>
+                            <Button Background="{StaticResource SecondaryColor}" Content="Редактировать"/>
+                        </DataTemplate>
+                    </DataGridTemplateColumn.CellTemplate>
+                </DataGridTemplateColumn>
+            </DataGrid.Columns>
+        </DataGrid>
+
+        <Grid Grid.Row="1">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="256"/>
+                <ColumnDefinition Width="*"/>
+                <ColumnDefinition Width="256"/>
+            </Grid.ColumnDefinitions>
+
+            <Button Grid.Column="0" Background="{StaticResource SecondaryColor}" Command="{Binding AddServiceCmd}">Добавить</Button>
+            <Button Grid.Column="2" Background="{StaticResource SecondaryColor}">Удалить</Button>
+        </Grid>
+    </Grid>
+</Page>

+ 29 - 0
src/DontHarmDesktop/Pages/Services.xaml.cs

@@ -0,0 +1,29 @@
+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 DontHarmDesktop.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для Services.xaml
+    /// </summary>
+    public partial class Services : Page
+    {
+        public Services()
+        {
+            InitializeComponent();
+            DataContext = new ViewModels.ServicesViewModel();
+        }
+    }
+}

+ 2 - 20
src/DontHarmDesktop/Pages/WelcomePage.xaml

@@ -21,26 +21,8 @@
                 <RowDefinition/>
                 <RowDefinition/>
             </Grid.RowDefinitions>
-            <Label Visibility="{Binding Path=AcceptWasteVisibility}" Name="AcceptWasteLabel" Grid.Row="0">
-                <Hyperlink>Принять отходы</Hyperlink>
-            </Label>
-            <Label Visibility="{Binding Path=MakeReportsVisibility}" Name="MakeReportsLabel" Grid.Row="1">
-                <Hyperlink>Сформировать отчёты</Hyperlink>
-            </Label>
-            <Label Visibility="{Binding Path=UtilizerVisibility}" Name="UtilizerLabel" Grid.Row="2">
-                <Hyperlink>Работа с утилизатором</Hyperlink>
-            </Label>
-            <Label Visibility="{Binding Path=ViewReportsVisibility}" Name="ViewReportsLabel" Grid.Row="3">
-                <Hyperlink>Просмотреть отчёты</Hyperlink>
-            </Label>
-            <Label Visibility="{Binding Path=MakeInvoiceVisibility}" Name="MakeInvoiceLabel" Grid.Row="4">
-                <Hyperlink>Сформировать счёт предприятию</Hyperlink>
-            </Label>
-            <Label Visibility="{Binding Path=LoginHistoryVisibility}" Name="LoginHistoryLabel" Grid.Row="5">
-                <Hyperlink NavigateUri="/Pages/LogOnHistory.xaml">Просмотр истории входа</Hyperlink>
-            </Label>
-            <Label Visibility="{Binding Path=UsageVisibility}" Name="UsageLabel" Grid.Row="6">
-                <Hyperlink>Просмотр расходов</Hyperlink>
+            <Label Grid.Row="0">
+                <Hyperlink NavigateUri="Services.xaml" >Просмотр услуг</Hyperlink>
             </Label>
         </Grid>
     </StackPanel>

+ 21 - 0
src/DontHarmDesktop/ViewModels/ServiceAddViewModel.cs

@@ -0,0 +1,21 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DontHarmDesktop.ViewModels
+{
+    class ServiceAddViewModel : BindableBase
+    {
+        public string Name { get; set; }
+        public float Price { get; set; }
+        public string Code { get; set; }
+
+        public ServiceAddViewModel()
+        {
+            
+        }
+    }
+}

+ 32 - 0
src/DontHarmDesktop/ViewModels/ServicesViewModel.cs

@@ -0,0 +1,32 @@
+using DontHarmDesktop.Models;
+using Prism.Commands;
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DontHarmDesktop.ViewModels
+{
+    class ServicesViewModel : BindableBase
+    {
+        public List<services> Services { get; set; }
+        public DelegateCommand AddServiceCmd { get; set; }
+        
+        public ServicesViewModel() 
+        {
+            var db = new Models.Entities();
+
+            // Сбор услуг, которые не скрыты
+            Services = db.services.Where(s => s.hidden == false).ToList();
+
+            AddServiceCmd = new DelegateCommand(AddServiceExecuted);
+        }
+
+        private void AddServiceExecuted()
+        {
+            (App.Current.MainWindow as MainWindow).MainFrame.Navigate(new Pages.ServiceAdd());
+        }
+    }
+}