F_SAP_HEGII_0103.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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.Collections.Generic;
  12. using System.Data;
  13. using System.Reflection;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseControls;
  16. using Dongke.IBOSS.PRD.Basics.BaseResources;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.Client.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. using Dongke.IBOSS.PRD.WCF.Proxys;
  22. namespace Dongke.IBOSS.PRD.Client.SAPDataModule
  23. {
  24. /// <summary>
  25. /// SAP同步日志
  26. /// </summary>
  27. public partial class F_SAP_HEGII_0103 : DKDockPanelBase
  28. {
  29. #region 成员变量
  30. private static F_SAP_HEGII_0103 _instance = null;
  31. #endregion
  32. #region 单例模式
  33. /// <summary>
  34. /// 单例模式,防止重复创建窗体
  35. /// </summary>
  36. public static F_SAP_HEGII_0103 Instance
  37. {
  38. get
  39. {
  40. if (_instance == null)
  41. {
  42. _instance = new F_SAP_HEGII_0103();
  43. }
  44. return _instance;
  45. }
  46. }
  47. #endregion
  48. #region 构造函数
  49. /// <summary>
  50. /// SAP同步日志
  51. /// </summary>
  52. public F_SAP_HEGII_0103()
  53. {
  54. InitializeComponent();
  55. this.Text = "SAP同步日志";
  56. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  57. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  58. this.dgvLog.AutoGenerateColumns = false;
  59. this.dgvSum.AutoGenerateColumns = false;
  60. }
  61. #endregion
  62. #region 控件事件
  63. /// <summary>
  64. /// 关闭
  65. /// </summary>
  66. /// <param name="sender"></param>
  67. /// <param name="e"></param>
  68. private void F_SAP_HEGII_0103_FormClosed(object sender, FormClosedEventArgs e)
  69. {
  70. _instance = null;
  71. }
  72. /// <summary>
  73. /// 画面加载
  74. /// </summary>
  75. /// <param name="sender"></param>
  76. /// <param name="e"></param>
  77. private void F_SAP_HEGII_0103_Load(object sender, System.EventArgs e)
  78. {
  79. try
  80. {
  81. // 加载权限
  82. FormPermissionManager.FormPermissionControl(this.Name, this,
  83. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  84. LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  85. this.dtpDatebegin.Value = DateTime.Now.Date;
  86. this.dtpDateend.Value = DateTime.Now.Date;
  87. }
  88. catch (Exception ex)
  89. {
  90. // 对异常进行共通处理
  91. ExceptionManager.HandleEventException(this.ToString(),
  92. 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 tsbtnSearch_Click(object sender, EventArgs e)
  101. {
  102. try
  103. {
  104. this.dgvLog.DataSource = null;
  105. this.tsbtnSyn.Enabled = true;
  106. this.QueryDataFromOther();
  107. }
  108. catch (Exception ex)
  109. {
  110. // 对异常进行共通处理
  111. ExceptionManager.HandleEventException(this.ToString(),
  112. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  113. }
  114. }
  115. /// <summary>
  116. /// 清除条件
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. private void tsbtnClearCondition_Click(object sender, EventArgs e)
  121. {
  122. this.dtpDatebegin.Value = DateTime.Now.Date;
  123. this.dtpDateend.Value = DateTime.Now.Date;
  124. }
  125. /// <summary>
  126. /// 自适应列宽
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  131. {
  132. this.dgvLog.AutoResizeColumns();
  133. this.dgvSum.AutoResizeColumns();
  134. this.dgvFP.AutoResizeColumns();
  135. this.dgvSPSum.AutoResizeColumns();
  136. }
  137. /// <summary>
  138. /// 关闭画面
  139. /// </summary>
  140. /// <param name="sender"></param>
  141. /// <param name="e"></param>
  142. private void tsbtnClose_Click(object sender, EventArgs e)
  143. {
  144. this.Close();
  145. }
  146. /// <summary>
  147. /// 查询同步明细
  148. /// </summary>
  149. /// <param name="sender"></param>
  150. /// <param name="e"></param>
  151. private void dgvLog_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  152. {
  153. if (e.RowIndex < 0 || this.dgvLog.CurrentRow == null)
  154. {
  155. return;
  156. }
  157. this.dgvSPSum.DataSource = null;
  158. try
  159. {
  160. string datacode = this.dgvLog.CurrentRow.Cells["datacode"].Value + "";
  161. if (datacode == "6001" || datacode == "6002")
  162. {
  163. this.dgvFP.DataSource = null;
  164. ClientRequestEntity cre = new ClientRequestEntity();
  165. cre.NameSpace = "Hegii";
  166. cre.Name = "GetFinishedProductByDataLog";
  167. cre.Request = this.dgvLog.CurrentRow.Cells["datalogid"].Value;
  168. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  169. {
  170. return SAPDataModuleProxy.Service.DoRequest(cre);
  171. }
  172. );
  173. if (sre.Status == Constant.ServiceResultStatus.Success)
  174. {
  175. // 查询成功
  176. this.dgvFP.DataSource = sre.Data.Tables[0];
  177. }
  178. this.tabControl1.SelectedIndex = 2;
  179. }
  180. else
  181. {
  182. this.dgvSum.DataSource = null;
  183. ClientRequestEntity cre = new ClientRequestEntity();
  184. cre.NameSpace = "Hegii";
  185. cre.Name = "GetWorkDataByDataLog";
  186. cre.Request = this.dgvLog.CurrentRow.Cells["datalogid"].Value;
  187. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  188. {
  189. return SAPDataModuleProxy.Service.DoRequest(cre);
  190. }
  191. );
  192. if (sre.Status == Constant.ServiceResultStatus.Success)
  193. {
  194. // 查询成功
  195. this.dgvSum.DataSource = sre.Data.Tables[0];
  196. if (sre.Data.Tables.Count > 1)
  197. {
  198. this.dgvSPSum.DataSource = sre.Data.Tables[1];
  199. }
  200. }
  201. this.tabControl1.SelectedIndex = 1;
  202. }
  203. }
  204. catch (Exception ex)
  205. {
  206. // 对异常进行共通处理
  207. ExceptionManager.HandleEventException(this.ToString(),
  208. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  209. }
  210. }
  211. #endregion
  212. #region 私有方法
  213. /// <summary>
  214. /// 查询数据
  215. /// </summary>
  216. private void QueryDataFromOther()
  217. {
  218. if (this.dtpDatebegin.Value == null ||
  219. this.dtpDateend.Value == null)
  220. {
  221. return;
  222. }
  223. try
  224. {
  225. this.tsrToolStrip1.Focus();
  226. this.dgvLog.DataSource = null;
  227. ClientRequestEntity cre = new ClientRequestEntity();
  228. cre.NameSpace = "Hegii";
  229. if (this.tabControl1.SelectedIndex == 3)
  230. {
  231. cre.Name = "GetWorkDataSPSumByDate";
  232. cre.Properties["datebegin"] = this.dtpDatebegin.Value.Value.ToString("yyyyMMdd");
  233. cre.Properties["dateend"] = this.dtpDateend.Value.Value.ToString("yyyyMMdd");
  234. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  235. {
  236. return SAPDataModuleProxy.Service.DoRequest(cre);
  237. }
  238. );
  239. if (sre.Status == Constant.ServiceResultStatus.Success)
  240. {
  241. // 查询成功
  242. this.dgvSPSum.DataSource = sre.Data.Tables[0];
  243. //this.tabControl1.SelectedIndex = 0;
  244. if (this.dgvSPSum.RowCount == 0)
  245. {
  246. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_001);
  247. }
  248. }
  249. }
  250. else
  251. {
  252. cre.Name = "GetDataLog";
  253. cre.Properties["datebegin"] = this.dtpDatebegin.Value.Value.ToString("yyyyMMdd");
  254. cre.Properties["dateend"] = this.dtpDateend.Value.Value.ToString("yyyyMMdd");
  255. ServiceResultEntity sre = DoAsync<ServiceResultEntity>(() =>
  256. {
  257. return SAPDataModuleProxy.Service.DoRequest(cre);
  258. }
  259. );
  260. if (sre.Status == Constant.ServiceResultStatus.Success)
  261. {
  262. // 查询成功
  263. this.dgvLog.DataSource = sre.Data.Tables[0];
  264. this.tabControl1.SelectedIndex = 0;
  265. if (this.dgvLog.RowCount == 0)
  266. {
  267. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_001);
  268. }
  269. }
  270. }
  271. }
  272. catch (Exception ex)
  273. {
  274. throw ex;
  275. }
  276. }
  277. #endregion
  278. private void dgvLog_SelectionChanged(object sender, EventArgs e)
  279. {
  280. if (dgvLog.CurrentRow == null)
  281. {
  282. this.tsbtnSyn.Enabled = true;
  283. return;
  284. }
  285. try
  286. {
  287. string datacode = dgvLog.CurrentRow.Cells["datacode"].Value + "";
  288. string datastuts = dgvLog.CurrentRow.Cells["DataStuts"].Value + "";
  289. if (datacode == "60" || datastuts == "S")
  290. {
  291. this.tsbtnSyn.Enabled = false;
  292. }
  293. else
  294. {
  295. this.tsbtnSyn.Enabled = true;
  296. }
  297. }
  298. catch (Exception ex)
  299. {
  300. // 对异常进行共通处理
  301. ExceptionManager.HandleEventException(this.ToString(),
  302. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  303. }
  304. }
  305. private void tsbtnSyn_Click(object sender, EventArgs e)
  306. {
  307. DialogResult dialogResult = DialogResult.Cancel;
  308. if (dgvLog.CurrentRow == null)
  309. {
  310. F_SAP_HEGII_010301 f = new F_SAP_HEGII_010301(null, null);
  311. dialogResult = f.ShowDialog();
  312. if (dialogResult == DialogResult.OK)
  313. {
  314. this.tsbtnSearch_Click(null, null);
  315. }
  316. return;
  317. }
  318. try
  319. {
  320. string datacode = dgvLog.CurrentRow.Cells["datacode"].Value + "";
  321. //string datacodename = dgvLog.CurrentRow.Cells["datacodename"].Value + "";
  322. string datastuts = dgvLog.CurrentRow.Cells["DataStuts"].Value + "";
  323. string date = dgvLog.CurrentRow.Cells["logdate"].Value + "";
  324. if (datacode == "60" || datastuts == "S")
  325. {
  326. return;
  327. }
  328. F_SAP_HEGII_010301 f = new F_SAP_HEGII_010301(date, datacode);
  329. dialogResult = f.ShowDialog();
  330. if (dialogResult == DialogResult.OK)
  331. {
  332. this.tsbtnSearch_Click(null, null);
  333. }
  334. }
  335. catch (Exception ex)
  336. {
  337. // 对异常进行共通处理
  338. ExceptionManager.HandleEventException(this.ToString(),
  339. MethodBase.GetCurrentMethod().Name, this.Text, ex);
  340. }
  341. }
  342. }
  343. }