schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
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
    }
}