F_RPT_040106.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_040104.cs
  5. * 2.功能描述:产成品质量分析表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/05/11 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  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.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.ReportModule
  22. {
  23. public partial class F_RPT_040106 : DKDockPanelBase
  24. {
  25. #region 成员变量
  26. // 窗体的单例模式
  27. private static F_RPT_040106 _instance;
  28. //默认清空生产线,重置回用户当前权限生产线
  29. private string _currentUserLinePuview = null;
  30. #endregion
  31. #region 构造函数
  32. public F_RPT_040106()
  33. {
  34. InitializeComponent();
  35. // 窗体显示的Title
  36. this.Text = FormTitles.F_RPT_040106;
  37. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  38. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  39. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  40. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  41. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  42. }
  43. #endregion
  44. #region 单例模式
  45. /// <summary>
  46. /// 单例模式,防止重复创建窗体
  47. /// </summary>
  48. public static F_RPT_040106 Instance
  49. {
  50. get
  51. {
  52. if (_instance == null || _instance.IsDisposed)
  53. {
  54. _instance = new F_RPT_040106();
  55. }
  56. return _instance;
  57. }
  58. }
  59. #endregion
  60. #region 事件处理
  61. /// <summary>
  62. /// 窗体加载事件
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void F_RPT_040104_Load(object sender, EventArgs e)
  67. {
  68. try
  69. {
  70. //lblKilnCode.Visible = true;
  71. //dropKilnCode.Visible = true;
  72. // 加载权限
  73. FormPermissionManager.FormPermissionControl(this.Name, this,
  74. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  75. //绑定下了列表
  76. BindPage();
  77. // 设置表格不自动创建列
  78. this.dgvRptProcedure.AutoGenerateColumns = false;
  79. this.dropRptProcedure.Focus();
  80. //this.dkproductionLineSearchBox.IsEnablePurview = true;
  81. // 初始化时间控件为当前日期
  82. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  83. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  84. this.RecyclingflagCheckBox1.FalseItemCheck();
  85. getPurviewLine();
  86. //this.dkCJProcedureSearchBox.IsEnablePurview = true;//add xiacm 2022-11-02
  87. //getPurview();//add xiacm 2022-11-02
  88. }
  89. catch (Exception ex)
  90. {
  91. // 对异常进行共通处理
  92. ExceptionManager.HandleEventException(this.ToString(),
  93. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  94. }
  95. }
  96. /// <summary>
  97. /// 自动适应列宽
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  102. {
  103. this.dgvRptProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  104. }
  105. /// <summary>
  106. /// 窗体关闭事件
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. private void F_RPT_040104_FormClosed(object sender, FormClosedEventArgs e)
  111. {
  112. _instance = null;
  113. }
  114. /// <summary>
  115. /// 关闭按钮
  116. /// </summary>
  117. /// <param name="sender"></param>
  118. /// <param name="e"></param>
  119. private void tsbtnClose_Click(object sender, EventArgs e)
  120. {
  121. this.Close();
  122. }
  123. /// <summary>
  124. /// 查询按钮事件
  125. /// </summary>
  126. /// <param name="sender"></param>
  127. /// <param name="e"></param>
  128. private void btnSearch_Click(object sender, EventArgs e)
  129. {
  130. try
  131. {
  132. this.dgvRptProcedure.DataSource = null;
  133. this.dgvRptProcedure.DataSource = this.GetSearchData();
  134. }
  135. catch (Exception ex)
  136. {
  137. this.btnSearch.Enabled = true;
  138. this.btnClearCondition.Enabled = true;
  139. // 对异常进行共通处理
  140. ExceptionManager.HandleEventException(this.ToString(),
  141. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  142. }
  143. }
  144. /// <summary>
  145. /// 清空条件按钮事件
  146. /// </summary>
  147. /// <param name="sender"></param>
  148. /// <param name="e"></param>
  149. private void btnClearCondition_Click(object sender, EventArgs e)
  150. {
  151. //this.dropKilnCode.Text = string.Empty;
  152. this.dropKilnCode.SelectedIndex = 0;
  153. //this.dkGoodsSearchBox.ClearControl();
  154. //this.dkGoodsTypeSearchBox.ClearControl();
  155. //this.dkproductionLineSearchBox.ClearControl();
  156. this.dkProcedureSearchBox3.ClearControl();
  157. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  158. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  159. this.txtDefectCode.Clear();
  160. this.txtDefectName.Clear();
  161. this.RecyclingflagCheckBox1.FalseItemCheck();
  162. //this.dkGroutingLineSearchBox.ClearControl();
  163. //this.dkUserInfoSearchBox.ClearControl();
  164. this.chkOutKilnNum.Checked = true;
  165. //this.dkCJProcedureSearchBox.ClearControl();//add xiacm 2022-11-02
  166. }
  167. #endregion
  168. #region 私有方法
  169. /// <summary>
  170. /// 根据界面查询条件获取数据集
  171. /// </summary>
  172. private DataTable GetSearchData()
  173. {
  174. try
  175. {
  176. RPT040106_SE se = new RPT040106_SE();
  177. if (string.IsNullOrEmpty(this.dropRptProcedure.Text))
  178. {
  179. this.dropRptProcedure.Focus();
  180. return null;
  181. }
  182. //se.RptProcedureID = Convert.ToInt32(this.dropRptProcedure.SelectedValue);
  183. DataRowView drv = this.dropRptProcedure.SelectedItem as DataRowView;
  184. if (drv == null)
  185. {
  186. return null;
  187. }
  188. //获取数据来源工序Id
  189. //ServiceResultEntity sre0 = this.DoAsync<ServiceResultEntity>(() =>
  190. //{
  191. // return ReportModuleProxy.Service.GetRptSourceProcedureModule(se.RptProcedureID);
  192. //}
  193. //);
  194. //if (sre0.Data != null && sre0.Data.Tables.Count > 0)
  195. //{
  196. // se.RptSProcedureID = int.Parse(sre0.Data.Tables[0].Rows[Constant.INT_IS_ZERO]["Procedureid"].ToString());
  197. //}
  198. se.RptSProcedureID = Convert.ToInt32(drv["SProcedureID"]);
  199. if (!this.dropKilnCode.Text.Equals(Constant.CBO_SELECT_ALL_NAME))
  200. {
  201. se.KilnID = Convert.ToInt32(this.dropKilnCode.SelectedValue);
  202. }
  203. // 质量工序id
  204. se.ProcedureIDS = dkProcedureSearchBox3.ProcedureIDS == null ? string.Empty : dkProcedureSearchBox3.ProcedureIDS;
  205. //se.CJprocedureids = dkCJProcedureSearchBox.ProcedureIDS; //add xiacm 2022-11-09
  206. se.CreateTimeStart = this.dtpAccountDateStart.Value;
  207. se.CreateTimeEnd = this.dtpAccountDateEnd.Value;
  208. se.DefectCode = this.txtDefectCode.Text.Trim();
  209. se.DefectName = this.txtDefectName.Text.Trim();
  210. se.OutKilnNumByGoodsType = this.chkOutKilnNum.Checked;
  211. object[] testRecyclingflag = this.RecyclingflagCheckBox1.SelectedValues;
  212. if (testRecyclingflag.Length == 1)
  213. {
  214. se.TestRecyclingflag = testRecyclingflag[0].ToString();
  215. }
  216. // 调用服务器端获取数据集
  217. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  218. {
  219. return ReportModuleProxy.Service.GetRPT040106SData(se);
  220. }
  221. );
  222. if (sre.Status == Constant.ServiceResultStatus.Success)
  223. {
  224. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  225. {
  226. // 提示未查找到数据
  227. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  228. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  229. //清空数据
  230. return null;
  231. }
  232. return sre.Data.Tables[0];
  233. }
  234. return null;
  235. }
  236. catch (Exception ex)
  237. {
  238. throw ex;
  239. }
  240. }
  241. /// <summary>
  242. /// 绑定下拉列表值
  243. /// </summary>
  244. /// <returns></returns>
  245. private void BindPage()
  246. {
  247. //绑定数据来源下拉列表
  248. ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
  249. {
  250. return ReportModuleProxy.Service.GetRptProcedureModule();
  251. }
  252. );
  253. this.dropRptProcedure.DataSource = sre1.Data.Tables[Constant.INT_IS_ZERO];
  254. this.dropRptProcedure.ValueMember = "Rptprocedureid";
  255. this.dropRptProcedure.DisplayMember = "Rptprocedurename";
  256. //绑定窑炉下来列表
  257. ServiceResultEntity sre2 = DoAsync<ServiceResultEntity>(() =>
  258. {
  259. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  260. return ReportModuleProxy.Service.GetKilnData(byFlage);
  261. }
  262. );
  263. DataTable dtKilnInfo = sre2.Data.Tables[Constant.INT_IS_ZERO];
  264. DataRow newRowDic = dtKilnInfo.NewRow();
  265. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  266. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_NAME;
  267. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  268. this.dropKilnCode.DataSource = dtKilnInfo;
  269. this.dropKilnCode.ValueMember = "KilnID";
  270. this.dropKilnCode.DisplayMember = "KilnCode";
  271. }
  272. /// <summary>
  273. /// 获取权限(生产线)
  274. /// </summary>
  275. protected void getPurviewLine()
  276. {
  277. /*
  278. try
  279. {
  280. StringBuilder sbProcedurePurview = new StringBuilder();
  281. //得到工序查看权限
  282. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  283. {
  284. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  285. }));
  286. if (dsProcedurePurview != null)
  287. {
  288. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  289. if (drPurview.Length == 0)
  290. {
  291. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  292. {
  293. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  294. }
  295. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  296. {
  297. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  298. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  299. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  300. }
  301. }
  302. else
  303. {
  304. ProductionLineEntity line = new ProductionLineEntity();
  305. line.ValueFlags = new object[] { 1 };
  306. dsProcedurePurview = (DataSet)DoAsync(() =>
  307. {
  308. return PCModuleProxy.Service.SearchProductionLine(line);
  309. });
  310. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  311. {
  312. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  313. }
  314. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  315. {
  316. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  317. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  318. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  319. }
  320. }
  321. }
  322. }
  323. catch (Exception ex)
  324. {
  325. throw ex;
  326. }
  327. */
  328. }
  329. // /// <summary>
  330. ///// 获取权限(成检工序)
  331. ///// </summary>
  332. //protected void getPurview()
  333. // {
  334. // try
  335. // {
  336. // StringBuilder sbProcedurePurview = new StringBuilder();
  337. // StringBuilder CJProcedure = new StringBuilder();
  338. // //得到工序查看权限
  339. // DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  340. // {
  341. // return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  342. // }));
  343. // if (dsProcedurePurview != null)
  344. // {
  345. // DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  346. // if (drPurview.Length == 0)
  347. // {
  348. // foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  349. // {
  350. // sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  351. // }
  352. // if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  353. // {
  354. // //add xiacm 2022-10-25 成检工序数据
  355. // this.dkCJProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  356. // SearchProductionLineEntity line = new SearchProductionLineEntity();
  357. // DataSet dsCJProcedure = SystemModuleProxy.Service.GetProdureList(line);
  358. // DataRow[] drCJProcedure = dsCJProcedure.Tables[Constant.INT_IS_ZERO].Select("FINISHEDCHECKPROCEDUREID is not null and ProcedureID in (" + sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1) + ")");
  359. // foreach (DataRow item in drCJProcedure)
  360. // {
  361. // CJProcedure.Append(item["FINISHEDCHECKPROCEDUREID"].ToString() + ",");
  362. // }
  363. // if (CJProcedure.Length > 0)
  364. // {
  365. // this.dkCJProcedureSearchBox.Purview = CJProcedure.ToString().Substring(Constant.INT_IS_ZERO, CJProcedure.Length - 1);
  366. // }
  367. // }
  368. // }
  369. // else
  370. // {
  371. // SearchProductionLineEntity line = new SearchProductionLineEntity();
  372. // dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  373. // foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  374. // {
  375. // sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  376. // }
  377. // if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  378. // {
  379. // //add xiacm 2022-10-25 成检工序数据
  380. // this.dkCJProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  381. // DataRow[] drCJProcedure = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("FINISHEDCHECKPROCEDUREID is not null and ProcedureID in (" + sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1) + ")");
  382. // foreach (DataRow item in drCJProcedure)
  383. // {
  384. // CJProcedure.Append(item["FINISHEDCHECKPROCEDUREID"].ToString() + ",");
  385. // }
  386. // if (CJProcedure.Length > 0)
  387. // {
  388. // this.dkCJProcedureSearchBox.Purview = CJProcedure.ToString().Substring(Constant.INT_IS_ZERO, CJProcedure.Length - 1);
  389. // }
  390. // }
  391. // }
  392. // }
  393. // }
  394. // catch (Exception ex)
  395. // {
  396. // throw ex;
  397. // }
  398. // }
  399. #endregion
  400. private void dgvRptProcedure_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  401. {
  402. //string colName = this.dgvRptProcedure.Columns[e.ColumnIndex].Name;
  403. //if ("DefectPercent1" == colName)
  404. //{
  405. // if(Convert.ToDecimal(e.Value) == -1)
  406. // {
  407. // e.Value = "N/A";
  408. // }
  409. //}
  410. }
  411. }
  412. }