Browse Source

增加用户权限管理页面

master
sc 9 months ago
parent
commit
4d2506ca7f
  1. 2
      MainWindow.xaml
  2. 10
      MainWindow.xaml.cs
  3. 2
      WindowsView/MachineSelection.xaml.cs
  4. 20
      WindowsView/User.xaml
  5. 72
      WindowsView/User.xaml.cs

2
MainWindow.xaml

@ -44,7 +44,7 @@
<TextBlock Text="{Binding Sys_Time}" VerticalAlignment="Center" FontSize="14" Foreground="White"/>
<materialDesign:PopupBox Foreground="White" Margin="10" PlacementMode="BottomAndAlignRightEdges" StaysOpen="False">
<StackPanel Width="150">
<Button Content="{x:Static lang:Resources.USER}"/>
<Button Content="{x:Static lang:Resources.USER}" Click="ButtonUSER_Click"/>
<Button Content="{x:Static lang:Resources.SysSet}" Click="ButtonSYS_Click"/>
<Separator/>
<Button Content="{x:Static lang:Resources.Permit}" Click="ButtonPermit_Click"/>

10
MainWindow.xaml.cs

@ -103,8 +103,7 @@ namespace SunlightCentralizedControlManagement_SCCM_
}
private void ListViewItem_ConveyorCenters(object sender, MouseButtonEventArgs e)
{
WindowsView.User user_ =new WindowsView.User();
user_.Show();
}
private void Buttonhelp_Click(object sender, RoutedEventArgs e)
@ -116,7 +115,11 @@ namespace SunlightCentralizedControlManagement_SCCM_
{
Picture.Content = new View.SYSSetView();
}
private void ButtonUSER_Click(object sender, RoutedEventArgs e)
{
WindowsView.User user_ = new WindowsView.User();
user_.Show();
}
private void ButtonPermit_Click(object sender, RoutedEventArgs e)
{
WindowsView.CDKEY cDKEY = new WindowsView.CDKEY();
@ -193,5 +196,6 @@ namespace SunlightCentralizedControlManagement_SCCM_
}
}
}
}

2
WindowsView/MachineSelection.xaml.cs

@ -29,8 +29,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
public delegate void AddressUpdateHandler(object sender, AddressUpdateEventArgs e);
//声明一个更新Address的事件
public event AddressUpdateHandler AddressUpdated;
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private string MACHINEDATA;
DataTable machine_table;
private List<string> machine;

20
WindowsView/User.xaml

@ -9,7 +9,7 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:viewmodel="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ViewModel"
mc:Ignorable="d" Loaded="user_Loaded"
Title="MAC_SET" Height="720" Width="900" MinHeight="720" MinWidth="900"
Title="MAC_SET" Height="900" Width="1440" MinHeight="900" MinWidth="1440"
BorderBrush="White" Background="White">
<Grid>
<Grid.RowDefinitions>
@ -21,7 +21,7 @@
<GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" Background="#FFCECECE"/>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="300" MaxWidth="600"/>
<ColumnDefinition MinWidth="200" MaxWidth="500"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
@ -48,10 +48,12 @@
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,145,0,50" TextWrapping="Wrap" Text="{x:Static lang:Resources.Remark}"
VerticalAlignment="Top" Width="40" FontSize="20"/>
</Grid>
<ScrollViewer Grid.Column="2" Margin="0" VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Horizontal" x:Name="Capacity" Background="White" Margin="0,0,0,0">
</WrapPanel>
</ScrollViewer>
<Grid Grid.Column="2" Margin="0">
<ScrollViewer Margin="0" VerticalScrollBarVisibility="Auto">
<WrapPanel Orientation="Horizontal" x:Name="Capacity" >
</WrapPanel>
</ScrollViewer>
</Grid>
</Grid>
<!--表-->
<DataGrid Grid.Row="2" x:Name="DataGriduser" MouseDoubleClick="DataGridMac_MouseDoubleClick" SelectionMode="Single" AlternationCount="2" IsReadOnly="True"
@ -88,10 +90,10 @@
</Style>
</DataGrid.CellStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static lang:Resources.USER}" Binding="{Binding UserCode}" Width="200" FontSize="15" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Group}" Binding="{Binding GROUP_CODE}" Width="200" FontSize="15" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
<DataGridTextColumn Header="{x:Static lang:Resources.USER}" Binding="{Binding Name}" Width="200" FontSize="15" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Group}" Binding="{Binding Groups}" Width="200" FontSize="15" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
<DataGridTextColumn Binding="{Binding Capacity}" FontSize="15" MaxWidth="0" MinWidth="0" CanUserReorder="False"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Remark}" Binding="{Binding Note}" Width="600" FontSize="15" MinWidth="100" CanUserReorder="False"/>
<DataGridTextColumn Header="{x:Static lang:Resources.Remark}" Binding="{Binding Note}" Width="*" FontSize="15" MinWidth="100" CanUserReorder="False"/>
</DataGrid.Columns>
</DataGrid>
<!--存储按钮-->

72
WindowsView/User.xaml.cs

@ -1,5 +1,7 @@
using SunlightCentralizedControlManagement_SCCM_.View;
using nGantt.GanttChart;
using SunlightCentralizedControlManagement_SCCM_.View;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
@ -14,30 +16,34 @@ namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
/// </summary>
public partial class User : Window
{
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
private UserClass.SqliteHelper.SQLiteHelper SQLiteHelpers = null; //定义数据库
CheckBox[] checkBoxes = new CheckBox[99];
string[] strings = new string[0] { };
string[] strings = new string[13] {"修改系统设置", "修改用户设置",
"单机监控","单机控制","单机设置","新建排程","排程编辑","排程删除",
"历史曲线","工艺查看","工艺编辑","工艺删除","输送信息"};
public User()
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
InitializeComponent();
}
private async void user_Loaded(object sender, RoutedEventArgs e)//打开页面执行
private void user_Loaded(object sender, RoutedEventArgs e)//打开页面执行
{
for (int i = 0; i < strings.Length; i++)
{
checkBoxes[i] = new CheckBox();
checkBoxes[i].Content = strings[i].ToString();
checkBoxes[i].FontSize = 20;
checkBoxes[i].Width = 80;
checkBoxes[i].Width = 200;
checkBoxes[i].Height = 50;
checkBoxes[i].IsEnabled = false;
Capacity.Children.Add(checkBoxes[i]);
}
}
SQLiteHelpers = new UserClass.SqliteHelper.SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
DataGriduser.ItemsSource = SQLiteHelpers.ExecuteDataSet("select * from USER order by Name desc", null).Tables[0].DefaultView;
SQLiteHelpers.Close();
}
private void Tb_KeyFloating(object sender, TextCompositionEventArgs e)//输入事件
{
@ -45,9 +51,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
Regex re = new Regex(@"^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");// 非负浮点数
e.Handled = !re.IsMatch(e.Text);
}
string Capacity_;
private void DataGridMac_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
{
string Capacity_;
int rownum = DataGriduser.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
@ -56,12 +63,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
GROUP.Text = (DataGriduser.Columns[1].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim();
Capacity_ = (DataGriduser.Columns[2].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim();
Note.Text = (DataGriduser.Columns[3].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim();
}
Pasword.Text = null; //清除密码框
for (int i = 0; i < Capacity_.Length; i++)
{
if (Capacity_.Substring(i, 1) == "1")
{
checkBoxes[i].IsChecked = true;
}
else
{
checkBoxes[i].IsChecked = false;
}
}
}
Pasword.Text = null; //清除密码框
}
private async void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
private void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
{
Regex re_number = new Regex(@"^[0-9]+(.[0-9]{1,2})?$");//校验用正则表达式有1~2位小数的正实数
Regex re_char = new Regex(@"^[A-Za-z0-9\s@()()/+!!_-]+$");//校验用正则表达式由数字,26个英文字母,空白字符和@()()/+!!_-组成的字符串
@ -69,15 +88,32 @@ namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
string name = _Name.Text;
string password = Pasword.Text;
string Group = GROUP.Text;
int Cap = 0;
string Cap = null;
string note = Note.Text;
string Stuff_sql;
string t = null;
for (int i = 0; i < strings.Length; i++)
{
if ((bool)checkBoxes[i].IsChecked)
{
Cap = Cap + "1";
}
else { Cap = Cap + "0"; }
}
Dictionary<string, object> USER_new = new Dictionary<string, object>();//缓存函数
USER_new.Add("Name", name);
USER_new.Add("Password", password);
USER_new.Add("Groups", Group);
USER_new.Add("Capacity", Cap);
USER_new.Add("Note", note);
SQLiteHelpers = new UserClass.SqliteHelper.SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.Delete("USER", "Name='" + name + "'", null);
SQLiteHelpers.InsertData("USER", USER_new);// 执行插入
SQLiteHelpers.Close();
}
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
private void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
{
}

Loading…
Cancel
Save