F_RPT_030116.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_030116.cs
  5. * 2.功能描述:成型存坯汇总表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2018/04/01 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.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.WCF.DataModels;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
  19. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  20. using Dongke.IBOSS.PRD.Client.Controls;
  21. using System.Collections.Generic;
  22. namespace Dongke.IBOSS.PRD.Client.ReportModule
  23. {
  24. /// <summary>
  25. /// 成型存坯汇总表
  26. /// </summary>
  27. public partial class F_RPT_030116 : DKDockPanelBase
  28. {
  29. #region 成员变量
  30. //单例模式
  31. private static F_RPT_030116 _instance;
  32. ClientRequestEntity _cre1 = null;
  33. ClientRequestEntity _cre2 = null;
  34. #endregion
  35. #region 构造函数
  36. /// <summary>
  37. /// 废弃一览构造
  38. /// </summary>
  39. public F_RPT_030116()
  40. {
  41. InitializeComponent();
  42. this.Text = "成型存坯汇总表";
  43. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  44. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  45. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  46. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  47. }
  48. #endregion
  49. #region 单例模式
  50. /// <summary>
  51. /// 单例模式,防止重复创建窗体
  52. /// </summary>
  53. public static F_RPT_030116 Instance
  54. {
  55. get
  56. {
  57. if (_instance == null)
  58. {
  59. _instance = new F_RPT_030116();
  60. }
  61. return _instance;
  62. }
  63. }
  64. #endregion
  65. #region 事件
  66. /// <summary>
  67. /// 查询事件
  68. /// </summary>
  69. /// <param name="sender"></param>
  70. /// <param name="e"></param>
  71. private void btnSearch_Click(object sender, EventArgs e)
  72. {
  73. try
  74. {
  75. // 汇总表
  76. if (this.tabControl1.SelectedIndex == 0)
  77. {
  78. this.dgvG1.DataSource = null;
  79. this._cre1 = new ClientRequestEntity();
  80. this._cre1.NameSpace = "R03";
  81. this._cre1.Name = "R030116Goods";
  82. this._cre1.Properties["LineCode"] = this.txtLinCode.Text.Trim();
  83. this._cre1.Properties["UserCode"] = this.txtUserCode.Text.Trim();
  84. this._cre1.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  85. this._cre1.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  86. if (this.chkGDate.Checked)
  87. {
  88. this._cre1.Properties["DateBegin"] = this.txtTimeStart.Value;
  89. this._cre1.Properties["DateEnd"] = this.txtTimeEnd.Value;
  90. }
  91. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  92. {
  93. return ReportModuleProxy.Service.DoRequest(_cre1);
  94. });
  95. if (resultEntity == null || resultEntity.Data == null ||
  96. resultEntity.Data.Tables.Count == 0 ||
  97. resultEntity.Data.Tables[0].Rows.Count == 0)
  98. {
  99. this.dgvG1.AutoResizeColumns();
  100. return;
  101. }
  102. else
  103. {
  104. this.dgvG1.DataSource = resultEntity.Data.Tables[0];
  105. this.dgvG1.ReadOnly = true;
  106. this.dgvG1.Rows[0].Selected = true;
  107. this.dgvG1.AutoResizeColumns();
  108. }
  109. }
  110. else if (this.tabControl1.SelectedIndex == 1)
  111. {
  112. this.dgvG2.DataSource = null;
  113. this._cre2 = new ClientRequestEntity();
  114. this._cre2.NameSpace = "R03";
  115. this._cre2.Name = "R030116User";
  116. this._cre2.Properties["LineCode"] = this.txtLinCode.Text.Trim();
  117. this._cre2.Properties["UserCode"] = this.txtUserCode.Text.Trim();
  118. this._cre2.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  119. this._cre2.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  120. if (this.chkGDate.Checked)
  121. {
  122. this._cre2.Properties["DateBegin"] = this.txtTimeStart.Value;
  123. this._cre2.Properties["DateEnd"] = this.txtTimeEnd.Value;
  124. }
  125. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  126. {
  127. return ReportModuleProxy.Service.DoRequest(_cre2);
  128. });
  129. if (resultEntity == null || resultEntity.Data == null ||
  130. resultEntity.Data.Tables.Count == 0 ||
  131. resultEntity.Data.Tables[0].Rows.Count == 0)
  132. {
  133. this.dgvG2.AutoResizeColumns();
  134. return;
  135. }
  136. else
  137. {
  138. this.dgvG2.DataSource = resultEntity.Data.Tables[0];
  139. this.dgvG2.ReadOnly = true;
  140. this.dgvG2.Rows[0].Selected = true;
  141. this.dgvG2.AutoResizeColumns();
  142. }
  143. }
  144. // 明细表
  145. else
  146. {
  147. this.dgvG3.DataSource = null;
  148. ClientRequestEntity cre = new ClientRequestEntity();
  149. cre.NameSpace = "R03";
  150. cre.Name = "R030116D";
  151. cre.Properties["LineCode"] = this.txtLinCode.Text.Trim();
  152. cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
  153. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  154. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  155. if (this.chkGDate.Checked)
  156. {
  157. cre.Properties["DateBegin"] = this.txtTimeStart.Value;
  158. cre.Properties["DateEnd"] = this.txtTimeEnd.Value;
  159. }
  160. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  161. {
  162. return ReportModuleProxy.Service.DoRequest(cre);
  163. });
  164. if (resultEntity == null || resultEntity.Data == null ||
  165. resultEntity.Data.Tables.Count == 0 ||
  166. resultEntity.Data.Tables[0].Rows.Count == 0)
  167. {
  168. this.dgvG3.AutoResizeColumns();
  169. return;
  170. }
  171. else
  172. {
  173. this.dgvG3.DataSource = resultEntity.Data.Tables[0];
  174. this.dgvG3.ReadOnly = true;
  175. this.dgvG3.Rows[0].Selected = true;
  176. this.dgvG3.AutoResizeColumns();
  177. }
  178. }
  179. }
  180. catch (Exception ex)
  181. {
  182. // 对异常进行共通处理
  183. ExceptionManager.HandleEventException(this.ToString(),
  184. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  185. }
  186. }
  187. /// <summary>
  188. /// 清空条件
  189. /// </summary>
  190. /// <param name="sender"></param>
  191. /// <param name="e"></param>
  192. private void btnClearCondition_Click(object sender, EventArgs e)
  193. {
  194. this.txtLinCode.Clear();
  195. this.txtUserCode.Clear();
  196. this.scbGoodsType.ClearValue();
  197. this.txtGoodsCode.Text = string.Empty;
  198. this.chkGDate.Checked = false;
  199. }
  200. /// <summary>
  201. /// 关闭一览窗体
  202. /// </summary>
  203. /// <param name="sender"></param>
  204. /// <param name="e"></param>
  205. private void tsbtnClose_Click(object sender, EventArgs e)
  206. {
  207. this.Close();
  208. }
  209. /// <summary>
  210. /// 窗体关闭事件
  211. /// </summary>
  212. /// <param name="sender"></param>
  213. /// <param name="e"></param>
  214. private void F_RPT_030110_FormClosed(object sender, FormClosedEventArgs e)
  215. {
  216. _instance = null;
  217. }
  218. /// <summary>
  219. /// 自动列宽
  220. /// </summary>
  221. /// <param name="sender"></param>
  222. /// <param name="e"></param>
  223. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  224. {
  225. this.dgvG1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  226. this.dgvG2.AutoResizeColumns();
  227. this.dgvG3.AutoResizeColumns();
  228. }
  229. /// <summary>
  230. /// 窗体加载
  231. /// </summary>
  232. /// <param name="sender"></param>
  233. /// <param name="e"></param>
  234. private void F_RPT_030110_Load(object sender, EventArgs e)
  235. {
  236. try
  237. {
  238. // 加载权限
  239. FormPermissionManager.FormPermissionControl(this.Name, this,
  240. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  241. Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  242. this.dgvG1.AutoGenerateColumns = false;
  243. // 设置日期控件默认值
  244. DateTime date = DateTime.Now;
  245. this.txtTimeStart.Value = new DateTime(date.Year, date.Month, 1);
  246. this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddSeconds(-1);
  247. }
  248. catch (Exception ex)
  249. {
  250. // 对异常进行共通处理
  251. ExceptionManager.HandleEventException(this.ToString(),
  252. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  253. }
  254. }
  255. private void chkGDate_CheckedChanged(object sender, EventArgs e)
  256. {
  257. this.txtTimeStart.Enabled = this.chkGDate.Checked;
  258. this.txtTimeEnd.Enabled = this.chkGDate.Checked;
  259. if (!this.chkGDate.Checked)
  260. {
  261. DateTime date = DateTime.Now;
  262. this.txtTimeStart.Value = new DateTime(date.Year, date.Month, 1);
  263. this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddSeconds(-1);
  264. }
  265. }
  266. private void dgvG1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  267. {
  268. if (e.ColumnIndex < 0 || e.RowIndex < 0 || this.dgvG1.CurrentRow == null)
  269. {
  270. return;
  271. }
  272. try
  273. {
  274. this.dgvG3.DataSource = null;
  275. this._cre1.NameSpace = "R03";
  276. this._cre1.Name = "R030116D";
  277. this._cre1.Properties["GoodsID"] = this.dgvG1.CurrentRow.Cells["g1GOODSID"].Value;
  278. this.tabControl1.SelectedIndex = 2;
  279. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  280. {
  281. return ReportModuleProxy.Service.DoRequest(this._cre1);
  282. });
  283. if (resultEntity == null || resultEntity.Data == null ||
  284. resultEntity.Data.Tables.Count == 0 ||
  285. resultEntity.Data.Tables[0].Rows.Count == 0)
  286. {
  287. this.dgvG3.AutoResizeColumns();
  288. return;
  289. }
  290. else
  291. {
  292. this.dgvG3.DataSource = resultEntity.Data.Tables[0];
  293. this.dgvG3.ReadOnly = true;
  294. this.dgvG3.Rows[0].Selected = true;
  295. this.dgvG3.AutoResizeColumns();
  296. }
  297. }
  298. catch (Exception ex)
  299. {
  300. // 对异常进行共通处理
  301. ExceptionManager.HandleEventException(this.ToString(),
  302. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  303. }
  304. }
  305. private void dgvG2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  306. {
  307. if (e.ColumnIndex < 0 || e.RowIndex < 0 || this.dgvG2.CurrentRow == null)
  308. {
  309. return;
  310. }
  311. try
  312. {
  313. this.dgvG3.DataSource = null;
  314. this._cre2.NameSpace = "R03";
  315. this._cre2.Name = "R030116D";
  316. this._cre2.Properties["LineID"] = this.dgvG2.CurrentRow.Cells["g2groutinglineid"].Value;
  317. this._cre2.Properties["UserID"] = this.dgvG2.CurrentRow.Cells["g2userid"].Value;
  318. this._cre2.Properties["GoodsID"] = this.dgvG2.CurrentRow.Cells["g2GOODSID"].Value;
  319. this.tabControl1.SelectedIndex = 2;
  320. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  321. {
  322. return ReportModuleProxy.Service.DoRequest(this._cre2);
  323. });
  324. if (resultEntity == null || resultEntity.Data == null ||
  325. resultEntity.Data.Tables.Count == 0 ||
  326. resultEntity.Data.Tables[0].Rows.Count == 0)
  327. {
  328. this.dgvG3.AutoResizeColumns();
  329. return;
  330. }
  331. else
  332. {
  333. this.dgvG3.DataSource = resultEntity.Data.Tables[0];
  334. this.dgvG3.ReadOnly = true;
  335. this.dgvG3.Rows[0].Selected = true;
  336. this.dgvG3.AutoResizeColumns();
  337. }
  338. }
  339. catch (Exception ex)
  340. {
  341. // 对异常进行共通处理
  342. ExceptionManager.HandleEventException(this.ToString(),
  343. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  344. }
  345. }
  346. #endregion
  347. #region 私有方法
  348. /// <summary>
  349. /// 根据界面查询条件获取数据集
  350. /// </summary>
  351. private DataTable GetData(ClientRequestEntity cre)
  352. {
  353. try
  354. {
  355. ServiceResultEntity resultEntity = ReportModuleProxy.Service.DoRequest(cre);
  356. if (resultEntity == null || resultEntity.Data == null || resultEntity.Data.Tables.Count == 0)
  357. {
  358. return null;
  359. }
  360. return resultEntity.Data.Tables[0];
  361. }
  362. catch (Exception ex)
  363. {
  364. throw ex;
  365. }
  366. }
  367. #endregion
  368. }
  369. }