F_SAP_HEGII_0104.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /*******************************************************************************
  2. * Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_SAP_HEGII_0104.cs
  5. * 2.功能描述:成品WMS同步日志
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 付斌 2022/09/02 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.Client.Controls;
  18. using Dongke.IBOSS.PRD.WCF.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. namespace Dongke.IBOSS.PRD.Client.SAPDataModule
  21. {
  22. /// <summary>
  23. /// 成品SAP日志
  24. /// </summary>
  25. public partial class F_SAP_HEGII_0104 : DKDockPanelBase
  26. {
  27. #region 成员变量
  28. private static F_SAP_HEGII_0104 _instance = null;
  29. #endregion
  30. #region 单例模式
  31. /// <summary>
  32. /// 单例模式,防止重复创建窗体
  33. /// </summary>
  34. public static F_SAP_HEGII_0104 Instance
  35. {
  36. get
  37. {
  38. if (_instance == null)
  39. {
  40. _instance = new F_SAP_HEGII_0104();
  41. }
  42. return _instance;
  43. }
  44. }
  45. #endregion
  46. #region 构造函数
  47. /// <summary>
  48. /// 成品SAP日志
  49. /// </summary>
  50. public F_SAP_HEGII_0104()
  51. {
  52. InitializeComponent();
  53. tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  54. tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  55. }
  56. #endregion
  57. #region 控件事件
  58. /// <summary>
  59. /// 关闭
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="e"></param>
  63. private void F_SAP_HEGII_0104_FormClosed(object sender, FormClosedEventArgs e)
  64. {
  65. _instance = null;
  66. }
  67. /// <summary>
  68. /// 画面加载
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. private void F_SAP_HEGII_0104_Load(object sender, System.EventArgs e)
  73. {
  74. try
  75. {
  76. // 加载权限
  77. //FormPermissionManager.FormPermissionControl(Name, this,
  78. // LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
  79. // LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  80. dgvBarcode.AutoGenerateColumns = false;
  81. dtpDatebegin.Value = DateTime.Now.Date;
  82. dtpDateend.Value = DateTime.Now.Date;
  83. DataTable dtLogType = new DataTable();
  84. dtLogType.Columns.Add("LogType", typeof(string));
  85. dtLogType.Columns.Add("LogTypeName", typeof(string));
  86. DataRow newRow = dtLogType.NewRow();
  87. dtLogType.Rows.Add(newRow);
  88. newRow = dtLogType.NewRow();
  89. newRow["LogType"] = "1";
  90. newRow["LogTypeName"] = "交接";
  91. dtLogType.Rows.Add(newRow);
  92. newRow = dtLogType.NewRow();
  93. newRow["LogType"] = "2";
  94. newRow["LogTypeName"] = "撤销";
  95. dtLogType.Rows.Add(newRow);
  96. this.cmbLogType.DisplayMember = "LogTypeName";
  97. this.cmbLogType.ValueMember = "LogType";
  98. this.cmbLogType.DataSource = dtLogType;
  99. }
  100. catch (Exception ex)
  101. {
  102. // 对异常进行共通处理
  103. ExceptionManager.HandleEventException(ToString(),
  104. MethodBase.GetCurrentMethod().Name, Text, ex);
  105. }
  106. }
  107. /// <summary>
  108. /// 查询
  109. /// </summary>
  110. /// <param name="sender"></param>
  111. /// <param name="e"></param>
  112. private void tsbtnSearch_Click(object sender, EventArgs e)
  113. {
  114. try
  115. {
  116. tsrToolStrip1.Focus();
  117. dgvBarcode.DataSource = null;
  118. if (dtpDatebegin.Value == null || dtpDateend.Value == null)
  119. {
  120. return;
  121. }
  122. ClientRequestEntity cre = new ClientRequestEntity();
  123. cre.NameSpace = "Hegii";
  124. cre.Name = "GetWMSDataLog";
  125. cre.Properties["datebegin"] = dtpDatebegin.Value.Value;
  126. cre.Properties["dateend"] = dtpDateend.Value.Value.AddDays(1);
  127. cre.Properties["LogType"] = cmbLogType.SelectedValue;
  128. cre.Properties["ReturnDesc"] = txtReturnDesc.Text;
  129. ServiceResultEntity sre = DoAsync(() =>
  130. {
  131. return SAPDataModuleProxy.Service.DoRequest(cre);
  132. });
  133. if (sre.Status == Constant.ServiceResultStatus.Success)
  134. {
  135. // 查询成功
  136. dgvBarcode.DataSource = sre.Data.Tables[0];
  137. dgvBarcode.IsSetInputColumnsColor = true;
  138. if (dgvBarcode.RowCount == 0)
  139. {
  140. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_001);
  141. }
  142. }
  143. }
  144. catch (Exception ex)
  145. {
  146. // 对异常进行共通处理
  147. ExceptionManager.HandleEventException(ToString(),
  148. MethodBase.GetCurrentMethod().Name, Text, ex);
  149. }
  150. }
  151. /// <summary>
  152. /// 清除条件
  153. /// </summary>
  154. /// <param name="sender"></param>
  155. /// <param name="e"></param>
  156. private void tsbtnClearCondition_Click(object sender, EventArgs e)
  157. {
  158. dtpDatebegin.Value = DateTime.Now.Date;
  159. dtpDateend.Value = DateTime.Now.Date;
  160. this.cmbLogType.SelectedIndex = 0;
  161. txtReturnDesc.Text = string.Empty;
  162. }
  163. /// <summary>
  164. /// 自适应列宽
  165. /// </summary>
  166. /// <param name="sender"></param>
  167. /// <param name="e"></param>
  168. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  169. {
  170. dgvBarcode.AutoResizeColumns();
  171. }
  172. /// <summary>
  173. /// 关闭画面
  174. /// </summary>
  175. /// <param name="sender"></param>
  176. /// <param name="e"></param>
  177. private void tsbtnClose_Click(object sender, EventArgs e)
  178. {
  179. Close();
  180. }
  181. #endregion
  182. /// <summary>
  183. /// 同步操作
  184. /// </summary>
  185. /// <param name="sender"></param>
  186. /// <param name="e"></param>
  187. private void tsbtnSynLog_Click(object sender, EventArgs e)
  188. {
  189. try
  190. {
  191. tsrToolStrip1.Focus();
  192. DataTable dtBarcode = dgvBarcode.DataSource as DataTable;
  193. if (dtBarcode == null)
  194. {
  195. return;
  196. }
  197. DataTable dtSelBarcode = dtBarcode.Copy();
  198. dtSelBarcode.DefaultView.RowFilter = "Sel = 1";
  199. dtSelBarcode = dtSelBarcode.DefaultView.ToTable();
  200. if (dtSelBarcode.Rows.Count == 0)
  201. {
  202. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "未选择任何数据");
  203. return;
  204. }
  205. DataRow[] rows = dtSelBarcode.Select("RETURNDESC = '同步成功'");
  206. if (rows.Length > 0)
  207. {
  208. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "同步成功不允许再同步");
  209. return;
  210. }
  211. string logtype;
  212. rows = dtSelBarcode.Select("LOGTYPE = '1'");
  213. if (rows.Length == dtSelBarcode.Rows.Count)
  214. {
  215. logtype = "1";
  216. }
  217. else if(rows.Length == 0)
  218. {
  219. logtype = "2";
  220. }
  221. else
  222. {
  223. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, "交接和撤销不能一起同步");
  224. return;
  225. }
  226. foreach (DataRow row in dtSelBarcode.Rows)
  227. {
  228. rows = dtSelBarcode.Select("CODEI = '" + row["CODEI"] + "'");
  229. if (rows.Length > 1)
  230. {
  231. DKMessageBox.ShowDialog(this, DKMessageCode.W_CMN_S_004, row["CODEI"] + ":出现两次以上");
  232. return;
  233. }
  234. }
  235. DialogResult dr = MessageBox.Show("是否对所选数据进行同步?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
  236. if (dr != System.Windows.Forms.DialogResult.Yes)
  237. {
  238. return;
  239. }
  240. ClientRequestEntity cre = new ClientRequestEntity();
  241. cre.NameSpace = "Hegii";
  242. cre.Name = "SyncWMSDataLog";
  243. cre.Properties["LogType"] = logtype;
  244. cre.Data = new DataSet();
  245. cre.Data.Tables.Add(dtSelBarcode);
  246. ServiceResultEntity sre = DoAsync(() =>
  247. {
  248. return SAPDataModuleProxy.Service.DoRequest(cre);
  249. });
  250. if (sre.OtherStatus > 0)
  251. {
  252. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  253. tsbtnSearch_Click(null, null);
  254. }
  255. else
  256. {
  257. MessageBox.Show(this, sre.Message);
  258. }
  259. }
  260. catch (Exception ex)
  261. {
  262. // 对异常进行共通处理
  263. ExceptionManager.HandleEventException(ToString(),
  264. MethodBase.GetCurrentMethod().Name, Text, ex);
  265. }
  266. }
  267. }
  268. }