F_RPT_030118.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_030118.cs
  5. * 2.功能描述:年度各工序月产量统计表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/12/26 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Reflection;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.ReportModule
  22. {
  23. /// <summary>
  24. /// 年度各工序月产量统计表
  25. /// </summary>
  26. public partial class F_RPT_030118 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. private static F_RPT_030118 _instance = null;
  30. #endregion
  31. #region 单例模式
  32. /// <summary>
  33. /// 单例模式,防止重复创建窗体
  34. /// </summary>
  35. public static F_RPT_030118 Instance
  36. {
  37. get
  38. {
  39. if (_instance == null)
  40. {
  41. _instance = new F_RPT_030118();
  42. }
  43. return _instance;
  44. }
  45. }
  46. #endregion
  47. #region 构造函数
  48. /// <summary>
  49. ///
  50. /// </summary>
  51. public F_RPT_030118()
  52. {
  53. InitializeComponent();
  54. this.Text = "年度各工序月产量统计表";
  55. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  56. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  57. this.dgvSum.AutoGenerateColumns = false;
  58. }
  59. #endregion
  60. #region 控件事件
  61. /// <summary>
  62. /// 关闭
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void F_PC_1001_FormClosed(object sender, FormClosedEventArgs e)
  67. {
  68. _instance = null;
  69. }
  70. /// <summary>
  71. /// 画面加载
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void F_PC_1001_Load(object sender, System.EventArgs e)
  76. {
  77. try
  78. {
  79. this.dtpYear1.Value = DateTime.Now;
  80. this.txtMonth1.Text = DateTime.Now.Month.ToString();
  81. this.txtMonth2.Text = DateTime.Now.Month.ToString();
  82. }
  83. catch (Exception ex)
  84. {
  85. // 对异常进行共通处理
  86. ExceptionManager.HandleEventException(this.ToString(),
  87. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  88. }
  89. }
  90. /// <summary>
  91. /// 查询
  92. /// </summary>
  93. /// <param name="sender"></param>
  94. /// <param name="e"></param>
  95. private void tsbtnSearch_Click(object sender, EventArgs e)
  96. {
  97. try
  98. {
  99. this.dgvSum.DataSource = null;
  100. this.QueryDataFromOther();
  101. }
  102. catch (Exception ex)
  103. {
  104. // 对异常进行共通处理
  105. ExceptionManager.HandleEventException(this.ToString(),
  106. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  107. }
  108. }
  109. /// <summary>
  110. /// 清除条件
  111. /// </summary>
  112. /// <param name="sender"></param>
  113. /// <param name="e"></param>
  114. private void tsbtnClearCondition_Click(object sender, EventArgs e)
  115. {
  116. this.dtpYear1.Value = DateTime.Now;
  117. this.txtMonth1.Text = DateTime.Now.Month.ToString();
  118. this.txtMonth2.Text = DateTime.Now.Month.ToString();
  119. this.TXTMonth.Text = null;
  120. this.comboBox1.Text = null;
  121. this.comboBox1.SelectedIndex = 0;
  122. }
  123. /// <summary>
  124. /// 自适应列宽
  125. /// </summary>
  126. /// <param name="sender"></param>
  127. /// <param name="e"></param>
  128. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  129. {
  130. this.dgvSum.AutoResizeColumns();
  131. }
  132. /// <summary>
  133. /// 关闭画面
  134. /// </summary>
  135. /// <param name="sender"></param>
  136. /// <param name="e"></param>
  137. private void tsbtnClose_Click(object sender, EventArgs e)
  138. {
  139. this.Close();
  140. }
  141. #endregion
  142. #region 私有方法
  143. /// <summary>
  144. /// 查询数据
  145. /// </summary>
  146. private void QueryDataFromOther()
  147. {
  148. try
  149. {
  150. this.tsrToolStrip1.Focus();
  151. ClientRequestEntity cre = new ClientRequestEntity();
  152. cre.NameSpace = "R03";
  153. cre.Name = "R030118Data";
  154. int y = this.dtpYear1.Value.Value.Year;
  155. int month1 = 0;
  156. int month2 = 0;
  157. if (!string.IsNullOrWhiteSpace(this.txtMonth1.Text) && !string.IsNullOrWhiteSpace(this.txtMonth2.Text))
  158. {
  159. month1 = Convert.ToInt32(this.txtMonth1.Text);
  160. month2 = Convert.ToInt32(this.txtMonth2.Text);
  161. }
  162. string month = this.TXTMonth.Text;
  163. if (month1 > 0 && month2 > 0)
  164. {
  165. cre.Properties["DateBegin"] = new DateTime(y, month1, 1);
  166. cre.Properties["DateEnd"] = new DateTime(y, month2+1, 1);
  167. }
  168. else if((month == null || month == ""))
  169. {
  170. cre.Properties["DateBegin"] = new DateTime(y - 1, 12, 1);
  171. cre.Properties["DateEnd"] = new DateTime(y, 12, 1);
  172. }
  173. else {
  174. int months = Convert.ToInt32(month);
  175. cre.Properties["DateBegin"] = new DateTime(y, months, 1);
  176. cre.Properties["DateEnd"] = new DateTime(y, months+1, 1);
  177. }
  178. cre.Properties["workshop"] = this.comboBox1.Text;
  179. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  180. {
  181. return ReportModuleProxy.Service.DoRequest(cre);
  182. }
  183. );
  184. if (sre.Status == Constant.ServiceResultStatus.Success)
  185. {
  186. // 查询成功
  187. this.dgvSum.DataSource = sre.Data.Tables[0];
  188. }
  189. }
  190. catch (Exception ex)
  191. {
  192. throw ex;
  193. }
  194. }
  195. #endregion
  196. }
  197. }