using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing; using System.Data; namespace Mesnac.Controls.Feeding { /// /// 胶料重量偏差值标签 /// [ToolboxBitmap(typeof(System.Windows.Forms.Label))] public partial class RecipPlyFact : Label { public RecipPlyFact() { InitializeComponent(); } private string _finishStatusName; private OnOffStatuses _finishStatus; private string _dataName; private DataTable _data; private DataTable _cloneData; private string _currentRecipPlyName1; private int _currentRecipPly1; private string _currentRecipPlyName2; private int _currentRecipPly2; private string _currentRecipPlyName3; private int _currentRecipPly3; private string _currentRecipPlyName4; private int _currentRecipPly4; private string _currentRecipPlyName5; private int _currentRecipPly5; private string _currentRecipPlyName6; private int _currentRecipPly6; private string _currentRecipPlyName7; private int _currentRecipPly7; private string _currentRecipPlyName8; private int _currentRecipPly8; private string _currentRecipPlyName9; private int _currentRecipPly9; private string _currentRecipPlyName10; private int _currentRecipPly10; private string _currentRecipPlyName11; private int _currentRecipPly11; private string _currentRecipPlyName12; private int _currentRecipPly12; private string _currentRecipPlyName13; private int _currentRecipPly13; private string _currentRecipPlyName14; private int _currentRecipPly14; private string _currentRecipPlyName15; private int _currentRecipPly15; private string _plyCurrentValueName1; private double _plyCurrentValue1; //胶料实际值 private string _plyCurrentValueName2; private double _plyCurrentValue2; private string _plyCurrentValueName3; private double _plyCurrentValue3; private string _plyCurrentValueName4; private double _plyCurrentValue4; private string _plyCurrentValueName5; private double _plyCurrentValue5; private string _plyCurrentValueName6; private double _plyCurrentValue6; private string _plyCurrentValueName7; private double _plyCurrentValue7; private string _plyCurrentValueName8; private double _plyCurrentValue8; private string _plyCurrentValueName9; private double _plyCurrentValue9; private string _plyCurrentValueName10; private double _plyCurrentValue10; private string _plyCurrentValueName11; private double _plyCurrentValue11; private string _plyCurrentValueName12; private double _plyCurrentValue12; private string _plyCurrentValueName13; private double _plyCurrentValue13; private string _plyCurrentValueName14; private double _plyCurrentValue14; private string _plyCurrentValueName15; private double _plyCurrentValue15; /// /// 数据源 /// public DataTable Data { get { return _data; } set { _data = value; this._cloneData = _data; if (this._cloneData == null || this._cloneData.TableName != this._data.TableName) { this.InitData(false); } } } /// /// 数据源动画属性 /// public string DataName { get { return _dataName; } set { _dataName = value; } } /// /// 一车结束标志动画属性 /// public string FinishStatusName { get { return _finishStatusName; } set { _finishStatusName = value; } } /// /// 初始化数据 /// private void InitData(bool isclear) { try { if (isclear) { if (this._cloneData == null || this._cloneData.TableName != this._data.TableName) { if (this._cloneData != null) { this._cloneData.Dispose(); } this._cloneData = null; } } if ((this._cloneData == null && this._data != null && this._data.Rows.Count > 0) || (this._cloneData != null && this._data != null && this._cloneData.TableName != this._data.TableName)) { this._cloneData = this._data.Copy(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } } /// /// 一车结束标志 /// public OnOffStatuses FinishStatus { get { return _finishStatus; } set { if ((int)value > 1) { this._finishStatus = OnOffStatuses.On; } else if ((int)value < 0) { this._finishStatus = OnOffStatuses.Off; } else { this._finishStatus = value; } //如果一车标志结束,则重新绑定数据源 if (this._finishStatus == OnOffStatuses.On) { this.InitData(true); } } } #region 称量的第几种胶料动画属性 /// /// 称量的第一种胶料动画属性 /// public string CurrentRecipPlyName1 { get { return _currentRecipPlyName1; } set { _currentRecipPlyName1 = value; } } /// /// 称量的第二种胶料动画属性 /// public string CurrentRecipPlyName2 { get { return _currentRecipPlyName2; } set { _currentRecipPlyName2 = value; } } /// /// 称量的第三种胶料动画属性 /// public string CurrentRecipPlyName3 { get { return _currentRecipPlyName3; } set { _currentRecipPlyName3 = value; } } /// /// 称量的第四种胶料动画属性 /// public string CurrentRecipPlyName4 { get { return _currentRecipPlyName4; } set { _currentRecipPlyName4 = value; } } /// /// 称量的第五种胶料动画属性 /// public string CurrentRecipPlyName5 { get { return _currentRecipPlyName5; } set { _currentRecipPlyName5 = value; } } /// /// 称量的第六种胶料动画属性 /// public string CurrentRecipPlyName6 { get { return _currentRecipPlyName6; } set { _currentRecipPlyName6 = value; } } /// /// 称量的第七种胶料动画属性 /// public string CurrentRecipPlyName7 { get { return _currentRecipPlyName7; } set { _currentRecipPlyName7 = value; } } /// /// 称量的第八种胶料动画属性 /// public string CurrentRecipPlyName8 { get { return this._currentRecipPlyName8; } set { this._currentRecipPlyName8 = value; } } /// /// 称量的第九种胶料动画属性 /// public string CurrentRecipPlyName9 { get { return this._currentRecipPlyName9; } set { this._currentRecipPlyName9 = value; } } /// /// 称量的第十种胶料动画属性 /// public string CurrentRecipPlyName10 { get { return this._currentRecipPlyName10; } set { this._currentRecipPlyName10 = value; } } /// /// 称量的第十一种胶料动画属性 /// public string CurrentRecipPlyName11 { get { return this._currentRecipPlyName11; } set { this._currentRecipPlyName11 = value; } } /// /// 称量的第十二种胶料动画属性 /// public string CurrentRecipPlyName12 { get { return this._currentRecipPlyName12; } set { this._currentRecipPlyName12 = value;} } /// /// 称量的第十三种胶料动画属性 /// public string CurrentRecipPlyName13 { get { return this._currentRecipPlyName13; } set { this._currentRecipPlyName13 = value; } } /// /// 称量的第十四种胶料动画属性 /// public string CurrentRecipPlyName14 { get { return this._currentRecipPlyName14; } set { this._currentRecipPlyName14 = value; } } /// /// 称量的第十五种胶料动画属性 /// public string CurrentRecipPlyName15 { get { return this._currentRecipPlyName15; } set { this._currentRecipPlyName15 = value; } } #endregion #region 胶料实际值动画属性 /// /// 称量的第一种胶料实际值动画属性 /// public string PlyCurrentValueName1 { get { return this._plyCurrentValueName1; } set { this._plyCurrentValueName1 = value; } } /// /// 称量的第二种胶料实际值动画属性 /// public string PlyCurrentValueName2 { get { return _plyCurrentValueName2; } set { this._plyCurrentValueName2 = value; } } /// /// 称量的第三种胶料实际值动画属性 /// public string PlyCurrentValueName3 { get { return this._plyCurrentValueName3; } set { this._plyCurrentValueName3 = value; } } /// /// 称量的第四种胶料实际值动画属性 /// public string PlyCurrentValueName4 { get { return this._plyCurrentValueName4; } set { this._plyCurrentValueName4 = value; } } /// /// 称量的第五种胶料实际值动画属性 /// public string PlyCurrentValueName5 { get { return this._plyCurrentValueName5; } set { this._plyCurrentValueName5 = value; } } /// /// 称量的第六种胶料实际值动画属性 /// public string PlyCurrentValueName6 { get { return this._plyCurrentValueName6; } set { this._plyCurrentValueName6 = value; } } /// /// 称量的第七种胶料实际值动画属性 /// public string PlyCurrentValueName7 { get { return this._plyCurrentValueName7; } set { this._plyCurrentValueName7 = value; } } /// /// 称量的第八种胶料实际值动画属性 /// public string PlyCurrentValueName8 { get { return this._plyCurrentValueName8; } set { this._plyCurrentValueName8 = value; } } /// /// 称量的第九种胶料实际值动画属性 /// public string PlyCurrentValueName9 { get { return this._plyCurrentValueName9; } set { this._plyCurrentValueName9 = value; } } /// /// 称量的第十种胶料实际值动画属性 /// public string PlyCurrentValueName10 { get { return this._plyCurrentValueName10; } set { this._plyCurrentValueName10 = value; } } /// /// 称量的第十一种胶料实际值动画属性 /// public string PlyCurrentValueName11 { get { return this._plyCurrentValueName11; } set { this._plyCurrentValueName11 = value; } } /// /// 称量的第十二种胶料实际值动画属性 /// public string PlyCurrentValueName12 { get { return this._plyCurrentValueName12; } set { this._plyCurrentValueName12 = value; } } /// /// 称量的第十三种胶料实际值动画属性 /// public string PlyCurrentValueName13 { get { return this._plyCurrentValueName13; } set { this._plyCurrentValueName13 = value; } } /// /// 称量的第十四种胶料实际值动画属性 /// public string PlyCurrentValueName14 { get { return this._plyCurrentValueName14; } set { this._plyCurrentValueName14 = value; } } /// /// 称量的第十五种胶料实际值动画属性 /// public string PlyCurrentValueName15 { get { return this._plyCurrentValueName15; } set { this._plyCurrentValueName15 = value; } } #endregion public RecipPlyFact(IContainer container) { container.Add(this); InitializeComponent(); } #region 判断当前称量的胶料 /// /// 称量的第一种胶料 /// public int CurrentRecipPly1 { get { return _currentRecipPly1; } set { _currentRecipPly1 = value; } } /// /// 称量的第二种胶料 /// public int CurrentRecipPly2 { get { return _currentRecipPly2; } set { _currentRecipPly2 = value; } } /// /// 称量的第三种胶料 /// public int CurrentRecipPly3 { get { return _currentRecipPly3; } set { _currentRecipPly3 = value; } } /// /// 称量的第四种胶料 /// public int CurrentRecipPly4 { get { return _currentRecipPly4; } set { _currentRecipPly4 = value; } } /// /// 称量的第五种胶料 /// public int CurrentRecipPly5 { get { return _currentRecipPly5; } set { _currentRecipPly5 = value; } } /// /// 称量的第六种胶料 /// public int CurrentRecipPly6 { get { return _currentRecipPly6; } set { _currentRecipPly6 = value; } } /// /// 称量的第七种胶料 /// public int CurrentRecipPly7 { get { return _currentRecipPly7; } set { _currentRecipPly7 = value; } } /// /// 称量的第八种胶料 /// public int CurrentRecipPly8 { get { return this._currentRecipPly8; } set { this._currentRecipPly8 = value; } } /// /// 称量的第九种胶料 /// public int CurrentRecipPly9 { get { return this._currentRecipPly9; } set { this._currentRecipPly9 = value; } } /// /// 称量的第十种胶料 /// public int CurrentRecipPly10 { get { return this._currentRecipPly10; } set { this._currentRecipPly10 = value; } } /// /// 称量的第十一种胶料 /// public int CurrentRecipPly11 { get { return this._currentRecipPly11; } set { this._currentRecipPly11 = value; } } /// /// 称量的第十二种胶料 /// public int CurrentRecipPly12 { get { return this._currentRecipPly12; } set { this._currentRecipPly12 = value; } } /// /// 称量的第十三种胶料 /// public int CurrentRecipPly13 { get { return this._currentRecipPly13; } set { this._currentRecipPly13 = value; } } /// /// 称量的第十四种胶料 /// public int CurrentRecipPly14 { get { return this._currentRecipPly14; } set { this._currentRecipPly14 = value; } } /// /// 称量的第十五种胶料 /// public int CurrentRecipPly15 { get { return this._currentRecipPly15; } set { this._currentRecipPly15 = value; } } #endregion #region 胶料实际值属性 /// /// 第一种胶料实际值 /// public double PlyCurrentValue1 { get { return _plyCurrentValue1; } set { _plyCurrentValue1 = value; this.RefreshCurrentValue(1, value); } } /// /// 第二种胶料实际值 /// public double PlyCurrentValue2 { get { return this._plyCurrentValue2; } set { this._plyCurrentValue2 = value; this.RefreshCurrentValue(2, value); } } /// /// 第三种胶料实际值 /// public double PlyCurrentValue3 { get { return this._plyCurrentValue3; } set { this._plyCurrentValue3 = value; this.RefreshCurrentValue(3, value); } } /// /// 第四种胶料实际值 /// public double PlyCurrentValue4 { get { return this._plyCurrentValue4; } set { this._plyCurrentValue4 = value; this.RefreshCurrentValue(4, value); } } /// /// 第五种胶料实际值 /// public double PlyCurrentValue5 { get { return this._plyCurrentValue5; } set { this._plyCurrentValue5 = value; this.RefreshCurrentValue(5, value); } } /// /// 第六种胶料实际值 /// public double PlyCurrentValue6 { get { return this._plyCurrentValue6; } set { this._plyCurrentValue6 = value; this.RefreshCurrentValue(6, value); } } /// /// 第七种胶料实际值 /// public double PlyCurrentValue7 { get { return this._plyCurrentValue7; } set { this._plyCurrentValue7 = value; this.RefreshCurrentValue(7, value); } } /// /// 第八种胶料实际值 /// public double PlyCurrentValue8 { get { return this._plyCurrentValue8; } set { this._plyCurrentValue8 = value; this.RefreshCurrentValue(8, value); } } /// /// 第九种胶料实际值 /// public double PlyCurrentValue9 { get { return this._plyCurrentValue9; } set { this._plyCurrentValue9 = value; this.RefreshCurrentValue(9, value); } } /// /// 第十种胶料实际值 /// public double PlyCurrentValue10 { get { return this._plyCurrentValue10; } set { this._plyCurrentValue10 = value; this.RefreshCurrentValue(10, value); } } /// /// 第十一种胶料实际值 /// public double PlyCurrentValue11 { get { return this._plyCurrentValue11; } set { this._plyCurrentValue11 = value; this.RefreshCurrentValue(11, value); } } /// /// 第十二种胶料实际值 /// public double PlyCurrentValue12 { get { return this._plyCurrentValue12; } set { this._plyCurrentValue12 = value; this.RefreshCurrentValue(12, value); } } /// /// 第十三种胶料实际值 /// public double PlyCurrentValue13 { get { return this._plyCurrentValue13; } set { this._plyCurrentValue13 = value; this.RefreshCurrentValue(13, value); } } /// /// 第十四种胶料实际值 /// public double PlyCurrentValue14 { get { return this._plyCurrentValue14; } set { this._plyCurrentValue14 = value; this.RefreshCurrentValue(14, value); } } /// /// 第十五种胶料实际值 /// public double PlyCurrentValue15 { get { return this._plyCurrentValue15; } set { this._plyCurrentValue15 = value; this.RefreshCurrentValue(15, value); } } #endregion #region 辅助方法 private void RefreshCurrentValue(int step, double values) { if (this._currentRecipPly15 == 1 && step == 15) { getValues(15, values); } if (this._currentRecipPly14 == 1 && step == 14) { getValues(14, values); } if (this._currentRecipPly13 == 1 && step == 13) { getValues(13, values); } if (this._currentRecipPly12 == 1 && step == 12) { getValues(12, values); } if (this._currentRecipPly11 == 1 && step == 11) { getValues(11, values); } if (this._currentRecipPly10 == 1 && step == 10) { getValues(10, values); } if (this._currentRecipPly9 == 1 && step == 9) { getValues(9, values); } if (this._currentRecipPly8 == 1 && step == 8) { getValues(8, values); } if (this._currentRecipPly7 == 1 && step == 7) { getValues(7, values); } if (this._currentRecipPly6 == 1 && step == 6) { getValues(6, values); } if (this._currentRecipPly5 == 1 && step == 5) { getValues(5, values); } if (this._currentRecipPly4 == 1 && step == 4) { getValues(4, values); } if (this._currentRecipPly3 == 1 && step == 3) { getValues(3, values); } if (this._currentRecipPly2 == 1 && step==2) { getValues(2, values); } if (this._currentRecipPly1 == 1 && step == 1) { getValues(1, values); } } private void getValues(int step,double values) { if (this._cloneData != null) { if (this._cloneData.Columns.Contains("序号") && this._cloneData.Columns.Contains("设定")) { for (int i = 0; i < this._cloneData.Rows.Count; i++) { if (step == int.Parse(this._cloneData.Rows[i]["序号"].ToString())) { this.Text = Convert.ToDecimal((values - double.Parse(this._cloneData.Rows[i]["设定"].ToString())).ToString()).ToString("f2"); } } } } } #endregion } }