/// <summary> /// Realiza la actualizacion de un premio. /// </summary> /// <param name="item"></param> public bool Update(PremiosInfo item) { try { return(module.Update(item)); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("NIVI Error: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)); return(false); } }
/// <summary> /// Realiza el registro de un premio. /// </summary> /// <param name="item"></param> public int Insert(PremiosInfo item) { int id = 0; IDataReader dr = null; try { db.SetParameterValue(commandPremios, "i_operation", 'I'); db.SetParameterValue(commandPremios, "i_option", 'A'); db.SetParameterValue(commandPremios, "i_pre_descripcion", item.Descripcion); db.SetParameterValue(commandPremios, "i_pre_condiciones", item.Condiciones); db.SetParameterValue(commandPremios, "i_pre_estado", item.Estado); db.SetParameterValue(commandPremios, "i_pre_creado", item.Creado); db.SetParameterValue(commandPremios, "i_pre_modificado", item.Modificado); dr = db.ExecuteReader(commandPremios); //Obtiene el identificador (consecutivo) del insert id = Convert.ToInt32(db.GetParameterValue(commandPremios, "i_pre_id")); } catch (Exception ex) { id = 0; System.Diagnostics.Trace.WriteLine(string.Format("NIVI Error: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)); bool rethrow = ExceptionPolicy.HandleException(ex, "DataAccess Policy"); if (rethrow) { throw; } } finally { if (dr != null) { dr.Close(); } } return(id); }
/// <summary> /// busca un premio por nombre. /// </summary> /// <param name="NombrePremio"></param> /// <returns></returns> public List <PremiosInfo> ListxNombre(string NombrePremio) { db.SetParameterValue(commandPremios, "i_operation", 'S'); db.SetParameterValue(commandPremios, "i_option", 'D'); db.SetParameterValue(commandPremios, "i_pre_descripcion", NombrePremio); List <PremiosInfo> col = new List <PremiosInfo>(); IDataReader dr = null; PremiosInfo m = null; try { dr = db.ExecuteReader(commandPremios); while (dr.Read()) { m = Factory.GetPremios(dr); col.Add(m); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("NIVI Error: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)); bool rethrow = ExceptionPolicy.HandleException(ex, "DataAccess Policy"); if (rethrow) { throw; } } finally { if (dr != null) { dr.Close(); } } return(col); }
/// <summary> /// Realiza la actualizacion de un premio. /// </summary> /// <param name="item"></param> public bool Update(PremiosInfo item) { bool transOk = false; IDataReader dr = null; try { db.SetParameterValue(commandPremios, "i_operation", 'U'); db.SetParameterValue(commandPremios, "i_option", 'A'); db.SetParameterValue(commandPremios, "i_pre_id", item.Id); db.SetParameterValue(commandPremios, "i_pre_descripcion", item.Descripcion); db.SetParameterValue(commandPremios, "i_pre_condiciones", item.Condiciones); db.SetParameterValue(commandPremios, "i_pre_estado", item.Estado); db.SetParameterValue(commandPremios, "i_pre_modificado", item.Modificado); dr = db.ExecuteReader(commandPremios); transOk = true; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("NIVI Error: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)); bool rethrow = ExceptionPolicy.HandleException(ex, "DataAccess Policy"); if (rethrow) { throw; } } finally { if (dr != null) { dr.Close(); } } return(transOk); }