/// <summary> /// Metodo para actualizar un registro de IndicadorProductoBoleta /// </summary> /// <param name="info">Valores de la entidad que se actualizarán</param> public void Actualizar(IndicadorProductoBoletaInfo info) { try { Logger.Info(); var parameters = new Dictionary <string, object> { { "@IndicadorProductoBoletaID", info.IndicadorProductoBoletaID }, { "@OrganizacionID", info.Organizacion.OrganizacionID }, { "@IndicadorProductoID", info.IndicadorProducto.IndicadorProductoId }, { "@Activo", info.Activo }, { "@RangoMaximo", info.RangoMaximo }, { "@RangoMinimo", info.RangoMinimo }, { "@UsuarioModificacionID", info.UsuarioModificacionID }, }; Update("IndicadorProductoBoleta_Actualizar", parameters); } catch (SqlException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (DataException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene un registro de IndicadorProductoBoleta /// </summary> /// <param name="indicadorProductoBoletaID">Identificador de la IndicadorProductoBoleta</param> /// <returns></returns> public IndicadorProductoBoletaInfo ObtenerPorID(int indicadorProductoBoletaID) { try { Logger.Info(); Dictionary <string, object> parameters = null; DataSet ds = Retrieve("IndicadorProductoBoleta_ObtenerPorID", parameters); IndicadorProductoBoletaInfo result = null; if (ValidateDataSet(ds)) { result = MapIndicadorProductoBoletaDAL.ObtenerPorID(ds); } return(result); } catch (SqlException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (DataException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene una indicador producto boleta por /// indicador producto y organizacion /// </summary> /// <param name="indicadorProductoID"></param> /// <param name="organizacionID"></param> /// <returns></returns> internal IndicadorProductoBoletaInfo ObtenerPorIndicadorProductoOrganizacion(int indicadorProductoID, int organizacionID) { try { Logger.Info(); var parameters = new Dictionary <string, object> { { "@IndicadorProductoID", indicadorProductoID }, { "@OrganizacionID", organizacionID } }; DataSet ds = Retrieve("IndicadorProductoBoleta_ObtenerPorIndicadorProductoOrganizacion", parameters); IndicadorProductoBoletaInfo result = null; if (ValidateDataSet(ds)) { result = MapIndicadorProductoBoletaDAL.ObtenerPorIndicadorProductoOrganizacion(ds); } return(result); } catch (SqlException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (DataException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Metodo para Guardar/Modificar una entidad IndicadorProductoBoleta /// </summary> /// <param name="info"></param> public int Guardar(IndicadorProductoBoletaInfo info) { try { Logger.Info(); var indicadorProductoBoletaDAL = new IndicadorProductoBoletaDAL(); int result = info.IndicadorProductoBoletaID; if (info.IndicadorProductoBoletaID == 0) { result = indicadorProductoBoletaDAL.Crear(info); } else { indicadorProductoBoletaDAL.Actualizar(info); } return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Inicializa el Contexto /// </summary> private void InicializaContexto() { Contexto = new IndicadorProductoBoletaInfo { UsuarioCreacionID = AuxConfiguracion.ObtenerUsuarioLogueado(), IndicadorProducto = new IndicadorProductoInfo { IndicadorInfo = new IndicadorInfo(), Producto = new ProductoInfo() } }; }
/// <summary> /// Evento que se ejecuta mientras se esta cerrando la ventana /// </summary> /// <param name="e"></param> protected override void OnClosing(CancelEventArgs e) { if (confirmaSalir) { MessageBoxResult result = SkMessageBox.Show(this, Properties.Resources.Msg_CerrarSinGuardar, MessageBoxButton.YesNo, MessageImage.Question); if (result == MessageBoxResult.Yes) { Contexto = null; } else { e.Cancel = true; } } }
/// <summary> /// Obtiene una entidad IndicadorProductoBoleta por su Id /// </summary> /// <param name="indicadorProductoBoletaID">Obtiene una entidad IndicadorProductoBoleta por su Id</param> /// <returns></returns> public IndicadorProductoBoletaInfo ObtenerPorID(int indicadorProductoBoletaID) { try { Logger.Info(); var indicadorProductoBoletaDAL = new IndicadorProductoBoletaDAL(); IndicadorProductoBoletaInfo result = indicadorProductoBoletaDAL.ObtenerPorID(indicadorProductoBoletaID); return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Inicializa el Contexto /// </summary> private void InicializaContexto() { Contexto = new IndicadorProductoBoletaInfo { UsuarioCreacionID = AuxConfiguracion.ObtenerUsuarioLogueado(), IndicadorProducto = new IndicadorProductoInfo { IndicadorInfo = new IndicadorInfo(), Producto = new ProductoInfo { Familia = new FamiliaInfo { FamiliaID = FamiliasEnum.MateriaPrimas.GetHashCode() } }, }, Organizacion = new OrganizacionInfo() }; skAyudaIndicador.AsignarFoco(); }
/// <summary> /// Obtiene un lista paginada /// </summary> /// <param name="pagina"></param> /// <param name="filtro"></param> /// <returns></returns> public ResultadoInfo <IndicadorProductoBoletaInfo> ObtenerPorPagina(PaginacionInfo pagina, IndicadorProductoBoletaInfo filtro) { try { Logger.Info(); var indicadorProductoBoletaDAL = new IndicadorProductoBoletaDAL(); ResultadoInfo <IndicadorProductoBoletaInfo> result = indicadorProductoBoletaDAL.ObtenerPorPagina(pagina, filtro); return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Constructor para editar una entidad IndicadorProductoBoleta Existente /// </summary> /// <param name="indicadorProductoBoletaInfo"></param> public IndicadorProductoBoletaEdicion(IndicadorProductoBoletaInfo indicadorProductoBoletaInfo) { InitializeComponent(); indicadorProductoBoletaInfo.UsuarioModificacionID = AuxConfiguracion.ObtenerUsuarioLogueado(); Contexto = indicadorProductoBoletaInfo; }
/// <summary> /// Metodo que valida los datos para guardar /// </summary> /// <returns></returns> private bool ValidaGuardar() { bool resultado = true; string mensaje = string.Empty; try { if (Contexto.IndicadorProducto.IndicadorInfo.IndicadorId == 0) { resultado = false; mensaje = Properties.Resources.IndicadorProductoBoletaEdicion_MsgIndicadorProductoBoletaIDRequerida; skAyudaIndicador.AsignarFoco(); } else if (Contexto.IndicadorProducto.Producto.ProductoId == 0) { resultado = false; mensaje = Properties.Resources.IndicadorProductoBoletaEdicion_MsgIndicadorProductoIDRequerida; skAyudaProducto.AsignarFoco(); } else if (Contexto.Organizacion.OrganizacionID == 0) { resultado = false; mensaje = Properties.Resources.IndicadorProductoBoletaEdicion_MsgOrganizacionIDRequerida; skAyudaOrganizacion.AsignarFoco(); } //else if (!dtuRangoMinimo.Value.HasValue || Contexto.RangoMinimo == 0) //{ // resultado = false; // mensaje = Properties.Resources.IndicadorProductoBoletaEdicion_MsgRangoMinimoRequerida; // dtuRangoMinimo.Focus(); //} //else if (!dtuRangoMaximo.Value.HasValue || Contexto.RangoMaximo == 0) //{ // resultado = false; // mensaje = Properties.Resources.IndicadorProductoBoletaEdicion_MsgRangoMaximoRequerida; // dtuRangoMaximo.Focus(); //} else if (cmbActivo.SelectedItem == null) { resultado = false; mensaje = Properties.Resources.IndicadorProductoBoletaEdicion_MsgActivoRequerida; cmbActivo.Focus(); } else { int indicadorProductoBoletaId = Contexto.IndicadorProductoBoletaID; var indicadorProductoBoletaBL = new IndicadorProductoBoletaBL(); IndicadorProductoBoletaInfo indicadorProductoBoleta = indicadorProductoBoletaBL.ObtenerPorIndicadorProductoOrganizacion( Contexto.IndicadorProducto.IndicadorProductoId, Contexto.Organizacion.OrganizacionID); if (indicadorProductoBoleta != null && (indicadorProductoBoletaId == 0 || indicadorProductoBoletaId != indicadorProductoBoleta.IndicadorProductoBoletaID)) { resultado = false; mensaje = string.Format(Properties.Resources.IndicadorProductoBoletaEdicion_MsgDescripcionExistente, indicadorProductoBoleta.IndicadorProductoBoletaID); } } } catch (Exception ex) { throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } if (!string.IsNullOrWhiteSpace(mensaje)) { SkMessageBox.Show(this, mensaje, MessageBoxButton.OK, MessageImage.Warning); } return(resultado); }
/// <summary> /// Obtiene un lista paginada /// </summary> /// <param name="pagina"></param> /// <param name="filtro"></param> /// <returns></returns> public ResultadoInfo <IndicadorProductoBoletaInfo> ObtenerPorPagina(PaginacionInfo pagina, IndicadorProductoBoletaInfo filtro) { try { var parameters = new Dictionary <string, object> { { "@Inicio", pagina.Inicio }, { "@Limite", pagina.Limite }, { "@Activo", filtro.Activo }, { "@IndicadorID", filtro.IndicadorProducto.IndicadorInfo.IndicadorId }, { "@ProductoID", filtro.IndicadorProducto.Producto.ProductoId } }; DataSet ds = Retrieve("IndicadorProductoBoleta_ObtenerPorPagina", parameters); ResultadoInfo <IndicadorProductoBoletaInfo> result = null; if (ValidateDataSet(ds)) { result = MapIndicadorProductoBoletaDAL.ObtenerPorPagina(ds); } return(result); } catch (SqlException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (DataException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }