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
{
///
/// 菌落挑选结果界面
///
public partial class BacteriaPickResult : UserControl
{
#region 变量
private int TotalPage = 0;
private int pageSize = 10;
// 分页数据
private Pagination m_pagination = new Pagination();
#endregion
///
/// 构造函数
///
public BacteriaPickResult()
{
InitializeComponent();
}
#region 初期表示
///
/// 初期表示
///
///
///
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
try
{
// 设置识别方法下拉值
BindIdentification();
// 获取查询结果
GetData();
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
///
/// 设置识别方法下拉值
///
private void BindIdentification()
{
List dropdownNames = new List();
// 全选
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;
}
///
/// 获取查询结果
///
private void GetData()
{
DataBinding(m_pagination);
}
///
/// 分页绑定
///
///
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(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;
}
}
///
/// 获取搜索参数
///
///
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 查询
///
/// 日期选择变更事件
///
///
///
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;
}
}
///
/// 日期控件click
///
///
///
private void btnDatePick_Click(object sender, RoutedEventArgs e)
{
calendar.Visibility = calendar.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
}
#endregion
#region 查询按钮
///
/// 查询按钮
///
///
///
private void btnSearch_Click(object sender, RoutedEventArgs e)
{
calendar.Visibility = Visibility.Collapsed;
dgResult.ItemsSource = null;
pagerToolsControl_paging.Current = PaginationDefaultParameter.Current;
}
#endregion
#region 挑选详情
///
/// 挑选详情
///
///
///
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(wnd);
parent.Children.Add(details);
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
///
/// 图片预览窗口关闭
///
///
///
private void Details_closeEvent(object sender, EventArgs e)
{
Window wnd = Application.Current.MainWindow;
Grid grid = Utilities.FindVisualChild(wnd);
UIElement element = sender as UIElement;
grid.Children.Remove(element);
}
#endregion
#region 涂布报告
///
/// 涂布报告
///
///
///
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(wnd);
parent.Children.Add(details);
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
#endregion
#region 挑菌结果查看图片
///
/// 挑菌结果查看图片
///
///
///
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(wnd);
parent.Children.Add(imagePreview);
e.Handled = true;
}
}
catch (Exception ex)
{
LoggerHelper.ErrorLog("ERROR:", ex);
}
}
///
/// 图片预览窗口关闭
///
///
///
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 分页事件
///
/// 当前页改变时发生
///
///
///
private void pagerToolsControl_paging_PageCntChanged(object sender, C_EventArgsClass e)
{
m_pagination.Current = e.CurrentPageNo;
DataBinding(m_pagination);
}
///
/// 每页行数改变时发生
///
///
///
private void pagerToolsControl_paging_OnePageRowCntChanged(object sender, C_EventArgsClass e)
{
m_pagination.Current = e.CurrentPageNo;
m_pagination.PageSize = e.PagerNum;
DataBinding(m_pagination);
}
#endregion
}
}