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.
153 lines
5.7 KiB
153 lines
5.7 KiB
using DyeingComputer.UserClass;
|
|
using DyeingComputer.ViewModel;
|
|
using ScottPlot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using System.Xml.Linq;
|
|
using static DyeingComputer.UserClass.SqliteHelper;
|
|
using static System.Collections.Specialized.BitVector32;
|
|
|
|
namespace DyeingComputer.View
|
|
{
|
|
/// <summary>
|
|
/// WorkOrder.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class WorkOrderView : UserControl
|
|
{
|
|
public WorkOrderView()
|
|
{
|
|
DataContext = new WorkOrderViewModel();
|
|
|
|
InitializeComponent();
|
|
|
|
Workorder_sql();
|
|
WpfPlot();
|
|
}
|
|
|
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
|
DataSet sql; //内存数据缓存
|
|
|
|
string WorkOrder_Numder;
|
|
string Process_Name;
|
|
string Process_id;
|
|
string _lock;
|
|
|
|
public void Workorder_sql()
|
|
{
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
string sql_script = "select * from WorkOrder where StartTime > '" + DateTime.Now.ToString("yyyy/MM/dd") + "'";
|
|
|
|
if (sql != null) sql.Clear(); //清空缓存
|
|
sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
|
|
if(sql!=null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
|
|
|
SQLiteHelpers.Close(); //关闭连接
|
|
|
|
WorkOrder_Numder = null;
|
|
Process_Name = null;
|
|
Process_id = null;
|
|
_lock = null;
|
|
//sql.Clear(); //清除缓存
|
|
//System.GC.Collect();
|
|
}
|
|
|
|
public void WpfPlot()
|
|
{
|
|
DateTime[] xs = Generate.ConsecutiveHours(100);
|
|
double[] ys = Generate.RandomWalk(100);
|
|
|
|
//double q = ploigrid.ActualHeight;
|
|
|
|
//WpfPlot_Grid.y. SetAxisLimitsY(yMin: 0, yMax: 150);
|
|
// WpfPlot_Grid.Height = 500;
|
|
|
|
// WpfPlot_Grid.Plot.Grid.XAxisStyle.IsVisible = true;
|
|
// WpfPlot_Grid.Plot.Grid.YAxisStyle.IsVisible = false;
|
|
|
|
|
|
// WpfPlot_Grid.Plot.YLabel("Temperature (C)");
|
|
|
|
}
|
|
|
|
private void WorkOrderView_lock_Click(object sender, RoutedEventArgs e)//锁定按钮
|
|
{
|
|
Dictionary<string, object> lock_v = new Dictionary<string, object>();//缓存函数
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
if (_lock == "0") //改变lock的状态
|
|
{
|
|
lock_v.Add("lock", 1);
|
|
SQLiteHelpers.Update("WorkOrder", lock_v, "WorkOrder='"+WorkOrder_Numder+"'",null);
|
|
}else
|
|
{
|
|
lock_v.Add("lock", 0);
|
|
SQLiteHelpers.Update("WorkOrder", lock_v, "WorkOrder='" + WorkOrder_Numder + "'", null);
|
|
}
|
|
|
|
SQLiteHelpers.Close();
|
|
Workorder_sql();
|
|
}
|
|
|
|
private void WorkOrderView_new_Click(object sender, RoutedEventArgs e)//新建按钮
|
|
{
|
|
WpfPlot();
|
|
}
|
|
|
|
private void WorkOrderView_del_Click(object sender, RoutedEventArgs e)//删除按钮
|
|
{
|
|
///弹窗提示确认删除
|
|
if (System.Windows.Forms.MessageBox.Show(Properties.Resources.Confirm + Properties.Resources.Delete + WorkOrder_Numder , "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='" + WorkOrder_Numder + "'", null);
|
|
SQLiteHelpers.Close();
|
|
Workorder_sql();
|
|
}
|
|
}
|
|
|
|
private void WorkOrderView_redy_Click(object sender, RoutedEventArgs e)//重染按钮
|
|
{
|
|
string WorkNum = MainWindowViewModel.WorkNumder.ToString();
|
|
if (WorkNum !=null)
|
|
{
|
|
if (System.Windows.Forms.MessageBox.Show(Properties.Resources.Confirm + Properties.Resources.Redye + WorkNum, "Redye ",
|
|
System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
///执行重染
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)//表格选择事件
|
|
{
|
|
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
WorkOrder_Numder = (Grid.Columns[0].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
Process_Name = (Grid.Columns[1].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
|
Process_id = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
_lock = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第1列,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|