frmRptDaySCKB.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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.Threading;
  16. using System.Net;
  17. using System.Collections;
  18. using CoreFS.SA06;
  19. namespace Core.StlMes.Client.BuyBillet
  20. {
  21. public partial class frmRptDaySCKB : FrmBase
  22. {
  23. public frmRptDaySCKB()
  24. {
  25. InitializeComponent();
  26. this.updator = new UpdateProgress(UIUpdateProgress);
  27. }
  28. private void frmRptDaySCKB_Load(object sender, EventArgs e)
  29. {
  30. //this.startDate.Value = DateTime.Now.AddDays(-7);
  31. //this.endDate.Value = DateTime.Now;
  32. this.startDate.Value = this.endDate.Value.AddDays(-6);
  33. ultraExpandableGroupBox1.Expanded = false;
  34. ForbidSort(ug);
  35. ForbidSort1(ug1);
  36. }
  37. public override void ToolBar_Click(object sender, string ToolbarKey)
  38. {
  39. base.ToolBar_Click(sender, ToolbarKey);
  40. switch (ToolbarKey)
  41. {
  42. case "Query":
  43. Query();
  44. break;
  45. case "Export":
  46. Export();
  47. break;
  48. case "ExportDetails":
  49. ExportDetails();
  50. break;
  51. case "Close":
  52. this.Close();
  53. break;
  54. }
  55. }
  56. private void Query()
  57. {
  58. int flag = DateTime.Compare(this.startDate.Value, this.endDate.Value);
  59. string startDate = this.startDate.Value.ToString("yyyyMMdd");
  60. string endDate = this.endDate.Value.ToString("yyyyMMdd");
  61. if (Convert.ToInt32(startDate) > Convert.ToInt32(endDate))
  62. {
  63. MessageUtil.ShowWarning("起始日期不能大于截止日期!");
  64. return;
  65. }
  66. string selectedDay = this.endDate.Value.ToString("yyyyMMdd");
  67. //TimeSpan sp = this.endDate.Value.Subtract(this.startDate.Value);
  68. //int days = sp.Days;
  69. //System.DateTime f = this.startDate.Value;
  70. //System.DateTime g = this.endDate.Value;
  71. //System.TimeSpan diff = g.Subtract(f);
  72. //int days = diff.Days;
  73. DateTime d1 = this.startDate.Value;
  74. DateTime d2 = this.endDate.Value;
  75. DateTime d3 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d1.Year, d1.Month, d1.Day));
  76. DateTime d4 = Convert.ToDateTime(string.Format("{0}-{1}-{2}", d2.Year, d2.Month, d2.Day));
  77. int days = (d4 - d3).Days;
  78. DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_Rpt_DaySCKB", new object[] { startDate,endDate,days }, this.ob);
  79. DataTable dt3 = ds.Tables[0];
  80. GridHelper.CopyDataToDatatable(dt, dt3, true);
  81. //if(dt.Columns.Contains("PLINEORDER")){
  82. //dt.Columns["PLINEORDER"].ColumnMapping = MappingType.Hidden;
  83. //}
  84. ug.DisplayLayout.Bands[0].Columns["DEPT"].CellAppearance.BackColor = Color.Wheat;
  85. ug.DisplayLayout.Bands[0].Columns["DEPT"].MergedCellStyle = MergedCellStyle.Always;
  86. //ug.DisplayLayout.Bands[0].Columns["DEPARTMENT_DESC_P"].MergedCellStyle = MergedCellStyle.Always;
  87. ug.DisplayLayout.Bands[0].Columns["DEPT"].CellAppearance.TextHAlign = HAlign.Center;
  88. ug.DisplayLayout.Bands[0].Columns["DEPT"].MinWidth = 100;
  89. ug.DisplayLayout.Bands[0].Columns["DAYZYL"].CellAppearance.TextHAlign = HAlign.Right;
  90. ug.DisplayLayout.Bands[0].Columns["YXNB"].CellAppearance.TextHAlign = HAlign.Right;
  91. ug.DisplayLayout.Bands[0].Columns["YXZH"].CellAppearance.TextHAlign = HAlign.Right;
  92. ug.DisplayLayout.Bands[0].Columns["DAYZYLDAY"].CellAppearance.TextHAlign = HAlign.Right;
  93. ug.DisplayLayout.Bands[0].Columns["YXNBDAY"].CellAppearance.TextHAlign = HAlign.Right;
  94. ug.DisplayLayout.Bands[0].Columns["YXZHDAY"].CellAppearance.TextHAlign = HAlign.Right;
  95. ug.DisplayLayout.Bands[0].Columns["PLINECODE"].Hidden = true;
  96. //ug.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.VisibleRows);
  97. //ug.DisplayLayout.AutoFitStyle = AutoFitStyle.ResizeAllColumns;
  98. ug.DisplayLayout.Bands[0].Columns["DEPT"].PerformAutoResize();
  99. UltraGridBand band = this.ug.DisplayLayout.Bands[0];
  100. foreach (UltraGridRow row in band.GetRowEnumerator(GridRowType.DataRow))
  101. {
  102. if (row.Cells["PLINENAME"].Value.ToString() == "合计" ||
  103. row.Cells["PLINENAME"].Value.ToString() == "管加工热处理(炉)合计" ||
  104. row.Cells["PLINENAME"].Value.ToString() == "管加工热处理(探伤)合计" ||
  105. row.Cells["PLINENAME"].Value.ToString() == "管加工加工线合计")
  106. {
  107. Color cellColor = Color.Yellow;
  108. row.Cells["PLINENAME"].Appearance.BackColor = cellColor;
  109. row.Cells["ZCNB"].Appearance.BackColor = cellColor;
  110. row.Cells["ZCWB"].Appearance.BackColor = cellColor;
  111. row.Cells["YCNB"].Appearance.BackColor = cellColor;
  112. row.Cells["YCWB"].Appearance.BackColor = cellColor;
  113. row.Cells["TJTIMETOTAL"].Appearance.BackColor = cellColor;
  114. row.Cells["YXNB"].Appearance.BackColor = cellColor;
  115. row.Cells["YXZH"].Appearance.BackColor = cellColor;
  116. row.Cells["DAYZYL"].Appearance.BackColor = cellColor;
  117. row.Cells["ZCNBDAY"].Appearance.BackColor = cellColor;
  118. row.Cells["ZCWBDAY"].Appearance.BackColor = cellColor;
  119. row.Cells["YCNBDAY"].Appearance.BackColor = cellColor;
  120. row.Cells["YCWBDAY"].Appearance.BackColor = cellColor;
  121. row.Cells["TJTIMETOTALDAY"].Appearance.BackColor = cellColor;
  122. row.Cells["YXNBDAY"].Appearance.BackColor = cellColor;
  123. row.Cells["YXZHDAY"].Appearance.BackColor = cellColor;
  124. row.Cells["DAYZYLDAY"].Appearance.BackColor = cellColor;
  125. }
  126. if (row.Cells["PLINENAME"].Value.ToString() == "本部热处理(炉)合计" ||
  127. row.Cells["PLINENAME"].Value.ToString() == "元通热处理(炉)合计" ||
  128. row.Cells["PLINENAME"].Value.ToString() == "深加工热处理(炉)合计" ||
  129. row.Cells["PLINENAME"].Value.ToString() == "本部热处理(探伤)合计" ||
  130. row.Cells["PLINENAME"].Value.ToString() == "元通热处理(探伤)合计" ||
  131. row.Cells["PLINENAME"].Value.ToString() == "深加工热处理(探伤)合计" ||
  132. row.Cells["PLINENAME"].Value.ToString() == "本部加工线合计" ||
  133. row.Cells["PLINENAME"].Value.ToString() == "元通加工线合计" ||
  134. row.Cells["PLINENAME"].Value.ToString() == "深加工加工线合计"
  135. )
  136. {
  137. Color cellColor = Color.SkyBlue;
  138. row.Cells["PLINENAME"].Appearance.BackColor = cellColor;
  139. row.Cells["ZCNB"].Appearance.BackColor = cellColor;
  140. row.Cells["ZCWB"].Appearance.BackColor = cellColor;
  141. row.Cells["YCNB"].Appearance.BackColor = cellColor;
  142. row.Cells["YCWB"].Appearance.BackColor = cellColor;
  143. row.Cells["TJTIMETOTAL"].Appearance.BackColor = cellColor;
  144. row.Cells["YXNB"].Appearance.BackColor = cellColor;
  145. row.Cells["YXZH"].Appearance.BackColor = cellColor;
  146. row.Cells["DAYZYL"].Appearance.BackColor = cellColor;
  147. row.Cells["ZCNBDAY"].Appearance.BackColor = cellColor;
  148. row.Cells["ZCWBDAY"].Appearance.BackColor = cellColor;
  149. row.Cells["YCNBDAY"].Appearance.BackColor = cellColor;
  150. row.Cells["YCWBDAY"].Appearance.BackColor = cellColor;
  151. row.Cells["TJTIMETOTALDAY"].Appearance.BackColor = cellColor;
  152. row.Cells["YXNBDAY"].Appearance.BackColor = cellColor;
  153. row.Cells["YXZHDAY"].Appearance.BackColor = cellColor;
  154. row.Cells["DAYZYLDAY"].Appearance.BackColor = cellColor;
  155. }
  156. }
  157. foreach (var col in ug.DisplayLayout.Bands[0].Columns)
  158. {
  159. col.CellAppearance.TextHAlign = HAlign.Right;
  160. }
  161. ug.DisplayLayout.Bands[0].Columns["DEPT"].CellAppearance.TextHAlign = HAlign.Left;
  162. ug.DisplayLayout.Bands[0].Columns["PLINENAME"].CellAppearance.TextHAlign = HAlign.Left;
  163. }
  164. private void Export()
  165. {
  166. if (ug.Rows.Count == 0)
  167. {
  168. MessageUtil.ShowWarning("查询数据为空,无法导出!");
  169. }
  170. else
  171. {
  172. GridHelper.ulGridToExcel(ug, "日生产运行快报");
  173. }
  174. }
  175. private void ExportDetails()
  176. {
  177. if (ug1.Rows.Count == 0)
  178. {
  179. MessageUtil.ShowWarning("查询数据为空,无法导出!");
  180. }
  181. else
  182. {
  183. GridHelper.ulGridToExcel(ug1, "停机详情");
  184. }
  185. }
  186. /// <summary>
  187. /// 禁止排序及筛选
  188. /// </summary>
  189. /// <param name="ugr"></param>
  190. public void ForbidSort(UltraGrid ugr)
  191. {
  192. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  193. {
  194. ugc.SortIndicator = SortIndicator.Disabled;
  195. ugc.AllowRowFiltering = DefaultableBoolean.False;
  196. }
  197. }
  198. /// <summary>
  199. /// 禁止排序
  200. /// </summary>
  201. /// <param name="ugr"></param>
  202. public void ForbidSort1(UltraGrid ugr)
  203. {
  204. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  205. {
  206. ugc.SortIndicator = SortIndicator.Disabled;
  207. //ugc.AllowRowFiltering = DefaultableBoolean.False;
  208. }
  209. }
  210. private void ug_ClickCell(object sender, ClickCellEventArgs e)
  211. {
  212. e.Cell.Selected = true;
  213. string plinecode = e.Cell.Row.Cells["PLINECODE"].Value.ToString();
  214. if (string.IsNullOrEmpty(plinecode))
  215. {
  216. //ug1.DataSource;
  217. ThreadPool.QueueUserWorkItem(new WaitCallback(DoInBackgroundThread));
  218. return;
  219. }
  220. string date = endDate.Value.ToString("yyyyMMdd");
  221. string date1 = startDate.Value.ToString("yyyyMMdd");
  222. DataTable dt = ServerHelper.GetData("com.steering.pss.buybillet.Buybillet.get_FrmddTJ_data", new object[] { plinecode, date,date1 }, this.ob);
  223. DataTable dt1 = ds1.Tables[0];
  224. GridHelper.CopyDataToDatatable(dt, dt1, true);
  225. if (dt == null || dt.Rows.Count == 0)
  226. {
  227. //ultraExpandableGroupBox1.Expanded = true;
  228. //WaitingForm2 wf = new WaitingForm2("无停机数据....");
  229. //System.Threading.Thread.Sleep(3000);
  230. //wf.Close();
  231. ThreadPool.QueueUserWorkItem(new WaitCallback(DoInBackgroundThread));
  232. //ultraExpandableGroupBox1.Expanded = false;
  233. return;
  234. }
  235. ug1.DisplayLayout.Bands[0].Columns["PLINE_NAME"].CellAppearance.BackColor = Color.Wheat;
  236. ug1.DisplayLayout.Bands[0].Columns["PLINE_NAME"].MergedCellStyle = MergedCellStyle.Always;
  237. ug1.DisplayLayout.Bands[0].Columns["TJHOURS"].MergedCellStyle = MergedCellStyle.Always;
  238. ug1.DisplayLayout.Bands[0].Columns["TJHOURS"].CellAppearance.TextHAlign = HAlign.Right;
  239. //ug1.DisplayLayout.Bands[0].Columns["TJHOURS"].PerformAutoResize();
  240. ug1.DisplayLayout.Bands[0].Columns["LOGS_BEG"].MinWidth = 100;
  241. ug1.DisplayLayout.Bands[0].Columns["LOGS_END"].MinWidth = 100;
  242. ug1.DisplayLayout.Bands[0].Columns["CONFIRM_TIME"].MinWidth = 100;
  243. ug1.DisplayLayout.Bands[0].Columns["TJ_DATE"].MinWidth = 60;
  244. ug1.DisplayLayout.Bands[0].Columns["FLAG"].Hidden = true;
  245. UltraGridBand band = this.ug1.DisplayLayout.Bands[0];
  246. foreach (UltraGridRow row in band.GetRowEnumerator(GridRowType.DataRow))
  247. {
  248. if (row.Cells["FLAG"].Value.ToString() == "1")
  249. {
  250. row.Cells["TJ_DATE"].Value = "小计";
  251. row.Cells["TJ_DATE"].Appearance.BackColor = Color.Yellow;
  252. }
  253. if (row.Cells["FLAG"].Value.ToString() == "2")
  254. {
  255. row.Cells["TJ_DATE"].Value = "合计";
  256. row.Cells["TJ_DATE"].Appearance.BackColor = Color.Green;
  257. }
  258. row.Activation = Activation.NoEdit;
  259. if (plinecode.Length == 5)
  260. {
  261. if (plinecode.EndsWith("0"))
  262. {
  263. row.Cells["PLINE_NAME"].Value = row.Cells["PLINE_NAME"].Value + "(热处理)";
  264. }
  265. if (plinecode.EndsWith("1"))
  266. {
  267. row.Cells["PLINE_NAME"].Value = row.Cells["PLINE_NAME"].Value + "(探伤)";
  268. }
  269. }
  270. }
  271. ultraExpandableGroupBox1.Expanded = true;
  272. //ug1.DisplayLayout.Bands[0].PerformAutoResizeColumns(true, PerformAutoSizeType.VisibleRows);
  273. //foreach (UltraGridColumn ugc in ug1.DisplayLayout.Bands[0].Columns)
  274. // ugc.PerformAutoResize();
  275. }
  276. private void DoInBackgroundThread(object state)
  277. {
  278. this.BeginInvoke(updator,true);
  279. WaitingForm2 wf = new WaitingForm2("无停机数据....");
  280. System.Threading.Thread.Sleep(3000);
  281. wf.Close();
  282. this.BeginInvoke(updator,false);
  283. }
  284. //定义一个更新UI的委托类
  285. public delegate void UpdateProgress(bool flag);
  286. //定义一个委托实例
  287. private UpdateProgress updator;
  288. private void UIUpdateProgress(bool flag)
  289. {
  290. this.ultraExpandableGroupBox1.Expanded = flag;
  291. }
  292. private void ultraExpandableGroupBox1_ExpandedStateChanging(object sender, CancelEventArgs e)
  293. {
  294. ulBoxExpanded = !ulBoxExpanded;
  295. spcPanel2_Resize();
  296. }
  297. private void spcPanel2_Resize()
  298. {
  299. if (ulBoxExpanded)
  300. {
  301. setSpcSize();
  302. }
  303. else
  304. {
  305. setSpcCollapse();
  306. }
  307. }
  308. bool ulBoxExpanded = true;
  309. private void setSpcSize()
  310. {
  311. this.spc.SplitterDistance = Convert.ToInt32(spc.Size.Height * 0.7);
  312. }
  313. private void setSpcCollapse()
  314. {
  315. this.spc.SplitterDistance = this.spc.Size.Height - 10;
  316. }
  317. private void frmRptDaySCKB_Resize(object sender, EventArgs e)
  318. {
  319. spcPanel2_Resize();
  320. }
  321. private void spc_SizeChanged(object sender, EventArgs e)
  322. {
  323. //WaitingForm2 wf = new WaitingForm2("无停机数据....");
  324. //System.Threading.Thread.Sleep(3000);
  325. //wf.Close();
  326. }
  327. private void btn_week_Click(object sender, EventArgs e)
  328. {
  329. this.startDate.Value = this.endDate.Value.AddDays(-6);
  330. }
  331. private void btn_month_Click(object sender, EventArgs e)
  332. {
  333. this.startDate.Value = this.endDate.Value.AddMonths(-1);
  334. }
  335. }
  336. }