F_RPT_080116.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_080116.cs
  5. * 2.功能描述:QC检验分析汇总表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 秦祺 2022/12/09 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using System.Linq;
  14. using System.Collections.Generic;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.Client.PMModule;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. using Dongke.IBOSS.PRD.WCF.Proxys;
  22. namespace Dongke.IBOSS.PRD.Client.ReportModule
  23. {
  24. public partial class F_RPT_080116 : DKDockPanelBase
  25. {
  26. #region 成员变量
  27. // 窗体的单例模式
  28. private static F_RPT_080116 _instance;
  29. #region 定义数据类型
  30. //输入模糊查询字段之后,返回的关键词
  31. System.Collections.Generic.List<cbinpectname> listNew = new List<cbinpectname>();
  32. //下拉框初始化数据绑定
  33. List<cbinpectname> listOnit = new List<cbinpectname>();
  34. //数据库查询原始数据
  35. List<cbinpectnameType> selectList = new List<cbinpectnameType>();
  36. /// <summary>
  37. /// 空间所需类
  38. /// </summary>
  39. public class cbinpectname
  40. {
  41. /// <summary>
  42. /// id
  43. /// </summary>
  44. public string ITEMSID { get; set; }
  45. /// <summary>
  46. /// 检验类型
  47. /// </summary>
  48. public string INSPECTTYPE { get; set; }
  49. /// <summary>
  50. /// 名称
  51. /// </summary>
  52. public string INSPECTNAME { get; set; }
  53. }
  54. /// <summary>
  55. /// 数据库查询数据返回类
  56. /// </summary>
  57. public class cbinpectnameType : cbinpectname
  58. {
  59. /// <summary>
  60. /// 版本号
  61. /// </summary>
  62. public string INSPECTVERSION { get; set; }
  63. /// <summary>
  64. /// 是否有效
  65. /// </summary>
  66. public string VALUEFLAG { get; set; }
  67. }
  68. #endregion
  69. #endregion
  70. #region 构造函数
  71. public F_RPT_080116()
  72. {
  73. InitializeComponent();
  74. // 窗体显示的Title
  75. this.Text = "QC检验分析汇总表";
  76. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  77. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  78. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  79. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  80. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  81. }
  82. #endregion
  83. #region 单例模式
  84. /// <summary>
  85. /// 单例模式,防止重复创建窗体
  86. /// </summary>
  87. public static F_RPT_080116 Instance
  88. {
  89. get
  90. {
  91. if (_instance == null || _instance.IsDisposed)
  92. {
  93. _instance = new F_RPT_080116();
  94. }
  95. return _instance;
  96. }
  97. }
  98. #endregion
  99. #region 事件处理
  100. /// <summary>
  101. /// 窗体加载事件
  102. /// </summary>
  103. /// <param name="sender"></param>
  104. /// <param name="e"></param>
  105. private void F_RPT_080116_Load(object sender, EventArgs e)
  106. {
  107. try
  108. {
  109. // 加载权限
  110. FormPermissionManager.FormPermissionControl(this.Name, this,
  111. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  112. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  113. this.dtpCreateTimeBegin.Value = DateTime.Now.Date;
  114. this.dtpCreateTimeEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  115. // 设置表格不自动创建列
  116. this.dgvBarcodeIdnrk.AutoGenerateColumns = false;
  117. // 检验标准名称
  118. //绑定检验类型
  119. ClientRequestEntity cre = new ClientRequestEntity();
  120. cre.NameSpace = "F_RPT_080116";
  121. cre.Name = "GetInspectName";
  122. ServiceResultEntity sre = DoAsync(() =>
  123. {
  124. return PCModuleProxyNew.Service.HandleRequest(cre);
  125. });
  126. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  127. {
  128. //将查询的数据转换成List
  129. DataTable dt = sre.Data.Tables[0];
  130. for (int i = 0; i < dt.Rows.Count; i++)
  131. {
  132. var item = dt.Rows[i];
  133. selectList.Add(new cbinpectnameType
  134. {
  135. ITEMSID = item.ItemArray[0].ToString(),
  136. INSPECTTYPE = item.ItemArray[1].ToString(),
  137. INSPECTNAME = item.ItemArray[2].ToString(),
  138. INSPECTVERSION = item.ItemArray[3].ToString(),
  139. VALUEFLAG = item.ItemArray[4].ToString()
  140. });
  141. }
  142. this.cbInpectName.DisplayMember = "INSPECTNAME";
  143. this.cbInpectName.ValueMember = "ITEMSID";
  144. //this.cbInpectName.DataSource = sre.Data.Tables[0];
  145. handle(radioButton1.Checked, radioButton3.Checked);
  146. }
  147. }
  148. catch (Exception ex)
  149. {
  150. // 对异常进行共通处理
  151. ExceptionManager.HandleEventException(this.ToString(),
  152. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  153. }
  154. }
  155. /// <summary>
  156. /// 自动适应列宽
  157. /// </summary>
  158. /// <param name="sender"></param>
  159. /// <param name="e"></param>
  160. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  161. {
  162. this.dgvBarcodeIdnrk.AutoResizeColumns();
  163. }
  164. /// <summary>
  165. /// 窗体关闭事件
  166. /// </summary>
  167. /// <param name="sender"></param>
  168. /// <param name="e"></param>
  169. private void F_RPT_080116_FormClosed(object sender, FormClosedEventArgs e)
  170. {
  171. _instance = null;
  172. }
  173. /// <summary>
  174. /// 关闭按钮
  175. /// </summary>
  176. /// <param name="sender"></param>
  177. /// <param name="e"></param>
  178. private void tsbtnClose_Click(object sender, EventArgs e)
  179. {
  180. this.Close();
  181. }
  182. /// <summary>
  183. /// 查询按钮事件
  184. /// </summary>
  185. /// <param name="sender"></param>
  186. /// <param name="e"></param>
  187. private void btnSearch_Click(object sender, EventArgs e)
  188. {
  189. if (this.cbInpectName.Text.Length == 0)
  190. {
  191. MessageBox.Show("请选择检验标准名称", this.Text,
  192. MessageBoxButtons.OK, MessageBoxIcon.Information);
  193. return;
  194. }
  195. try
  196. {
  197. this.dgvBarcodeIdnrk.DataSource = null;
  198. ClientRequestEntity cre = new ClientRequestEntity();
  199. cre.NameSpace = "F_RPT_080116";
  200. cre.Name = "Get080116Detail";
  201. cre.Properties["CreateTimeBegin"] = this.dtpCreateTimeBegin.Value;
  202. cre.Properties["CreateTimeEnd"] = Convert.ToDateTime(this.dtpCreateTimeEnd.Value).AddSeconds(1);
  203. // cre.Properties["ITEMSID"] = this.cbInpectName.SelectedValue;
  204. cre.Properties["ITEMSID"] = listOnit.Where(ex => ex.INSPECTNAME == this.cbInpectName.Text).FirstOrDefault().ITEMSID;
  205. ServiceResultEntity sre = DoAsync(() =>
  206. {
  207. return PCModuleProxyNew.Service.HandleRequest(cre);
  208. });
  209. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  210. {
  211. dgvBarcodeIdnrk.DataSource = sre.Data.Tables[0];
  212. tsbtnAdaptive_Click(null, null);
  213. }
  214. else
  215. {
  216. // 提示未查找到数据
  217. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  218. MessageBoxButtons.OK, MessageBoxIcon.Information);
  219. }
  220. }
  221. catch (Exception ex)
  222. {
  223. this.btnSearch.Enabled = true;
  224. this.btnClearCondition.Enabled = true;
  225. // 对异常进行共通处理
  226. ExceptionManager.HandleEventException(this.ToString(),
  227. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  228. }
  229. }
  230. /// <summary>
  231. /// 清空条件按钮事件
  232. /// </summary>
  233. /// <param name="sender"></param>
  234. /// <param name="e"></param>
  235. private void btnClearCondition_Click(object sender, EventArgs e)
  236. {
  237. this.dtpCreateTimeBegin.Value = DateTime.Now.Date;
  238. this.dtpCreateTimeEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  239. this.cbInpectName.SelectedValue = 1;
  240. //清空combobox
  241. this.cbInpectName.Text = "";
  242. this.cbInpectName.Items.Clear();
  243. this.cbInpectName.Items.AddRange(listOnit.ToArray());
  244. }
  245. /// <summary>
  246. /// 编辑
  247. /// </summary>
  248. /// <param name="sender"></param>
  249. /// <param name="e"></param>
  250. private void tsbtnEdit_Click(object sender, EventArgs e)
  251. {
  252. try
  253. {
  254. if (this.dgvBarcodeIdnrk.CurrentCell != null)
  255. {
  256. F_RPT_080111 frm080111 = new F_RPT_080111();
  257. frm080111.DrValue = (this.dgvBarcodeIdnrk.CurrentRow.DataBoundItem as DataRowView).Row;
  258. frm080111.ShowDialog();
  259. if (DialogResult.OK.Equals(frm080111.DialogResult))
  260. {
  261. btnSearch_Click(null, null);
  262. }
  263. }
  264. }
  265. catch (Exception ex)
  266. {
  267. this.btnSearch.Enabled = true;
  268. this.btnClearCondition.Enabled = true;
  269. // 对异常进行共通处理
  270. ExceptionManager.HandleEventException(this.ToString(),
  271. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  272. }
  273. }
  274. /// <summary>
  275. /// 双击编辑
  276. /// </summary>
  277. /// <param name="sender"></param>
  278. /// <param name="e"></param>
  279. private void dgvBarcodeIdnrk_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  280. {
  281. try
  282. {
  283. if (this.dgvBarcodeIdnrk.CurrentRow == null)
  284. {
  285. return;
  286. }
  287. //获取数据信息
  288. DataGridViewRow dgvr = dgvBarcodeIdnrk.CurrentRow;
  289. string INSPECTITEM = dgvr.Cells["INSPECTITEM"].Value.ToString();
  290. //跳转页
  291. this.tabControl1.SelectTab(1);
  292. //清空数据
  293. this.dgvQCdata.DataSource = null;
  294. this.dgvQCdata.DataSource = GetSearchDetailData(INSPECTITEM);
  295. }
  296. catch (Exception ex)
  297. {
  298. this.btnSearch.Enabled = true;
  299. this.btnClearCondition.Enabled = true;
  300. // 对异常进行共通处理
  301. ExceptionManager.HandleEventException(this.ToString(),
  302. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  303. }
  304. }
  305. /// <summary>
  306. /// 查询检验计划明细
  307. /// </summary>
  308. private DataTable GetSearchDetailData(string INSPECTITEM)
  309. {
  310. try
  311. {
  312. ClientRequestEntity cre = new ClientRequestEntity();
  313. cre.NameSpace = "F_RPT_080116";
  314. cre.Name = "GetDetailInspection";
  315. cre.Properties["INSPECTITEM"] = INSPECTITEM;
  316. cre.Properties["CreateTimeBegin"] = this.dtpCreateTimeBegin.Value;
  317. cre.Properties["CreateTimeEnd"] = Convert.ToDateTime(this.dtpCreateTimeEnd.Value).AddSeconds(1);
  318. ServiceResultEntity sre = DoAsync(() =>
  319. {
  320. return PCModuleProxyNew.Service.HandleRequest(cre);
  321. });
  322. if (sre.Data != null && sre.Data.Tables.Count > 0 && sre.Data.Tables[0].Rows.Count > 0)
  323. {
  324. return sre.Data.Tables[0];
  325. }
  326. else
  327. {
  328. return null;
  329. // 提示未查找到数据
  330. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  331. MessageBoxButtons.OK, MessageBoxIcon.Information);
  332. }
  333. }
  334. catch (Exception ex)
  335. {
  336. throw ex;
  337. }
  338. }
  339. #region 模糊查询 历史版本和型式检验 及数据处理
  340. /// <summary>
  341. /// 模糊查询
  342. /// </summary>
  343. /// <param name="sender"></param>
  344. /// <param name="e"></param>
  345. private void cbInpectNameText_Updata(object sender, EventArgs e)
  346. {
  347. //清空combobox
  348. this.cbInpectName.Items.Clear();
  349. //清空listNew
  350. listNew.Clear();
  351. //遍历全部备查数据
  352. foreach (var item in listOnit)
  353. {
  354. if (item.INSPECTNAME.Contains(this.cbInpectName.Text))
  355. {
  356. //符合,插入ListNew
  357. listNew.Add(item);
  358. }
  359. }
  360. //combobox添加已经查到的关键词
  361. this.cbInpectName.Items.AddRange(listNew.ToArray());
  362. //设置光标位置,否则光标位置始终保持在第一列,造成输入关键词的倒序排列
  363. this.cbInpectName.SelectionStart = this.cbInpectName.Text.Length;
  364. //保持鼠标指针原来状态,有时候鼠标指针会被下拉框覆盖,所以要进行一次设置。
  365. Cursor = Cursors.Default;
  366. //自动弹出下拉框
  367. this.cbInpectName.DroppedDown = true;
  368. }
  369. /// <summary>
  370. /// 数据处理
  371. /// </summary>
  372. /// <param name="a">是否显示历史版本</param>
  373. /// <param name="b">是否显示型式检验</param>
  374. private void handle(bool a, bool b)
  375. {
  376. //清除初始数据
  377. this.cbInpectName.Items.Clear();
  378. listOnit.Clear();
  379. //赋值数据以便筛选
  380. var list = selectList;
  381. //不显示历史版本
  382. if (!a)
  383. {
  384. list = list.Where(ex => ex.VALUEFLAG == "1").ToList();
  385. }
  386. // 型式检验
  387. list = !b ? list.Where(ex => ex.INSPECTTYPE != "615").ToList() : list.Where(ex => ex.INSPECTTYPE == "615").ToList();
  388. //遍历符合数据
  389. foreach (var item in list)
  390. {
  391. //按要求将数据装入listOnit中
  392. listOnit.Add(new cbinpectname
  393. {
  394. ITEMSID = item.ITEMSID,
  395. INSPECTTYPE = item.INSPECTTYPE,
  396. INSPECTNAME = a ? item.INSPECTNAME + "[版本:" + item.INSPECTVERSION + "]" : item.INSPECTNAME
  397. });
  398. }
  399. //赋值给控件
  400. this.cbInpectName.Items.AddRange(listOnit.ToArray());
  401. }
  402. /// <summary>
  403. /// 是否按钮数据切换
  404. /// </summary>
  405. /// <param name="sender"></param>
  406. /// <param name="e"></param>
  407. private void RadioButton_CheckedChanged(object sender, EventArgs e)
  408. {
  409. //滤除第一遍的请求
  410. if (!((RadioButton)sender).Checked)
  411. {
  412. return;
  413. }
  414. handle(radioButton1.Checked, radioButton3.Checked);
  415. }
  416. #endregion
  417. #endregion
  418. }
  419. }