Ver código fonte

Реорганизация страницы добро пожаловать

21IS02 7 meses atrás
pai
commit
7b0ecf102b

+ 9 - 7
src/DontHarmDesktop/DontHarmDesktop.csproj

@@ -87,6 +87,9 @@
     </ApplicationDefinition>
     <Compile Include="AuthState.cs" />
     <Compile Include="Navigation.cs" />
+    <Compile Include="Pages\Clients.xaml.cs">
+      <DependentUpon>Clients.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Pages\ServiceAdd.xaml.cs">
       <DependentUpon>ServiceAdd.xaml</DependentUpon>
     </Compile>
@@ -98,10 +101,12 @@
     </Compile>
     <Compile Include="Validation.cs" />
     <Compile Include="ViewModels\AuthViewModel.cs" />
+    <Compile Include="ViewModels\ClientsViewModel.cs" />
     <Compile Include="ViewModels\MainViewModel.cs" />
     <Compile Include="ViewModels\ServiceAddViewModel.cs" />
     <Compile Include="ViewModels\ServiceEditViewModel.cs" />
     <Compile Include="ViewModels\ServicesViewModel.cs" />
+    <Compile Include="ViewModels\WelcomeViewModel.cs" />
     <Page Include="Dictionaries\BrushesStyle.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -138,6 +143,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="Pages\Clients.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Pages\LogOnHistory.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -154,10 +163,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Pages\UserInfoPage.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="Pages\WelcomePage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -218,9 +223,6 @@
     <Compile Include="Pages\LogOnHistory.xaml.cs">
       <DependentUpon>LogOnHistory.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Pages\UserInfoPage.xaml.cs">
-      <DependentUpon>UserInfoPage.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Pages\WelcomePage.xaml.cs">
       <DependentUpon>WelcomePage.xaml</DependentUpon>
     </Compile>

+ 6 - 9
src/DontHarmDesktop/Pages/AuthPage.xaml

@@ -12,20 +12,17 @@
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition Height="Auto"/>
-            <RowDefinition Height="64"/>
-            <RowDefinition Height="64"/>
-            <RowDefinition Height="64"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="48"/>
         </Grid.RowDefinitions>
 
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="*"/>
-        </Grid.ColumnDefinitions>
-        
         <TextBlock
             Grid.Row="0" 
+            TextAlignment="Center"
+            HorizontalAlignment="Center"
             Padding="8"
-            FontSize="18"
-            TextAlignment="Center">
+            FontSize="18">
             Добро пожаловать в Не навреди!<LineBreak/>Пожалуйста, авторизуйтесь
         </TextBlock>
 

+ 23 - 0
src/DontHarmDesktop/Pages/Clients.xaml

@@ -0,0 +1,23 @@
+<Page x:Class="DontHarmDesktop.Pages.Clients"
+      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"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="Clients">
+
+    <StackPanel Style="{StaticResource FormContainer}">
+        <TextBlock Text="Список клиентов" Style="{StaticResource H2}"/>
+        <Grid Style="{StaticResource FormBody}">
+            <ListView ItemsSource="{Binding}">
+                <ListView.ItemTemplate>
+                    <DataTemplate>
+                        
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+            </ListView>
+        </Grid>
+    </StackPanel>
+</Page>

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

+ 0 - 15
src/DontHarmDesktop/Pages/UserInfoPage.xaml

@@ -1,15 +0,0 @@
-<Page x:Class="DontHarmDesktop.Pages.UserInfoPage"
-      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"
-      mc:Ignorable="d" 
-      d:DesignHeight="450" d:DesignWidth="800"
-      Title="NavigationPage">
-
-    <StackPanel Orientation="Horizontal">
-        <Image x:Name="ProfilePictureImage" Source="{Binding Path=ProfileImagePath}" Width="64" Height="64"/>
-        <TextBlock x:Name="GreetingTextBlock"/>
-    </StackPanel>
-</Page>

+ 0 - 51
src/DontHarmDesktop/Pages/UserInfoPage.xaml.cs

@@ -1,51 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data.Entity.Infrastructure;
-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;
-using static System.Net.Mime.MediaTypeNames;
-
-namespace DontHarmDesktop.Pages
-{
-    /// <summary>
-    /// Логика взаимодействия для UserInfoPage.xaml
-    /// </summary>
-    public partial class UserInfoPage : Page
-    {
-        private string UserImagePath;
-        public UserInfoPage()
-        {
-            InitializeComponent();
-            DataContext = this;
-
-            var db = new Models.Entities();
-                
-            Models.users current_user = AuthState.CurrentUser;
-            UserImagePath = current_user.image_path;
-
-            // Получение названия роли
-            Models.roles role = db.roles.First(r => r.id == current_user.role);
-
-            GreetingTextBlock.Text = $"Добро пожаловать, {current_user.surname} {current_user.name} {current_user.patronymic} ({role.name})";
-            //ProfilePictureImage.Source = new BitmapImage( new Uri("pack://application:,,,/Images/ProfilePictures/" + current_user.image_path, UriKind.Absolute));
-        }
-
-        public string ProfileImagePath
-        {
-            get
-            {
-                return "/Images/ProfilePictures/" + UserImagePath;
-            }
-        }
-    }
-}

+ 6 - 3
src/DontHarmDesktop/Pages/WelcomePage.xaml

@@ -3,14 +3,14 @@
       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:local="clr-namespace:DontHarmDesktop.Pages" xmlns:viewmodels="clr-namespace:DontHarmDesktop.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:WelcomeViewModel}"
       mc:Ignorable="d" 
       d:DesignHeight="450" d:DesignWidth="800"
       Title="WelcomePage"
       ShowsNavigationUI="False">
 
-    <StackPanel>
-        <Frame Source="/Pages/UserInfoPage.xaml"/>
+    <StackPanel Style="{StaticResource FormContainer}">
+        <TextBlock Text="{Binding GreetingsText}" Style="{StaticResource H2}"/>
         <Grid>
             <Grid.RowDefinitions>
                 <RowDefinition/>
@@ -24,6 +24,9 @@
             <Label Grid.Row="0">
                 <Hyperlink NavigateUri="Services.xaml" >Просмотр услуг</Hyperlink>
             </Label>
+            <Label Grid.Row="1">
+                <Hyperlink NavigateUri="Clients.xaml" >Просмотр клиентов</Hyperlink>
+            </Label>
         </Grid>
     </StackPanel>
 </Page>

+ 1 - 126
src/DontHarmDesktop/Pages/WelcomePage.xaml.cs

@@ -23,132 +23,7 @@ namespace DontHarmDesktop.Pages
         public WelcomePage()
         {
             InitializeComponent();
-            this.DataContext = this;
-        }
-
-        /// <summary>
-        /// Конвертор роли в видимость ссылки принятия отходов
-        /// </summary>
-        public Visibility AcceptWasteVisibility
-        {
-            get
-            {
-                if (AuthState.CurrentUser.role == 3)
-                {
-                    return Visibility.Visible;
-                } else { 
-                    return Visibility.Collapsed;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Конвертор роли в видимость ссылки работы с утилизатором
-        /// </summary>
-        public Visibility UtilizerVisibility
-        {
-            get
-            {
-                if (AuthState.CurrentUser.role == 4)
-                {
-                    return Visibility.Visible;
-                }
-                else
-                {
-                    return Visibility.Collapsed;
-                }
-            }
-        }
-
-
-        /// <summary>
-        /// Конвертор роли в видимость ссылки формирования отчётов
-        /// </summary>
-        public Visibility MakeReportsVisibility
-        {
-            get
-            {
-                if (AuthState.CurrentUser.role == 3 || AuthState.CurrentUser.role == 1)
-                {
-                    return Visibility.Visible;
-                }
-                else
-                {
-                    return Visibility.Collapsed;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Конвертор роли в видимость ссылки просмотра отчётов
-        /// </summary>
-        public Visibility ViewReportsVisibility
-        {
-            get
-            {
-                if (AuthState.CurrentUser.role == 2)
-                {
-                    return Visibility.Visible;
-                }
-                else
-                {
-                    return Visibility.Collapsed;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Конвертор роли в видимость ссылки формирования счёта предприятию
-        /// </summary>
-        public Visibility MakeInvoiceVisibility
-        {
-            get
-            {
-                if (AuthState.CurrentUser.role == 2)
-                {
-                    return Visibility.Visible;
-                }
-                else
-                {
-                    return Visibility.Collapsed;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Конвертор роли в видимость ссылки просмотра истории логинов
-        /// </summary>
-        public Visibility LoginHistoryVisibility
-        {
-            get
-            {
-                if (AuthState.CurrentUser.role == 1)
-                {
-                    return Visibility.Visible;
-                }
-                else
-                {
-                    return Visibility.Collapsed;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Конвертор роли в видимость ссылки просмотра расходов
-        /// </summary>
-        public Visibility UsageVisibility
-        {
-            get
-            {
-                if (AuthState.CurrentUser.role == 1)
-                {
-                    return Visibility.Visible;
-                }
-                else
-                {
-                    return Visibility.Collapsed;
-                }
-            }
+            DataContext = new ViewModels.WelcomeViewModel(AuthState.CurrentUser);
         }
     }
 }

+ 12 - 0
src/DontHarmDesktop/ViewModels/ClientsViewModel.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DontHarmDesktop.ViewModels
+{
+    public class ClientsViewModel
+    {
+    }
+}

+ 25 - 0
src/DontHarmDesktop/ViewModels/WelcomeViewModel.cs

@@ -0,0 +1,25 @@
+using Prism.Mvvm;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DontHarmDesktop.ViewModels
+{
+    public class WelcomeViewModel : BindableBase
+    {
+        /// <summary>
+        /// Текст "Добро пожаловать"
+        /// </summary>
+        public string GreetingsText { get; set; }
+
+        public WelcomeViewModel(Models.users user)
+        {
+            var db = new Models.Entities();
+            Models.roles role = db.roles.First(r => r.id == user.role);
+
+            GreetingsText = $"Добро пожаловать, {user.surname} {user.name} {user.patronymic} ({role.name})";
+        }
+    }
+}