using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.Linq;
|
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;
|
using DataRWDAL;
|
using XImagingXhandler.XDAL;
|
using DataEntity.Page;
|
using XCommon.Log;
|
using XHandler.View.BacteriaPickResult;
|
using XHandler.Class;
|
|
namespace XHandler.View.OperateAudit
|
{
|
/// <summary>
|
/// OperateAuditList.xaml 的交互逻辑
|
/// </summary>
|
public partial class OperateAuditList : UserControl
|
{
|
ObservableCollection<OperateAuditLog> operateAuditLogs = new ObservableCollection<OperateAuditLog>();
|
|
#region 变量
|
// 分页数据
|
private Pagination m_pagination = new Pagination();
|
#endregion
|
public OperateAuditList()
|
{
|
InitializeComponent();
|
}
|
|
private void btnSearch_Click(object sender, RoutedEventArgs e)
|
{
|
dgResult.ItemsSource = null;
|
pagerToolsControl_paging.Current = PaginationDefaultParameter.Current;
|
}
|
|
private void pagerToolsControl_paging_PageCntChanged(object sender, Page.C_EventArgsClass e)
|
{
|
m_pagination.Current = e.CurrentPageNo;
|
DataBinding(m_pagination);
|
}
|
|
private void pagerToolsControl_paging_OnePageRowCntChanged(object sender, Page.C_EventArgsClass e)
|
{
|
m_pagination.Current = e.CurrentPageNo;
|
m_pagination.PageSize = e.PagerNum;
|
DataBinding(m_pagination);
|
}
|
|
private void btnEdit_Click(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
Button btn = (Button)sender;
|
if (btn != null)
|
{
|
string id = (string)btn.Tag;
|
OperateAuditView operateAuditView = new OperateAuditView(id);
|
operateAuditView.closeEvent += EditUserInfo_closeEvent;
|
Window wnd = Application.Current.MainWindow;
|
Grid parent = Utilities.FindVisualChild<Grid>(wnd);
|
parent.Children.Add(operateAuditView);
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void EditUserInfo_closeEvent(object sender, EventArgs e)
|
{
|
UIElement element = sender as UIElement;
|
Window wnd = Application.Current.MainWindow;
|
Grid parent = Utilities.FindVisualChild<Grid>(wnd);
|
if (parent.Children.Contains(element))
|
parent.Children.Remove(element);
|
}
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
gdContent.RowDefinitions[0].Height = new GridLength(0);
|
BindExperimentCollectionToList();
|
}
|
catch (Exception ex)
|
{
|
|
}
|
}
|
|
private void DataGridCell_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
{
|
|
}
|
|
#region 绑定数据查询结果
|
public void BindExperimentCollectionToList()
|
{
|
DataBinding(m_pagination);
|
}
|
#endregion
|
|
/// <summary>
|
/// 分页绑定
|
/// </summary>
|
/// <param name="pagination"></param>
|
private void DataBinding(Pagination pagination)
|
{
|
string strOperateType = this.tbxOperateType.Text;
|
string strCreateName = this.tbxCreateName.Text;
|
operateAuditLogs = OperateAuditLogDB.GetExperimentCollectionFromdb(strOperateType, strCreateName);
|
int num = 1;
|
foreach(OperateAuditLog o in operateAuditLogs)
|
{
|
o.Index = num;
|
++num;
|
}
|
|
var resultOperateAuditLogList = GetPagedData(operateAuditLogs, pagination.Current, pagination.PageSize);
|
var result = new Tuple<IEnumerable<OperateAuditLog>, int>(resultOperateAuditLogList, operateAuditLogs.Count());
|
if (result != null)
|
{
|
pagerToolsControl_paging.IsTrigger = false;
|
pagerToolsControl_paging.DataCount = result.Item2; // 当前查到数量
|
pagerToolsControl_paging.Current = pagination.Current;
|
pagerToolsControl_paging.IsTrigger = true;
|
dgResult.ItemsSource = result.Item1;
|
}
|
}
|
|
#region 集合数据分页方法
|
private static IEnumerable<T> GetPagedData<T>(IEnumerable<T> source, int currentPageNumber, int pageSize)
|
{
|
if (source == null || !source.Any()) return Enumerable.Empty<T>();
|
|
int startIndex = (currentPageNumber - 1) * pageSize;
|
int endIndex = Math.Min(startIndex + pageSize, source.Count());
|
|
return source.Skip(startIndex).Take(endIndex - startIndex);
|
}
|
#endregion
|
}
|
}
|