F_RPT_01040502.cs 6.5 KB

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