F_RPT_080114.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_080114.cs
  5. * 2.功能描述:QC检验数据明细表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 秦祺 2022/12/09 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  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.Client.PMModule;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.ReportModule
  22. {
  23. public partial class F_RPT_080114 : DKDockPanelBase
  24. {
  25. #region 成员变量
  26. // 窗体的单例模式
  27. private static F_RPT_080114 _instance;
  28. #endregion
  29. #region 构造函数
  30. public F_RPT_080114()
  31. {
  32. InitializeComponent();
  33. // 窗体显示的Title
  34. this.Text = "QC检验数据明细表";
  35. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  36. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  37. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  38. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  39. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  40. }
  41. #endregion
  42. #region 单例模式
  43. /// <summary>
  44. /// 单例模式,防止重复创建窗体
  45. /// </summary>
  46. public static F_RPT_080114 Instance
  47. {
  48. get
  49. {
  50. if (_instance == null || _instance.IsDisposed)
  51. {
  52. _instance = new F_RPT_080114();
  53. }
  54. return _instance;
  55. }
  56. }
  57. #endregion
  58. #region 事件处理
  59. /// <summary>
  60. /// 窗体加载事件
  61. /// </summary>
  62. /// <param name="sender"></param>
  63. /// <param name="e"></param>
  64. private void F_RPT_080114_Load(object sender, EventArgs e)
  65. {
  66. try
  67. {
  68. // 加载权限
  69. FormPermissionManager.FormPermissionControl(this.Name, this,
  70. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  71. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  72. this.dtpCreateTimeBegin.Value = DateTime.Now.Date;
  73. this.dtpCreateTimeEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  74. // 设置表格不自动创建列
  75. this.dgvQCdata.AutoGenerateColumns = false;
  76. // 检验标准名称
  77. //绑定检验类型
  78. ClientRequestEntity cre = new ClientRequestEntity();
  79. cre.NameSpace = "F_RPT_080116";
  80. cre.Name = "GetInspectName";
  81. ServiceResultEntity sre = DoAsync(() =>
  82. {
  83. return PCModuleProxyNew.Service.HandleRequest(cre);
  84. });
  85. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  86. {
  87. this.cbInpectName.DisplayMember = "INSPECTNAME";
  88. this.cbInpectName.ValueMember = "ITEMSID";
  89. this.cbInpectName.DataSource = sre.Data.Tables[0];
  90. }
  91. }
  92. catch (Exception ex)
  93. {
  94. // 对异常进行共通处理
  95. ExceptionManager.HandleEventException(this.ToString(),
  96. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  97. }
  98. }
  99. /// <summary>
  100. /// 自动适应列宽
  101. /// </summary>
  102. /// <param name="sender"></param>
  103. /// <param name="e"></param>
  104. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  105. {
  106. this.dgvQCdata.AutoResizeColumns();
  107. }
  108. /// <summary>
  109. /// 窗体关闭事件
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void F_RPT_080114_FormClosed(object sender, FormClosedEventArgs e)
  114. {
  115. _instance = null;
  116. }
  117. /// <summary>
  118. /// 关闭按钮
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void tsbtnClose_Click(object sender, EventArgs e)
  123. {
  124. this.Close();
  125. }
  126. /// <summary>
  127. /// 查询按钮事件
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void btnSearch_Click(object sender, EventArgs e)
  132. {
  133. try
  134. {
  135. this.dgvQCdata.DataSource = null;
  136. ClientRequestEntity cre = new ClientRequestEntity();
  137. cre.NameSpace = "F_RPT_080114";
  138. cre.Name = "GetBarCodeData";
  139. cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
  140. cre.Properties["CreateTimeBegin"] = this.dtpCreateTimeBegin.Value;
  141. cre.Properties["CreateTimeEnd"] = Convert.ToDateTime(this.dtpCreateTimeEnd.Value).AddSeconds(1);
  142. cre.Properties["InpectName"] = this.cbInpectName.SelectedValue;
  143. ServiceResultEntity sre = DoAsync(() =>
  144. {
  145. return PCModuleProxyNew.Service.HandleRequest(cre);
  146. });
  147. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  148. {
  149. if (tabControl1.SelectedIndex == 0) {
  150. List<string> ss = new List<string>();
  151. for (int j = 0; j < this.dgvQCdata.Columns.Count; j++)
  152. {
  153. if (!sre.Data.Tables[0].Columns.Contains(this.dgvQCdata.Columns[j].Name))
  154. {
  155. ss.Add(this.dgvQCdata.Columns[j].Name);
  156. }
  157. }
  158. for (int y = 0; y < ss.Count; y++)
  159. {
  160. this.dgvQCdata.Columns.Remove(ss[y]);
  161. }
  162. dgvBarcode.DataSource = sre.Data.Tables[1];
  163. }
  164. if (tabControl1.SelectedIndex == 1) {
  165. for (int i = 0; i < sre.Data.Tables[0].Columns.Count; i++)
  166. {
  167. string columns = sre.Data.Tables[0].Columns[i].ColumnName;
  168. if (!this.dgvQCdata.Columns.Contains(columns))
  169. {
  170. DataGridViewTextBoxColumn d = new DataGridViewTextBoxColumn();
  171. this.dgvQCdata.Columns.AddRange(new DataGridViewColumn[] { d });
  172. d.DataPropertyName = columns;
  173. d.HeaderText = columns;
  174. d.Name = columns;
  175. d.ReadOnly = true;
  176. }
  177. }
  178. dgvQCdata.DataSource = sre.Data.Tables[0];
  179. }
  180. tsbtnAdaptive_Click(null, null);
  181. }
  182. else
  183. {
  184. // 提示未查找到数据
  185. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  186. MessageBoxButtons.OK, MessageBoxIcon.Information);
  187. }
  188. }
  189. catch (Exception ex)
  190. {
  191. this.btnSearch.Enabled = true;
  192. this.btnClearCondition.Enabled = true;
  193. // 对异常进行共通处理
  194. ExceptionManager.HandleEventException(this.ToString(),
  195. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  196. }
  197. }
  198. /// <summary>
  199. /// 清空条件按钮事件
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. private void btnClearCondition_Click(object sender, EventArgs e)
  204. {
  205. this.dtpCreateTimeBegin.Value = DateTime.Now.Date;
  206. this.dtpCreateTimeEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  207. this.txtBarCode.Text = "";
  208. this.cbInpectName.SelectedValue = 1;
  209. }
  210. /// <summary>
  211. /// 导出
  212. /// </summary>
  213. /// <param name="sender"></param>
  214. /// <param name="e"></param>
  215. private void tsbtnEdit_Click(object sender, EventArgs e)
  216. {
  217. try
  218. {
  219. if (this.dgvBarcode.CurrentCell != null)
  220. {
  221. DataRowView dr = (DataRowView)this.dgvBarcode.CurrentRow.DataBoundItem;
  222. string barcode = dr["BARCODE"].ToString();
  223. string inspectname = dr["inspectname"].ToString();
  224. string goUrl = "http://172.18.32.32:9100/main/excel/excelRW.ashx";
  225. System.Diagnostics.Process.Start(goUrl + "?barcode=" + barcode + "&inspectname="+ inspectname);
  226. }
  227. }
  228. catch (Exception ex)
  229. {
  230. this.btnSearch.Enabled = true;
  231. this.btnClearCondition.Enabled = true;
  232. // 对异常进行共通处理
  233. ExceptionManager.HandleEventException(this.ToString(),
  234. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  235. }
  236. }
  237. /// <summary>
  238. /// 双击编辑
  239. /// </summary>
  240. /// <param name="sender"></param>
  241. /// <param name="e"></param>
  242. private void dgvBarcodeIdnrk_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  243. {
  244. try
  245. {
  246. if (this.dgvQCdata.CurrentCell != null)
  247. {
  248. tsbtnEdit_Click(null, null);
  249. }
  250. }
  251. catch (Exception ex)
  252. {
  253. this.btnSearch.Enabled = true;
  254. this.btnClearCondition.Enabled = true;
  255. // 对异常进行共通处理
  256. ExceptionManager.HandleEventException(this.ToString(),
  257. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  258. }
  259. }
  260. #endregion
  261. }
  262. }