ctrlOrderLineDesign.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Server;
  11. using System.Diagnostics;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Infragistics.Win.UltraWinGrid;
  14. using System.Collections;
  15. using Core.Mes.Client.Comm.Control;
  16. namespace Core.StlMes.Client.SaleOrder.Control
  17. {
  18. public partial class ctrlOrderLineDesign : UserControl
  19. {
  20. private DataTable designDt;
  21. public DataTable DesignDt
  22. {
  23. get { return designDt; }
  24. set { designDt = value; }
  25. }
  26. private DataTable designDtNPass;
  27. public DataTable DesignDtNPass
  28. {
  29. get { return designDtNPass; }
  30. set { designDtNPass = value; }
  31. }
  32. public ctrlOrderLineDesign()
  33. {
  34. InitializeComponent();
  35. }
  36. private void ctrlOrderLineDesign_Load(object sender, EventArgs e)
  37. {
  38. }
  39. /// <summary>
  40. /// 绑定设计状态表数据源。
  41. /// </summary>
  42. public void binUltraGrid()
  43. {
  44. if (designDt.Rows.Count > 0)
  45. {
  46. //为UltraGrid控件绑定数据源。
  47. DataSet ds = new DataSet();
  48. ds.Tables.Add(designDt);
  49. ultraGirdDelivery.DataSource = ds;
  50. ultraGirdDelivery.DataBind();
  51. //隐藏设计状态明细列。
  52. for (int i = 1; i < ultraGirdDelivery.DisplayLayout.Bands[0].Columns.Count; i++)
  53. {
  54. //i=0,是设计状态主信息,因此从1开始。单项展示,双项隐藏。
  55. if (i % 2 == 0)
  56. {
  57. ultraGirdDelivery.DisplayLayout.Bands[0].Columns[i].Hidden = true;
  58. }
  59. else
  60. {
  61. //单项展示,同时为单项指定ToolTipText为他下一列的Text,设计状态明细。
  62. if (i + 1 < ultraGirdDelivery.Rows[1].Cells.Count)
  63. {
  64. ultraGirdDelivery.Rows[1].Cells[i].ToolTipText = ultraGirdDelivery.Rows[1].Cells[i + 1].Text.ToString();
  65. }
  66. }
  67. }
  68. //隐藏列头,动态构建UltraGrid,因此第一行就是列头。
  69. ultraGirdDelivery.DisplayLayout.Bands[0].ColHeadersVisible = false;
  70. //列自适应
  71. GridHelper.RefreshAndAutoSizeExceptRows(ultraGirdDelivery, new UltraGridColumn[] {
  72. //ultraGridDesignStd.DisplayLayout.Bands[0].Columns["CHK"]
  73. });
  74. //第一列合并
  75. //ultraGirdDelivery.DisplayLayout.Bands[0].Columns["columns"].MergedCellStyle = MergedCellStyle.Always;
  76. if (ultraGirdDelivery.Rows.Count >= 2)
  77. {
  78. ultraGirdDelivery.Rows[0].Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
  79. }
  80. }
  81. }
  82. /// <summary>
  83. /// 不通过项目数据源绑定。
  84. /// </summary>
  85. public void binUltraGridNPass()
  86. {
  87. if (designDtNPass.Rows.Count > 0)
  88. {
  89. DataSet ds = new DataSet();
  90. ds.Tables.Add(designDtNPass);
  91. ultraGridD.DataSource = ds;
  92. ultraGridD.DataBind();
  93. for (int i = 1; i < ultraGridD.DisplayLayout.Bands[0].Columns.Count; i++)
  94. {
  95. //项目名称转变为button。
  96. ultraGridD.DisplayLayout.Rows[0].Cells[i].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button;
  97. ultraGridD.DisplayLayout.Rows[0].Cells[i].Column.ButtonDisplayStyle = ButtonDisplayStyle.Always;
  98. //Tag存储下一行的Text值,也就是管理科室名称。
  99. ultraGridD.DisplayLayout.Rows[0].Cells[i].Tag = ultraGridD.DisplayLayout.Rows[2].Cells[i].Text.ToString();
  100. }
  101. ultraGridD.DisplayLayout.Rows[2].Hidden = true;
  102. //列头隐藏,第1行即为列头。
  103. ultraGridD.DisplayLayout.Bands[0].ColHeadersVisible = false;
  104. //列自适应
  105. //GridHelper.RefreshAndAutoSizeExceptRows(ultraGridD, new UltraGridColumn[] {
  106. // //ultraGridDesignStd.DisplayLayout.Bands[0].Columns["CHK"]
  107. //});
  108. //第一列合并
  109. //ultraGridD.DisplayLayout.Bands[0].Columns["columns"].MergedCellStyle = MergedCellStyle.Always;
  110. if (ultraGridD.Rows.Count >= 2)
  111. {
  112. ultraGridD.Rows[0].Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
  113. }
  114. }
  115. }
  116. private void ultraGridD_ClickCellButton(object sender, CellEventArgs e)
  117. {
  118. //ultraGridD.ActiveCell.Text
  119. //string[] design_Obj = e.Cell.Tag.ToString().Split('|');
  120. //string key = abc[0];
  121. //现在除了失败原因和管理科室,还需要传入钢种。
  122. DesignCellText(e.Cell.Text, e.Cell.Tag.ToString());
  123. //for (int i = 0; i < ultraGridD.DisplayLayout.Bands[0].Columns; i++ )
  124. //{
  125. // if (e.Cell.Column.Key == ultraGridD.DisplayLayout.Bands[0].Columns[i].Key)
  126. // {
  127. // if (e.Cell.Row.Cells.Count > i + 1)
  128. // {
  129. // UltraGridCell cell = e.Cell.Row.Cells[i + 1];
  130. // }
  131. // }
  132. //}
  133. //ultraGirdDelivery.Rows[1].Cells[i].ToolTipText = ultraGirdDelivery.Rows[1].Cells[i + 1].Text.ToString();
  134. }
  135. public delegate void HDesignCellText(string lstItem, string designObj);
  136. public event HDesignCellText DesignCellText;
  137. //private void ctrlOrderLineDesign_Load(object sender, EventArgs e)
  138. //{
  139. // //if (designDt.Rows.Count > 0)
  140. // //{
  141. // // ultraGirdDelivery.DataSource = designDt;
  142. // // ultraGirdDelivery.DataBind();
  143. // //}
  144. //}
  145. }
  146. }