F_SAP_HEGII_0103.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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.Extension.ExObjectConvert;
  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. try
  250. {
  251. F_SAP_HEGII_010301 f = new F_SAP_HEGII_010301(null, null);
  252. DialogResult dialogResult = f.ShowDialog();
  253. if (dialogResult == DialogResult.OK)
  254. {
  255. this.tsbtnSearch_Click(null, null);
  256. }
  257. }
  258. catch (Exception ex)
  259. {
  260. // 对异常进行共通处理
  261. ExceptionManager.HandleEventException(this.ToString(),
  262. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  263. }
  264. #region 注销
  265. //DialogResult dialogResult = DialogResult.Cancel;
  266. //if (dgvLog.CurrentRow == null)
  267. //{
  268. // F_SAP_HEGII_010301 f = new F_SAP_HEGII_010301(null, null);
  269. // dialogResult = f.ShowDialog();
  270. // if (dialogResult == DialogResult.OK)
  271. // {
  272. // this.tsbtnSearch_Click(null, null);
  273. // }
  274. // return;
  275. //}
  276. //try
  277. //{
  278. // string datacode = dgvLog.CurrentRow.Cells["datacode"].Value + "";
  279. // //string datacodename = dgvLog.CurrentRow.Cells["datacodename"].Value + "";
  280. // string datastuts = dgvLog.CurrentRow.Cells["DataStuts"].Value + "";
  281. // string date = dgvLog.CurrentRow.Cells["executedateend"].Value + "";
  282. // if (datacode == "60" || datastuts == "S")
  283. // {
  284. // return;
  285. // }
  286. // F_SAP_HEGII_010301 f = new F_SAP_HEGII_010301(date, datacode);
  287. // dialogResult = f.ShowDialog();
  288. // if (dialogResult == DialogResult.OK)
  289. // {
  290. // this.tsbtnSearch_Click(null, null);
  291. // }
  292. //}
  293. //catch (Exception ex)
  294. //{
  295. // // 对异常进行共通处理
  296. // ExceptionManager.HandleEventException(this.ToString(),
  297. // MethodBase.GetCurrentMethod().Name, this.Text, ex);
  298. //}
  299. #endregion
  300. }
  301. /// <summary>
  302. /// 同步当前日志
  303. /// </summary>
  304. /// <param name="sender"></param>
  305. /// <param name="e"></param>
  306. private void tsbtnSynLog_Click(object sender, EventArgs e)
  307. {
  308. try
  309. {
  310. if (dgvLog.CurrentRow == null)
  311. {
  312. MessageBox.Show("请选择一条未成功的日志。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  313. return;
  314. }
  315. DialogResult dr = MessageBox.Show("是否同步当前日志的数据到SAP。",
  316. this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  317. if (dr != DialogResult.Yes)
  318. {
  319. return;
  320. }
  321. ClientRequestEntity cre = new ClientRequestEntity();
  322. cre.NameSpace = "Hegii";
  323. cre.Name = "SyncSap";
  324. cre.Request = dgvLog.CurrentRow.Cells["executedateend"].Value;
  325. if (cre.Request == null || cre.Request == DBNull.Value)
  326. {
  327. cre.Request = dgvLog.CurrentRow.Cells["BeginTime"].Value;
  328. }
  329. cre.Properties["datacode"] = dgvLog.CurrentRow.Cells["datacode"].Value + "";
  330. cre.Properties["logid"] = dgvLog.CurrentRow.Cells["logid"].Value.ToInt32();
  331. ServiceResultEntity sre = DoAsync(() =>
  332. {
  333. return SAPDataModuleProxy.Service.DoRequest(cre);
  334. });
  335. if (sre == null)
  336. {
  337. MessageBox.Show("数据同步失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
  338. return;
  339. }
  340. if (sre.Status == Constant.ServiceResultStatus.Other)
  341. {
  342. MessageBox.Show(sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  343. return;
  344. }
  345. if (sre.Status == Constant.ServiceResultStatus.Success)
  346. {
  347. if (sre.Result + "" == "S")
  348. {
  349. MessageBox.Show("数据同步成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  350. }
  351. else
  352. {
  353. MessageBox.Show(sre.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  354. }
  355. }
  356. else
  357. {
  358. MessageBox.Show("数据同步失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
  359. }
  360. }
  361. catch (Exception ex)
  362. {
  363. // 对异常进行共通处理
  364. ExceptionManager.HandleEventException(this.ToString(),
  365. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  366. }
  367. }
  368. #endregion
  369. #region 私有方法
  370. /// <summary>
  371. /// 查询数据
  372. /// </summary>
  373. private void QueryDataFromOther()
  374. {
  375. if (this.dtpDatebegin.Value == null ||
  376. this.dtpDateend.Value == null)
  377. {
  378. return;
  379. }
  380. try
  381. {
  382. this.tsrToolStrip1.Focus();
  383. this.dgvLog.DataSource = null;
  384. ClientRequestEntity cre = new ClientRequestEntity();
  385. cre.NameSpace = "Hegii";
  386. if (this.tabControl1.SelectedIndex == 3)
  387. {
  388. cre.Name = "GetWorkDataSPSumByDate";
  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.dgvSPSum.DataSource = sre.Data.Tables[0];
  400. //this.tabControl1.SelectedIndex = 0;
  401. if (this.dgvSPSum.RowCount == 0)
  402. {
  403. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_001);
  404. }
  405. }
  406. }
  407. else
  408. {
  409. cre.Name = "GetDataLog";
  410. cre.Properties["datebegin"] = this.dtpDatebegin.Value.Value.ToString("yyyyMMdd");
  411. cre.Properties["dateend"] = this.dtpDateend.Value.Value.ToString("yyyyMMdd");
  412. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  413. {
  414. return SAPDataModuleProxy.Service.DoRequest(cre);
  415. }
  416. );
  417. if (sre.Status == Constant.ServiceResultStatus.Success)
  418. {
  419. // 查询成功
  420. this.dgvLog.DataSource = sre.Data.Tables[0];
  421. this.tabControl1.SelectedIndex = 0;
  422. if (this.dgvLog.RowCount == 0)
  423. {
  424. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_001);
  425. }
  426. }
  427. }
  428. }
  429. catch (Exception ex)
  430. {
  431. throw ex;
  432. }
  433. }
  434. #endregion
  435. }
  436. }