F_RPT_040106.cs 19 KB

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