F_RPT_030117.cs 12 KB

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