F_RPT_040103.cs 13 KB

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