@@ -9,6 +9,13 @@ namespace BPASmart.Model.用户 | |||
{ | |||
public class LocalUser | |||
{ | |||
public ObservableCollection<UserManager> UserManagers { get; set; } = new ObservableCollection<UserManager>(); | |||
/// <summary> | |||
/// 普通用户 | |||
/// </summary> | |||
public ObservableCollection<UserManager> UserManagers { get; set; } = new ObservableCollection<UserManager>(); | |||
/// <summary> | |||
/// 高等级用户 | |||
/// </summary> | |||
public ObservableCollection<UserManager> HighGradeUsers { get; set; } = new ObservableCollection<UserManager>(); | |||
} | |||
} |
@@ -1,5 +1,6 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
@@ -8,10 +9,31 @@ namespace BPASmart.Model.用户 | |||
{ | |||
public class UserManager | |||
{ | |||
public string UserID { get; set; } | |||
/// <summary> | |||
/// 用户ID | |||
/// </summary> | |||
public string? UserID { get; set; } | |||
public string UserName { get; set; } | |||
/// <summary> | |||
/// 用户名 | |||
/// </summary> | |||
public string? UserName { get; set; } | |||
public string Password { get; set; } | |||
/// <summary> | |||
/// 用户密码 | |||
/// </summary> | |||
public string? Password { get; set; } | |||
/// <summary> | |||
/// 用户权限等级 | |||
/// </summary> | |||
public UserPower userPower { get; set; } = UserPower.普通用户权限; | |||
/// <summary> | |||
/// 用户权限列表 | |||
/// </summary> | |||
public ObservableCollection<string> powerList { get; set; } = new ObservableCollection<string>(); | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.用户 | |||
{ | |||
public enum UserPower | |||
{ | |||
开发者权限 = 0, | |||
管理员权限 = 1, | |||
普通用户权限 = 2 | |||
} | |||
} |
@@ -21,7 +21,12 @@ | |||
<None Remove="Image\尺条框.png" /> | |||
<None Remove="Image\成功提示.png" /> | |||
<None Remove="Image\按钮背景.png" /> | |||
<None Remove="Image\方形.png" /> | |||
<None Remove="Image\方形背景.png" /> | |||
<None Remove="Image\权限背景.png" /> | |||
<None Remove="Image\用户名边框.png" /> | |||
<None Remove="Image\用户名边框1.png" /> | |||
<None Remove="Image\用户边框1.png" /> | |||
<None Remove="Image\科技警告.png" /> | |||
<None Remove="Image\背景4.png" /> | |||
<None Remove="Image\边框.png" /> | |||
@@ -40,7 +45,12 @@ | |||
<Resource Include="Image\尺条框.png" /> | |||
<Resource Include="Image\成功提示.png" /> | |||
<Resource Include="Image\按钮背景.png" /> | |||
<Resource Include="Image\方形.png" /> | |||
<Resource Include="Image\方形背景.png" /> | |||
<Resource Include="Image\权限背景.png" /> | |||
<Resource Include="Image\用户名边框.png" /> | |||
<Resource Include="Image\用户名边框1.png" /> | |||
<Resource Include="Image\用户边框1.png" /> | |||
<Resource Include="Image\科技警告.png" /> | |||
<Resource Include="Image\背景4.png" /> | |||
<Resource Include="Image\边框.png" /> | |||
@@ -6,8 +6,8 @@ using System.Threading.Tasks; | |||
namespace BPASmart.UserManagement.Globle | |||
{ | |||
public class GlobleData | |||
public static class GlobleData | |||
{ | |||
public static UserManager ChangeUser = new UserManager(); | |||
} | |||
} |
@@ -6,8 +6,9 @@ | |||
xmlns:local="clr-namespace:BPASmart.UserManagement" | |||
mc:Ignorable="d" | |||
Title="MessageBox" Height="110" Width="240" | |||
WindowStartupLocation="CenterOwner" WindowStyle="None" AllowsTransparency="True" Background="Transparent" Topmost="True" ResizeMode="NoResize" ShowInTaskbar="False"> | |||
<Border MouseLeftButtonDown="Border_MouseLeftButtonDown" Background="Black" Opacity="0.9" CornerRadius="10"> | |||
WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True" Background="Transparent" Topmost="True" ResizeMode="NoResize" ShowInTaskbar="False" | |||
KeyDown="Window_KeyDown"> | |||
<Border MouseLeftButtonDown="Border_MouseLeftButtonDown" Background="#363636" Opacity="0.9" CornerRadius="10"> | |||
<Border> | |||
<Border.Background> | |||
@@ -38,10 +39,22 @@ | |||
<Border.Background> | |||
<ImageBrush ImageSource="../Image/按钮背景.png"/> | |||
</Border.Background> | |||
<TextBlock Text="确 定" FontSize="16" Margin="15,0" Foreground="#056F75" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<TextBlock x:Name="textSure" Text="确 定" FontSize="16" Margin="15,0" HorizontalAlignment="Center" VerticalAlignment="Center"> | |||
<TextBlock.Foreground> | |||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> | |||
<GradientStop Color="#FF056F75" Offset="0"/> | |||
<GradientStop Color="#888FFAFF" Offset="0.4"/> | |||
<GradientStop Color="#888FFAFF" Offset="0.6"/> | |||
<GradientStop Color="#FF056F75" Offset="1"/> | |||
</LinearGradientBrush> | |||
</TextBlock.Foreground> | |||
</TextBlock> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="textSure" Property="Foreground" Value="#FF00FFFF" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Button.Template> | |||
</Button> | |||
@@ -95,6 +95,14 @@ namespace BPASmart.UserManagement | |||
{ | |||
this.DragMove(); | |||
} | |||
private void Window_KeyDown(object sender, KeyEventArgs e) | |||
{ | |||
if(e.Key == Key.Enter) | |||
{ | |||
Close(); | |||
} | |||
} | |||
} | |||
} | |||
@@ -103,6 +103,7 @@ | |||
</Grid> | |||
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="top"> | |||
<Button | |||
x:Name="registerButton" | |||
Grid.Column="1" | |||
Command="{Binding ResgisterUserCommand}" | |||
Content="注 册" | |||
@@ -38,7 +38,8 @@ namespace BPASmart.UserManagement.View | |||
private void pb2_KeyDown(object sender, KeyEventArgs e) | |||
{ | |||
if (e.Key == Key.Enter) registerButton.Focus(); | |||
} | |||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) | |||
@@ -4,24 +4,148 @@ | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmart.UserManagement.View" | |||
xmlns:common="clr-namespace:BPASmart.UserManagement.Helper" | |||
xmlns:vm ="clr-namespace:BPASmart.UserManagement.ViewModel" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800" FontFamily="楷体"> | |||
<Border Margin="100,80"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="../Image/user背景.png" Stretch="Fill"/> | |||
</Border.Background> | |||
<UserControl.DataContext> | |||
<vm:ChangeUserViewModel/> | |||
</UserControl.DataContext> | |||
<Border Margin="100,40"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="../Image/user背景.png" Stretch="Fill"/> | |||
</Border.Background> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="1.2*"/> | |||
<RowDefinition Height="6*"/> | |||
<RowDefinition Height="10*"/> | |||
<RowDefinition Height="20*"/> | |||
<RowDefinition Height="20*"/> | |||
<RowDefinition Height="13*"/> | |||
<RowDefinition Height="44*"/> | |||
<RowDefinition Height="27*"/> | |||
<RowDefinition Height="173*"/> | |||
<RowDefinition Height="40*"/> | |||
<RowDefinition Height="77*"/> | |||
</Grid.RowDefinitions> | |||
<TextBlock Grid.Row="1" Text="修改密码" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#009DFF" | |||
FontSize="22"/> | |||
FontSize="24" Height="30" Width="96" /> | |||
<TextBlock Grid.Row="2" Text="{Binding UserName}" VerticalAlignment="Bottom" HorizontalAlignment="Center" Foreground="Orange" FontSize="20" Height="23" /> | |||
<Grid Grid.Row="3" VerticalAlignment="Center" Height="150" Width="260"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="*"/> | |||
</Grid.RowDefinitions> | |||
<PasswordBox | |||
Name="pb0" | |||
Margin="5" | |||
common:PasswordHelper.Attach="True" | |||
common:PasswordHelper.Password="{Binding LastPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | |||
BorderBrush="#009DFF" | |||
BorderThickness="3" | |||
FontSize="20" | |||
Height="40" | |||
Foreground="#009DFF" | |||
KeyDown="pb_KeyDown" | |||
PasswordChanged="pb0_PasswordChanged" | |||
Style="{DynamicResource PasswordBoxStyle}" | |||
TabIndex="2" /> | |||
<PasswordBox | |||
Name="pb1" | |||
Grid.Row="1" | |||
Margin="5" | |||
common:PasswordHelper.Attach="True" | |||
common:PasswordHelper.Password="{Binding UserPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | |||
BorderBrush="#009DFF" | |||
BorderThickness="3" | |||
FontSize="20" | |||
Height="40" | |||
Foreground="#009DFF" | |||
KeyDown="pb_KeyDown" | |||
PasswordChanged="PasswordBox_PasswordChanged" | |||
Style="{DynamicResource PasswordBoxStyle}" | |||
TabIndex="2" /> | |||
<PasswordBox | |||
Name="pb2" | |||
Grid.Row="2" | |||
Margin="5" | |||
common:PasswordHelper.Attach="True" | |||
common:PasswordHelper.Password="{Binding ConfirmPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | |||
BorderBrush="#009DFF" | |||
BorderThickness="3" | |||
FontSize="20" | |||
Height="40" | |||
Foreground="#009DFF" | |||
KeyDown="pb2_KeyDown" | |||
PasswordChanged="PasswordBox2_PasswordChanged" | |||
Style="{DynamicResource PasswordBoxStyle}" | |||
TabIndex="2" /> | |||
<TextBlock | |||
Name="mark0Text" | |||
Grid.Row="0" | |||
Margin="58,5" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#88009dff" | |||
IsHitTestVisible="False" | |||
Text="请输入原始密码" | |||
Visibility="Visible" /> | |||
<TextBlock | |||
Name="markText" | |||
Grid.Row="1" | |||
Margin="58,5" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#88009dff" | |||
IsHitTestVisible="False" | |||
Text="请输入账号密码" | |||
Visibility="Visible" /> | |||
<TextBlock | |||
Name="mark2Text" | |||
Grid.Row="2" | |||
Margin="58,5" | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="#88009dff" | |||
IsHitTestVisible="False" | |||
Text="请再次确认密码" | |||
Visibility="Visible" /> | |||
</Grid> | |||
<StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Height="29" Width="320"> | |||
<Button | |||
x:Name="saveButton" | |||
Grid.Column="1" | |||
Command="{Binding SaveUserCommand}" | |||
Content="保 存" | |||
Style="{StaticResource CommonButton}" | |||
FontSize="20" | |||
TabIndex="3" | |||
Width="120" | |||
Background="#009DFF" | |||
Foreground="White" | |||
VerticalAlignment="Top" | |||
Margin="20,0"/> | |||
<Button | |||
Command="{Binding ExitCommand}" | |||
Content="退 出" FontSize="20" | |||
Width="120" | |||
Style="{StaticResource CommonButton}" | |||
Background="#009DFF" | |||
Foreground="White" | |||
VerticalAlignment="Top" | |||
Margin="20,0" | |||
/> | |||
</StackPanel> | |||
<StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top" Visibility="{Binding ErrorVisibility}" Width="auto" > | |||
<Image Source="../image/科技警告.png" Width="25" Height="25" Stretch="Fill"/> | |||
<TextBlock Margin="10,0" Text="{Binding ErrorMessage}" Foreground="#FF3F36" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||
</StackPanel> | |||
</Grid> | |||
</Border> | |||
</Border> | |||
</UserControl> |
@@ -24,5 +24,34 @@ namespace BPASmart.UserManagement.View | |||
{ | |||
InitializeComponent(); | |||
} | |||
private void pb0_PasswordChanged(object sender, RoutedEventArgs e) | |||
{ | |||
this.mark0Text.Visibility = this.pb0.Password.Length > 0 ? Visibility.Collapsed : Visibility.Visible; | |||
} | |||
private void TextBox_KeyDown(object sender, KeyEventArgs e) | |||
{ | |||
if (e.Key == Key.Enter) pb1.Focus(); | |||
} | |||
private void pb_KeyDown(object sender, KeyEventArgs e) | |||
{ | |||
if (e.Key == Key.Enter) pb2.Focus(); | |||
} | |||
private void pb2_KeyDown(object sender, KeyEventArgs e) | |||
{ | |||
if (e.Key == Key.Enter) saveButton.Focus(); | |||
} | |||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) | |||
{ | |||
this.markText.Visibility = this.pb1.Password.Length > 0 ? Visibility.Collapsed : Visibility.Visible; | |||
} | |||
private void PasswordBox2_PasswordChanged(object sender, RoutedEventArgs e) | |||
{ | |||
this.mark2Text.Visibility = this.pb2.Password.Length > 0 ? Visibility.Collapsed : Visibility.Visible; | |||
} | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
<UserControl x:Class="BPASmart.UserManagement.View.EditPower" | |||
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:BPASmart.UserManagement.View" | |||
mc:Ignorable="d" | |||
d:DesignHeight="450" d:DesignWidth="800" FontFamily="楷体"> | |||
<Border> | |||
<Border.Background> | |||
<ImageBrush ImageSource="../image/方形背景.png"/> | |||
</Border.Background> | |||
<Grid> | |||
</Grid> | |||
</Border> | |||
</UserControl> |
@@ -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 BPASmart.UserManagement.View | |||
{ | |||
/// <summary> | |||
/// EditPower.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class EditPower : UserControl | |||
{ | |||
public EditPower() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -28,39 +28,39 @@ | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||
<Border x:Name="IconBorder" CornerRadius="4" BorderThickness="1" Background="Transparent"> | |||
<Grid Margin="20,5,0,5" HorizontalAlignment="Left" > | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="auto"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock x:Name="userIcon" Text="" FontFamily="pack://application:,,,/Fonts/#iconfont" | |||
<Border x:Name="IconBorder" CornerRadius="4" BorderThickness="0,1,0,1" Background="Transparent" Opacity="0.8"> | |||
<Grid Margin="20,10,0,10" HorizontalAlignment="Left" > | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="auto"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock x:Name="userIcon" Text="" FontFamily="pack://application:,,,/Fonts/#iconfont" | |||
Foreground="{DynamicResource commanTextblock}" FontSize="26" | |||
HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||
<TextBlock x:Name="userText" Grid.Column="1" Text="{Binding UserName}" Foreground="{DynamicResource commanTextblock}" | |||
<TextBlock x:Name="userText" Grid.Column="1" Text="{Binding UserName}" Foreground="{DynamicResource commanTextblock}" | |||
FontSize="18" FontFamily="楷体" | |||
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,5,0,0"/> | |||
</Grid> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
</Grid> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="IconBorder" Property="BorderBrush" Value="Transparent"/> | |||
<Setter TargetName="IconBorder" Property="Background" Value=" #3A5FCD"> | |||
<Setter TargetName="IconBorder" Property="BorderBrush" Value="#ff8EE5EE"/> | |||
<Setter TargetName="IconBorder" Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Image/用户名边框.png"/> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="userText" Property="Foreground" Value="Orange"/> | |||
<Setter TargetName="userIcon" Property="Foreground" Value="Orange"/> | |||
<!--<Setter TargetName="userImage" Property="Source" Value="../image/账户黄.png"/>--> | |||
</Trigger> | |||
<Trigger Property="IsFocused" Value="true"> | |||
<!--<Setter TargetName="IconBorder" Property="BorderBrush" Value="#ff8EE5EE"/>--> | |||
<Setter TargetName="IconBorder" Property="Background"> | |||
<Setter.Value> | |||
<LinearGradientBrush StartPoint="1,0" EndPoint="1,1"> | |||
<GradientStop Color="#87CEFA" Offset="0"/> | |||
<GradientStop Color=" #3A5FCD" Offset="0.2"/> | |||
<GradientStop Color=" #1C86EE" Offset="0.4"/> | |||
<GradientStop Color=" #87CEFA" Offset="1"/> | |||
</LinearGradientBrush> | |||
<ImageBrush ImageSource="../Image/方形.png"/> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="userText" Property="Foreground" Value="Orange"/> | |||
@@ -80,84 +80,87 @@ | |||
</UserControl.Resources> | |||
<Border> | |||
<Border.Background> | |||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> | |||
<!--<LinearGradientBrush StartPoint="0,0" EndPoint="1,1"> | |||
<GradientStop Color="#FF00203B" Offset="0"/> | |||
<GradientStop Color="#FF020026" Offset="1"/> | |||
</LinearGradientBrush> | |||
</LinearGradientBrush>--> | |||
<ImageBrush ImageSource="../Image/用户边框1.png"/> | |||
</Border.Background> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40"/> | |||
<RowDefinition Height="*"/> | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" > | |||
<Image Source="../image/List.png" Height="19" Margin="2,2,4,0" VerticalAlignment="Center" HorizontalAlignment="Stretch"/> | |||
<TextBlock Text="用户列表" Foreground="White" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
</StackPanel> | |||
<Border Grid.Row="1" BorderBrush="White" BorderThickness="0,1,0,0"> | |||
<ScrollViewer Grid.Row="1" Template="{DynamicResource ScrollViewerControlTemplate1 }" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="12*"/> | |||
</Grid.RowDefinitions> | |||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" > | |||
<Image Source="../image/List.png" Height="19" Margin="2,2,4,0" VerticalAlignment="Center" HorizontalAlignment="Stretch"/> | |||
<TextBlock Text="用户列表" Foreground="White" FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
</StackPanel> | |||
<Border Grid.Row="1" BorderBrush="Transparent" BorderThickness="0,1,0,0"> | |||
<ScrollViewer Background="Transparent" | |||
Grid.Row="1" Margin="5" Template="{DynamicResource ScrollViewerControlTemplate1 }" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> | |||
<ListBox Style="{DynamicResource listbox}" ItemContainerStyle="{DynamicResource ItemContainer}" ItemsSource="{Binding userManagers}" > | |||
<ListBox.ContextMenu> | |||
<ContextMenu Height="auto"> | |||
<MenuItem Command="{Binding RegisterNewUserCommand}" > | |||
<MenuItem.Header> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Style="{DynamicResource menuText}" Text=""/> | |||
<TextBlock Grid.Column="1" Text="注册新用户" Style="{DynamicResource menuText}" FontFamily="楷体"/> | |||
</Grid> | |||
</MenuItem.Header> | |||
</MenuItem> | |||
<MenuItem Command="{Binding ChangePasswordCommand}" | |||
<ListBox Style="{DynamicResource listbox}" ItemContainerStyle="{DynamicResource ItemContainer}" ItemsSource="{Binding userManagers}" > | |||
<ListBox.ContextMenu> | |||
<ContextMenu Height="auto"> | |||
<MenuItem Command="{Binding RegisterNewUserCommand}" > | |||
<MenuItem.Header> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Style="{DynamicResource menuText}" Text=""/> | |||
<TextBlock Grid.Column="1" Text="注册新用户" Style="{DynamicResource menuText}" FontFamily="楷体"/> | |||
</Grid> | |||
</MenuItem.Header> | |||
</MenuItem> | |||
<MenuItem Command="{Binding ChangePasswordCommand}" | |||
CommandParameter="{Binding PlacementTarget.SelectedItem,RelativeSource={RelativeSource AncestorType=ContextMenu,Mode=FindAncestor}}"> | |||
<MenuItem.Header> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Style="{DynamicResource menuText}" Text=""/> | |||
<TextBlock Grid.Column="1" Text="修改密码" Style="{DynamicResource menuText}" FontFamily="楷体" /> | |||
</Grid> | |||
</MenuItem.Header> | |||
</MenuItem> | |||
<MenuItem Command="{Binding EditUsetPowerCommand}" | |||
<MenuItem.Header> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Style="{DynamicResource menuText}" Text=""/> | |||
<TextBlock Grid.Column="1" Text="修改密码" Style="{DynamicResource menuText}" FontFamily="楷体" /> | |||
</Grid> | |||
</MenuItem.Header> | |||
</MenuItem> | |||
<MenuItem Command="{Binding EditUsetPowerCommand}" | |||
CommandParameter="{Binding PlacementTarget.SelectedItem,RelativeSource={RelativeSource AncestorType=ContextMenu,Mode=FindAncestor}}"> | |||
<MenuItem.Header> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Style="{DynamicResource menuText}" Text="󰈓"/> | |||
<TextBlock Grid.Column="1" Text="编辑权限" Style="{DynamicResource menuText}" FontFamily="楷体"/> | |||
</Grid> | |||
</MenuItem.Header> | |||
</MenuItem> | |||
<MenuItem Command="{Binding DeleteUserCommand}" | |||
<MenuItem.Header> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Style="{DynamicResource menuText}" Text="󰈓"/> | |||
<TextBlock Grid.Column="1" Text="编辑权限" Style="{DynamicResource menuText}" FontFamily="楷体"/> | |||
</Grid> | |||
</MenuItem.Header> | |||
</MenuItem> | |||
<MenuItem Command="{Binding DeleteUserCommand}" | |||
CommandParameter="{Binding PlacementTarget.SelectedItem,RelativeSource={RelativeSource AncestorType=ContextMenu,Mode=FindAncestor}}"> | |||
<MenuItem.Header> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Style="{DynamicResource menuText}" Text=""/> | |||
<TextBlock Grid.Column="1" Text="删除用户" Style="{DynamicResource menuText}" FontFamily="楷体"/> | |||
</Grid> | |||
</MenuItem.Header> | |||
</MenuItem> | |||
</ContextMenu> | |||
</ListBox.ContextMenu> | |||
<MenuItem.Header> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="auto"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Style="{DynamicResource menuText}" Text=""/> | |||
<TextBlock Grid.Column="1" Text="删除用户" Style="{DynamicResource menuText}" FontFamily="楷体"/> | |||
</Grid> | |||
</MenuItem.Header> | |||
</MenuItem> | |||
</ContextMenu> | |||
</ListBox.ContextMenu> | |||
</ListBox> | |||
</ListBox> | |||
</ScrollViewer> | |||
</Border> | |||
</ScrollViewer> | |||
</Border> | |||
</Grid> | |||
</Border> | |||
</UserControl> |
@@ -40,13 +40,13 @@ namespace BPASmart.UserManagement.ViewModel | |||
[RelayCommand] | |||
private void ResgisterUser() | |||
{ | |||
if(UserName == null) | |||
if(UserName == null || UserName == string.Empty) | |||
{ | |||
ErrorVisibility = Visibility.Visible; | |||
ErrorMessage = "请输入用户名"; | |||
return; | |||
} | |||
if(UserPassword == null) | |||
if(UserPassword == null || UserPassword == string.Empty) | |||
{ | |||
ErrorVisibility = Visibility.Visible; | |||
ErrorMessage = "请输入密码"; | |||
@@ -74,7 +74,7 @@ namespace BPASmart.UserManagement.ViewModel | |||
{ | |||
UserID = Guid.NewGuid().ToString(), | |||
UserName = UserName, | |||
Password = AESHelper.Encrypt(UserPassword) | |||
Password = AESHelper.Encrypt(UserPassword), | |||
}); | |||
} | |||
} | |||
@@ -90,7 +90,10 @@ namespace BPASmart.UserManagement.ViewModel | |||
}); | |||
} | |||
Json<LocalUser>.Save(); | |||
MessageBox.Show("注册成功"); | |||
UserName = String.Empty; | |||
UserPassword = String.Empty; | |||
ConfirmPassword = String.Empty; | |||
MessageBox.ShowDialog("注册成功"); | |||
} | |||
@@ -100,9 +103,6 @@ namespace BPASmart.UserManagement.ViewModel | |||
ActionManage.GetInstance.Send("ChangeMianContent",string.Empty); | |||
} | |||
public AddNewUserViewModel() | |||
{ | |||
} | |||
} | |||
} |
@@ -1,14 +1,104 @@ | |||
| |||
using BPASmart.UserManagement.Globle; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
namespace BPASmart.UserManagement.ViewModel | |||
{ | |||
public class ChangeUserViewModel:ObservableObject | |||
[INotifyPropertyChanged] | |||
partial class ChangeUserViewModel | |||
{ | |||
/// <summary> | |||
/// 用户名 | |||
/// </summary> | |||
[ObservableProperty] | |||
private string? _userName; | |||
/// <summary> | |||
/// 原始密码 | |||
/// </summary> | |||
[ObservableProperty] | |||
private string? _lastPassword; | |||
/// <summary> | |||
/// 用户密码 | |||
/// </summary> | |||
[ObservableProperty] | |||
private string? _userPassword; | |||
/// <summary> | |||
/// 确认密码 | |||
/// </summary> | |||
[ObservableProperty] | |||
private string? _confirmPassword; | |||
/// <summary> | |||
/// 提示消息 | |||
/// </summary> | |||
[ObservableProperty] | |||
private string? _errorMessage; | |||
[ObservableProperty] | |||
private Visibility _errorVisibility = Visibility.Collapsed; | |||
[RelayCommand] | |||
private void SaveUser() | |||
{ | |||
if (LastPassword == null|| LastPassword == string.Empty) | |||
{ | |||
ErrorVisibility = Visibility.Visible; | |||
ErrorMessage = "请输入原始密码"; | |||
return; | |||
} | |||
if (UserPassword == null || UserPassword == string.Empty) | |||
{ | |||
ErrorVisibility = Visibility.Visible; | |||
ErrorMessage = "请输入密码"; | |||
return; | |||
} | |||
if (UserPassword != ConfirmPassword) | |||
{ | |||
ErrorVisibility = Visibility.Visible; | |||
ErrorMessage = "两次密码不一致"; | |||
return; | |||
} | |||
if(AESHelper.Decrypt(GlobleData.ChangeUser.Password) != LastPassword) | |||
{ | |||
ErrorVisibility = Visibility.Visible; | |||
ErrorMessage = "原始密码错误"; | |||
return; | |||
} | |||
var res = Json<LocalUser>.Data.UserManagers.FirstOrDefault(x => x.UserID == GlobleData.ChangeUser.UserID); | |||
if (res != null) | |||
{ | |||
res.Password = AESHelper.Encrypt(UserPassword); | |||
} | |||
else | |||
{ | |||
ErrorVisibility = Visibility.Visible; | |||
ErrorMessage = "该员工不存在"; | |||
return; | |||
} | |||
Json<LocalUser>.Save(); | |||
GlobleData.ChangeUser = null; | |||
ActionManage.GetInstance.Send("ChangeMianContent", string.Empty); | |||
MessageBox.ShowDialog("修改成功"); | |||
} | |||
[RelayCommand] | |||
private void Exit() | |||
{ | |||
ActionManage.GetInstance.Send("ChangeMianContent", string.Empty); | |||
} | |||
public ChangeUserViewModel() | |||
{ | |||
if (GlobleData.ChangeUser != null) | |||
{ | |||
UserName = GlobleData.ChangeUser.UserName; | |||
} | |||
} | |||
} | |||
} |
@@ -16,6 +16,27 @@ namespace BPASmart.UserManagement.ViewModel | |||
public MainWindowViewModel() | |||
{ | |||
Json<LocalUser>.Read(); | |||
if (Json<LocalUser>.Data.HighGradeUsers.FirstOrDefault(p => p.UserID == "1") == null) | |||
{ | |||
Json<LocalUser>.Data.HighGradeUsers.Insert(0, new UserManager() | |||
{ | |||
UserID = "1", | |||
UserName = "admin", | |||
Password = AESHelper.Encrypt("admin") , | |||
userPower = UserPower.管理员权限 | |||
}); | |||
} | |||
if (Json<LocalUser>.Data.HighGradeUsers.FirstOrDefault(p => p.UserID == "0") == null) | |||
{ | |||
Json<LocalUser>.Data.HighGradeUsers.Insert(0, new UserManager() | |||
{ | |||
UserID = "0", | |||
UserName = "developer", | |||
Password = AESHelper.Encrypt("developer"), | |||
userPower = UserPower.开发者权限 | |||
}); | |||
} | |||
} | |||
} | |||
} |
@@ -1,4 +1,5 @@ | |||
using BPASmart.Model.用户; | |||
using BPASmart.UserManagement.View; | |||
using BPASmartClient.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
@@ -35,7 +36,8 @@ namespace BPASmart.UserManagement.ViewModel | |||
{ | |||
if(userManagers.Contains(user)) | |||
{ | |||
Globle.GlobleData.ChangeUser = user; | |||
ActionManage.GetInstance.Send("ChangeMianContent", "ChangeUser"); | |||
} | |||
} | |||
@@ -52,7 +54,7 @@ namespace BPASmart.UserManagement.ViewModel | |||
{ | |||
if (userManagers.Contains(user)) | |||
{ | |||
ActionManage.GetInstance.Send("ChangeMianContent", "EditPower"); | |||
} | |||
} | |||
@@ -70,7 +72,6 @@ namespace BPASmart.UserManagement.ViewModel | |||
{ | |||
userManagers.Remove(user); | |||
} | |||
} | |||
Json<LocalUser>.Save(); | |||