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);
        }
Example #2
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);
            }
        }
Example #3
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);
            }
        }
Example #4
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);
            }
        }
Example #5
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);
        }
Example #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);
        }
        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);
        }
Example #8
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);
        }