public Historico_Contramedidas Detalles(int id) { Historico_Contramedidas historico = null; try { var accessor = new DataAccesor(_connectionString); string ic = accessor.ParameterIdentifierCharacter(); var sql = string.Format(@"SELECT ID AS {0}, Expiracion AS {1}, CV AS {2}, Lote AS {3}, Id_Prensa AS {4} FROM HISTORICO_CONTRAMEDIDAS WHERE ID= " + ic + "{0}", Arguments.Id, Arguments.Expiracion, Arguments.CV, Arguments.lote, Arguments.Id_Prensa); List <IDataParameter> parameters = new List <IDataParameter>() { accessor.Parameter(Arguments.Id, id) }; var ds = accessor.FillDataSet(sql, parameters); historico = GetSingle(ds); } catch (Exception ex) { log.Error("Detalles({0})", ex, id); } return(historico); }
private Historico_Contramedidas GetSingle(DataSet ds) { Historico_Contramedidas historico = null; try { if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { historico = new Historico_Contramedidas() { Id = Convert.ToInt32(ds.Tables[0].Rows[0][Arguments.Id]), Expiracion = Convert.ToDateTime(ds.Tables[0].Rows[0][Arguments.Expiracion]), CV = Convert.ToString(ds.Tables[0].Rows[0][Arguments.CV]), Lote = Convert.ToString(ds.Tables[0].Rows[0][Arguments.lote]), Id_Prensa = Convert.ToInt32(ds.Tables[0].Rows[0][Arguments.Id_Prensa]) }; } } catch (Exception ex) { log.Error("GetSingle", ex); } return(historico); }
public int Agregar(Historico_Contramedidas entidad) { int id = -1; try { var accessor = new DataAccesor(_connectionString); string ic = accessor.ParameterIdentifierCharacter(); var sql = string.Format("INSERT INTO HISTORICO_CONTRAMEDIDAS (EXPIRACION,CV,LOTE, ID_PRENSA)" + " VALUES (" + ic + "{0}, " + ic + "{1}, " + ic + "{2}," + ic + "{3} ) " + accessor.sqlGetNewIdentity(Arguments.Id, "{4}"), Arguments.Expiracion, Arguments.CV, Arguments.lote, Arguments.Id_Prensa, Arguments.Id); List <IDataParameter> parameters = new List <IDataParameter>() { accessor.Parameter(Arguments.Expiracion, entidad.Expiracion), accessor.Parameter(Arguments.CV, entidad.CV), accessor.Parameter(Arguments.lote, entidad.Lote), accessor.Parameter(Arguments.Id_Prensa, entidad.Id_Prensa), 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); }