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.
102 lines
3.7 KiB
102 lines
3.7 KiB
using DyeingComputer.ViewModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
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.Animation;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using static DyeingComputer.UserClass.SqliteHelper;
|
|
|
|
namespace DyeingComputer.View
|
|
{
|
|
/// <summary>
|
|
/// InOutView.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class InOutView : UserControl
|
|
{
|
|
public InOutView()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
|
|
|
private void Grid_D_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void Grid_A_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void Grid_M_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
private void Grid_D_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
{
|
|
string ID;
|
|
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
|
|
|
|
int rownum = Grid_D.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
ID = (Grid_D.Columns[0].GetCellContent(Grid_D.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
|
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
|
datagrid_v.Add("PLC", newValue);
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
SQLiteHelpers.Update("IOName", datagrid_v, "ID ='" + ID + "'", null);//更新
|
|
SQLiteHelpers.Close();//关闭数据库
|
|
}
|
|
MainWindowViewModel.SQL_data();//重新获得io表
|
|
MainWindowViewModel.D_view = true;
|
|
}
|
|
|
|
private void Grid_D_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
|
{
|
|
MainWindowViewModel.D_view = false;
|
|
}
|
|
|
|
private void Grid_A_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
|
{
|
|
string ID;
|
|
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
|
|
|
|
int rownum = Grid_A.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
ID = (Grid_A.Columns[0].GetCellContent(Grid_A.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
|
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
|
datagrid_v.Add("PLC", newValue);
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
SQLiteHelpers.Update("IOName", datagrid_v, "ID ='" + ID + "'", null);//更新
|
|
SQLiteHelpers.Close();//关闭数据库
|
|
}
|
|
MainWindowViewModel.SQL_data();//重新获得io表
|
|
MainWindowViewModel.A_view = true;
|
|
}
|
|
|
|
private void Grid_A_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
|
{
|
|
MainWindowViewModel.A_view = false;
|
|
}
|
|
}
|
|
}
|
|
|