using DyeingComputer.UserClass; using DyeingComputer.ViewModel; 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 static DyeingComputer.UserClass.SqliteHelper; namespace DyeingComputer.View { /// /// WorkOrder.xaml 的交互逻辑 /// public partial class WorkOrderView : UserControl { public WorkOrderView() { DataContext = new WorkOrderViewModel(); InitializeComponent(); workorder_sql(); } private SQLiteHelper SQLiteHelpers = null; //定义数据库 private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径 public void workorder_sql() { SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径 SQLiteHelpers.Open(); //打开数据库 string Work_Time = DateTime.Now.ToString("yyyy/MM/dd"); string sql_script = "select * from WorkOrder where StartTime > '" + Work_Time + "'"; DataSet sql = SQLiteHelpers.ExecuteDataSet(sql_script, null); //读取计划表 if(sql!=null) Grid.ItemsSource = sql.Tables[0].DefaultView; //转显示计划表 SQLiteHelpers.Close(); //关闭连接 //sql.Clear(); //清除缓存 //System.GC.Collect(); } } }