Example #1
0
        public Tag_Mapping Detalles(int id)
        {
            Tag_Mapping mapping = null;

            try
            {
                var    accessor = new DataAccesor(_connectionString);
                string ic       = accessor.ParameterIdentifierCharacter();
                var    sql      = string.Format(@"SELECT
                                            ID AS {0},
                                            Nombre AS {1}                                            
                                        FROM TAG_MAPPING
                                        WHERE ID= " + ic + "{0}",
                                                Arguments.Id, Arguments.Nombre);



                List <IDataParameter> parameters = new List <IDataParameter>()
                {
                    accessor.Parameter(Arguments.Id, id)
                };

                var ds = accessor.FillDataSet(sql, parameters);

                mapping = GetSingle(ds);
            }
            catch (Exception ex)
            {
                log.Error("Detalles({0})", ex, id);
            }
            return(mapping);
        }
Example #2
0
        private Tag_Mapping GetSingle(DataSet ds)
        {
            Tag_Mapping mapping = null;

            try
            {
                if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    mapping = new Tag_Mapping()
                    {
                        Id     = Convert.ToInt32(ds.Tables[0].Rows[0][Arguments.Id]),
                        Nombre = Convert.ToString(ds.Tables[0].Rows[0][Arguments.Nombre])
                    };
                }
            }
            catch (Exception ex)
            {
                log.Error("GetSingle", ex);
            }

            return(mapping);
        }
Example #3
0
        public int Agregar(Tag_Mapping entidad)
        {
            int id = -1;

            try
            {
                var    accessor = new DataAccesor(_connectionString);
                string ic       = accessor.ParameterIdentifierCharacter();

                var sql = string.Format("INSERT INTO TAG_MAPPING (NOMBRE)" +
                                        " VALUES (" + ic + "{0}) " + accessor.sqlGetNewIdentity(Arguments.Id, "{1}"),
                                        Arguments.Nombre, Arguments.Id);


                List <IDataParameter> parameters = new List <IDataParameter>()
                {
                    accessor.Parameter(Arguments.Nombre, entidad.Nombre),
                    accessor.Parameter(Arguments.Id, 0, ParameterDirection.Output)
                };

                var result = accessor.ExecuteNonQueryWithResult(sql, parameters, false);

                if (result != null && typeof(int).Equals(result.GetType()))
                {
                    id = (int)result;
                }
                else
                {
                    log.Warning("Agregar() No se ha completado la inserción");
                }
            }
            catch (Exception ex)
            {
                log.Error("Agregar()", ex);
            }

            return(id);
        }
Example #4
0
        public bool Modificar(Tag_Mapping entidad)
        {
            bool sw = false;

            try
            {
                var    accessor = new DataAccesor(_connectionString);
                string ic       = accessor.ParameterIdentifierCharacter();
                var    sql      = string.Format("UPDATE TAG_MAPPING SET NOMBRE = " + ic + "{0} WHERE ID = " + ic + "{1}",
                                                Arguments.Nombre, Arguments.Id_Estado);



                List <IDataParameter> parameters = new List <IDataParameter>()
                {
                    accessor.Parameter(Arguments.Nombre, entidad.Nombre),
                    accessor.Parameter(Arguments.Id_Estado, entidad.Id)
                };

                var result = accessor.ExecuteNonQuery(sql, parameters, false);

                if (typeof(int).Equals(result.GetType()))
                {
                    sw = (int)result > 0;
                }
                else
                {
                    log.Warning("Modificar() No se ha completado la modificación");
                }
            }
            catch (Exception ex)
            {
                log.Error("Modificar()", ex);
            }

            return(sw);
        }