添加用户权限管理
This commit is contained in:
commit
04f0798c17
10 files changed
+98
-142
No files matched your search
+2
-2
@@ -173,8 +173,8 @@ namespace SunlightCentralizedControlManagement_SCCM_
|
||||
/// </summary>
|
||||
private void Application_Startup(object sender, StartupEventArgs e)
|
||||
{
|
||||
// Application.Current.StartupUri = new Uri("Login.xaml", UriKind.Relative);
|
||||
Current.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);//和MainWindwo同一目录
|
||||
Current.StartupUri = new Uri("Login.xaml", UriKind.Relative);
|
||||
//Current.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);//和MainWindwo同一目录
|
||||
}
|
||||
|
||||
public static class SystemSleepTool
|
||||
|
||||
+15
-6
@@ -10,6 +10,7 @@
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Loaded="Window_Loaded"
|
||||
Title="SUNLIGHT SCCM b0.0.1 (2024/08/10)"
|
||||
Height="1080" Width="1920" Background="#FF003640"
|
||||
WindowState ="Maximized" WindowStyle="None">
|
||||
@@ -41,11 +42,19 @@
|
||||
<Grid x:Name="GridTitle" Height="50" VerticalAlignment="Top" Background="#FF006361" MouseDown="GridTitle_MouseDown" Margin="60,0,0,0">
|
||||
<TextBlock Text="Sunlight Centralized Control Management (SCCM)" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22" Foreground="White"/>
|
||||
<StackPanel VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<ComboBox x:Name="username" VerticalAlignment="Center" FontSize="14" DropDownClosed="username_DropDownClosed" HorizontalAlignment="Right" Margin="0,0,5,0" Width="100" Foreground="White">
|
||||
<ComboBox.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type ComboBoxItem}">
|
||||
<Setter Property="Foreground" Value="Black">
|
||||
</Setter>
|
||||
</Style>
|
||||
</ComboBox.ItemContainerStyle>
|
||||
</ComboBox>
|
||||
<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}" Click="ButtonUSER_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.SysSet}" Click="ButtonSYS_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.USER}" Click="ButtonUSER_Click" x:Name="User_" IsEnabled="{Binding USER_Capacity[1]}"/>
|
||||
<Button Content="{x:Static lang:Resources.SysSet}" Click="ButtonSYS_Click" x:Name="SysSet_" IsEnabled="{Binding USER_Capacity[0]}"/>
|
||||
<Separator/>
|
||||
<Button Content="{x:Static lang:Resources.Permit}" Click="ButtonPermit_Click"/>
|
||||
<Button Content="{x:Static lang:Resources.Help}" Click="Buttonhelp_Click"/>
|
||||
@@ -87,25 +96,25 @@
|
||||
<TextBlock Text="{x:Static lang:Resources.ProductionPlanning}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</ListViewItem>
|
||||
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_Curve">
|
||||
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_Curve" IsEnabled="{Binding USER_Capacity[9]}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="ChartBellCurve" Width="25" Height="25" Margin="10" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{x:Static lang:Resources.Curve}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</ListViewItem>
|
||||
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_Machine">
|
||||
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_Machine" IsEnabled="{Binding USER_Capacity[2]}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Settings" Width="25" Height="25" Margin="10" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{x:Static lang:Resources.Machine}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</ListViewItem>
|
||||
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_Programgroup">
|
||||
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_Programgroup" IsEnabled="{Binding USER_Capacity[9]}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Database" Width="25" Height="25" Margin="10" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{x:Static lang:Resources.Programgroup}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||
</StackPanel>
|
||||
</ListViewItem>
|
||||
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_ConveyorCenters">
|
||||
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_ConveyorCenters" IsEnabled="{Binding USER_Capacity[12]}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<materialDesign:PackIcon Kind="Pipe" Width="25" Height="25" Margin="10" VerticalAlignment="Center"/>
|
||||
<TextBlock Text="{x:Static lang:Resources.ConveyorCenters}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
@@ -17,6 +19,7 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
|
||||
|
||||
namespace SunlightCentralizedControlManagement_SCCM_
|
||||
@@ -196,6 +199,19 @@ namespace SunlightCentralizedControlManagement_SCCM_
|
||||
}
|
||||
}
|
||||
|
||||
private void username_DropDownClosed(object sender, EventArgs e)
|
||||
{
|
||||
MainWindowViewModel.USERCapacity(username.Text);
|
||||
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)//打开页面
|
||||
{
|
||||
username.ItemsSource = MainWindowViewModel.USER_data.Select(
|
||||
"Groups='" + MainWindowViewModel.USER_data.Select("Name='" + App.USER_Purview + "'").
|
||||
First().Field<string>("Groups").ToString() + "'").
|
||||
AsEnumerable().Select(rowdata => rowdata.Field<string>("Name")).ToList();
|
||||
username.Text = App.USER_Purview;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,6 @@
|
||||
<Compile Include="UserClass\StrToInt.cs" />
|
||||
<Compile Include="UserClass\SubItem.cs" />
|
||||
<Compile Include="UserClass\UserControlMenuItem.cs" />
|
||||
<Compile Include="ViewModel\ProductionPlanningModel.cs" />
|
||||
<Compile Include="ViewModel\CurveDiagramViewModel.cs" />
|
||||
<Compile Include="ViewModel\MainWindowViewModel.cs" />
|
||||
<Compile Include="ViewModel\ViewModelLocator.cs" />
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:viewmodel="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ViewModel"
|
||||
xmlns:Ngantt="clr-namespace:nGantt;assembly=nGantt"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:ProductionPlanningModel}"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}"
|
||||
mc:Ignorable="d" Loaded="UserControl_Loaded"
|
||||
d:DesignHeight="900" d:DesignWidth="1800">
|
||||
<UserControl.Resources>
|
||||
@@ -75,7 +75,7 @@
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Height="60" Background="#FF00204E" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
|
||||
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_New" x:Name="Quit">
|
||||
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_New" x:Name="Quit" IsEnabled="{Binding USER_Capacity[5]}">
|
||||
<StackPanel Orientation="Horizontal" >
|
||||
<materialDesign:PackIcon Kind="NewBox" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
|
||||
<TextBlock Text="{x:Static lang:Resources.New}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||
|
||||
@@ -54,7 +54,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
public ProductionPlanningView()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new ProductionPlanningModel();
|
||||
Sdatepicker.Language = XmlLanguage.GetLanguage(Configini.IniReadvalue("SYS", "Language"));
|
||||
CountDown();
|
||||
}
|
||||
@@ -147,41 +146,47 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||
}
|
||||
private void EditClicked(GanttTask ganttTask)
|
||||
{
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
DataTable WorkOrder_dt = SQLiteHelpers.ExecuteDataSet(
|
||||
"select * from WorkOrder where WorkOrder='" + ganttTask.ID + "'Order by StartTime", null).Tables[0]; //读取表写入缓存
|
||||
SQLiteHelpers.Close();
|
||||
if (MainWindowViewModel.USER_Capacity[6])
|
||||
{
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
DataTable WorkOrder_dt = SQLiteHelpers.ExecuteDataSet(
|
||||
"select * from WorkOrder where WorkOrder='" + ganttTask.ID + "'Order by StartTime", null).Tables[0]; //读取表写入缓存
|
||||
SQLiteHelpers.Close();
|
||||
|
||||
if (DateTime.Now > DateTime.Parse(WorkOrder_dt.Select().First().Field<object>("EndTime").ToString()))
|
||||
{
|
||||
MessageBox.Show(Properties.Resources.EHCIP, "SCCM", MessageBoxButton.OK, MessageBoxImage.Warning);//禁止编辑历史工艺
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WorkOrder_dt.Select().First().Field<object>("State").ToString() == "101")
|
||||
if (DateTime.Now > DateTime.Parse(WorkOrder_dt.Select().First().Field<object>("EndTime").ToString()))
|
||||
{
|
||||
Picture.Content = null;
|
||||
Picture.Width = 600;
|
||||
Picture.Content = new ProductionPlanningEdit(ganttTask.ID, true);
|
||||
MessageBox.Show(Properties.Resources.EHCIP, "SCCM", MessageBoxButton.OK, MessageBoxImage.Warning);//禁止编辑历史工艺
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(Properties.Resources.ENWOIP, "SCCM", MessageBoxButton.OK, MessageBoxImage.Warning);//禁止编辑非等待中的工单
|
||||
if (WorkOrder_dt.Select().First().Field<object>("State").ToString() == "101")
|
||||
{
|
||||
Picture.Content = null;
|
||||
Picture.Width = 600;
|
||||
Picture.Content = new ProductionPlanningEdit(ganttTask.ID, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(Properties.Resources.ENWOIP, "SCCM", MessageBoxButton.OK, MessageBoxImage.Warning);//禁止编辑非等待中的工单
|
||||
}
|
||||
}
|
||||
}
|
||||
}//编辑
|
||||
private void DeleteClicked(GanttTask ganttTask)//删除
|
||||
{
|
||||
if (System.Windows.Forms.MessageBox.Show(Properties.Resources.Confirm + Properties.Resources.Delete + ganttTask.Name, "Delete ",
|
||||
System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
|
||||
if (MainWindowViewModel.USER_Capacity[7])
|
||||
{
|
||||
///执行删除
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Delete("WorkOrder", "WorkOrder='" + ganttTask.ID + "'", null);
|
||||
SQLiteHelpers.Close();
|
||||
GanttChartNEW();
|
||||
if (System.Windows.Forms.MessageBox.Show(Properties.Resources.Confirm + Properties.Resources.Delete + ganttTask.Name, "Delete ",
|
||||
System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
///执行删除
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
SQLiteHelpers.Delete("WorkOrder", "WorkOrder='" + ganttTask.ID + "'", null);
|
||||
SQLiteHelpers.Close();
|
||||
GanttChartNEW();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string FormatYear(Period period)
|
||||
|
||||
@@ -5,6 +5,7 @@ using Newtonsoft.Json.Linq;
|
||||
using OpenTK.Graphics.ES11;
|
||||
using SunlightCentralizedControlManagement_SCCM_.Properties;
|
||||
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -65,20 +66,51 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
||||
public static DataTable Machines = new DataTable(); //设备表缓存
|
||||
public static DataTable USER_data = new DataTable();
|
||||
public static UserControls.info[] inf = new UserControls.info[999]; //定义总览信息卡
|
||||
public static int ERR_c = 0;//错误计数器
|
||||
public static bool[] USER_Capacity { set; get; } = new bool[99];
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||
SQLiteHelpers.Open(); //打开数据库
|
||||
Machines = SQLiteHelpers.ExecuteDataSet("select * from Machines Order by id", null).Tables[0]; //读取表写入缓存
|
||||
USER_data = SQLiteHelpers.ExecuteDataSet("select * from USER order by Name desc", null).Tables[0];
|
||||
SQLiteHelpers.Close();
|
||||
|
||||
USERCapacity(App.USER_Purview);//App.USER_Purview);
|
||||
CountDown();
|
||||
TcpClientNEW();
|
||||
SQL_LINK();
|
||||
}
|
||||
public static void USERCapacity(string user) //权限
|
||||
{
|
||||
if (user != "ENGINEER")
|
||||
{
|
||||
string USER_Cap = USER_data.Select("Name='" + user + "'").First().Field<string>("Capacity").ToString();
|
||||
for (int i = 0; i < USER_Cap.Length; i++)
|
||||
{
|
||||
if (USER_Cap.Substring(i, 1) == "1")
|
||||
{
|
||||
USER_Capacity[i] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
USER_Capacity[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 99; i++)
|
||||
{
|
||||
USER_Capacity[i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static async void SQL_LINK()//连接dbc数据库
|
||||
{
|
||||
if (conn_SC.State == ConnectionState.Open) conn_SC.Close();
|
||||
@@ -101,7 +133,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
ERR_c++;
|
||||
}
|
||||
}
|
||||
|
||||
public void CountDown()
|
||||
{
|
||||
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
using LiveChartsCore.SkiaSharpView;
|
||||
using LiveChartsCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using LiveChartsCore.Kernel.Sketches;
|
||||
using LiveChartsCore.SkiaSharpView.Painting;
|
||||
using ScottPlot.Colormaps;
|
||||
using System.Drawing;
|
||||
using System.Windows.Media.TextFormatting;
|
||||
using System.Xml.Linq;
|
||||
using SkiaSharp;
|
||||
using LiveChartsCore.Defaults;
|
||||
using static System.Net.WebRequestMethods;
|
||||
using System.Collections.ObjectModel;
|
||||
using DyeingComputer.Properties;
|
||||
using LiveChartsCore.Measure;
|
||||
using LiveChartsCore.Motion;
|
||||
using SunlightCentralizedControlManagement_SCCM_.Properties;
|
||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||
using TouchSocket.Core;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using SunlightCentralizedControlManagement_SCCM_.View;
|
||||
using LiveChartsCore.SkiaSharpView.Painting.Effects;
|
||||
using LiveChartsCore.Drawing;
|
||||
using LiveChartsCore.SkiaSharpView.Drawing.Geometries;
|
||||
using System.Windows.Documents;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
{
|
||||
public partial class ProductionPlanningModel : ObservableObject//ViewModelBase
|
||||
{
|
||||
//x轴时间格式
|
||||
/* public Axis[] XAxes { get; set; } =
|
||||
{
|
||||
new DateTimeAxis(TimeSpan.FromSeconds(5) , date => date.ToString("yyyy-MM-dd HH:mm"))
|
||||
{
|
||||
CrosshairLabelsBackground = SKColors.DarkGray.AsLvcColor(),
|
||||
CrosshairLabelsPaint = new SolidColorPaint(SKColors.DarkSlateBlue, 1),
|
||||
CrosshairPaint = new SolidColorPaint(SKColors.DarkSlateGray, 1),
|
||||
},
|
||||
};
|
||||
public Axis[] YAxes { get; set; } =
|
||||
{
|
||||
new Axis
|
||||
{
|
||||
MinLimit = 0,
|
||||
// TextSize = 20,
|
||||
LabelsDensity = 1,
|
||||
Labels = MainWindowViewModel.Machines.AsEnumerable().Select(row=> row.Field<string>("name")).ToList(),//转换列名为机台
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
public ProductionPlanningModel()
|
||||
{
|
||||
var r = new Random();
|
||||
var values1 = new ObservableCollection<ObservablePoint>();
|
||||
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
values1.Add(new ObservablePoint(r.Next(10, 20), r.Next(0, 20)));
|
||||
}
|
||||
|
||||
Series = new ISeries[]
|
||||
{
|
||||
// use the second type parameter to specify the geometry to draw for every point
|
||||
// there are already many predefined geometries in the
|
||||
// LiveChartsCore.SkiaSharpView.Drawing.Geometries namespace
|
||||
new ScatterSeries<ObservablePoint, RoundedRectangleGeometry>
|
||||
{
|
||||
Values = values1,
|
||||
Stroke = null,
|
||||
GeometrySize = 10,
|
||||
},
|
||||
|
||||
// You can also use SVG paths to draw the geometry
|
||||
// LiveCharts already provides some predefined paths in the SVGPoints class.
|
||||
|
||||
|
||||
// you can declare your own gemetry and use the SkiaSharp api to draw it
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public ISeries[] Series { get; set; } */
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||
return ServiceLocator.Current.GetInstance<CurveDiagramViewModel>();
|
||||
}
|
||||
}
|
||||
public ProductionPlanningModel Production
|
||||
{
|
||||
get
|
||||
{
|
||||
return ServiceLocator.Current.GetInstance<ProductionPlanningModel>();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -90,8 +90,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
|
||||
string Group = GROUP.Text;
|
||||
string Cap = null;
|
||||
string note = Note.Text;
|
||||
|
||||
string t = null;
|
||||
for (int i = 0; i < strings.Length; i++)
|
||||
{
|
||||
if ((bool)checkBoxes[i].IsChecked)
|
||||
|
||||
Reference in new issue
Block a user