public bool UpdatePremiosPuntos(PremiosPuntosWinformsInfo item) { try { return(module.UpdatePremiosPuntos(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 consulta de los premios que tengan un nivel inferior a la referencia contenedora y no esten asociados a esa referencia /// </summary> /// <param name="campana"></param> /// <param name="referencia"></param> /// <returns></returns> public List <PremiosPuntosWinformsInfo> ListSinRefcontenedora(int nivel, string refcontenedora, string filtro) { db.SetParameterValue(commandPremiosPuntosWinforms, "i_operation", 'S'); db.SetParameterValue(commandPremiosPuntosWinforms, "i_option", 'D'); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_nivel", nivel); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_refcontenedora", refcontenedora); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_filtro", filtro); List <PremiosPuntosWinformsInfo> col = new List <PremiosPuntosWinformsInfo>(); IDataReader dr = null; PremiosPuntosWinformsInfo m = null; try { dr = db.ExecuteReader(commandPremiosPuntosWinforms); while (dr.Read()) { m = Factory.GetPremiosPuntosWinforms(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> /// Metodo que valida y realiza actualizacion o insercion en la tabla SVDN_PREMIOS_PUNTOS_WINFORMS /// </summary> /// <param name="referencia"></param> /// <param name="Puntos"></param> /// <param name="Campana"></param> /// <param name="Nivel"></param> /// <returns>Mensaje despues de la operacion</returns> public string guardarPremioPuntos(string referencia, int Puntos, string Campana, int Nivel, string CampanaEntrega, string refcontenedora = "", string sumarpuntos = "") { string mensaje = string.Empty; string strResult = string.Empty; PremiosPuntosWinformsInfo ppw = new PremiosPuntosWinformsInfo(); ppw.Referencia = referencia; ppw.Puntos = Puntos; ppw.Campana = Campana; ppw.Nivel = Nivel; ppw.Campana_Entrega = CampanaEntrega; if (sumarpuntos != "") { ppw.SumarPuntos = sumarpuntos; } if (refcontenedora != "") { ppw.RefContenedora = refcontenedora; } List <PremiosPuntosWinformsInfo> lista; lista = ListReferenciasYCampanas(Campana, referencia); if (lista != null) { if (lista.Count > 0) { if (UpdatePremiosPuntos(ppw)) { mensaje = "Registro Actualizado"; } else { mensaje = "Registro no pudo ser Actualizado"; } } else { strResult = InsertPremiosPuntos(ppw); mensaje = "Registro insertado correctamente"; } } return(mensaje); }
/// <summary> /// Actualiza Registro de Punto por Premio /// </summary> /// <param name="item"></param> /// <returns></returns> public bool UpdatePremiosPuntos(PremiosPuntosWinformsInfo item) { bool transOk = false; IDataReader dr = null; try { db.SetParameterValue(commandPremiosPuntosWinforms, "i_operation", 'U'); db.SetParameterValue(commandPremiosPuntosWinforms, "i_option", 'A'); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_puntos", item.Puntos); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_campana", item.Campana); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_referencia", item.Referencia); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_refcontenedora", item.RefContenedora); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_sumarpuntos", item.SumarPuntos); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_nivel", item.Nivel); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_campanaentrega", item.Campana_Entrega); dr = db.ExecuteReader(commandPremiosPuntosWinforms); transOk = true; //**************************************************************************************************************************************** //Si el perfil es de un usuario interno de nivi se debe guardar la auditoria. if (item.GuardarAuditoria) { //----------------------------------------------------------------------------------------------------------------------------- //Guardar auditoria try { Auditoria objAuditoria = new Auditoria("conexion"); AuditoriaInfo objAuditoriaInfo = new AuditoriaInfo(); objAuditoriaInfo.FechaSistema = DateTime.Now; objAuditoriaInfo.Usuario = item.Usuario; string numero = "0"; //System.Convert.ToString(db.GetParameterValue(commandPremiosPuntosWinforms, "i_prepw_numero")).Trim(); objAuditoriaInfo.Proceso = "Se realizó la actualización del Pedido Número: " + numero + " . Acción Realizada por el Usuario: " + item.Usuario; objAuditoria.Insert(objAuditoriaInfo); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("NIVI Error Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)); } //----------------------------------------------------------------------------------------------------------------------------- } //**************************************************************************************************************************************** } 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); }
/// <summary> /// Inserta Nuevo Registro de Punto por Premio /// </summary> /// <param name="item"></param> /// <returns></returns> public string InsertPremiosPuntos(PremiosPuntosWinformsInfo item) { string strid = ""; IDataReader dr = null; try { db.SetParameterValue(commandPremiosPuntosWinforms, "i_operation", 'I'); db.SetParameterValue(commandPremiosPuntosWinforms, "i_option", 'A'); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_referencia", item.Referencia); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_puntos", item.Puntos); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_campana", item.Campana); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_nivel", item.Nivel); db.SetParameterValue(commandPremiosPuntosWinforms, "i_prepw_campanaentrega", item.Campana_Entrega); dr = db.ExecuteReader(commandPremiosPuntosWinforms); strid = System.Convert.ToString(db.GetParameterValue(commandPremiosPuntosWinforms, "i_prepw_numero")).Trim(); //Obtiene el identificador (consecutivo) del insert if (item.GuardarAuditoria) { //----------------------------------------------------------------------------------------------------------------------------- //Guardar auditoria try { Auditoria objAuditoria = new Auditoria("conexion"); AuditoriaInfo objAuditoriaInfo = new AuditoriaInfo(); item.Usuario = "User_Premios_Winforms"; objAuditoriaInfo.FechaSistema = DateTime.Now; objAuditoriaInfo.Usuario = item.Usuario; objAuditoriaInfo.Proceso = "Se realizó la insercion en la tabla Premios_Puntos_Winforms #: " + strid + " Referencia: " + item.Referencia + " Puntos: " + item.Puntos + " Campana: " + item.Campana + " . Acción Realizada por el Usuario: " + item.Usuario; objAuditoria.Insert(objAuditoriaInfo); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("NIVI Error Auditoria: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name)); } //----------------------------------------------------------------------------------------------------------------------------- } //**************************************************************************************************************************************** } 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(strid); }