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.

82 lines
2.6 KiB
C#

using MaterialTraceability.Entity.DAO;
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 MesRequestControl : UserControl
{
private IBaseServices<RecordMesWebServiceRequest> baseServices = new BaseServices<RecordMesWebServiceRequest>();
public MesRequestControl()
{
InitializeComponent();
}
private void Seach_Click(object sender, RoutedEventArgs e)
{
Refresh();
}
private void Refresh()
{
Expression<Func<RecordMesWebServiceRequest, bool>> exp = s1 => true;
if (this.beginTime.Text.ToString() != "")
{
DateTime beginTime = Convert.ToDateTime(this.beginTime.Text.ToString());
exp = exp.And(x => Convert.ToDateTime(x.requestTime) >= beginTime);
}
if (this.endTime.Text.ToString() != "")
{
DateTime endTime = Convert.ToDateTime(this.endTime.Text.ToString());
exp = exp.And(x => Convert.ToDateTime(x.requestTime) <= endTime);
}
if (Convert.ToString(this.isAlarmInfo.SelectedItem) != "")
{
int isAlarm = Convert.ToString(this.isAlarmInfo.SelectedItem) == "是" ? 1 : 0;
exp = exp.And(x => x.responseCode == isAlarm);
}
List<RecordMesWebServiceRequest> recordLogInfos = baseServices.Query(exp).Result;
recordLogInfos.ForEach(x =>
{
x.responseResult = x.responseCode == 0 ? "成功" : "失败";
});
this.ReadRecordDataGrid.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> isAlarm = new List<string>() { "是", "否", "" };
this.isAlarmInfo.ItemsSource = isAlarm;
Refresh();
}
}
}