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.
103 lines
3.8 KiB
103 lines
3.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
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.Markup;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using static DyeingComputer.Windows.ViewStep;
|
|
using System.Xml.Linq;
|
|
using System.Windows.Media.Animation;
|
|
using System.Net;
|
|
using System.Data;
|
|
using static DyeingComputer.UserClass.SqliteHelper;
|
|
|
|
namespace DyeingComputer.Windows
|
|
{
|
|
/// <summary>
|
|
/// ViewProgram.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class ViewProgram : Window
|
|
{
|
|
public ViewProgram()
|
|
{
|
|
InitializeComponent();
|
|
Programgroup_sql();
|
|
}
|
|
// private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
// private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
|
DataSet sql; //内存数据缓存
|
|
public void Programgroup_sql()
|
|
{
|
|
//SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
// SQLiteHelpers.Open(); //打开数据库
|
|
|
|
string sql_script = "select * from ProgramName order by ProgramID desc";
|
|
|
|
if (sql != null) sql.Clear(); //清空缓存
|
|
sql = MainWindow.SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表写入缓存
|
|
if (sql != null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转换显示计划表
|
|
|
|
// SQLiteHelpers.Close(); //关闭连接
|
|
|
|
//sql.Clear(); //清除缓存
|
|
//System.GC.Collect();
|
|
}
|
|
public delegate void AddressUpdateHandler(object sender, AddressUpdateEventArgs e);
|
|
//声明一个更新Address的事件
|
|
public event AddressUpdateHandler AddressUpdated;
|
|
|
|
private void YES_Click(object sender, RoutedEventArgs e)//确认
|
|
{
|
|
var args = new AddressUpdateEventArgs(Program_STEP, Program_ID, Program_NAME, Program_TIME);
|
|
AddressUpdated(this, args);
|
|
this.Close(); //关闭窗口
|
|
}
|
|
|
|
private void NO_Click(object sender, RoutedEventArgs e)//关闭
|
|
{
|
|
this.Close(); //关闭窗口
|
|
}
|
|
|
|
string Program_ID;
|
|
string Program_NAME;
|
|
string Program_STEP;
|
|
string Program_TIME;
|
|
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)//表格选择事件
|
|
{
|
|
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
Program_ID = (Grid.Columns[0].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
Program_NAME = (Grid.Columns[1].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
Program_STEP = (Grid.Columns[2].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
Program_TIME = (Grid.Columns[3].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
}
|
|
}
|
|
|
|
public class AddressUpdateEventArgs : System.EventArgs
|
|
{
|
|
public AddressUpdateEventArgs(string dStep, string dID, string dNAME, string dtime)
|
|
{
|
|
this.ID = dID;
|
|
this.Step = dStep;
|
|
this.NAME = dNAME;
|
|
this.TIME = dtime;
|
|
}
|
|
|
|
public string Step { get; set; }
|
|
public string ID { get; set; }
|
|
public string NAME { get; set; }
|
|
public string TIME { get; set; }
|
|
|
|
}
|
|
}
|
|
}
|
|
|