frmManualOperate.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using Core.StlMes.Client.LgClassModel;
  5. namespace Core.StlMes.Client.LgCommon
  6. {
  7. public partial class frmManualOperate : Form
  8. {
  9. private string _DEVICE_POSITION = ""; //设备位置:BOF01
  10. private string _OBJECTPOS = ""; //当前工位:BOF01_DEVICE
  11. private CommandCollection _CC; //当前岗位手动操作配置集合
  12. private COM_STL_COMMAND _csc; //返回选中的手动操作
  13. /// <summary>
  14. /// COM_STL_COMMAND%ROWTYPE
  15. /// </summary>
  16. public COM_STL_COMMAND CSC
  17. {
  18. get { return _csc; }
  19. }
  20. /// <summary>
  21. /// 构造函数
  22. /// </summary>
  23. /// <param name="DEVICE_POSITION">设备位置:BOF01</param>
  24. /// <param name="OBJECTPOS">当前工位:BOF01_DEVICE</param>
  25. /// <param name="MOC">当前岗位手动操作配置集合</param>
  26. /// <param name="ob"></param>
  27. public frmManualOperate(string DEVICE_POSITION, string OBJECTPOS, CommandCollection CC)
  28. {
  29. InitializeComponent();
  30. this._DEVICE_POSITION = DEVICE_POSITION.ToUpper();
  31. this._OBJECTPOS = OBJECTPOS.ToUpper();
  32. this._CC = CC;
  33. }
  34. private void frmManualOperate_Load(object sender, EventArgs e)
  35. {
  36. InitUnitItems();
  37. AdjustForm();
  38. }
  39. /// <summary>
  40. /// 初始化操作配置
  41. /// </summary>
  42. private void InitUnitItems()
  43. {
  44. try
  45. {
  46. if (_CC != null)
  47. {
  48. COM_STL_COMMAND csc;
  49. for (int i = 0; i < _CC.Count; i++)
  50. {
  51. csc = _CC[i];
  52. if (csc == null) continue;
  53. if (_OBJECTPOS.Equals(csc.OBJECTPOS)) continue; //当前设备位置与目标位置一致
  54. if (_OBJECTPOS.Equals(csc.OBJECTPOS.Replace("%", _DEVICE_POSITION))) continue; //当前设备位置与目标位置一致
  55. if (csc.OPTTYPE == "2" && csc.OBJECTPOS.IndexOf(_DEVICE_POSITION) == 0) continue; //所处岗位与目标岗位一致
  56. if (_OBJECTPOS.Contains("IDLE") && csc.VISIBLE_IDLE != "1") continue;
  57. if (_OBJECTPOS.Contains("FRONT") && csc.VISIBLE_FRONT != "1") continue;
  58. if (_OBJECTPOS.Contains("DEVICE") && csc.VISIBLE_DEVICE != "1") continue;
  59. if (_OBJECTPOS.Contains("BACK") && csc.VISIBLE_BACK != "1") continue;
  60. if (csc.OPTTYPE == "1") unit_Normal.Add(csc);
  61. else if (csc.OPTTYPE == "2") unit_Abnormal.Add(csc);
  62. else if (csc.OPTTYPE == "3") unit_Switch.Add(csc);
  63. }
  64. }
  65. }
  66. catch { }
  67. }
  68. private void AdjustForm()
  69. {
  70. try
  71. {
  72. unit_Switch.Visible = unit_Switch.Count > 0;
  73. bool Hidden = (unit_Abnormal.Count == 0 && unit_Switch.Count == 0);
  74. panel2.Visible = !Hidden;
  75. if (Hidden)
  76. {
  77. Size iSize = panel2.Size;
  78. Point point = btnOK.Location;
  79. point.Offset(0, 0 - iSize.Height);
  80. btnOK.Location = point;
  81. point = btnCancel.Location;
  82. point.Offset(0, 0 - iSize.Height);
  83. btnCancel.Location = point;
  84. point = new Point(panel1.Size);
  85. point.Offset(0, 0 - iSize.Height);
  86. panel1.Size = new Size(point);
  87. point = new Point(this.Size);
  88. point.Offset(0, 0 - iSize.Height);
  89. this.Size = new Size(point);
  90. }
  91. }
  92. catch { }
  93. finally
  94. {
  95. ClsControlPack.GetChildWindowLocation(this.Size);
  96. }
  97. }
  98. private COM_STL_COMMAND GetSelection()
  99. {
  100. if (unit_Normal.Value != null) return unit_Normal.Value;
  101. else if (unit_Abnormal.Value != null) return unit_Abnormal.Value;
  102. else if (unit_Switch.Value != null) return unit_Switch.Value;
  103. else return null;
  104. }
  105. private void btnOK_Click(object sender, EventArgs e)
  106. {
  107. _csc = GetSelection();
  108. if (_csc == null)
  109. {
  110. MessageBox.Show("未选择任何操作!\n如需退出,请点击【退出】按钮。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  111. return;
  112. }
  113. this.DialogResult = DialogResult.OK;
  114. this.Close();
  115. }
  116. }
  117. }