F_RPT_020101_1.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. DataTable detailTable = dsQuery.Tables[1];
  119. DataColumn column = new DataColumn("ParentID");
  120. detailTable.Columns.Add(column);
  121. for (int i = 0; i < detailTable.Rows.Count; i++)
  122. {
  123. detailTable.Rows[i]["ParentID"] = 0;
  124. }
  125. this.dgvProductionDetail.DataSource = detailTable;
  126. if (!this.radioNo.Checked && this.radioYes.Checked && dsQuery.Tables.Count > 2)
  127. {
  128. DataTable idnrkInformation = dsQuery.Tables[2];
  129. DataTable newDatable = detailTable.Clone();
  130. DataColumn columns = new DataColumn("IdnrkInformation");
  131. newDatable.Columns.Add(columns);
  132. for (int i = 0; i < detailTable.Rows.Count; i++)
  133. {
  134. newDatable.ImportRow(detailTable.Rows[i]);
  135. for (int j = 0; j < idnrkInformation.Rows.Count; j++)
  136. {
  137. if (detailTable.Rows[i]["ProcedureName"].ToString() == idnrkInformation.Rows[j]["ProcedureName"].ToString())
  138. {
  139. newDatable.ImportRow(idnrkInformation.Rows[j]);
  140. }
  141. }
  142. }
  143. this.dgvProductionDetail.DataSource = newDatable;
  144. }
  145. }
  146. else
  147. {
  148. this.dgvProductionFollowing.DataSource = dsQuery.Tables[0];
  149. }
  150. }
  151. }
  152. else
  153. {
  154. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "产品条码"),
  155. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  156. this.txtBarCode.Focus();
  157. }
  158. }
  159. catch (Exception ex)
  160. {
  161. this.btnSearch.Enabled = true;
  162. // 对异常进行共通处理
  163. ExceptionManager.HandleEventException(this.ToString(),
  164. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  165. }
  166. }
  167. /// <summary>
  168. /// 根据界面查询条件获取数据集
  169. /// </summary>
  170. private DataSet GetSearchData()
  171. {
  172. try
  173. {
  174. RPT020101_SE se = new RPT020101_SE();
  175. se.Barcode = this.txtBarCode.Text.Trim();
  176. // 调用服务器端获取数据集
  177. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  178. {
  179. return ReportModuleProxy.Service.GetRPT020101SData(se);
  180. }
  181. );
  182. if (sre.Status == Constant.ServiceResultStatus.Success)
  183. {
  184. return sre.Data;
  185. }
  186. return null;
  187. }
  188. catch (Exception ex)
  189. {
  190. throw ex;
  191. }
  192. }
  193. /// <summary>
  194. /// 清空条件按钮事件
  195. /// </summary>
  196. /// <param name="sender"></param>
  197. /// <param name="e"></param>
  198. private void btnClearCondition_Click(object sender, EventArgs e)
  199. {
  200. this.txtBarCode.Text = string.Empty;
  201. }
  202. /// <summary>
  203. /// 窗体关闭事件
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. private void F_RPT_0201_1_FormClosed(object sender, FormClosedEventArgs e)
  208. {
  209. _instance = null;
  210. }
  211. /// <summary>
  212. /// 关闭按钮
  213. /// </summary>
  214. /// <param name="sender"></param>
  215. /// <param name="e"></param>
  216. private void tsbtnClose_Click(object sender, EventArgs e)
  217. {
  218. this.Close();
  219. }
  220. /// <summary>
  221. /// 按回车查询
  222. /// </summary>
  223. /// <param name="sender"></param>
  224. /// <param name="e"></param>
  225. private void txtBarCode_KeyDown(object sender, KeyEventArgs e)
  226. {
  227. if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(this.txtBarCode.Text.Trim()))
  228. {
  229. this.btnSearch_Click(null, null);
  230. }
  231. }
  232. #endregion
  233. /// <summary>
  234. /// 是否变化按钮
  235. /// </summary>
  236. /// <param name="sender"></param>
  237. /// <param name="e"></param>
  238. private void radioYes_CheckedChanged(object sender, EventArgs e)
  239. {
  240. if (this.radioYes.Checked)
  241. {
  242. this.radioNo.Checked = false;
  243. }
  244. else
  245. {
  246. this.radioNo.Checked = true;
  247. }
  248. }
  249. /// <summary>
  250. /// 是否变化按钮
  251. /// </summary>
  252. /// <param name="sender"></param>
  253. /// <param name="e"></param>
  254. private void radioNo_CheckedChanged(object sender, EventArgs e)
  255. {
  256. if (this.radioNo.Checked)
  257. {
  258. this.radioYes.Checked = false;
  259. }
  260. else
  261. {
  262. this.radioYes.Checked = true;
  263. }
  264. }
  265. }
  266. }