F_SAP_HEGII_010301.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 = this.dtpSynTime.Value.Date;
  77. sre = (ServiceResultEntity)DoAsync(() =>
  78. {
  79. return SAPDataModuleProxy.Service.DoRequest(cre);
  80. }
  81. );
  82. }
  83. else if (datacode == "6002")
  84. {
  85. ClientRequestEntity cre = new ClientRequestEntity();
  86. cre.NameSpace = "Hegii";
  87. cre.Name = "SetFP6002";
  88. cre.Request = this.dtpSynTime.Value.Date;
  89. sre = (ServiceResultEntity)DoAsync(() =>
  90. {
  91. return SAPDataModuleProxy.Service.DoRequest(cre);
  92. }
  93. );
  94. }
  95. else
  96. {
  97. ClientRequestEntity cre = new ClientRequestEntity();
  98. cre.NameSpace = "Hegii";
  99. cre.Name = "SetWorkData10_50";
  100. cre.Request = this.dtpSynTime.Value;
  101. cre.Properties["datacode"] = datacode;
  102. sre = (ServiceResultEntity)DoAsync(() =>
  103. {
  104. return SAPDataModuleProxy.Service.DoRequest(cre);
  105. });
  106. }
  107. if (sre == null)
  108. {
  109. MessageBox.Show("数据同步失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
  110. return;
  111. }
  112. if (sre.Status == Constant.ServiceResultStatus.Other)
  113. {
  114. MessageBox.Show("数据同步失败\n" + sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  115. return;
  116. }
  117. if (sre.Status == Constant.ServiceResultStatus.Success)
  118. {
  119. if (sre.Result + "" == "S")
  120. {
  121. MessageBox.Show("数据同步成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  122. this.DialogResult = DialogResult.OK;
  123. this.Close();
  124. }
  125. else
  126. {
  127. MessageBox.Show("数据同步失败\n" + sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  128. }
  129. }
  130. else
  131. {
  132. MessageBox.Show("数据同步失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
  133. }
  134. }
  135. catch (Exception ex)
  136. {
  137. // 对异常进行共通处理
  138. ExceptionManager.HandleEventException(this.ToString(),
  139. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  140. }
  141. }
  142. }
  143. }