/// <summary> /// Obtiene los tipos de Formula /// </summary> private void ObtenerTipoFormula() { try { var tipoFormulaPL = new TipoFormulaPL(); IList <TipoFormulaInfo> tiposFormula = tipoFormulaPL.ObtenerTodos(EstatusEnum.Activo); var tipoFormulaSeleccione = new TipoFormulaInfo { Descripcion = Properties.Resources.cbo_Seleccione }; tiposFormula.Insert(0, tipoFormulaSeleccione); cmbTipoFormula.ItemsSource = tiposFormula; } catch (ExcepcionGenerica) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.FormulaEdicion_ErrorBuscarTipoFormula, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.FormulaEdicion_ErrorBuscarTipoFormula, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Método para guardar los valores del contexto /// </summary> private void Guardar() { bool guardar = ValidaGuardar(); if (guardar) { try { var tipoFormulaPL = new TipoFormulaPL(); tipoFormulaPL.Guardar(Contexto); SkMessageBox.Show(this, Properties.Resources.GuardadoConExito, MessageBoxButton.OK, MessageImage.Correct); if (Contexto.TipoFormulaID != 0) { confirmaSalir = false; Close(); } else { InicializaContexto(); } } catch (ExcepcionGenerica) { SkMessageBox.Show(this, Properties.Resources.TipoFormula_ErrorGuardar, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(this, Properties.Resources.TipoFormula_ErrorGuardar, MessageBoxButton.OK, MessageImage.Error); } } }
public void ObtenerTipoFormulaPorId() { var tipoFormulaPL = new TipoFormulaPL(); TipoFormulaInfo tipoFormula = tipoFormulaPL.ObtenerPorID(1); Assert.IsNotNull(tipoFormula); Assert.IsTrue(tipoFormula.Descripcion.Length > 0); }
/// <summary> /// Metodo que valida los datos para guardar /// </summary> /// <returns></returns> private bool ValidaGuardar() { bool resultado = true; string mensaje = string.Empty; try { if (string.IsNullOrWhiteSpace(txtTipoFormulaID.Text)) { resultado = false; mensaje = Properties.Resources.TipoFormulaEdicion_MsgTipoFormulaIDRequerida; txtTipoFormulaID.Focus(); } else if (string.IsNullOrWhiteSpace(txtDescripcion.Text) || Contexto.Descripcion == string.Empty) { resultado = false; mensaje = Properties.Resources.TipoFormulaEdicion_MsgDescripcionRequerida; txtDescripcion.Focus(); } else if (cmbActivo.SelectedItem == null) { resultado = false; mensaje = Properties.Resources.TipoFormulaEdicion_MsgActivoRequerida; cmbActivo.Focus(); } else { int tipoFormulaId = Extensor.ValorEntero(txtTipoFormulaID.Text); string descripcion = txtDescripcion.Text.Trim(); var tipoFormulaPL = new TipoFormulaPL(); TipoFormulaInfo tipoFormula = tipoFormulaPL.ObtenerPorDescripcion(descripcion); if (tipoFormula != null && (tipoFormulaId == 0 || tipoFormulaId != tipoFormula.TipoFormulaID)) { resultado = false; mensaje = string.Format(Properties.Resources.TipoFormulaEdicion_MsgDescripcionExistente, tipoFormula.TipoFormulaID); } } } 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 la lista para mostrar en el grid /// </summary> private void ObtenerListaTipoFormula(int inicio, int limite) { try { if (ucPaginacion.ContextoAnterior != null) { bool contextosIguales = ucPaginacion.CompararObjetos(Contexto, ucPaginacion.ContextoAnterior); if (!contextosIguales) { ucPaginacion.Inicio = 1; inicio = 1; } } var tipoFormulaPL = new TipoFormulaPL(); TipoFormulaInfo filtros = ObtenerFiltros(); var pagina = new PaginacionInfo { Inicio = inicio, Limite = limite }; ResultadoInfo <TipoFormulaInfo> resultadoInfo = tipoFormulaPL.ObtenerPorPagina(pagina, filtros); if (resultadoInfo != null && resultadoInfo.Lista != null && resultadoInfo.Lista.Count > 0) { gridDatos.ItemsSource = resultadoInfo.Lista; ucPaginacion.TotalRegistros = resultadoInfo.TotalRegistros; } else { ucPaginacion.TotalRegistros = 0; gridDatos.ItemsSource = new List <TipoFormula>(); } } catch (ExcepcionGenerica) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.TipoFormula_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.TipoFormula_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Evento de Carga de la forma /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { try { TipoFormulaPL tipoFormulaPL = new TipoFormulaPL(); skAyudaOrganizacion.ObjetoNegocio = new OrganizacionPL(); skAyudaProducto.ObjetoNegocio = new ProductoPL(); skAyudaFormula.ObjetoNegocio = new FormulaPL(); skAyudaOrganizacion.Contexto = Contexto.Organizacion; Contexto.Producto = new ProductoInfo { Familias = new List <FamiliaInfo> { new FamiliaInfo { FamiliaID = FamiliasEnum.MateriaPrimas.GetHashCode() }, new FamiliaInfo { FamiliaID = FamiliasEnum.Premezclas.GetHashCode() }, new FamiliaInfo { FamiliaID = FamiliasEnum.Alimento.GetHashCode() } } }; //skAyudaProducto.DataContext = Contexto.Producto; skAyudaOrganizacion.LimpiarCampos(); skAyudaProducto.LimpiarCampos(); skAyudaFormula.LimpiarCampos(); List <TipoFormulaInfo> tipos = tipoFormulaPL.ObtenerTodos() as List <TipoFormulaInfo>; cmbTipoFormula.ItemsSource = (from tipo in tipos where tipo.Activo == EstatusEnum.Activo select tipo).ToList(); cmbTipoFormula.DisplayMemberPath = "Descripcion"; cmbTipoFormula.SelectedValuePath = "TipoFormulaID"; ucPaginacion.DatosDelegado += ObtenerListaIngrediente; ucPaginacion.AsignarValoresIniciales(); Buscar(); skAyudaOrganizacion.AsignarFoco(); } catch (ExcepcionGenerica) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.Ingrediente_ErrorCargar, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.Ingrediente_ErrorCargar, MessageBoxButton.OK, MessageImage.Error); } }