using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace Mesnac.Controls.Feeding { public partial class SmallMaterialItem : UserControl { public SmallMaterialItem() { InitializeComponent(); } #region 自定义属性 private string _dataName; private DataTable _data; private DataTable _cloneData; private string _smallMaterialName; private int _smallMaterial; private string _smallMaterialValueName; private double _smallMaterialValue; /// /// 数据源动画属性 /// public string DataName { get { return _dataName; } set { _dataName = value; } } /// /// 正在称量名称 /// public string SmallMaterialName { get { return this._smallMaterialName; } set { this._smallMaterialName = value; } } /// /// 正在称量画面 /// public int SmallMaterial { get { return this._smallMaterial; } set { this._smallMaterial = value; UpdateCurrnetRow(value); } } /// /// 小料实际值动画属性 /// public string SmallMaterialValueName { get { return this._smallMaterialValueName; } set { this._smallMaterialValueName = value; } } /// /// 正在称量小料 /// public double SmallMaterialValue { get { return this._smallMaterialValue; } set { this._smallMaterialValue = value; this.UpdateCurrentValue(value); } } #endregion #region 数据属性 /// /// 数据源 /// public DataTable Data { get { return _data; } set { _data = value; if (this._cloneData == null || this._cloneData.Rows.Count == 0 || this._cloneData.TableName != this._data.TableName) { InitData(); } } } /// /// 数据初始化 /// private void InitData() { try { if (this._cloneData != null) { this._cloneData.Dispose(); this._cloneData = null; } if (this._data != null) { this._cloneData = this._data.Copy(); if (this._cloneData.Rows.Count > 0) { DataRow dr = this._cloneData.Rows[0]; this.labMaterilName.Text = dr["小料名称"].ToString(); this.labSet.Text = dr["小料标重"].ToString(); this.labFact.Text = dr["实重"].ToString(); this.labError.Text = dr["误差"].ToString(); } else { this.labMaterilName.Text = string.Empty; this.labSet.Text = string.Empty; this.labFact.Text = string.Empty; this.labError.Text = string.Empty; } } } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("胶料称监控画面小料列表数据初始化错误:" + ex.Message, ex); } } #endregion /// /// 更新实际称量值 /// private void UpdateCurrentValue(double value) { try { if (this._cloneData != null) { this.labFact.Text = value.ToString(); } } catch (Exception ex) { ICSharpCode.Core.LoggingService.Error("胶料称监控画面小料列表数据初始化错误:" + ex.Message, ex); } } /// /// 刷新当前行 /// /// private void UpdateCurrnetRow(int value) { if (value == 7 || value == 8) { this.labState.Text = "称量正确,等待送料..."; } else if(value==1) { this.labState.Text = "正在称量第一种物料"; } else this.labState.Text = ""; } } }