FrmJGONLINE.cs 2.7 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 CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Server;
  11. using Core.Mes.Client.Comm.Control;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Infragistics.Win.UltraWinGrid;
  14. namespace Core.StlMes.Client.BuyBillet
  15. {
  16. public partial class FrmJGONLINE : FrmBase
  17. {
  18. public FrmJGONLINE()
  19. {
  20. InitializeComponent();
  21. }
  22. private void FrmJGONLINE_Load(object sender, EventArgs e)
  23. {
  24. ug.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
  25. doQuery();
  26. }
  27. public override void ToolBar_Click(object sender, string ToolbarKey)
  28. {
  29. base.ToolBar_Click(sender, ToolbarKey);
  30. switch (ToolbarKey)
  31. {
  32. case "Close":
  33. this.Close();
  34. break;
  35. case "doQuery":
  36. doQuery();
  37. break;
  38. case "doExcel":
  39. Export();
  40. break;
  41. }
  42. }
  43. private void ug_bind()
  44. {
  45. DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_Rpt_JG_ONLINE", new object[] { }, this.ob);
  46. DataTable dt1 = ds.Tables[0];
  47. GridHelper.CopyDataToDatatable(dt, dt1, true);
  48. RefreshAndAutoSize(ug);
  49. }
  50. private void doQuery()
  51. {
  52. ug_bind();
  53. }
  54. /// <summary>
  55. /// 刷新Grid数据并根据数据调整Grid列宽
  56. /// </summary>
  57. /// <param name="ultraGrid">需要处理的Grid</param>
  58. public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid)
  59. {
  60. try
  61. {
  62. ultraGrid.DataBind();
  63. foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
  64. {
  65. foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
  66. {
  67. column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
  68. }
  69. }
  70. ultraGrid.Refresh();
  71. }
  72. catch { }
  73. }
  74. private void Export()
  75. {
  76. if (ug.Rows.Count == 0)
  77. {
  78. MessageUtil.ShowWarning("查询数据为空,无法导出!");
  79. }
  80. else
  81. {
  82. GridHelper.ulGridToExcel(ug, "接箍在线");
  83. }
  84. }
  85. }
  86. }