FrmEquMsg.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. using DevComponents.DotNetBar.Layout;
  2. using DevComponents.DotNetBar.SuperGrid;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Windows.Forms;
  8. using WCS.Entity.Protocol;
  9. using WCS_Client.UC;
  10. using WCS_Client.Utility;
  11. namespace WCS_Client.Frm
  12. {
  13. public partial class FrmEquMsg : Form
  14. {
  15. public FrmEquMsg()
  16. {
  17. InitializeComponent();
  18. InitFrm();
  19. }
  20. private void InitFrm()
  21. {
  22. List<GridColumn> GCList = new List<GridColumn>()
  23. {
  24. SuperGridUtil.Get_GridColumn("CODE", "设备编号", 80),
  25. SuperGridUtil.Get_GridColumn("NAME", "设备名称", 200),
  26. SuperGridUtil.Get_GridColumn("PLCCODE", "plc编号", 100),
  27. SuperGridUtil.Get_GridColumn("PLCNAME", "plc名称", 140),
  28. SuperGridUtil.Get_GridColumn("IP", "plc 地址", 200),
  29. };
  30. List<LayoutControlItem> LCIList = new List<LayoutControlItem>();
  31. LCIList.Add(LCItemUtil.Add_TextboxX("CODE", "设备编号:", 20, SubmitMethods, null));
  32. LCIList[LCIList.Count - 1].Tag = new LCWhereInfo() { QWhereText = "a.CODE like '%{0}%'" };
  33. LCIList.Add(LCItemUtil.Add_TextboxX("NAME", "设备名称:", 20, SubmitMethods, null));
  34. LCIList[LCIList.Count - 1].Tag = new LCWhereInfo() { QWhereText = "a.NAME like '%{0}%'" };
  35. LCIList.Add(LCItemUtil.Add_ButtonX("btn_QDB", "查询", 80, 30, SubmitMethods));
  36. LCIList.Add(LCItemUtil.Add_ButtonX("btn_QClear", "重置", 80, 30, SubmitMethods));
  37. //LCIList.Add(LCItemUtil.Add_ButtonX("updateEquNotes", "修改备注", 100, 30, SubmitMethods));
  38. uC_QueryPage1.Init_QueryPage(30, true, true, "", GCList, LCIList, QueryPageDataMethodsms, RefreshRoleMethodsms, DoubleClikMethod, null, ClikMethod);
  39. CommonShow.ShowProcessing("正在处理中,请稍候...", this, (obj) =>
  40. {
  41. uC_QueryPage1.RefreshData(1, 0);
  42. }, null);
  43. }
  44. private PageData QueryPageDataMethodsms(int PageIndex, int PageSize)
  45. {
  46. string _SQLText = string.Format(@"select a.CODE,a.NAME,b.DBCODE,c.PLCCODE,d.NAME PLCNAME,d.IP from WCS_DEVICE a left join
  47. WCS_DEVICEPROTOCOL b on b.DEVICECODE=a.CODE
  48. left join WCS_DATABLOCK c on c.CODE=b.DBCODE
  49. left join WCS_PLC d on d.CODE=c.PLCCODE
  50. where DBCODE not like '%521%' and DBCODE not like '%523%' and DBCODE not like '%537%' AND a.CODE NOT like 'BCR%'");
  51. string _Orderby = "a.CODE asc";
  52. PageData pd = BaseWorkflow.QueryPageData(_SQLText, _Orderby, uC_QueryPage1.GetQueryWhere(), PageIndex, 3000);
  53. return pd;
  54. }
  55. private void SubmitMethods(string LCName)
  56. {
  57. if (LCName == "btn_QDB")
  58. {
  59. uC_QueryPage1.RefreshData();
  60. }
  61. else if (LCName == "btn_QClear")
  62. {
  63. uC_QueryPage1.ShowOpaqueLayer();
  64. uC_QueryPage1.ClearLCItemValue();
  65. uC_QueryPage1.RefreshData(1, 0);
  66. uC_QueryPage1.HideOpaqueLayer();
  67. }
  68. else if (LCName == "updateEquNotes")
  69. {
  70. DataTable dt = this.uC_QueryPage1.SCGrid_GetChkRows();
  71. if (dt == null || dt.Rows.Count == 0)
  72. {
  73. MessageUtil.ShowTips("请选择配置信息。");
  74. return;
  75. }
  76. var frmupdate = new Frm.MBtn_Monitor.FrmUpdateEquMsg(dt.Rows[0]);
  77. frmupdate.ShowDialog();
  78. uC_QueryPage1.RefreshData(1, 0);
  79. }
  80. }
  81. private void RefreshRoleMethodsms(bool ChkValue)
  82. {
  83. }
  84. private void DoubleClikMethod(DataRow dr)
  85. {
  86. Current.RefreshData();
  87. string code = dr["CODE"].ToString();
  88. //var pack = eqpData.deviceDataPack;
  89. //if (code.Contains("SRM"))
  90. //{
  91. //}
  92. //else if (code.Contains("BCR"))
  93. //{
  94. //}
  95. //else if (code.Contains("RGV"))
  96. //{
  97. //}
  98. //else
  99. //{
  100. //}
  101. FrmEquMsg_dtl Frm = new FrmEquMsg_dtl(code);
  102. Frm.Show();
  103. }
  104. private void ClikMethod(DataRow dr)
  105. {
  106. var pack = eqpData.deviceDataPack;
  107. if (pack is null)
  108. {
  109. MessageBox.Show("该设备无数据。");
  110. return;
  111. }
  112. TryCachHelper.TryExecute((db) =>
  113. {
  114. string equName = dr["CODE"].ToString();
  115. DataTable dt = null;
  116. if (pack.SCDatas.Datas.Any(p => p.Code == equName))
  117. {
  118. var rgvdata = pack.SCDatas;//堆垛机数据
  119. var plcItem = pack.SCDatas.Datas.Where(o => o.Code == equName).FirstOrDefault();
  120. if (plcItem == null)
  121. {
  122. MessageBox.Show("该设备无数据。");
  123. return;
  124. }
  125. dt = plcItem.GetAttributesDataTable();
  126. }
  127. else if (pack.RGVDatas.Datas.Any(p => p.Code == equName))
  128. {
  129. var rgvdata = pack.RGVDatas;//RGV数据
  130. var plcItem = pack.RGVDatas.Datas.Where(o => o.Code == equName).FirstOrDefault();
  131. if (plcItem == null)
  132. {
  133. MessageBox.Show("该设备无数据。");
  134. return;
  135. }
  136. dt = plcItem.GetAttributesDataTable();
  137. }
  138. else
  139. {
  140. if (pack.StationDatas.Datas.Any(p => p.Code == equName))
  141. {
  142. var convdata = pack.StationDatas;//输送机数据
  143. var plcItem = pack.StationDatas.Datas.Where(o => o.Code == equName).FirstOrDefault();
  144. if (plcItem == null)
  145. {
  146. MessageBox.Show("该设备无数据。");
  147. return;
  148. }
  149. dt = plcItem.GetAttributesDataTable();
  150. }
  151. }
  152. if (dt == null)
  153. return;
  154. string QeuMsg = null;
  155. for (int i = 0; i < dt.Rows.Count; i++)
  156. {
  157. for (int j = 1; j < dt.Columns.Count; j++)
  158. {
  159. if (j == 1)
  160. QeuMsg += "[" + dt.Rows[i][0].ToString() + "]" + "\r\n" + dt.Rows[i][j] + ":";
  161. else
  162. QeuMsg += dt.Rows[i][j];
  163. }
  164. QeuMsg += "\r\n";
  165. }
  166. textBox1.Text = QeuMsg;
  167. });
  168. //try
  169. //{
  170. //}
  171. //catch (Exception ex)
  172. //{
  173. // MessageUtil.ShowTips(ex.Message);
  174. //}
  175. }
  176. }
  177. }