You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
3.0 KiB
C#

using MaterialTraceability.Entity.DAO;
using MaterialTraceability.Entity.DTO;
using MaterialTraceability.SqlSugar;
using MaterialTraceability.SqlSugar.ServiceImpl;
using MaterialTraceabilityUI.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
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;
namespace MaterialTraceabilityUI
{
/// <summary>
/// LogRecordControl.xaml 的交互逻辑
/// </summary>
public partial class LogRecordControl : UserControl
{
private AppConfigDto appConfig = AppConfigDto.Instance;
private IBaseServices<RecordLogInfo> logInfoServices = new BaseServices<RecordLogInfo>();
public LogRecordControl()
{
InitializeComponent();
}
private void Seach_Click(object sender, RoutedEventArgs e)
{
Refresh();
}
private void Refresh()
{
Expression<Func<RecordLogInfo, bool>> exp = s1 => true;
if (this.beginTime.Text.ToString() != "")
{
DateTime beginTime = Convert.ToDateTime(this.beginTime.Text.ToString());
exp = exp.And(x => Convert.ToDateTime(x.recordTime) >= beginTime);
}
if (this.endTime.Text.ToString() != "")
{
DateTime endTime = Convert.ToDateTime(this.endTime.Text.ToString());
exp = exp.And(x => Convert.ToDateTime(x.recordTime) <= endTime);
}
if(Convert.ToString(this.logType.SelectedItem) != "")
{
exp = exp.And(x => x.alarmType == Convert.ToString(this.logType.SelectedItem));
}
if (Convert.ToString(this.isAlarm.SelectedItem) != "")
{
int isAlarm = Convert.ToString(this.isAlarm.SelectedItem) == "是" ? 1 : 0;
exp = exp.And(x => x.isAlarm == isAlarm);
}
if (appConfig.processId == "AB")
{
exp = exp.And(x => x.machineId == appConfig.machineId.ToString());
}
List<RecordLogInfo> recordLogInfos = logInfoServices.Query(exp).Result;
this.LogRecordDataGrid.ItemsSource = recordLogInfos;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
this.beginTime.Text = DateTime.Now.ToLongDateString();
this.endTime.Text = DateTime.Now.AddDays(1).ToLongDateString();
List<String> types = new List<string>() { "MES", "PLC", "RFID", "" };
this.logType.ItemsSource = types;
List<String> isAlarm = new List<string>() { "是", "否", "" };
this.isAlarm.ItemsSource = isAlarm;
Refresh();
}
}
}