F_RPT_030117.cs 12 KB

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