F_SAP_HEGII_0104.cs 11 KB

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