F_RPT_030112.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. /*******************************************************************************
  2. * Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_RPT_030102_1.cs
  5. * 2.功能描述:产成品交接汇总表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 袁新成 2015/4/14 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Text;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.DockPanel;
  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. using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
  22. namespace Dongke.IBOSS.PRD.Client.ReportModule
  23. {
  24. public partial class F_RPT_030112 : DKDockPanelBase
  25. {
  26. #region 成员变量
  27. // 窗体的单例模式
  28. private static F_RPT_030112 _instance;
  29. //实体类
  30. private RPT030102_SE _rptse = null;
  31. private RPT030102_SE _rptse1 = null;
  32. // 存储查询条件
  33. private SearchFinishedProductEntity _orderEntity = null;
  34. //private SearchFinishedProductEntity _orderEntity2 = null;
  35. private SearchFinishedProductEntity _orderCRE = null;
  36. #endregion
  37. #region 构造函数
  38. public F_RPT_030112()
  39. {
  40. InitializeComponent();
  41. // 窗体显示的Title
  42. this.Text = FormTitles.F_RPT_030112;
  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. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  48. }
  49. #endregion
  50. #region 单例模式
  51. /// <summary>
  52. /// 单例模式,防止重复创建窗体
  53. /// </summary>
  54. public static F_RPT_030112 Instance
  55. {
  56. get
  57. {
  58. if (_instance == null || _instance.IsDisposed)
  59. {
  60. _instance = new F_RPT_030112();
  61. }
  62. return _instance;
  63. }
  64. }
  65. #endregion
  66. #region 事件处理
  67. /// <summary>
  68. /// 窗体加载事件
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. private void F_RPT_030102_1_Load(object sender, EventArgs e)
  73. {
  74. try
  75. {
  76. // 加载权限
  77. FormPermissionManager.FormPermissionControl(this.Name, this,
  78. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  79. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  80. // 设置表格不自动创建列
  81. this.dgvOrder.AutoGenerateColumns = false;
  82. this.dgvOrderDetail.AutoGenerateColumns = false;
  83. //this.dtpStartTime.Enabled = false;
  84. //this.dtpEndTime.Enabled = false;
  85. this.dtpStartTime.Value = DateTime.Now.Date;
  86. this.dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  87. this.chkTestMouldFlag.AllItemCheck();
  88. }
  89. catch (Exception ex)
  90. {
  91. // 对异常进行共通处理
  92. ExceptionManager.HandleEventException(this.ToString(),
  93. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  94. }
  95. }
  96. /// <summary>
  97. /// 窗体关闭事件
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. private void F_RPT_030102_1_FormClosed(object sender, FormClosedEventArgs e)
  102. {
  103. _instance = null;
  104. }
  105. /// <summary>
  106. /// 关闭按钮
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. private void tsbtnClose_Click(object sender, EventArgs e)
  111. {
  112. this.Close();
  113. }
  114. /// <summary>
  115. /// 自动适应列宽
  116. /// </summary>
  117. /// <param name="sender"></param>
  118. /// <param name="e"></param>
  119. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  120. {
  121. if (this.tblScrapTotalModule.SelectedIndex == Constant.INT_IS_ZERO)
  122. {
  123. this.dgvOrder.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  124. }
  125. else
  126. {
  127. this.dgvOrderDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  128. }
  129. }
  130. /// <summary>
  131. /// 查询按钮事件
  132. /// </summary>
  133. /// <param name="sender"></param>
  134. /// <param name="e"></param>
  135. private void btnSearch_Click(object sender, EventArgs e)
  136. {
  137. try
  138. {
  139. GetOrderEntityFromLayout();// 设置查询实体类
  140. if (this.tblScrapTotalModule.SelectedIndex == 0)//交接汇总查询
  141. {
  142. //this._orderEntity2 = this._orderEntity;
  143. //this.dgvOrder.DataSource = null;
  144. //this.dgvOrder.DataSource = this.GetSearchTotalData();
  145. _orderCRE = this._orderEntity;
  146. this.GetSearchTotalData();
  147. }
  148. else if (this.tblScrapTotalModule.SelectedIndex == 1)//交接明细查询
  149. {
  150. this.dgvOrderDetail.DataSource = null;
  151. this.dgvOrderDetail.DataSource = this.GetSearchDetailData();
  152. }
  153. else if (this.tblScrapTotalModule.SelectedIndex == 2)//交接数量查询
  154. {
  155. this.dgvNum.DataSource = null;
  156. ClientRequestEntity cre = new ClientRequestEntity();
  157. cre.NameSpace = "R03";
  158. cre.Name = "R030112Num";
  159. cre.Properties["OrderNo"] = this.txtOrderNo.Text.Trim();
  160. cre.Properties["FHUserCode"] = this.txtFHUserCode.Text.Trim();
  161. if (this.chkDateTime.Checked)
  162. {
  163. cre.Properties["FHTimeStart"] = this.dtpStartTime.Value;
  164. cre.Properties["FHTimeEnd"] = this.dtpEndTime.Value;
  165. }
  166. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  167. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  168. cre.Properties["GoodsModel"] = this.txtGoodsModel.Text.Trim();
  169. cre.Properties["LogoIDS"] = this.dkLogoSearchBox1.LogoIDS;
  170. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  171. if (testMouldFlags.Length == 1)
  172. {
  173. cre.Properties["TestMouldFlag"] = testMouldFlags[0].ToString();
  174. }
  175. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  176. {
  177. return ReportModuleProxy.Service.DoRequest(cre);
  178. });
  179. if (resultEntity == null || resultEntity.Data == null ||
  180. resultEntity.Data.Tables.Count == 0 ||
  181. resultEntity.Data.Tables[0].Rows.Count == 0)
  182. {
  183. this.dgvNum.AutoResizeColumns();
  184. return;
  185. }
  186. else
  187. {
  188. this.dgvNum.DataSource = resultEntity.Data.Tables[0];
  189. this.dgvNum.ReadOnly = true;
  190. this.dgvNum.Rows[0].Selected = true;
  191. this.dgvNum.AutoResizeColumns();
  192. }
  193. }
  194. else if (this.tblScrapTotalModule.SelectedIndex == 3)//型号数量查询
  195. {
  196. this.dgvGoodsNum.DataSource = null;
  197. ClientRequestEntity cre = new ClientRequestEntity();
  198. cre.NameSpace = "R03";
  199. cre.Name = "R030112GoodsNum";
  200. cre.Properties["OrderNo"] = this.txtOrderNo.Text.Trim();
  201. cre.Properties["FHUserCode"] = this.txtFHUserCode.Text.Trim();
  202. if (this.chkDateTime.Checked)
  203. {
  204. cre.Properties["FHTimeStart"] = this.dtpStartTime.Value;
  205. cre.Properties["FHTimeEnd"] = this.dtpEndTime.Value;
  206. }
  207. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  208. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  209. cre.Properties["GoodsModel"] = this.txtGoodsModel.Text.Trim();
  210. cre.Properties["LogoIDS"] = this.dkLogoSearchBox1.LogoIDS;
  211. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  212. if (testMouldFlags.Length == 1)
  213. {
  214. cre.Properties["TestMouldFlag"] = testMouldFlags[0].ToString();
  215. }
  216. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  217. {
  218. return ReportModuleProxy.Service.DoRequest(cre);
  219. });
  220. if (resultEntity == null || resultEntity.Data == null ||
  221. resultEntity.Data.Tables.Count == 0 ||
  222. resultEntity.Data.Tables[0].Rows.Count == 0)
  223. {
  224. this.dgvGoodsNum.AutoResizeColumns();
  225. return;
  226. }
  227. else
  228. {
  229. this.dgvGoodsNum.DataSource = resultEntity.Data.Tables[0];
  230. this.dgvGoodsNum.ReadOnly = true;
  231. this.dgvGoodsNum.Rows[0].Selected = true;
  232. this.dgvGoodsNum.AutoResizeColumns();
  233. }
  234. }
  235. else
  236. {
  237. }
  238. }
  239. catch (Exception ex)
  240. {
  241. this.btnSearch.Enabled = true;
  242. // 对异常进行共通处理
  243. ExceptionManager.HandleEventException(this.ToString(),
  244. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  245. }
  246. }
  247. /// <summary>
  248. /// 清空条件按钮事件
  249. /// </summary>
  250. /// <param name="sender"></param>
  251. /// <param name="e"></param>
  252. private void btnClearCondition_Click(object sender, EventArgs e)
  253. {
  254. this.txtOrderNo.Clear();
  255. this.txtFHUserCode.Clear();
  256. this.chkDateTime.Checked = false;
  257. this.dtpStartTime.Value = DateTime.Now.Date;
  258. this.dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  259. this.scbGoodsType.ClearValue();
  260. this.txtGoodsCode.Clear();
  261. this.dkLogoSearchBox1.ClearControl();
  262. this.chkTestMouldFlag.AllItemCheck();
  263. }
  264. /// <summary>
  265. /// 双击单元格事件
  266. /// </summary>
  267. /// <param name="sender"></param>
  268. /// <param name="e"></param>
  269. private void dgvScrapTotalModule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  270. {
  271. try
  272. {
  273. //判断是否为空
  274. if (this.dgvOrder.CurrentRow == null)
  275. {
  276. return;
  277. }
  278. //获取数据信息
  279. DataRowView row = dgvOrder.CurrentRow.DataBoundItem as DataRowView;
  280. //this._orderEntity = _orderCRE;
  281. if (row["fhorderid"] == DBNull.Value)
  282. {
  283. this._orderCRE.OrderID = null;
  284. }
  285. else
  286. {
  287. this._orderCRE.OrderID = Convert.ToInt32(row["fhorderid"]);
  288. }
  289. if (row["goodsid"] == DBNull.Value)
  290. {
  291. this._orderCRE.GoodsID = null;
  292. }
  293. else
  294. {
  295. this._orderCRE.GoodsID = Convert.ToInt32(row["goodsid"]);
  296. }
  297. if (row["logoid"] == DBNull.Value)
  298. {
  299. this._orderCRE.LogoID = null;
  300. }
  301. else
  302. {
  303. this._orderCRE.LogoID = Convert.ToInt32(row["logoid"]);
  304. }
  305. this.dgvOrderDetail.DataSource = null;
  306. this.tblScrapTotalModule.SelectTab(1);
  307. this.dgvOrderDetail.DataSource = GetSearchDetailDataByDouble();
  308. }
  309. catch (Exception ex)
  310. {
  311. this.btnSearch.Enabled = true;
  312. this.btnClearCondition.Enabled = true;
  313. // 对异常进行共通处理
  314. ExceptionManager.HandleEventException(this.ToString(),
  315. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  316. }
  317. }
  318. /// <summary>
  319. /// 复选框按钮事件
  320. /// </summary>
  321. /// <param name="sender"></param>
  322. /// <param name="e"></param>
  323. private void chkDateTime_CheckedChanged(object sender, EventArgs e)
  324. {
  325. this.dtpStartTime.Enabled = chkDateTime.Checked;
  326. this.dtpEndTime.Enabled = chkDateTime.Checked;
  327. }
  328. #endregion
  329. #region 私有方法
  330. /// <summary>
  331. /// 搜索条件
  332. /// </summary>
  333. /// <returns></returns>
  334. private SearchFinishedProductEntity GetOrderEntityFromLayout()
  335. {
  336. this._orderEntity = new SearchFinishedProductEntity();
  337. this._orderEntity.OrderNo = this.txtOrderNo.Text.Trim();
  338. this._orderEntity.FHUserCode = this.txtFHUserCode.Text.Trim();
  339. if (this.chkDateTime.Checked)
  340. {
  341. this._orderEntity.FHTimeStart = this.dtpStartTime.Value;
  342. this._orderEntity.FHTimeEnd = this.dtpEndTime.Value;
  343. }
  344. this._orderEntity.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  345. this._orderEntity.GoodsCode = this.txtGoodsCode.Text.Trim();
  346. this._orderEntity.GoodsModel = this.txtGoodsModel.Text.Trim();
  347. this._orderEntity.LogoIDS = this.dkLogoSearchBox1.LogoIDS;
  348. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  349. if (testMouldFlags.Length == 1)
  350. {
  351. _orderEntity.TestMouldFlag = testMouldFlags[0].ToString();
  352. }
  353. return this._orderEntity;
  354. }
  355. /// <summary>
  356. /// 明细搜索条件
  357. /// </summary>
  358. /// <returns></returns>
  359. private void CreateSearchConditionDetail()
  360. {
  361. this._rptse = new RPT030102_SE();
  362. this._rptse.ProductionLineID = this._rptse1.ProductionLineID;
  363. this._rptse.GoodsTypeCode = this._rptse1.GoodsTypeCode;
  364. this._rptse.GoodsCode = this._rptse1.GoodsCode;
  365. this._rptse.ProcedureIDS = this._rptse1.ProcedureIDS;
  366. this._rptse.ScrapDateStart = this._rptse1.ScrapDateStart;
  367. this._rptse.ScrapDateEnd = this._rptse1.ScrapDateEnd;
  368. this._rptse.ResponProcedureIDS = this._rptse1.ResponProcedureIDS;
  369. this._rptse.ResponUserIDS = this._rptse1.ResponUserIDS;
  370. this._rptse.CreatUser = this._rptse1.CreatUser;
  371. this._rptse.AuditUser = this._rptse1.AuditUser;
  372. this._rptse.SpecialRepairFlag = this._rptse1.SpecialRepairFlag;
  373. }
  374. /// <summary>
  375. /// 查询损坏汇总表
  376. /// </summary>
  377. private DataTable GetSearchTotalData()
  378. {
  379. try
  380. {
  381. //// 调用服务器端获取数据集
  382. //ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  383. //{
  384. // return ReportModuleProxy.Service.GetRPT0030112SData(this._orderEntity);
  385. //}
  386. //);
  387. //if (sre.Status == Constant.ServiceResultStatus.Success)
  388. //{
  389. // if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  390. // {
  391. // // 提示未查找到数据
  392. // MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  393. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  394. // //清空数据
  395. // return null;
  396. // }
  397. // return sre.Data.Tables[0];
  398. //}
  399. this.dgvOrder.DataSource = null;
  400. ClientRequestEntity cre = new ClientRequestEntity();
  401. cre.NameSpace = "R03";
  402. cre.Name = "R030112Sum";
  403. cre.Properties["OrderNo"] = this.txtOrderNo.Text.Trim();
  404. cre.Properties["FHUserCode"] = this.txtFHUserCode.Text.Trim();
  405. if (this.chkDateTime.Checked)
  406. {
  407. cre.Properties["FHTimeStart"] = this.dtpStartTime.Value;
  408. cre.Properties["FHTimeEnd"] = this.dtpEndTime.Value;
  409. }
  410. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  411. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  412. cre.Properties["GoodsModel"] = this.txtGoodsModel.Text.Trim();
  413. cre.Properties["LogoIDS"] = this.dkLogoSearchBox1.LogoIDS;
  414. object[] testMouldFlags = this.chkTestMouldFlag.SelectedValues;
  415. if (testMouldFlags.Length == 1)
  416. {
  417. cre.Properties["TestMouldFlag"] = testMouldFlags[0].ToString();
  418. }
  419. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  420. {
  421. return ReportModuleProxy.Service.DoRequest(cre);
  422. });
  423. if (resultEntity == null || resultEntity.Data == null ||
  424. resultEntity.Data.Tables.Count == 0 ||
  425. resultEntity.Data.Tables[0].Rows.Count == 0)
  426. {
  427. this.dgvOrder.AutoResizeColumns();
  428. return null;
  429. }
  430. else
  431. {
  432. this.dgvOrder.DataSource = resultEntity.Data.Tables[0];
  433. this.dgvOrder.ReadOnly = true;
  434. this.dgvOrder.Rows[0].Selected = true;
  435. this.dgvOrder.AutoResizeColumns();
  436. }
  437. return null;
  438. }
  439. catch (Exception ex)
  440. {
  441. throw ex;
  442. }
  443. }
  444. /// <summary>
  445. /// 查询损坏明细表
  446. /// </summary>
  447. private DataTable GetSearchDetailData()
  448. {
  449. try
  450. {
  451. // 调用服务器端获取数据集
  452. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  453. {
  454. return ReportModuleProxy.Service.GetRPT0030112DetailSData(this._orderEntity);
  455. }
  456. );
  457. if (sre.Status == Constant.ServiceResultStatus.Success)
  458. {
  459. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  460. {
  461. // 提示未查找到数据
  462. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  463. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  464. //清空数据
  465. return null;
  466. }
  467. return sre.Data.Tables[0];
  468. }
  469. return null;
  470. }
  471. catch (Exception ex)
  472. {
  473. throw ex;
  474. }
  475. }
  476. /// <summary>
  477. /// 查询损坏明细表
  478. /// </summary>
  479. private DataTable GetSearchDetailDataByDouble()
  480. {
  481. try
  482. {
  483. // 调用服务器端获取数据集
  484. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  485. {
  486. return ReportModuleProxy.Service.GetRPT0030112DetailSData(this._orderCRE);
  487. }
  488. );
  489. if (sre.Status == Constant.ServiceResultStatus.Success)
  490. {
  491. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  492. {
  493. // 提示未查找到数据
  494. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  495. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  496. //清空数据
  497. return null;
  498. }
  499. return sre.Data.Tables[0];
  500. }
  501. return null;
  502. }
  503. catch (Exception ex)
  504. {
  505. throw ex;
  506. }
  507. }
  508. #endregion
  509. }
  510. }