コード例 #1
0
        public bool TransferirStock(string origen, string destino, string producto, string lote, double cantidad)
        {
            string numTrans;

            //Hacer la transferencia
            SAPbobsCOM.StockTransfer stockTransfer = (SAPbobsCOM.StockTransfer)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);
            stockTransfer.DocDate                        = DateTime.Now;
            stockTransfer.FromWarehouse                  = origen;
            stockTransfer.ToWarehouse                    = destino;
            stockTransfer.Lines.ItemCode                 = producto;
            stockTransfer.Lines.WarehouseCode            = destino;
            stockTransfer.Lines.Quantity                 = cantidad;
            stockTransfer.Lines.BatchNumbers.BatchNumber = lote;
            stockTransfer.Lines.BatchNumbers.Quantity    = cantidad;
            stockTransfer.Lines.BatchNumbers.Add();

            stockTransfer.Lines.Add();

            stockTransfer.Add();
            numTrans = oCompany.GetNewObjectKey();

            if (stockTransfer.Add() == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }


            //Traer el número de transferencia
            //numTrans = oCompany.GetNewObjectKey();
        }
コード例 #2
0
        public async Task <IActionResult> Get(int id)
        {
            SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext;

            SAPbobsCOM.StockTransfer transfer = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);
            SAPbobsCOM.Recordset     oRecSet  = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

            oRecSet.DoQuery("Select * From OWTR WHERE \"DocNum\" = " + id);
            int rc = oRecSet.RecordCount;

            if (rc == 0)
            {
                return(NotFound());
            }
            transfer.Browser.Recordset = oRecSet;
            transfer.Browser.MoveFirst();


            JToken temp = context.XMLTOJSON(transfer.GetAsXML());

            temp["OWTR"] = temp["OWTR"][0];
            temp["AdmInfo"]?.Parent.Remove();
            temp["WTR12"]?.Parent.Remove();
            temp["BTNT"]?.Parent.Remove();
            return(Ok(temp));
        }
コード例 #3
0
ファイル: ReceptionForm.b1f.cs プロジェクト: xavl369/UGRS
        private void CreateTransferRequest()
        {
            UIAPIRawForm.Freeze(true);
            int result = -1;

            try
            {
                mObjTransferRequest = (SAPbobsCOM.StockTransfer)mObjCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest);
                foreach (TransferHeader_DTO lObjTransferHeader_DTO in mObjReceptionTransferService.GetTransferHeader(GetWhsCode(), mIntId))
                {
                    mObjTransferRequest = PopulateTransferRequest(lObjTransferHeader_DTO);
                    int i = 0;
                    foreach (TransferDetail_DTO lObjTransferDetail_DTO in mObjReceptionTransferService.GetTransferDetail(mIntId))
                    {
                        mObjTransferRequest = PopulateTransferRequestDetail(lObjTransferDetail_DTO, i);
                        mObjTransferRequest.Lines.Add();
                        ++i;
                    }
                    result = mObjTransferRequest.Add();
                    if (result == 0)
                    {
                        //Se creo el documento solicitud de transferencia
                        //TicketLogService.WriteSuccess("[CrearTransferencia] DocNum:" + lObjStockTrasnfer.DocNum);
                        UIAPIRawForm.Freeze(false);
                        UIApplication.ShowMessageBox(string.Format("Solicitud de Transferencia realizada correctamente {0}", mIntId));
                        UIAPIRawForm.Freeze(true);
                        bool lBooResultRow = this.LoadMtxHeader(mStrWhsCode);
                        if (lBooResultRow)
                        {
                            mIntId = ((SAPbouiCOM.EditText)mtxHeader.GetCellSpecific(1, 1)).Value;
                            mtxHeader.SelectRow(1, true, false);
                            this.LoadMtxDetail(mIntId);
                            UIControlsEnabled(true);
                        }
                        else
                        {
                            UIControlsEnabled(false);
                        }
                        ClearTxt();
                    }
                    if (result != 0)
                    {
                        UIAPIRawForm.Freeze(false);
                        UIApplication.ShowMessageBox(string.Format("Exception: {0}", DIApplication.Company.GetLastErrorDescription()));
                        //TicketLogService.WriteError("[CrearTransferencia]" + DIApplication.Company.GetLastErrorDescription());
                    }
                }
            }
            catch (Exception ex)
            {
                UIAPIRawForm.Freeze(false);
                UIApplication.ShowError(string.Format(ex.Message, ex.Message));
            }
            finally
            {
                UIAPIRawForm.Freeze(false);
                MemoryUtility.ReleaseComObject(mObjStockTransfer);
            }
        }
コード例 #4
0
        public async Task <IActionResult> Post([FromBody] TransferRequest value)
        {
            SAPContext context = HttpContext.RequestServices.GetService(typeof(SAPContext)) as SAPContext;

            SAPbobsCOM.StockTransfer newRequest = (SAPbobsCOM.StockTransfer)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryTransferRequest);
            SAPbobsCOM.Recordset     oRecSet    = (SAPbobsCOM.Recordset)context.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

            oRecSet.DoQuery(@"
                        Select
                            warehouse.""WhsCode"",
                            warehouse.""WhsName"",
                            serie.""Series""
                        From OWHS warehouse
                        LEFT JOIN NNM1 serie ON serie.""SeriesName"" = warehouse.""WhsCode""
                        Where serie.""ObjectCode"" = 1250000001 AND warehouse.""WhsCode"" = '" + value.towhs.whscode + "'");
            oRecSet.MoveFirst();
            JToken warehouseList = context.XMLTOJSON(oRecSet.GetAsXML())["OWHS"];

            int warehouseSerie = warehouseList[0]["Series"].ToObject <int>();

            newRequest.Series        = warehouseSerie;
            newRequest.FromWarehouse = value.fromwhs.whscode;
            newRequest.ToWarehouse   = value.towhs.whscode;

            for (int i = 0; i < value.rows.Count; i++)
            {
                newRequest.Lines.ItemCode = value.rows[i].code;


                if (value.rows[i].uom == -2)
                {
                    newRequest.Lines.UoMEntry = 185;
                    newRequest.Lines.UserFields.Fields.Item("U_CjsPsVr").Value = value.rows[i].quantity;
                    newRequest.Lines.Quantity     = value.rows[i].quantity * value.rows[i].equivalentePV;
                    newRequest.Lines.UseBaseUnits = SAPbobsCOM.BoYesNoEnum.tYES;
                }
                else
                {
                    newRequest.Lines.Quantity     = value.rows[i].quantity;
                    newRequest.Lines.UoMEntry     = value.rows[i].uom;
                    newRequest.Lines.UseBaseUnits = (SAPbobsCOM.BoYesNoEnum)value.rows[i].uomBase;
                }

                newRequest.Lines.FromWarehouseCode = value.fromwhs.whscode;
                newRequest.Lines.WarehouseCode     = value.towhs.whstsrcode;
                newRequest.Lines.Add();
            }

            int result = newRequest.Add();

            if (result != 0)
            {
                string error = context.oCompany.GetLastErrorDescription();
                return(BadRequest(error));
            }
            return(Ok(context.oCompany.GetNewObjectKey()));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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" }));
        }
コード例 #7
0
        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"));
        }
コード例 #8
0
        private SAPbobsCOM.StockTransfer AddLines(SAPbobsCOM.StockTransfer pObjStockTrasnfer, SAPbobsCOM.StockTransfer pObjRequest, object pObjData)
        {
            float lFltnum     = float.Parse(((dynamic)pObjData).Trans);
            int   lIntQuanity = int.Parse(lFltnum.ToString());

            try
            {
                var           lObjLines   = lLstExtraData.FindAll(x => ((dynamic)x).FromWhscode == ((dynamic)pObjData).Almacen && ((dynamic)x).ItemCode == ((dynamic)pObjData).ItemCode && ((dynamic)x).CardCode == ((dynamic)pObjData).CardCode);
                List <object> lLstObjTemp = new List <object>();
                foreach (var lObjLine in lObjLines)
                {
                    List <object> lLstrLotes = GetListBatch(pObjStockTrasnfer.FromWarehouse, ((dynamic)lObjLine).CardCode, ((dynamic)pObjData).ItemCode, lLstObjTemp);

                    if (lIntQuanity > 0)
                    {
                        pObjStockTrasnfer.Lines.ItemCode = ((dynamic)pObjData).ItemCode;
                        //pObjStockTrasnfer.Lines.InventoryQuantity = double.Parse(((dynamic)pObjData).Cantidad);
                        if (int.Parse(((dynamic)lObjLine).Quantity) < lIntQuanity)
                        {
                            pObjStockTrasnfer.Lines.Quantity = int.Parse(((dynamic)lObjLine).Quantity);
                        }
                        else
                        {
                            pObjStockTrasnfer.Lines.Quantity = lIntQuanity;
                        }

                        pObjStockTrasnfer.Lines.BaseType          = SAPbobsCOM.InvBaseDocTypeEnum.InventoryTransferRequest;
                        pObjStockTrasnfer.Lines.BaseEntry         = pObjRequest.DocEntry;
                        pObjStockTrasnfer.Lines.BaseLine          = int.Parse(((dynamic)lObjLine).LineNum);
                        pObjStockTrasnfer.Lines.FromWarehouseCode = ((dynamic)pObjData).Almacen;
                        pObjStockTrasnfer.Lines.WarehouseCode     = ((dynamic)lObjLine).Whscode;
                        int lBatchQty = int.Parse(pObjStockTrasnfer.Lines.Quantity.ToString());
                        while (lBatchQty > 0)
                        {
                            if (((dynamic)lObjLine).Lote != "")
                            {
                                lLstrLotes = lLstrLotes.OrderByDescending(x => ((dynamic)x).Batch == ((dynamic)lObjLine).Lote).ToList();
                            }

                            foreach (var lotes in lLstrLotes)
                            {
                                if (lBatchQty > 0)
                                {
                                    var lObjUsedBatch = lLstObjTemp.Find(x => ((dynamic)x).Batch == ((dynamic)lotes).Batch);
                                    int lIntBatchQty  = ((dynamic)lotes).Quantity;
                                    if (lObjUsedBatch == null || ((dynamic)lObjUsedBatch).Quantity < lIntBatchQty)
                                    {
                                        pObjStockTrasnfer.Lines.BatchNumbers.BatchNumber = ((dynamic)lotes).Batch;
                                        int lIntQty = 0;
                                        if (lObjUsedBatch != null)
                                        {
                                            lIntQty = lIntBatchQty - ((dynamic)lObjUsedBatch).Quantity;
                                        }
                                        else
                                        {
                                            if (((dynamic)lotes).Quantity < lBatchQty)
                                            {
                                                lIntQty = lIntBatchQty;
                                            }
                                            else
                                            {
                                                lIntQty = lBatchQty;
                                            }
                                        }
                                        pObjStockTrasnfer.Lines.BatchNumbers.Quantity = lIntQty;
                                        pObjStockTrasnfer.Lines.BatchNumbers.Add();
                                        lLstObjTemp.Add(new
                                        {
                                            Batch    = ((dynamic)lotes).Batch,
                                            Quantity = lIntQty
                                        });
                                        lBatchQty -= lIntQty;
                                    }
                                }
                            }
                            if (lBatchQty > 0)
                            {
                                throw new Exception("No se tiene la cantidad de articulos suficiente dentro de los lotes para hacer el traslado");
                            }
                        }
                        pObjStockTrasnfer.Lines.Add();
                        lIntQuanity -= int.Parse(((dynamic)lObjLine).Quantity);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(pObjStockTrasnfer);
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        private void CreateStockTransfer()
        {
            try
            {
                if (string.IsNullOrEmpty(txtRiseFolio.Value))
                {
                    UIApplication.ShowError("No se seleccionó una subida");
                    return;
                }

                if (dtItems.Rows.Count <= 0)
                {
                    UIApplication.ShowError("Sin artículos para dar salida");
                    return;
                }

                SAPbobsCOM.StockTransfer lObjStockTransfer = (SAPbobsCOM.StockTransfer)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);
                lObjStockTransfer.FromWarehouse = "MQHEOBRA";
                lObjStockTransfer.ToWarehouse   = "MQHE";
                lObjStockTransfer.UserFields.Fields.Item("U_MQ_Rise").Value = txtRiseFolio.Value;

                for (int i = 0; i < dtItems.Rows.Count; i++)
                {
                    string lStrItemCode = dtItems.GetValue("ItemCode", i).ToString();
                    double lDblQuantity = double.Parse(dtItems.GetValue("Qty", i).ToString());

                    if (lDblQuantity <= 0)
                    {
                        UIApplication.ShowError(string.Format("No puede dar entrada al artículo {0} si la cantidad es menor o igual a 0", lStrItemCode));
                        return;
                    }

                    lObjStockTransfer.Lines.SetCurrentLine(i);
                    lObjStockTransfer.Lines.ItemCode          = lStrItemCode;
                    lObjStockTransfer.Lines.FromWarehouseCode = "MQHEOBRA";
                    lObjStockTransfer.Lines.WarehouseCode     = "MQHE";
                    lObjStockTransfer.Lines.Quantity          = lDblQuantity;
                    lObjStockTransfer.Lines.Add();
                }

                if (lObjStockTransfer.Add() != 0)
                {
                    string lStrLastError = DIApplication.Company.GetLastErrorDescription();
                    UIApplication.ShowMessageBox(string.Format("Error al generar la entrada de consumibles: {0}", DIApplication.Company.GetLastErrorDescription()));
                }
                else
                {
                    int lIntDocEntry = int.Parse(DIApplication.Company.GetNewObjectKey());

                    LogUtility.WriteSuccess(string.Format("[frmStockTransfer - CreateStockTransfer] StockTransfer creado correctamente con el DocEntry {0} para la Subida: {1}", lIntDocEntry, txtRiseFolio.Value));

                    mObjMachineryServiceFactory.GetRiseService().MarkRiseAsStockTransfer(int.Parse(txtRiseFolio.Value));
                    ClearControls();

                    UIApplication.ShowSuccess("Entrada de mercancía creada correctamente");
                }
            }
            catch (Exception lObjException)
            {
                LogUtility.WriteError(string.Format("[frmStockTransfer - CreateStockTransfer] Error al crear la entrada de consumibles: {0}", lObjException.Message));
                throw new Exception(string.Format("Error al crear la entrada de consumibles: {0}", lObjException.Message));
            }
        }
コード例 #11
0
ファイル: frm_INSP.cs プロジェクト: ubaidmughal/SAP
        private int PostTransfer(string ObjType, string docKey)
        {
            int result = -1;

            int rowCnt = dtRow.Rows.Count;

            for (int i = 0; i < rowCnt; i++)
            {
                double ApprQty  = Convert.ToDouble(dtRow.GetValue("ApprQty", i));
                double RejQty   = Convert.ToDouble(dtRow.GetValue("RejQty", i));
                double Quantity = Convert.ToDouble(dtRow.GetValue("Quantity", i));
                if (Quantity != ApprQty + RejQty)
                {
                    oApplication.MessageBox("Inspaction not completed. Please save Accepted/Rejected Qty for all rows");
                    return(-1);
                }
            }
            try

            {
                SAPbobsCOM.StockTransfer Inspactiontransfer = (SAPbobsCOM.StockTransfer)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);
                Inspactiontransfer.DocDate = DateTime.Now.Date;
                Inspactiontransfer.UserFields.Fields.Item("U_B1_QA_INSP_OT").Value = ObjType;
                Inspactiontransfer.UserFields.Fields.Item("U_B1_QA_INSP_DE").Value = docKey;



                for (int i = 0; i < rowCnt; i++)
                {
                    string FromWhs = Convert.ToString(dtRow.GetValue("WHS", i));
                    string strSel  = "SELECT * from \"@B1_QA_ATTR_INSWHS\" WHERE \"U_OWHS\" = '" + FromWhs + "'";

                    System.Data.DataTable dtWhs = Program.objHrmsUI.getDataTable(strSel, "getting whs");
                    if (dtWhs == null || dtWhs.Rows.Count == 0)
                    {
                        return(-1);
                    }

                    mtDocRows.SelectRow(i + 1, true, false);
                    string strCode = Convert.ToString(dtRow.GetValue("ItemCode", i));
                    string MM      = Convert.ToString(dtRow.GetValue("MM", i));
                    string OBT     = Convert.ToString(dtRow.GetValue("OBT", i));
                    string LN      = Convert.ToString(dtRow.GetValue("LN", i));
                    string Qty     = Convert.ToString(dtRow.GetValue("Quantity", i));


                    fillSerilaOrBatch(Qty, docKey, LN, OBT, MM);

                    string toWHSAppr = dtWhs.Rows[0]["U_OWHS_APPR"].ToString();
                    string toWHSRej  = dtWhs.Rows[0]["U_OWHS_REJ"].ToString();

                    double ApprQty  = Convert.ToDouble(dtRow.GetValue("ApprQty", i));
                    double RejQty   = Convert.ToDouble(dtRow.GetValue("RejQty", i));
                    string itemCode = Convert.ToString(dtRow.GetValue("ItemCode", i));
                    if (ApprQty > 0 && itemCode != "")
                    {
                        Inspactiontransfer.Lines.ItemCode          = itemCode;
                        Inspactiontransfer.Lines.FromWarehouseCode = FromWhs;
                        Inspactiontransfer.Lines.WarehouseCode     = toWHSAppr;
                        Inspactiontransfer.Lines.Quantity          = ApprQty;
                        if (MM == "B")
                        {
                            string strBatchApproved           = " SELECT * from \"@B1_QA_RPT\" WHERE \"U_DocType\" = '" + OBT + "' AND \"U_DocEntry\"='" + docKey + "' AND \"U_LineNum\" = '" + LN + "' AND \"U_ApprQty\">0 ";
                            System.Data.DataTable dtLineBatch = Program.objHrmsUI.getDataTable(strBatchApproved, "Assigning Batch");
                            foreach (System.Data.DataRow dr in dtLineBatch.Rows)
                            {
                                Inspactiontransfer.Lines.BatchNumbers.BatchNumber = dr["U_Batch"].ToString();
                                Inspactiontransfer.Lines.BatchNumbers.Quantity    = Convert.ToDouble(dr["U_ApprQty"]);
                                Inspactiontransfer.Lines.BatchNumbers.Add();
                            }
                        }
                        if (MM == "S")
                        {
                            string strBatchApproved            = " SELECT * from \"@B1_QA_RPT\" WHERE \"U_DocType\" = '" + OBT + "' AND \"U_DocEntry\"='" + docKey + "' AND \"U_LineNum\" = '" + LN + "' AND \"U_ApprQty\">0 ";
                            System.Data.DataTable dtLineSerial = Program.objHrmsUI.getDataTable(strBatchApproved, "Assigning Batch");
                            foreach (System.Data.DataRow dr in dtLineSerial.Rows)
                            {
                                Inspactiontransfer.Lines.SerialNumbers.InternalSerialNumber = dr["U_Serial"].ToString();
                                Inspactiontransfer.Lines.SerialNumbers.Quantity             = Convert.ToDouble(dr["U_ApprQty"]);
                                Inspactiontransfer.Lines.SerialNumbers.Add();
                            }
                        }

                        Inspactiontransfer.Lines.Add();
                    }
                    if (RejQty > 0 && itemCode != "")
                    {
                        Inspactiontransfer.Lines.ItemCode          = itemCode;
                        Inspactiontransfer.Lines.FromWarehouseCode = FromWhs;
                        Inspactiontransfer.Lines.WarehouseCode     = toWHSRej;
                        Inspactiontransfer.Lines.Quantity          = RejQty;

                        if (MM == "B")
                        {
                            string strBatchApproved           = " SELECT * from \"@B1_QA_RPT\" WHERE \"U_DocType\" = '" + OBT + "' AND \"U_DocEntry\"='" + docKey + "' AND \"U_LineNum\" = '" + LN + "' AND \"U_RejQty\">0 ";
                            System.Data.DataTable dtLineBatch = Program.objHrmsUI.getDataTable(strBatchApproved, "Assigning Batch");
                            foreach (System.Data.DataRow dr in dtLineBatch.Rows)
                            {
                                Inspactiontransfer.Lines.BatchNumbers.BatchNumber = dr["U_Batch"].ToString();
                                Inspactiontransfer.Lines.BatchNumbers.Quantity    = Convert.ToDouble(dr["U_RejQty"]);
                                Inspactiontransfer.Lines.BatchNumbers.Add();
                            }
                        }
                        if (MM == "S")
                        {
                            string strBatchApproved            = " SELECT * from \"@B1_QA_RPT\" WHERE \"U_DocType\" = '" + OBT + "' AND \"U_DocEntry\"='" + docKey + "' AND \"U_LineNum\" = '" + LN + "' AND \"U_RejQty\">0 ";
                            System.Data.DataTable dtLineSerial = Program.objHrmsUI.getDataTable(strBatchApproved, "Assigning Batch");
                            foreach (System.Data.DataRow dr in dtLineSerial.Rows)
                            {
                                Inspactiontransfer.Lines.SerialNumbers.InternalSerialNumber = dr["U_Serial"].ToString();
                                Inspactiontransfer.Lines.SerialNumbers.Quantity             = Convert.ToDouble(dr["U_RejQty"]);
                                Inspactiontransfer.Lines.SerialNumbers.Add();
                            }
                        }

                        Inspactiontransfer.Lines.Add();
                    }
                }

                if (Inspactiontransfer.Add() != 0)
                {
                    int    erroCode = 0;
                    string errDescr = "";
                    Program.objHrmsUI.oCompany.GetLastError(out erroCode, out errDescr);
                    oApplication.StatusBar.SetText("Failed to add transfer request   : " + errDescr);
                    result = -1;
                }
                else
                {
                    string outStr = Convert.ToString(Program.objHrmsUI.oCompany.GetNewObjectKey());
                    result = Convert.ToInt32(outStr);
                }
            }
            catch (Exception ex)
            {
                oApplication.MessageBox(ex.Message);
                result = -1;
            }

            return(result);
        }
コード例 #12
0
        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" }));
        }
コード例 #13
0
        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));
        }
コード例 #14
0
ファイル: S_OWTR.cs プロジェクト: Procons-4IT/ARMADA
        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);
            }
        }