FrmReportDefault.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Windows.Forms;
  7. using com.steering.mes.mcp.entity;
  8. using Core.Mes.Client.Comm.Format;
  9. using Core.Mes.Client.Comm.Server;
  10. using Core.Mes.Client.Comm.Tool;
  11. using Core.StlMes.Client.Mcp.Control.Common;
  12. using Core.StlMes.Client.Mcp.Control.Entity;
  13. using CoreFS.CA06;
  14. using Infragistics.Win.UltraWinGrid;
  15. namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment
  16. {
  17. public partial class FrmReportDefault : FrmBase
  18. {
  19. public FrmReportDefault()
  20. {
  21. InitializeComponent();
  22. uceMachineNo.SelectedIndex = 0;
  23. }
  24. protected override void OnLoad(EventArgs e)
  25. {
  26. base.OnLoad(e);
  27. string[] plineCodes = comm.InitDropPlinePower(CustomInfo, ucePlinCode, ValidDataPurviewIds, ob);
  28. if (plineCodes.Length <= 0)
  29. {
  30. MessageBox.Show("无数据权限");
  31. this.Close();
  32. }
  33. commonCrackDetection1.Init(ob,null);
  34. ucePlinCode.SelectedIndex = 0;
  35. ucReportNo.SelectedIndex = 0;
  36. EntityHelper.ShowGridCaption<HttReportDefaultEntity>(ugDefault.DisplayLayout.Bands[0]);
  37. DataTable dt1 = ServerHelper.GetData(
  38. "com.steering.mes.mcp.heatTreatment.FrmReportDefault.getReportColumns",
  39. new object[] { }, ob);
  40. var dt =
  41. ServerHelper.GetData(
  42. "com.steering.mes.mcp.collarMaterial.ComBaseInfo.getBaseInfo",
  43. new object[] { "4097" }, ob);
  44. if (dt != null && dt.Rows.Count > 0 && dt1!=null)
  45. {
  46. foreach (DataRow row in dt.Rows)
  47. {
  48. DataRow datarow = dt1.NewRow();
  49. datarow[0] = "PROBE_QTY_" + row["BASECODE"];
  50. datarow[1] = "[" + row["BASENAME"] + "]探头个数";
  51. dt1.Rows.Add(datarow);
  52. DataRow datarow1 = dt1.NewRow();
  53. datarow1[0] = "PROBE_PARAMETERS_" + row["BASECODE"];
  54. datarow1[1] = "[" + row["BASENAME"] + "]探头参数";
  55. dt1.Rows.Add(datarow1);
  56. }
  57. }
  58. cmbReportColumn.DataSource = dt1;
  59. cmbReportColumn.DisplayMember = "COMMENTS";
  60. cmbReportColumn.ValueMember = "COLUMN_NAME";
  61. }
  62. public override void ToolBar_Click(object sender, string ToolbarKey)
  63. {
  64. //base.ToolBar_Click(sender, ToolbarKey);
  65. switch (ToolbarKey)
  66. {
  67. case "DoQuery":
  68. Query();
  69. break;
  70. case "DoSave":
  71. DoSave();
  72. break;
  73. case "DoDelete":
  74. DoReturn();
  75. break;
  76. case "DoUpdate":
  77. DoUpdate();
  78. break;
  79. case "DoClose":
  80. Close();
  81. break;
  82. case "Copy":
  83. Copy();
  84. break;
  85. }
  86. }
  87. private void Copy()
  88. {
  89. var matfrm = new FrmReportDefaultCopy(ob, ucePlinCode.SelectedItem.DataValue.ToString(), ucReportNo.SelectedItem.DataValue.ToString2(), uceMachineNo.SelectedItem.DataValue.ToString2());
  90. matfrm.ShowDialog();
  91. if (matfrm.DialogResult == DialogResult.OK)
  92. {
  93. Query();
  94. }
  95. }
  96. private void DoUpdate()
  97. {
  98. List<HttReportDefaultEntity> list = httReportDefaultEntityBindingSource.DataSource as List<HttReportDefaultEntity>;
  99. if (list == null || !list.Any()) return;
  100. list = list.Where(p => p.Chk && !p.isNew).ToList();
  101. if (!list.Any())
  102. {
  103. MessageBox.Show("请选择需要修改的行");
  104. return;
  105. }
  106. var ccp = new CoreClientParam();
  107. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FrmReportDefault";
  108. ccp.MethodName = "UpdateDefault";
  109. ccp.ServerParams = new object[]
  110. {
  111. list.Select(JSONFormat.Format).ToList()
  112. };
  113. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  114. if (ccp.ReturnCode != -1)
  115. {
  116. MessageUtil.ShowTips(ccp.ReturnInfo);
  117. if (ccp.ReturnInfo.Equals("修改成功!"))
  118. {
  119. Query();
  120. }
  121. }
  122. }
  123. private void DoReturn()
  124. {
  125. List<HttReportDefaultEntity> list = httReportDefaultEntityBindingSource.DataSource as List<HttReportDefaultEntity>;
  126. if (list == null || !list.Any()) return;
  127. list = list.Where(p => p.Chk && !p.isNew).ToList();
  128. if (!list.Any())
  129. {
  130. MessageBox.Show("请选择需要删除的行");
  131. return;
  132. }
  133. var ccp = new CoreClientParam();
  134. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FrmReportDefault";
  135. ccp.MethodName = "DeleteDefault";
  136. ccp.ServerParams = new object[]
  137. {
  138. list.Select(JSONFormat.Format).ToList()
  139. };
  140. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  141. if (ccp.ReturnCode != -1)
  142. {
  143. MessageUtil.ShowTips(ccp.ReturnInfo);
  144. if (ccp.ReturnInfo.Equals("删除成功!"))
  145. {
  146. Query();
  147. }
  148. }
  149. }
  150. private void DoSave()
  151. {
  152. List<HttReportDefaultEntity> list = httReportDefaultEntityBindingSource.DataSource as List<HttReportDefaultEntity>;
  153. if (list == null || !list.Any()) return;
  154. list = list.Where(p => p.Chk && p.isNew).ToList();
  155. if (!list.Any())
  156. {
  157. MessageBox.Show("请选择需要新增的行");
  158. return;
  159. }
  160. var ccp = new CoreClientParam();
  161. ccp.ServerName = "com.steering.mes.mcp.heatTreatment.FrmReportDefault";
  162. ccp.MethodName = "AddDefault";
  163. ccp.ServerParams = new object[]
  164. {
  165. list.Select(JSONFormat.Format).ToList()
  166. };
  167. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  168. if (ccp.ReturnCode != -1)
  169. {
  170. MessageUtil.ShowTips(ccp.ReturnInfo);
  171. if (ccp.ReturnInfo.Equals("新增成功!"))
  172. {
  173. Query();
  174. }
  175. }
  176. }
  177. private void Query()
  178. {
  179. List<HttReportDefaultEntity> list = EntityHelper.GetData<HttReportDefaultEntity>(
  180. "com.steering.mes.mcp.heatTreatment.FrmReportDefault.Query",
  181. new object[] { ucePlinCode.SelectedItem.DataValue.ToString(), ucReportNo.SelectedItem.DataValue.ToString2(), uceMachineNo.SelectedItem.DataValue.ToString2()}, ob);
  182. httReportDefaultEntityBindingSource.DataSource = list;
  183. commonCrackDetection1.SettingModeValue(list, ucePlinCode.SelectedItem.DataValue.ToString());
  184. commHelper.RefreshAndAutoSize(ugDefault);
  185. }
  186. private void ugDefault_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  187. {
  188. try
  189. {
  190. ugDefault.UpdateData();
  191. HttReportDefaultEntity HttReportDefaultEntity = e.Cell.Row.ListObject as HttReportDefaultEntity;
  192. commonCrackDetection1.SetValue(HttReportDefaultEntity.ReportNo, HttReportDefaultEntity,e.Cell.Column.Key);
  193. if (e.Cell.Column.Key != "Chk")
  194. HttReportDefaultEntity.Chk = true;
  195. }
  196. catch (Exception)
  197. {
  198. }
  199. }
  200. private void utProbe_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  201. {
  202. TextEdit TextEdit = new TextEdit() {data = ugDefault.ActiveCell.Text};
  203. TextEdit.ShowDialog();
  204. if (TextEdit.DialogResult == DialogResult.OK)
  205. {
  206. ugDefault.ActiveCell.Value = TextEdit.data;
  207. ugDefault_CellChange(null, new CellEventArgs(ugDefault.ActiveCell));
  208. }
  209. }
  210. private void egbView_ExpandedStateChanged(object sender, EventArgs e)
  211. {
  212. }
  213. private void utUsed_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  214. {
  215. HttReportDefaultEntity HttReportDefaultEntity = ugDefault.ActiveRow.ListObject as HttReportDefaultEntity;
  216. if(HttReportDefaultEntity==null) return;
  217. SelectEdit SelectEdit = new SelectEdit(ob,
  218. HttReportDefaultEntity.ReportColumn == "PROBE_NAME" ||
  219. HttReportDefaultEntity.ReportColumn == "STANDARD_NAME",
  220. HttReportDefaultEntity.ReportColumn == "PROBE_NAME"?"4097": HttReportDefaultEntity.ReportColumn == "STANDARD_NAME"? "4021":HttReportDefaultEntity.DroplistDefult, HttReportDefaultEntity.DroplistUsed.Split(';').ToList());
  221. SelectEdit.ShowDialog();
  222. if (SelectEdit.DialogResult == DialogResult.OK)
  223. {
  224. ugDefault.ActiveCell.Value = SelectEdit.Codes;
  225. ugDefault_CellChange(null, new CellEventArgs(ugDefault.ActiveCell));
  226. }
  227. }
  228. private void ugDefault_AfterRowInsert(object sender, RowEventArgs e)
  229. {
  230. e.Row.Cells["isNew"].Value = true;
  231. e.Row.Appearance.BackColor = Color.LightGreen;
  232. e.Row.Cells["PlineCode"].Value = ucePlinCode.SelectedItem.DataValue;
  233. e.Row.Cells["ReportNo"].Value = ucReportNo.SelectedItem.DataValue.ToString2();
  234. e.Row.Cells["ReportNo"].Activation = Activation.AllowEdit;
  235. e.Row.Cells["ReportNo"].IgnoreRowColActivation = true;
  236. e.Row.Cells["ReportColumn"].Activation = Activation.AllowEdit;
  237. e.Row.Cells["ReportColumn"].IgnoreRowColActivation = true;
  238. e.Row.Cells["MachineNo"].Value = uceMachineNo.SelectedItem.DataValue.ToString();
  239. }
  240. }
  241. }