F_RPT_030109.cs 17 KB

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