using DataEntity;
|
using DataEntity.Device;
|
using DataEntity.Page;
|
using DataRWDAL;
|
using DataRWDAL.Device;
|
using HxEnum;
|
using NPOI.SS.UserModel;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.Linq;
|
using System.Windows;
|
using System.Windows.Controls;
|
using System.Windows.Input;
|
using XCommon;
|
using XCommon.Log;
|
using XCoreBLL;
|
using XHandler.Class;
|
using XHandler.View.Page;
|
using XImagingXhandler.XDAL;
|
namespace XHandler.View.BacteriaPickResult
|
{
|
/// <summary>
|
/// 菌落挑选结果界面
|
/// </summary>
|
public partial class BacteriaPickResult : UserControl
|
{
|
#region 变量
|
private int TotalPage = 0;
|
private int pageSize = 10;
|
// 分页数据
|
private Pagination m_pagination = new Pagination();
|
#endregion
|
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public BacteriaPickResult()
|
{
|
InitializeComponent();
|
}
|
|
#region 初期表示
|
/// <summary>
|
/// 初期表示
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
// 设置识别方法下拉值
|
BindIdentification();
|
|
// 获取查询结果
|
GetData();
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
/// <summary>
|
/// 设置识别方法下拉值
|
/// </summary>
|
private void BindIdentification()
|
{
|
List<DropdownName> dropdownNames = new List<DropdownName>();
|
|
// 全选
|
DropdownName dropdownName = new DropdownName();
|
dropdownName.dropdown_id = EnumManagement.GetEnumValue(IdentificationEnum.None).ToString();
|
dropdownName.dropdown_name = Properties.Resources.strSelectAll;
|
dropdownNames.Add(dropdownName);
|
|
// 自动
|
dropdownName = new DropdownName();
|
dropdownName.dropdown_id = EnumManagement.GetEnumValue(IdentificationEnum.Auto).ToString();
|
dropdownName.dropdown_name = Properties.Resources.strAuto;
|
dropdownNames.Add(dropdownName);
|
|
// 人工
|
dropdownName = new DropdownName();
|
dropdownName.dropdown_id = EnumManagement.GetEnumValue(IdentificationEnum.Manual).ToString();
|
dropdownName.dropdown_name = Properties.Resources.strManual;
|
dropdownNames.Add(dropdownName);
|
|
comboxIdentification.ItemsSource = dropdownNames;
|
comboxIdentification.SelectedIndex = 0;
|
}
|
|
/// <summary>
|
/// 获取查询结果
|
/// </summary>
|
private void GetData()
|
{
|
DataBinding(m_pagination);
|
}
|
|
/// <summary>
|
/// 分页绑定
|
/// </summary>
|
/// <param name="pagination"></param>
|
private void DataBinding(Pagination pagination)
|
{
|
var result = ExperimentRunChoiceBacteraDB.GetPageData(pagination, GetSearch());
|
if (result != null)
|
{
|
for (int i = 0; i < result.Item1.Count; i++)
|
{
|
result.Item1[i].indexNum = i + 1;
|
result.Item1[i].IdentificationName =
|
EnumManagement.GetEnumDescription(EnumManagement.GetField<IdentificationEnum>(result.Item1[i].Identification));
|
}
|
|
pagerToolsControl_paging.IsTrigger = false;
|
pagerToolsControl_paging.DataCount = result.Item2; // 当前查到数量
|
pagerToolsControl_paging.Current = pagination.Current;
|
pagerToolsControl_paging.IsTrigger = true;
|
dgResult.ItemsSource = result.Item1;
|
}
|
}
|
|
/// <summary>
|
/// 获取搜索参数
|
/// </summary>
|
/// <returns></returns>
|
private ExperimentRunChoiceBacteraModel GetSearch()
|
{
|
ExperimentRunChoiceBacteraModel searchModel = new ExperimentRunChoiceBacteraModel();
|
|
DateTime dt = DateTime.MinValue;
|
if (!string.IsNullOrEmpty(txtStart.Text))
|
{
|
ComUtility.ParseToDateTime(txtStart.Text + " 00:00:00", out dt);
|
searchModel.StartTime = dt;
|
}
|
|
if (!string.IsNullOrEmpty(txtEnd.Text))
|
{
|
ComUtility.ParseToDateTime(txtEnd.Text + " 23:59:59", out dt);
|
searchModel.EndTime = dt;
|
}
|
|
searchModel.SourceBarcode = txtDishBarcode.Text;
|
searchModel.Identification = Convert.ToInt32(comboxIdentification.SelectedValue.ToString());
|
searchModel.ExperimentId = txtRunProductId.Text;
|
|
return searchModel;
|
}
|
#endregion
|
|
#region 查询
|
/// <summary>
|
/// 日期选择变更事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
|
{
|
if (e.AddedItems.Count > 0)
|
{
|
txtStart.Text = calendar.SelectedDates.First().ToString("yyyy/MM/dd");
|
txtEnd.Text = calendar.SelectedDates.Last().ToString("yyyy/MM/dd");
|
//calendar.Visibility = Visibility.Collapsed;
|
}
|
}
|
|
/// <summary>
|
/// 日期控件click
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnDatePick_Click(object sender, RoutedEventArgs e)
|
{
|
calendar.Visibility = calendar.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
|
}
|
#endregion
|
|
#region 查询按钮
|
/// <summary>
|
/// 查询按钮
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnSearch_Click(object sender, RoutedEventArgs e)
|
{
|
calendar.Visibility = Visibility.Collapsed;
|
dgResult.ItemsSource = null;
|
|
pagerToolsControl_paging.Current = PaginationDefaultParameter.Current;
|
}
|
#endregion
|
|
#region 挑选详情
|
/// <summary>
|
/// 挑选详情
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnPickDetail_Click(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
Button btn = (Button)sender;
|
if (btn != null)
|
{
|
string runChoiceBacteraId = (string)btn.Tag;
|
|
// 获取挑菌详细信息
|
var experimentRunChoiceBacteraModel = ExperimentRunChoiceBacteraDB.GetInfodById(runChoiceBacteraId);
|
|
// 表示挑选菌落详情页面
|
BacteriaPickDetails details = new BacteriaPickDetails(experimentRunChoiceBacteraModel);
|
details.closeEvent += Details_closeEvent;
|
Window wnd = Application.Current.MainWindow;
|
Grid parent = Utilities.FindVisualChild<Grid>(wnd);
|
parent.Children.Add(details);
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
/// <summary>
|
/// 图片预览窗口关闭
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void Details_closeEvent(object sender, EventArgs e)
|
{
|
Window wnd = Application.Current.MainWindow;
|
Grid grid = Utilities.FindVisualChild<Grid>(wnd);
|
|
UIElement element = sender as UIElement;
|
grid.Children.Remove(element);
|
}
|
#endregion
|
|
#region 涂布报告
|
/// <summary>
|
/// 涂布报告
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void btnCoatingReport_Click(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
Button btn = (Button)sender;
|
if (btn != null)
|
{
|
string runChoiceBacteraId = (string)btn.Tag;
|
var experimentRunChoiceBacteraModel = ExperimentRunChoiceBacteraDB.GetInfodById(runChoiceBacteraId);
|
|
// 表示涂布报告页面
|
BacteriaCoatingDetails details = new BacteriaCoatingDetails(experimentRunChoiceBacteraModel);
|
details.closeEvent += Details_closeEvent;
|
Window wnd = Application.Current.MainWindow;
|
Grid parent = Utilities.FindVisualChild<Grid>(wnd);
|
parent.Children.Add(details);
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
#endregion
|
|
#region 挑菌结果查看图片
|
/// <summary>
|
/// 挑菌结果查看图片
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void DataGridCell_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
{
|
try
|
{
|
if (e.OriginalSource is Image)
|
{
|
Image img = (Image)e.OriginalSource;
|
ExperimentRunChoiceBacteraModel data = img.DataContext as ExperimentRunChoiceBacteraModel;
|
ImagePreview imagePreview = new ImagePreview(data.UpdateImagePath);
|
imagePreview.closeEvent += ImagePreview_closeEvent;
|
Window wnd = Application.Current.MainWindow;
|
Grid parent = Utilities.FindVisualChild<Grid>(wnd);
|
parent.Children.Add(imagePreview);
|
|
e.Handled = true;
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
/// <summary>
|
/// 图片预览窗口关闭
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void ImagePreview_closeEvent(object sender, EventArgs e)
|
{
|
try
|
{
|
// 移除元素
|
UIElement element = sender as UIElement;
|
Utilities.RemoveChild(element);
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
#endregion
|
|
#region 分页事件
|
/// <summary>
|
/// 当前页改变时发生
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void pagerToolsControl_paging_PageCntChanged(object sender, C_EventArgsClass e)
|
{
|
m_pagination.Current = e.CurrentPageNo;
|
DataBinding(m_pagination);
|
}
|
|
/// <summary>
|
/// 每页行数改变时发生
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void pagerToolsControl_paging_OnePageRowCntChanged(object sender, C_EventArgsClass e)
|
{
|
m_pagination.Current = e.CurrentPageNo;
|
m_pagination.PageSize = e.PagerNum;
|
DataBinding(m_pagination);
|
}
|
#endregion
|
}
|
}
|