frmRptPlineJudgeAll.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. using Infragistics.Win;
  15. using System.Net;
  16. using System.Collections;
  17. using CoreFS.SA06;
  18. namespace Core.StlMes.Client.BuyBillet
  19. {
  20. public partial class frmRptPlineJudgeAll : FrmBase
  21. {
  22. private UltraGrid[] ugs ;
  23. public frmRptPlineJudgeAll()
  24. {
  25. InitializeComponent();
  26. ugs = new UltraGrid[] { ug1,ug2,ug3,ug4,ug5,ug6,ug7,ug8,ug9,ug10,ug11,ug12 };
  27. foreach (UltraGrid ug in ugs)
  28. {
  29. ug.InitializeLayout += ug_InitializeLayout;
  30. }
  31. }
  32. void ug_InitializeLayout(object sender, InitializeLayoutEventArgs e)
  33. {
  34. e.Layout.Override.CellAppearance.TextHAlign = HAlign.Right;
  35. e.Layout.Bands[0].Columns["RPT_YM"].CellAppearance.TextHAlign = HAlign.Left;
  36. e.Layout.Bands[0].Columns["DEPARTMENT_DESC_P"].CellAppearance.TextHAlign = HAlign.Left;
  37. e.Layout.Bands[0].Columns["PLINE_NAME"].CellAppearance.TextHAlign = HAlign.Left;
  38. e.Layout.Bands[0].Columns["CCL"].CellAppearance.TextHAlign = HAlign.Left;
  39. e.Layout.Bands[0].Columns["ZYL"].CellAppearance.TextHAlign = HAlign.Left;
  40. e.Layout.Bands[0].Columns["YCHGRATE"].CellAppearance.TextHAlign = HAlign.Left;
  41. foreach (var col in e.Layout.Bands[0].Columns)
  42. {
  43. if (col.Key.ToUpper() == "RPT_YM" || col.Key.ToUpper() == "DEPARTMENT_DESC_P" ||
  44. col.Key.ToUpper() == "PLINE_NAME" || col.Key.ToUpper() == "CCL" ||
  45. col.Key.ToUpper() == "ZYL" || col.Key.ToUpper() == "YCHGRATE")
  46. {
  47. }
  48. else
  49. {
  50. col.MaskDisplayMode = Infragistics.Win.UltraWinMaskedEdit.MaskMode.IncludeLiterals;
  51. col.MaskInput = "{LOC}-nn,nnn,nnn.nnn";
  52. }
  53. }
  54. }
  55. private void frmRptPlineJudgeAll_Load(object sender, EventArgs e)
  56. {
  57. HideTabs();
  58. }
  59. private void HideTabs()
  60. {
  61. //首先判断年份
  62. int selectedYear = int.Parse(cb_year.Text);
  63. //如果大于当前年份 则隐藏tab控件
  64. if (selectedYear > DateTime.Now.Year)
  65. {
  66. tabC.Visible = false;
  67. }
  68. //如果是当前年份则,当前月份被选中
  69. if (selectedYear == DateTime.Now.Year)
  70. {
  71. int month = DateTime.Now.Month;
  72. for (int i = 11; i > month - 1; i--)
  73. {
  74. tabC.Tabs[i].Visible = false;
  75. }
  76. tabC.Tabs[month - 1].Selected = true;
  77. }
  78. //小于当前年份,则默认1月份被选中
  79. if (selectedYear < DateTime.Now.Year)
  80. {
  81. tabC.Tabs[0].Selected = true;
  82. }
  83. }
  84. private void InitialTabs()
  85. {
  86. tabC.Visible = true;
  87. int count = tabC.Tabs.Count;
  88. for (int i = 0; i < count; i++)
  89. {
  90. tabC.Tabs[i].Visible = true;
  91. }
  92. }
  93. public override void ToolBar_Click(object sender, string ToolbarKey)
  94. {
  95. base.ToolBar_Click(sender, ToolbarKey);
  96. switch (ToolbarKey)
  97. {
  98. case "Query":
  99. Query();
  100. break;
  101. case "Export":
  102. Export();
  103. break;
  104. case "Close":
  105. this.Close();
  106. break;
  107. }
  108. }
  109. private void Export()
  110. {
  111. int month =tabC.SelectedTab.Index+1;
  112. string strmonth = month <10 ?"0"+month.ToString():month.ToString();
  113. string yearMonth = cb_year.Text + strmonth;
  114. UltraGrid ug = ugs[month-1];
  115. if (ug.Rows.Count == 0)
  116. {
  117. MessageUtil.ShowWarning("查询数据为空,无法导出!");
  118. }
  119. else
  120. {
  121. GridHelper.ulGridToExcel(ug, yearMonth+"产量判定数据");
  122. }
  123. }
  124. private void Query()
  125. {
  126. int month =tabC.SelectedTab.Index+1;
  127. string strmonth = month <10 ?"0"+month.ToString():month.ToString();
  128. string yearMonth = cb_year.Text + strmonth;
  129. DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_Rpt_Pline_Judge_All", new object[] { yearMonth }, this.ob);
  130. UltraGrid ug = ugs[month-1];
  131. ug.DataSource = dt;
  132. ug.DisplayLayout.Bands[0].Columns["RPT_YM"].CellAppearance.BackColor = Color.Gray;
  133. ug.DisplayLayout.Bands[0].Columns["RPT_YM"].MergedCellStyle = MergedCellStyle.Always;
  134. ug.DisplayLayout.Bands[0].Columns["DEPARTMENT_DESC_P"].MergedCellStyle = MergedCellStyle.Always;
  135. }
  136. private void cb_year_SelectionChanged(object sender, EventArgs e)
  137. {
  138. //Tabs 控件初始化
  139. InitialTabs();
  140. HideTabs();
  141. }
  142. }
  143. }