Kaynağa Gözat

临时提交

样式分支
taoye 2 yıl önce
ebeveyn
işleme
3fbaba8616
5 değiştirilmiş dosya ile 80 ekleme ve 22 silme
  1. +22
    -4
      BPASmartClient.CustomResource/Pages/Model/Config.cs
  2. +3
    -1
      BPASmartClient.CustomResource/Pages/Model/UserInfo.cs
  3. +1
    -1
      FryPot_DosingSystem/View/UserManageView.xaml
  4. +17
    -3
      FryPot_DosingSystem/View/UserManageView.xaml.cs
  5. +37
    -13
      FryPot_DosingSystem/ViewModel/UserManageViewModel.cs

+ 22
- 4
BPASmartClient.CustomResource/Pages/Model/Config.cs Dosyayı Görüntüle

@@ -38,10 +38,10 @@ namespace BPASmartClient.CustomResource.Pages.Model

private void AddData()
{
Global.userManager.userInfos.Add(new UserInfo() { Permission = Permission.管理员, UserName = "admin", Password = "admin" });
Global.userManager.userInfos.Add(new UserInfo() { Permission = Permission.操作员, UserName = "czy", Password = "123456" });
Global.userManager.userInfos.Add(new UserInfo() { Permission = Permission.观察员, UserName = "gcy", Password = "654321" });
Global.userManager.userInfos.Add(new UserInfo() { Permission = Permission.技术员, UserName = "jsy", Password = "88888888" });
Global.userManager.userInfos.Add(new UserInfo() {Id= IdProcess(), Permission = Permission.管理员, UserName = "admin", Password = "admin" }); ;
Global.userManager.userInfos.Add(new UserInfo() { Id = IdProcess(), Permission = Permission.操作员, UserName = "czy", Password = "123456" });
Global.userManager.userInfos.Add(new UserInfo() { Id = IdProcess(), Permission = Permission.观察员, UserName = "gcy", Password = "654321" });
Global.userManager.userInfos.Add(new UserInfo() { Id = IdProcess(), Permission = Permission.技术员, UserName = "jsy", Password = "88888888" });
SaveUser();
}

@@ -49,5 +49,23 @@ namespace BPASmartClient.CustomResource.Pages.Model
{
File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
}
public string IdProcess()
{
erp:
string id= Guid.NewGuid().ToString();
if (Global.userManager.userInfos.Count > 0)
{
var res=Global.userManager.userInfos.FirstOrDefault(p => p.Id == id);
if (res != null)
{
goto erp;
}
else
{
return id;
}
}
return id;
}
}
}

+ 3
- 1
BPASmartClient.CustomResource/Pages/Model/UserInfo.cs Dosyayı Görüntüle

@@ -10,7 +10,9 @@ namespace BPASmartClient.CustomResource.Pages.Model
{
public class UserInfo:ObservableObject
{
public Permission Permission { get { return _permission; } set { if (value is Permission per) { _permission = value; } else { _permission =(Permission) Enum.Parse(typeof(Permission), value.ToString()); } OnPropertyChanged(); } }
public string Id { get { return _id; } set { _id = value;OnPropertyChanged(); } }
private string _id;
public Permission Permission { get { return _permission; } set { _permission = value; OnPropertyChanged(); } }
private Permission _permission;
public string UserName { get { return _userName; } set { _userName = value;OnPropertyChanged(); } }
private string _userName;


+ 1
- 1
FryPot_DosingSystem/View/UserManageView.xaml Dosyayı Görüntüle

@@ -478,7 +478,7 @@
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Style="{StaticResource ComboBoxStyle1}" SelectedValue="{Binding Permission}" SelectionChanged="ComboBox_SelectionChanged" ItemsSource="{Binding DataContext.Authorities, RelativeSource={RelativeSource AncestorType=DataGrid, Mode=FindAncestor}}" Foreground="SkyBlue" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="16">
<ComboBox Style="{StaticResource ComboBoxStyle1}" Text="{Binding Permission}" Tag="{Binding Id}" SelectedItem="{Binding Permission}" SelectionChanged="ComboBox_SelectionChanged" ItemsSource="{Binding DataContext.Authorities, RelativeSource={RelativeSource AncestorType=DataGrid, Mode=FindAncestor}}" Foreground="SkyBlue" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="16">
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">


+ 17
- 3
FryPot_DosingSystem/View/UserManageView.xaml.cs Dosyayı Görüntüle

@@ -1,5 +1,11 @@
using System;
using BPA.Message;
using BPASmartClient.CustomResource.Pages.Enums;
using BPASmartClient.CustomResource.Pages.Model;
using FryPot_DosingSystem.ViewModel;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -27,8 +33,16 @@ namespace FryPot_DosingSystem.View

private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var a= (sender as ComboBox).SelectedValue;
var b= (sender as ComboBox).Text;
ComboBox cbo = sender as ComboBox;
var id = cbo.Tag;
var per = cbo.SelectedItem;
var a = UserManageViewModel.GetInstance.usersInfo.FirstOrDefault(p=>p.Id==id);

if (a != null && per != null)
{
a.Permission = (Permission)Enum.Parse(typeof(Permission), per.ToString());

}
}
}
}

+ 37
- 13
FryPot_DosingSystem/ViewModel/UserManageViewModel.cs Dosyayı Görüntüle

@@ -17,18 +17,19 @@ namespace FryPot_DosingSystem.ViewModel
{
internal class UserManageViewModel : ObservableObject
{
private static UserManageViewModel _instance;
public static UserManageViewModel GetInstance=>_instance??= new UserManageViewModel();
public ObservableCollection<UserInfo> usersInfo { get; set; } = new ObservableCollection<UserInfo>();

public List<Permission> Authorities { get; set; } = new List<Permission>() { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 };

//public string selecttext { get; set; } = "123";
//public List<Permission> Authorities { get; set; } = new List<Permission>() { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 };
public List<string> Authorities { get; set; } = new List<string>();
public RelayCommand<string> SaveCommand { get; set; }
public RelayCommand<string> DeleteCommand { get; set; }
public UserManageViewModel()
{
var userManager = JsonConvert.DeserializeObject<UserManager>(File.ReadAllText("up.hbl").AESDecrypt());
usersInfo = userManager.userInfos;
// AddAuthorities();
AddAuthorities();
SaveCommand = new RelayCommand<string>((str) =>
{
@@ -41,9 +42,15 @@ namespace FryPot_DosingSystem.ViewModel
}
else
{
var res = usersInfo.FirstOrDefault(p => p.UserName == str);
if (res.Id == null || res.Id == string.Empty)
{
res.Id = IdProcess();
}
Global.userManager.userInfos = usersInfo;
File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt());
MessageBox.Show("保存成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);

}

}
@@ -69,17 +76,34 @@ namespace FryPot_DosingSystem.ViewModel
});
}



//private void AddAuthorities()
//{
// foreach (Permission aut in System.Enum.GetValues(typeof(Permission)))
// {
// Authorities.Add(aut.ToString());
// }
public string IdProcess()
{
erp:
string id = Guid.NewGuid().ToString();
if (usersInfo.Count > 0)
{
var res = usersInfo.FirstOrDefault(p => p.Id == id);
if (res != null)
{
goto erp;
}
else
{
return id;
}
}
return id;
}

//}
private void AddAuthorities()
{
foreach (Permission aut in System.Enum.GetValues(typeof(Permission)))
{
Authorities.Add(aut.ToString());
}

}
}
}

Yükleniyor…
İptal
Kaydet