public async Task <IActionResult> Manage(ProductoFinal ProductoFinal)
        {
            try
            {
                ViewBag.accion = ProductoFinal.ProductoFinalId == 0 ? "Crear" : "Editar";
                if (ModelState.IsValid)
                {
                    await cargarCombos();

                    var existeRegistro = false;
                    if (ProductoFinal.ProductoFinalId == 0)
                    {
                        if (!await db.ProductoFinal.AnyAsync(c => c.Codigo.ToUpper().Trim() == ProductoFinal.Codigo.ToUpper().Trim() && c.ProductoId == ProductoFinal.ProductoId))
                        {
                            await db.AddAsync(ProductoFinal);
                        }

                        else
                        {
                            existeRegistro = true;
                        }
                    }
                    else
                    {
                        if (!await db.ProductoFinal.Where(c => c.Codigo.ToUpper().Trim() == ProductoFinal.Codigo.ToUpper().Trim() && c.ProductoId == ProductoFinal.ProductoId).AnyAsync(c => c.ProductoFinalId != ProductoFinal.ProductoFinalId))
                        {
                            var CurrentProductoFinal = await db.ProductoFinal.Where(x => x.ProductoFinalId == ProductoFinal.ProductoFinalId).FirstOrDefaultAsync();

                            CurrentProductoFinal.Codigo      = ProductoFinal.Codigo;
                            CurrentProductoFinal.Descripcion = ProductoFinal.Descripcion;
                        }
                        else
                        {
                            existeRegistro = true;
                        }
                    }
                    if (!existeRegistro)
                    {
                        await db.SaveChangesAsync();

                        return(this.Redireccionar($"{Mensaje.MensajeSatisfactorio}|{Mensaje.Satisfactorio}"));
                    }
                    else
                    {
                        TempData["Mensaje"] = $"{Mensaje.Error}|{Mensaje.ExisteRegistro}";
                    }
                    return(View(ProductoFinal));
                }

                return(View(ProductoFinal));
            }
            catch (Exception)
            {
                return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.Excepcion}"));
            }
        }
Beispiel #2
0
        private void Menu_KeyUp(object sender, KeyEventArgs e)
        {
            //CTRL+E
            if (Convert.ToInt32(e.KeyData) == Convert.ToInt32(Keys.Control) + Convert.ToInt32(Keys.E))
            {
                Empleados em = new Empleados();
                em.Show();
                //this.Close();
            }

            //CTRL+M
            if (Convert.ToInt32(e.KeyData) == Convert.ToInt32(Keys.Control) + Convert.ToInt32(Keys.M))
            {
                MateriaPrima mp = new MateriaPrima();
                mp.Show();
                //this.Close();
            }

            //CTRL+N
            if (Convert.ToInt32(e.KeyData) == Convert.ToInt32(Keys.Control) + Convert.ToInt32(Keys.N))
            {
                ProductoFinal cp = new ProductoFinal();
                cp.Show();
                //this.Close();
            }

            //CTRL+B
            if (Convert.ToInt32(e.KeyData) == Convert.ToInt32(Keys.Control) + Convert.ToInt32(Keys.B))
            {
                Compra p = new Compra();
                p.Show();
                //this.Close();
            }

            //CTRL+L
            if (Convert.ToInt32(e.KeyData) == Convert.ToInt32(Keys.Control) + Convert.ToInt32(Keys.L))
            {
                Venta v = new Venta();
                v.Show();
                //this.Close();
            }

            //CTRL+K
            if (Convert.ToInt32(e.KeyData) == Convert.ToInt32(Keys.Control) + Convert.ToInt32(Keys.K))
            {
                Pedidos p = new Pedidos();
                p.Show();
                //this.Close();
            }
        }
Beispiel #3
0
        private void btProducto_Click(object sender, EventArgs e)
        {
            ProductoFinal pf = new ProductoFinal();

            pf.Show();
        }