F_RPT_030101_1.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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. rptse.Building = this.BuildingNumber.Text.ToString();
  249. }
  250. /// <summary>
  251. /// 获取权限(生产线)
  252. /// </summary>
  253. protected void getPurviewLine()
  254. {
  255. try
  256. {
  257. StringBuilder sbProcedurePurview = new StringBuilder();
  258. //得到工序查看权限
  259. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  260. {
  261. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  262. }));
  263. if (dsProcedurePurview != null)
  264. {
  265. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  266. if (drPurview.Length == 0)
  267. {
  268. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  269. {
  270. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  271. }
  272. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  273. {
  274. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  275. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  276. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  277. }
  278. }
  279. else
  280. {
  281. ProductionLineEntity line = new ProductionLineEntity();
  282. line.ValueFlags = new object[] { 1 };
  283. dsProcedurePurview = (DataSet)DoAsync(() =>
  284. {
  285. return PCModuleProxy.Service.SearchProductionLine(line);
  286. });
  287. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  288. {
  289. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  290. }
  291. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  292. {
  293. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  294. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  295. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  296. }
  297. }
  298. }
  299. }
  300. catch (Exception ex)
  301. {
  302. throw ex;
  303. }
  304. }
  305. /// <summary>
  306. /// 查询产品产量汇总表
  307. /// </summary>
  308. private DataTable GetSearchTotalData()
  309. {
  310. try
  311. {
  312. // 调用服务器端获取数据集
  313. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  314. {
  315. return ReportModuleProxy.Service.GetRPT030101SData(rptse);
  316. }
  317. );
  318. if (sre.Status == Constant.ServiceResultStatus.Success)
  319. {
  320. //if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  321. //{
  322. // // 提示未查找到数据
  323. // MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  324. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  325. // //清空数据
  326. // return null;
  327. //}
  328. return sre.Data.Tables[0];
  329. }
  330. return null;
  331. }
  332. catch (Exception ex)
  333. {
  334. throw ex;
  335. }
  336. }
  337. /// <summary>
  338. /// 查询损坏明细表
  339. /// </summary>
  340. private DataTable GetSearchDetailData()
  341. {
  342. try
  343. {
  344. // 调用服务器端获取数据集
  345. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  346. {
  347. return ReportModuleProxy.Service.GetRPT030101IData(rptse);
  348. }
  349. );
  350. if (sre.Status == Constant.ServiceResultStatus.Success)
  351. {
  352. //if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  353. //{
  354. // // 提示未查找到数据
  355. // MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  356. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  357. // //清空数据
  358. // return null;
  359. //}
  360. return sre.Data.Tables[0];
  361. }
  362. return null;
  363. }
  364. catch (Exception ex)
  365. {
  366. throw ex;
  367. }
  368. }
  369. /// <summary>
  370. /// 获取权限
  371. /// </summary>
  372. protected void getPurview()
  373. {
  374. try
  375. {
  376. StringBuilder sbProcedurePurview = new StringBuilder();
  377. //得到工序查看权限
  378. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  379. {
  380. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  381. }));
  382. if (dsProcedurePurview != null)
  383. {
  384. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  385. if (drPurview.Length == 0)
  386. {
  387. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  388. {
  389. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  390. }
  391. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  392. {
  393. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  394. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  395. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  396. }
  397. }
  398. else
  399. {
  400. SearchProductionLineEntity line = new SearchProductionLineEntity();
  401. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  402. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  403. {
  404. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  405. }
  406. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  407. {
  408. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  409. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  410. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  411. }
  412. }
  413. }
  414. }
  415. catch (Exception ex)
  416. {
  417. throw ex;
  418. }
  419. }
  420. #endregion
  421. }
  422. }