Пример #1
0
        /// <summary> Removes the given pStrDocEntry. </summary>
        /// <remarks> Ranaya, 26/05/2017. </remarks>
        /// <exception cref="TableException"> Thrown when a Table error condition occurs. </exception>
        /// <param name="pStrDocEntry"> The String Document entry to remove. </param>

        public void Remove(string pStrDocEntry)
        {
            SAPbobsCOM.GeneralService    lObjGeneralService    = null;
            SAPbobsCOM.GeneralData       lObjGeneralData       = null;
            SAPbobsCOM.GeneralDataParams lObjGeneralDataParams = null;
            SAPbobsCOM.CompanyService    lObjCompanyService    = null;

            try
            {
                //Initialize variables
                lObjCompanyService    = DIApplication.Company.GetCompanyService();
                lObjGeneralService    = lObjCompanyService.GetGeneralService(GetObjectCode());
                lObjGeneralDataParams = ((SAPbobsCOM.GeneralDataParams)(lObjGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));

                //Set docentry
                lObjGeneralDataParams.SetProperty("DocEntry", pStrDocEntry);

                //Delete data
                lObjGeneralService.Delete(lObjGeneralDataParams);
            }
            catch (Exception e)
            {
                throw new TableException(e.Message, e);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjGeneralService, lObjGeneralData, lObjGeneralDataParams, lObjCompanyService);
            }
        }
Пример #2
0
        /// <summary> Adds pObjRecord. </summary>
        /// <remarks> Ranaya, 26/05/2017. </remarks>
        /// <exception cref="TableException"> Thrown when a Table error condition occurs. </exception>
        /// <param name="pObjRecord"> The Object record to add. </param>

        public void Add(T pObjRecord)
        {
            SAPbobsCOM.GeneralService    lObjGeneralService    = null;
            SAPbobsCOM.GeneralData       lObjGeneralData       = null;
            SAPbobsCOM.GeneralDataParams lObjGeneralDataParams = null;
            SAPbobsCOM.CompanyService    lObjCompanyService    = null;

            try
            {
                //Initialize variables
                lObjCompanyService = DIApplication.Company.GetCompanyService();
                lObjGeneralService = lObjCompanyService.GetGeneralService(GetObjectCode());
                lObjGeneralData    = ((SAPbobsCOM.GeneralData)(lObjGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));

                //Set data
                lObjGeneralData = PopulateGeneralData(lObjGeneralData, pObjRecord);

                //Add data
                lObjGeneralDataParams = lObjGeneralService.Add(lObjGeneralData);
            }
            catch (Exception e)
            {
                throw new TableException(e.Message, e);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjGeneralService, lObjGeneralData, lObjGeneralDataParams, lObjCompanyService);
            }
        }
        public static string DeleteRecord(string UDO_Name, string CodigoObj)
        {
            SAPbobsCOM.GeneralService    oGeneralService = null;
            SAPbobsCOM.GeneralData       oGeneralData    = null;
            SAPbobsCOM.GeneralDataParams oGeneralParams  = null;
            SAPbobsCOM.CompanyService    sCmp            = null;
            SAPbobsCOM.Company           SBO_Company     = Conexion.oCompany;

            sCmp = SBO_Company.GetCompanyService();
            string rpta = "N";

            try
            {
                // Get a handle to the SM_MOR UDO
                oGeneralService = sCmp.GetGeneralService(UDO_Name);

                // Delete UDO record
                oGeneralParams = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));
                oGeneralParams.SetProperty("Code", CodigoObj);
                oGeneralData = oGeneralService.GetByParams(oGeneralParams);
                oGeneralService.Delete(oGeneralParams);
            }
            catch (Exception) {}
            return(rpta);
        }
Пример #4
0
        //Alteração em tabela customizada por objeto, passar nome da tabela e coleção de parâmetros(Nome do campo e valor)
        protected bool Alterar(string nomeObjeto, string codigo, Dictionary <string, string> parametros)
        {
            bool retorno = false;

            try
            {
                oCompService    = oCompany.GetCompanyService();
                oGeneralService = oCompService.GetGeneralService(nomeObjeto);
                oGeneralParams  = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));

                //Recupera Objeto para alteração
                oGeneralParams.SetProperty("Code", codigo);
                oGeneralData = oGeneralService.GetByParams(oGeneralParams);

                if (parametros != null && parametros.Count > 0)
                {
                    foreach (var item in parametros)
                    {
                        oGeneralData.SetProperty(item.Key.ToString(), item.Value.ToString());
                    }

                    oGeneralService.Update(oGeneralData);
                }

                retorno = true;
            }
            catch (Exception e)
            {
                throw e;
            }

            return(retorno);
        }
Пример #5
0
        private static void AddLandedCostXML()
        {
            SAPbobsCOM.Company        oCompany        = Application.SBO_Application.Company.GetDICompany() as SAPbobsCOM.Company;
            SAPbobsCOM.CompanyService oCompanyService = oCompany.GetCompanyService() as SAPbobsCOM.CompanyService;
            LandedCostsService        LandedService   = oCompanyService.GetBusinessService(ServiceTypes.LandedCostsService) as LandedCostsService;
            LandedCost       oLandedCost     = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCost) as LandedCost;
            LandedCostParams oCopiedLCParams = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCostParams) as LandedCostParams;

            oCopiedLCParams.LandedCostNumber = 17;
            LandedCost oCopiedLC = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCost) as LandedCost;

            oCopiedLC = LandedService.GetLandedCost(oCopiedLCParams);

            string k = XMLCleaner(oCopiedLC.ToXMLString(), oCopiedLC.LandedCostNumber + "", oCopiedLC.DocEntry + "");

            oLandedCost.FromXMLString(k);
            //Adding Costs
            LandedCost_CostLine oLandedCost_CostLine = oLandedCost.LandedCost_CostLines.Add();

            oLandedCost_CostLine.LandedCostCode = "TI";
            oLandedCost_CostLine.amount         = 10;


            LandedService.AddLandedCost(oLandedCost);
        }
Пример #6
0
        //Consulta em tabela customizada por objeto, passar nome da tabela e coleção de parâmetros(Nome do campo e valor)
        protected GeneralData Consultar(string nomeObjeto, Dictionary <string, string> parametros)
        {
            oGeneralData = null;

            try
            {
                if (!String.IsNullOrEmpty(nomeObjeto) && parametros != null)
                {
                    oCompService    = oCompany.GetCompanyService();
                    oGeneralService = oCompService.GetGeneralService(nomeObjeto);
                    oGeneralParams  = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));

                    if (parametros != null && parametros.Count > 0)
                    {
                        foreach (var item in parametros)
                        {
                            oGeneralParams.SetProperty(item.Key.ToString(), item.Value);
                        }

                        oGeneralData = oGeneralService.GetByParams(oGeneralParams);
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(oGeneralData);
        }
Пример #7
0
        //Inclusão em tabela customizada por objeto, passar nome da tabela e coleção de parâmetros(Nome do campo e valor)
        protected void Incluir(string nomeObjeto, Dictionary <string, string> parametros)
        {
            try
            {
                oCompService = oCompany.GetCompanyService();
                oCompany.StartTransaction();
                oGeneralService = oCompService.GetGeneralService(nomeObjeto);

                oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                if (parametros != null && parametros.Count > 0)
                {
                    foreach (var item in parametros)
                    {
                        oGeneralData.SetProperty(item.Key.ToString(), item.Value.ToString());
                    }

                    oGeneralService.Add(oGeneralData);
                }

                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                }
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                }

                throw e;
            }
        }
Пример #8
0
        public IHttpActionResult UpdateItem(Authorizations authorizations)
        {
            //Inicializo mi conexión a SAP
            SAPConnection conncetion = new SAPConnection();

            SAPbobsCOM.Company company = conncetion.OpenConnection();

            SAPbobsCOM.CompanyService          oCompanyService = company.GetCompanyService();
            SAPbobsCOM.ApprovalRequestsService approvalSrv     = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService);
            ApprovalRequestParams oParams = approvalSrv.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams) as ApprovalRequestParams;

            oParams.Code = authorizations.WddCode;
            ApprovalRequest oData = approvalSrv.GetApprovalRequest(oParams);

            //Agregar una autorización
            oData.ApprovalRequestDecisions.Add();
            oData.ApprovalRequestDecisions.Item(0).ApproverUserName = "******";
            oData.ApprovalRequestDecisions.Item(0).ApproverPassword = "******";
            oData.ApprovalRequestDecisions.Item(0).Status           = BoApprovalRequestDecisionEnum.ardApproved;
            oData.ApprovalRequestDecisions.Item(0).Remarks          = authorizations.Remarks;

            //Actualizar la autorización
            approvalSrv.UpdateRequest(oData);
            return(Ok(responseCall));
        }
Пример #9
0
        private static void updateLandedCost()
        {
            SAPbobsCOM.Company        oCompany        = Application.SBO_Application.Company.GetDICompany() as SAPbobsCOM.Company;
            SAPbobsCOM.CompanyService oCompanyService = oCompany.GetCompanyService() as SAPbobsCOM.CompanyService;
            LandedCostsService        LandedService   = oCompanyService.GetBusinessService(ServiceTypes.LandedCostsService) as LandedCostsService;

            LandedCostParams oLandedCostUpdateParams = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCostParams) as LandedCostParams;
            LandedCost       oLandedCostUpdate       = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCost) as LandedCost;

            oLandedCostUpdateParams.LandedCostNumber = 10;
            //LandedService.CancelLandedCost(oLandedCostUpdateParams);
            oLandedCostUpdate = LandedService.GetLandedCost(oLandedCostUpdateParams);

            // oLandedCostUpdate.LandedCost_ItemLines.Remove(0);
            // LandedCost_ItemLine oLandedCost_ItemLine;
            //oLandedCost_ItemLine = oLandedCostUpdate.LandedCost_ItemLines.Add();
            //oLandedCost_ItemLine.BaseDocumentType = LandedCostBaseDocumentTypeEnum.asGoodsReceiptPO;
            //oLandedCost_ItemLine.BaseEntry = 521;
            //oLandedCost_ItemLine.BaseLine = 1;


            ////LandedCost_CostLine oLandedCostUpdate_CostLine = oLandedCostUpdate.LandedCost_CostLines.Add();
            ////oLandedCostUpdate_CostLine.LandedCostCode = "CM";
            ////oLandedCostUpdate_CostLine.amount = 11;
            //LandedService.UpdateLandedCost(oLandedCostUpdate);
        }
Пример #10
0
        public IHttpActionResult UpdateItems([FromBody] Authorizations authorizations)
        {
            //Inicializo mi conexión a SAP
            SAPConnection conncetion = new SAPConnection();

            SAPbobsCOM.Company company = conncetion.OpenConnection(authorizations.dbname, authorizations.userSap, authorizations.userSapPass);

            SAPbobsCOM.CompanyService          oCompanyService = company.GetCompanyService();
            SAPbobsCOM.ApprovalRequestsService approvalSrv     = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService);
            ApprovalRequestParams oParams = approvalSrv.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams) as ApprovalRequestParams;

            oParams.Code = authorizations.WddCode;
            ApprovalRequest oData = approvalSrv.GetApprovalRequest(oParams);

            //Agregar una autorización
            oData.ApprovalRequestDecisions.Add();
            oData.ApprovalRequestDecisions.Item(0).ApproverUserName = authorizations.userSap;
            oData.ApprovalRequestDecisions.Item(0).ApproverPassword = authorizations.userSapPass;
            //Autorizar
            if (authorizations.Status == "Y")
            {
                oData.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestDecisionEnum.ardApproved;
            }
            else
            if (authorizations.Status == "N")
            {
                oData.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestDecisionEnum.ardNotApproved;
            }
            oData.ApprovalRequestDecisions.Item(0).Remarks = authorizations.Remarks;

            //Actualizar la autorización
            approvalSrv.UpdateRequest(oData);
            return(Ok(authorizations));
        }
Пример #11
0
        /// <summary> Updates the given pObjRecord. </summary>
        /// <remarks> Ranaya, 26/05/2017. </remarks>
        /// <exception cref="TableException"> Thrown when a Table error condition occurs. </exception>
        /// <param name="pObjRecord"> The object record. </param>

        public void Update(T pObjRecord)
        {
            SAPbobsCOM.GeneralService    lObjGeneralService    = null;
            SAPbobsCOM.GeneralData       lObjGeneralData       = null;
            SAPbobsCOM.GeneralDataParams lObjGeneralDataParams = null;
            SAPbobsCOM.CompanyService    lObjCompanyService    = null;

            try
            {
                //Initialize variables
                lObjCompanyService    = DIApplication.Company.GetCompanyService();
                lObjGeneralService    = lObjCompanyService.GetGeneralService(GetObjectCode());
                lObjGeneralDataParams = ((SAPbobsCOM.GeneralDataParams)(lObjGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));

                //Get current data by params
                lObjGeneralDataParams.SetProperty("DocEntry", pObjRecord.GetKey());
                lObjGeneralData = lObjGeneralService.GetByParams(lObjGeneralDataParams);

                //Set new data
                lObjGeneralData = PopulateGeneralData(lObjGeneralData, pObjRecord);

                //Update data
                lObjGeneralService.Update(lObjGeneralData);
            }
            catch (Exception e)
            {
                throw new TableException(e.Message, e);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjGeneralService, lObjGeneralData, lObjGeneralDataParams, lObjCompanyService);
            }
        }
Пример #12
0
        //private void button3_Click(object sender, EventArgs e)
        //{

        //}

        private void button3_Click(object sender, EventArgs e)
        {
            StreamReader rd    = new StreamReader(@txtCaminho.Text);
            string       Linha = null;

            string[] linhaseparada = null;


            if (GlobalConection.oCompany.Connected)

            {
                try

                {
                    oCS  = GlobalConection.oCompany.GetCompanyService();
                    oICS = oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryCountingsService);
                    oIC  = oICS.GetDataInterface(SAPbobsCOM.InventoryCountingsServiceDataInterfaces.icsInventoryCounting);


                    while ((Linha = rd.ReadLine()) != null)

                    {
                        linhaseparada = Linha.Split(';');
                        oIC.CountDate = DateTime.Now;

                        oICLS = oIC.InventoryCountingLines;
                        oICL  = oICLS.Add();

                        oICL.ItemCode        = linhaseparada[0]; //"998";
                        oICL.WarehouseCode   = linhaseparada[1]; //"01";
                        oICL.CountedQuantity = 2;
                        oICL.Counted         = BoYesNoEnum.tYES;

                        oICP = oICS.Add(oIC);

                        int Docentry = oICP.DocumentEntry;
                    }


                    MessageBox.Show("Contagem de Estoque realizada com sucesso");
                }
                catch (Exception ex)

                {
                    string msg = ex.Message;

                    MessageBox.Show("ERRO" + msg);
                }
            }
            else
            {
                MessageBox.Show("Contagem Não Realizada");
            }
        }
Пример #13
0
        public static bool addupdTransactionCode(string TransCode, string TransCodeDescription)
        {
            bool blResult = false;

            SAPbobsCOM.TransactionCodesService objTransCodeService = null;
            SAPbobsCOM.CompanyService          objCompanyService   = null;
            SAPbobsCOM.TransactionCodeParams   objParamas          = null;
            SAPbobsCOM.TransactionCode         objTransCode        = null;



            try
            {
                objCompanyService        = MainObject.Instance.B1Company.GetCompanyService();
                objTransCodeService      = objCompanyService.GetBusinessService(ServiceTypes.TransactionCodesService);
                objParamas               = objTransCodeService.GetDataInterface(TransactionCodesServiceDataInterfaces.tcsTransactionCodeParams);
                objParamas.Code          = TransCode;
                objTransCode             = objTransCodeService.Get(objParamas);
                objTransCode.Description = TransCodeDescription;
                objTransCodeService.Update(objTransCode);
            }
            catch (COMException comEx)
            {
                if (comEx.ErrorCode == -2028)
                {
                    objTransCode             = objTransCodeService.GetDataInterface(TransactionCodesServiceDataInterfaces.tcsTransactionCode);
                    objTransCode.Code        = TransCode;
                    objTransCode.Description = TransCodeDescription;
                    try
                    {
                        objParamas = objTransCodeService.Add(objTransCode);
                    }
                    catch (COMException comE)
                    {
                        _Logger.Error("", comE);
                    }
                    catch (Exception er)
                    {
                        _Logger.Error("", er);
                    }
                }
                else
                {
                    _Logger.Error("", comEx);
                }
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }


            return(blResult);
        }
Пример #14
0
        //Consulta o o último Id por objeto na tabela customizada
        protected int ConsultarUltimoId(string nomeObjeto)
        {
            int ultimo = 0;

            try
            {
                oCompService    = oCompany.GetCompanyService();
                oGeneralService = oCompService.GetGeneralService(nomeObjeto);

                try
                {
                    oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);
                    GeneralCollectionParams oGeneralCol = oGeneralService.GetList();

                    List <int> lista = new List <int>();

                    foreach (GeneralDataParams item in oGeneralCol)
                    {
                        string aux = item.GetProperty("Code").ToString();
                        if (aux != "*")
                        {
                            lista.Add(Convert.ToInt32(aux));
                        }
                    }

                    lista.Sort();
                    ultimo = lista.Last();
                }
                catch (Exception e)
                {
                    //Não existe registro no BD
                    if (e.HResult == -2028)
                    {
                        return(ultimo);
                    }
                    //Registro Duplicado
                    else if (e.HResult == -2035)
                    {
                        throw e;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(ultimo);
        }
Пример #15
0
        public void getDimensionsList()
        {
            List <dimensionInfo> objResult = null;

            SAPbobsCOM.CompanyService    objCmpService         = null;
            SAPbobsCOM.DimensionsService objPDimensionsService = null;
            SAPbobsCOM.DimensionsParams  objDimensionsList     = null;
            SAPbobsCOM.DimensionParams   objDimensionInfo      = null;


            try
            {
                objResult             = new List <dimensionInfo>();
                objCmpService         = MainObject.Instance.B1Company.GetCompanyService();
                objPDimensionsService = objCmpService.GetBusinessService(SAPbobsCOM.ServiceTypes.DimensionsService);
                objDimensionsList     = objPDimensionsService.GetDimensionList();
                for (int i = 0; i < objDimensionsList.Count; i++)
                {
                    objDimensionInfo = objDimensionsList.Item(i);
                    SAPbobsCOM.DimensionParams objTemp = objPDimensionsService.GetDataInterface(SAPbobsCOM.DimensionsServiceDataInterfaces.dsDimensionParams);
                    objTemp.DimensionCode = objDimensionInfo.DimensionCode;
                    SAPbobsCOM.Dimension objDimensions = objPDimensionsService.GetDimension(objTemp);
                    dimensionInfo        oDImension    = new dimensionInfo();
                    oDImension.DimentionCode = objDimensions.DimensionCode;
                    oDImension.DimensionName = objDimensions.DimensionDescription;
                    oDImension.isActive      = objDimensions.IsActive == SAPbobsCOM.BoYesNoEnum.tYES ? true : false;

                    //oDImension.DimensionLevel = objDimensions..InWhichDimension;


                    objResult.Add(oDImension);
                }
            }
            catch (COMException comEx)
            {
                _Logger.Error("", comEx);
                objResult = new List <dimensionInfo>();
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
                objResult = new List <dimensionInfo>();
            }
            finally
            {
                CacheManager.CacheManager.Instance.addToCache("DimensionList", objResult, CacheManager.CacheManager.objCachePriority.NotRemovable);
            }
        }
Пример #16
0
        public void getProfitCenterList()
        {
            List <costCenterInfo> objResult = null;

            SAPbobsCOM.CompanyService       objCmpService          = null;
            SAPbobsCOM.ProfitCentersService objProfitCenterService = null;
            SAPbobsCOM.ProfitCentersParams  objProfitCenterList    = null;
            SAPbobsCOM.ProfitCenterParams   objProfitCenterInfo    = null;


            try
            {
                objResult              = new List <costCenterInfo>();
                objCmpService          = MainObject.Instance.B1Company.GetCompanyService();
                objProfitCenterService = objCmpService.GetBusinessService(SAPbobsCOM.ServiceTypes.ProfitCentersService);
                objProfitCenterList    = objProfitCenterService.GetProfitCenterList();
                for (int i = 0; i < objProfitCenterList.Count; i++)
                {
                    objProfitCenterInfo = objProfitCenterList.Item(i);
                    SAPbobsCOM.ProfitCenterParams objTemp = objProfitCenterService.GetDataInterface(SAPbobsCOM.ProfitCentersServiceDataInterfaces.pcsProfitCenterParams);
                    objTemp.CenterCode = objProfitCenterInfo.CenterCode;
                    SAPbobsCOM.ProfitCenter objProfitCenter = objProfitCenterService.GetProfitCenter(objTemp);
                    costCenterInfo          oProfit         = new costCenterInfo();
                    oProfit.CostCenterCode = objProfitCenter.CenterCode;
                    oProfit.CostCenterName = objProfitCenter.CenterName;
                    oProfit.DimensionCode  = objProfitCenter.InWhichDimension;


                    objResult.Add(oProfit);
                }
            }
            catch (COMException comEx)
            {
                _Logger.Error("", comEx);
                objResult = new List <costCenterInfo>();
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
                objResult = new List <costCenterInfo>();
            }
            finally
            {
                CacheManager.CacheManager.Instance.addToCache("ProfitCenterList", objResult, CacheManager.CacheManager.objCachePriority.NotRemovable);
            }
        }
Пример #17
0
        private static void testLandedCost()
        {
            SAPbobsCOM.Company        oCompany        = Application.SBO_Application.Company.GetDICompany() as SAPbobsCOM.Company;
            SAPbobsCOM.CompanyService oCompanyService = oCompany.GetCompanyService() as SAPbobsCOM.CompanyService;
            LandedCostsService        LandedService   = oCompanyService.GetBusinessService(ServiceTypes.LandedCostsService) as LandedCostsService;
            LandedCost       oLandedCost     = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCost) as LandedCost;
            LandedCostParams oCopiedLCParams = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCostParams) as LandedCostParams;

            oCopiedLCParams.LandedCostNumber = 13;
            LandedCost oCopiedLC = LandedService.GetDataInterface(LandedCostsServiceDataInterfaces.lcsLandedCost) as LandedCost;

            oCopiedLC = LandedService.GetLandedCost(oCopiedLCParams);
            //Testing
            int  total_lineNum    = oCopiedLC.LandedCost_ItemLines.Count;
            long oLandedCostEntry = 0;//Try 10
            int  GRPOEntry        = 2474;

            //Adding Items
            for (int i = 0; i < 2; i++)
            {
                LandedCost_ItemLine oLandedCost_ItemLine = oLandedCost.LandedCost_ItemLines.Add();
                oLandedCost_ItemLine.BaseDocumentType = LandedCostBaseDocumentTypeEnum.asPurchaseInvoice;
                oLandedCost_ItemLine.BaseEntry        = GRPOEntry;
                oLandedCost_ItemLine.BaseLine         = i;
            }

            //Adding Costs
            LandedCost_CostLine oLandedCost_CostLine = oLandedCost.LandedCost_CostLines.Add();

            oLandedCost_CostLine.LandedCostCode = "CD";
            oLandedCost_CostLine.amount         = 99;
            //Extra Cost
            oLandedCost_CostLine = oLandedCost.LandedCost_CostLines.Add();
            oLandedCost_CostLine.LandedCostCode = "CM";
            oLandedCost_CostLine.amount         = 150;



            LandedCostParams oLandedCostParams;

            oLandedCostParams = LandedService.AddLandedCost(oLandedCost);
            oLandedCostEntry  = oLandedCostParams.LandedCostNumber;
        }
Пример #18
0
        public IHttpActionResult AutorizacionesMasivas([FromBody] AuthorizationsM authorizationsm)
        {
            //return Ok (authorizationsm.WddCode[1]);
            //Inicializo mi conexión a SAP
            SAPConnection conncetion = new SAPConnection();

            SAPbobsCOM.Company company = conncetion.OpenConnection(authorizationsm.dbname, authorizationsm.userSap, authorizationsm.userSapPass);

            SAPbobsCOM.CompanyService          oCompanyService = company.GetCompanyService();
            SAPbobsCOM.ApprovalRequestsService approvalSrv     = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService);
            ApprovalRequestParams oParams = approvalSrv.GetDataInterface(ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams) as ApprovalRequestParams;

            for (int i = 0; i < authorizationsm.WddCode.Length; i++)
            {
                oParams.Code = authorizationsm.WddCode[i];
                ApprovalRequest oData = approvalSrv.GetApprovalRequest(oParams);

                //Agregar una autorización
                oData.ApprovalRequestDecisions.Add();
                oData.ApprovalRequestDecisions.Item(0).ApproverUserName = authorizationsm.userSap;
                oData.ApprovalRequestDecisions.Item(0).ApproverPassword = authorizationsm.userSapPass;
                //Autorizar
                if (authorizationsm.Status == "Y")
                {
                    oData.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestDecisionEnum.ardApproved;
                }
                else
                if (authorizationsm.Status == "N")
                {
                    oData.ApprovalRequestDecisions.Item(0).Status = BoApprovalRequestDecisionEnum.ardNotApproved;
                }
                oData.ApprovalRequestDecisions.Item(0).Remarks = authorizationsm.Remarks;
                //Actualizar la autorización

                approvalSrv.UpdateRequest(oData);
            }

            return(Ok(responseCall));
            //return Json(new { status = "error", message = "error creating customer" });
        }
        public static string UpdateRecordHead(string UDO_Name, Object Objeto, string CodigoObj)
        {
            SAPbobsCOM.GeneralService    oGeneralService = null;
            SAPbobsCOM.GeneralData       oGeneralData    = null;
            SAPbobsCOM.GeneralDataParams oGeneralParams  = null;
            SAPbobsCOM.CompanyService    sCmp            = null;
            SAPbobsCOM.Company           SBO_Company     = Conexion.oCompany;

            sCmp = SBO_Company.GetCompanyService();
            string rpta = "N";

            //  This function updates only parent record.
            //  Child records remain as is.
            try
            {
                // Get a handle UDO
                oGeneralService = sCmp.GetGeneralService(UDO_Name);
                // Get UDO record
                oGeneralParams = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));
                oGeneralParams.SetProperty("Code", CodigoObj);
                oGeneralData = oGeneralService.GetByParams(oGeneralParams);
                // Update UDO record
                foreach (PropertyInfo propiedad in Objeto.GetType().GetProperties())
                {
                    try
                    {
                        string tipoPropiedad   = propiedad.PropertyType.Name;
                        string NombrePropiedad = propiedad.Name;
                        var    valorPropiedad  = propiedad.GetValue(Objeto, null);
                        oGeneralData.SetProperty(NombrePropiedad, valorPropiedad);
                    }
                    catch (Exception) { }
                }
                oGeneralService.Update(oGeneralData);
                rpta = "S";
            }
            catch (Exception) { }
            return(rpta);
        }
Пример #20
0
        public static void getProjectList()
        {
            List <projectInfo> objResult = null;

            SAPbobsCOM.CompanyService  objCmpService     = null;
            SAPbobsCOM.ProjectsService objProjectService = null;
            SAPbobsCOM.ProjectsParams  objProjectList    = null;
            SAPbobsCOM.ProjectParams   objProjectInfo    = null;

            try
            {
                objResult         = new List <projectInfo>();
                objCmpService     = MainObject.Instance.B1Company.GetCompanyService();
                objProjectService = objCmpService.GetBusinessService(SAPbobsCOM.ServiceTypes.ProjectsService);
                objProjectList    = objProjectService.GetProjectList();
                for (int i = 0; i < objProjectList.Count; i++)
                {
                    objProjectInfo = objProjectList.Item(i);
                    projectInfo oProj = new projectInfo();
                    oProj.ProjectCode = objProjectInfo.Code;
                    oProj.ProjectName = objProjectInfo.Name;
                    objResult.Add(oProj);
                }
            }
            catch (COMException comEx)
            {
                _Logger.Error("", comEx);
                objResult = new List <projectInfo>();
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
                objResult = new List <projectInfo>();
            }
            finally
            {
                CacheManager.CacheManager.Instance.addToCache("ProjectList", objResult, CacheManager.CacheManager.objCachePriority.NotRemovable);
            }
        }
Пример #21
0
        //Exclusão em tabela customizada por objeto, passar nome da tabela e parâmetros(Nome do campo e valor)
        protected bool Excluir(string nomeObjeto, KeyValuePair <string, string> parametro)
        {
            bool retorno = false;

            try
            {
                oCompService    = oCompany.GetCompanyService();
                oGeneralService = oCompService.GetGeneralService(nomeObjeto);
                oGeneralParams  = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));

                if (parametro.Key != null && parametro.Value != null)
                {
                    oGeneralParams.SetProperty(parametro.Key, parametro.Value);
                    oGeneralService.Delete(oGeneralParams);
                    retorno = true;
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(retorno);
        }
        public bool InsertMonitoring(MonitoringEntity monitoring)
        {
            bool success = false;

            try
            {
                oCompService = oCompany.GetCompanyService();
                oCompany.StartTransaction();
                oGeneralService = oCompService.GetGeneralService("UD_INT_MONITORING");

                oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                oGeneralData.SetProperty("Code", monitoring.DocCode);

                oGeneralData.SetProperty("U_SketchInv", monitoring.Sketch_Invoice);

                oGeneralData.SetProperty("U_DocDate", DateTime.Now.ToString("yyyyMMdd"));

                oGeneralData.SetProperty("U_DocTotal", monitoring.DocTot);

                if (monitoring.BL != null)
                {
                    oGeneralData.SetProperty("U_Bl", monitoring.BL);
                }

                if (monitoring.BLId != null)
                {
                    oGeneralData.SetProperty("U_BlId", monitoring.BLId);
                }

                if (monitoring.Draft != null)
                {
                    oGeneralData.SetProperty("U_Draft", monitoring.Draft);
                }

                if (monitoring.Branch != null)
                {
                    oGeneralData.SetProperty("U_Branch", monitoring.Branch);
                }

                if (monitoring.BranchId != null)
                {
                    oGeneralData.SetProperty("U_BranchId", monitoring.BranchId);
                }

                oGeneralData.SetProperty("U_StatusId", monitoring.StatusId);
                oGeneralData.SetProperty("U_Status", monitoring.Status);

                oGeneralData.SetProperty("U_XMLPath", monitoring.XMLPath);
                oGeneralData.SetProperty("U_Message", monitoring.Message);

                oGeneralService.Add(oGeneralData);
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                }

                LogDAL _log = new LogDAL();
                _log.WriteEntry("InsertMonitoring error: " + e.Message);

                throw e;
            }
            if (oCompany.InTransaction)
            {
                oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
            }
            return(success);
        }
        private void InsertDate_AfterAddBtnPressed(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            try
            {
                __Form = __app.Forms.GetForm(pVal.FormTypeEx, pVal.FormTypeCount);

                oRs   = (SAPbobsCOM.Recordset)____bobCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oRs1  = (SAPbobsCOM.Recordset)____bobCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oGrid = __Form.Items.Item("grid").Specific;

                int Progress = 0;
                SAPbouiCOM.ProgressBar oProgressBar = null;
                oProgressBar = __app.StatusBar.CreateProgressBar("Updating History ", Htable.Rows.Count, true);

                #region UpdateHistoryTable
                for (int i = 0; i < Htable.Rows.Count; i++)
                {
                    try
                    {
                        int    DocEntry        = int.Parse(Htable.Rows[i][0].ToString()); //oGrid.DataTable.GetValue("DocEntry", i);
                        string CollectionNotes = Htable.Rows[i][1].ToString();            //oGrid.DataTable.GetValue("As Collection Notes", i);

                        oProgressBar.Text  = "Updating History " + i + " rows...";
                        Progress          += 1;
                        oProgressBar.Value = Progress;

                        if (!string.IsNullOrEmpty(CollectionNotes))
                        {
                            SAPbobsCOM.GeneralService        oGeneralService;
                            SAPbobsCOM.GeneralData           oGeneralData;
                            SAPbobsCOM.CompanyService        sCmp = null;
                            SAPbobsCOM.GeneralData           oChild;
                            SAPbobsCOM.GeneralDataCollection oChildren;
                            SAPbobsCOM.GeneralDataParams     oGeneralParams;

                            sCmp = ____bobCompany.GetCompanyService();

                            oGeneralService = sCmp.GetGeneralService("UDOB1CZHDR");
                            oGeneralData    = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                            string SqlQry = "";
                            SqlQry = "SELECT \"Code\" FROM \"@AW_B1CZHDR\" Where \"U_DocEntry\"=" + DocEntry;
                            oRs.DoQuery(SqlQry);

                            if (oRs.RecordCount > 0)
                            {
                                ____bobCompany.StartTransaction();
                                string SqlCode = "";
                                SqlCode = "SELECT T0.\"Code\",T1.\"U_AsColNotes\",T1.\"U_UpdateDate\"  FROM \"@AW_B1CZHDR\" T0 INNER JOIN \"@AW_B1CZDTL\" T1 ON T1.\"U_DocEntry\"=T0.\"U_DocEntry\" and T0.\"Code\"=T1.\"Code\" " +
                                          " Where T0.\"U_DocEntry\"=" + DocEntry;
                                oRs1.DoQuery(SqlCode);

                                oGeneralData.SetProperty("Code", Convert.ToString(oRs1.Fields.Item("Code").Value));
                                oGeneralData.SetProperty("Name", Convert.ToString(oRs.Fields.Item("Code").Value));
                                oGeneralData.SetProperty("U_DocEntry", DocEntry);


                                oChildren = oGeneralData.Child("AW_B1CZDTL");

                                for (int j = 0; j < oRs1.RecordCount; j++)
                                {
                                    oChild = oChildren.Add();
                                    oChild.SetProperty("U_DocEntry", DocEntry);
                                    oChild.SetProperty("U_AsColNotes", oRs1.Fields.Item("U_AsColNotes").Value);
                                    oChild.SetProperty("U_UpdateDate", oRs1.Fields.Item("U_UpdateDate").Value);
                                    oRs1.MoveNext();
                                }

                                oChild = oChildren.Add();
                                oChild.SetProperty("U_DocEntry", DocEntry);
                                oChild.SetProperty("U_AsColNotes", CollectionNotes);
                                oChild.SetProperty("U_UpdateDate", DateTime.Now);

                                oGeneralService.Update(oGeneralData);
                                if (____bobCompany.InTransaction)
                                {
                                    ____bobCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                                }
                            }
                            else
                            {
                                ____bobCompany.StartTransaction();
                                string SqlCode = "";
                                SqlCode = "SELECT IFNULL(MAX((CAST(\"Code\" AS int))),0)+1 \"MaxCode\",IFNULL(MAX((CAST(\"DocEntry\" AS int))),0)+1 \"MaxDocEntry\" FROM \"@AW_B1CZHDR\"";
                                oRs.DoQuery(SqlCode);

                                oGeneralData.SetProperty("Code", Convert.ToString(oRs.Fields.Item("MaxCode").Value));
                                oGeneralData.SetProperty("Name", Convert.ToString(oRs.Fields.Item("MaxCode").Value));
                                oGeneralData.SetProperty("U_DocEntry", DocEntry);

                                oChildren = oGeneralData.Child("AW_B1CZDTL");
                                oChild    = oChildren.Add();
                                oChild.SetProperty("U_DocEntry", DocEntry);
                                oChild.SetProperty("U_AsColNotes", CollectionNotes);
                                oChild.SetProperty("U_UpdateDate", DateTime.Now.Date);

                                oGeneralService.Add(oGeneralData);
                                if (____bobCompany.InTransaction)
                                {
                                    ____bobCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                oProgressBar.Stop();
                Htable.Clear();
                DT.Clear();
                DT = null;
                #endregion

                string CardCode = __Form.Items.Item("Item_0").Specific.Value;

                string SqlDoc = "";
                if (!string.IsNullOrEmpty(CardCode))
                {
                    SqlDoc = "CALL AGING_REPORT ('" + CardCode + "')";
                }
                else
                {
                    SqlDoc = "CALL AGING_REPORT (NULL)";
                }
                oRs.DoQuery(SqlDoc);

                if (oRs.RecordCount > 0)
                {
                    if (DT == null)
                    {
                        DT = __Form.DataSources.DataTables.Add("DT1" + DateTime.Now.Second);
                    }

                    DT.ExecuteQuery(SqlDoc);

                    oGrid.DataTable = DT;
                    oGrid.AutoResizeColumns();

                    oGrid.Columns.Item("Customer Code").Editable = false;
                    oGrid.Columns.Item("Customer Name").Editable = false;

                    oGrid.Columns.Item("Customer Name").Editable = false;
                    oGrid.Columns.Item("Type").Editable          = false;
                    SAPbouiCOM.EditTextColumn Typcol = (SAPbouiCOM.EditTextColumn)oGrid.Columns.Item("DocEntry");
                    Typcol.LinkedObjectType = "13";
                    oGrid.Columns.Item("TransType").Visible          = false;
                    oGrid.Columns.Item("DocEntry").Editable          = false;
                    oGrid.Columns.Item("Document No.").Editable      = false;
                    oGrid.Columns.Item("Customer Ref. No.").Editable = false;
                    oGrid.Columns.Item("Posting Date").Editable      = false;
                    oGrid.Columns.Item("Due Date").Editable          = false;
                    oGrid.Columns.Item("Future").Editable            = false;
                    oGrid.Columns.Item("0-30 Days").Editable         = false;
                    oGrid.Columns.Item("31-60 Days").Editable        = false;
                    oGrid.Columns.Item("61-90 Days").Editable        = false;
                    oGrid.Columns.Item("91-120 Days").Editable       = false;
                    oGrid.Columns.Item("121+ Days").Editable         = false;

                    SAPbouiCOM.EditTextColumn col = (SAPbouiCOM.EditTextColumn)oGrid.Columns.Item("AWDocEntry");
                    col.LinkedObjectType = "UDOB1CZHDR";
                    col.Width            = 15;

                    oGrid.Columns.Item("DocEntry").Editable    = false;
                    oGrid.Columns.Item("Balance Due").Editable = false;
                    oGrid.Columns.Item("Previous Collection Notes").Editable = false;

                    oGrid.CollapseLevel = 1;
                }
            }
            catch (SqlException e)
            {
                __app.MessageBox(e.Message, 1, "Ok", "", "");
                BubbleEvent = false;
            }
            catch (COMException e)
            {
                __app.MessageBox(e.Message, 1, "Ok", "", "");
                BubbleEvent = false;
            }
            catch (Exception e)
            {
                __app.MessageBox(e.Message, 1, "Ok", "", "");
                BubbleEvent = false;
            }
        }