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
using DataEntity.Rack;
using DataEntity.Share;
using DataRWDAL.Rack;
using HandyControl.Data;
using HxEnum;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Input;
using XCommon;
using XCommon.Log;
using XCommon.Tip;
using XHandler.Class.DataEx;
using XImagingXhandler.XDAL;
using static XCommon.Event.EventBind;
 
namespace XHandler.View.Rack
{
    /// <summary>
    /// 设置页面
    /// </summary>
    public partial class RackLayerEdit : Window
    {
        #region 变量
        private RacksetLayerModel m_racksetLayerModel = null;
        #endregion
 
        #region 构造函数
        public RackLayerEdit(RacksetLayerModel racksetLayerModel)
        {
            InitializeComponent();
            m_racksetLayerModel = racksetLayerModel;
            this.Owner = (Window)Shared.Main;
        }
        #endregion
 
        #region 初期表示
        private void SytemSettings_Loaded(object sender, RoutedEventArgs e)
        {
            #region 是否有耗材
            cBoxHasLabware.ItemsSource = ComUtility.GetDropDownList<IsHasLabwareEnum>();
            cBoxHasLabware.SelectedValue = m_racksetLayerModel.is_has_labware.ToString();
            #endregion
 
            #region 耗材名称
            ObservableCollection<Labware> labwareList = DataModule.getInstance().GetLabwares();
            cBoxLabware.ItemsSource = labwareList;
            cBoxLabware.SelectedValue = m_racksetLayerModel.labware_id.ToString();
            #endregion
 
            tBoxTitle.Text = string.Format("编辑暂存架{0}", m_racksetLayerModel.rack_name);
        }
        #endregion
 
        #region 确定
        /// <summary>
        /// 确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var racksetLayerModel = RacksetLayerDB.GetInfodById(m_racksetLayerModel.id);
 
                racksetLayerModel.is_has_labware = Convert.ToInt32(cBoxHasLabware.SelectedValue);
                racksetLayerModel.labware_id = cBoxLabware.SelectedValue.ToString();
                racksetLayerModel.modify_name = Shared.User.username;
                racksetLayerModel.modify_time = DateTime.Now;
                RacksetLayerDB.Update(racksetLayerModel);
 
                ShowTip.ShowNotice("保存成功", InfoType.Success);
                this.Close();
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 是否有耗材 选择变更
        /// <summary>
        /// 是否有耗材 选择变更
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cBoxHasLabware_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            try
            {
                // 无耗材时,耗材类型不可选择
                cBoxLabware.IsEnabled = Convert.ToInt32(cBoxHasLabware.SelectedValue) == EnumManagement.GetEnumValue(IsHasLabwareEnum.Yes);
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 关闭窗口
        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        #endregion
 
        #region 拖动窗体
        /// <summary>
        /// 拖动窗体
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (e.ChangedButton == MouseButton.Left)
                {
                    this.DragMove();
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region ESC关闭画面
        /// <summary>
        /// ESC关闭画面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Escape)
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
    }
}