|
|
@ -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)//删除按钮事件
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|