F_RPT_040103.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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. getPurview();
  90. getPurviewLine();
  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.dgvRptProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  107. }
  108. /// <summary>
  109. /// 窗体关闭事件
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void F_RPT_040103_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. if (string.IsNullOrEmpty(this._currentUserPurview))
  136. {
  137. // 提示未查找到数据
  138. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  139. MessageBoxButtons.OK, MessageBoxIcon.Information);
  140. return;
  141. }
  142. this.dgvRptProcedure.DataSource = null;
  143. this.dgvRptProcedure.DataSource = this.GetSearchData();
  144. }
  145. catch (Exception ex)
  146. {
  147. this.btnSearch.Enabled = true;
  148. this.btnClearCondition.Enabled = true;
  149. // 对异常进行共通处理
  150. ExceptionManager.HandleEventException(this.ToString(),
  151. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  152. }
  153. }
  154. /// <summary>
  155. /// 清空条件按钮事件
  156. /// </summary>
  157. /// <param name="sender"></param>
  158. /// <param name="e"></param>
  159. private void btnClearCondition_Click(object sender, EventArgs e)
  160. {
  161. //this.dropKilnCode.Text = string.Empty;
  162. this.dropKilnCode.SelectedIndex = 0;
  163. this.scbGoods.ClearValue();
  164. this.scbGoodsType.ClearValue();
  165. this.dkProcedureSearchBox.ClearControl();
  166. this.dkproductionLineSearchBox.ClearControl();
  167. this.dkUserInfoSearchBox.ClearControl();
  168. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  169. this.dtpAccountDateEnd.Value = DateTime.Now.Date;
  170. this.dkProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
  171. }
  172. #endregion
  173. #region 私有方法
  174. /// <summary>
  175. /// 根据界面查询条件获取数据集
  176. /// </summary>
  177. private DataTable GetSearchData()
  178. {
  179. try
  180. {
  181. RPT040103_SE se = new RPT040103_SE();
  182. if (string.IsNullOrEmpty(this.dropRptProcedure.Text))
  183. {
  184. this.dropRptProcedure.Focus();
  185. return null;
  186. }
  187. se.RptProcedureID = Convert.ToInt32(this.dropRptProcedure.SelectedValue);
  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. //获取数据来源工序Id
  199. se.RptTProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  200. se.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  201. se.UserIDS = this.dkUserInfoSearchBox.UserIDS;
  202. se.GoodsIDS = scbGoods.CheckedPKMember;
  203. se.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
  204. if (!this.dropKilnCode.Text.Equals(Constant.CBO_SELECT_ALL_NAME))
  205. {
  206. se.KilnID = Convert.ToInt32(this.dropKilnCode.SelectedValue);
  207. }
  208. //se.CreateTimeStart = DateTime.Parse(this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd") + " 00:00:00");
  209. //se.CreateTimeEnd = DateTime.Parse(this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  210. se.CreateTimeStart = this.dtpAccountDateStart.Value.Date;
  211. se.CreateTimeEnd = this.dtpAccountDateEnd.Value.AddDays(1).Date;
  212. // 调用服务器端获取数据集
  213. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  214. {
  215. return ReportModuleProxy.Service.GetRPT040103SData(se);
  216. }
  217. );
  218. if (sre.Status == Constant.ServiceResultStatus.Success)
  219. {
  220. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  221. {
  222. // 提示未查找到数据
  223. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  224. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  225. //清空数据
  226. return null;
  227. }
  228. return sre.Data.Tables[0];
  229. }
  230. return null;
  231. }
  232. catch (Exception ex)
  233. {
  234. throw ex;
  235. }
  236. }
  237. /// <summary>
  238. /// 绑定下拉列表值
  239. /// </summary>
  240. /// <returns></returns>
  241. private void BindPage()
  242. {
  243. //绑定数据来源下拉列表
  244. ServiceResultEntity sre1 = DoAsync<ServiceResultEntity>(() =>
  245. {
  246. return ReportModuleProxy.Service.GetRptProcedureModule();
  247. }
  248. );
  249. this.dropRptProcedure.DataSource = sre1.Data.Tables[Constant.INT_IS_ZERO];
  250. this.dropRptProcedure.ValueMember = "Rptprocedureid";
  251. this.dropRptProcedure.DisplayMember = "Rptprocedurename";
  252. //绑定窑炉下来列表
  253. ServiceResultEntity sre2 = DoAsync<ServiceResultEntity>(() =>
  254. {
  255. byte byFlage = Convert.ToByte(Constant.ValueFlag.Invalid);
  256. return ReportModuleProxy.Service.GetKilnData(byFlage);
  257. }
  258. );
  259. DataTable dtKilnInfo = sre2.Data.Tables[Constant.INT_IS_ZERO];
  260. DataRow newRowDic = dtKilnInfo.NewRow();
  261. newRowDic["KilnID"] = Constant.CBO_SELECT_ALL_VALUE;
  262. newRowDic["KilnCode"] = Constant.CBO_SELECT_ALL_NAME;
  263. dtKilnInfo.Rows.InsertAt(newRowDic, Constant.INT_IS_ZERO);
  264. this.dropKilnCode.DataSource = dtKilnInfo;
  265. this.dropKilnCode.ValueMember = "KilnID";
  266. this.dropKilnCode.DisplayMember = "KilnCode";
  267. }
  268. /// <summary>
  269. /// 获取权限
  270. /// </summary>
  271. protected void getPurview()
  272. {
  273. try
  274. {
  275. StringBuilder sbProcedurePurview = new StringBuilder();
  276. //得到工序查看权限
  277. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  278. {
  279. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  280. }));
  281. if (dsProcedurePurview != null)
  282. {
  283. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  284. if (drPurview.Length == 0)
  285. {
  286. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  287. {
  288. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  289. }
  290. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  291. {
  292. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  293. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  294. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  295. }
  296. }
  297. else
  298. {
  299. SearchProductionLineEntity line = new SearchProductionLineEntity();
  300. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  301. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  302. {
  303. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  304. }
  305. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  306. {
  307. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  308. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  309. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  310. }
  311. }
  312. }
  313. }
  314. catch (Exception ex)
  315. {
  316. throw ex;
  317. }
  318. }
  319. /// <summary>
  320. /// 获取权限(生产线)
  321. /// </summary>
  322. protected void getPurviewLine()
  323. {
  324. try
  325. {
  326. StringBuilder sbProcedurePurview = new StringBuilder();
  327. //得到工序查看权限
  328. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  329. {
  330. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  331. }));
  332. if (dsProcedurePurview != null)
  333. {
  334. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  335. if (drPurview.Length == 0)
  336. {
  337. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  338. {
  339. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  340. }
  341. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  342. {
  343. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  344. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  345. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  346. }
  347. }
  348. else
  349. {
  350. ProductionLineEntity line = new ProductionLineEntity();
  351. line.ValueFlags = new object[] { 1 };
  352. dsProcedurePurview = (DataSet)DoAsync(() =>
  353. {
  354. return PCModuleProxy.Service.SearchProductionLine(line);
  355. });
  356. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  357. {
  358. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  359. }
  360. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  361. {
  362. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  363. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  364. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  365. }
  366. }
  367. }
  368. }
  369. catch (Exception ex)
  370. {
  371. throw ex;
  372. }
  373. }
  374. #endregion
  375. }
  376. }