F_RPT_040115.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. 
  2. /*******************************************************************************
  3. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  4. * 类的信息:
  5. * 1.程序名称:F_RPT_040115.cs
  6. * 2.功能描述:半成品工序质量表
  7. * 编辑履历:
  8. * 作者 日期 版本 修改内容
  9. * 陈晓野 2019/07/16 1.00 新建
  10. *******************************************************************************/
  11. using System;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.Client.Controls;
  17. using Dongke.IBOSS.PRD.Client.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. namespace Dongke.IBOSS.PRD.Client.ReportModule
  21. {
  22. /// <summary>
  23. /// 半成品工序质量表
  24. /// </summary>
  25. public partial class F_RPT_040115 : DKDockPanelBase
  26. {
  27. #region 成员变量
  28. // 窗体的单例模式
  29. private static F_RPT_040115 _instance;
  30. private ClientRequestEntity _cre = null;
  31. private bool _init = false;
  32. #endregion
  33. #region 构造函数
  34. public F_RPT_040115()
  35. {
  36. InitializeComponent();
  37. // 窗体显示的Title
  38. this.Text = "半成品工序质量表";
  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_040115 Instance
  51. {
  52. get
  53. {
  54. if (_instance == null || _instance.IsDisposed)
  55. {
  56. _instance = new F_RPT_040115();
  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_040113_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.dgvRpt.AutoGenerateColumns = false;
  78. this.dgvD.AutoGenerateColumns = false;
  79. // 初始化时间控件为当前日期
  80. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  81. this.dtpAccountDateEnd.Value = DateTime.Now.Date;
  82. this.scbGoodsType.ClearValue();
  83. }
  84. catch (Exception ex)
  85. {
  86. // 对异常进行共通处理
  87. ExceptionManager.HandleEventException(this.ToString(),
  88. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  89. }
  90. }
  91. /// <summary>
  92. /// 自动适应列宽
  93. /// </summary>
  94. /// <param name="sender"></param>
  95. /// <param name="e"></param>
  96. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  97. {
  98. this.dgvRpt.AutoResizeColumns();
  99. this.dgvD.AutoResizeColumns();
  100. }
  101. /// <summary>
  102. /// 窗体关闭事件
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void F_RPT_040113_FormClosed(object sender, FormClosedEventArgs e)
  107. {
  108. _instance = null;
  109. }
  110. /// <summary>
  111. /// 关闭按钮
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void tsbtnClose_Click(object sender, EventArgs e)
  116. {
  117. this.Close();
  118. }
  119. /// <summary>
  120. /// 查询按钮事件
  121. /// </summary>
  122. /// <param name="sender"></param>
  123. /// <param name="e"></param>
  124. private void btnSearch_Click(object sender, EventArgs e)
  125. {
  126. try
  127. {
  128. _init = true;
  129. this.dgvRpt.DataSource = null;
  130. this.dgvD.DataSource = null;
  131. _cre = new ClientRequestEntity();
  132. _cre.NameSpace = "R04";
  133. _cre.Name = "R040115";
  134. _cre.Properties["timebegin"] = this.dtpAccountDateStart.Value.Date;
  135. _cre.Properties["timeend"] = this.dtpAccountDateEnd.Value.Date.AddDays(1);
  136. _cre.Properties["gtcode"] = this.scbGoodsType.SearchedValue + "";
  137. _cre.Properties["GoodsIDS"] = scbGoods.CheckedPKMember;
  138. _cre.Properties["ProcedureIDS"] = dkProcedureSearchBox.ProcedureIDS;
  139. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  140. {
  141. return ReportModuleProxy.Service.DoRequest(_cre);
  142. });
  143. if (resultEntity != null && resultEntity.Data != null &&
  144. resultEntity.Data.Tables.Count > 0)
  145. {
  146. this.dgvRpt.DataSource = resultEntity.Data.Tables[0];
  147. if (resultEntity.Data.Tables.Count > 1)
  148. {
  149. this.dgvD.DataSource = resultEntity.Data.Tables[1];
  150. }
  151. }
  152. }
  153. catch (Exception ex)
  154. {
  155. this.btnSearch.Enabled = true;
  156. this.btnClearCondition.Enabled = true;
  157. // 对异常进行共通处理
  158. ExceptionManager.HandleEventException(this.ToString(),
  159. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  160. }
  161. finally
  162. {
  163. _init = false;
  164. }
  165. }
  166. /// <summary>
  167. /// 清空条件按钮事件
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void btnClearCondition_Click(object sender, EventArgs e)
  172. {
  173. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  174. this.dtpAccountDateEnd.Value = DateTime.Now.Date;
  175. this.scbGoodsType.ClearValue();
  176. this.scbGoods.ClearValue();
  177. this.dkProcedureSearchBox.ClearControl();
  178. }
  179. private void dgvRpt_SelectionChanged(object sender, EventArgs e)
  180. {
  181. if (_init || this.dgvRpt.CurrentRow == null)
  182. {
  183. return;
  184. }
  185. try
  186. {
  187. string pcode = this.dgvRpt.CurrentRow.Cells["g1PROCEDUREID"].Value + "";
  188. if (pcode == "0")
  189. {
  190. this.dgvD.DataSource = null;
  191. return;
  192. }
  193. ClientRequestEntity cre = new ClientRequestEntity();
  194. cre.NameSpace = "R04";
  195. cre.Name = "R040115D";
  196. if (_cre != null)
  197. {
  198. cre.Properties["timebegin"] = _cre.Properties["timebegin"];
  199. cre.Properties["timeend"] = _cre.Properties["timeend"];
  200. cre.Properties["gtcode"] = _cre.Properties["gtcode"];
  201. cre.Properties["GoodsIDS"] = _cre.Properties["GoodsIDS"];
  202. cre.Properties["ProcedureIDS"] = _cre.Properties["ProcedureIDS"];
  203. }
  204. else
  205. {
  206. cre.Properties["timebegin"] = this.dtpAccountDateStart.Value.Date;
  207. cre.Properties["timeend"] = this.dtpAccountDateEnd.Value.Date.AddDays(1);
  208. }
  209. cre.Properties["PROCEDUREID"] = this.dgvRpt.CurrentRow.Cells["g1PROCEDUREID"].Value;
  210. ServiceResultEntity resultEntity = ReportModuleProxy.Service.DoRequest(cre);
  211. this.dgvD.DataSource = null;
  212. if (resultEntity != null || resultEntity.Data != null ||
  213. resultEntity.Data.Tables.Count > 0)
  214. {
  215. this.dgvD.DataSource = resultEntity.Data.Tables[0];
  216. }
  217. }
  218. catch (Exception ex)
  219. {
  220. this.btnSearch.Enabled = true;
  221. this.btnClearCondition.Enabled = true;
  222. // 对异常进行共通处理
  223. ExceptionManager.HandleEventException(this.ToString(),
  224. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  225. }
  226. }
  227. #endregion
  228. #region 私有方法
  229. #endregion
  230. }
  231. }