Esempio n. 1
0
        /// <summary>
        /// Return an UDO data by an providerd param. Eg.: GetDataByKey("Code", "A0001")
        /// </summary>
        /// <param name="paramName">Name of the field to find the data</param>
        /// <param name="paramValue">Value of the field to find the data</param>
        /// <returns>Return a SAPbobsCOM.GeneralData find in values provided</returns>
        public GeneralData GetDataByKey(string paramName, object paramValue)
        {
            var generalParams = GetDataInterface <GeneralDataParams>(GeneralServiceDataInterfaces.gsGeneralDataParams);

            generalParams.SetProperty(paramName, paramValue);
            return(_generalService.GetByParams(generalParams));
        }
Esempio n. 2
0
        public static GeneralData getUDOInfo(object objKey, string UDOName)
        {
            GeneralData       objResult         = null;
            CompanyService    objCompanyService = null;
            GeneralService    UDOService        = null;
            GeneralDataParams getInfo           = null;

            try
            {
                objCompanyService = MainObject.Instance.B1Company.GetCompanyService();
                UDOService        = objCompanyService.GetGeneralService(UDOName);
                foreach (var prop in objKey.GetType().GetProperties())
                {
                    getInfo.SetProperty(prop.Name, prop.GetValue(objKey, null));
                }
                objResult = UDOService.GetByParams(getInfo);
            }
            catch (COMException comEx)
            {
                _Logger.Error("", comEx);
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
            return(objResult);
        }
Esempio n. 3
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);
        }
Esempio n. 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);
        }
Esempio n. 5
0
        /// <summary>
        /// Actualiza los datos de un motivo de rechazo determinado
        /// </summary>
        /// <param name="comp"></param>
        /// <param name="estadoCertificadoRecibido"></param>
        /// <returns></returns>
        public bool Actualizar(EstadoCertificadoRecibido estadoCertificadoRecibido)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFEESTCFER");

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", estadoCertificadoRecibido.DocEntry);

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                //Establecer los valores para las propiedades
                dataGeneral.SetProperty("U_Motivo", estadoCertificadoRecibido.Motivo);
                dataGeneral.SetProperty("U_Glosa", estadoCertificadoRecibido.Glosa);
                dataGeneral.SetProperty("U_Detalle", estadoCertificadoRecibido.Detalle);
                dataGeneral.SetProperty("U_ConsRec", estadoCertificadoRecibido.IdConsecutivo);

                //Agregar el nuevo registro a la base de datos mediante el serivicio general
                servicioGeneral.Update(dataGeneral);

                resultado = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (parametros != null)
                {
                    //Liberar memoria utlizada por objeto parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
Esempio n. 6
0
        /// <summary>
        /// Actualiza los datos de un tipo de documento a conservar determinado
        /// </summary>
        /// <param name="comp"></param>
        /// <param name="cae"></param>
        /// <param name="numeroRegistro"></param>
        /// <returns></returns>
        public bool Actualizar(CAE cae, string numeroRegistro)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFETDCON");

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", numeroRegistro);

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                //Establecer los valores para las propiedades
                dataGeneral.SetProperty("U_TipoDoc", ((int)cae.TipoCFE).ToString());
                dataGeneral.SetProperty("U_NombDoc", cae.NombreDocumento);
                dataGeneral.SetProperty("U_IndCon", cae.IndicadorConservar);

                //Agregar el nuevo registro a la base de datos mediante el serivicio general
                servicioGeneral.Update(dataGeneral);

                resultado = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (parametros != null)
                {
                    //Liberar memoria utlizada por el objeto parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
Esempio n. 7
0
        /// <summary>
        /// Actualiza los datos del emisor de factura electronica en la base de datos
        /// </summary>
        /// <param name="comp"></param>
        /// <param name="emisor"></param>
        /// <returns></returns>
        public bool Actualizar(Emisor emisor)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFEEMI");

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", 1);

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                dataGeneral.SetProperty("U_Ruc", emisor.Ruc.ToString());
                dataGeneral.SetProperty("U_Nombre", emisor.Nombre);
                dataGeneral.SetProperty("U_NombreC", emisor.NombreComercial);
                dataGeneral.SetProperty("U_NumRes", emisor.NumeroResolucion);

                //Agregar el nuevo registro a la base de datos mediante el servicio general
                servicioGeneral.Update(dataGeneral);

                resultado = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (parametros != null)
                {
                    //Liberar memoria utlizada por el objeto parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
        /// <summary>
        /// Metodo para actualizar los datos de correo electronico
        /// </summary>
        /// <param name="comp"></param>
        /// <returns></returns>
        private bool actualizarCorreoElectronico(Correo correo, string entry)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTECA");

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", entry);

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                //Establecer los valores para las propiedades
                dataGeneral.SetProperty("U_Correo", correo.Cuenta);
                dataGeneral.SetProperty("U_Clave", correo.Clave);
                dataGeneral.SetProperty("U_Opcion", correo.Opcion);

                //Agregar el nuevo registro a la base de datos mediante el servicio general
                servicioGeneral.Update(dataGeneral);

                resultado = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (parametros != null)
                {
                    //Liberar memoria utlizada por parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
Esempio n. 9
0
        /// <summary>
        /// Actualiza la configuracion de ejecucion del reporte diario
        /// </summary>
        /// <param name="confRptd"></param>
        /// <returns></returns>
        private bool Actualizar(ConfRptd confRptd, string docEntry)
        {
            bool salida = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTCRPTD");

                //Apuntar a la cabecera del udo
                dataGeneral = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);
                parametros  = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", docEntry);

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                //Establecer los valores para las propiedades
                dataGeneral.SetProperty("U_DiaE", confRptd.DiaEjecucion);
                dataGeneral.SetProperty("U_Modo", confRptd.ModoEjecucion);
                dataGeneral.SetProperty("U_SecEnv", confRptd.SecuenciaEnvio);
                dataGeneral.SetProperty("U_CAE_General", confRptd.CAEGenerico);
                dataGeneral.SetProperty("U_AutoGenerar", confRptd.AutoGenerar);
                dataGeneral.SetProperty("U_HoraEjecucion", confRptd.HoraEjec);
                dataGeneral.SetProperty("U_DiaEFinal", confRptd.DiaFin);

                //Agregar el nuevo registro a la base de datos mediante el servicio general
                servicioGeneral.Update(dataGeneral);

                salida = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }

            return(salida);
        }
Esempio n. 10
0
        /// <summary>
        /// Actualiza el idConsecutivo del sobre recibido
        /// </summary>
        /// <param name="idconsecutivo"></param>
        /// <returns></returns>
        public bool ActualizarIdConsecutivo(string idconsecutivo, string docEntry)
        {
            bool salida = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = (ProcConexion.Comp.GetCompanyService()).GetGeneralService("TTFETDCON");

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", docEntry);

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                //Establecer los valores para las propiedades
                dataGeneral.SetProperty("U_IdCons", idconsecutivo);

                //Agregar el nuevo registro a la base de datos mediante el serivicio general
                servicioGeneral.Update(dataGeneral);

                salida = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (parametros != null)
                {
                    //Liberar memoria utlizada por el objeto parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }
            return(salida);
        }
Esempio n. 11
0
        /// <summary>
        /// Actualiza el estado de los sobres
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        public bool Actualizar(ControlSobres control)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFECONSOB");

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", control.DocEntry);

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);
                dataGeneral.SetProperty("U_Estado", control.Estado);

                //Agregar el nuevo registro a la base de datos mediante el servicio general
                servicioGeneral.Update(dataGeneral);

                resultado = true;
            }
            catch (Exception ex)
            {
                SAPbouiCOM.Framework.Application.SBO_Application.MessageBox(ex.ToString());
            }
            finally
            {
                if (parametros != null)
                {
                    //Liberar memoria utlizada por el objeto parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
Esempio n. 12
0
        /// <summary>
        /// Atualiza dados no banco
        /// </summary>
        /// <param name="tableName">Nome da tabela</param>
        /// <param name="where">Condição WHRE</param>
        /// <param name="model">Model com os dados a serem atualizados</param>
        public void UpdateModel(string where)
        {
            Recordset rs = (Recordset)SBOApp.Company.GetBusinessObject(BoObjectTypes.BoRecordset);

            string sql = @"SELECT DocEntry FROM [{0}] WHERE {1}";

            sql = SBOApp.TranslateToHana(String.Format(sql, TableName, where));

            rs.DoQuery(String.Format(sql, TableName, where));
            if (rs.RecordCount > 0)
            {
                CompanyService sCompany        = SBOApp.Company.GetCompanyService();
                GeneralService oGeneralService = sCompany.GetGeneralService(TableName.Replace("@", ""));

                GeneralDataParams oGeneralParams = (GeneralDataParams)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                oGeneralParams.SetProperty("DocEntry", rs.Fields.Item(0).Value.ToString());

                GeneralData oGeneralData = oGeneralService.GetByParams(oGeneralParams);

                ModelControllerAttribute modelController;
                foreach (PropertyInfo property in Model.GetType().GetProperties())
                {
                    foreach (Attribute attribute in property.GetCustomAttributes(true))
                    {
                        modelController = attribute as ModelControllerAttribute;
                        if (modelController.DataBaseFieldYN)
                        {
                            if (String.IsNullOrEmpty(modelController.ColumnName))
                            {
                                modelController.ColumnName = property.Name;
                            }
                            oGeneralData.SetProperty(modelController.ColumnName, property.GetValue(Model, null));
                        }
                    }
                }
                oGeneralService.Update(oGeneralData);
            }

            Marshal.ReleaseComObject(rs);
            rs = null;
            GC.Collect();
        }
Esempio n. 13
0
        /// <summary>
        /// Almacena el C.I generico
        /// </summary>
        /// <param name="cIgenerico"></param>
        /// <returns></returns>
        public bool AlmacenarCI(string cIgenerico)
        {
            bool              resultado       = false;
            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                string docEntry = ConsultarCI();

                //Obtener el servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFEADOBE");

                dataGeneral = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                if (docEntry.Equals(""))
                {
                    dataGeneral.SetProperty("U_DatosCi", cIgenerico);
                    //Agregar el nuevo registro a la base de datos
                    servicioGeneral.Add(dataGeneral);
                }
                else
                {
                    //Nota: el orden importa por esa razon dataGeneral.SetProperty se repita en el if y else
                    //Obtener lista de parametros
                    parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                    //Establecer parametros
                    parametros.SetProperty("DocEntry", docEntry);

                    //Apuntar al udo que corresponde con los parametros
                    dataGeneral = servicioGeneral.GetByParams(parametros);

                    dataGeneral.SetProperty("U_DatosCi", cIgenerico);

                    //Actualiza el registro en la base de datos
                    servicioGeneral.Update(dataGeneral);
                }
                resultado = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (parametros != null)
                {
                    //Liberar memoria utlizada por parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utilizada por el objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
Esempio n. 14
0
        /// <summary>
        /// Salva o model no BD de acordo com o tipo da operação
        /// </summary>
        /// <param name="enumCrudOperation">Operação - Create ou Update</param>
        /// <param name="tableName">Nome da tabela</param>
        /// <param name="model">Modelo</param>
        private void SaveModel(EnumCrudOperation enumCrudOperation)
        {
            CompanyService sCompany        = null;
            GeneralService oGeneralService = null;
            GeneralData    oGeneralData    = null;

            try
            {
                sCompany        = SBOApp.Company.GetCompanyService();
                oGeneralService = sCompany.GetGeneralService(TableName.Replace("@", ""));
                oGeneralData    = (GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                if (enumCrudOperation == EnumCrudOperation.Update)
                {
                    GeneralDataParams oGeneralParams = (GeneralDataParams)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                    object code = null;
                    try
                    {
                        code = Model.GetType().GetProperty("Code").GetValue(Model, null);
                    }
                    catch
                    {
                        Recordset rstDocEntry = (Recordset)SBOApp.Company.GetBusinessObject(BoObjectTypes.BoRecordset);
                        string    sql         = @"SELECT DocEntry FROM {0} WHERE Code = '{1}'";
                        sql = String.Format(sql, TableName, Model.GetType().GetProperty("Code").GetValue(Model, null));
                        sql = SBOApp.TranslateToHana(sql);

                        rstDocEntry.DoQuery(sql);
                        if (rstDocEntry.RecordCount > 0)
                        {
                            code = rstDocEntry.Fields.Item(0).Value;
                        }

                        Marshal.ReleaseComObject(oGeneralParams);
                        oGeneralParams = null;

                        Marshal.ReleaseComObject(rstDocEntry);
                        rstDocEntry = null;

                        GC.Collect();
                    }

                    oGeneralParams.SetProperty("Code", code);
                    oGeneralData = oGeneralService.GetByParams(oGeneralParams);
                }

                ModelControllerAttribute modelController;
                object value;
                // Percorre as propriedades do Model
                foreach (PropertyInfo property in Model.GetType().GetProperties())
                {
                    try
                    {
                        // Busca os Custom Attributes
                        foreach (Attribute attribute in property.GetCustomAttributes(true))
                        {
                            modelController = attribute as ModelControllerAttribute;
                            if (property.GetType() != typeof(DateTime))
                            {
                                value = property.GetValue(Model, null);
                            }
                            else
                            {
                                value = ((DateTime)property.GetValue(Model, null)).ToString("yyyy-MM-dd HH:mm:ss");
                            }

                            if (modelController != null)
                            {
                                // Se não for DataBaseField não seta nas properties
                                if (!modelController.DataBaseFieldYN)
                                {
                                    break;
                                }
                                if (String.IsNullOrEmpty(modelController.ColumnName))
                                {
                                    modelController.ColumnName = property.Name;
                                }
                                if (value == null)
                                {
                                    if (property.PropertyType == typeof(string))
                                    {
                                        value = String.Empty;
                                    }
                                    else if (property.PropertyType != typeof(DateTime) && property.PropertyType != typeof(Nullable <DateTime>))
                                    {
                                        value = 0;
                                    }
                                    else
                                    {
                                        value = new DateTime();
                                    }
                                }

                                if (property.PropertyType != typeof(decimal) && property.PropertyType != typeof(Nullable <decimal>))
                                {
                                    oGeneralData.SetProperty(modelController.ColumnName, value);
                                }
                                else
                                {
                                    oGeneralData.SetProperty(modelController.ColumnName, Convert.ToDouble(value));
                                }
                                break;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception(String.Format("Erro ao setar propriedade {0}: {1}", property.Name, e));
                    }
                }

                switch (enumCrudOperation)
                {
                case EnumCrudOperation.Create:
                    oGeneralService.Add(oGeneralData);
                    break;

                case EnumCrudOperation.Update:
                    oGeneralService.Update(oGeneralData);
                    break;

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (sCompany != null)
                {
                    Marshal.ReleaseComObject(sCompany);
                    sCompany = null;
                }

                if (oGeneralService != null)
                {
                    Marshal.ReleaseComObject(oGeneralService);
                    oGeneralService = null;
                }

                if (oGeneralData != null)
                {
                    Marshal.ReleaseComObject(oGeneralData);
                    oGeneralData = null;
                }
                GC.Collect();
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Actualiza los registros a la tabla @TFECEANU
        /// </summary>
        /// <param name="comp"></param>
        /// <param name="certificadosAnulados"></param>
        /// <returns></returns>
        public bool ActualizarMaestro(ArrayList certificadosAnulados)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener el servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFECEANU");

                //Apuntar a la cabecera del udo
                dataGeneral = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                foreach (Anulado anulado in certificadosAnulados)
                {
                    //Establecer parametros
                    parametros.SetProperty("DocEntry", anulado.DocEntry);

                    //Apuntar al udo que corresponde con los parametros
                    dataGeneral = servicioGeneral.GetByParams(parametros);

                    //Establecer los valores para cada una de las propiedades del udo
                    dataGeneral.SetProperty("U_Corregido", anulado.CorregidoCon);

                    ////Agregar el nuevo registro a la base de dato utilizando el servicio general de la compañia
                    servicioGeneral.Update(dataGeneral);
                }
                resultado = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (servicioGeneral != null)
                {
                    ////Liberar memoria utlizada por el objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    ////Liberar memoria utlizada por el objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (parametros != null)
                {
                    ////Liberar memoria utlizada por el objeto parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
Esempio n. 16
0
        /// <summary>
        /// Actualiza los datos de un rango determinado
        /// </summary>
        /// <param name="comp"></param>
        /// <param name="cae"></param>
        /// <param name="numeroRango"></param>
        /// <returns></returns>
        public bool Actualizar(CAE cae, string numeroRango)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFECAE");

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", numeroRango);

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                //Establecer los valores para las propiedades
                dataGeneral.SetProperty("U_TipoDoc", ((int)cae.TipoCFE).ToString());
                dataGeneral.SetProperty("U_NombDoc", cae.NombreDocumento);
                dataGeneral.SetProperty("U_Sucursal", cae.Sucursal);
                dataGeneral.SetProperty("U_Caja", QuitarGuion(cae.Caja));
                dataGeneral.SetProperty("U_Serie", cae.Serie.ToUpper());
                dataGeneral.SetProperty("U_NumIni", cae.NumeroDesde.ToString());
                dataGeneral.SetProperty("U_NumFin", cae.NumeroHasta.ToString());
                dataGeneral.SetProperty("U_TipAut", cae.TipoAutorizacion);
                dataGeneral.SetProperty("U_NumAut", cae.NumeroAutorizacion);
                dataGeneral.SetProperty("U_ValDesde", cae.FechaEmision);
                dataGeneral.SetProperty("U_ValHasta", cae.FechaVencimiento);

                //Agregar el nuevo registro a la base de datos mediante el serivicio general
                servicioGeneral.Update(dataGeneral);

                resultado = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (parametros != null)
                {
                    //Liberar memoria utlizada por objeto parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
Esempio n. 17
0
        /// <summary>
        /// Almacena la adenda
        /// </summary>
        /// <param name="comp"></param>
        /// <param name="tipoObjetoAsignado"></param>
        /// <param name="objetoAsignado"></param>
        /// <param name="partesAdenda"></param>
        /// <returns></returns>
        private bool Actualizar(Adenda adena)
        {
            bool salida = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFEADENDA");

                //Apuntar a la cabecera del udo
                dataGeneral = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);
                parametros  = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", adena.DocEntry);

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                //Establecer los valores para las propiedades
                dataGeneral.SetProperty("U_TipoObjAsig", adena.TipoObjetoAsignado.ToString());
                dataGeneral.SetProperty("U_ObjAsig", adena.ObjetoAsignado);
                dataGeneral.SetProperty("U_Adenda1", adena.ArregloAdenda[0]);
                dataGeneral.SetProperty("U_Adenda2", adena.ArregloAdenda[1]);
                dataGeneral.SetProperty("U_Adenda3", adena.ArregloAdenda[2]);
                dataGeneral.SetProperty("U_Adenda4", adena.ArregloAdenda[3]);
                dataGeneral.SetProperty("U_Adenda5", adena.ArregloAdenda[4]);
                dataGeneral.SetProperty("U_Adenda6", adena.ArregloAdenda[5]);
                dataGeneral.SetProperty("U_Adenda7", adena.ArregloAdenda[6]);
                dataGeneral.SetProperty("U_Adenda8", adena.ArregloAdenda[7]);
                dataGeneral.SetProperty("U_Adenda9", adena.ArregloAdenda[8]);
                dataGeneral.SetProperty("U_Adenda10", adena.ArregloAdenda[9]);

                //Agregar el nuevo registro a la base de datos mediante el serivicio general
                servicioGeneral.Update(dataGeneral);

                salida = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }

            return(salida);
        }
Esempio n. 18
0
        /// <summary>
        /// Actualiza los datos del CFE
        /// </summary>
        /// <param name="comp"></param>
        /// <param name="tipo"></param>
        /// <param name="serie"></param>
        /// <param name="numero"></param>
        /// <returns></returns>
        public bool Actualizar(int tipo, string serie, int numero, CFE.ESEstadoCFE estado, CFE.ESTipoReceptor tipoReceptor)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFECFE");

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", ConsultarDocEntryCFE(tipo, serie, numero));

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                if (tipoReceptor == CFE.ESTipoReceptor.DGI)
                {
                    dataGeneral.SetProperty("U_EstadoDgi", estado.ToString());
                }
                else
                {
                    dataGeneral.SetProperty("U_EstadoRec", estado.ToString());
                }

                //Agregar el nuevo registro a la base de datos mediante el servicio general
                servicioGeneral.Update(dataGeneral);

                resultado = true;
            }
            catch (Exception ex)
            {
                //SAPbouiCOM.Framework.Application.SBO_Application.MessageBox("actualizarCFE " + ex.ToString());
            }
            finally
            {
                if (parametros != null)
                {
                    //Liberar memoria utlizada por el objeto parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por el objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
Esempio n. 19
0
        /// <summary>
        /// Actualiza los datos de la configuracion de conexion al servidor FTP
        /// </summary>
        /// <param name="comp"></param>
        /// <param name="configFtp"></param>
        /// <returns></returns>
        public bool Actualizar(ConfigFTP configFtp)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;

            try
            {
                //Obtener servicio general de la compañia
                servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFECONFTP");

                //Obtener lista de parametros
                parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                //Establecer parametros
                parametros.SetProperty("DocEntry", "1");

                //Apuntar al udo que corresponde con los parametros
                dataGeneral = servicioGeneral.GetByParams(parametros);

                dataGeneral.SetProperty("U_Serv", configFtp.Servidor);
                dataGeneral.SetProperty("U_RepComp", configFtp.RepoComp);
                dataGeneral.SetProperty("U_RepSob", configFtp.RepoSob);
                dataGeneral.SetProperty("U_RepBan", configFtp.RepoBandejaEntrada);
                dataGeneral.SetProperty("U_RepResp", configFtp.RepoResp);
                dataGeneral.SetProperty("U_RepRepDi", configFtp.RepoRepDi);
                dataGeneral.SetProperty("U_RepConSob", configFtp.RepoContingenciaSobres);
                dataGeneral.SetProperty("U_RepConCom", configFtp.RepoContingenciaComprobantes);
                dataGeneral.SetProperty("U_RepConReDi", configFtp.RepoContingenciaReportesDiarios);
                dataGeneral.SetProperty("U_Usuario", configFtp.Usuario);
                dataGeneral.SetProperty("U_Clave", configFtp.Clave);
                dataGeneral.SetProperty("U_RutWsE", configFtp.RepoWebServiceEnvio);
                dataGeneral.SetProperty("U_RutWsC", configFtp.RepoWebServiceConsulta);
                dataGeneral.SetProperty("U_RepCfe", configFtp.RepoCFEs);
                dataGeneral.SetProperty("U_RepCerAnu", configFtp.RepoCertificadosAnulados);
                dataGeneral.SetProperty("U_ConSobDgi", configFtp.RepoContingenciaSobreDgi);
                dataGeneral.SetProperty("U_ConSobDgi", configFtp.RepoContingenciaSobreDgi);
                dataGeneral.SetProperty("U_FilePcDel", configFtp.FileDelete);
                ///dataGeneral.SetProperty("U_RUT", configFtp.RutDgi);

                //Agregar el nuevo registro a la base de datos mediante el serivicio general
                servicioGeneral.Update(dataGeneral);

                resultado = true;
            }
            catch (Exception)
            {
            }
            finally
            {
                if (parametros != null)
                {
                    //Liberar memoria utlizada por parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
Esempio n. 20
0
        /// <summary>
        /// Actualiza un nuevo registro en la tabla de estado de contingencia
        /// </summary>
        /// <param name="comp"></param>
        /// <param name="estado"></param>
        /// <returns></returns>
        public bool Actualizar(string estado)
        {
            bool resultado = false;

            GeneralService    servicioGeneral = null;
            GeneralData       dataGeneral     = null;
            GeneralDataParams parametros      = null;
            string            docEntry        = ObtenerDocEntry();

            try
            {
                if (docEntry.Equals(""))
                {
                    resultado = false;
                }
                else
                {
                    //Obtener servicio general de la compañia
                    servicioGeneral = ProcConexion.Comp.GetCompanyService().GetGeneralService("TTFEESTCON");

                    //Apuntar a la cabecera del udo
                    dataGeneral = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                    //Obtener lista de parametros
                    parametros = servicioGeneral.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralDataParams);

                    //Establecer parametros
                    parametros.SetProperty("DocEntry", docEntry);

                    //Apuntar al udo que corresponde con los parametros
                    dataGeneral = servicioGeneral.GetByParams(parametros);

                    //Establecer los valores para las propiedades
                    dataGeneral.SetProperty("U_Activo", estado);

                    //Agregar el nuevo registro a la base de datos mediante el serivicio general
                    servicioGeneral.Update(dataGeneral);

                    resultado = true;

                    FrmEstadoContingencia.estadoContingencia = estado;
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (parametros != null)
                {
                    //Liberar memoria utlizada por parametros
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(parametros);
                    System.GC.Collect();
                }
                if (dataGeneral != null)
                {
                    //Liberar memoria utlizada por dataGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(dataGeneral);
                    System.GC.Collect();
                }
                if (servicioGeneral != null)
                {
                    //Liberar memoria utlizada por objeto servicioGeneral
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(servicioGeneral);
                    System.GC.Collect();
                }
            }
            return(resultado);
        }
        public void CreateModelList(object parentCode)
        {
            Recordset rstExistsParent = (Recordset)SBOApp.Company.GetBusinessObject(BoObjectTypes.BoRecordset);
            string    sql             = "SELECT TOP 1 1 FROM [{0}] WHERE Code = '{1}'";

            sql = String.Format(sql, ParentTableName, parentCode);

            try
            {
                rstExistsParent.DoQuery(sql);

                if (rstExistsParent.RecordCount == 0)
                {
                    throw new Exception(String.Format("Código {0} do item pai não encontrado", parentCode));
                }
            }
            finally
            {
                Marshal.ReleaseComObject(rstExistsParent);
                rstExistsParent = null;
            }

            CompanyService oCompanyService = SBOApp.Company.GetCompanyService();
            GeneralService oGeneralService = oCompanyService.GetGeneralService(ParentTableName.Replace("@", ""));

            GeneralDataParams oGeneralParams = (GeneralDataParams)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);

            oGeneralParams.SetProperty("Code", parentCode);

            GeneralData           oGeneralData = oGeneralService.GetByParams(oGeneralParams);
            GeneralDataCollection oChildren    = oGeneralData.Child(TableName.Replace("@", ""));
            GeneralData           oChild       = null;

            try
            {
                foreach (object model in ModelList)
                {
                    Model  = model;
                    oChild = oChildren.Add();

                    ModelControllerAttribute modelController;
                    object value;
                    // Percorre as propriedades do Model
                    foreach (PropertyInfo property in Model.GetType().GetProperties())
                    {
                        // Busca os Custom Attributes
                        foreach (Attribute attribute in property.GetCustomAttributes(true))
                        {
                            modelController = attribute as ModelControllerAttribute;
                            if (property.GetType() != typeof(DateTime))
                            {
                                value = property.GetValue(Model, null);
                            }
                            else
                            {
                                value = ((DateTime)property.GetValue(Model, null)).ToString("yyyy-MM-dd HH:mm:ss");
                            }

                            if (modelController != null)
                            {
                                // Se não for DataBaseField não seta nas properties
                                if (!modelController.DataBaseFieldYN)
                                {
                                    break;
                                }
                                if (String.IsNullOrEmpty(modelController.ColumnName))
                                {
                                    modelController.ColumnName = property.Name;
                                }
                                if (modelController.ColumnName == "Code" || modelController.ColumnName == "LineId")
                                {
                                    continue;
                                }

                                if (value == null)
                                {
                                    if (property.PropertyType == typeof(string))
                                    {
                                        value = String.Empty;
                                    }
                                    else if (property.PropertyType != typeof(DateTime) && property.PropertyType != typeof(Nullable <DateTime>))
                                    {
                                        value = 0;
                                    }
                                    else
                                    {
                                        value = new DateTime();
                                    }
                                }

                                if (property.PropertyType != typeof(decimal) && property.PropertyType != typeof(Nullable <decimal>))
                                {
                                    oChild.SetProperty(modelController.ColumnName, value);
                                }
                                else
                                {
                                    oChild.SetProperty(modelController.ColumnName, Convert.ToDouble(value));
                                }
                                break;
                            }
                        }
                    }
                }

                oGeneralService.Update(oGeneralData);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                Marshal.ReleaseComObject(oGeneralService);
                Marshal.ReleaseComObject(oGeneralData);
                Marshal.ReleaseComObject(oCompanyService);

                oGeneralService = null;
                oGeneralData    = null;
                oCompanyService = null;

                if (oChildren != null)
                {
                    Marshal.ReleaseComObject(oChildren);
                    oChildren = null;
                }
                if (oChild != null)
                {
                    Marshal.ReleaseComObject(oChild);
                    oChild = null;
                }
            }
        }