F_RPT_030120.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_030120.cs
  5. * 2.功能描述:工厂调出汇总表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 付斌 2020/11/06 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.Client.CommonModule;
  15. using Dongke.IBOSS.PRD.Client.Controls;
  16. using Dongke.IBOSS.PRD.Client.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. namespace Dongke.IBOSS.PRD.Client.ReportModule
  20. {
  21. public partial class F_RPT_030120 : DKDockPanelBase
  22. {
  23. #region 成员变量
  24. private static F_RPT_030120 _instance; // 窗体的单例模式
  25. #endregion
  26. #region 构造函数
  27. /// <summary>
  28. /// 构造函数
  29. /// </summary>
  30. private F_RPT_030120()
  31. {
  32. InitializeComponent();
  33. // 控件赋值
  34. Text = FormTitles.F_RPT_030120;
  35. gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  36. tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  37. tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  38. btnSearch.Text = ButtonText.BTN_SEARCH;
  39. btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  40. }
  41. /// <summary>
  42. /// 单例模式,防止重复创建窗体
  43. /// </summary>
  44. public static F_RPT_030120 Instance
  45. {
  46. get
  47. {
  48. if (_instance == null || _instance.IsDisposed)
  49. {
  50. _instance = new F_RPT_030120();
  51. }
  52. return _instance;
  53. }
  54. }
  55. #endregion
  56. #region 事件
  57. /// <summary>
  58. /// 窗体加载事件
  59. /// </summary>
  60. /// <param name="sender"></param>
  61. /// <param name="e"></param>
  62. private void F_RPT_030102_1_Load(object sender, EventArgs e)
  63. {
  64. try
  65. {
  66. // 加载权限
  67. FormPermissionManager.FormPermissionControl(Name, this,
  68. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  69. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  70. // 损坯原因
  71. DataSet dsRreason = DoAsync(
  72. () => { return SystemModuleProxy.Service.GetDictionaryData(0, "TPC009"); });
  73. DataRow row = dsRreason.Tables[0].NewRow();
  74. row["DictionaryValue"] = "";
  75. row["DictionaryID"] = 0;
  76. dsRreason.Tables[0].Rows.InsertAt(row, 0);
  77. cmbRreason.DisplayMember = "DictionaryValue";
  78. cmbRreason.ValueMember = "DictionaryID";
  79. cmbRreason.DataSource = dsRreason.Tables[0];
  80. // 设置表格不自动创建列
  81. dgvScrapProductTotal.AutoGenerateColumns = false;
  82. dgvScrapProductDetail.AutoGenerateColumns = false;
  83. dtpScrapDateStart.Value = DateTime.Now.Date;
  84. dtpScrapDateEnd.Value = DateTime.Now.Date;
  85. }
  86. catch (Exception ex)
  87. {
  88. // 对异常进行共通处理
  89. ExceptionManager.HandleEventException(ToString(),
  90. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  91. }
  92. }
  93. /// <summary>
  94. /// 查询按钮点击事件
  95. /// </summary>
  96. /// <param name="sender"></param>
  97. /// <param name="e"></param>
  98. private void btnSearch_Click(object sender, EventArgs e)
  99. {
  100. try
  101. {
  102. btnSearch.Enabled = false;
  103. btnClearCondition.Enabled = false;
  104. // 汇总表查询
  105. if (page.SelectedIndex == Constant.INT_IS_ZERO)
  106. {
  107. dgvScrapProductTotal.DataSource = null;
  108. dgvScrapProductTotal.DataSource = GetSearchTotalData();
  109. }
  110. // 明细表查询
  111. else
  112. {
  113. dgvScrapProductDetail.DataSource = null;
  114. dgvScrapProductDetail.DataSource = GetSearchDetailData();
  115. }
  116. }
  117. catch (Exception ex)
  118. {
  119. // 对异常进行共通处理
  120. ExceptionManager.HandleEventException(ToString(),
  121. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  122. }
  123. finally
  124. {
  125. btnSearch.Enabled = true;
  126. btnClearCondition.Enabled = true;
  127. }
  128. }
  129. /// <summary>
  130. /// 双击单元格事件
  131. /// </summary>
  132. /// <param name="sender"></param>
  133. /// <param name="e"></param>
  134. private void dgvScrapProductTotal_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  135. {
  136. try
  137. {
  138. // 判断是否为空
  139. if (this.dgvScrapProductTotal.CurrentRow == null)
  140. {
  141. return;
  142. }
  143. dgvScrapProductDetail.DataSource = null;
  144. DataGridViewRow dgvr = dgvScrapProductTotal.CurrentRow;
  145. // 异步处理,验证挂起条码
  146. ClientRequestEntity cre = new ClientRequestEntity();
  147. cre.NameSpace = "F_RPT_030120";
  148. cre.Name = "GetAllocateOutDetail";
  149. // 创建实体,获取数据信息
  150. DateTime scrapDate = new DateTime();
  151. DateTime.TryParse(dgvr.Cells["ScrapDate1"].Value + "", out scrapDate);
  152. string rreason = dgvr.Cells["rreason1"].Value + "";
  153. string goodsCode = dgvr.Cells["GoodsCode1"].Value + "";
  154. // 正常选择统计行
  155. if (!goodsCode.Equals("--"))
  156. {
  157. page.SelectTab(1);
  158. // 获取查询条件
  159. cre.Properties["goodscode"] = goodsCode;
  160. cre.Properties["rreason"] = rreason;
  161. cre.Properties["scrapdatestart"] = scrapDate;
  162. cre.Properties["scrapdateend"] = scrapDate.AddDays(1);
  163. }
  164. // 调出类型小计行
  165. if (rreason.StartsWith("小计"))
  166. {
  167. page.SelectTab(1);
  168. dgvr = dgvScrapProductTotal.Rows[dgvScrapProductTotal.CurrentCell.RowIndex - 1];
  169. // 获取查询条件
  170. rreason = dgvr.Cells["rreason1"].Value + "";
  171. cre.Properties["rreason"] = rreason;
  172. cre.Properties["scrapdatestart"] = scrapDate;
  173. cre.Properties["scrapdateend"] = scrapDate.AddDays(1);
  174. }
  175. // 日期小计行
  176. if ((dgvr.Cells["ScrapDate1"].Value + "").StartsWith("小计"))
  177. {
  178. page.SelectTab(1);
  179. dgvr = dgvScrapProductTotal.Rows[dgvScrapProductTotal.CurrentCell.RowIndex - 1];
  180. // 获取查询条件
  181. scrapDate = Convert.ToDateTime(dgvr.Cells["ScrapDate1"].Value);
  182. cre.Properties["scrapdatestart"] = scrapDate;
  183. cre.Properties["scrapdateend"] = scrapDate.AddDays(1);
  184. }
  185. // 合计行
  186. if ((dgvr.Cells["ScrapDate1"].Value + "").StartsWith("合计"))
  187. {
  188. page.SelectTab(1);
  189. dgvr = dgvScrapProductTotal.Rows[dgvScrapProductTotal.CurrentCell.RowIndex - 2];
  190. DataGridViewRow dgvr1 = dgvScrapProductTotal.Rows[0];
  191. cre.Properties["scrapdatestart"] = Convert.ToDateTime(dgvr1.Cells["ScrapDate1"].Value);
  192. scrapDate = Convert.ToDateTime(dgvr.Cells["ScrapDate1"].Value);
  193. cre.Properties["scrapdateend"] = scrapDate.AddDays(1);
  194. }
  195. // 调用服务器端获取数据集
  196. ServiceResultEntity sre = DoAsync(
  197. () => { return PMModuleProxyNew.Service.HandleRequest(cre); });
  198. if (sre.Data.Tables[0].Rows.Count == 0)
  199. {
  200. // 提示未查找到数据
  201. MessageBox.Show(Messages.MSG_CMN_I002, Text,
  202. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  203. }
  204. dgvScrapProductDetail.DataSource = sre.Data.Tables[0];
  205. }
  206. catch (Exception ex)
  207. {
  208. // 对异常进行共通处理
  209. ExceptionManager.HandleEventException(ToString(),
  210. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  211. }
  212. finally
  213. {
  214. btnSearch.Enabled = true;
  215. btnClearCondition.Enabled = true;
  216. }
  217. }
  218. /// <summary>
  219. /// 清空条件按钮点击事件
  220. /// </summary>
  221. /// <param name="sender"></param>
  222. /// <param name="e"></param>
  223. private void btnClearCondition_Click(object sender, EventArgs e)
  224. {
  225. dtpScrapDateStart.Value = DateTime.Now.Date;
  226. dtpScrapDateEnd.Value = DateTime.Now.Date;
  227. txtGoodsCode.Clear();
  228. cmbRreason.SelectedIndex = 0;
  229. txtBarCode.Clear();
  230. }
  231. /// <summary>
  232. /// 自动适应列宽按钮点击事件
  233. /// </summary>
  234. /// <param name="sender"></param>
  235. /// <param name="e"></param>
  236. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  237. {
  238. if (page.SelectedIndex == Constant.INT_IS_ZERO)
  239. {
  240. dgvScrapProductTotal.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  241. }
  242. else
  243. {
  244. dgvScrapProductDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  245. }
  246. }
  247. /// <summary>
  248. /// 关闭按钮点击事件
  249. /// </summary>
  250. /// <param name="sender"></param>
  251. /// <param name="e"></param>
  252. private void tsbtnClose_Click(object sender, EventArgs e)
  253. {
  254. Close();
  255. }
  256. /// <summary>
  257. /// 窗体关闭事件
  258. /// </summary>
  259. /// <param name="sender"></param>
  260. /// <param name="e"></param>
  261. private void F_RPT_030102_1_FormClosed(object sender, FormClosedEventArgs e)
  262. {
  263. _instance = null;
  264. }
  265. #endregion
  266. #region 私有方法
  267. /// <summary>
  268. /// 查询汇总表
  269. /// </summary>
  270. private DataTable GetSearchTotalData()
  271. {
  272. try
  273. {
  274. // 异步处理,验证挂起条码
  275. ClientRequestEntity cre = new ClientRequestEntity();
  276. cre.NameSpace = "F_RPT_030120";
  277. cre.Name = "GetAllocateOutTotal";
  278. cre.Properties["barcode"] = txtBarCode.Text.Trim();
  279. cre.Properties["goodscode"] = txtGoodsCode.Text.Trim();
  280. cre.Properties["scrapdatestart"] = dtpScrapDateStart.Value;
  281. cre.Properties["scrapdateend"] = dtpScrapDateEnd.Value.AddDays(1);
  282. cre.Properties["rreason"] = cmbRreason.Text.Trim();
  283. // 调用服务器端获取数据集
  284. ServiceResultEntity sre = DoAsync(
  285. () => { return PMModuleProxyNew.Service.HandleRequest(cre); });
  286. if (sre.Data.Tables[0].Rows.Count == 0)
  287. {
  288. // 提示未查找到数据
  289. MessageBox.Show(Messages.MSG_CMN_I002, Text,
  290. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  291. return null;
  292. }
  293. return sre.Data.Tables[0];
  294. }
  295. catch (Exception ex)
  296. {
  297. // 对异常进行共通处理
  298. ExceptionManager.HandleEventException(ToString(),
  299. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  300. return null;
  301. }
  302. }
  303. /// <summary>
  304. /// 查询明细表
  305. /// </summary>
  306. private DataTable GetSearchDetailData()
  307. {
  308. try
  309. {
  310. // 异步处理,验证挂起条码
  311. ClientRequestEntity cre = new ClientRequestEntity();
  312. cre.NameSpace = "F_RPT_030120";
  313. cre.Name = "GetAllocateOutDetail";
  314. cre.Properties["barcode"] = txtBarCode.Text.Trim();
  315. cre.Properties["goodscode"] = txtGoodsCode.Text.Trim();
  316. cre.Properties["scrapdatestart"] = dtpScrapDateStart.Value;
  317. cre.Properties["scrapdateend"] = dtpScrapDateEnd.Value.AddDays(1);
  318. cre.Properties["rreason"] = cmbRreason.Text.Trim();
  319. // 调用服务器端获取数据集
  320. ServiceResultEntity sre = DoAsync(
  321. () => { return PMModuleProxyNew.Service.HandleRequest(cre); });
  322. if (sre.Status == Constant.ServiceResultStatus.NoSearchResults)
  323. {
  324. // 提示未查找到数据
  325. MessageBox.Show(Messages.MSG_CMN_I002, tapUndoDetail.Text,
  326. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  327. return null;
  328. }
  329. return sre.Data.Tables[0];
  330. }
  331. catch (Exception ex)
  332. {
  333. // 对异常进行共通处理
  334. ExceptionManager.HandleEventException(ToString(),
  335. System.Reflection.MethodBase.GetCurrentMethod().Name, Text, ex);
  336. return null;
  337. }
  338. }
  339. #endregion
  340. }
  341. }