F_RPT_040113.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. 
  2. /*******************************************************************************
  3. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  4. * 类的信息:
  5. * 1.程序名称:F_RPT_040113.cs
  6. * 2.功能描述:各工艺质量表
  7. * 编辑履历:
  8. * 作者 日期 版本 修改内容
  9. * 陈晓野 2019/07/16 1.00 新建
  10. *******************************************************************************/
  11. using System;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Client.CommonModule;
  15. using Dongke.IBOSS.PRD.Client.Controls;
  16. using Dongke.IBOSS.PRD.Client.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. namespace Dongke.IBOSS.PRD.Client.ReportModule
  20. {
  21. /// <summary>
  22. /// 各工序质量表
  23. /// </summary>
  24. public partial class F_RPT_040113 : DKDockPanelBase
  25. {
  26. #region 成员变量
  27. // 窗体的单例模式
  28. private static F_RPT_040113 _instance;
  29. private ClientRequestEntity _cre = null;
  30. private bool _init = false;
  31. #endregion
  32. #region 构造函数
  33. public F_RPT_040113()
  34. {
  35. InitializeComponent();
  36. // 窗体显示的Title
  37. this.Text = "各工艺质量表";
  38. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  39. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  40. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  41. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  42. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  43. }
  44. #endregion
  45. #region 单例模式
  46. /// <summary>
  47. /// 单例模式,防止重复创建窗体
  48. /// </summary>
  49. public static F_RPT_040113 Instance
  50. {
  51. get
  52. {
  53. if (_instance == null || _instance.IsDisposed)
  54. {
  55. _instance = new F_RPT_040113();
  56. }
  57. return _instance;
  58. }
  59. }
  60. #endregion
  61. #region 事件处理
  62. /// <summary>
  63. /// 窗体加载事件
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. private void F_RPT_040113_Load(object sender, EventArgs e)
  68. {
  69. try
  70. {
  71. // 加载权限
  72. FormPermissionManager.FormPermissionControl(this.Name, this,
  73. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  74. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  75. // 设置表格不自动创建列
  76. this.dgvRpt.AutoGenerateColumns = false;
  77. this.dgvD.AutoGenerateColumns = false;
  78. // 初始化时间控件为当前日期
  79. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  80. this.dtpAccountDateEnd.Value = DateTime.Now.Date;
  81. this.cmbGoodsType2.SelectedIndex = 0;
  82. }
  83. catch (Exception ex)
  84. {
  85. // 对异常进行共通处理
  86. ExceptionManager.HandleEventException(this.ToString(),
  87. System.Reflection.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 tsbtnAdaptive_Click(object sender, EventArgs e)
  96. {
  97. this.dgvRpt.AutoResizeColumns();
  98. this.dgvD.AutoResizeColumns();
  99. }
  100. /// <summary>
  101. /// 窗体关闭事件
  102. /// </summary>
  103. /// <param name="sender"></param>
  104. /// <param name="e"></param>
  105. private void F_RPT_040113_FormClosed(object sender, FormClosedEventArgs e)
  106. {
  107. _instance = null;
  108. }
  109. /// <summary>
  110. /// 关闭按钮
  111. /// </summary>
  112. /// <param name="sender"></param>
  113. /// <param name="e"></param>
  114. private void tsbtnClose_Click(object sender, EventArgs e)
  115. {
  116. this.Close();
  117. }
  118. /// <summary>
  119. /// 查询按钮事件
  120. /// </summary>
  121. /// <param name="sender"></param>
  122. /// <param name="e"></param>
  123. private void btnSearch_Click(object sender, EventArgs e)
  124. {
  125. try
  126. {
  127. _init = true;
  128. this.dgvRpt.DataSource = null;
  129. this.dgvD.DataSource = null;
  130. _cre = new ClientRequestEntity();
  131. _cre.NameSpace = "R04";
  132. _cre.Name = "R040113";
  133. _cre.Properties["timebegin"] = this.dtpAccountDateStart.Value.Date;
  134. _cre.Properties["timeend"] = this.dtpAccountDateEnd.Value.Date.AddDays(1);
  135. if (this.cmbGoodsType2.Text == "大件")
  136. {
  137. _cre.Properties["gtcode2"] = "001001";
  138. }
  139. else if (this.cmbGoodsType2.Text == "小件")
  140. {
  141. _cre.Properties["gtcode2"] = "001002";
  142. }
  143. else
  144. {
  145. _cre.Properties["gtcode2"] = "[ALL]";
  146. }
  147. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  148. {
  149. return ReportModuleProxy.Service.DoRequest(_cre);
  150. });
  151. if (resultEntity != null && resultEntity.Data != null &&
  152. resultEntity.Data.Tables.Count > 0)
  153. {
  154. this.dgvRpt.DataSource = resultEntity.Data.Tables[0];
  155. if (resultEntity.Data.Tables.Count > 1)
  156. {
  157. this.dgvD.DataSource = resultEntity.Data.Tables[1];
  158. }
  159. }
  160. }
  161. catch (Exception ex)
  162. {
  163. this.btnSearch.Enabled = true;
  164. this.btnClearCondition.Enabled = true;
  165. // 对异常进行共通处理
  166. ExceptionManager.HandleEventException(this.ToString(),
  167. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  168. }
  169. finally
  170. {
  171. _init = false;
  172. }
  173. }
  174. /// <summary>
  175. /// 清空条件按钮事件
  176. /// </summary>
  177. /// <param name="sender"></param>
  178. /// <param name="e"></param>
  179. private void btnClearCondition_Click(object sender, EventArgs e)
  180. {
  181. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  182. this.dtpAccountDateEnd.Value = DateTime.Now.Date;
  183. this.cmbGoodsType2.SelectedIndex = 0;
  184. }
  185. private void dgvRpt_SelectionChanged(object sender, EventArgs e)
  186. {
  187. if (_init || this.dgvRpt.CurrentRow == null)
  188. {
  189. return;
  190. }
  191. try
  192. {
  193. string pcode = this.dgvRpt.CurrentRow.Cells["g1pcode"].Value + "";
  194. if (pcode == "99")
  195. {
  196. this.dgvD.DataSource = null;
  197. return;
  198. }
  199. ClientRequestEntity cre = new ClientRequestEntity();
  200. cre.NameSpace = "R04";
  201. cre.Name = "R040113D";
  202. if (_cre != null)
  203. {
  204. cre.Properties["timebegin"] = _cre.Properties["timebegin"];
  205. cre.Properties["timeend"] = _cre.Properties["timeend"];
  206. }
  207. else
  208. {
  209. cre.Properties["timebegin"] = this.dtpAccountDateStart.Value.Date;
  210. cre.Properties["timeend"] = this.dtpAccountDateEnd.Value.Date.AddDays(1);
  211. }
  212. cre.Properties["pcode"] = this.dgvRpt.CurrentRow.Cells["g1pcode"].Value;
  213. cre.Properties["pname"] = this.dgvRpt.CurrentRow.Cells["g1pname"].Value;
  214. cre.Properties["gtcode2"] = this.dgvRpt.CurrentRow.Cells["g1gtcode2"].Value;
  215. ServiceResultEntity resultEntity = ReportModuleProxy.Service.DoRequest(cre);
  216. this.dgvD.DataSource = null;
  217. if (resultEntity != null || resultEntity.Data != null ||
  218. resultEntity.Data.Tables.Count > 0)
  219. {
  220. this.dgvD.DataSource = resultEntity.Data.Tables[0];
  221. }
  222. }
  223. catch (Exception ex)
  224. {
  225. this.btnSearch.Enabled = true;
  226. this.btnClearCondition.Enabled = true;
  227. // 对异常进行共通处理
  228. ExceptionManager.HandleEventException(this.ToString(),
  229. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  230. }
  231. }
  232. #endregion
  233. #region 私有方法
  234. #endregion
  235. }
  236. }