Example #2
0

        
Example #3
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CategoriaMenuDAO categoriaMenuDao = new CategoriaMenuDAO();

            try
            {
                var result = await categoriaMenuDao.GetAll();

                BindableCollection <CategoriaMenu> lista = new BindableCollection <CategoriaMenu>(result);

                //opcion por defecto combobox
                CategoriaMenu defaultCB = new CategoriaMenu
                {
                    cat_menu_id     = 0,
                    cat_menu_nombre = "Seleccionar",
                    cat_fase        = 0
                };
                //insertar en la primera posición
                lista.Insert(0, defaultCB);

                categoriaCB.ItemsSource   = lista;
                categoriaCB.SelectedIndex = 0;
            }
            catch (Exception)
            {
                MessageBox.Show("Error al cargar listado Categoría");
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            CategoriaMenu categoriaMenu = db.TiposDePlatillo.Find(id);

            db.TiposDePlatillo.Remove(categoriaMenu);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CategoriaMenuDAO categoriaMenuDao = new CategoriaMenuDAO();
            MenuItemDAO      menuItemDao      = new MenuItemDAO();

            try
            {
                //datos combobox
                var combobox = await categoriaMenuDao.GetAll();

                BindableCollection <CategoriaMenu> lista = new BindableCollection <CategoriaMenu>(combobox);
                categoriaCB.ItemsSource = lista;

                //opcion por defecto combobox
                CategoriaMenu defaultCB = new CategoriaMenu
                {
                    cat_menu_id     = 0,
                    cat_menu_nombre = "Seleccionar",
                    cat_fase        = 0
                };
                //insertar en la primera posición
                lista.Insert(0, defaultCB);

                //datos menuitem por id
                var menuItem = await menuItemDao.GetById(this.item_id);

                //obtener el nombre de la categoria
                string nombreCategoria = (from c in lista
                                          where c.cat_menu_id == menuItem.cat_menu_id
                                          select new
                {
                    c.cat_menu_nombre
                }).FirstOrDefault().cat_menu_nombre;

                //identificar la posicion en el combobox
                int indice = 0;

                for (int i = 0; i < lista.Count; i++)
                {
                    string opcion = lista[i].cat_menu_nombre;
                    if (opcion.Equals(nombreCategoria))
                    {
                        indice = i;
                    }
                }


                categoriaCB.SelectedIndex = indice;
                txtNombre.Text            = menuItem.item_nombre;
                txtDescripcion.Text       = menuItem.item_desc;
                txtValor.Text             = menuItem.item_val.ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("Error al cargar datos en Actualizar");
            }
        }
 public ActionResult Edit([Bind(Include = "Id,CodigoTipoPlatillo,DescripcionTipoPlatillo,EstadoTipoPlatillo")] CategoriaMenu categoriaMenu)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categoriaMenu).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categoriaMenu));
 }
        public ActionResult Create([Bind(Include = "Id,CodigoTipoPlatillo,DescripcionTipoPlatillo,EstadoTipoPlatillo")] CategoriaMenu categoriaMenu)
        {
            if (ModelState.IsValid)
            {
                db.TiposDePlatillo.Add(categoriaMenu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categoriaMenu));
        }
Example #8
0
        private async void btnActualizar_Click(object sender, RoutedEventArgs e)
        {
            CategoriaMenu selectedCategoria = this.categoriaCB.SelectedItem as CategoriaMenu;
            string        nombre;
            string        descripcion;

            nombre      = txtNombre.Text;
            descripcion = txtDescripcion.Text;
            int valor = Int32.Parse(txtValor.Text);


            MenuItemDAO dao = new MenuItemDAO();

            //var listadoMenu = await dao.GetAll();
            //var result = (from u in listadoMenu
            //              where u.item_nombre == nombre
            //              select new
            //              {
            //                  u.cat_menu_id
            //              }).FirstOrDefault();

            //if (result != null)
            //{

            //    MessageBox.Show("Menú ya Existe");
            //    this.Close();

            //}

            //else
            try
            {
                Entities.MenuItem obj = new Entities.MenuItem()
                {
                    item_id     = this.item_id,
                    cat_menu_id = selectedCategoria.cat_menu_id,
                    item_nombre = nombre,
                    item_desc   = descripcion,
                    item_val    = valor
                };
                var response = await dao.Update(obj);

                MessageBox.Show("Item Menú Actualizado Exitosamente", "Result", MessageBoxButton.OK, MessageBoxImage.Information);

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Item Menú no Actualizado");
            }
        }
Example #9
0

        
        // GET: CategoriasMenu/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CategoriaMenu categoriaMenu = db.TiposDePlatillo.Find(id);

            if (categoriaMenu == null)
            {
                return(HttpNotFound());
            }
            return(View(categoriaMenu));
        }
Example #11
0
        private async void btnGuardar_Click(object sender, RoutedEventArgs e)
        {
            CategoriaMenu selectedCategoria = this.categoriaCB.SelectedItem as CategoriaMenu;
            string        nombre;
            string        descripcion;
            int           valor;

            nombre      = txtNombre.Text;
            descripcion = txtDescripcion.Text;
            valor       = Int32.Parse(txtValor.Text);

            MenuItemDAO dao         = new MenuItemDAO();
            var         listadoMenu = await dao.GetAll();

            var result = (from u in listadoMenu
                          where u.item_nombre == nombre
                          select new
            {
                u.cat_menu_id
            }).FirstOrDefault();

            if (result != null)
            {
                MessageBox.Show("Menú ya Existe");
                this.Close();
            }

            else
            {
                try
                {
                    Entities.MenuItem obj = new Entities.MenuItem()
                    {
                        cat_menu_id = selectedCategoria.cat_menu_id,
                        item_nombre = nombre,
                        item_desc   = descripcion,
                        item_val    = valor
                    };
                    var response = await dao.Save(obj);

                    MessageBox.Show("Item Menú Añadido Exitosamente", "Result", MessageBoxButton.OK, MessageBoxImage.Information);
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Item Menú no Añadido, Podría Existir Duplicidad de ID");
                }
            }
        }
        public JsonResult AddCategoria(CategoriaWS categoriaWS)
        {
            CategoriaMenu categoria   = db.TiposDePlatillo.DefaultIfEmpty(null).FirstOrDefault(x => x.CodigoTipoPlatillo == categoriaWS.codigo);
            ResultadoWS   resultadoWS = new ResultadoWS();

            if (categoria == null)
            {
                categoria = new CategoriaMenu();
                categoria.CodigoTipoPlatillo      = categoriaWS.codigo;
                categoria.DescripcionTipoPlatillo = categoriaWS.descripcion;
                categoria.EstadoTipoPlatillo      = categoriaWS.estado;

                db.TiposDePlatillo.Add(categoria);

                int safe = db.SaveChanges();

                if (safe > 0)
                {
                    resultadoWS.Mensaje   = "Agregado correctamente";
                    resultadoWS.Resultado = true;
                    return(Json(resultadoWS));
                }
                else
                {
                    resultadoWS.Mensaje   = "Error al guardar";
                    resultadoWS.Resultado = false;

                    return(Json(resultadoWS));
                }
            }

            resultadoWS.Mensaje   = "Ya existe ese Codigo";
            resultadoWS.Resultado = false;

            return(Json(resultadoWS));
        }