BaseInfoPopup1.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.Client.Comm.Control;
  10. using Core.Mes.Client.Comm.Server;
  11. using Core.Mes.Client.Comm.Tool;
  12. using CoreFS.CA06;
  13. using Infragistics.Win.UltraWinGrid;
  14. namespace Core.StlMes.Client.YdmPipeManage
  15. {
  16. public partial class BaseInfoPopup1 : FrmBase
  17. {
  18. private DataTable _dt;
  19. private UltraGridRow _choicedRow;
  20. private string _whereColumn;
  21. public UltraGridRow ChoicedRow
  22. {
  23. get { return _choicedRow; }
  24. set { _choicedRow = value; }
  25. }
  26. public BaseInfoPopup1(DataTable dt, string whereColumn, params string[] hideColumns)
  27. {
  28. InitializeComponent();
  29. _dt = dt;
  30. ultraGrid1.DataSource = _dt.DefaultView;
  31. _whereColumn = whereColumn;
  32. labelTextBox1.Caption = dt.Columns[whereColumn].Caption;
  33. dt.Columns["GRADENAME"].Caption = "钢种";
  34. foreach (UltraGridColumn column in ultraGrid1.DisplayLayout.Bands[0].Columns)
  35. {
  36. if (hideColumns.Contains(column.Key))
  37. {
  38. ultraGrid1.DisplayLayout.Bands[0].Columns[column.Key].Hidden = true;
  39. }
  40. }
  41. ultraGrid1.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
  42. GridHelper.RefreshAndAutoSize(ultraGrid1);
  43. }
  44. private void Query()
  45. {
  46. string txt = labelTextBox1.Checked ? labelTextBox1.Text.Trim() : "";
  47. _dt.DefaultView.RowFilter = _whereColumn + " LIKE '%"+ txt +"%'";
  48. }
  49. private void Choice()
  50. {
  51. ultraGrid1.UpdateData();
  52. if (ultraGrid1.ActiveRow == null)
  53. {
  54. MessageUtil.ShowWarning("请选择一条记录!");
  55. return;
  56. }
  57. _choicedRow = ultraGrid1.ActiveRow;
  58. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  59. }
  60. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  61. {
  62. switch (e.Tool.Key)
  63. {
  64. case "查询":
  65. Query();
  66. break;
  67. case "确认选择":
  68. Choice();
  69. break;
  70. }
  71. }
  72. private void ultraGrid1_DoubleClickRow(object sender, Infragistics.Win.UltraWinGrid.DoubleClickRowEventArgs e)
  73. {
  74. Choice();
  75. }
  76. private void labelTextBox1_TextBox_KeyDown(object sender, KeyEventArgs e)
  77. {
  78. if (e.KeyData == Keys.Enter)
  79. {
  80. Query();
  81. }
  82. }
  83. }
  84. }