F_RPT_030113.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_030113.cs
  5. * 2.功能描述:模具收发存汇总表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2017/12/26 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Reflection;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  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.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.ReportModule
  22. {
  23. /// <summary>
  24. /// 模具收发存汇总表
  25. /// </summary>
  26. public partial class F_RPT_030113 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. private static F_RPT_030113 _instance = null;
  30. private ClientRequestEntity _sumCRE = null;
  31. #endregion
  32. #region 单例模式
  33. /// <summary>
  34. /// 单例模式,防止重复创建窗体
  35. /// </summary>
  36. public static F_RPT_030113 Instance
  37. {
  38. get
  39. {
  40. if (_instance == null)
  41. {
  42. _instance = new F_RPT_030113();
  43. }
  44. return _instance;
  45. }
  46. }
  47. #endregion
  48. #region 构造函数
  49. /// <summary>
  50. ///
  51. /// </summary>
  52. public F_RPT_030113()
  53. {
  54. InitializeComponent();
  55. this.Text = "模具收发存汇总表";
  56. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  57. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  58. this.dgvSum.AutoGenerateColumns = false;
  59. this.dgvIN.AutoGenerateColumns = false;
  60. this.dgvOUT.AutoGenerateColumns = false;
  61. }
  62. #endregion
  63. #region 控件事件
  64. /// <summary>
  65. /// 关闭
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. private void F_PC_1001_FormClosed(object sender, FormClosedEventArgs e)
  70. {
  71. _instance = null;
  72. }
  73. /// <summary>
  74. /// 画面加载
  75. /// </summary>
  76. /// <param name="sender"></param>
  77. /// <param name="e"></param>
  78. private void F_PC_1001_Load(object sender, System.EventArgs e)
  79. {
  80. try
  81. {
  82. this.dtpMonth1.Value = DateTime.Now.AddMonths(-1);
  83. this.dtpMonth2.Value = DateTime.Now;
  84. }
  85. catch (Exception ex)
  86. {
  87. // 对异常进行共通处理
  88. ExceptionManager.HandleEventException(this.ToString(),
  89. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  90. }
  91. }
  92. /// <summary>
  93. /// 查询
  94. /// </summary>
  95. /// <param name="sender"></param>
  96. /// <param name="e"></param>
  97. private void tsbtnSearch_Click(object sender, EventArgs e)
  98. {
  99. try
  100. {
  101. this.QueryDataFromOther(this.tabControl1.SelectedIndex);
  102. }
  103. catch (Exception ex)
  104. {
  105. // 对异常进行共通处理
  106. ExceptionManager.HandleEventException(this.ToString(),
  107. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  108. }
  109. }
  110. /// <summary>
  111. /// 清除条件
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void tsbtnClearCondition_Click(object sender, EventArgs e)
  116. {
  117. this.dtpMonth1.Value = DateTime.Now.AddMonths(-1);
  118. this.dtpMonth2.Value = DateTime.Now;
  119. this.scbGoods.ClearValue();
  120. this.scbGoodsType.ClearValue();
  121. }
  122. /// <summary>
  123. /// 自适应列宽
  124. /// </summary>
  125. /// <param name="sender"></param>
  126. /// <param name="e"></param>
  127. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  128. {
  129. this.dgvSum.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  130. this.dgvIN.AutoResizeColumns();
  131. this.dgvOUT.AutoResizeColumns();
  132. }
  133. /// <summary>
  134. /// 关闭画面
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void tsbtnClose_Click(object sender, EventArgs e)
  139. {
  140. this.Close();
  141. }
  142. /// <summary>
  143. /// 入出库明细
  144. /// </summary>
  145. /// <param name="sender"></param>
  146. /// <param name="e"></param>
  147. private void dgvSum_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  148. {
  149. if (e.ColumnIndex < 0 || e.RowIndex < 0)
  150. {
  151. return;
  152. }
  153. try
  154. {
  155. string colName = this.dgvSum.Columns[e.ColumnIndex].Name;
  156. if (colName == "MI_1")
  157. {
  158. this.QueryDataFromOther(-1);
  159. this.tabControl1.SelectedIndex = 1;
  160. }
  161. else if (colName == "MO_1")
  162. {
  163. this.QueryDataFromOther(-2);
  164. this.tabControl1.SelectedIndex = 2;
  165. }
  166. }
  167. catch (Exception ex)
  168. {
  169. // 对异常进行共通处理
  170. ExceptionManager.HandleEventException(this.ToString(),
  171. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  172. }
  173. }
  174. #endregion
  175. #region 私有方法
  176. /// <summary>
  177. /// 查询数据
  178. /// </summary>
  179. /// <param name="type">-2:Grid双击(出);-1:Grid双击(入);0:总单;1:入库;2:出库</param>
  180. private void QueryDataFromOther(int type)
  181. {
  182. try
  183. {
  184. this.tsrToolStrip1.Focus();
  185. ClientRequestEntity cre = new ClientRequestEntity();
  186. cre.NameSpace = "R03";
  187. cre.Name = "R030113";
  188. if (type < 0 && (this._sumCRE == null || this.dgvSum.CurrentCell == null))
  189. {
  190. type = 0;
  191. }
  192. if (type < 0)
  193. {
  194. DataRowView drv = this.dgvSum.CurrentRow.DataBoundItem as DataRowView;
  195. cre.Properties["YYYYMM"] = this._sumCRE.Properties["YYYYMM"];
  196. cre.Properties["DateBegin"] = this._sumCRE.Properties["DateBegin"];
  197. cre.Properties["DateEnd"] = this._sumCRE.Properties["DateEnd"];
  198. if (drv["GoodsID"] != DBNull.Value)
  199. {
  200. cre.Properties["GoodsID"] = drv["GoodsID"];
  201. }
  202. else if (this._sumCRE.Properties["GoodsID"] != null)
  203. {
  204. cre.Properties["GoodsID"] = this._sumCRE.Properties["GoodsID"];
  205. }
  206. else if (this._sumCRE.Properties["GoodsIDs"] != null)
  207. {
  208. cre.Properties["GoodsIDs"] = this._sumCRE.Properties["GoodsIDs"];
  209. }
  210. if (drv["GoodsTypeCode"] != DBNull.Value)
  211. {
  212. cre.Properties["GoodsTypeCode"] = drv["GoodsTypeCode"];
  213. }
  214. else
  215. {
  216. cre.Properties["GoodsTypeCode"] = this._sumCRE.Properties["GoodsTypeCode"];
  217. }
  218. cre.Properties["Type"] = 0 - type;
  219. }
  220. else
  221. {
  222. cre.Properties["YYYYMM"] = this.dtpMonth1.Value.Value.AddMonths(-1).ToString("yyyyMM");
  223. cre.Properties["DateBegin"] = this.dtpMonth1.Value.Value;
  224. cre.Properties["DateEnd"] = this.dtpMonth2.Value.Value.AddMonths(1);
  225. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  226. if (!string.IsNullOrWhiteSpace(this.scbGoods.Text))
  227. {
  228. if (this.scbGoods.CheckedPKMember.Contains(","))
  229. {
  230. cre.Properties["GoodsIDs"] = scbGoods.CheckedPKMember;
  231. }
  232. else
  233. {
  234. cre.Properties["GoodsID"] = scbGoods.SearchedPKMember;
  235. }
  236. }
  237. cre.Properties["Type"] = type;
  238. }
  239. if (type == 0)
  240. {
  241. this.dgvSum.DataSource = null;
  242. this._sumCRE = cre;
  243. }
  244. else if (type == 1 || type == -1)
  245. {
  246. this.dgvIN.DataSource = null;
  247. }
  248. else
  249. {
  250. this.dgvOUT.DataSource = null;
  251. }
  252. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  253. {
  254. return ReportModuleProxy.Service.DoRequest(cre);
  255. }
  256. );
  257. if (sre.Status == Constant.ServiceResultStatus.Success)
  258. {
  259. // 查询成功
  260. if (type == 0)
  261. {
  262. this.dgvSum.DataSource = sre.Data.Tables[0];
  263. }
  264. else if (type == 1 || type == -1)
  265. {
  266. this.dgvIN.DataSource = sre.Data.Tables[0];
  267. }
  268. else
  269. {
  270. this.dgvOUT.DataSource = sre.Data.Tables[0];
  271. }
  272. }
  273. }
  274. catch (Exception ex)
  275. {
  276. throw ex;
  277. }
  278. }
  279. #endregion
  280. }
  281. }