using DyeingComputer.ViewModel ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Linq ;
using System.Net ;
using System.Text ;
using System.Threading ;
using System.Threading.Tasks ;
using System.Timers ;
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 static DyeingComputer . UserClass . SqliteHelper ;
namespace DyeingComputer.View
{
/// <summary>
/// HistoryRecordsView.xaml 的交互逻辑
/// </summary>
public partial class HistoryRecordsView : UserControl
{
private SQLiteHelper SQLiteHelpers = null ; //定义数据库
private readonly string DBAddress = Environment . CurrentDirectory + "\\DataBase\\800COMPUTER.db" ; //数据库路径
DataTable GRIDDB = new DataTable ( ) ;
public HistoryRecordsView ( )
{
InitializeComponent ( ) ;
DataContext = new HistoryRecordsViewModel ( ) ;
SQLiteHelpers = new SQLiteHelper ( DBAddress ) ; //数据库连接路径
SQLiteHelpers . Open ( ) ; //打开数据库
GRIDDB = SQLiteHelpers . ExecuteDataSet ( "select * from WorkOrder where StartTime > '" + DateTime . Now . AddDays ( - 3 0 ) . ToString ( "yyyy/MM/dd HH:mm:ss" ) + "order by StartTime'" , null ) . Tables [ 0 ] ;
SQLiteHelpers . Close ( ) ;
gridH . ItemsSource = GRIDDB . DefaultView ;
}
private void Grid_SelectionChanged ( object sender , SelectionChangedEventArgs e )
{
int rownum = gridH . SelectedIndex ; //获取鼠标选中行并定义变量
if ( rownum ! = - 1 ) //判断鼠标定位是否有效
{
HistoryRecordsViewModel . name = ( gridH . Columns [ 0 ] . GetCellContent ( gridH . Items [ rownum ] ) as TextBlock ) . Text ; //定位第0列,
HistoryRecordsViewModel . stime = ( gridH . Columns [ 5 ] . GetCellContent ( gridH . Items [ rownum ] ) as TextBlock ) . Text ; //定位第1列,
HistoryRecordsViewModel . etime = ( gridH . Columns [ 6 ] . GetCellContent ( gridH . Items [ rownum ] ) as TextBlock ) . Text ; //定位第6列
HistoryRecordsViewModel . history_ = true ;
}
}
}
}