F_RPT_010301_1.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_010301_1.cs
  5. * 2.功能描述:条码变更明细表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/4/10 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.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. using Dongke.IBOSS.PRD.WCF.Proxys.ReportModuleService;
  21. using Dongke.IBOSS.PRD.Client.Controls;
  22. namespace Dongke.IBOSS.PRD.Client.ReportModule
  23. {
  24. /// <summary>
  25. /// 条码变更明细表
  26. /// </summary>
  27. public partial class F_RPT_010301_1 : DKDockPanelBase
  28. {
  29. #region 成员变量
  30. // 窗体的单例模式
  31. private static F_RPT_010301_1 _instance;
  32. #endregion
  33. #region 构造函数
  34. public F_RPT_010301_1()
  35. {
  36. InitializeComponent();
  37. // 窗体显示的Title
  38. this.Text = FormTitles.F_RPT_010301;
  39. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  40. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  41. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  42. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  43. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  44. }
  45. #endregion
  46. #region 单例模式
  47. /// <summary>
  48. /// 单例模式,防止重复创建窗体
  49. /// </summary>
  50. public static F_RPT_010301_1 Instance
  51. {
  52. get
  53. {
  54. if (_instance == null || _instance.IsDisposed)
  55. {
  56. _instance = new F_RPT_010301_1();
  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_010301_1_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.dgvReportModule.AutoGenerateColumns = false;
  78. // 初始化时间控件为当前日期
  79. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  80. this.dtpAccountDateEnd.Value = DateTime.Now.Date;
  81. }
  82. catch (Exception ex)
  83. {
  84. // 对异常进行共通处理
  85. ExceptionManager.HandleEventException(this.ToString(),
  86. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  87. }
  88. }
  89. /// <summary>
  90. /// 自动适应列宽
  91. /// </summary>
  92. /// <param name="sender"></param>
  93. /// <param name="e"></param>
  94. /// <summary>
  95. /// 窗体关闭事件
  96. /// </summary>
  97. /// <param name="sender"></param>
  98. /// <param name="e"></param>
  99. private void F_RPT_010301_1_FormClosed(object sender, FormClosedEventArgs e)
  100. {
  101. _instance = null;
  102. }
  103. /// <summary>
  104. /// 关闭按钮
  105. /// </summary>
  106. /// <param name="sender"></param>
  107. /// <param name="e"></param>
  108. private void tsbtnClose_Click(object sender, EventArgs e)
  109. {
  110. this.Close();
  111. }
  112. /// <summary>
  113. /// 查询按钮事件
  114. /// </summary>
  115. /// <param name="sender"></param>
  116. /// <param name="e"></param>
  117. private void btnSearch_Click(object sender, EventArgs e)
  118. {
  119. try
  120. {
  121. this.dgvReportModule.DataSource = null;
  122. this.dgvReportModule.DataSource = this.GetSearchData();
  123. }
  124. catch (Exception ex)
  125. {
  126. this.btnSearch.Enabled = true;
  127. this.btnClearCondition.Enabled = true;
  128. // 对异常进行共通处理
  129. ExceptionManager.HandleEventException(this.ToString(),
  130. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  131. }
  132. }
  133. /// <summary>
  134. /// 清空条件按钮事件
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void btnClearCondition_Click(object sender, EventArgs e)
  139. {
  140. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  141. this.dtpAccountDateEnd.Value = DateTime.Now.Date;
  142. this.txtBarcode.Text = string.Empty;
  143. }
  144. #endregion
  145. #region 私有方法
  146. /// <summary>
  147. /// 根据界面查询条件获取数据集
  148. /// </summary>
  149. private DataTable GetSearchData()
  150. {
  151. try
  152. {
  153. RPT010301_SE se = new RPT010301_SE();
  154. se.Barcode = txtBarcode.Text.Trim();
  155. se.createTimeBegin = DateTime.Parse(this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd") + " 0:0:0");
  156. se.createTimeEnd = DateTime.Parse(this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  157. // 调用服务器端获取数据集
  158. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  159. {
  160. return ReportModuleProxy.Service.GetRPT010301SData(se);
  161. }
  162. );
  163. if (sre.Status == Constant.ServiceResultStatus.Success)
  164. {
  165. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  166. {
  167. // 提示未查找到数据
  168. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  169. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  170. //清空数据
  171. return null;
  172. }
  173. return sre.Data.Tables[0];
  174. }
  175. return null;
  176. }
  177. catch (Exception ex)
  178. {
  179. throw ex;
  180. }
  181. }
  182. /// <summary>
  183. /// 自适应列宽
  184. /// </summary>
  185. /// <param name="sender"></param>
  186. /// <param name="e"></param>
  187. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  188. {
  189. this.dgvReportModule.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  190. }
  191. #endregion
  192. }
  193. }