F_RPT_030101_1.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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 = null;//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.txtSTAFFNAME.Text = string.Empty;
  181. this.dkProcedureSearchBox.ClearControl();
  182. this.dkproductionLineSearchBox.ClearControl();
  183. this.dtpAccountDateStart.Value = DateTime.Now.Date;
  184. this.dtpAccountDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  185. this.dkProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
  186. this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
  187. this.chkFlag.Checked = false;
  188. }
  189. /// <summary>
  190. /// 双击单元格事件
  191. /// </summary>
  192. /// <param name="sender"></param>
  193. /// <param name="e"></param>
  194. private void dgvReportModule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  195. {
  196. try
  197. {
  198. if (this.dgvReportModule.CurrentRow == null)
  199. {
  200. return;
  201. }
  202. //获取数据信息
  203. DataGridViewRow dgvr = dgvReportModule.CurrentRow;
  204. string goodsId = dgvr.Cells["GoodsID"].Value.ToString();
  205. string procedureId = dgvr.Cells["Procedureid"].Value.ToString();
  206. if (goodsId.Equals("小计") || goodsId.Equals("--"))
  207. {
  208. return;
  209. }
  210. else
  211. {
  212. //跳转页
  213. this.tblReportModule.SelectTab(1);
  214. //获取条件
  215. //CreateSearchCondition();
  216. rptse.GoodsIDS = goodsId.ToString();
  217. rptse.ProcedureIDS = procedureId.ToString();
  218. //清空数据
  219. this.dgvReportModuleDetail.DataSource = null;
  220. this.dgvReportModuleDetail.DataSource = GetSearchDetailData();
  221. }
  222. }
  223. catch (Exception ex)
  224. {
  225. this.btnSearch.Enabled = true;
  226. this.btnClearCondition.Enabled = true;
  227. // 对异常进行共通处理
  228. ExceptionManager.HandleEventException(this.ToString(),
  229. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  230. }
  231. }
  232. #endregion
  233. #region 私有方法
  234. /// <summary>
  235. /// 搜索条件
  236. /// </summary>
  237. /// <returns></returns>
  238. private void CreateSearchCondition()
  239. {
  240. rptse = new RPT030101_SE();
  241. rptse.OrganizationIDS = this.scbOrganization.CheckedPKMember;
  242. rptse.GoodsIDS = scbGoods.CheckedPKMember;
  243. rptse.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
  244. rptse.ProductionLineIDS = this.dkproductionLineSearchBox.ProductionLineIDS;
  245. rptse.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
  246. rptse.StaffName = this.txtSTAFFNAME.Text.Trim();
  247. rptse.AccountDateStart = DateTime.Parse(this.dtpAccountDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
  248. rptse.AccountDateEnd = DateTime.Parse(this.dtpAccountDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
  249. rptse.ProductionFlag = this.chkFlag.Checked ? "1" : "0";
  250. }
  251. /// <summary>
  252. /// 获取权限(生产线)
  253. /// </summary>
  254. protected void getPurviewLine()
  255. {
  256. try
  257. {
  258. StringBuilder sbProcedurePurview = new StringBuilder();
  259. //得到工序查看权限
  260. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  261. {
  262. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  263. }));
  264. if (dsProcedurePurview != null)
  265. {
  266. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  267. if (drPurview.Length == 0)
  268. {
  269. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  270. {
  271. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  272. }
  273. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  274. {
  275. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  276. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  277. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  278. }
  279. }
  280. else
  281. {
  282. ProductionLineEntity line = new ProductionLineEntity();
  283. line.ValueFlags = new object[] { 1 };
  284. dsProcedurePurview = (DataSet)DoAsync(() =>
  285. {
  286. return PCModuleProxy.Service.SearchProductionLine(line);
  287. });
  288. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  289. {
  290. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  291. }
  292. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  293. {
  294. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  295. this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  296. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  297. }
  298. }
  299. }
  300. }
  301. catch (Exception ex)
  302. {
  303. throw ex;
  304. }
  305. }
  306. /// <summary>
  307. /// 查询产品产量汇总表
  308. /// </summary>
  309. private DataTable GetSearchTotalData()
  310. {
  311. try
  312. {
  313. // 调用服务器端获取数据集
  314. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  315. {
  316. return ReportModuleProxy.Service.GetRPT030101SData(rptse);
  317. }
  318. );
  319. if (sre.Status == Constant.ServiceResultStatus.Success)
  320. {
  321. //if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  322. //{
  323. // // 提示未查找到数据
  324. // MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  325. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  326. // //清空数据
  327. // return null;
  328. //}
  329. return sre.Data.Tables[0];
  330. }
  331. return null;
  332. }
  333. catch (Exception ex)
  334. {
  335. throw ex;
  336. }
  337. }
  338. /// <summary>
  339. /// 查询损坏明细表
  340. /// </summary>
  341. private DataTable GetSearchDetailData()
  342. {
  343. try
  344. {
  345. // 调用服务器端获取数据集
  346. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  347. {
  348. return ReportModuleProxy.Service.GetRPT030101IData(rptse);
  349. }
  350. );
  351. if (sre.Status == Constant.ServiceResultStatus.Success)
  352. {
  353. //if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  354. //{
  355. // // 提示未查找到数据
  356. // MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  357. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  358. // //清空数据
  359. // return null;
  360. //}
  361. return sre.Data.Tables[0];
  362. }
  363. return null;
  364. }
  365. catch (Exception ex)
  366. {
  367. throw ex;
  368. }
  369. }
  370. /// <summary>
  371. /// 获取权限
  372. /// </summary>
  373. protected void getPurview()
  374. {
  375. try
  376. {
  377. StringBuilder sbProcedurePurview = new StringBuilder();
  378. //得到工序查看权限
  379. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  380. {
  381. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  382. }));
  383. if (dsProcedurePurview != null)
  384. {
  385. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  386. if (drPurview.Length == 0)
  387. {
  388. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  389. {
  390. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  391. }
  392. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  393. {
  394. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  395. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  396. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  397. }
  398. }
  399. else
  400. {
  401. SearchProductionLineEntity line = new SearchProductionLineEntity();
  402. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  403. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  404. {
  405. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  406. }
  407. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  408. {
  409. this.dkProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  410. this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  411. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  412. }
  413. }
  414. }
  415. }
  416. catch (Exception ex)
  417. {
  418. throw ex;
  419. }
  420. }
  421. #endregion
  422. }
  423. }