/// <summary> /// Método que obtiene un registro /// </summary> /// <param name="ds"></param> /// <returns></returns> internal static IngredienteInfo ObtenerPorDescripcion(DataSet ds) { try { Logger.Info(); DataTable dt = ds.Tables[ConstantesDAL.DtDatos]; IngredienteInfo entidad = (from info in dt.AsEnumerable() select new IngredienteInfo { IngredienteId = info.Field <int>("IngredienteID"), Organizacion = new OrganizacionInfo { OrganizacionID = info.Field <int>("OrganizacionID"), Descripcion = info.Field <string>("Organizacion") }, Formula = new FormulaInfo { FormulaId = info.Field <int>("FormulaID"), Descripcion = info.Field <string>("Formula") }, Producto = new ProductoInfo { ProductoId = info.Field <int>("ProductoID"), Descripcion = info.Field <string>("Producto") }, PorcentajeProgramado = info.Field <decimal>("PorcentajeProgramado"), Activo = info.Field <bool>("Activo").BoolAEnum(), }).First(); return(entidad); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
public static List <IngredienteInfo> ObtenerIngredientesFormula(int formulaId) { List <IngredienteInfo> listaIngredientes = new List <IngredienteInfo>(); try { SeguridadInfo seguridad = HttpContext.Current.Session["Seguridad"] as SeguridadInfo; if (seguridad != null) { var ingredientePl = new IngredientePL(); IngredienteInfo ingrediente = new IngredienteInfo(); ingrediente.Formula = new FormulaInfo() { FormulaId = formulaId }; ingrediente.Organizacion = new OrganizacionInfo() { OrganizacionID = seguridad.Usuario.Organizacion.OrganizacionID }; listaIngredientes = ingredientePl.ObtenerPorFormula(ingrediente, EstatusEnum.Activo); } } catch (ExcepcionDesconocida) { throw; } catch (Exception ex) { Logger.Error(ex); } return(listaIngredientes); }
/// <summary> /// Obtiene un registro de Ingrediente /// </summary> /// <param name="descripcion">Descripción de la Ingrediente</param> /// <returns></returns> internal IngredienteInfo ObtenerPorDescripcion(string descripcion) { try { Logger.Info(); Dictionary <string, object> parameters = AuxIngredienteDAL.ObtenerParametrosPorDescripcion(descripcion); DataSet ds = Retrieve("Ingrediente_ObtenerPorDescripcion", parameters); IngredienteInfo result = null; if (ValidateDataSet(ds)) { result = MapIngredienteDAL.ObtenerPorDescripcion(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 un registro de Ingrediente /// </summary> /// <param name="ingredienteID">Identificador de la Ingrediente</param> /// <returns></returns> internal IngredienteInfo ObtenerPorIdOrganizacionFormulaProducto(int formula, int ProductoId, int OrganizacionID) { try { Logger.Info(); Dictionary <string, object> parameters = AuxIngredienteDAL.ObtenerPorIdOrganizacionFormulaProducto(formula, ProductoId, OrganizacionID); DataSet ds = Retrieve("Ingrediente_ObtenerPorIdOrganizacionFormulaProducto", parameters); IngredienteInfo result = null; if (ValidateDataSet(ds)) { result = MapIngredienteDAL.ObtenerPorIDOrganizacionFormulaProducto(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 Ingrediente /// </summary> /// <param name="info"></param> public int Guardar(IngredienteInfo info) { try { Logger.Info(); var ingredienteDAL = new IngredienteDAL(); int result = info.IngredienteId; if (info.IngredienteId == 0) { result = ingredienteDAL.Crear(info); } else { ingredienteDAL.Actualizar(info); } return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene una lista de ingredientes /// Activo - Solo activos /// Inactivo - Solo inactivos /// Todos - Ambos /// </summary> /// <param name="ingrediente"></param> /// <param name="estatus"></param> /// <returns>Lista de IngredienteInfo</returns> internal List <IngredienteInfo> ObtenerPorFormula(IngredienteInfo ingrediente, EstatusEnum estatus) { List <IngredienteInfo> listaIngredientes = null; try { Logger.Info(); Dictionary <string, object> parameters = AuxIngredienteDAL.ObtenerParametrosPorFormula(ingrediente, estatus); DataSet ds = Retrieve("Ingrediente_ObtenerPorFormula", parameters); if (ValidateDataSet(ds)) { listaIngredientes = MapIngredienteDAL.ObtenerPorFormula(ds); } } catch (ExcepcionDesconocida) { throw; } catch (Exception ex) { Logger.Error(ex); } return(listaIngredientes); }
/// <summary> /// Metodo para Crear un registro de Ingrediente /// </summary> /// <param name="info">Valores de la entidad que será creada</param> internal int Crear(IngredienteInfo info) { try { Logger.Info(); Dictionary <string, object> parameters = AuxIngredienteDAL.ObtenerParametrosCrear(info); int result = Create("Ingrediente_Crear", parameters); 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 lista de ingredientes por formula /// Activo - Solo activos /// Inactivo - Solo inactivos /// Todos - Ambos /// </summary> /// <param name="ingrediente"></param> /// <param name="estatus"></param> /// <returns>Lista IngredienteInfo</returns> internal List <IngredienteInfo> ObtenerPorFormula(IngredienteInfo ingrediente, EstatusEnum estatus) { List <IngredienteInfo> listaIngredientes = null; List <IngredienteInfo> listaIngredientesRegreso = new List <IngredienteInfo>(); try { var ingredienteDal = new IngredienteDAL(); listaIngredientes = ingredienteDal.ObtenerPorFormula(ingrediente, estatus); if (listaIngredientes != null) { listaIngredientesRegreso.AddRange(listaIngredientes.Select(ingredienteInfo => ObtenerPorId(ingredienteInfo, estatus))); } } catch (ExcepcionDesconocida) { throw; } catch (Exception ex) { Logger.Error(ex); } return(listaIngredientesRegreso); }
/// <summary> /// Constructor parametrizado /// </summary> public IngredienteEdicionProducto(IngredienteInfo ingredienteProducto) { try { InitializeComponent(); IngredienteProducto = ingredienteProducto; IngredienteProducto.Producto.Familias = new List <FamiliaInfo> { new FamiliaInfo { FamiliaID = FamiliasEnum.MateriaPrimas.GetHashCode() }, new FamiliaInfo { FamiliaID = FamiliasEnum.Premezclas.GetHashCode() }, }; } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(this, Properties.Resources.IngredienteEdicionProducto_ErrorInicial, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Evento que se ejecuta cuando se da click en el boton Nuevo Producto /// </summary> private void BotonNuevoProducto_Click(object sender, RoutedEventArgs e) { try { var ingrediente = new IngredienteInfo { Producto = new ProductoInfo { //Descripcion = " ", SubFamilia = new SubFamiliaInfo(), Familia = new FamiliaInfo(), Familias = new List <FamiliaInfo> { new FamiliaInfo { FamiliaID = FamiliasEnum.MateriaPrimas.GetHashCode() }, new FamiliaInfo { FamiliaID = FamiliasEnum.Premezclas.GetHashCode() }, new FamiliaInfo { FamiliaID = FamiliasEnum.Alimento.GetHashCode() } }, }, PorcentajeProgramado = 0.0M, Activo = EstatusEnum.Activo, HabilitaEdicion = true, TieneCambios = true, UsuarioCreacionID = AuxConfiguracion.ObtenerUsuarioLogueado() }; Contexto.ListaIngredientes.Add(ingrediente); gridDatosProducto.ItemsSource = null; gridDatosProducto.ItemsSource = Contexto.ListaIngredientes; CargarGridIngredientes(); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(this, Properties.Resources.IngredienteEdicionProducto_ErrorNuevo, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Obtiene un ingrediente con su detalle /// Activo - Solo activos /// Inactivo - Solo inactivos /// Todos - Ambos /// </summary> /// <returns>IngredienteInfo</returns> public IngredienteInfo ObtenerPorId(IngredienteInfo ingrediente, EstatusEnum estatus) { try { var ingredienteBl = new IngredienteBL(); ingrediente = ingredienteBl.ObtenerPorId(ingrediente, estatus); } catch (ExcepcionDesconocida) { throw; } catch (Exception ex) { Logger.Error(ex); } return(ingrediente); }
/// <summary> /// Obtiene los parametros para obtener por id /// </summary> /// <param name="ingrediente"></param> /// <param name="estatus"></param> /// <returns></returns> internal static Dictionary <string, object> ObtenerParametrosPorId(IngredienteInfo ingrediente, EstatusEnum estatus) { try { Logger.Info(); var parametros = new Dictionary <string, object> { { "@IngredienteID", ingrediente.IngredienteId }, { "@Activo", estatus } }; return(parametros); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene la lista para mostrar en el grid /// </summary> private void ObtenerListaIngrediente(int inicio, int limite) { try { if (ucPaginacion.ContextoAnterior != null) { bool contextosIguales = ucPaginacion.CompararObjetos(Contexto, ucPaginacion.ContextoAnterior); if (!contextosIguales) { ucPaginacion.Inicio = 1; inicio = 1; } } var ingredientePL = new IngredientePL(); IngredienteInfo filtros = ObtenerFiltros(); var pagina = new PaginacionInfo { Inicio = inicio, Limite = limite }; //ResultadoInfo<FormulaInfo> resultadoInfo = ingredientePL.ObtenerPorPaginaFormula(pagina, filtros); ResultadoInfo <FormulaInfo> resultadoInfo = ingredientePL.ObtenerPorPaginaFormulaOrganizacion(pagina, filtros); if (resultadoInfo != null && resultadoInfo.Lista != null && resultadoInfo.Lista.Count > 0) { gridDatos.ItemsSource = resultadoInfo.Lista; ucPaginacion.TotalRegistros = resultadoInfo.TotalRegistros; } else { ucPaginacion.TotalRegistros = 0; ucPaginacion.AsignarValoresIniciales(); gridDatos.ItemsSource = new List <Ingrediente>(); } } catch (ExcepcionGenerica) { SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.Ingrediente_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error); } catch (Exception ex) { Logger.Error(ex); SkMessageBox.Show(Application.Current.Windows[ConstantesVista.WindowPrincipal], Properties.Resources.Ingrediente_ErrorBuscar, MessageBoxButton.OK, MessageImage.Error); } }
/// <summary> /// Metodo para Guardar/Modificar una entidad Ingrediente /// </summary> /// <param name="info">Representa la entidad que se va a grabar</param> public int Guardar(IngredienteInfo info) { try { Logger.Info(); var ingredienteBL = new IngredienteBL(); int result = ingredienteBL.Guardar(info); return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene una entidad Ingrediente por su descripción /// </summary> /// <param name="descripcion"></param> /// <returns></returns> public IngredienteInfo ObtenerPorDescripcion(string descripcion) { try { Logger.Info(); var ingredienteDAL = new IngredienteDAL(); IngredienteInfo result = ingredienteDAL.ObtenerPorDescripcion(descripcion); return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene una entidad Ingrediente por su Id /// </summary> /// <param name="ingredienteID">Obtiene una entidad Ingrediente por su Id</param> /// <returns></returns> public IngredienteInfo ObtenerPorIdOrganizacionFormulaProducto(int formula, int ProductoId, int OrganizacionID) { try { Logger.Info(); var ingredienteDAL = new IngredienteDAL(); IngredienteInfo result = ingredienteDAL.ObtenerPorIdOrganizacionFormulaProducto(formula, ProductoId, OrganizacionID); return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene una lista de ingredientes por formula /// Activo - Solo activos /// Inactivo - Solo inactivos /// Todos - Ambos /// </summary> /// <param name="ingrediente"></param> /// <param name="estatus"></param> /// <returns>Lista de IngredienteInfo</returns> public List <IngredienteInfo> ObtenerPorFormula(IngredienteInfo ingrediente, EstatusEnum estatus) { List <IngredienteInfo> listaIngredientes = null; try { var ingredienteBl = new IngredienteBL(); listaIngredientes = ingredienteBl.ObtenerPorFormula(ingrediente, estatus); } catch (ExcepcionDesconocida) { throw; } catch (Exception ex) { Logger.Error(ex); } return(listaIngredientes); }
/// <summary> /// Obtiene un ingrediente con su detalle /// Activo - Solo activos /// Inactivo - Solo inactivos /// Todos - Ambos /// </summary> /// <returns>IngredienteInfo</returns> internal IngredienteInfo ObtenerPorId(IngredienteInfo ingrediente, EstatusEnum estatus) { try { var ingredienteDal = new IngredienteDAL(); ingrediente = ingredienteDal.ObtenerPorId(ingrediente, estatus); if (ingrediente != null) { if (ingrediente.Organizacion.OrganizacionID > 0) { var organizacionBl = new OrganizacionBL(); ingrediente.Organizacion = organizacionBl.ObtenerPorID(ingrediente.Organizacion.OrganizacionID); } if (ingrediente.Formula.FormulaId > 0) { var formulaBl = new FormulaBL(); ingrediente.Formula = formulaBl.ObtenerPorID(ingrediente.Formula.FormulaId); } if (ingrediente.Producto.ProductoId > 0) { var productoBl = new ProductoBL(); ingrediente.Producto = productoBl.ObtenerPorID(ingrediente.Producto); } } } catch (ExcepcionDesconocida) { throw; } catch (Exception ex) { Logger.Error(ex); } return(ingrediente); }
/// <summary> /// Inicializa el Contexto /// </summary> private void InicializaContexto() { Contexto = new IngredienteInfo { UsuarioCreacionID = AuxConfiguracion.ObtenerUsuarioLogueado(), Formula = new FormulaInfo { Descripcion = " ", FormulaId = 0, TipoFormula = new TipoFormulaInfo() }, Producto = new ProductoInfo(), Organizacion = new OrganizacionInfo { TipoOrganizacion = new TipoOrganizacionInfo { TipoOrganizacionID = 3 } } //{ // OrganizacionID = AuxConfiguracion.ObtenerOrganizacionUsuario() //} }; }
/// <summary> /// Obtiene parametros para crear /// </summary> /// <param name="info">Valores de la entidad</param> /// <returns></returns> internal static Dictionary <string, object> ObtenerParametrosCrear(IngredienteInfo info) { try { Logger.Info(); var parametros = new Dictionary <string, object> { { "@OrganizacionID", info.Organizacion.OrganizacionID }, { "@FormulaID", info.Formula.FormulaId }, { "@ProductoID", info.Producto.ProductoId }, { "@PorcentajeProgramado", info.PorcentajeProgramado }, { "@Activo", info.Activo }, { "@UsuarioCreacionID", info.UsuarioCreacionID }, }; return(parametros); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene un ingrediente por id /// Activo - Solo activos /// Inactivo - Solo inactivos /// Todos - Ambos /// </summary> /// <param name="ingrediente"></param> /// <param name="estatus"></param> /// <returns></returns> internal IngredienteInfo ObtenerPorId(IngredienteInfo ingrediente, EstatusEnum estatus) { try { Logger.Info(); Dictionary <string, object> parameters = AuxIngredienteDAL.ObtenerParametrosPorId(ingrediente, estatus); DataSet ds = Retrieve("Ingrediente_ObtenerPorID", parameters); if (ValidateDataSet(ds)) { ingrediente = MapIngredienteDAL.ObtenerPorId(ds); } } catch (ExcepcionDesconocida) { throw; } catch (Exception ex) { Logger.Error(ex); } return(ingrediente); }
/// <summary> /// Metodo para actualizar un registro de Ingrediente /// </summary> /// <param name="info">Valores de la entidad que se actualizarán</param> internal void Actualizar(IngredienteInfo info) { try { Logger.Info(); Dictionary <string, object> parameters = AuxIngredienteDAL.ObtenerParametrosActualizar(info); Update("Ingrediente_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); } }
public List <ProduccionFormulaDetalleInfo> CrearListaProduccionFormulaDetalle(List <ProcesarArchivoInfo> lista, string formula) { var seguridad = (SeguridadInfo)ObtenerSeguridad(); var listaGlobalFormulaDetalle = new List <ProduccionFormulaDetalleInfo>(); var ingredientePL = new IngredientePL(); try { //sacamos los Productos var Prod = from w in lista where w.Formula == formula && w.Marca != "2" group w by w.Codigo into g select new { FirstLetter = g.Key, Words = g }; var formulaPL = new FormulaPL(); var formulasTodas = formulaPL.ObtenerTodos(EstatusEnum.Activo); foreach (var produccion in Prod) { var produccionFormulaDetalle = new ProduccionFormulaDetalleInfo(); List <ProcesarArchivoInfo> listafltrada = lista.Where(k => k.Formula == formula && k.Codigo == produccion.FirstLetter).ToList(); decimal cantidad = (from prod in listafltrada select prod.Real).Sum(); produccionFormulaDetalle.Producto = new ProductoInfo { ProductoId = int.Parse(produccion.FirstLetter) }; produccionFormulaDetalle.CantidadProducto = cantidad; produccionFormulaDetalle.Activo = EstatusEnum.Activo; var formulaExiste = formulasTodas.FirstOrDefault( fo => fo.Descripcion.ToUpper().Trim().Equals(formula.ToUpper().Trim(), StringComparison.InvariantCultureIgnoreCase)); if (formulaExiste == null) { formulaExiste = new FormulaInfo(); } IngredienteInfo ingredienteInfo = ingredientePL.ObtenerPorIdOrganizacionFormulaProducto(formulaExiste.FormulaId, int.Parse(produccion.FirstLetter), seguridad.Usuario.Organizacion.OrganizacionID); if (ingredienteInfo == null) { return(null); } produccionFormulaDetalle.Ingrediente = ingredienteInfo; listaGlobalFormulaDetalle.Add(produccionFormulaDetalle); } } catch (Exception er) { Logger.Error(er); return(null); } return(listaGlobalFormulaDetalle); }
/// <summary> /// Obtiene un lista paginada /// </summary> /// <param name="pagina"></param> /// <param name="filtro"></param> /// <returns></returns> public ResultadoInfo <FormulaInfo> ObtenerPorPaginaFormula(PaginacionInfo pagina, IngredienteInfo filtro) { try { Logger.Info(); var ingredienteDAL = new IngredienteDAL(); ResultadoInfo <FormulaInfo> result = ingredienteDAL.ObtenerPorPaginaFormula(pagina, filtro); return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene parametros para obtener lista paginada /// </summary> /// <param name="pagina"></param> /// <param name="filtro"></param> /// <returns></returns> internal static Dictionary <string, object> ObtenerParametrosPorPaginaFormulaOrganizacion(PaginacionInfo pagina, IngredienteInfo filtro) { try { Logger.Info(); var parametros = new Dictionary <string, object> { { "@OrganizacionID", filtro.Organizacion != null ? filtro.Organizacion.OrganizacionID : 0 }, { "@TipoFormulaID", filtro.Formula != null && filtro.Formula.TipoFormula != null ? filtro.Formula.TipoFormula.TipoFormulaID : 0 }, { "@ProductoID", filtro.Producto != null ? filtro.Producto.ProductoId : 0 }, { "@FormulaID", filtro.Formula != null ? filtro.Formula.FormulaId : 0 }, { "@Activo", filtro.Activo }, { "@Inicio", pagina.Inicio }, { "@Limite", pagina.Limite } }; return(parametros); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene un lista paginada /// </summary> /// <param name="pagina"></param> /// <param name="filtro"></param> /// <returns></returns> internal ResultadoInfo <FormulaInfo> ObtenerPorPaginaFormula(PaginacionInfo pagina, IngredienteInfo filtro) { try { Dictionary <string, object> parameters = AuxIngredienteDAL.ObtenerParametrosPorPaginaFormula(pagina, filtro); DataSet ds = Retrieve("Ingrediente_ObtenerPorPaginaFormula", parameters); ResultadoInfo <FormulaInfo> result = null; if (ValidateDataSet(ds)) { result = MapIngredienteDAL.ObtenerPorPaginaFormula(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 parametros para obtener lista paginada /// </summary> /// <param name="pagina"></param> /// <param name="filtro"></param> /// <returns></returns> internal static Dictionary <string, object> ObtenerParametrosPorPagina(PaginacionInfo pagina, IngredienteInfo filtro) { try { Logger.Info(); var parametros = new Dictionary <string, object> { { "@IngredienteID", filtro.IngredienteId }, { "@OrganizacionID", filtro.Organizacion.OrganizacionID }, { "@Activo", filtro.Activo }, { "@Inicio", pagina.Inicio }, { "@Limite", pagina.Limite } }; return(parametros); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
// Update is called once per frame void Update() { PlayerPrefs.Save(); if (PlayerPrefs.GetString("PoP") == "Sim") { MakePopUp(); } if (stateGame == StateGameMulti.INGREDIENTEFASE) { if (ingredientesCanvas.activeSelf == false) { //gameObject.SendMessage("IngreVisit"); ingredientesCanvas.SetActive(true); receitaCanvas.SetActive(false); pontuacaoCanvas.SetActive(false); } for (int i = 0; i < textButtonsGame.Length; i++) { if (i == 0) { textButtonsGame[i].gameObject.SetActive(true); textButtonsGame[i].interactable = false; } else if (i < 4) { textButtonsGame[i].gameObject.SetActive(false); } if (i == 4) { if (actualIngrediente == 0) { textButtonsGame[i].interactable = false; } else { textButtonsGame[i].interactable = true; } } if (i == 5) { textButtonsGame[i].interactable = true; } } ingredienteCatch = (Resources.Load("Ingredientes/" + actualReceita.Ingredientes[actualIngrediente]) as GameObject).GetComponent <Ingrediente>().ingredienteInfo; imageIngre.sprite = ingredienteCatch.imageIngrediente; imageCircle.enabled = true; imageIngre.enabled = true; desafioText.enabled = true; if (mudaDesafio) { desafioCatch = Resources.LoadAll <GameObject>("Desafios/" + actualReceita.Ingredientes[actualIngrediente] + "/"); randomDesafio = (int)Random.Range(0, desafioCatch.Length); desafio = desafioCatch[randomDesafio].GetComponent <DesafioInfo>().desafio; desafiosLevel.Add(desafio); mudaDesafio = false; } if (changeTexts) { ChangeTexts(); } } else { imageIngre.enabled = false; imageCircle.enabled = false; desafioText.enabled = false; } if (stateGame == StateGameMulti.RECEITAFASE) { receitaCanvas.SetActive(true); ingredientesCanvas.SetActive(false); pontuacaoCanvas.SetActive(false); for (int i = 0; i < textButtonsGame.Length; i++) { textButtonsGame[i].gameObject.SetActive(true); if (i == 5) { textButtonsGame[i].interactable = false; } else { textButtonsGame[i].interactable = true; } } if (changeTexts) { ChangeTexts(); } } if (stateGame == StateGameMulti.PONTUACAOFASE) { ingredientesCanvas.SetActive(false); receitaCanvas.SetActive(false); pontuacaoCanvas.SetActive(true); if (!contandoPonto) { ContaPonto(); fimPontuacao.text = ""; nextLevel.gameObject.SetActive(false); } } else { pontuacaoCanvas.SetActive(false); } }
public void ChangeTexts() { if (stateGame == StateGameSingle.DISCASFASE) { for (int i = 0; i < dicaSlots.Length; i++) { for (int y = 0; y < dicasCatch.Length; y++) { if (dicasCatch[y].GetComponent <Dicas>().dicas.ingredienteName == actualReceita.Ingredientes[actualIngrediente]) { dicaSlots[i].GetComponentInChildren <Text>().text = dicasCatch[y].GetComponent <Dicas>().dicas.dicas[i]; } } } for (int i = 0; i < dicaSlots.Length; i++) { if (i >= dicasLiberadas) { if (i == 0) { if (dicasLiberadas == 0) { } } else { dicaSlots[i].GetComponentInChildren <Text>().text = "Revelar Dica"; } } } } if (stateGame == StateGameSingle.INGREDIENTEFASE) { for (int i = 0; i < textButtonsGame.Length; i++) { if (i == correctButtonIngre) { textIngre[i].GetComponentInChildren <Text>().text = actualReceita.Ingredientes[actualIngrediente]; } else if (i < 4) { GameObject ingredientesRandom = Resources.Load <GameObject>("Ingredientes/" + actualReceita.Ingredientes[actualIngrediente]); print(ingredientesRandom.name); IngredienteInfo random = ingredientesRandom.GetComponent <Ingrediente>().ingredienteInfo; textIngre[i].GetComponentInChildren <Text>().text = random.randomIngre[i]; } } } if (stateGame == StateGameSingle.RECEITAFASE) { for (int i = 0; i < textButtonsGame.Length; i++) { if (i == correctButton) { textButtonsGame[i].GetComponentInChildren <Text>().text = actualReceita.NomeDaReceita; } else if (i < 4) { textButtonsGame[i].GetComponentInChildren <Text>().text = actualReceita.random[i]; } } } changeTexts = false; }