F_RPT_030112.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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. }
  88. catch (Exception ex)
  89. {
  90. // 对异常进行共通处理
  91. ExceptionManager.HandleEventException(this.ToString(),
  92. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  93. }
  94. }
  95. /// <summary>
  96. /// 窗体关闭事件
  97. /// </summary>
  98. /// <param name="sender"></param>
  99. /// <param name="e"></param>
  100. private void F_RPT_030102_1_FormClosed(object sender, FormClosedEventArgs e)
  101. {
  102. _instance = null;
  103. }
  104. /// <summary>
  105. /// 关闭按钮
  106. /// </summary>
  107. /// <param name="sender"></param>
  108. /// <param name="e"></param>
  109. private void tsbtnClose_Click(object sender, EventArgs e)
  110. {
  111. this.Close();
  112. }
  113. /// <summary>
  114. /// 自动适应列宽
  115. /// </summary>
  116. /// <param name="sender"></param>
  117. /// <param name="e"></param>
  118. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  119. {
  120. if (this.tblScrapTotalModule.SelectedIndex == Constant.INT_IS_ZERO)
  121. {
  122. this.dgvOrder.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  123. }
  124. else
  125. {
  126. this.dgvOrderDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  127. }
  128. }
  129. /// <summary>
  130. /// 查询按钮事件
  131. /// </summary>
  132. /// <param name="sender"></param>
  133. /// <param name="e"></param>
  134. private void btnSearch_Click(object sender, EventArgs e)
  135. {
  136. try
  137. {
  138. GetOrderEntityFromLayout();// 设置查询实体类
  139. if (this.tblScrapTotalModule.SelectedIndex == 0)//交接汇总查询
  140. {
  141. //this._orderEntity2 = this._orderEntity;
  142. //this.dgvOrder.DataSource = null;
  143. //this.dgvOrder.DataSource = this.GetSearchTotalData();
  144. _orderCRE = this._orderEntity;
  145. this.GetSearchTotalData();
  146. }
  147. else if (this.tblScrapTotalModule.SelectedIndex == 1)//交接明细查询
  148. {
  149. this.dgvOrderDetail.DataSource = null;
  150. this.dgvOrderDetail.DataSource = this.GetSearchDetailData();
  151. }
  152. else if (this.tblScrapTotalModule.SelectedIndex == 2)//交接数量查询
  153. {
  154. this.dgvNum.DataSource = null;
  155. ClientRequestEntity cre = new ClientRequestEntity();
  156. cre.NameSpace = "R03";
  157. cre.Name = "R030112Num";
  158. cre.Properties["OrderNo"] = this.txtOrderNo.Text.Trim();
  159. cre.Properties["FHUserCode"] = this.txtFHUserCode.Text.Trim();
  160. if (this.chkDateTime.Checked)
  161. {
  162. cre.Properties["FHTimeStart"] = this.dtpStartTime.Value;
  163. cre.Properties["FHTimeEnd"] = this.dtpEndTime.Value;
  164. }
  165. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  166. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  167. cre.Properties["GoodsModel"] = this.txtGoodsModel.Text.Trim();
  168. cre.Properties["LogoIDS"] = this.dkLogoSearchBox1.LogoIDS;
  169. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  170. {
  171. return ReportModuleProxy.Service.DoRequest(cre);
  172. });
  173. if (resultEntity == null || resultEntity.Data == null ||
  174. resultEntity.Data.Tables.Count == 0 ||
  175. resultEntity.Data.Tables[0].Rows.Count == 0)
  176. {
  177. this.dgvNum.AutoResizeColumns();
  178. return;
  179. }
  180. else
  181. {
  182. this.dgvNum.DataSource = resultEntity.Data.Tables[0];
  183. this.dgvNum.ReadOnly = true;
  184. this.dgvNum.Rows[0].Selected = true;
  185. this.dgvNum.AutoResizeColumns();
  186. }
  187. }
  188. else if (this.tblScrapTotalModule.SelectedIndex == 3)//型号数量查询
  189. {
  190. this.dgvGoodsNum.DataSource = null;
  191. ClientRequestEntity cre = new ClientRequestEntity();
  192. cre.NameSpace = "R03";
  193. cre.Name = "R030112GoodsNum";
  194. cre.Properties["OrderNo"] = this.txtOrderNo.Text.Trim();
  195. cre.Properties["FHUserCode"] = this.txtFHUserCode.Text.Trim();
  196. if (this.chkDateTime.Checked)
  197. {
  198. cre.Properties["FHTimeStart"] = this.dtpStartTime.Value;
  199. cre.Properties["FHTimeEnd"] = this.dtpEndTime.Value;
  200. }
  201. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  202. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  203. cre.Properties["GoodsModel"] = this.txtGoodsModel.Text.Trim();
  204. cre.Properties["LogoIDS"] = this.dkLogoSearchBox1.LogoIDS;
  205. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  206. {
  207. return ReportModuleProxy.Service.DoRequest(cre);
  208. });
  209. if (resultEntity == null || resultEntity.Data == null ||
  210. resultEntity.Data.Tables.Count == 0 ||
  211. resultEntity.Data.Tables[0].Rows.Count == 0)
  212. {
  213. this.dgvGoodsNum.AutoResizeColumns();
  214. return;
  215. }
  216. else
  217. {
  218. this.dgvGoodsNum.DataSource = resultEntity.Data.Tables[0];
  219. this.dgvGoodsNum.ReadOnly = true;
  220. this.dgvGoodsNum.Rows[0].Selected = true;
  221. this.dgvGoodsNum.AutoResizeColumns();
  222. }
  223. }
  224. else
  225. {
  226. }
  227. }
  228. catch (Exception ex)
  229. {
  230. this.btnSearch.Enabled = true;
  231. // 对异常进行共通处理
  232. ExceptionManager.HandleEventException(this.ToString(),
  233. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  234. }
  235. }
  236. /// <summary>
  237. /// 清空条件按钮事件
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. private void btnClearCondition_Click(object sender, EventArgs e)
  242. {
  243. this.txtOrderNo.Clear();
  244. this.txtFHUserCode.Clear();
  245. this.chkDateTime.Checked = false;
  246. this.dtpStartTime.Value = DateTime.Now.Date;
  247. this.dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  248. this.scbGoodsType.ClearValue();
  249. this.txtGoodsCode.Clear();
  250. this.dkLogoSearchBox1.ClearControl();
  251. }
  252. /// <summary>
  253. /// 双击单元格事件
  254. /// </summary>
  255. /// <param name="sender"></param>
  256. /// <param name="e"></param>
  257. private void dgvScrapTotalModule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  258. {
  259. try
  260. {
  261. //判断是否为空
  262. if (this.dgvOrder.CurrentRow == null)
  263. {
  264. return;
  265. }
  266. //获取数据信息
  267. DataRowView row = dgvOrder.CurrentRow.DataBoundItem as DataRowView;
  268. //this._orderEntity = _orderCRE;
  269. if (row["fhorderid"] == DBNull.Value)
  270. {
  271. this._orderCRE.OrderID = null;
  272. }
  273. else
  274. {
  275. this._orderCRE.OrderID = Convert.ToInt32(row["fhorderid"]);
  276. }
  277. if (row["goodsid"] == DBNull.Value)
  278. {
  279. this._orderCRE.GoodsID = null;
  280. }
  281. else
  282. {
  283. this._orderCRE.GoodsID = Convert.ToInt32(row["goodsid"]);
  284. }
  285. if (row["logoid"] == DBNull.Value)
  286. {
  287. this._orderCRE.LogoID = null;
  288. }
  289. else
  290. {
  291. this._orderCRE.LogoID = Convert.ToInt32(row["logoid"]);
  292. }
  293. this.dgvOrderDetail.DataSource = null;
  294. this.tblScrapTotalModule.SelectTab(1);
  295. this.dgvOrderDetail.DataSource = GetSearchDetailDataByDouble();
  296. }
  297. catch (Exception ex)
  298. {
  299. this.btnSearch.Enabled = true;
  300. this.btnClearCondition.Enabled = true;
  301. // 对异常进行共通处理
  302. ExceptionManager.HandleEventException(this.ToString(),
  303. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  304. }
  305. }
  306. /// <summary>
  307. /// 复选框按钮事件
  308. /// </summary>
  309. /// <param name="sender"></param>
  310. /// <param name="e"></param>
  311. private void chkDateTime_CheckedChanged(object sender, EventArgs e)
  312. {
  313. this.dtpStartTime.Enabled = chkDateTime.Checked;
  314. this.dtpEndTime.Enabled = chkDateTime.Checked;
  315. }
  316. #endregion
  317. #region 私有方法
  318. /// <summary>
  319. /// 搜索条件
  320. /// </summary>
  321. /// <returns></returns>
  322. private SearchFinishedProductEntity GetOrderEntityFromLayout()
  323. {
  324. this._orderEntity = new SearchFinishedProductEntity();
  325. this._orderEntity.OrderNo = this.txtOrderNo.Text.Trim();
  326. this._orderEntity.FHUserCode = this.txtFHUserCode.Text.Trim();
  327. if (this.chkDateTime.Checked)
  328. {
  329. this._orderEntity.FHTimeStart = this.dtpStartTime.Value;
  330. this._orderEntity.FHTimeEnd = this.dtpEndTime.Value;
  331. }
  332. this._orderEntity.GoodsTypeCode = scbGoodsType.SearchedValue + "";
  333. this._orderEntity.GoodsCode = this.txtGoodsCode.Text.Trim();
  334. this._orderEntity.GoodsModel = this.txtGoodsModel.Text.Trim();
  335. this._orderEntity.LogoIDS = this.dkLogoSearchBox1.LogoIDS;
  336. return this._orderEntity;
  337. }
  338. /// <summary>
  339. /// 明细搜索条件
  340. /// </summary>
  341. /// <returns></returns>
  342. private void CreateSearchConditionDetail()
  343. {
  344. this._rptse = new RPT030102_SE();
  345. this._rptse.ProductionLineID = this._rptse1.ProductionLineID;
  346. this._rptse.GoodsTypeCode = this._rptse1.GoodsTypeCode;
  347. this._rptse.GoodsCode = this._rptse1.GoodsCode;
  348. this._rptse.ProcedureIDS = this._rptse1.ProcedureIDS;
  349. this._rptse.ScrapDateStart = this._rptse1.ScrapDateStart;
  350. this._rptse.ScrapDateEnd = this._rptse1.ScrapDateEnd;
  351. this._rptse.ResponProcedureIDS = this._rptse1.ResponProcedureIDS;
  352. this._rptse.ResponUserIDS = this._rptse1.ResponUserIDS;
  353. this._rptse.CreatUser = this._rptse1.CreatUser;
  354. this._rptse.AuditUser = this._rptse1.AuditUser;
  355. this._rptse.SpecialRepairFlag = this._rptse1.SpecialRepairFlag;
  356. }
  357. /// <summary>
  358. /// 查询损坏汇总表
  359. /// </summary>
  360. private DataTable GetSearchTotalData()
  361. {
  362. try
  363. {
  364. //// 调用服务器端获取数据集
  365. //ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  366. //{
  367. // return ReportModuleProxy.Service.GetRPT0030112SData(this._orderEntity);
  368. //}
  369. //);
  370. //if (sre.Status == Constant.ServiceResultStatus.Success)
  371. //{
  372. // if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  373. // {
  374. // // 提示未查找到数据
  375. // MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  376. // MessageBoxButtons.OK, MessageBoxIcon.Warning);
  377. // //清空数据
  378. // return null;
  379. // }
  380. // return sre.Data.Tables[0];
  381. //}
  382. this.dgvOrder.DataSource = null;
  383. ClientRequestEntity cre = new ClientRequestEntity();
  384. cre.NameSpace = "R03";
  385. cre.Name = "R030112Sum";
  386. cre.Properties["OrderNo"] = this.txtOrderNo.Text.Trim();
  387. cre.Properties["FHUserCode"] = this.txtFHUserCode.Text.Trim();
  388. if (this.chkDateTime.Checked)
  389. {
  390. cre.Properties["FHTimeStart"] = this.dtpStartTime.Value;
  391. cre.Properties["FHTimeEnd"] = this.dtpEndTime.Value;
  392. }
  393. cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
  394. cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
  395. cre.Properties["GoodsModel"] = this.txtGoodsModel.Text.Trim();
  396. cre.Properties["LogoIDS"] = this.dkLogoSearchBox1.LogoIDS;
  397. ServiceResultEntity resultEntity = DoAsync<ServiceResultEntity>(() =>
  398. {
  399. return ReportModuleProxy.Service.DoRequest(cre);
  400. });
  401. if (resultEntity == null || resultEntity.Data == null ||
  402. resultEntity.Data.Tables.Count == 0 ||
  403. resultEntity.Data.Tables[0].Rows.Count == 0)
  404. {
  405. this.dgvOrder.AutoResizeColumns();
  406. return null;
  407. }
  408. else
  409. {
  410. this.dgvOrder.DataSource = resultEntity.Data.Tables[0];
  411. this.dgvOrder.ReadOnly = true;
  412. this.dgvOrder.Rows[0].Selected = true;
  413. this.dgvOrder.AutoResizeColumns();
  414. }
  415. return null;
  416. }
  417. catch (Exception ex)
  418. {
  419. throw ex;
  420. }
  421. }
  422. /// <summary>
  423. /// 查询损坏明细表
  424. /// </summary>
  425. private DataTable GetSearchDetailData()
  426. {
  427. try
  428. {
  429. // 调用服务器端获取数据集
  430. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  431. {
  432. return ReportModuleProxy.Service.GetRPT0030112DetailSData(this._orderEntity);
  433. }
  434. );
  435. if (sre.Status == Constant.ServiceResultStatus.Success)
  436. {
  437. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  438. {
  439. // 提示未查找到数据
  440. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  441. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  442. //清空数据
  443. return null;
  444. }
  445. return sre.Data.Tables[0];
  446. }
  447. return null;
  448. }
  449. catch (Exception ex)
  450. {
  451. throw ex;
  452. }
  453. }
  454. /// <summary>
  455. /// 查询损坏明细表
  456. /// </summary>
  457. private DataTable GetSearchDetailDataByDouble()
  458. {
  459. try
  460. {
  461. // 调用服务器端获取数据集
  462. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  463. {
  464. return ReportModuleProxy.Service.GetRPT0030112DetailSData(this._orderCRE);
  465. }
  466. );
  467. if (sre.Status == Constant.ServiceResultStatus.Success)
  468. {
  469. if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  470. {
  471. // 提示未查找到数据
  472. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  473. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  474. //清空数据
  475. return null;
  476. }
  477. return sre.Data.Tables[0];
  478. }
  479. return null;
  480. }
  481. catch (Exception ex)
  482. {
  483. throw ex;
  484. }
  485. }
  486. #endregion
  487. }
  488. }