F_SAP_HEGII_0103.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_SAP_HEGII_0103.cs
  5. * 2.功能描述:SAP同步日志
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2018/11/13 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Reflection;
  12. using System.Windows.Forms;
  13. using Curtain.Core;
  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.Client.Controls;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.Proxys;
  21. namespace Dongke.IBOSS.PRD.Client.SAPDataModule
  22. {
  23. /// <summary>
  24. /// SAP同步日志
  25. /// </summary>
  26. public partial class F_SAP_HEGII_0103 : DKDockPanelBase
  27. {
  28. #region 成员变量
  29. private static F_SAP_HEGII_0103 _instance = null;
  30. #endregion
  31. #region 单例模式
  32. /// <summary>
  33. /// 单例模式,防止重复创建窗体
  34. /// </summary>
  35. public static F_SAP_HEGII_0103 Instance
  36. {
  37. get
  38. {
  39. if (_instance == null)
  40. {
  41. _instance = new F_SAP_HEGII_0103();
  42. }
  43. return _instance;
  44. }
  45. }
  46. #endregion
  47. #region 构造函数
  48. /// <summary>
  49. /// SAP同步日志
  50. /// </summary>
  51. public F_SAP_HEGII_0103()
  52. {
  53. InitializeComponent();
  54. this.Text = "SAP同步日志";
  55. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  56. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  57. this.dgvLog.AutoGenerateColumns = false;
  58. this.dgvSum.AutoGenerateColumns = false;
  59. }
  60. #endregion
  61. #region 控件事件
  62. /// <summary>
  63. /// 关闭
  64. /// </summary>
  65. /// <param name="sender"></param>
  66. /// <param name="e"></param>
  67. private void F_SAP_HEGII_0103_FormClosed(object sender, FormClosedEventArgs e)
  68. {
  69. _instance = null;
  70. }
  71. /// <summary>
  72. /// 画面加载
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void F_SAP_HEGII_0103_Load(object sender, System.EventArgs e)
  77. {
  78. try
  79. {
  80. // 加载权限
  81. FormPermissionManager.FormPermissionControl(this.Name, this,
  82. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  83. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  84. this.dtpDatebegin.Value = DateTime.Now.Date;
  85. this.dtpDateend.Value = DateTime.Now.Date;
  86. }
  87. catch (Exception ex)
  88. {
  89. // 对异常进行共通处理
  90. ExceptionManager.HandleEventException(this.ToString(),
  91. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  92. }
  93. }
  94. /// <summary>
  95. /// 查询
  96. /// </summary>
  97. /// <param name="sender"></param>
  98. /// <param name="e"></param>
  99. private void tsbtnSearch_Click(object sender, EventArgs e)
  100. {
  101. try
  102. {
  103. this.dgvLog.DataSource = null;
  104. //this.tsbtnSyn.Enabled = true;
  105. this.QueryDataFromOther();
  106. }
  107. catch (Exception ex)
  108. {
  109. // 对异常进行共通处理
  110. ExceptionManager.HandleEventException(this.ToString(),
  111. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  112. }
  113. }
  114. /// <summary>
  115. /// 清除条件
  116. /// </summary>
  117. /// <param name="sender"></param>
  118. /// <param name="e"></param>
  119. private void tsbtnClearCondition_Click(object sender, EventArgs e)
  120. {
  121. this.dtpDatebegin.Value = DateTime.Now.Date;
  122. this.dtpDateend.Value = DateTime.Now.Date;
  123. }
  124. /// <summary>
  125. /// 自适应列宽
  126. /// </summary>
  127. /// <param name="sender"></param>
  128. /// <param name="e"></param>
  129. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  130. {
  131. this.dgvLog.AutoResizeColumns();
  132. this.dgvSum.AutoResizeColumns();
  133. this.dgvFP.AutoResizeColumns();
  134. this.dgvSPSum.AutoResizeColumns();
  135. }
  136. /// <summary>
  137. /// 关闭画面
  138. /// </summary>
  139. /// <param name="sender"></param>
  140. /// <param name="e"></param>
  141. private void tsbtnClose_Click(object sender, EventArgs e)
  142. {
  143. this.Close();
  144. }
  145. /// <summary>
  146. /// 查询同步明细
  147. /// </summary>
  148. /// <param name="sender"></param>
  149. /// <param name="e"></param>
  150. private void dgvLog_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  151. {
  152. if (e.RowIndex < 0 || this.dgvLog.CurrentRow == null)
  153. {
  154. return;
  155. }
  156. this.dgvSPSum.DataSource = null;
  157. try
  158. {
  159. string datacode = this.dgvLog.CurrentRow.Cells["datacode"].Value + "";
  160. if (datacode == "6001" || datacode == "6002" || datacode == "60")
  161. {
  162. this.dgvFP.DataSource = null;
  163. ClientRequestEntity cre = new ClientRequestEntity();
  164. cre.NameSpace = "Hegii";
  165. cre.Name = "GetFinishedProductByDataLog";
  166. cre.Request = this.dgvLog.CurrentRow.Cells["datalogid"].Value;
  167. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  168. {
  169. return SAPDataModuleProxy.Service.DoRequest(cre);
  170. }
  171. );
  172. if (sre.Status == Constant.ServiceResultStatus.Success)
  173. {
  174. // 查询成功
  175. this.dgvFP.DataSource = sre.Data.Tables[0];
  176. }
  177. this.tabControl1.SelectedIndex = 2;
  178. }
  179. if (datacode != "6001" && datacode != "6002")
  180. {
  181. this.dgvSum.DataSource = null;
  182. ClientRequestEntity cre = new ClientRequestEntity();
  183. cre.NameSpace = "Hegii";
  184. cre.Name = "GetWorkDataByDataLog";
  185. cre.Request = this.dgvLog.CurrentRow.Cells["datalogid"].Value;
  186. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  187. {
  188. return SAPDataModuleProxy.Service.DoRequest(cre);
  189. }
  190. );
  191. if (sre.Status == Constant.ServiceResultStatus.Success)
  192. {
  193. // 查询成功
  194. this.dgvSum.DataSource = sre.Data.Tables[0];
  195. if (sre.Data.Tables.Count > 1)
  196. {
  197. this.dgvSPSum.DataSource = sre.Data.Tables[1];
  198. }
  199. }
  200. this.tabControl1.SelectedIndex = 1;
  201. }
  202. }
  203. catch (Exception ex)
  204. {
  205. // 对异常进行共通处理
  206. ExceptionManager.HandleEventException(this.ToString(),
  207. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  208. }
  209. }
  210. /// <summary>
  211. /// 行切换事件
  212. /// </summary>
  213. /// <param name="sender"></param>
  214. /// <param name="e"></param>
  215. private void dgvLog_SelectionChanged(object sender, EventArgs e)
  216. {
  217. if (dgvLog.CurrentRow == null)
  218. {
  219. //this.tsbtnSyn.Enabled = true;
  220. return;
  221. }
  222. try
  223. {
  224. string datacode = dgvLog.CurrentRow.Cells["datacode"].Value + "";
  225. string datastuts = dgvLog.CurrentRow.Cells["DataStuts"].Value + "";
  226. if (datacode == "60" || datastuts == "S")
  227. {
  228. //this.tsbtnSyn.Enabled = false;
  229. }
  230. else
  231. {
  232. //this.tsbtnSyn.Enabled = true;
  233. }
  234. }
  235. catch (Exception ex)
  236. {
  237. // 对异常进行共通处理
  238. ExceptionManager.HandleEventException(this.ToString(),
  239. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  240. }
  241. }
  242. /// <summary>
  243. /// 获取数据并同步
  244. /// </summary>
  245. /// <param name="sender"></param>
  246. /// <param name="e"></param>
  247. private void tsbtnSyn_Click(object sender, EventArgs e)
  248. {
  249. DialogResult dialogResult = DialogResult.Cancel;
  250. if (dgvLog.CurrentRow == null)
  251. {
  252. F_SAP_HEGII_010301 f = new F_SAP_HEGII_010301(null, null);
  253. dialogResult = f.ShowDialog();
  254. if (dialogResult == DialogResult.OK)
  255. {
  256. this.tsbtnSearch_Click(null, null);
  257. }
  258. return;
  259. }
  260. try
  261. {
  262. string datacode = dgvLog.CurrentRow.Cells["datacode"].Value + "";
  263. //string datacodename = dgvLog.CurrentRow.Cells["datacodename"].Value + "";
  264. string datastuts = dgvLog.CurrentRow.Cells["DataStuts"].Value + "";
  265. string date = dgvLog.CurrentRow.Cells["logdate"].Value + "";
  266. if (datacode == "60" || datastuts == "S")
  267. {
  268. return;
  269. }
  270. F_SAP_HEGII_010301 f = new F_SAP_HEGII_010301(date, datacode);
  271. dialogResult = f.ShowDialog();
  272. if (dialogResult == DialogResult.OK)
  273. {
  274. this.tsbtnSearch_Click(null, null);
  275. }
  276. }
  277. catch (Exception ex)
  278. {
  279. // 对异常进行共通处理
  280. ExceptionManager.HandleEventException(this.ToString(),
  281. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  282. }
  283. }
  284. /// <summary>
  285. /// 同步当前日志
  286. /// </summary>
  287. /// <param name="sender"></param>
  288. /// <param name="e"></param>
  289. private void tsbtnSynLog_Click(object sender, EventArgs e)
  290. {
  291. try
  292. {
  293. if (dgvLog.CurrentRow == null)
  294. {
  295. MessageBox.Show("请选择一条未成功的日志。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  296. return;
  297. }
  298. DialogResult dr = MessageBox.Show("是否同步当前日志的数据到SAP。",
  299. this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  300. if (dr != DialogResult.Yes)
  301. {
  302. return;
  303. }
  304. ClientRequestEntity cre = new ClientRequestEntity();
  305. cre.NameSpace = "Hegii";
  306. cre.Name = "SyncSap";
  307. cre.Request = dgvLog.CurrentRow.Cells["executedateend"].Value;
  308. cre.Properties["datacode"] = dgvLog.CurrentRow.Cells["datacode"].Value + "";
  309. cre.Properties["logid"] = dgvLog.CurrentRow.Cells["logid"].Value.ToInt32();
  310. ServiceResultEntity sre = DoAsync(() =>
  311. {
  312. return SAPDataModuleProxy.Service.DoRequest(cre);
  313. });
  314. if (sre == null)
  315. {
  316. MessageBox.Show("数据同步失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
  317. return;
  318. }
  319. if (sre.Status == Constant.ServiceResultStatus.Other)
  320. {
  321. MessageBox.Show(sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  322. return;
  323. }
  324. if (sre.Status == Constant.ServiceResultStatus.Success)
  325. {
  326. if (sre.Result + "" == "S")
  327. {
  328. MessageBox.Show("数据同步成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  329. }
  330. else
  331. {
  332. MessageBox.Show(sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  333. }
  334. }
  335. else
  336. {
  337. MessageBox.Show("数据同步失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
  338. }
  339. }
  340. catch (Exception ex)
  341. {
  342. // 对异常进行共通处理
  343. ExceptionManager.HandleEventException(this.ToString(),
  344. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  345. }
  346. }
  347. #endregion
  348. #region 私有方法
  349. /// <summary>
  350. /// 查询数据
  351. /// </summary>
  352. private void QueryDataFromOther()
  353. {
  354. if (this.dtpDatebegin.Value == null ||
  355. this.dtpDateend.Value == null)
  356. {
  357. return;
  358. }
  359. try
  360. {
  361. this.tsrToolStrip1.Focus();
  362. this.dgvLog.DataSource = null;
  363. ClientRequestEntity cre = new ClientRequestEntity();
  364. cre.NameSpace = "Hegii";
  365. if (this.tabControl1.SelectedIndex == 3)
  366. {
  367. cre.Name = "GetWorkDataSPSumByDate";
  368. cre.Properties["datebegin"] = this.dtpDatebegin.Value.Value.ToString("yyyyMMdd");
  369. cre.Properties["dateend"] = this.dtpDateend.Value.Value.ToString("yyyyMMdd");
  370. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  371. {
  372. return SAPDataModuleProxy.Service.DoRequest(cre);
  373. }
  374. );
  375. if (sre.Status == Constant.ServiceResultStatus.Success)
  376. {
  377. // 查询成功
  378. this.dgvSPSum.DataSource = sre.Data.Tables[0];
  379. //this.tabControl1.SelectedIndex = 0;
  380. if (this.dgvSPSum.RowCount == 0)
  381. {
  382. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_001);
  383. }
  384. }
  385. }
  386. else
  387. {
  388. cre.Name = "GetDataLog";
  389. cre.Properties["datebegin"] = this.dtpDatebegin.Value.Value.ToString("yyyyMMdd");
  390. cre.Properties["dateend"] = this.dtpDateend.Value.Value.ToString("yyyyMMdd");
  391. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  392. {
  393. return SAPDataModuleProxy.Service.DoRequest(cre);
  394. }
  395. );
  396. if (sre.Status == Constant.ServiceResultStatus.Success)
  397. {
  398. // 查询成功
  399. this.dgvLog.DataSource = sre.Data.Tables[0];
  400. this.tabControl1.SelectedIndex = 0;
  401. if (this.dgvLog.RowCount == 0)
  402. {
  403. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_001);
  404. }
  405. }
  406. }
  407. }
  408. catch (Exception ex)
  409. {
  410. throw ex;
  411. }
  412. }
  413. #endregion
  414. }
  415. }