private void LogDN(List <BenQGuru.eMES.SAPRFCService.Domain.DN> dns, BenQGuru.eMES.SAPRFCService.Domain.SAPRfcReturn ret, string isAll) { _WarehouseFacade = new WarehouseFacade(this.DataProvider); foreach (BenQGuru.eMES.SAPRFCService.Domain.DN dn in dns) { DNLOG log = new DNLOG(); log.DNLINE = dn.DNLine; log.DNNO = dn.DNNO; log.ISALL = isAll; if (ret == null) { log.RESULT = "empty"; } else { log.RESULT = ret.Result; } log.MDATE = FormatHelper.TODateInt(DateTime.Now); log.MTIME = FormatHelper.TOTimeInt(DateTime.Now); log.MUSER = GetUserCode(); log.Qty = dn.Qty; log.Unit = dn.Unit; log.MESSAGE = ret != null ? ret.Message : "null"; if (ret != null && string.IsNullOrEmpty(ret.Message)) { log.MESSAGE = "empty"; } log.DNBATCHNO = dn.BatchNO; _WarehouseFacade.InsertDNLOG(log); } }
private BenQGuru.eMES.SAPRFCService.Domain.SAPRfcReturn SendDNToSap(List <BenQGuru.eMES.SAPRFCService.Domain.DN> dns, bool isALL) { BenQGuru.eMES.SAPRFCService.Domain.SAPRfcReturn r = null; BenQGuru.eMES.SAPRFCService.DNToSAP d = new BenQGuru.eMES.SAPRFCService.DNToSAP(this.DataProvider); try { r = d.DNPGIToSAP(dns, isALL); } catch (Exception ex) { throw new SAPException(ex.Message); } return(r); }
//软件出库 protected void cmdSoftwareOut_ServerClick(object sender, EventArgs e) { if (facade == null) { facade = new InventoryFacade(base.DataProvider); } if (gridWebGrid.Rows.Count <= 0) { WebInfoPublish.Publish(this, "Gird数据不能为空", this.languageComponent1); return; } Dictionary <string, string> dnBatchNoList = new Dictionary <string, string>(); try { this.DataProvider.BeginTransaction(); #region 出库 #region dnBatchNo for (int i = 0; i < this.gridWebGrid.Rows.Count; i++) { //string InvNo = this.gridWebGrid.Rows[i].Items.FindItemByKey("INVNO").Value.ToString(); //string InvLine = this.gridWebGrid.Rows[i].Items.FindItemByKey("INVLINE").Value.ToString(); string dnBatchNo = this.gridWebGrid.Rows[i].Items.FindItemByKey("DNBatchNo").Value.ToString(); string movementtype = this.gridWebGrid.Rows[i].Items.FindItemByKey("MOVEMENTTYPE").Value.ToString(); //判断发货批号不能为空。 #region check if (string.IsNullOrEmpty(dnBatchNo)) { this.DataProvider.RollbackTransaction(); WebInfoPublish.Publish(this, "发货批号不能为空", this.languageComponent1); return; } if (!string.IsNullOrEmpty(movementtype)) { this.DataProvider.RollbackTransaction(); WebInfoPublish.PublishInfo(this, "所有物料移动类型必须全为空", this.languageComponent1); return; } #endregion if (!dnBatchNoList.ContainsKey(dnBatchNo)) { dnBatchNoList.Add(dnBatchNo, dnBatchNo); } //dnBatchNoList.Add(dnBatchNo); } #endregion if (dnBatchNoList.Count > 1) { this.DataProvider.RollbackTransaction(); WebInfoPublish.PublishInfo(this, "软件不允许多个DN批次号出库", this.languageComponent1); return; } //回写当前整个发货批中的所有DN if (dnBatchNoList.Count > 0) { foreach (string dnbatchNo in dnBatchNoList.Keys) { BenQGuru.eMES.Material.InvoicesDetailEx[] ins = facade.GetDNInVoicesDetails(dnbatchNo); Dictionary <string, List <BenQGuru.eMES.SAPRFCService.Domain.DN> > dnsOk = new Dictionary <string, List <BenQGuru.eMES.SAPRFCService.Domain.DN> >(); if (ins.Length == 0) { this.DataProvider.RollbackTransaction(); WebInfoPublish.PublishInfo(this, "此单已被取消", this.languageComponent1); return; } #region dnsOk foreach (BenQGuru.eMES.Material.InvoicesDetailEx inv in ins) { if (string.IsNullOrEmpty(inv.MovementType)) { #region BenQGuru.eMES.SAPRFCService.Domain.DN dn = new BenQGuru.eMES.SAPRFCService.Domain.DN(); dn.DNNO = inv.InvNo; dn.DNLine = inv.InvLine; dn.BatchNO = dnbatchNo; dn.Unit = inv.Unit; if (dnsOk.ContainsKey(inv.InvNo)) { dnsOk[inv.InvNo].Add(dn); } else { dnsOk[inv.InvNo] = new List <BenQGuru.eMES.SAPRFCService.Domain.DN>(); dnsOk[inv.InvNo].Add(dn); } #endregion } else { this.DataProvider.RollbackTransaction(); WebInfoPublish.PublishInfo(this, "所有物料移动类型必须全为空", this.languageComponent1); return; } } #endregion #region SAP回写 foreach (string key in dnsOk.Keys) { if (dnsOk[key].Count > 0) { BenQGuru.eMES.SAPRFCService.Domain.SAPRfcReturn ok = SendDNToSap(dnsOk[key], true); LogDN(dnsOk[key], ok, "Y"); if (ok == null) { throw new SAPException(key + "SAP回写返回空:"); } if (string.IsNullOrEmpty(ok.Result)) { throw new SAPException(key + "SAP回写失败 值:" + ok.Result + ":" + ok.Message); } if (ok.Result.ToUpper().Trim() != "S") { throw new SAPException(key + "SAP回写失败 值:" + ok.Result + ok.Message); } BenQGuru.eMES.Common.Log.Error("---------------------" + ok.Result + ":" + ok.Message + "---------------"); } else { throw new SAPException(key + "项目为空!"); } } #endregion } } #endregion this.DataProvider.CommitTransaction(); WebInfoPublish.Publish(this, "软件出库成功", this.languageComponent1); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); WebInfoPublish.PublishInfo(this, ex.Message, this.languageComponent1); } }