F_RPT_030109.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. 
  2. /*******************************************************************************
  3. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  4. * 类的信息:
  5. * 1.程序名称:F_RPT_030109.cs
  6. * 2.功能描述:工序交接数量汇总表
  7. * 编辑履历:
  8. * 作者 日期 版本 修改内容
  9. * 袁新成 2015/4/14 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_030109 : DKDockPanelBase
  28. {
  29. #region 成员变量
  30. // 窗体的单例模式
  31. private static F_RPT_030109 _instance;
  32. //实体类
  33. private RPT030109_SE _rptse = null;
  34. private RPT030109_SE _rptse1 = null;
  35. //默认清空工序,重置回用户当前权限工序
  36. private string _currentUserPurview = null;
  37. //默认清空生产线,重置回用户当前权限生产线
  38. private string _currentUserLinePuview = null;
  39. #endregion
  40. #region 构造函数
  41. public F_RPT_030109()
  42. {
  43. InitializeComponent();
  44. // 窗体显示的Title
  45. this.Text = "撤销产品汇总表";
  46. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  47. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  48. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  49. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  50. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  51. }
  52. #endregion
  53. #region 单例模式
  54. /// <summary>
  55. /// 单例模式,防止重复创建窗体
  56. /// </summary>
  57. public static F_RPT_030109 Instance
  58. {
  59. get
  60. {
  61. if (_instance == null || _instance.IsDisposed)
  62. {
  63. _instance = new F_RPT_030109();
  64. }
  65. return _instance;
  66. }
  67. }
  68. #endregion
  69. #region 事件处理
  70. /// <summary>
  71. /// 窗体加载事件
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. private void F_RPT_030103_1_Load(object sender, EventArgs e)
  76. {
  77. try
  78. {
  79. // 加载权限
  80. FormPermissionManager.FormPermissionControl(this.Name, this,
  81. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  82. // 设置表格不自动创建列
  83. this.dgvRptProcedureDetail.AutoGenerateColumns = false;
  84. this.dgvRptProcedure.AutoGenerateColumns = false;
  85. this.dkproductionLineSearchBox.IsEnablePurview = true;
  86. // 初始化时间控件为当前日期
  87. this.dtpPDateStart.Value = DateTime.Now.Date;
  88. this.dtpPDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  89. this.dtpBackDateStart.Value = DateTime.Now.Date;
  90. this.dtpBackDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  91. getPurview();
  92. getPurviewLine();
  93. }
  94. catch (Exception ex)
  95. {
  96. // 对异常进行共通处理
  97. ExceptionManager.HandleEventException(this.ToString(),
  98. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  99. }
  100. }
  101. /// <summary>
  102. /// 自动适应列宽
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  107. {
  108. if (this.tblReportModule.SelectedIndex == Constant.INT_IS_ZERO)
  109. {
  110. this.dgvRptProcedure.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  111. }
  112. else
  113. {
  114. this.dgvRptProcedureDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  115. }
  116. }
  117. /// <summary>
  118. /// 窗体关闭事件
  119. /// </summary>
  120. /// <param name="sender"></param>
  121. /// <param name="e"></param>
  122. private void F_RPT_030103_1_FormClosed(object sender, FormClosedEventArgs e)
  123. {
  124. _instance = null;
  125. }
  126. /// <summary>
  127. /// 关闭按钮
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. private void tsbtnClose_Click(object sender, EventArgs e)
  132. {
  133. this.Close();
  134. }
  135. /// <summary>
  136. /// 查询按钮事件
  137. /// </summary>
  138. /// <param name="sender"></param>
  139. /// <param name="e"></param>
  140. private void btnSearch_Click(object sender, EventArgs e)
  141. {
  142. try
  143. {
  144. CreateSearchCondition();
  145. if (this.tblReportModule.SelectedIndex == Constant.INT_IS_ZERO)
  146. {
  147. this._rptse1 = this._rptse;
  148. this.dgvRptProcedure.DataSource = null;
  149. this.dgvRptProcedure.DataSource = this.GetSearchTotalData();
  150. }
  151. else //出窑数量明细查询
  152. {
  153. this.dgvRptProcedureDetail.DataSource = null;
  154. this.dgvRptProcedureDetail.DataSource = this.GetSearchDetailData();
  155. }
  156. }
  157. catch (Exception ex)
  158. {
  159. this.btnSearch.Enabled = true;
  160. this.btnClearCondition.Enabled = true;
  161. // 对异常进行共通处理
  162. ExceptionManager.HandleEventException(this.ToString(),
  163. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  164. }
  165. }
  166. /// <summary>
  167. /// 清空条件按钮事件
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void btnClearCondition_Click(object sender, EventArgs e)
  172. {
  173. this.dkproductionLineSearchBox.ClearControl();
  174. this.txtBackUserCode.Clear();
  175. this.txtGroutingUserCode.Clear();
  176. this.scbGoodsType.ClearValue();
  177. this.txtGoodCode.Clear();
  178. this.dkProcedure.ClearControl();
  179. this.dkUserInfoSearchBox.ClearControl();
  180. this.chkPDate.Checked = false;
  181. this.chkBack.Checked = true;
  182. this.dtpBackDateStart.Value = DateTime.Now.Date;
  183. this.dtpBackDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  184. this.txtSTAFFNAME.Text = string.Empty;
  185. }
  186. /// <summary>
  187. /// 双击单元格事件
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. private void dgvRptProcedure_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  192. {
  193. try
  194. {
  195. //判断是否为空
  196. if (this.dgvRptProcedure.CurrentRow == null ||
  197. this.dgvRptProcedure.CurrentRow.Index < 0)
  198. {
  199. return;
  200. }
  201. //获取数据信息
  202. DataGridViewRow dgvr = dgvRptProcedure.CurrentRow;
  203. string goodsId = dgvr.Cells["GoodsId"].Value.ToString();
  204. string userId = dgvr.Cells["Userid"].Value.ToString();
  205. string procedureId = dgvr.Cells["ProcedureId"].Value.ToString();
  206. string goodstypecode2 = dgvr.Cells["goodstypecode2"].Value.ToString();
  207. //判断是否选择统计行
  208. if (!string.IsNullOrEmpty(goodsId))
  209. {
  210. this.dgvRptProcedureDetail.DataSource = null;
  211. this.tblReportModule.SelectTab(1);
  212. //获取条件
  213. this.CreateSearchConditionDetail();
  214. this._rptse.GoodsID = goodsId;
  215. this._rptse.ProcedureIDS = procedureId;
  216. this._rptse.UserIDS = userId;
  217. this.dgvRptProcedureDetail.DataSource = null;
  218. this.dgvRptProcedureDetail.DataSource = GetSearchDetailData();
  219. return;
  220. }
  221. if (!string.IsNullOrEmpty(goodstypecode2))
  222. {
  223. this.dgvRptProcedureDetail.DataSource = null;
  224. this.tblReportModule.SelectTab(1);
  225. //获取条件
  226. this.CreateSearchConditionDetail();
  227. this._rptse.ProcedureIDS = procedureId;
  228. this._rptse.GoodsTypeCode = goodstypecode2;
  229. this.dgvRptProcedureDetail.DataSource = null;
  230. this.dgvRptProcedureDetail.DataSource = GetSearchDetailData();
  231. return;
  232. }
  233. if (!string.IsNullOrEmpty(procedureId))
  234. {
  235. this.dgvRptProcedureDetail.DataSource = null;
  236. this.tblReportModule.SelectTab(1);
  237. //获取条件
  238. this.CreateSearchConditionDetail();
  239. this._rptse.ProcedureIDS = procedureId;
  240. this.dgvRptProcedureDetail.DataSource = null;
  241. this.dgvRptProcedureDetail.DataSource = GetSearchDetailData();
  242. return;
  243. }
  244. this.dgvRptProcedureDetail.DataSource = null;
  245. this.tblReportModule.SelectTab(1);
  246. //获取条件
  247. this.CreateSearchConditionDetail();
  248. this.dgvRptProcedureDetail.DataSource = null;
  249. this.dgvRptProcedureDetail.DataSource = GetSearchDetailData();
  250. }
  251. catch (Exception ex)
  252. {
  253. this.btnSearch.Enabled = true;
  254. this.btnClearCondition.Enabled = true;
  255. // 对异常进行共通处理
  256. ExceptionManager.HandleEventException(this.ToString(),
  257. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  258. }
  259. }
  260. private void chkOver_CheckedChanged(object sender, EventArgs e)
  261. {
  262. if (this.chkPDate.Checked)
  263. {
  264. this.dtpPDateStart.Enabled = true;
  265. this.dtpPDateEnd.Enabled = true;
  266. }
  267. else
  268. {
  269. this.dtpPDateStart.Enabled = false;
  270. this.dtpPDateEnd.Enabled = false;
  271. this.dtpPDateStart.Value = DateTime.Now.Date;
  272. this.dtpPDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  273. }
  274. }
  275. private void chkOut_CheckedChanged(object sender, EventArgs e)
  276. {
  277. if (this.chkBack.Checked)
  278. {
  279. this.dtpBackDateStart.Enabled = true;
  280. this.dtpBackDateEnd.Enabled = true;
  281. }
  282. else
  283. {
  284. this.dtpBackDateStart.Enabled = false;
  285. this.dtpBackDateEnd.Enabled = false;
  286. this.dtpBackDateStart.Value = DateTime.Now.Date;
  287. this.dtpBackDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  288. }
  289. }
  290. #endregion
  291. #region 私有方法
  292. /// <summary>
  293. /// 搜索条件
  294. /// </summary>
  295. /// <returns></returns>
  296. private void CreateSearchCondition()
  297. {
  298. this._rptse = new RPT030109_SE();
  299. this._rptse.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  300. this._rptse.BackUserCode = this.txtBackUserCode.Text;
  301. this._rptse.GroutingUserCode = this.txtGroutingUserCode.Text;
  302. this._rptse.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  303. this._rptse.GoodsCode = this.txtGoodCode.Text.Trim();
  304. this._rptse.ProcedureIDS = this.dkProcedure.ProcedureIDS;
  305. this._rptse.UserIDS = this.dkUserInfoSearchBox.UserIDS;
  306. this._rptse.StaffName = this.txtSTAFFNAME.Text;
  307. if (this.chkPDate.Checked)
  308. {
  309. this._rptse.PTimeStart = DateTime.Parse(this.dtpPDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
  310. this._rptse.PTimeEnd = DateTime.Parse(this.dtpPDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
  311. }
  312. if (this.chkBack.Checked)
  313. {
  314. this._rptse.BackTimeStart = DateTime.Parse(this.dtpBackDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
  315. this._rptse.BackTimeEnd = DateTime.Parse(this.dtpBackDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
  316. }
  317. }
  318. /// <summary>
  319. /// 明细搜索条件
  320. /// </summary>
  321. /// <returns></returns>
  322. private void CreateSearchConditionDetail()
  323. {
  324. this._rptse = new RPT030109_SE();
  325. this._rptse.ProductionLineID = this._rptse1.ProductionLineID;
  326. this._rptse.BackUserCode = this._rptse1.BackUserCode;
  327. this._rptse.GroutingUserCode = this._rptse1.GroutingUserCode;
  328. this._rptse.GoodsTypeCode = this._rptse1.GoodsTypeCode;
  329. this._rptse.GoodsCode = this._rptse1.GoodsCode;
  330. this._rptse.ProcedureIDS = this._rptse1.ProcedureIDS;
  331. this._rptse.UserIDS = this._rptse1.UserIDS;
  332. this._rptse.PTimeStart = this._rptse1.PTimeStart;
  333. this._rptse.PTimeEnd = this._rptse1.PTimeEnd;
  334. this._rptse.BackTimeStart = this._rptse1.BackTimeStart;
  335. this._rptse.BackTimeEnd = this._rptse1.BackTimeEnd;
  336. }
  337. /// <summary>
  338. /// 查询出窑数量汇总表
  339. /// </summary>
  340. private DataTable GetSearchTotalData()
  341. {
  342. try
  343. {
  344. // 调用服务器端获取数据集
  345. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  346. {
  347. return ReportModuleProxy.Service.GetRPT030109SData(_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. private DataTable GetSearchDetailData()
  373. {
  374. try
  375. {
  376. // 调用服务器端获取数据集
  377. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  378. {
  379. return ReportModuleProxy.Service.GetRPT030109IData(_rptse);
  380. }
  381. );
  382. if (sre.Status == Constant.ServiceResultStatus.Success)
  383. {
  384. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  385. {
  386. // 提示未查找到数据
  387. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  388. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  389. //清空数据
  390. return null;
  391. }
  392. return sre.Data.Tables[0];
  393. }
  394. return null;
  395. }
  396. catch (Exception ex)
  397. {
  398. throw ex;
  399. }
  400. }
  401. /// <summary>
  402. /// 获取权限(生产线)
  403. /// </summary>
  404. protected void getPurviewLine()
  405. {
  406. try
  407. {
  408. StringBuilder sbProcedurePurview = new StringBuilder();
  409. //得到工序查看权限
  410. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  411. {
  412. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  413. }));
  414. if (dsProcedurePurview != null)
  415. {
  416. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  417. if (drPurview.Length == 0)
  418. {
  419. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  420. {
  421. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  422. }
  423. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  424. {
  425. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  426. //this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  427. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  428. }
  429. }
  430. else
  431. {
  432. ProductionLineEntity line = new ProductionLineEntity();
  433. line.ValueFlags = new object[] { 1 };
  434. dsProcedurePurview = (DataSet)DoAsync(() =>
  435. {
  436. return PCModuleProxy.Service.SearchProductionLine(line);
  437. });
  438. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  439. {
  440. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  441. }
  442. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  443. {
  444. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  445. //this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  446. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  447. }
  448. }
  449. }
  450. }
  451. catch (Exception ex)
  452. {
  453. throw ex;
  454. }
  455. }
  456. /// <summary>
  457. /// 获取权限
  458. /// </summary>
  459. protected void getPurview()
  460. {
  461. try
  462. {
  463. StringBuilder sbProcedurePurview = new StringBuilder();
  464. //得到工序查看权限
  465. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  466. {
  467. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  468. }));
  469. if (dsProcedurePurview != null)
  470. {
  471. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  472. if (drPurview.Length == 0)
  473. {
  474. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  475. {
  476. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  477. }
  478. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  479. {
  480. this.dkProcedure.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  481. //this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  482. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  483. }
  484. }
  485. else
  486. {
  487. SearchProductionLineEntity line = new SearchProductionLineEntity();
  488. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  489. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  490. {
  491. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  492. }
  493. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  494. {
  495. this.dkProcedure.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  496. //this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  497. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  498. }
  499. }
  500. }
  501. }
  502. catch (Exception ex)
  503. {
  504. throw ex;
  505. }
  506. }
  507. #endregion
  508. }
  509. }