BaseInfoPopup.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.ZGMil.Common
  15. {
  16. public partial class BaseInfoPopup : 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 BaseInfoPopup(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. foreach (UltraGridColumn column in ultraGrid1.DisplayLayout.Bands[0].Columns)
  34. {
  35. if (hideColumns.Contains(column.Key))
  36. {
  37. ultraGrid1.DisplayLayout.Bands[0].Columns[column.Key].Hidden = true;
  38. }
  39. }
  40. ultraGrid1.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;
  41. //GridHelper.RefreshAndAutoSize(ultraGrid1);
  42. }
  43. private void Query()
  44. {
  45. string txt = labelTextBox1.Checked ? labelTextBox1.Text.Trim() : "";
  46. _dt.DefaultView.RowFilter = _whereColumn + " LIKE '%"+ txt +"%'";
  47. }
  48. private void Choice()
  49. {
  50. ultraGrid1.UpdateData();
  51. if (ultraGrid1.ActiveRow == null)
  52. {
  53. MessageUtil.ShowWarning("请选择一条记录!");
  54. return;
  55. }
  56. _choicedRow = ultraGrid1.ActiveRow;
  57. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  58. }
  59. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  60. {
  61. switch (e.Tool.Key)
  62. {
  63. case "查询":
  64. Query();
  65. break;
  66. case "确认选择":
  67. Choice();
  68. break;
  69. }
  70. }
  71. private void ultraGrid1_DoubleClickRow(object sender, Infragistics.Win.UltraWinGrid.DoubleClickRowEventArgs e)
  72. {
  73. Choice();
  74. }
  75. private void labelTextBox1_TextBox_KeyDown(object sender, KeyEventArgs e)
  76. {
  77. if (e.KeyData == Keys.Enter)
  78. {
  79. Query();
  80. }
  81. }
  82. }
  83. }