F_PM_1801.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1801.cs
  5. * 2.功能描述:环境日报
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/17 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  16. using Dongke.IBOSS.PRD.WCF.Proxys;
  17. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  18. using Dongke.IBOSS.PRD.Client.CommonModule;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. namespace Dongke.IBOSS.PRD.Client.PMModule
  21. {
  22. public partial class F_PM_1801 : DockPanelBase
  23. {
  24. #region 成员变量
  25. //单例模式
  26. private static F_PM_1801 _instance;
  27. // 金额小数位数
  28. private string _amountDecimalplaces = "N1";
  29. #endregion
  30. #region 构造函数
  31. public F_PM_1801()
  32. {
  33. InitializeComponent();
  34. }
  35. #endregion
  36. #region 单例模式
  37. /// <summary>
  38. /// 单例模式,防止重复创建窗体
  39. /// </summary>
  40. public static F_PM_1801 Instance
  41. {
  42. get
  43. {
  44. if (_instance == null)
  45. {
  46. _instance = new F_PM_1801();
  47. }
  48. return _instance;
  49. }
  50. }
  51. #endregion
  52. #region 事件
  53. private void F_PM_1801_Load(object sender, EventArgs e)
  54. {
  55. try
  56. {
  57. this.chart1.Series[0].XValueMember = "ThermometerCode";
  58. this.chart1.Series[0].YValueMembers = "Celsius";
  59. this.chart1.Series[1].XValueMember = "ThermometerCode";
  60. this.chart1.Series[1].YValueMembers = "Humidity";
  61. }
  62. catch(Exception ex)
  63. {
  64. // 对异常进行共通处理
  65. ExceptionManager.HandleEventException(this.ToString(),
  66. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  67. }
  68. }
  69. private void btnSearch_Click(object sender, EventArgs e)
  70. {
  71. try
  72. {
  73. DataSet dsThermometer = (DataSet)DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(() =>
  74. {
  75. return this.GetCelsiusRecord();
  76. }));
  77. if (dsThermometer != null)
  78. {
  79. if (dsThermometer.Tables.Count != Constant.INT_IS_ZERO)
  80. {
  81. this.chart1.DataSource = ((DataSet)dsThermometer).Tables[Constant.INT_IS_ZERO].DefaultView;
  82. this.chart1.Series[0].LabelFormat = _amountDecimalplaces;
  83. this.chart1.Series[1].LabelFormat = _amountDecimalplaces;
  84. chart1.ChartAreas[0].AxisX.Interval = 1;
  85. chart1.ChartAreas[0].AxisX.IntervalOffset = 1;
  86. this.chart1.Update();
  87. if (((DataSet)dsThermometer).Tables[Constant.INT_IS_ZERO].Rows.Count == Constant.INT_IS_ZERO)
  88. {
  89. // 提示未查找到数据
  90. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  91. MessageBoxButtons.OK, MessageBoxIcon.Information);
  92. }
  93. }
  94. }
  95. else
  96. {
  97. this.chart1.DataSource = null;
  98. // 提示未查找到数据
  99. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  100. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  101. }
  102. }
  103. catch (Exception ex)
  104. {
  105. // 对异常进行共通处理
  106. ExceptionManager.HandleEventException(this.ToString(),
  107. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  108. }
  109. }
  110. private void btnClearCondition_Click(object sender, EventArgs e)
  111. {
  112. this.txtThermometer.Text = "";
  113. }
  114. private void F_PM_1801_FormClosed(object sender, FormClosedEventArgs e)
  115. {
  116. _instance = null;
  117. }
  118. #endregion
  119. #region 私有方法
  120. /// <summary>
  121. /// 根据界面查询条件获取数据集
  122. /// </summary>
  123. private DataSet GetCelsiusRecord()
  124. {
  125. try
  126. {
  127. CelsiusRecordEntity crEntity = new CelsiusRecordEntity();
  128. crEntity.ThermometerCode = this.txtThermometer.Text;
  129. crEntity.RecordDate = this.txtRecordDateStart.Value.Date;
  130. crEntity.RecordDateEnd = this.txtRecordDateEnd.Value.Date.AddDays(1);
  131. crEntity.Days = ((TimeSpan)(crEntity.RecordDateEnd - crEntity.RecordDate)).Days;
  132. return PMModuleProxy.Service.GetCelsiusRecordView(crEntity);
  133. }
  134. catch (Exception ex)
  135. {
  136. throw ex;
  137. }
  138. }
  139. #endregion
  140. }
  141. }