F_RPT_030101_1.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_030101_1.cs
  5. * 2.功能描述:工序产量统计表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/4/14 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. /// <summary>
  24. /// 产品产量汇总表
  25. /// </summary>
  26. public partial class F_RPT_030101_1 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. // 窗体的单例模式
  30. private static F_RPT_030101_1 _instance;
  31. //实体类
  32. private RPT030101_SE rptse = new RPT030101_SE();
  33. //默认清空工序,重置回用户当前权限工序
  34. private string _currentUserPurview = null;
  35. //默认清空生产线,重置回用户当前权限生产线
  36. private string _currentUserLinePuview = null;
  37. #endregion
  38. #region 构造函数
  39. public F_RPT_030101_1()
  40. {
  41. InitializeComponent();
  42. // 窗体显示的Title
  43. this.Text = FormTitles.F_RPT_030101;
  44. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  45. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  46. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  47. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  48. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  49. }
  50. #endregion
  51. #region 单例模式
  52. /// <summary>
  53. /// 单例模式,防止重复创建窗体
  54. /// </summary>
  55. public static F_RPT_030101_1 Instance
  56. {
  57. get
  58. {
  59. if (_instance == null || _instance.IsDisposed)
  60. {
  61. _instance = new F_RPT_030101_1();
  62. }
  63. return _instance;
  64. }
  65. }
  66. #endregion
  67. #region 事件处理
  68. /// <summary>
  69. /// 窗体加载事件
  70. /// </summary>
  71. /// <param name="sender"></param>
  72. /// <param name="e"></param>
  73. private void F_RPT_030101_1_Load(object sender, EventArgs e)
  74. {
  75. try
  76. {
  77. // 加载权限
  78. FormPermissionManager.FormPermissionControl(this.Name, this,
  79. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  80. // 设置表格不自动创建列
  81. this.dgvReportModuleDetail.AutoGenerateColumns = false;
  82. this.dgvReportModule.AutoGenerateColumns = false;
  83. this.scbOrganization.Focus();
  84. this.dkproductionLineSearchBox.IsEnablePurview = true;
  85. this.dkProcedureSearchBox.IsEnablePurview = true;
  86. // 初始化时间控件为当前日期
  87. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  88. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  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. if (this.tblReportModule.SelectedIndex == Constant.INT_IS_ZERO)//产品产量汇总查询
  107. {
  108. this.dgvReportModule.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  109. }
  110. else//产品产量明细查询
  111. {
  112. this.dgvReportModuleDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  113. }
  114. }
  115. /// <summary>
  116. /// 窗体关闭事件
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. private void F_RPT_030101_1_FormClosed(object sender, FormClosedEventArgs e)
  121. {
  122. _instance = null;
  123. }
  124. /// <summary>
  125. /// 关闭按钮
  126. /// </summary>
  127. /// <param name="sender"></param>
  128. /// <param name="e"></param>
  129. private void tsbtnClose_Click(object sender, EventArgs e)
  130. {
  131. this.Close();
  132. }
  133. /// <summary>
  134. /// 查询按钮事件
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void btnSearch_Click(object sender, EventArgs e)
  139. {
  140. try
  141. {
  142. if (string.IsNullOrEmpty(this._currentUserPurview))
  143. {
  144. // 提示未查找到数据
  145. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  146. MessageBoxButtons.OK, MessageBoxIcon.Information);
  147. return;
  148. }
  149. CreateSearchCondition();
  150. if (this.tblReportModule.SelectedIndex == Constant.INT_IS_ZERO)
  151. {
  152. this.dgvReportModule.DataSource = null;
  153. this.dgvReportModule.DataSource = GetSearchTotalData();
  154. }
  155. else
  156. {
  157. this.dgvReportModuleDetail.DataSource = null;
  158. this.dgvReportModuleDetail.DataSource = GetSearchDetailData();
  159. }
  160. }
  161. catch (Exception ex)
  162. {
  163. this.btnSearch.Enabled = true;
  164. this.btnClearCondition.Enabled = true;
  165. // 对异常进行共通处理
  166. ExceptionManager.HandleEventException(this.ToString(),
  167. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  168. }
  169. }
  170. /// <summary>
  171. /// 清空条件按钮事件
  172. /// </summary>
  173. /// <param name="sender"></param>
  174. /// <param name="e"></param>
  175. private void btnClearCondition_Click(object sender, EventArgs e)
  176. {
  177. this.scbOrganization.ClearValue();
  178. this.scbGoods.ClearValue();
  179. this.scbGoodsType.ClearValue();
  180. this.dkProcedureSearchBox.ClearControl();
  181. this.dkproductionLineSearchBox.ClearControl();
  182. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  183. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  184. this.dkProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
  185. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
  186. this.chkFlag.Checked = false;
  187. }
  188. /// <summary>
  189. /// 双击单元格事件
  190. /// </summary>
  191. /// <param name="sender"></param>
  192. /// <param name="e"></param>
  193. private void dgvReportModule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  194. {
  195. try
  196. {
  197. if (this.dgvReportModule.CurrentRow == null)
  198. {
  199. return;
  200. }
  201. //获取数据信息
  202. DataGridViewRow dgvr = dgvReportModule.CurrentRow;
  203. string goodsId = dgvr.Cells["GoodsID"].Value.ToString();
  204. string procedureId = dgvr.Cells["Procedureid"].Value.ToString();
  205. if (goodsId.Equals("小计") || goodsId.Equals("--"))
  206. {
  207. return;
  208. }
  209. else
  210. {
  211. //跳转页
  212. this.tblReportModule.SelectTab(1);
  213. //获取条件
  214. CreateSearchCondition();
  215. rptse.GoodsIDS = goodsId.ToString();
  216. rptse.ProcedureIDS = procedureId.ToString();
  217. //清空数据
  218. this.dgvReportModuleDetail.DataSource = null;
  219. this.dgvReportModuleDetail.DataSource = GetSearchDetailData();
  220. }
  221. }
  222. catch (Exception ex)
  223. {
  224. this.btnSearch.Enabled = true;
  225. this.btnClearCondition.Enabled = true;
  226. // 对异常进行共通处理
  227. ExceptionManager.HandleEventException(this.ToString(),
  228. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  229. }
  230. }
  231. #endregion
  232. #region 私有方法
  233. /// <summary>
  234. /// 搜索条件
  235. /// </summary>
  236. /// <returns></returns>
  237. private void CreateSearchCondition()
  238. {
  239. rptse = new RPT030101_SE();
  240. rptse.OrganizationIDS = this.scbOrganization.CheckedPKMember;
  241. rptse.GoodsIDS = scbGoods.CheckedPKMember;
  242. rptse.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
  243. rptse.ProductionLineIDS = this.dkproductionLineSearchBox.ProductionLineIDS;
  244. rptse.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  245. rptse.AccountDateStart = DateTime.Parse(this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
  246. rptse.AccountDateEnd = DateTime.Parse(this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
  247. rptse.ProductionFlag = this.chkFlag.Checked ? "1" : "0";
  248. }
  249. /// <summary>
  250. /// 获取权限(生产线)
  251. /// </summary>
  252. protected void getPurviewLine()
  253. {
  254. try
  255. {
  256. StringBuilder sbProcedurePurview = new StringBuilder();
  257. //得到工序查看权限
  258. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  259. {
  260. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  261. }));
  262. if (dsProcedurePurview != null)
  263. {
  264. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  265. if (drPurview.Length == 0)
  266. {
  267. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  268. {
  269. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  270. }
  271. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  272. {
  273. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  274. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  275. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  276. }
  277. }
  278. else
  279. {
  280. ProductionLineEntity line = new ProductionLineEntity();
  281. line.ValueFlags = new object[] { 1 };
  282. dsProcedurePurview = (DataSet)DoAsync(() =>
  283. {
  284. return PCModuleProxy.Service.SearchProductionLine(line);
  285. });
  286. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  287. {
  288. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  289. }
  290. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  291. {
  292. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  293. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  294. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  295. }
  296. }
  297. }
  298. }
  299. catch (Exception ex)
  300. {
  301. throw ex;
  302. }
  303. }
  304. /// <summary>
  305. /// 查询产品产量汇总表
  306. /// </summary>
  307. private DataTable GetSearchTotalData()
  308. {
  309. try
  310. {
  311. // 调用服务器端获取数据集
  312. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  313. {
  314. return ReportModuleProxy.Service.GetRPT030101SData(rptse);
  315. }
  316. );
  317. if (sre.Status == Constant.ServiceResultStatus.Success)
  318. {
  319. //if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  320. //{
  321. // // 提示未查找到数据
  322. // MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  323. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  324. // //清空数据
  325. // return null;
  326. //}
  327. return sre.Data.Tables[0];
  328. }
  329. return null;
  330. }
  331. catch (Exception ex)
  332. {
  333. throw ex;
  334. }
  335. }
  336. /// <summary>
  337. /// 查询损坏明细表
  338. /// </summary>
  339. private DataTable GetSearchDetailData()
  340. {
  341. try
  342. {
  343. // 调用服务器端获取数据集
  344. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  345. {
  346. return ReportModuleProxy.Service.GetRPT030101IData(rptse);
  347. }
  348. );
  349. if (sre.Status == Constant.ServiceResultStatus.Success)
  350. {
  351. //if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  352. //{
  353. // // 提示未查找到数据
  354. // MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  355. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  356. // //清空数据
  357. // return null;
  358. //}
  359. return sre.Data.Tables[0];
  360. }
  361. return null;
  362. }
  363. catch (Exception ex)
  364. {
  365. throw ex;
  366. }
  367. }
  368. /// <summary>
  369. /// 获取权限
  370. /// </summary>
  371. protected void getPurview()
  372. {
  373. try
  374. {
  375. StringBuilder sbProcedurePurview = new StringBuilder();
  376. //得到工序查看权限
  377. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  378. {
  379. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  380. }));
  381. if (dsProcedurePurview != null)
  382. {
  383. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  384. if (drPurview.Length == 0)
  385. {
  386. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  387. {
  388. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  389. }
  390. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  391. {
  392. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  393. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  394. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  395. }
  396. }
  397. else
  398. {
  399. SearchProductionLineEntity line = new SearchProductionLineEntity();
  400. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  401. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  402. {
  403. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  404. }
  405. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  406. {
  407. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  408. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  409. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  410. }
  411. }
  412. }
  413. }
  414. catch (Exception ex)
  415. {
  416. throw ex;
  417. }
  418. }
  419. #endregion
  420. }
  421. }