F_RPT_030117.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_030117.cs
  5. * 2.功能描述:产成品交接撤销汇总表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 付斌 2015/08/08 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Basics.DockPanel;
  15. using Dongke.IBOSS.PRD.Basics.Library;
  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.DataModels.PMModule;
  21. using Dongke.IBOSS.PRD.WCF.Proxys;
  22. namespace Dongke.IBOSS.PRD.Client.ReportModule
  23. {
  24. public partial class F_RPT_030117 : DKDockPanelBase
  25. {
  26. #region 成员变量
  27. private static F_RPT_030117 _instance; // 窗体的单例模式
  28. private SearchFinishedProductEntity _orderEntityBySearch; // 按钮查询条件实体类
  29. private SearchFinishedProductEntity _orderEntityByDouble; // 双击查询条件实体类
  30. #endregion
  31. #region 构造函数
  32. /// <summary>
  33. /// 构造函数
  34. /// </summary>
  35. private F_RPT_030117()
  36. {
  37. InitializeComponent();
  38. // 控件赋值
  39. this.Text = FormTitles.F_RPT_030117;
  40. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  41. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  42. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  43. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  44. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  45. }
  46. /// <summary>
  47. /// 单例模式,防止重复创建窗体
  48. /// </summary>
  49. public static F_RPT_030117 Instance
  50. {
  51. get
  52. {
  53. if (_instance == null || _instance.IsDisposed)
  54. {
  55. _instance = new F_RPT_030117();
  56. }
  57. return _instance;
  58. }
  59. }
  60. #endregion
  61. #region 事件
  62. /// <summary>
  63. /// 窗体加载事件
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. private void F_RPT_030102_1_Load(object sender, EventArgs e)
  68. {
  69. try
  70. {
  71. // 加载权限
  72. FormPermissionManager.FormPermissionControl(this.Name, this,
  73. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  74. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  75. // 设置表格不自动创建列
  76. this.dgvUndoTotal.AutoGenerateColumns = false;
  77. this.dgvUndoDetail.AutoGenerateColumns = false;
  78. this.dtpStartTime.Value = DateTime.Now.Date;
  79. this.dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddMinutes(-1);
  80. this.FHTimeStart.Value = DateTime.Now.Date;
  81. this.FHTimeEnd.Value = DateTime.Now.Date.AddDays(1).AddMinutes(-1);
  82. }
  83. catch (Exception ex)
  84. {
  85. // 对异常进行共通处理
  86. ExceptionManager.HandleEventException(this.ToString(),
  87. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  88. }
  89. }
  90. /// <summary>
  91. /// 查询按钮点击事件
  92. /// </summary>
  93. /// <param name="sender"></param>
  94. /// <param name="e"></param>
  95. private void btnSearch_Click(object sender, EventArgs e)
  96. {
  97. try
  98. {
  99. // 设置查询实体类
  100. GetOrderEntityFromLayout();
  101. this.btnSearch.Enabled = false;
  102. this.btnClearCondition.Enabled = false;
  103. if (this.ckflag.Checked && !this.chkDateTime.Checked)
  104. {
  105. MessageBox.Show("已勾选【过滤撤销时间再交接产品】,请选择撤销时间", this.Text,
  106. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  107. return ;
  108. }
  109. // 汇总表查询
  110. if (this.tblUndo.SelectedIndex == Constant.INT_IS_ZERO)
  111. {
  112. this.dgvUndoTotal.DataSource = null;
  113. this.dgvUndoTotal.DataSource = this.GetSearchTotalData();
  114. }
  115. // 明细表查询
  116. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_ONE)
  117. {
  118. this.dgvUndoDetail.DataSource = null;
  119. this.dgvUndoDetail.DataSource = this.GetSearchDetailData();
  120. }
  121. // 明细表查询
  122. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_TWO)
  123. {
  124. this.dgvlc.DataSource = null;
  125. this.dgvlc.DataSource = this.GetlcSearchTotalData();
  126. }
  127. // 明细表查询
  128. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_THREE)
  129. {
  130. this.dgvlcDetail.DataSource = null;
  131. this.dgvlcDetail.DataSource = this.GetlcSearchDetailData();
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. // 对异常进行共通处理
  137. ExceptionManager.HandleEventException(this.ToString(),
  138. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  139. }
  140. finally
  141. {
  142. this.btnSearch.Enabled = true;
  143. this.btnClearCondition.Enabled = true;
  144. }
  145. }
  146. /// <summary>
  147. /// 双击单元格事件
  148. /// </summary>
  149. /// <param name="sender"></param>
  150. /// <param name="e"></param>
  151. private void dgvScrapTotalModule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  152. {
  153. try
  154. {
  155. // 判断是否为空
  156. if (this.dgvUndoTotal.CurrentRow == null)
  157. {
  158. return;
  159. }
  160. // 创建实体,获取数据信息
  161. this._orderEntityByDouble = new SearchFinishedProductEntity();
  162. DataGridViewRow dgvr = dgvUndoTotal.CurrentRow;
  163. string goodsModel = dgvr.Cells["GoodsModel"].Value.ToString();
  164. DateTime createTime = new DateTime();
  165. DateTime.TryParse(dgvr.Cells["CreateTime"].Value + "", out createTime);
  166. this.btnSearch.Enabled = false;
  167. this.btnClearCondition.Enabled = false;
  168. // 正常选择统计行
  169. if (!goodsModel.Equals("--"))
  170. {
  171. this.tblUndo.SelectTab(1);
  172. // 获取查询条件
  173. this._orderEntityByDouble.GoodsModel = goodsModel;
  174. this._orderEntityByDouble.UndoTimeStart = createTime;
  175. this._orderEntityByDouble.UndoTimeEnd = createTime.AddDays(1).AddMinutes(-1);
  176. this.dgvUndoDetail.DataSource = null;
  177. this.dgvUndoDetail.DataSource = GetSearchDetailDataByDouble();
  178. return;
  179. }
  180. // 小计行
  181. if (dgvr.Cells["CreateTime"].Value.ToString().StartsWith("小计"))
  182. {
  183. this.tblUndo.SelectTab(1);
  184. dgvr = dgvUndoTotal.Rows[this.dgvUndoTotal.CurrentCell.RowIndex - 1];
  185. // 获取查询条件
  186. createTime = Convert.ToDateTime(dgvr.Cells["CreateTime"].Value);
  187. this._orderEntityByDouble.UndoTimeStart = createTime;
  188. this._orderEntityByDouble.UndoTimeEnd = createTime.AddDays(1).AddMinutes(-1);
  189. // 导入上一次查询的商品规格的条件
  190. this._orderEntityByDouble.GoodsModel = _orderEntityBySearch.GoodsModel;
  191. this.dgvUndoDetail.DataSource = null;
  192. this.dgvUndoDetail.DataSource = GetSearchDetailDataByDouble();
  193. return;
  194. }
  195. // 合计行
  196. if (dgvr.Cells["CreateTime"].Value.ToString().StartsWith("合计"))
  197. {
  198. this.tblUndo.SelectTab(1);
  199. dgvr = dgvUndoTotal.Rows[this.dgvUndoTotal.CurrentCell.RowIndex - 2];
  200. // 获取查询条件
  201. this._orderEntityByDouble.UndoTimeStart = _orderEntityBySearch.UndoTimeStart;
  202. this._orderEntityByDouble.UndoTimeEnd = _orderEntityBySearch.UndoTimeEnd;
  203. this._orderEntityByDouble.GoodsModel = _orderEntityBySearch.GoodsModel;
  204. this.dgvUndoDetail.DataSource = null;
  205. this.dgvUndoDetail.DataSource = GetSearchDetailDataByDouble();
  206. return;
  207. }
  208. }
  209. catch (Exception ex)
  210. {
  211. // 对异常进行共通处理
  212. ExceptionManager.HandleEventException(this.ToString(),
  213. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  214. }
  215. finally
  216. {
  217. this.btnSearch.Enabled = true;
  218. this.btnClearCondition.Enabled = true;
  219. }
  220. }
  221. /// <summary>
  222. /// 清空条件按钮点击事件
  223. /// </summary>
  224. /// <param name="sender"></param>
  225. /// <param name="e"></param>
  226. private void btnClearCondition_Click(object sender, EventArgs e)
  227. {
  228. this.chkDateTime.Checked = true;
  229. this.dtpStartTime.Value = DateTime.Now.Date;
  230. this.dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddMinutes(-1);
  231. this.txtGoodsModel.Clear();
  232. }
  233. /// <summary>
  234. /// 复选框改变事件
  235. /// </summary>
  236. /// <param name="sender"></param>
  237. /// <param name="e"></param>
  238. private void chkDateTime_CheckedChanged(object sender, EventArgs e)
  239. {
  240. this.dtpStartTime.Enabled = chkDateTime.Checked;
  241. this.dtpEndTime.Enabled = chkDateTime.Checked;
  242. }
  243. /// <summary>
  244. /// 自动适应列宽按钮点击事件
  245. /// </summary>
  246. /// <param name="sender"></param>
  247. /// <param name="e"></param>
  248. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  249. {
  250. if (this.tblUndo.SelectedIndex == Constant.INT_IS_ZERO)
  251. {
  252. this.dgvUndoTotal.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  253. }
  254. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_ONE)
  255. {
  256. this.dgvUndoDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  257. }
  258. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_TWO)
  259. {
  260. this.dgvlc.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  261. }
  262. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_THREE)
  263. {
  264. this.dgvlcDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  265. }
  266. }
  267. /// <summary>
  268. /// 关闭按钮点击事件
  269. /// </summary>
  270. /// <param name="sender"></param>
  271. /// <param name="e"></param>
  272. private void tsbtnClose_Click(object sender, EventArgs e)
  273. {
  274. this.Close();
  275. }
  276. /// <summary>
  277. /// 窗体关闭事件
  278. /// </summary>
  279. /// <param name="sender"></param>
  280. /// <param name="e"></param>
  281. private void F_RPT_030102_1_FormClosed(object sender, FormClosedEventArgs e)
  282. {
  283. _instance = null;
  284. }
  285. #endregion
  286. #region 私有方法
  287. /// <summary>
  288. /// 查询按钮搜索条件
  289. /// </summary>
  290. /// <returns></returns>
  291. private SearchFinishedProductEntity GetOrderEntityFromLayout()
  292. {
  293. this._orderEntityBySearch = new SearchFinishedProductEntity();
  294. if (this.chkDateTime.Checked)
  295. {
  296. this._orderEntityBySearch.UndoTimeStart = this.dtpStartTime.Value;
  297. this._orderEntityBySearch.UndoTimeEnd = this.dtpEndTime.Value;
  298. }
  299. if (this.FHCheckBox.Checked)
  300. {
  301. this._orderEntityBySearch.FHTimeStart = this.FHTimeStart.Value;
  302. this._orderEntityBySearch.FHTimeEnd = this.FHTimeEnd.Value;
  303. }
  304. this._orderEntityBySearch.GoodsModel = this.txtGoodsModel.Text.Trim();
  305. //过滤撤销时间再交接产品
  306. if (this.ckflag.Checked)
  307. {
  308. this._orderEntityBySearch.FhFlag = "1";
  309. }
  310. else
  311. {
  312. this._orderEntityBySearch.FhFlag = "0";
  313. }
  314. return this._orderEntityBySearch;
  315. }
  316. /// <summary>
  317. /// 查询汇总表
  318. /// </summary>
  319. private DataTable GetSearchTotalData()
  320. {
  321. try
  322. {
  323. // 异步处理,验证挂起条码
  324. ClientRequestEntity cre = new ClientRequestEntity();
  325. cre.NameSpace = "F_RPT_030117";
  326. cre.Name = "GetSearchTotalData";
  327. cre.Request = JsonHelper.ToJson(_orderEntityBySearch);
  328. // 调用服务器端获取数据集
  329. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  330. {
  331. return ReportModuleProxy.Service.DoRequest(cre);
  332. }));
  333. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  334. {
  335. // 提示未查找到数据
  336. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  337. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  338. return null;
  339. }
  340. return sre.Data.Tables[0];
  341. }
  342. catch (Exception ex)
  343. {
  344. // 对异常进行共通处理
  345. ExceptionManager.HandleEventException(this.ToString(),
  346. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  347. return null;
  348. }
  349. }
  350. /// <summary>
  351. /// 查询明细表
  352. /// </summary>
  353. private DataTable GetSearchDetailData()
  354. {
  355. try
  356. {
  357. // 异步处理,验证挂起条码
  358. ClientRequestEntity cre = new ClientRequestEntity();
  359. cre.NameSpace = "F_RPT_030117";
  360. cre.Name = "GetSearchDetailData";
  361. cre.Request = JsonHelper.ToJson(_orderEntityBySearch);
  362. // 调用服务器端获取数据集
  363. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  364. {
  365. return ReportModuleProxy.Service.DoRequest(cre);
  366. }));
  367. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  368. {
  369. // 提示未查找到数据
  370. MessageBox.Show(Messages.MSG_CMN_I002, tapUndoDetail.Text,
  371. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  372. return null;
  373. }
  374. return sre.Data.Tables[0];
  375. }
  376. catch (Exception ex)
  377. {
  378. // 对异常进行共通处理
  379. ExceptionManager.HandleEventException(this.ToString(),
  380. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  381. return null;
  382. }
  383. }
  384. /// <summary>
  385. /// 查询明细表(通过汇总表双击事件)
  386. /// </summary>
  387. private DataTable GetSearchDetailDataByDouble()
  388. {
  389. try
  390. {
  391. // 异步处理,验证挂起条码
  392. ClientRequestEntity cre = new ClientRequestEntity();
  393. cre.NameSpace = "F_RPT_030117";
  394. cre.Name = "GetSearchDetailData";
  395. cre.Request = JsonHelper.ToJson(_orderEntityByDouble);
  396. // 调用服务器端获取数据集
  397. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  398. {
  399. return ReportModuleProxy.Service.DoRequest(cre);
  400. }));
  401. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  402. {
  403. // 提示未查找到数据
  404. MessageBox.Show(Messages.MSG_CMN_I002, tapUndoDetail.Text,
  405. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  406. return null;
  407. }
  408. return sre.Data.Tables[0];
  409. }
  410. catch (Exception ex)
  411. {
  412. // 对异常进行共通处理
  413. ExceptionManager.HandleEventException(this.ToString(),
  414. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  415. return null;
  416. }
  417. }
  418. /// <summary>
  419. /// 查询裸瓷汇总表
  420. /// </summary>
  421. private DataTable GetlcSearchTotalData()
  422. {
  423. try
  424. {
  425. // 异步处理,验证挂起条码
  426. ClientRequestEntity cre = new ClientRequestEntity();
  427. cre.NameSpace = "F_RPT_030117";
  428. cre.Name = "GetlcSearchTotalData";
  429. cre.Request = JsonHelper.ToJson(_orderEntityBySearch);
  430. // 调用服务器端获取数据集
  431. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  432. {
  433. return ReportModuleProxy.Service.DoRequest(cre);
  434. }));
  435. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  436. {
  437. // 提示未查找到数据
  438. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  439. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  440. return null;
  441. }
  442. return sre.Data.Tables[0];
  443. }
  444. catch (Exception ex)
  445. {
  446. // 对异常进行共通处理
  447. ExceptionManager.HandleEventException(this.ToString(),
  448. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  449. return null;
  450. }
  451. }
  452. /// <summary>
  453. /// 查询裸瓷明细表
  454. /// </summary>
  455. private DataTable GetlcSearchDetailData()
  456. {
  457. try
  458. {
  459. // 异步处理,验证挂起条码
  460. ClientRequestEntity cre = new ClientRequestEntity();
  461. cre.NameSpace = "F_RPT_030117";
  462. cre.Name = "GetlcSearchDetailData";
  463. cre.Request = JsonHelper.ToJson(_orderEntityBySearch);
  464. // 调用服务器端获取数据集
  465. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  466. {
  467. return ReportModuleProxy.Service.DoRequest(cre);
  468. }));
  469. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  470. {
  471. // 提示未查找到数据
  472. MessageBox.Show(Messages.MSG_CMN_I002, tapUndoDetail.Text,
  473. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  474. return null;
  475. }
  476. return sre.Data.Tables[0];
  477. }
  478. catch (Exception ex)
  479. {
  480. // 对异常进行共通处理
  481. ExceptionManager.HandleEventException(this.ToString(),
  482. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  483. return null;
  484. }
  485. }
  486. #endregion
  487. }
  488. }