F_SAP_HEGII_010301.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_SAP_HEGII_010301.cs
  5. * 2.功能描述:手动同步
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2018/11/16 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Reflection;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.WCF.DataModels;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. namespace Dongke.IBOSS.PRD.Client.SAPDataModule
  20. {
  21. public partial class F_SAP_HEGII_010301 : FormBase
  22. {
  23. public F_SAP_HEGII_010301(string date, string datacode)
  24. {
  25. InitializeComponent();
  26. DataTable datacodes = new DataTable();
  27. datacodes.Columns.Add("datacode");
  28. datacodes.Columns.Add("datacodeName");
  29. datacodes.Rows.Add("10", "模具");
  30. datacodes.Rows.Add("20", "湿坯");
  31. datacodes.Rows.Add("30", "精坯");
  32. datacodes.Rows.Add("40", "釉坯");
  33. datacodes.Rows.Add("50", "烧成");
  34. datacodes.Rows.Add("6001", "成品明细");
  35. datacodes.Rows.Add("6002", "成品明细(小时)");
  36. cmbDataCode.ValueMember = "datacode";
  37. cmbDataCode.DisplayMember = "datacodeName";
  38. cmbDataCode.DataSource = datacodes;
  39. if (string.IsNullOrEmpty(date))
  40. {
  41. this.dtpSynTime.Value = DateTime.Now;
  42. }
  43. //else
  44. //{
  45. // this.dtpDatebegin.Value = DateTime.ParseExact(date, "yyyyMMdd HH:mm", null);
  46. //}
  47. if (!string.IsNullOrEmpty(datacode))
  48. {
  49. cmbDataCode.SelectedValue = datacode;
  50. }
  51. }
  52. private void btnCancel_Click(object sender, EventArgs e)
  53. {
  54. this.DialogResult = DialogResult.Cancel;
  55. this.Close();
  56. }
  57. private void btnSave_Click(object sender, EventArgs e)
  58. {
  59. try
  60. {
  61. string datacode = cmbDataCode.SelectedValue + "";
  62. string datacodename = cmbDataCode.Text;
  63. string date = this.dtpSynTime.Value.ToString("yyyyMMdd HH:mm");
  64. DialogResult dr = MessageBox.Show("是否同步【" + date + "】的【" + datacodename + "】数据。",
  65. this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  66. if (dr != DialogResult.Yes)
  67. {
  68. return;
  69. }
  70. ServiceResultEntity sre = null;
  71. if (datacode == "6001")
  72. {
  73. ClientRequestEntity cre = new ClientRequestEntity();
  74. cre.NameSpace = "Hegii";
  75. cre.Name = "SetFP6001";
  76. //cre.Request = DateTime.ParseExact(date, "yyyyMMdd", null);
  77. cre.Request = this.dtpSynTime.Value.Date;
  78. sre = (ServiceResultEntity)DoAsync(() =>
  79. {
  80. return SAPDataModuleProxy.Service.DoRequest(cre);
  81. }
  82. );
  83. }
  84. else if (datacode == "6002")
  85. {
  86. ClientRequestEntity cre = new ClientRequestEntity();
  87. cre.NameSpace = "Hegii";
  88. cre.Name = "SetFP6002";
  89. //cre.Request = DateTime.ParseExact(date, "yyyyMMdd", null);
  90. cre.Request = this.dtpSynTime.Value.Date;
  91. sre = (ServiceResultEntity)DoAsync(() =>
  92. {
  93. return SAPDataModuleProxy.Service.DoRequest(cre);
  94. }
  95. );
  96. }
  97. else
  98. {
  99. ClientRequestEntity cre = new ClientRequestEntity();
  100. cre.NameSpace = "Hegii";
  101. cre.Name = "SetWorkData10_50";
  102. //cre.Request = DateTime.ParseExact(date, "yyyyMMdd", null);
  103. cre.Request = this.dtpSynTime.Value;
  104. cre.Properties["datacode"] = datacode;
  105. sre = (ServiceResultEntity)DoAsync(() =>
  106. {
  107. return SAPDataModuleProxy.Service.DoRequest(cre);
  108. });
  109. }
  110. if (sre == null)
  111. {
  112. MessageBox.Show("数据同步失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
  113. return;
  114. }
  115. if (sre.Status == Constant.ServiceResultStatus.Other)
  116. {
  117. MessageBox.Show("数据同步失败\n" + sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  118. return;
  119. }
  120. if (sre.Status == Constant.ServiceResultStatus.Success)
  121. {
  122. if (sre.Result + "" == "S")
  123. {
  124. MessageBox.Show("数据同步成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  125. this.DialogResult = DialogResult.OK;
  126. this.Close();
  127. }
  128. else
  129. {
  130. MessageBox.Show("数据同步失败\n" + sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  131. }
  132. }
  133. else
  134. {
  135. MessageBox.Show("数据同步失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
  136. }
  137. }
  138. catch (Exception ex)
  139. {
  140. // 对异常进行共通处理
  141. ExceptionManager.HandleEventException(this.ToString(),
  142. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  143. }
  144. }
  145. }
  146. }