You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
5.2 KiB
117 lines
5.2 KiB
using nGantt.GanttChart;
|
|
using SunlightCentralizedControlManagement_SCCM_.View;
|
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Text.RegularExpressions;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Xml.Linq;
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
|
|
{
|
|
/// <summary>
|
|
/// Machine.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class User : Window
|
|
{
|
|
CheckBox[] checkBoxes = new CheckBox[99];
|
|
string[] strings = new string[13] {"修改系统设置", "修改用户设置",
|
|
"单机监控","单机控制","单机设置","新建排程","排程编辑","排程删除",
|
|
"历史曲线","工艺查看","工艺编辑","工艺删除","输送信息"};
|
|
public User()
|
|
{
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
InitializeComponent();
|
|
}
|
|
|
|
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 = 200;
|
|
checkBoxes[i].Height = 50;
|
|
Capacity.Children.Add(checkBoxes[i]);
|
|
}
|
|
DataGriduser.ItemsSource = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from USER order by Name desc", null).Tables[0].DefaultView;
|
|
}
|
|
|
|
private void Tb_KeyFloating(object sender, TextCompositionEventArgs e)//输入事件
|
|
{
|
|
//Regex re = new Regex("[^0-9.-]+");
|
|
Regex re = new Regex(@"^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");// 非负浮点数
|
|
e.Handled = !re.IsMatch(e.Text);
|
|
}
|
|
|
|
private void DataGridMac_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
|
|
{
|
|
string Capacity_;
|
|
int rownum = DataGriduser.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
/*定位选中行及指定列单元格文本信息*/
|
|
_Name.Text = (DataGriduser.Columns[0].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim();//定位第列
|
|
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();
|
|
|
|
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 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个英文字母,空白字符和@()()/+!!_-组成的字符串
|
|
|
|
string name = _Name.Text;
|
|
string password = Pasword.Text;
|
|
string Group = GROUP.Text;
|
|
string Cap = null;
|
|
string note = Note.Text;
|
|
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);
|
|
MainWindowViewModel.SQLiteHelpers.Delete("USER", "Name='" + name + "'", null);
|
|
MainWindowViewModel.SQLiteHelpers.InsertData("USER", USER_new);// 执行插入
|
|
DataGriduser.ItemsSource = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from USER order by Name desc", null).Tables[0].DefaultView;
|
|
_Name.Text = null;
|
|
}
|
|
|
|
private void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
|
{
|
|
MainWindowViewModel.SQLiteHelpers.Delete("USER", "Name='" + _Name.Text + "'", null);
|
|
DataGriduser.ItemsSource = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from USER order by Name desc", null).Tables[0].DefaultView;
|
|
_Name.Text = null;
|
|
}
|
|
}
|
|
}
|
|
|