public decimal CrearSolicitudTraslado(SDK.SDKDatos.SDK_OWTR document) { SAPbobsCOM.StockTransfer oDocument_New = (SAPbobsCOM.StockTransfer)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); #region Encabezado oDocument_New.DocDate = document.DocDate; oDocument_New.FromWarehouse = document.Filler; oDocument_New.ToWarehouse = document.ToWhsCode; oDocument_New.UserFields.Fields.Item("U_FolioHalcon").Value = document.DocNum.ToString(); oDocument_New.UserFields.Fields.Item("U_TipoSolicitud").Value = document.U_TipoSolicitud; oDocument_New.UserFields.Fields.Item("U_FolioSolicitud").Value = document.U_FolioSolicitud; ////oDocument_New.Series = 23; // oDocument.Lines.FromWarehouseCode = "01" //oDocument.Lines.WarehouseCode = "02" #endregion #region Detalle foreach (SDK_WTR1 row in document.Lines) { //oDocument.Lines.b oDocument_New.Lines.ItemCode = row.ItemCode; oDocument_New.Lines.WarehouseCode = row.WhsCode; oDocument_New.Lines.FromWarehouseCode = row.FromWhsCode; oDocument_New.Lines.Quantity = Convert.ToDouble(row.Quantity); if (row.ManBtchNum.Equals("Y")) { foreach (DataRow lote in this.Lotes(oDocument_New.Lines.ItemCode, oDocument_New.Lines.FromWarehouseCode, oDocument_New.Lines.Quantity).Rows) { oDocument_New.Lines.BatchNumbers.BatchNumber = lote["BatchNum"].ToString(); oDocument_New.Lines.BatchNumbers.Quantity = Convert.ToDouble(lote["Quantity"]); oDocument_New.Lines.BatchNumbers.Add(); } } oDocument_New.Lines.UserFields.Fields.Item("U_Tarima").Value = row.U_Tarima; oDocument_New.Lines.UserFields.Fields.Item("U_TipoAlm").Value = row.U_TipoAlm; oDocument_New.Lines.Add(); } #endregion if (oDocument_New.Add() != 0) { throw new Exception("Error [" + oCompany.GetLastErrorDescription() + " | Linea: " + (oDocument_New.Lines.LineNum + 1) + "]"); } else { #region Datos SAP oDocument_New.GetByKey(Convert.ToInt32(oCompany.GetNewObjectKey())); #endregion } return(oDocument_New.DocNum); }
public async Task <IActionResult> Put(int id, [FromBody] UpdateTransferRequest value) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.StockTransfer request = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest); if (request.GetByKey(id)) { request.Lines.SetCurrentLine(0); string from = request.Lines.FromWarehouseCode; string to = request.Lines.WarehouseCode; request.Lines.Add(); for (int i = 0; i < value.newProducts.Count; i++) { request.Lines.ItemCode = value.newProducts[i].code; request.Lines.Quantity = value.newProducts[i].quantity; request.Lines.UoMEntry = value.newProducts[i].uom; request.Lines.UseBaseUnits = (SAPbobsCOM.BoYesNoEnum)value.newProducts[i].uomBase; request.Lines.FromWarehouseCode = from; request.Lines.WarehouseCode = to; request.Lines.Add(); } for (int i = 0; i < value.ProductsChanged.Count; i++) { request.Lines.SetCurrentLine(value.ProductsChanged[i].LineNum); if (request.Lines.Quantity != value.ProductsChanged[i].quantity) { request.Lines.Quantity = value.ProductsChanged[i].quantity; } if (request.Lines.UoMEntry != value.ProductsChanged[i].uom) { request.Lines.UseBaseUnits = (SAPbobsCOM.BoYesNoEnum)value.ProductsChanged[i].uomBase; request.Lines.UoMEntry = value.ProductsChanged[i].uom; } } int result = request.Update(); if (result == 0) { return(Ok()); } else { string error = context.oCompany.GetLastErrorDescription(); return(BadRequest(new { error })); } } return(BadRequest(new { error = "No Existe Documento" })); }
public async Task <IActionResult> Get(int id) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.StockTransfer request = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest); SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); if (request.GetByKey(id)) { JToken temp = context.XMLTOJSON(request.GetAsXML()); temp["OWTQ"] = temp["OWTQ"][0]; temp["AdmInfo"]?.Parent.Remove(); temp["WTQ12"]?.Parent.Remove(); return(Ok(temp)); } return(NotFound("No Existe Documento")); }
private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; try { if (EditText1.Value == "") { Application.SBO_Application.MessageBox("Favor de capturar el Folio de la solicitud"); return; } SAPbobsCOM.StockTransfer lObjStockTrasnfer; string lStrFolio = EditText1.Value; SAPbobsCOM.SBObob lObjSBObob = (SAPbobsCOM.SBObob)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge); SAPbobsCOM.Recordset lObjRecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); lObjRecordSet = lObjSBObob.GetObjectKeyBySingleValue(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest, "DocNum", lStrFolio, SAPbobsCOM.BoQueryConditions.bqc_Equal); SAPbobsCOM.StockTransfer lObjInventory = (SAPbobsCOM.StockTransfer)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest); if (lObjRecordSet.RecordCount == 1) { lObjInventory.GetByKey(int.Parse(lObjRecordSet.Fields.Item(0).Value.ToString())); } Memory.ReleaseComObject(lObjSBObob); Memory.ReleaseComObject(lObjRecordSet); SAPbobsCOM.Recordset lObjRecordSet2 = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); lObjRecordSet2.DoQuery("select T0.U_CR_Batch, T0.DocEntry,T0.LineNum, T0.OpenQty, T0.WhsCode, T0.FromWhsCod, T0.U_CR_CardCode, T0.ItemCode from WTQ1 T0 inner join OWTQ T1 on T1.DocEntry = T0.DocEntry Inner join OCRD T3 on T3.cardcode = T0.U_CR_CardCode where T1.DocNum = '" + lStrFolio + "' and T0.InvntSttus = 'O'"); lLstExtraData = new List <object>(); for (int i = 0; i < lObjRecordSet2.RecordCount; i++) { lLstExtraData.Add(new { Lote = lObjRecordSet2.Fields.Item(0).Value.ToString(), DocEntry = lObjRecordSet2.Fields.Item(1).Value.ToString(), LineNum = lObjRecordSet2.Fields.Item(2).Value.ToString(), Quantity = lObjRecordSet2.Fields.Item(3).Value.ToString(), Whscode = lObjRecordSet2.Fields.Item(4).Value.ToString(), FromWhscode = lObjRecordSet2.Fields.Item(5).Value.ToString(), CardCode = lObjRecordSet2.Fields.Item(6).Value.ToString(), ItemCode = lObjRecordSet2.Fields.Item(7).Value.ToString() }); lObjRecordSet2.MoveNext(); } Memory.ReleaseComObject(lObjRecordSet2); lObjStockTrasnfer = (SAPbobsCOM.StockTransfer)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); bool lBolIsSuccesss = false; for (int i = 1; i <= Matrix1.RowCount; i++) { SAPbouiCOM.CheckBox lObjChk = (SAPbouiCOM.CheckBox)Matrix1.Columns.Item(0).Cells.Item(i).Specific; if (lObjChk.Checked) { lObjStockTrasnfer.FromWarehouse = ((SAPbouiCOM.EditText)Matrix1.Columns.Item(3).Cells.Item(i).Specific).Value; lObjStockTrasnfer.ToWarehouse = ((dynamic)lLstExtraData[i - 1]).Whscode; string lStrCardCode = ((SAPbouiCOM.EditText)Matrix1.Columns.Item("Col_6").Cells.Item(i).Specific).Value; string lStrAlmacen = ((SAPbouiCOM.EditText)Matrix1.Columns.Item("Col_3").Cells.Item(i).Specific).Value; string lStrCantidad = ((SAPbouiCOM.EditText)Matrix1.Columns.Item("Col_4").Cells.Item(i).Specific).Value; string lStrTrans = ((SAPbouiCOM.EditText)Matrix1.Columns.Item("Col_5").Cells.Item(i).Specific).Value; string lStrItemCode = ((SAPbouiCOM.EditText)Matrix1.Columns.Item("Col_7").Cells.Item(i).Specific).Value; var lObjData = new { CardCode = lStrCardCode, Almacen = lStrAlmacen, Cantidad = lStrCantidad, Trans = lStrTrans, ItemCode = lStrItemCode }; if (lStrTrans.Trim() != "") { lObjStockTrasnfer = AddLines(lObjStockTrasnfer, lObjInventory, lObjData); lBolIsSuccesss = true; } else { Application.SBO_Application.StatusBar.SetText("Capturar cantidad", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } } } if (lBolIsSuccesss) { lObjStockTrasnfer.DocDate = DateTime.Now; if (lObjStockTrasnfer.Add() != 0) { int error = oCompany.GetLastErrorCode(); string strError = oCompany.GetLastErrorDescription(); Application.SBO_Application.MessageBox(strError); } else { EditText1.Value = ""; LoadMatrixPeticiones(); Application.SBO_Application.StatusBar.SetText("Traslado correctamente efectuado.", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Success); } } else { Application.SBO_Application.StatusBar.SetText("No se ha seleccionado ningun almacen para el traslado.", SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } } catch (Exception ex) { Application.SBO_Application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } }
public async Task <IActionResult> Post([FromBody] TransferOld value) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.StockTransfer request = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest); SAPbobsCOM.StockTransfer transfer = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); if (request.GetByKey(value.order)) { transfer.DocDate = DateTime.Now; oRecSet.DoQuery(@" Select serie1.""SeriesName"", serie1.""Series"", serie1.""ObjectCode"", serie2.""SeriesName""as s1, serie2.""Series"" as s2, serie2.""ObjectCode"" as s3 From NNM1 serie1 JOIN NNM1 serie2 ON serie1.""SeriesName"" = serie2.""SeriesName"" Where serie1.""ObjectCode"" = 67 AND serie2.""Series"" = '" + request.Series + "'"); oRecSet.MoveFirst(); transfer.Series = context.XMLTOJSON(oRecSet.GetAsXML())["NNM1"][0]["Series"].ToObject <int>(); for (int i = 0; i < value.products.Count; i++) { //transfer.Lines.ItemCode = value.products[i].ItemCode; //transfer.Lines.Quantity = value.products[i].Count; //transfer.Lines.UoMEntry = value.products[i].UoMEntry; //transfer.Lines.FromWarehouseCode = "S01"; // transfer.Lines.WarehouseCode = value.products[i].WarehouseCode; transfer.Lines.BaseEntry = request.DocEntry; transfer.Lines.BaseLine = value.products[i].Line; transfer.Lines.Quantity = value.products[i].Count; transfer.Lines.BaseType = SAPbobsCOM.InvBaseDocTypeEnum.InventoryTransferRequest; transfer.Lines.UserFields.Fields.Item("U_Tarima").Value = value.products[i].Pallet; for (int j = 0; j < value.products[i].batch.Count; j++) { //transfer.Lines.BatchNumbers.BaseLineNumber = transfer.Lines.LineNum; transfer.Lines.BatchNumbers.BatchNumber = value.products[i].batch[j].name; transfer.Lines.BatchNumbers.Quantity = value.products[i].batch[j].quantity; transfer.Lines.BatchNumbers.Add(); } transfer.Lines.Add(); } int result = transfer.Add(); if (result == 0) { if (request.Lines.FromWarehouseCode == request.FromWarehouse) { request.GetByKey(value.order); //for (int i = 0; i < request.Lines.Count; i++) //{ // request.Lines.SetCurrentLine(i); // if (request.Lines.RemainingOpenQuantity != 0) { // request.Lines.Quantity = request.Lines.Quantity - request.Lines.RemainingOpenQuantity; // } //} //int result3 = request.Update(); //if (result3 != 0) //{ // string error = context.oCompany.GetLastErrorDescription(); // return BadRequest(new {id = 1, error }); //} try { SAPbobsCOM.StockTransfer newRequest = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest); newRequest.FromWarehouse = request.FromWarehouse; newRequest.ToWarehouse = request.ToWarehouse; newRequest.Series = request.Series; newRequest.UserFields.Fields.Item("U_SO1_02NUMRECEPCION").Value = request.DocNum.ToString(); for (int i = 0; i < value.products.Count; i++) { //request.Lines.SetCurrentLine(value.products[i].Line); newRequest.Lines.ItemCode = value.products[i].ItemCode; //newRequest.Lines.UoMEntry = request.Lines.UoMEntry; newRequest.Lines.UoMEntry = value.products[i].UoMEntry; //newRequest.Lines.UseBaseUnits = request.Lines.UseBaseUnits; newRequest.Lines.UseBaseUnits = value.products[i].UseBaseUnits; newRequest.Lines.Quantity = value.products[i].Count; newRequest.Lines.FromWarehouseCode = request.Lines.WarehouseCode; newRequest.Lines.WarehouseCode = request.ToWarehouse; newRequest.Lines.Add(); } int result2 = newRequest.Add(); if (result2 != 0) { string error = context.oCompany.GetLastErrorDescription(); Console.WriteLine(2); Console.WriteLine(error); Console.WriteLine(value); Console.WriteLine(context.XMLTOJSON(newRequest.GetAsXML())); return(BadRequest(new { id = 2, error, value, va = context.XMLTOJSON(newRequest.GetAsXML()) })); } return(Ok(context.oCompany.GetNewObjectKey())); } catch (Exception ex) { Console.WriteLine(6); Console.WriteLine(ex); Console.WriteLine(value); return(BadRequest(new { id = 5, ex.Message, value })); } } } else { string error = context.oCompany.GetLastErrorDescription(); return(BadRequest(new { id = 3, error })); } return(Ok(new { value })); } return(BadRequest(new { error = "No Existe Documento" })); }
public async Task <IActionResult> InventoryTransferPost([FromBody] Transfer value) { SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext; SAPbobsCOM.StockTransfer transferRequest = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest); SAPbobsCOM.StockTransfer transfer = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); SAPbobsCOM.Recordset oRecSet = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); if (!transferRequest.GetByKey(value.DocEntry)) { return(NoContent()); } oRecSet.DoQuery($@" Select serie1.""SeriesName"", serie1.""Series"", serie1.""ObjectCode"", serie2.""SeriesName""as s1, serie2.""Series"" as s2, serie2.""ObjectCode"" as s3 From NNM1 serie1 JOIN NNM1 serie2 ON serie1.""SeriesName"" = serie2.""SeriesName"" Where serie1.""ObjectCode"" = 67 AND serie2.""Series"" = '{transferRequest.Series}';"); if (oRecSet.RecordCount == 0) { return(BadRequest("Error En Sucursal.")); } //int Serie = context.XMLTOJSON(oRecSet.GetAsXML())["NNM1"][0]["Series"].ToObject<int>(); int Serie = (int)oRecSet.Fields.Item("Series").Value; transfer.DocDate = DateTime.Now; transfer.Series = Serie; for (int i = 0; i < value.TransferRows.Count; i++) { transfer.Lines.BaseEntry = transferRequest.DocEntry; transfer.Lines.BaseLine = value.TransferRows[i].LineNum; transfer.Lines.Quantity = value.TransferRows[i].Count; transfer.Lines.BaseType = SAPbobsCOM.InvBaseDocTypeEnum.InventoryTransferRequest; if (value.TransferRows[i].Pallet != String.Empty && value.TransferRows[i].Pallet != null) { transfer.Lines.UserFields.Fields.Item("U_Tarima").Value = value.TransferRows[i].Pallet; } for (int k = 0; k < value.TransferRows[i].BatchList.Count; k++) { transfer.Lines.BatchNumbers.BatchNumber = value.TransferRows[i].BatchList[k].Code; transfer.Lines.BatchNumbers.Quantity = value.TransferRows[i].BatchList[k].Quantity; transfer.Lines.BatchNumbers.Add(); } transfer.Lines.Add(); } StringBuilder Errors = new StringBuilder(); if (transfer.Add() != 0) { Errors.AppendLine($"Documento Transferencia: "); Errors.AppendLine(context.oCompany.GetLastErrorDescription()); } if (Errors.Length != 0) { string error = Errors.ToString(); return(BadRequest(error)); } /* * if (transferRequest.Lines.FromWarehouseCode != transferRequest.Lines.WarehouseCode) * { * return Ok(); * } */ //Get Document Updated. transferRequest.GetByKey(value.DocEntry); if (transferRequest.Lines.FromWarehouseCode.Contains(transferRequest.Lines.WarehouseCode)) { return(Ok()); } SAPbobsCOM.StockTransfer newRequest = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest); newRequest.FromWarehouse = transferRequest.FromWarehouse; newRequest.ToWarehouse = transferRequest.ToWarehouse; newRequest.Series = transferRequest.Series; newRequest.UserFields.Fields.Item("U_SO1_02NUMRECEPCION").Value = transferRequest.DocNum.ToString(); for (int j = 0; j < transfer.Lines.Count; j++) { transfer.Lines.SetCurrentLine(j); transferRequest.Lines.SetCurrentLine(transfer.Lines.BaseLine); newRequest.Lines.ItemCode = transferRequest.Lines.ItemCode; newRequest.Lines.UoMEntry = transfer.Lines.UoMEntry; newRequest.Lines.UseBaseUnits = transferRequest.Lines.UseBaseUnits; newRequest.Lines.Quantity = transfer.Lines.Quantity; newRequest.Lines.FromWarehouseCode = transferRequest.Lines.WarehouseCode; newRequest.Lines.WarehouseCode = transferRequest.ToWarehouse; newRequest.Lines.Add(); } Errors = new StringBuilder(); if (newRequest.Add() != 0) { Errors.AppendLine($"Documento Copia: "); Errors.AppendLine(context.oCompany.GetLastErrorDescription()); } if (Errors.Length != 0) { string error = Errors.ToString(); return(Conflict(error)); } return(Ok(newRequest)); }
public void Add(string strKey, SAPbobsCOM.Company oCompany_S, SAPbobsCOM.Company oCompany_D, string strLogger, string strFromWare, string strToWare, string[] strValues) { DataTable oHeader = null; DataTable oDetails = null; int intTStatus = 0; int intExitStatus = 0; int intEntryStatus = 0; SAPbobsCOM.StockTransfer oStockTransfer = (SAPbobsCOM.StockTransfer)oCompany_S.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer); SAPbobsCOM.Documents oInventoryExit = (SAPbobsCOM.Documents)oCompany_S.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenExit); SAPbobsCOM.Documents oInventoryEntry = (SAPbobsCOM.Documents)oCompany_D.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry); try { string str_S_OWTR = "Exec Armada_Service_S_OWTR_s '" + strKey + "'"; oDataSet = Singleton.objSqlDataAccess.ExecuteDataSet(str_S_OWTR, strLogger); if (oDataSet == null && oDataSet.Tables.Count == 0) { return; } else { Singleton.traceService("Has Record"); oHeader = oDataSet.Tables[0]; oDetails = oDataSet.Tables[1]; if (oHeader != null && oHeader.Rows.Count > 0) { if (oCompany_S.CompanyDB == oCompany_D.CompanyDB) { Singleton.traceService("Same Company...So Transfer"); oStockTransfer.DocDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oStockTransfer.TaxDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oStockTransfer.FromWarehouse = strFromWare; oStockTransfer.Comments = oHeader.Rows[0]["Remarks"].ToString(); oStockTransfer.UserFields.Fields.Item("U_Z_TrnNum").Value = oHeader.Rows[0]["TrnNum"].ToString(); Singleton.traceService("Set Header"); Singleton.traceService(strFromWare); Singleton.traceService(strToWare); if (oDetails.Rows.Count > 0) { foreach (DataRow dr in oDetails.Rows) { oStockTransfer.Lines.ItemCode = dr["ItemCode"].ToString().Trim(); oStockTransfer.Lines.Quantity = Convert.ToDouble(dr["Qty"].ToString()); //oStockTransfer.Lines.FromWarehouseCode = strFromWare; oStockTransfer.Lines.WarehouseCode = strToWare; oStockTransfer.Lines.Add(); } Singleton.traceService("Set Details"); } Singleton.traceService("Adding"); intTStatus = oStockTransfer.Add(); Singleton.traceService(intTStatus.ToString()); if (intTStatus != 0) { Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), "0", "0", 0, oCompany_S.GetLastErrorCode().ToString(), oCompany_S.GetLastErrorDescription().Replace("'", ""), strLogger); } else { string strDkey; int intDocNum = 0; oCompany_S.GetNewObjectCode(out strDkey); if (oStockTransfer.GetByKey(Convert.ToInt32(strDkey))) { intDocNum = oStockTransfer.DocNum; } Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), strDkey, intDocNum.ToString(), 1, "", "Armada_Sync Completed Sucessfully", strLogger); } } else { //Singleton.traceService("Inventory Exit Started" + oCompany_S.CompanyDB.ToString()); //Singleton.traceService(strFromWare); //Singleton.traceService(strToWare); oInventoryExit.DocDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oInventoryExit.DocDueDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oInventoryExit.Comments = oHeader.Rows[0]["Remarks"].ToString(); oInventoryExit.UserFields.Fields.Item("U_Z_TrnNum").Value = oHeader.Rows[0]["TrnNum"].ToString(); //oInventoryExit.Reference2 = oHeader.Rows[0]["Ref2"].ToString(); //Singleton.traceService("Set Header"); if (oDetails.Rows.Count > 0) { foreach (DataRow dr in oDetails.Rows) { oInventoryExit.Lines.ItemCode = dr["ItemCode"].ToString(); oInventoryExit.Lines.ItemDescription = dr["ItemDsc"].ToString(); oInventoryExit.Lines.Quantity = Convert.ToDouble(dr["Qty"].ToString()); //oInventoryExit.Lines.ShipDate = Convert.ToDateTime(dr["ShipDate"].ToString()); //oInventoryExit.Lines.UnitPrice = 0; oInventoryExit.Lines.WarehouseCode = strFromWare; oInventoryExit.Lines.AccountCode = strValues[1]; oInventoryExit.Lines.Add(); } } //Singleton.traceService("Set Details"); oCompany_S.StartTransaction(); //Singleton.traceService("Adding"); intExitStatus = oInventoryExit.Add(); //Singleton.traceService("Added"); if (intExitStatus != 0) { //Singleton.traceService(intExitStatus.ToString()); Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), "0", "0", 0, intExitStatus.ToString(), oCompany_S.GetLastErrorDescription().Replace("'", ""), strLogger); if (oCompany_S.InTransaction) { oCompany_S.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } } else { string strDkey; int intDocNum = 0; oCompany_S.GetNewObjectCode(out strDkey); if (oInventoryExit.GetByKey(Convert.ToInt32(strDkey))) { intDocNum = oInventoryExit.DocNum; } //Singleton.traceService("Exit Success"); //Singleton.traceService(intDocNum.ToString()); //Singleton.traceService("Setting Entry Header"); oInventoryEntry.DocDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oInventoryEntry.DocDueDate = Convert.ToDateTime(oHeader.Rows[0]["TrnDate"].ToString()); oInventoryEntry.Comments = oHeader.Rows[0]["Remarks"].ToString(); //oInventoryEntry.PaymentGroupCode = Convert.ToInt16(strValues[0]); // oInventoryEntry.Reference2 = oHeader.Rows[0]["Ref2"].ToString(); oInventoryEntry.UserFields.Fields.Item("U_Z_TrnNum").Value = oHeader.Rows[0]["TrnNum"].ToString(); if (oDetails.Rows.Count > 0) { //Singleton.traceService("Setting Entry Detials"); foreach (DataRow dr in oDetails.Rows) { oInventoryEntry.Lines.ItemCode = dr["ItemCode"].ToString(); oInventoryEntry.Lines.ItemDescription = dr["ItemDsc"].ToString(); oInventoryEntry.Lines.Quantity = Convert.ToDouble(dr["Qty"].ToString()); // oInventoryEntry.Lines.ShipDate = Convert.ToDateTime(dr["ShipDate"].ToString()); oInventoryEntry.Lines.UnitPrice = Convert.ToDouble(dr["LCPrice"].ToString());; oInventoryEntry.Lines.WarehouseCode = strToWare; oInventoryEntry.Lines.AccountCode = strValues[2]; oInventoryEntry.Lines.Add(); } } oCompany_D.StartTransaction(); //Singleton.traceService("Adding Entry"); intEntryStatus = oInventoryEntry.Add(); if (intEntryStatus != 0) { //Singleton.traceService(intEntryStatus.ToString()); Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), "0", "0", 0, intEntryStatus.ToString(), oCompany_D.GetLastErrorDescription().Replace("'", ""), strLogger); if (oCompany_S.InTransaction) { oCompany_S.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } if (oCompany_D.InTransaction) { oCompany_D.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } } else { if (oCompany_S.InTransaction) { oCompany_S.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } if (oCompany_D.InTransaction) { oCompany_D.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit); } Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), strDkey, intDocNum.ToString(), 1, "", "Armada_Sync Completed Sucessfully", strLogger); } } } } } } catch (Exception ex) { if (oCompany_S.InTransaction) { oCompany_S.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } if (oCompany_D.InTransaction) { oCompany_D.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack); } //Singleton.objSqlDataAccess.UpdateLog(strKey, TransScenerio.InventoryTransfer.ToString(), "0", "0", 0, "0", ex.Message.ToString(), strLogger); throw ex; } finally { System.Runtime.InteropServices.Marshal.ReleaseComObject(oStockTransfer); System.Runtime.InteropServices.Marshal.ReleaseComObject(oInventoryExit); System.Runtime.InteropServices.Marshal.ReleaseComObject(oInventoryEntry); } }