F_RPT_020101_1.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_020101_1.cs
  5. * 2.功能描述:产品跟踪表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/4/9 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  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.DataModels.ReportModule;
  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_020101_1 : DKDockPanelBase
  26. {
  27. #region 成员变量
  28. // 窗体的单例模式
  29. private static F_RPT_020101_1 _instance;
  30. //定义实体类
  31. private SearchGoodsFollowingEntity searchGoodsFollowingEntity = new SearchGoodsFollowingEntity();
  32. #endregion
  33. #region 构造函数
  34. public F_RPT_020101_1()
  35. {
  36. InitializeComponent();
  37. // 窗体显示的Title
  38. this.Text = FormTitles.F_RPT_020101;
  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_020101_1 Instance
  51. {
  52. get
  53. {
  54. if (_instance == null || _instance.IsDisposed)
  55. {
  56. _instance = new F_RPT_020101_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_0201_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.dgvProductionFollowing.AutoGenerateColumns = false;
  78. this.dgvProductionDetail.AutoGenerateColumns = false;
  79. this.txtBarCode.Focus();
  80. }
  81. catch (Exception ex)
  82. {
  83. // 对异常进行共通处理
  84. ExceptionManager.HandleEventException(this.ToString(),
  85. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  86. }
  87. }
  88. /// <summary>
  89. /// 自动适应列宽
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  94. {
  95. this.dgvProductionFollowing.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  96. this.dgvProductionDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  97. }
  98. /// <summary>
  99. /// 查询按钮事件
  100. /// </summary>
  101. /// <param name="sender"></param>
  102. /// <param name="e"></param>
  103. private void btnSearch_Click(object sender, EventArgs e)
  104. {
  105. try
  106. {
  107. if (!string.IsNullOrEmpty(this.txtBarCode.Text.Trim()))
  108. {
  109. //清空数据
  110. this.dgvProductionDetail.DataSource = null;
  111. this.dgvProductionFollowing.DataSource = null;
  112. DataSet dsQuery = this.GetSearchData();
  113. if (dsQuery != null)
  114. {
  115. if (dsQuery.Tables.Count > 1)
  116. {
  117. this.dgvProductionFollowing.DataSource = dsQuery.Tables[0];
  118. this.dgvProductionDetail.DataSource = dsQuery.Tables[1];
  119. }
  120. else
  121. {
  122. this.dgvProductionFollowing.DataSource = dsQuery.Tables[0];
  123. }
  124. }
  125. }
  126. else
  127. {
  128. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品条码"),
  129. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  130. this.txtBarCode.Focus();
  131. }
  132. }
  133. catch (Exception ex)
  134. {
  135. this.btnSearch.Enabled = true;
  136. // 对异常进行共通处理
  137. ExceptionManager.HandleEventException(this.ToString(),
  138. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  139. }
  140. }
  141. /// <summary>
  142. /// 根据界面查询条件获取数据集
  143. /// </summary>
  144. private DataSet GetSearchData()
  145. {
  146. try
  147. {
  148. RPT020101_SE se = new RPT020101_SE();
  149. se.Barcode = this.txtBarCode.Text.Trim();
  150. // 调用服务器端获取数据集
  151. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  152. {
  153. return ReportModuleProxy.Service.GetRPT020101SData(se);
  154. }
  155. );
  156. if (sre.Status == Constant.ServiceResultStatus.Success)
  157. {
  158. return sre.Data;
  159. }
  160. return null;
  161. }
  162. catch (Exception ex)
  163. {
  164. throw ex;
  165. }
  166. }
  167. /// <summary>
  168. /// 清空条件按钮事件
  169. /// </summary>
  170. /// <param name="sender"></param>
  171. /// <param name="e"></param>
  172. private void btnClearCondition_Click(object sender, EventArgs e)
  173. {
  174. this.txtBarCode.Text = string.Empty;
  175. }
  176. /// <summary>
  177. /// 窗体关闭事件
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. private void F_RPT_0201_1_FormClosed(object sender, FormClosedEventArgs e)
  182. {
  183. _instance = null;
  184. }
  185. /// <summary>
  186. /// 关闭按钮
  187. /// </summary>
  188. /// <param name="sender"></param>
  189. /// <param name="e"></param>
  190. private void tsbtnClose_Click(object sender, EventArgs e)
  191. {
  192. this.Close();
  193. }
  194. /// <summary>
  195. /// 按回车查询
  196. /// </summary>
  197. /// <param name="sender"></param>
  198. /// <param name="e"></param>
  199. private void txtBarCode_KeyDown(object sender, KeyEventArgs e)
  200. {
  201. if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(this.txtBarCode.Text.Trim()))
  202. {
  203. this.btnSearch_Click(null, null);
  204. }
  205. }
  206. #endregion
  207. }
  208. }