F_PM_1802.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PM_1802.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.Basics.BaseControls;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. namespace Dongke.IBOSS.PRD.Client.PMModule
  22. {
  23. public partial class F_PM_1802 : FormBase
  24. {
  25. #region 成员变量
  26. //单例模式
  27. private static F_PM_1802 _instance;
  28. // 金额小数位数
  29. private string _amountDecimalplaces = "N1";
  30. #endregion
  31. #region 构造函数
  32. public F_PM_1802()
  33. {
  34. InitializeComponent();
  35. }
  36. #endregion
  37. #region 单例模式
  38. /// <summary>
  39. /// 单例模式,防止重复创建窗体
  40. /// </summary>
  41. public static F_PM_1802 Instance
  42. {
  43. get
  44. {
  45. if (_instance == null)
  46. {
  47. _instance = new F_PM_1802();
  48. }
  49. return _instance;
  50. }
  51. }
  52. #endregion
  53. #region 事件
  54. private void F_PM_1802_Load(object sender, EventArgs e)
  55. {
  56. try
  57. {
  58. this.chart1.Series[0].LegendText = "温度";
  59. this.chart1.Series[0].XValueMember = "RecordDateStr";
  60. this.chart1.Series[0].YValueMembers = "Celsius";
  61. this.chart1.Series[1].LegendText = "湿度";
  62. this.chart1.Series[1].XValueMember = "RecordDateStr";
  63. this.chart1.Series[1].YValueMembers = "Humidity";
  64. }
  65. catch(Exception ex)
  66. {
  67. // 对异常进行共通处理
  68. ExceptionManager.HandleEventException(this.ToString(),
  69. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  70. }
  71. }
  72. private void btnSearch_Click(object sender, EventArgs e)
  73. {
  74. try
  75. {
  76. if(this.dkThermometer.ThermometerID == null)
  77. {
  78. this.dkThermometer.Focus();
  79. return;
  80. }
  81. DataSet dsThermometer = (DataSet)DoAsync(() =>
  82. {
  83. return this.GetCelsiusRecord();
  84. });
  85. if (dsThermometer != null)
  86. {
  87. if (dsThermometer.Tables.Count != Constant.INT_IS_ZERO)
  88. {
  89. this.chart1.DataSource = ((DataSet)dsThermometer).Tables[Constant.INT_IS_ZERO].DefaultView;
  90. this.chart1.Series[0].LabelFormat = _amountDecimalplaces;
  91. this.chart1.Series[1].LabelFormat = _amountDecimalplaces;
  92. chart1.ChartAreas[0].AxisX.Interval = 7;
  93. chart1.ChartAreas[0].AxisX.IntervalOffset = 7;
  94. chart1.ChartAreas[0].AxisY.Interval = 5;
  95. chart1.ChartAreas[0].AxisY.IntervalOffset = 5;
  96. this.chart1.Update();
  97. if (((DataSet)dsThermometer).Tables[Constant.INT_IS_ZERO].Rows.Count == Constant.INT_IS_ZERO)
  98. {
  99. // 提示未查找到数据
  100. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  101. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  102. }
  103. }
  104. }
  105. else
  106. {
  107. this.chart1.DataSource = null;
  108. // 提示未查找到数据
  109. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  110. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  111. }
  112. }
  113. catch (Exception ex)
  114. {
  115. // 对异常进行共通处理
  116. ExceptionManager.HandleEventException(this.ToString(),
  117. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  118. }
  119. }
  120. private void btnClearCondition_Click(object sender, EventArgs e)
  121. {
  122. this.dkThermometer.Text = "";
  123. this.dkThermometer.ThermometerID = null;
  124. }
  125. private void F_PM_1802_FormClosed(object sender, FormClosedEventArgs e)
  126. {
  127. _instance = null;
  128. }
  129. #endregion
  130. #region 私有方法
  131. /// <summary>
  132. /// 根据界面查询条件获取数据集
  133. /// </summary>
  134. private DataSet GetCelsiusRecord()
  135. {
  136. try
  137. {
  138. CelsiusRecordEntity crEntity = new CelsiusRecordEntity();
  139. crEntity.ThermometerID = this.dkThermometer.ThermometerID;
  140. crEntity.RecordDate = this.txtRecordDateStart.Value.Date;
  141. crEntity.RecordDateEnd = this.txtRecordDateEnd.Value.Date.AddDays(1);
  142. crEntity.Days = ((TimeSpan)(crEntity.RecordDateEnd - crEntity.RecordDate)).Days;
  143. crEntity.PurviewType = 11;// 查看权限
  144. return PMModuleProxy.Service.GetCelsiusRecord(crEntity);
  145. }
  146. catch (Exception ex)
  147. {
  148. throw ex;
  149. }
  150. }
  151. #endregion
  152. }
  153. }