F_RPT_030109.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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.scbGoodsType.ClearValue();
  176. this.txtGoodCode.Clear();
  177. this.dkProcedure.ClearControl();
  178. this.dkUserInfoSearchBox.ClearControl();
  179. this.chkPDate.Checked = false;
  180. this.chkBack.Checked = true;
  181. this.dtpBackDateStart.Value = DateTime.Now.Date;
  182. this.dtpBackDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  183. this.txtSTAFFNAME.Text = string.Empty;
  184. }
  185. /// <summary>
  186. /// 双击单元格事件
  187. /// </summary>
  188. /// <param name="sender"></param>
  189. /// <param name="e"></param>
  190. private void dgvRptProcedure_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  191. {
  192. try
  193. {
  194. //判断是否为空
  195. if (this.dgvRptProcedure.CurrentRow == null ||
  196. this.dgvRptProcedure.CurrentRow.Index < 0)
  197. {
  198. return;
  199. }
  200. //获取数据信息
  201. DataGridViewRow dgvr = dgvRptProcedure.CurrentRow;
  202. string goodsId = dgvr.Cells["GoodsId"].Value.ToString();
  203. string userId = dgvr.Cells["Userid"].Value.ToString();
  204. string procedureId = dgvr.Cells["ProcedureId"].Value.ToString();
  205. string goodstypecode2 = dgvr.Cells["goodstypecode2"].Value.ToString();
  206. //判断是否选择统计行
  207. if (!string.IsNullOrEmpty(goodsId))
  208. {
  209. this.dgvRptProcedureDetail.DataSource = null;
  210. this.tblReportModule.SelectTab(1);
  211. //获取条件
  212. this.CreateSearchConditionDetail();
  213. this._rptse.GoodsID = goodsId;
  214. this._rptse.ProcedureIDS = procedureId;
  215. this._rptse.UserIDS = userId;
  216. this.dgvRptProcedureDetail.DataSource = null;
  217. this.dgvRptProcedureDetail.DataSource = GetSearchDetailData();
  218. return;
  219. }
  220. if (!string.IsNullOrEmpty(goodstypecode2))
  221. {
  222. this.dgvRptProcedureDetail.DataSource = null;
  223. this.tblReportModule.SelectTab(1);
  224. //获取条件
  225. this.CreateSearchConditionDetail();
  226. this._rptse.ProcedureIDS = procedureId;
  227. this._rptse.GoodsTypeCode = goodstypecode2;
  228. this.dgvRptProcedureDetail.DataSource = null;
  229. this.dgvRptProcedureDetail.DataSource = GetSearchDetailData();
  230. return;
  231. }
  232. if (!string.IsNullOrEmpty(procedureId))
  233. {
  234. this.dgvRptProcedureDetail.DataSource = null;
  235. this.tblReportModule.SelectTab(1);
  236. //获取条件
  237. this.CreateSearchConditionDetail();
  238. this._rptse.ProcedureIDS = procedureId;
  239. this.dgvRptProcedureDetail.DataSource = null;
  240. this.dgvRptProcedureDetail.DataSource = GetSearchDetailData();
  241. return;
  242. }
  243. this.dgvRptProcedureDetail.DataSource = null;
  244. this.tblReportModule.SelectTab(1);
  245. //获取条件
  246. this.CreateSearchConditionDetail();
  247. this.dgvRptProcedureDetail.DataSource = null;
  248. this.dgvRptProcedureDetail.DataSource = GetSearchDetailData();
  249. }
  250. catch (Exception ex)
  251. {
  252. this.btnSearch.Enabled = true;
  253. this.btnClearCondition.Enabled = true;
  254. // 对异常进行共通处理
  255. ExceptionManager.HandleEventException(this.ToString(),
  256. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  257. }
  258. }
  259. private void chkOver_CheckedChanged(object sender, EventArgs e)
  260. {
  261. if (this.chkPDate.Checked)
  262. {
  263. this.dtpPDateStart.Enabled = true;
  264. this.dtpPDateEnd.Enabled = true;
  265. }
  266. else
  267. {
  268. this.dtpPDateStart.Enabled = false;
  269. this.dtpPDateEnd.Enabled = false;
  270. this.dtpPDateStart.Value = DateTime.Now.Date;
  271. this.dtpPDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  272. }
  273. }
  274. private void chkOut_CheckedChanged(object sender, EventArgs e)
  275. {
  276. if (this.chkBack.Checked)
  277. {
  278. this.dtpBackDateStart.Enabled = true;
  279. this.dtpBackDateEnd.Enabled = true;
  280. }
  281. else
  282. {
  283. this.dtpBackDateStart.Enabled = false;
  284. this.dtpBackDateEnd.Enabled = false;
  285. this.dtpBackDateStart.Value = DateTime.Now.Date;
  286. this.dtpBackDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  287. }
  288. }
  289. #endregion
  290. #region 私有方法
  291. /// <summary>
  292. /// 搜索条件
  293. /// </summary>
  294. /// <returns></returns>
  295. private void CreateSearchCondition()
  296. {
  297. this._rptse = new RPT030109_SE();
  298. this._rptse.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
  299. this._rptse.BackUserCode = this.txtBackUserCode.Text;
  300. this._rptse.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  301. this._rptse.GoodsCode = this.txtGoodCode.Text.Trim();
  302. this._rptse.ProcedureIDS = this.dkProcedure.ProcedureIDS;
  303. this._rptse.UserIDS = this.dkUserInfoSearchBox.UserIDS;
  304. this._rptse.StaffName = this.txtSTAFFNAME.Text;
  305. if (this.chkPDate.Checked)
  306. {
  307. this._rptse.PTimeStart = DateTime.Parse(this.dtpPDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
  308. this._rptse.PTimeEnd = DateTime.Parse(this.dtpPDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
  309. }
  310. if (this.chkBack.Checked)
  311. {
  312. this._rptse.BackTimeStart = DateTime.Parse(this.dtpBackDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
  313. this._rptse.BackTimeEnd = DateTime.Parse(this.dtpBackDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
  314. }
  315. }
  316. /// <summary>
  317. /// 明细搜索条件
  318. /// </summary>
  319. /// <returns></returns>
  320. private void CreateSearchConditionDetail()
  321. {
  322. this._rptse = new RPT030109_SE();
  323. this._rptse.ProductionLineID = this._rptse1.ProductionLineID;
  324. this._rptse.BackUserCode = this._rptse1.BackUserCode;
  325. this._rptse.GoodsTypeCode = this._rptse1.GoodsTypeCode;
  326. this._rptse.GoodsCode = this._rptse1.GoodsCode;
  327. this._rptse.ProcedureIDS = this._rptse1.ProcedureIDS;
  328. this._rptse.UserIDS = this._rptse1.UserIDS;
  329. this._rptse.PTimeStart = this._rptse1.PTimeStart;
  330. this._rptse.PTimeEnd = this._rptse1.PTimeEnd;
  331. this._rptse.BackTimeStart = this._rptse1.BackTimeStart;
  332. this._rptse.BackTimeEnd = this._rptse1.BackTimeEnd;
  333. }
  334. /// <summary>
  335. /// 查询出窑数量汇总表
  336. /// </summary>
  337. private DataTable GetSearchTotalData()
  338. {
  339. try
  340. {
  341. // 调用服务器端获取数据集
  342. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  343. {
  344. return ReportModuleProxy.Service.GetRPT030109SData(_rptse);
  345. }
  346. );
  347. if (sre.Status == Constant.ServiceResultStatus.Success)
  348. {
  349. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  350. {
  351. // 提示未查找到数据
  352. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  353. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  354. //清空数据
  355. return null;
  356. }
  357. return sre.Data.Tables[0];
  358. }
  359. return null;
  360. }
  361. catch (Exception ex)
  362. {
  363. throw ex;
  364. }
  365. }
  366. /// <summary>
  367. /// 查询出窑数量明细表
  368. /// </summary>
  369. private DataTable GetSearchDetailData()
  370. {
  371. try
  372. {
  373. // 调用服务器端获取数据集
  374. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  375. {
  376. return ReportModuleProxy.Service.GetRPT030109IData(_rptse);
  377. }
  378. );
  379. if (sre.Status == Constant.ServiceResultStatus.Success)
  380. {
  381. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  382. {
  383. // 提示未查找到数据
  384. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  385. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  386. //清空数据
  387. return null;
  388. }
  389. return sre.Data.Tables[0];
  390. }
  391. return null;
  392. }
  393. catch (Exception ex)
  394. {
  395. throw ex;
  396. }
  397. }
  398. /// <summary>
  399. /// 获取权限(生产线)
  400. /// </summary>
  401. protected void getPurviewLine()
  402. {
  403. try
  404. {
  405. StringBuilder sbProcedurePurview = new StringBuilder();
  406. //得到工序查看权限
  407. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  408. {
  409. return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
  410. }));
  411. if (dsProcedurePurview != null)
  412. {
  413. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  414. if (drPurview.Length == 0)
  415. {
  416. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  417. {
  418. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  419. }
  420. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  421. {
  422. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  423. //this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  424. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  425. }
  426. }
  427. else
  428. {
  429. ProductionLineEntity line = new ProductionLineEntity();
  430. line.ValueFlags = new object[] { 1 };
  431. dsProcedurePurview = (DataSet)DoAsync(() =>
  432. {
  433. return PCModuleProxy.Service.SearchProductionLine(line);
  434. });
  435. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  436. {
  437. sbProcedurePurview.Append(dr["productionlineID"].ToString() + ",");
  438. }
  439. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  440. {
  441. this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  442. //this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  443. this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  444. }
  445. }
  446. }
  447. }
  448. catch (Exception ex)
  449. {
  450. throw ex;
  451. }
  452. }
  453. /// <summary>
  454. /// 获取权限
  455. /// </summary>
  456. protected void getPurview()
  457. {
  458. try
  459. {
  460. StringBuilder sbProcedurePurview = new StringBuilder();
  461. //得到工序查看权限
  462. DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
  463. {
  464. return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
  465. }));
  466. if (dsProcedurePurview != null)
  467. {
  468. DataRow[] drPurview = dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Select("PurviewID=-1");
  469. if (drPurview.Length == 0)
  470. {
  471. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  472. {
  473. sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
  474. }
  475. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  476. {
  477. this.dkProcedure.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  478. //this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  479. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  480. }
  481. }
  482. else
  483. {
  484. SearchProductionLineEntity line = new SearchProductionLineEntity();
  485. dsProcedurePurview = SystemModuleProxy.Service.GetProdureList(line);
  486. foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
  487. {
  488. sbProcedurePurview.Append(dr["ProcedureID"].ToString() + ",");
  489. }
  490. if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
  491. {
  492. this.dkProcedure.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  493. //this.dkProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  494. this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
  495. }
  496. }
  497. }
  498. }
  499. catch (Exception ex)
  500. {
  501. throw ex;
  502. }
  503. }
  504. #endregion
  505. }
  506. }