F_RPT_030117.cs 15 KB

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