F_RPT_040103.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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. this.txtSTAFFNAME.Text = string.Empty;
  172. }
  173. #endregion
  174. #region 私有方法
  175. /// <summary>
  176. /// 根据界面查询条件获取数据集
  177. /// </summary>
  178. private DataTable GetSearchData()
  179. {
  180. try
  181. {
  182. RPT040103_SE se = new RPT040103_SE();
  183. if (string.IsNullOrEmpty(this.dropRptProcedure.Text))
  184. {
  185. this.dropRptProcedure.Focus();
  186. return null;
  187. }
  188. se.RptProcedureID = Convert.ToInt32(this.dropRptProcedure.SelectedValue);
  189. //获取数据来源工序Id
  190. ServiceResultEntity sre0 = this.DoAsync<ServiceResultEntity>(() =>
  191. {
  192. return ReportModuleProxy.Service.GetRptSourceProcedureModule(se.RptProcedureID);
  193. }
  194. );
  195. if (sre0.Data != null && sre0.Data.Tables.Count > 0)
  196. {
  197. se.RptSProcedureID = int.Parse(sre0.Data.Tables[0].Rows[Constant.INT_IS_ZERO]["Procedureid"].ToString());
  198. }
  199. //获取数据来源工序Id
  200. se.RptTProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  201. se.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  202. se.UserIDS = this.dkUserInfoSearchBox.UserIDS;
  203. se.GoodsIDS = scbGoods.CheckedPKMember;
  204. se.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
  205. if (!this.dropKilnCode.Text.Equals(Constant.CBO_SELECT_ALL_NAME))
  206. {
  207. se.KilnID = Convert.ToInt32(this.dropKilnCode.SelectedValue);
  208. }
  209. //se.CreateTimeStart = DateTime.Parse(this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd") + " 00:00:00");
  210. //se.CreateTimeEnd = DateTime.Parse(this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd") + " 23:59:59");
  211. se.CreateTimeStart = this.dtpAccountDateStart.Value.Date;
  212. se.CreateTimeEnd = this.dtpAccountDateEnd.Value.AddDays(1).Date;
  213. se.StaffName = this.txtSTAFFNAME.Text.Trim();
  214. // 调用服务器端获取数据集
  215. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  216. {
  217. return ReportModuleProxy.Service.GetRPT040103SData(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 getPurview()
  274. {
  275. try
  276. {
  277. StringBuilder sbProcedurePurview = new StringBuilder();
  278. //得到工序查看权限
  279. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  280. {
  281. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  282. }));
  283. if (dsProcedurePurview != null)
  284. {
  285. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  286. if (drPurview.Length == 0)
  287. {
  288. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  289. {
  290. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  291. }
  292. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  293. {
  294. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  295. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  296. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  297. }
  298. }
  299. else
  300. {
  301. SearchProductionLineEntity line = new SearchProductionLineEntity();
  302. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  303. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  304. {
  305. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  306. }
  307. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  308. {
  309. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  310. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  311. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  312. }
  313. }
  314. }
  315. }
  316. catch (Exception ex)
  317. {
  318. throw ex;
  319. }
  320. }
  321. /// <summary>
  322. /// 获取权限(生产线)
  323. /// </summary>
  324. protected void getPurviewLine()
  325. {
  326. try
  327. {
  328. StringBuilder sbProcedurePurview = new StringBuilder();
  329. //得到工序查看权限
  330. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  331. {
  332. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  333. }));
  334. if (dsProcedurePurview != null)
  335. {
  336. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  337. if (drPurview.Length == 0)
  338. {
  339. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  340. {
  341. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  342. }
  343. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  344. {
  345. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  346. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  347. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  348. }
  349. }
  350. else
  351. {
  352. ProductionLineEntity line = new ProductionLineEntity();
  353. line.ValueFlags = new object[] { 1 };
  354. dsProcedurePurview = (DataSet)DoAsync(() =>
  355. {
  356. return PCModuleProxy.Service.SearchProductionLine(line);
  357. });
  358. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  359. {
  360. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  361. }
  362. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  363. {
  364. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  365. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  366. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  367. }
  368. }
  369. }
  370. }
  371. catch (Exception ex)
  372. {
  373. throw ex;
  374. }
  375. }
  376. #endregion
  377. }
  378. }