F_RPT_030117.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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. // 汇总表查询
  104. if (this.tblUndo.SelectedIndex == Constant.INT_IS_ZERO)
  105. {
  106. this.dgvUndoTotal.DataSource = null;
  107. this.dgvUndoTotal.DataSource = this.GetSearchTotalData();
  108. }
  109. // 明细表查询
  110. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_ONE)
  111. {
  112. this.dgvUndoDetail.DataSource = null;
  113. this.dgvUndoDetail.DataSource = this.GetSearchDetailData();
  114. }
  115. // 明细表查询
  116. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_TWO)
  117. {
  118. this.dgvlc.DataSource = null;
  119. this.dgvlc.DataSource = this.GetlcSearchTotalData();
  120. }
  121. // 明细表查询
  122. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_THREE)
  123. {
  124. this.dgvlcDetail.DataSource = null;
  125. this.dgvlcDetail.DataSource = this.GetlcSearchDetailData();
  126. }
  127. }
  128. catch (Exception ex)
  129. {
  130. // 对异常进行共通处理
  131. ExceptionManager.HandleEventException(this.ToString(),
  132. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  133. }
  134. finally
  135. {
  136. this.btnSearch.Enabled = true;
  137. this.btnClearCondition.Enabled = true;
  138. }
  139. }
  140. /// <summary>
  141. /// 双击单元格事件
  142. /// </summary>
  143. /// <param name="sender"></param>
  144. /// <param name="e"></param>
  145. private void dgvScrapTotalModule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  146. {
  147. try
  148. {
  149. // 判断是否为空
  150. if (this.dgvUndoTotal.CurrentRow == null)
  151. {
  152. return;
  153. }
  154. // 创建实体,获取数据信息
  155. this._orderEntityByDouble = new SearchFinishedProductEntity();
  156. DataGridViewRow dgvr = dgvUndoTotal.CurrentRow;
  157. string goodsModel = dgvr.Cells["GoodsModel"].Value.ToString();
  158. DateTime createTime = new DateTime();
  159. DateTime.TryParse(dgvr.Cells["CreateTime"].Value + "", out createTime);
  160. this.btnSearch.Enabled = false;
  161. this.btnClearCondition.Enabled = false;
  162. // 正常选择统计行
  163. if (!goodsModel.Equals("--"))
  164. {
  165. this.tblUndo.SelectTab(1);
  166. // 获取查询条件
  167. this._orderEntityByDouble.GoodsModel = goodsModel;
  168. this._orderEntityByDouble.UndoTimeStart = createTime;
  169. this._orderEntityByDouble.UndoTimeEnd = createTime.AddDays(1).AddMinutes(-1);
  170. this.dgvUndoDetail.DataSource = null;
  171. this.dgvUndoDetail.DataSource = GetSearchDetailDataByDouble();
  172. return;
  173. }
  174. // 小计行
  175. if (dgvr.Cells["CreateTime"].Value.ToString().StartsWith("小计"))
  176. {
  177. this.tblUndo.SelectTab(1);
  178. dgvr = dgvUndoTotal.Rows[this.dgvUndoTotal.CurrentCell.RowIndex - 1];
  179. // 获取查询条件
  180. createTime = Convert.ToDateTime(dgvr.Cells["CreateTime"].Value);
  181. this._orderEntityByDouble.UndoTimeStart = createTime;
  182. this._orderEntityByDouble.UndoTimeEnd = createTime.AddDays(1).AddMinutes(-1);
  183. // 导入上一次查询的商品规格的条件
  184. this._orderEntityByDouble.GoodsModel = _orderEntityBySearch.GoodsModel;
  185. this.dgvUndoDetail.DataSource = null;
  186. this.dgvUndoDetail.DataSource = GetSearchDetailDataByDouble();
  187. return;
  188. }
  189. // 合计行
  190. if (dgvr.Cells["CreateTime"].Value.ToString().StartsWith("合计"))
  191. {
  192. this.tblUndo.SelectTab(1);
  193. dgvr = dgvUndoTotal.Rows[this.dgvUndoTotal.CurrentCell.RowIndex - 2];
  194. // 获取查询条件
  195. this._orderEntityByDouble.UndoTimeStart = _orderEntityBySearch.UndoTimeStart;
  196. this._orderEntityByDouble.UndoTimeEnd = _orderEntityBySearch.UndoTimeEnd;
  197. this._orderEntityByDouble.GoodsModel = _orderEntityBySearch.GoodsModel;
  198. this.dgvUndoDetail.DataSource = null;
  199. this.dgvUndoDetail.DataSource = GetSearchDetailDataByDouble();
  200. return;
  201. }
  202. }
  203. catch (Exception ex)
  204. {
  205. // 对异常进行共通处理
  206. ExceptionManager.HandleEventException(this.ToString(),
  207. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  208. }
  209. finally
  210. {
  211. this.btnSearch.Enabled = true;
  212. this.btnClearCondition.Enabled = true;
  213. }
  214. }
  215. /// <summary>
  216. /// 清空条件按钮点击事件
  217. /// </summary>
  218. /// <param name="sender"></param>
  219. /// <param name="e"></param>
  220. private void btnClearCondition_Click(object sender, EventArgs e)
  221. {
  222. this.chkDateTime.Checked = true;
  223. this.dtpStartTime.Value = DateTime.Now.Date;
  224. this.dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddMinutes(-1);
  225. this.txtGoodsModel.Clear();
  226. }
  227. /// <summary>
  228. /// 复选框改变事件
  229. /// </summary>
  230. /// <param name="sender"></param>
  231. /// <param name="e"></param>
  232. private void chkDateTime_CheckedChanged(object sender, EventArgs e)
  233. {
  234. this.dtpStartTime.Enabled = chkDateTime.Checked;
  235. this.dtpEndTime.Enabled = chkDateTime.Checked;
  236. }
  237. /// <summary>
  238. /// 自动适应列宽按钮点击事件
  239. /// </summary>
  240. /// <param name="sender"></param>
  241. /// <param name="e"></param>
  242. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  243. {
  244. if (this.tblUndo.SelectedIndex == Constant.INT_IS_ZERO)
  245. {
  246. this.dgvUndoTotal.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  247. }
  248. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_ONE)
  249. {
  250. this.dgvUndoDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  251. }
  252. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_TWO)
  253. {
  254. this.dgvlc.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  255. }
  256. else if (this.tblUndo.SelectedIndex == Constant.INT_IS_THREE)
  257. {
  258. this.dgvlcDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  259. }
  260. }
  261. /// <summary>
  262. /// 关闭按钮点击事件
  263. /// </summary>
  264. /// <param name="sender"></param>
  265. /// <param name="e"></param>
  266. private void tsbtnClose_Click(object sender, EventArgs e)
  267. {
  268. this.Close();
  269. }
  270. /// <summary>
  271. /// 窗体关闭事件
  272. /// </summary>
  273. /// <param name="sender"></param>
  274. /// <param name="e"></param>
  275. private void F_RPT_030102_1_FormClosed(object sender, FormClosedEventArgs e)
  276. {
  277. _instance = null;
  278. }
  279. #endregion
  280. #region 私有方法
  281. /// <summary>
  282. /// 查询按钮搜索条件
  283. /// </summary>
  284. /// <returns></returns>
  285. private SearchFinishedProductEntity GetOrderEntityFromLayout()
  286. {
  287. this._orderEntityBySearch = new SearchFinishedProductEntity();
  288. if (this.chkDateTime.Checked)
  289. {
  290. this._orderEntityBySearch.UndoTimeStart = this.dtpStartTime.Value;
  291. this._orderEntityBySearch.UndoTimeEnd = this.dtpEndTime.Value;
  292. }
  293. if (this.FHCheckBox.Checked)
  294. {
  295. this._orderEntityBySearch.FHTimeStart = this.FHTimeStart.Value;
  296. this._orderEntityBySearch.FHTimeEnd = this.FHTimeEnd.Value;
  297. }
  298. this._orderEntityBySearch.GoodsModel = this.txtGoodsModel.Text.Trim();
  299. //过滤撤销时间再交接产品
  300. if (this.ckflag.Checked)
  301. {
  302. this._orderEntityBySearch.FhFlag = "1";
  303. }
  304. else
  305. {
  306. this._orderEntityBySearch.FhFlag = "0";
  307. }
  308. return this._orderEntityBySearch;
  309. }
  310. /// <summary>
  311. /// 查询汇总表
  312. /// </summary>
  313. private DataTable GetSearchTotalData()
  314. {
  315. try
  316. {
  317. // 异步处理,验证挂起条码
  318. ClientRequestEntity cre = new ClientRequestEntity();
  319. cre.NameSpace = "F_RPT_030117";
  320. cre.Name = "GetSearchTotalData";
  321. cre.Request = JsonHelper.ToJson(_orderEntityBySearch);
  322. // 调用服务器端获取数据集
  323. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  324. {
  325. return ReportModuleProxy.Service.DoRequest(cre);
  326. }));
  327. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  328. {
  329. // 提示未查找到数据
  330. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  331. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  332. return null;
  333. }
  334. return sre.Data.Tables[0];
  335. }
  336. catch (Exception ex)
  337. {
  338. // 对异常进行共通处理
  339. ExceptionManager.HandleEventException(this.ToString(),
  340. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  341. return null;
  342. }
  343. }
  344. /// <summary>
  345. /// 查询明细表
  346. /// </summary>
  347. private DataTable GetSearchDetailData()
  348. {
  349. try
  350. {
  351. // 异步处理,验证挂起条码
  352. ClientRequestEntity cre = new ClientRequestEntity();
  353. cre.NameSpace = "F_RPT_030117";
  354. cre.Name = "GetSearchDetailData";
  355. cre.Request = JsonHelper.ToJson(_orderEntityBySearch);
  356. // 调用服务器端获取数据集
  357. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  358. {
  359. return ReportModuleProxy.Service.DoRequest(cre);
  360. }));
  361. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  362. {
  363. // 提示未查找到数据
  364. MessageBox.Show(Messages.MSG_CMN_I002, tapUndoDetail.Text,
  365. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  366. return null;
  367. }
  368. return sre.Data.Tables[0];
  369. }
  370. catch (Exception ex)
  371. {
  372. // 对异常进行共通处理
  373. ExceptionManager.HandleEventException(this.ToString(),
  374. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  375. return null;
  376. }
  377. }
  378. /// <summary>
  379. /// 查询明细表(通过汇总表双击事件)
  380. /// </summary>
  381. private DataTable GetSearchDetailDataByDouble()
  382. {
  383. try
  384. {
  385. // 异步处理,验证挂起条码
  386. ClientRequestEntity cre = new ClientRequestEntity();
  387. cre.NameSpace = "F_RPT_030117";
  388. cre.Name = "GetSearchDetailData";
  389. cre.Request = JsonHelper.ToJson(_orderEntityByDouble);
  390. // 调用服务器端获取数据集
  391. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  392. {
  393. return ReportModuleProxy.Service.DoRequest(cre);
  394. }));
  395. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  396. {
  397. // 提示未查找到数据
  398. MessageBox.Show(Messages.MSG_CMN_I002, tapUndoDetail.Text,
  399. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  400. return null;
  401. }
  402. return sre.Data.Tables[0];
  403. }
  404. catch (Exception ex)
  405. {
  406. // 对异常进行共通处理
  407. ExceptionManager.HandleEventException(this.ToString(),
  408. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  409. return null;
  410. }
  411. }
  412. /// <summary>
  413. /// 查询裸瓷汇总表
  414. /// </summary>
  415. private DataTable GetlcSearchTotalData()
  416. {
  417. try
  418. {
  419. // 异步处理,验证挂起条码
  420. ClientRequestEntity cre = new ClientRequestEntity();
  421. cre.NameSpace = "F_RPT_030117";
  422. cre.Name = "GetlcSearchTotalData";
  423. cre.Request = JsonHelper.ToJson(_orderEntityBySearch);
  424. // 调用服务器端获取数据集
  425. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  426. {
  427. return ReportModuleProxy.Service.DoRequest(cre);
  428. }));
  429. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  430. {
  431. // 提示未查找到数据
  432. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  433. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  434. return null;
  435. }
  436. return sre.Data.Tables[0];
  437. }
  438. catch (Exception ex)
  439. {
  440. // 对异常进行共通处理
  441. ExceptionManager.HandleEventException(this.ToString(),
  442. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  443. return null;
  444. }
  445. }
  446. /// <summary>
  447. /// 查询裸瓷明细表
  448. /// </summary>
  449. private DataTable GetlcSearchDetailData()
  450. {
  451. try
  452. {
  453. // 异步处理,验证挂起条码
  454. ClientRequestEntity cre = new ClientRequestEntity();
  455. cre.NameSpace = "F_RPT_030117";
  456. cre.Name = "GetlcSearchDetailData";
  457. cre.Request = JsonHelper.ToJson(_orderEntityBySearch);
  458. // 调用服务器端获取数据集
  459. ServiceResultEntity sre = (ServiceResultEntity)DoAsync(new AsyncMethod(() =>
  460. {
  461. return ReportModuleProxy.Service.DoRequest(cre);
  462. }));
  463. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  464. {
  465. // 提示未查找到数据
  466. MessageBox.Show(Messages.MSG_CMN_I002, tapUndoDetail.Text,
  467. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  468. return null;
  469. }
  470. return sre.Data.Tables[0];
  471. }
  472. catch (Exception ex)
  473. {
  474. // 对异常进行共通处理
  475. ExceptionManager.HandleEventException(this.ToString(),
  476. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  477. return null;
  478. }
  479. }
  480. #endregion
  481. }
  482. }