首次提交:添加src文件夹代码

This commit is contained in:
2026-02-27 14:02:43 +08:00
commit d330cfbca7
4184 changed files with 5546478 additions and 0 deletions

View File

@@ -0,0 +1,169 @@
using Cowain.Bake.BLL;
using Cowain.Bake.Common;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
using Cowain.Bake.Model;
using Prism.Ioc;
using Cowain.Bake.Model.Entity;
using Prism.Commands;
using HandyControl.Controls;
namespace Cowain.Bake.UI.UserManagerment.ViewModels
{
public class AuthorityManagementViewModel : ViewModelBase, INotifyPropertyChanged
{
public AuthorityManagementViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
{
this.PageTitle = "权限管理";
_unityContainer = unityContainer;
RoleList = userService.GetAllRole();
InitTreeView();
SelectedRole= RoleList.FirstOrDefault();
RefreshAuthority();
}
#region
UserService userService = MyAppContainer.Current.Resolve<UserService>();
public new event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChange(string propName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
}
//用于展示角色的listbox
private List<TRoleInfo> roleList;
public List<TRoleInfo> RoleList
{
get { return roleList; }
set { roleList = value; }
}
//用于权限展示的treeview
private ObservableCollection<AuthorityEntity> authorityList;
public ObservableCollection<AuthorityEntity> AuthorityList
{
get { return authorityList; }
set { authorityList = value; }
}
//选中的角色
private TRoleInfo selectedRole;
public TRoleInfo SelectedRole
{
get { return selectedRole; }
set
{
if (selectedRole != value)
{
selectedRole = value;
OnPropertyChange(nameof(SelectedRole));
}
}
}
#endregion
private void InitTreeView()
{
AuthorityList = new ObservableCollection<AuthorityEntity>();
var menuList = userService.GetAllMenuInfo();
//第一个循环,循环父节点
for (int i = 1; i <= menuList.Where(x=>x.ParentId==0).ToList().Count; i++)
{
var a = menuList.Where(p => p.Id == i).FirstOrDefault();
AuthorityEntity parentItem = new AuthorityEntity
{
Header = a.Header,
HeaderName = a.HeaderName,
TargetView = a.TargetView,
MenuId = a.Id,
ParentId = a.ParentId,
CheckboxVisibility = System.Windows.Visibility.Collapsed
};
//第二个循环,循环子节点
foreach(var item in menuList.Where(c => c.ParentId == i).ToList())
{
AuthorityEntity childItem = new AuthorityEntity
{
Header = item.Header,
HeaderName = item.HeaderName,
TargetView = item.TargetView,
MenuId = item.Id,
ParentId = item.ParentId,
CheckboxVisibility = System.Windows.Visibility.Visible
};
parentItem.Children.Add(childItem);
}
AuthorityList.Add(parentItem);
}
}
public DelegateCommand SaveCommand => new DelegateCommand(() =>
{
StringBuilder authorityString = new StringBuilder();
foreach (var parentItem in AuthorityList)
{
foreach(var childitem in parentItem.Children)
{
if (childitem.IsHasAuthority)
{
if (!string.IsNullOrEmpty(childitem.HeaderName))
{
authorityString.Append(childitem.HeaderName);
authorityString.Append(";");
}
else
{
continue;
}
}
}
}
SelectedRole.AccessNode= authorityString.ToString();
_unityContainer.Resolve<RoleInfoService>().Update(SelectedRole);
Growl.Success("保存成功!");
});
public DelegateCommand ListBoxSelectionChangedCommand => new DelegateCommand(() =>
{
RefreshAuthority();
});
public void RefreshAuthority()
{
string authority = userService.GetAuthority(selectedRole.RoleName);
foreach (var parent in AuthorityList)
{
foreach (var child in parent.Children)
{
if (string.IsNullOrEmpty(child.HeaderName))
{
child.IsHasAuthority = true;
}
else
{
child.IsHasAuthority = authority.Contains(child.HeaderName) ? true : false;
}
}
}
}
}
}

View File

@@ -0,0 +1,147 @@
using Cowain.Bake.BLL;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Communication.MOM;
using Cowain.Bake.Model;
using Newtonsoft.Json;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using System.Windows.Input;
using Unity;
using static Cowain.Bake.Common.Models.MESModel;
namespace Cowain.Bake.UI.UserManagerment.ViewModels
{
public class DeviceModeViewModel : BindableBase
{
TDeviceConfig dev;
private string _userName;
public string UserName
{
get { return _userName; }
set
{
SetProperty(ref _userName, value);
}
}
private string _userPwa;
public string UserPwa
{
get { return _userPwa; }
set
{
SetProperty(ref _userPwa, value);
}
}
private string _url;
public string Url
{
get { return _url; }
set
{
SetProperty(ref _url, value);
}
}
private int _selectedRadioButtonIndex;
public int SelectedRadioButtonIndex
{
get { return _selectedRadioButtonIndex; }
set
{
SetProperty(ref _selectedRadioButtonIndex, value);
}
}
public class CloseWindowEvent : PubSubEvent
{
public CloseWindowEvent()
{
}
}
private IEventAggregator _eventAggregator;
private IUnityContainer _unityContainer;
public DeviceModeViewModel(IUnityContainer unityContainer, IEventAggregator eventAggregator)
{
//初始化数据库连接池
_unityContainer = unityContainer;
_eventAggregator = eventAggregator;
string v = _unityContainer.Resolve<BLL.SysSetupService>().GetValueByParaID(ESysSetup.MOMMode.ToString());
SelectedRadioButtonIndex = int.Parse(v);
dev = _unityContainer.Resolve<DeviceConfigService>().GetConfig(EDeviceType.MOM)[0];
dynamic d = JsonConvert.DeserializeObject<dynamic>(dev.Json);
_url = d.URL;
}
public ICommand ExitCommand
{
get => new DelegateCommand<object>(OnExit);
}
public ICommand SwitchCommand
{
get => new DelegateCommand<object>(OnSwitch);
}
//public ICommand MesIpUpdateCommand
//{
// get => new DelegateCommand<object>(OnMesUpdate);
//}
private void OnExit(object obj )
{
_eventAggregator.GetEvent<CloseWindowEvent>().Publish();
}
// _unityContainer.Resolve<SysSetupService>().GetValueByParaID(ESysSetup.MOMMode.ToString())
public void OnSwitch(object obj)
{
if (string.IsNullOrEmpty(UserName)|| string.IsNullOrEmpty(this.UserPwa))
{
HandyControl.Controls.MessageBox.Info("工号与密码不能为空!请输入后切换");
return;
}
int deviceMode = int.Parse(_unityContainer.Resolve<SysSetupService>().GetValueByParaID(ESysSetup.MOMMode.ToString()));
_unityContainer.Resolve<SysSetupService>().UpdateValue(ESysSetup.MOMMode.ToString(), SelectedRadioButtonIndex.ToString());
MESReturnCmdModel mesModel = _unityContainer.Resolve<MESProcess>().EqptRun(UserName, this.UserPwa,
SelectedRadioButtonIndex.ToString());
string MOMMessage = "";
if (null != mesModel)
{
MOMMessage = mesModel.Info.MOMMessage;
}
if (null == mesModel || mesModel.Info.ResultFlag == EResultFlag.NG.ToString())
{
_unityContainer.Resolve<SysSetupService>().UpdateValue(ESysSetup.MOMMode.ToString(), deviceMode.ToString());
HandyControl.Controls.MessageBox.Error($@"切换【{((EMOMMode)SelectedRadioButtonIndex).GetDescription()}】失败 {MOMMessage}", "切换提示");
return;
}
HandyControl.Controls.MessageBox.Show($@"切换【{((EMOMMode)SelectedRadioButtonIndex).GetDescription()}】成功!", "切换提示");
_unityContainer.Resolve<LogService>().AddLog($@"切换【{((EMOMMode)SelectedRadioButtonIndex).GetDescription()}】!", E_LogType.Operate.ToString());
}
//public void OnMesUpdate(object obj)
//{
// dynamic dc = JsonConvert.DeserializeObject<dynamic>(dev.Json);
// if (MessageBoxResult.OK == HandyControl.Controls.MessageBox.Ask("是否修改Mes地址该操作可能会导致Mes(MOM)无法使用,请仔细确认无误", "操作提示"))
// {
// dc.URL = _url;
// _unityContainer.Resolve<DeviceConfigService>().UpdateMesJosn(JsonConvert.SerializeObject(dc));
// //_unityContainer.Resolve<MESProcess>().GetJsonParam(JsonConvert.SerializeObject(dc));
// return;
// }
// Url = dc.URL;
//}
public void Refresh()
{
string v = _unityContainer.Resolve<BLL.SysSetupService>().GetValueByParaID(ESysSetup.MOMMode.ToString());
SelectedRadioButtonIndex = int.Parse(v);
dev = _unityContainer.Resolve<DeviceConfigService>().GetConfig(EDeviceType.MOM)[0];
dynamic d = JsonConvert.DeserializeObject<dynamic>(dev.Json);
Url = d.URL;
}
}
}

View File

@@ -0,0 +1,374 @@
using Cowain.Bake.BLL;
using Cowain.Bake.Common;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Model;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity;
using Prism.Commands;
using System.Windows;
using HandyControl.Controls;
using Cowain.Bake.Model.Entity;
using System.ComponentModel;
using System.Windows.Input;
using System.Text.Json;
using Newtonsoft.Json;
namespace Cowain.Bake.UI.UserManagerment.ViewModels
{
class UserManagermentViewModel : ViewModelBase, INotifyPropertyChanged
{
public UserManagermentViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
{
this.PageTitle = "用户管理";
userManagermentService = _unityContainer.Resolve<UserService>();
SetRoleList();
}
//记忆当前所有的用户
public List<TUserManage> CurrentUserList { get; set; }
//公共服务字段
private UserService userManagermentService { get; set; }
public new event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string proName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(proName));
}
//datagrid数据源
private ObservableCollection<TUserManage> userList;
public ObservableCollection<TUserManage> UserList
{
get => userList ?? (userList = new ObservableCollection<TUserManage>());
set
{
if (value != null)
{
userList = value;
OnPropertyChanged("UserList");
}
}
}
//隐藏增加用户的布局
private Visibility addUserVisibility = Visibility.Collapsed;
public Visibility AddUserVisibility
{
get { return addUserVisibility; }
set
{
if (addUserVisibility != value)
{
addUserVisibility = value;
OnPropertyChanged("AddUserVisibility");
}
}
}
//用户搜索框
private string textBoxContent;
public string TextBoxContent
{
get { return textBoxContent; }
set
{
if (textBoxContent != value)
{
textBoxContent = value;
OnPropertyChanged("TextBoxContent");
}
}
}
//用户框
private string userNameBoxContent;
public string UserNameBoxContent
{
get { return userNameBoxContent; }
set
{
if (userNameBoxContent != value)
{
userNameBoxContent = value;
OnPropertyChanged("UserNameBoxContent");
}
}
}
//账号框
private string userIdBoxContent;
public string UserIdBoxContent
{
get { return userIdBoxContent; }
set
{
if (userIdBoxContent != value)
{
userIdBoxContent = value;
OnPropertyChanged("UserIdBoxContent");
}
}
}
//密码框
private string pwdBoxContent;
public string PwdBoxContent
{
get { return pwdBoxContent; }
set
{
if (pwdBoxContent != value)
{
pwdBoxContent = value;
OnPropertyChanged("PwdBoxContent");
}
}
}
//确认密码框
//private string confirmPwdBoxContent;
//public string ConfirmPwdBoxContent
//{
// get { return confirmPwdBoxContent; }
// set
// {
// if (confirmPwdBoxContent != value)
// {
// confirmPwdBoxContent = value;
// OnPropertyChanged("ConfirmPwdBoxContent");
// }
// }
//}
//角色下拉框
private string roleComboboxSelected;
public string RoleComboboxSelected
{
get { return roleComboboxSelected; }
set
{
if (roleComboboxSelected != value)
{
roleComboboxSelected = value;
OnPropertyChanged("RoleComboboxSelected");
}
}
}
private TUserManage selectedUser;
public TUserManage SelectedUser
{
get { return selectedUser; }
set
{
if (selectedUser != value)
{
selectedUser = value;
OnPropertyChanged("SelectedUser");
}
}
}
public void AsyncRefreshTask()
{
Application.Current?.Dispatcher?.Invoke(new Action(() =>
{
Refresh();
}));
}
public async override void Refresh()
{
UserList.Clear();
if (CurrentUserList!=null)
{
CurrentUserList.Clear();
}
var listUser = await System.Threading.Tasks.Task.Run(() =>
{
var userService = _unityContainer.Resolve<UserService>();
//从数据库查询任务
return userService.GetAllUsers();
});
listUser.ForEach(x => UserList.Add(x));
CurrentUserList = listUser;
}
public List<string> RoleList { get; set; }
public void SetRoleList()
{
RoleList = new List<string>();
foreach(ERole role in Enum.GetValues(typeof(ERole)))
{
RoleList.Add(role.GetDescription());
}
}
//用户查询
public DelegateCommand QueryUserCommand => new DelegateCommand(() =>
{
if (string.IsNullOrWhiteSpace(TextBoxContent))
{
Refresh();
return;
}
var queryList = userManagermentService.QueryUser(TextBoxContent);
if (queryList.Count > 0)
{
UserList.Clear();
UserList.Add(queryList[0]);
Growl.Info("查询成功!");
}
else
{
Growl.Info("没有数据!");
}
});
//更改用户是否有效
public DelegateCommand<string> UserValidCommand => new DelegateCommand<string>((y) =>
{
if (SelectedUser == null)
{
Growl.Info("请选择用户!");
return;
}
var result = HandyControl.Controls.MessageBox.Ask("确认更改?", "操作提示");
if (result == MessageBoxResult.Cancel)
{
return;
}
if (y == EValidStatus.Invalid.ToString())
{
if (SelectedUser.Valid!=false)
{
SelectedUser.Valid = false;
}
else
{
return;
}
}
else if (y == EValidStatus.Valid.ToString())
{
if (SelectedUser.Valid!=true)
{
SelectedUser.Valid = true;
}
else
{
return;
}
}
userManagermentService.Update(SelectedUser);
Refresh();
Growl.Success("更改成功!");
});
public DelegateCommand ShowAddUserCommand => new DelegateCommand(() =>
{
AddUserVisibility = Visibility.Visible;
});
public DelegateCommand AddUserCommand => new DelegateCommand(() =>
{
if (string.IsNullOrWhiteSpace(UserIdBoxContent))
{
Growl.Info("请输入账号!");
return;
}
if (CurrentUserList.Where(a => a.UserId == UserIdBoxContent).ToList().Count > 0)
{
Growl.Info("账号已经存在!");
return;
}
//if (PwdBoxContent != ConfirmPwdBoxContent)
//{
// Growl.Info("密码不一致!");
// return;
//}
if (string.IsNullOrWhiteSpace(RoleComboboxSelected))
{
Growl.Info("请选择用户角色!");
return;
}
TUserManage addUserItem = new TUserManage()
{
UserId = UserIdBoxContent,
UserName = UserNameBoxContent,
Password = PwdBoxContent,
//将枚举描述转换成对应int
RoleId = (int)EnumHelper.GetValueByDescription<ERole>(roleComboboxSelected),
Valid = true,
};
if (userManagermentService.Insert(addUserItem)>0)
{
UserList.Add(addUserItem);
AddUserVisibility = Visibility.Collapsed;
Growl.Success("新增成功!");
};
});
public DelegateCommand DeleteUserCommand => new DelegateCommand(() =>
{
if (SelectedUser == null)
{
Growl.Info("请选择用户!");
return;
}
var result = HandyControl.Controls.MessageBox.Ask($"用户名:{selectedUser.UserName},是否删除?", "操作提示");
if (result == MessageBoxResult.Cancel)
{
return;
}
if (0 == userManagermentService.Delete(selectedUser))
{
Growl.Warning("删除失败!");
return;
}
Growl.Success($"删除用户【{selectedUser.UserName}】成功!");
_unityContainer.Resolve<LogService>().AddLog($"删除用户:{selectedUser.UserName}", E_LogType.Operate.ToString());
Refresh();
});
public DelegateCommand InitPwdCommand => new DelegateCommand(()=>
{
var result = HandyControl.Controls.MessageBox.Ask("是否初始化?","操作提示");
if (result == MessageBoxResult.Cancel)
{
return;
}
if (selectedUser != null)
{
selectedUser.Password = "123456";
userManagermentService.Update(selectedUser);
Growl.Success("初始化成功");
}
});
public DelegateCommand CancelSaveCommand => new DelegateCommand(() =>
{
AddUserVisibility = Visibility.Collapsed;
UserIdBoxContent = string.Empty;
UserNameBoxContent = string.Empty;
PwdBoxContent = string.Empty;
});
}
}

View File

@@ -0,0 +1,38 @@
<UserControl x:Class="Cowain.Bake.UI.UserManagerment.Views.AuthorityManagementView"
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:Cowain.Bake.UI.UserManagerment.Views"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ListBox Grid.Column="0" ItemsSource="{Binding RoleList}" DisplayMemberPath="RoleName" SelectedItem="{Binding SelectedRole,Mode=TwoWay}" SelectedIndex="0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding ListBoxSelectionChangedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>
<StackPanel Grid.Column="1" Orientation="Vertical" Background="#f1f2f6">
<TreeView ItemsSource="{Binding AuthorityList}" Height="342">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<StackPanel x:Name="stackPanel" Orientation="Horizontal">
<CheckBox FontSize="14" x:Name="checkBox1"
IsChecked="{Binding IsHasAuthority,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Tag="{Binding TargetView}" Visibility="{Binding CheckboxVisibility}"/>
<TextBlock Text="{Binding Header}" FontSize="14" Margin="8,0,0,0"/>
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<Button Content="保存" HorizontalAlignment="Left" Style="{StaticResource ButtonInfo}" Width="60" Margin="5" Command="{Binding SaveCommand}"/>
</StackPanel>
</Grid>
</UserControl>

View File

@@ -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 Cowain.Bake.UI.UserManagerment.Views
{
/// <summary>
/// AuthorityManagementView.xaml 的交互逻辑
/// </summary>
public partial class AuthorityManagementView : UserControl
{
public AuthorityManagementView()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,66 @@
<Window x:Class="Cowain.Bake.UI.UserManagerment.Views.DeviceModeView"
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:Cowain.Bake.UI.UserManagerment.Views"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:prism="http://prismlibrary.com/"
xmlns:pwdHelper="clr-namespace:Cowain.Bake.Common;assembly=Cowain.Bake.Common"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:cm="clr-namespace:Cowain.Bake.Common.Converter;assembly=Cowain.Bake.Common"
mc:Ignorable="d"
Title="设备模式" Height="230" Width="500" WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow">
<Window.Resources>
<ResourceDictionary>
<cm:RadioButtonToIndexConverter x:Key="RadioButtonToIndexConverter" />
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.01*"/>
<RowDefinition Height="0.1*"/>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="0.2*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.1*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="0.1*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.4*"/>
<ColumnDefinition Width="0.6*"/>
</Grid.ColumnDefinitions>
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
</Grid>
<Label Content="工号:" Grid.Row="0" Grid.Column="0" />
<TextBox Grid.Row="0" Grid.Column="1" x:Name="UserName" FontWeight="Bold" HorizontalAlignment="Left" Width="100" Height="23" TextWrapping="Wrap" Text="{Binding UserName}"/>
<Label Content="密码:" Grid.Row="0" Grid.Column="2" Margin="15,0,0,0" />
<PasswordBox pwdHelper:PasswordHelper.Password="{Binding UserPwa,Mode=TwoWay}" Width="160" Height="23" pwdHelper:PasswordHelper.Attach="True" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1" >
<RadioButton Content="联机模式" IsChecked="{Binding SelectedRadioButtonIndex, Mode=TwoWay, Converter={StaticResource RadioButtonToIndexConverter}, ConverterParameter=0}" FontSize="12" Foreground="DarkBlue"/>
<RadioButton Content="离线模式" IsChecked="{Binding SelectedRadioButtonIndex, Mode=TwoWay, Converter={StaticResource RadioButtonToIndexConverter}, ConverterParameter=1}" FontSize="12" Margin="30" Foreground="DarkBlue"/>
<RadioButton Content="调机模式" IsChecked="{Binding SelectedRadioButtonIndex, Mode=TwoWay, Converter={StaticResource RadioButtonToIndexConverter}, ConverterParameter=2}" FontSize="12" Foreground="DarkBlue"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="1">
<Button Content="切换" Command="{Binding SwitchCommand}" Style="{StaticResource ButtonInfo}" Margin="120,0,0,0"/>
<Button Content="退出" Command="{Binding ExitCommand}" Style="{StaticResource ButtonInfo}" Margin="80,0,0,0"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,23 @@
using Cowain.Bake.UI.UserManagerment.ViewModels;
using Prism.Events;
using System.Windows;
using Unity;
using static Cowain.Bake.UI.UserManagerment.ViewModels.DeviceModeViewModel;
namespace Cowain.Bake.UI.UserManagerment.Views
{
/// <summary>
/// DeviceModeView.xaml 的交互逻辑
/// </summary>
public partial class DeviceModeView : Window
{
private IEventAggregator _eventAggregator;
public DeviceModeView(IUnityContainer unityContainer, IEventAggregator eventAggregator)
{
InitializeComponent();
_eventAggregator = eventAggregator;
_eventAggregator.GetEvent<CloseWindowEvent>().Subscribe(() => Close());
unityContainer.Resolve<DeviceModeViewModel>().Refresh();
}
}
}

View File

@@ -0,0 +1,62 @@
<UserControl x:Class="Cowain.Bake.UI.UserManagerment.Views.UserManagermentView"
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:Cowain.Bake.UI.UserManagerment.Views"
xmlns:convertor="clr-namespace:Cowain.Bake.BLL.Converter;assembly=Cowain.Bake.BLL"
mc:Ignorable="d"
xmlns:hc="https://handyorg.github.io/handycontrol"
d:DesignHeight="450" d:DesignWidth="800" Background="Transparent">
<UserControl.Resources>
<Style TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<convertor:InvalidConvertor x:Key="invalidConvertor"/>
<convertor:RoleConvertor x:Key="roleConvertor"/>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="40"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="账号:" />
<TextBox Width="120" Text="{Binding TextBoxContent,Mode=OneWayToSource}"/>
<Button Content="查询" Style="{StaticResource ButtonSuccess}" Command="{Binding QueryUserCommand}" Margin="20,0,0,0" Width="80"/>
<Button Content="新增" Style="{StaticResource ButtonInfo}" Command="{Binding ShowAddUserCommand}" Margin="10,0,0,0" Width="80"/>
<Button Content="有效化" Style="{StaticResource ButtonInfo}" Command="{Binding UserValidCommand}" CommandParameter="Valid" Margin="10,0,0,0" Width="80"/>
<Button Content="无效化" Style="{StaticResource ButtonDanger}" Command="{Binding UserValidCommand}" CommandParameter="Invalid" Margin="10,0,0,0" Width="80"/>
<Button Content="初始化密码" Style="{StaticResource ButtonDanger}" Command="{Binding InitPwdCommand}" Margin="10,0,0,0" Width="80"/>
<Button Content="删除用户" Style="{StaticResource ButtonDanger}" Command="{Binding DeleteUserCommand}" Margin="10,0,0,0" Width="80"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,5" Visibility="{Binding AddUserVisibility ,Mode=TwoWay}">
<TextBlock Text="账号:"/>
<TextBox Width="120" Text="{Binding UserIdBoxContent,Mode=TwoWay}"/>
<TextBlock Text="用户名:"/>
<TextBox Width="120" Text="{Binding UserNameBoxContent,Mode=TwoWay}"/>
<TextBlock Text="密码:"/>
<TextBox Width="120" Text="{Binding PwdBoxContent,Mode=TwoWay}" />
<!--<TextBlock Text="确认密码:"/>
<TextBox Width="120" Text="{Binding ConfirmPwdBoxContent,Mode=OneWayToSource}"/>-->
<TextBlock Text="角色:"/>
<ComboBox Width="100" SelectedItem="{Binding RoleComboboxSelected,Mode=TwoWay}" ItemsSource="{Binding RoleList}"/>
<Button Content="保存" Width="80" Style="{StaticResource ButtonSuccess}" Margin="10,0,0,0" Command="{Binding AddUserCommand}" />
<Button Content="取消" Style="{StaticResource ButtonDanger}" Command="{Binding CancelSaveCommand}" Margin="10,0,0,0" Width="80"/>
</StackPanel>
<DataGrid Grid.Row="2" hc:DataGridAttach.CanUnselectAllWithBlankArea="True" HeadersVisibility="All"
CanUserSortColumns="False" SelectionMode="Single" Margin="4" IsReadOnly="True"
RowHeaderWidth="0" AutoGenerateColumns="False" ItemsSource="{Binding UserList}" SelectedItem="{Binding SelectedUser}">
<DataGrid.Columns>
<DataGridTextColumn Header="账号" Binding="{Binding UserId}"/>
<DataGridTextColumn Header="用户名" Binding="{Binding UserName}"/>
<DataGridTextColumn Header="是否有效" Binding="{Binding Valid,Converter={StaticResource invalidConvertor}}"/>
<DataGridTextColumn Header="角色" Binding="{Binding RoleId,Converter={StaticResource roleConvertor}}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</UserControl>

View File

@@ -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 Cowain.Bake.UI.UserManagerment.Views
{
/// <summary>
/// UserManagermentView.xaml 的交互逻辑
/// </summary>
public partial class UserManagermentView : UserControl
{
public UserManagermentView()
{
InitializeComponent();
}
}
}