using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
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 Aitex.Triton160.Common;
using Aitex.Triton160.UI.ViewModel;
using DataAnalysisControl.Core;
using Aitex.Core.Util;
using ExcelLibrary.SpreadSheet;
using Triton160.UI.ViewModel;
namespace Aitex.Triton160.UI.Views
{
///
/// Interaction logic for DataLogView.xaml
///
public partial class DataLogView : UserControl
{
private DataLogViewModel _viewModel;
private DateTime BeginTime
{
get
{
var BeginDate = dateBegin.SelectedDate.HasValue ? dateBegin.SelectedDate.Value : DateTime.Now;
return new DateTime(BeginDate.Year, BeginDate.Month, BeginDate.Day,
timeBegin.Value.Value.Hour, timeBegin.Value.Value.Minute, timeBegin.Value.Value.Second);
}
}
private DateTime EndTime
{
get
{
var EndDate = dateEnd.SelectedDate.HasValue ? dateEnd.SelectedDate.Value : DateTime.Now;
return new DateTime(EndDate.Year, EndDate.Month, EndDate.Day,
timeEnd.Value.Value.Hour, timeEnd.Value.Value.Minute, timeEnd.Value.Value.Second, 999);
}
}
public DataLogView()
{
InitializeComponent();
_viewModel = new DataLogViewModel();
DataContext = _viewModel;
var now = DateTime.Now;
dateBegin.DisplayDate = now - new TimeSpan(1, 0, 0, 0);
dateEnd.DisplayDate = now;
dateBegin.SelectedDate = now;
dateEnd.SelectedDate = now;
timeBegin.Value = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, 0);
timeEnd.Value = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59, 999);
dataGrid_LotList.CanUserAddRows = false;
_viewModel.UpdateRecipeList(BeginTime, EndTime);
IsVisibleChanged += DataLogView_IsVisibleChanged;
}
void DataLogView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (!IsLoaded)
return;
if (IsVisible)
_viewModel.UpdateRecipeList(BeginTime, EndTime);
}
private void buttonQuery_Click(object sender, RoutedEventArgs e)
{
_viewModel.UpdateDataLogList(BeginTime, EndTime, recipeName.Text,LotTextBox.BarcodeText.Trim());
List DataLogList = _viewModel.DataLogList;
ButtonExportList.IsEnabled = DataLogList != null && DataLogList.Count > 0;
}
private void dateBegin_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
if (!IsLoaded)
return;
_viewModel.UpdateRecipeList(BeginTime, EndTime);
}
private void timeBegin_ValueChanged(object sender, RoutedPropertyChangedEventArgs