F_RPT_010404.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_010404.cs
  5. * 2.功能描述:在产品备份表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/8/8 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  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_010404 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_RPT_010404 _instance;
  31. #endregion
  32. #region 构造函数
  33. public F_RPT_010404()
  34. {
  35. InitializeComponent();
  36. //自动适应列宽
  37. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  38. //关闭
  39. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  40. //查询
  41. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  42. //清空条件
  43. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  44. //查询条件
  45. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  46. // 窗体显示的Title
  47. this.Text = "在产品备份表";
  48. }
  49. #endregion
  50. #region 单例模式
  51. /// <summary>
  52. /// 单例模式,防止重复创建窗体
  53. /// </summary>
  54. public static F_RPT_010404 Instance
  55. {
  56. get
  57. {
  58. if (_instance == null || _instance.IsDisposed)
  59. {
  60. _instance = new F_RPT_010404();
  61. }
  62. return _instance;
  63. }
  64. }
  65. #endregion
  66. #region 事件
  67. /// <summary>
  68. /// 窗体加载事件
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. private void F_RPT_010401_Load(object sender, EventArgs e)
  73. {
  74. try
  75. {
  76. // 加载权限
  77. FormPermissionManager.FormPermissionControl(this.Name, this,
  78. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  79. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  80. // 设置表格不自动创建列
  81. this.dgvInProduction.AutoGenerateColumns = false;
  82. DateTime now = DateTime.Now;
  83. this.dtpBackupMonth.Value = new DateTime(now.Year, now.Month, 1);
  84. }
  85. catch (Exception ex)
  86. {
  87. // 对异常进行共通处理
  88. ExceptionManager.HandleEventException(this.ToString(),
  89. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  90. }
  91. }
  92. /// <summary>
  93. /// 窗体关闭事件
  94. /// </summary>
  95. /// <param name="sender"></param>
  96. /// <param name="e"></param>
  97. private void F_RPT_010401_FormClosed(object sender, FormClosedEventArgs e)
  98. {
  99. _instance = null;
  100. }
  101. /// <summary>
  102. /// 关闭按钮事件
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void tsbtnClose_Click(object sender, EventArgs e)
  107. {
  108. this.Close();
  109. }
  110. /// <summary>
  111. /// 查询按钮事件
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void btnSearch_Click(object sender, EventArgs e)
  116. {
  117. try
  118. {
  119. this.dgvInProduction.DataSource = null;
  120. this.dgvInProduction.DataSource = this.GetSearchData();
  121. }
  122. catch (Exception ex)
  123. {
  124. this.btnSearch.Enabled = true;
  125. this.btnClearCondition.Enabled = true;
  126. // 对异常进行共通处理
  127. ExceptionManager.HandleEventException(this.ToString(),
  128. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  129. }
  130. }
  131. /// <summary>
  132. /// 自动适应列宽
  133. /// </summary>
  134. /// <param name="sender"></param>
  135. /// <param name="e"></param>
  136. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  137. {
  138. this.dgvInProduction.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  139. }
  140. /// <summary>
  141. /// 清空条件按钮事件
  142. /// </summary>
  143. /// <param name="sender"></param>
  144. /// <param name="e"></param>
  145. private void btnClearCondition_Click(object sender, EventArgs e)
  146. {
  147. //清空更多条件内容
  148. DateTime now = DateTime.Now;
  149. this.dtpBackupMonth.Value = new DateTime(now.Year, now.Month, 1);
  150. }
  151. #endregion
  152. #region 私有方法
  153. /// <summary>
  154. /// 根据界面查询条件获取数据集
  155. /// </summary>
  156. private DataTable GetSearchData()
  157. {
  158. try
  159. {
  160. ClientRequestEntity cre = new ClientRequestEntity();
  161. cre.NameSpace = "R01";
  162. cre.Name = "R010404";
  163. cre.Properties["BackupMonth"] = this.dtpBackupMonth.Value;
  164. // 调用服务器端获取数据集
  165. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  166. {
  167. return ReportModuleProxy.Service.DoRequest(cre);
  168. }
  169. );
  170. if (sre.Status == Constant.ServiceResultStatus.Success)
  171. {
  172. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  173. {
  174. // 提示未查找到数据
  175. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  176. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  177. //清空数据
  178. return null;
  179. }
  180. return sre.Data.Tables[0];
  181. }
  182. return null;
  183. }
  184. catch (Exception ex)
  185. {
  186. throw ex;
  187. }
  188. }
  189. #endregion
  190. }
  191. }