Example #1
0
        public bool Update(Ingredientes ingredientes)
        {
            bool State = false;

            cmd.CommandText = "UPDATE T_INGREDIENTES SET Nome = @Nome, Unidade_Medida = @Unidade_Medida, Descricao = @Descricao, QTD = @QTD WHERE Codigo = @Codigo;";

            cmd.Parameters.AddWithValue("@Codigo", ingredientes.Codigo);
            cmd.Parameters.AddWithValue("@Nome", ingredientes.nome);
            cmd.Parameters.AddWithValue("@Unidade_Medida", ingredientes.unidadeMedida);
            cmd.Parameters.AddWithValue("@Descricao", ingredientes.descricao);
            cmd.Parameters.AddWithValue("@QTD", ingredientes.quantidade);

            try
            {
                cmd.Connection = connectionFactory.OpenConnection();
                cmd.ExecuteNonQuery();
                connectionFactory.CloseConnection();
                State = true;
            }
            catch (SqlException err)
            {
                MessageBox.Show(err.ToString());
            }
            return(State);
        }
Example #2
0
        public static List <Ingredientes> toList()
        {
            ConnectionFactory   connectionFactory = new ConnectionFactory(@"DESKTOP - IS3QU5U\SQLEXPRESS01", "GeekBurguer");
            Ingredientes        ingrediente;
            List <Ingredientes> listaIngredientes = new List <Ingredientes>();

            string sql = "SELECT * FROM T_INGREDIENTES";

            SqlConnection con = connectionFactory.OpenConnection();
            SqlCommand    cmd = new SqlCommand(sql, con);

            SqlDataReader rd;

            try
            {
                rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    ingrediente                  = new Ingredientes();
                    ingrediente.setCodigo        = Convert.ToInt32(rd["Codigo"].ToString());
                    ingrediente.setNome          = rd["Nome"].ToString();
                    ingrediente.setUnidadeMedida = rd["Unidade_Medida"].ToString();
                    ingrediente.setDescricao     = rd["Descricao"].ToString();
                    ingrediente.setQuantidade    = Convert.ToDouble(rd["QTD"].ToString());
                    listaIngredientes.Add(ingrediente);
                }
                connectionFactory.CloseConnection();
            }
            catch (SqlException err)
            {
                Console.WriteLine(err.ToString());
                listaIngredientes = null;
            }
            return(listaIngredientes);
        }
Example #3
0
        public Ingredientes Read(int Codigo)
        {
            Ingredientes ingredientes = new Ingredientes();

            string sql = "SELECT * FROM T_INGREDIENTES WHERE Codigo = @Codigo";

            SqlConnection con = connectionFactory.OpenConnection();
            SqlCommand    cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@Codigo", Codigo);
            SqlDataReader rd;

            try
            {
                rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    ingredientes.setCodigo        = Convert.ToInt32(rd["Codigo"].ToString());
                    ingredientes.setNome          = rd["Nome"].ToString();
                    ingredientes.setUnidadeMedida = rd["Unidade_Medida"].ToString();
                    ingredientes.setDescricao     = rd["Descricao"].ToString();
                    ingredientes.setQuantidade    = Convert.ToDouble(rd["QTD"].ToString());
                }
                connectionFactory.CloseConnection();
            }
            catch (SqlException err)
            {
                Console.WriteLine(err.ToString());
                ingredientes = null;
            }
            return(ingredientes);
        }
Example #4
0
        public HttpResponseMessage Post(Ingredientes varIngredientes)
        {
            if (ModelState.IsValid)
            {
                var data = "-1";
                try
                {
                    data = Convert.ToString(this.service.Insert(varIngredientes));
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, Convert.ToInt32(data), BitacoraHelper.TypeSql.INSERT, "sp_InsIngredientes", new JavaScriptSerializer().Serialize(varIngredientes), true);
                    serviceBitacora.Insert(bitacora);
                }
                catch (ServiceException ex)
                {
                    var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsIngredientes", new JavaScriptSerializer().Serialize(varIngredientes), true);
                    serviceBitacora.Insert(bitacora);
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, data, Configuration.Formatters.JsonFormatter));
            }
            else
            {
                var errors   = ModelState.SelectMany(m => m.Value.Errors.Select(err => err.ErrorMessage != string.Empty ? err.ErrorMessage : err.Exception.Message).ToList()).ToList();
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, 0, BitacoraHelper.TypeSql.INSERT, "sp_InsIngredientes", new JavaScriptSerializer().Serialize(varIngredientes), false, errors.ToString());
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
            }
        }
Example #5
0
        public HttpResponseMessage Delete(int id)
        {
            Ingredientes varIngredientes = this.service.GetByKey(id, false);
            bool         result          = false;

            if (varIngredientes == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            try
            {
                result = this.service.Delete(id);//, globalData, dataReference);
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelIngredientes", new JavaScriptSerializer().Serialize(varIngredientes), result);
                serviceBitacora.Insert(bitacora);
            }
            catch (ServiceException ex)
            {
                var bitacora = BitacoraHelper.GetBitacora(Request, object_id, id, BitacoraHelper.TypeSql.DELETE, "sp_DelIngredientes", new JavaScriptSerializer().Serialize(varIngredientes), result, ex.Message);
                serviceBitacora.Insert(bitacora);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, result));
        }
Example #6
0
        public HttpResponseMessage Get_Datos_Generales(int id)
        {
            Ingredientes entity = this.service.ListaSelAll(1, 1, "Ingredientes.Clave='" + id.ToString() + "'", "").Ingredientess.First();
            Ingredientes result = new Ingredientes();

            result.Clave = entity.Clave;
            result.Es_un_ingrediente_de_SMAE = entity.Es_un_ingrediente_de_SMAE;
            result.Clasificacion             = entity.Clasificacion;
            result.Clasificacion_Clasificacion_Ingredientes = entity.Clasificacion_Clasificacion_Ingredientes;
            result.Subgrupo = entity.Subgrupo;
            result.Subgrupo_Subgrupos_Ingredientes = entity.Subgrupo_Subgrupos_Ingredientes;
            result.Nombre_Ingrediente           = entity.Nombre_Ingrediente;
            result.Ingrediente                  = entity.Ingrediente;
            result.Imagen                       = entity.Imagen;
            result.Imagen_Spartane_File         = entity.Imagen_Spartane_File;
            result.Cantidad_sugerida            = entity.Cantidad_sugerida;
            result.Cantidad_Sugerida_Decimal    = entity.Cantidad_Sugerida_Decimal;
            result.Unidad                       = entity.Unidad;
            result.Unidad_Unidades_de_Medida    = entity.Unidad_Unidades_de_Medida;
            result.Peso_bruto_redondeado_g      = entity.Peso_bruto_redondeado_g;
            result.Peso_neto_g                  = entity.Peso_neto_g;
            result.Estatus                      = entity.Estatus;
            result.Estatus_Estatus_Ingredientes = entity.Estatus_Estatus_Ingredientes;

            return(Request.CreateResponse(HttpStatusCode.OK, result, Configuration.Formatters.JsonFormatter));
        }
Example #7
0
        /******************************************************************** LISTAR INGREDIENTE - ALTERAR INGREDIENTE F ********************************************************************/
        public List <Ingrediente> IngredienteF()
        {
            //SqlConnection Conexao = new SqlConnection(ConfigurationManager.ConnectionStrings["BancoEstoque"].ConnectionString);
            SqlConnection Conexao = new SqlConnection("Server = DESKTOP-PHTQI5U\\SQLEXPRESS; Database = DRLTCC; Trusted_Connection = True;");

            Conexao.Open();
            SqlCommand Comando = new SqlCommand();

            Comando.Connection = Conexao;

            Comando.CommandText = "SELECT CodigoIngrediente, NomeIngrediente FROM Ingrediente;";

            SqlDataReader Leitor = Comando.ExecuteReader();

            while (Leitor.Read())
            {
                Ingrediente I = new Ingrediente();
                I.CodigoIngrediente = Convert.ToInt32(Leitor["CodigoIngrediente"].ToString());
                I.NomeIngrediente   = Leitor["NomeIngrediente"].ToString();

                Ingredientes.Add(I);
            }
            Conexao.Close();

            return(Ingredientes);
        }
Example #8
0
        private void cmbCriticos_SelectedIndexChanged(object sender, EventArgs e)
        {
            string select = cmbCriticos.Text;

            tblInv.Rows.Clear();
            TipoCritico     tipoLocal  = listatiposCriticos.Where(tipo => tipo.descripcion == select).FirstOrDefault();
            IList <Critico> listaLocal = lCriticos.Where(tipo => tipo.idTipoCritico == tipoLocal.idTipoCritico).ToList();

            foreach (Critico cit in listaLocal)
            {
                InventarioIng localinv   = listaInventario.Where(inv => inv.idIngrediente == cit.idProducto).FirstOrDefault();
                Ingredientes  localIngre = listaIngredientes.Where(ingre => ingre.idIngrediente == cit.idProducto).FirstOrDefault();

                string fecha, invInic, entradas, salidas, mermas, invFin, min, max;
                fecha    = localinv.fecha;
                invInic  = localinv.inventarioInicial.ToString();
                entradas = localinv.entradas.ToString();
                salidas  = localinv.salidas.ToString();
                mermas   = localinv.mermas.ToString();
                invFin   = localinv.inventarioFinal.ToString();
                min      = localinv.minimo.ToString();
                max      = localinv.maximo.ToString();
                //Ingredientes localIng = listaIngredientes.Where(ing => ing.idIngrediente == ingrediente.idIngrediente).FirstOrDefault();
                string producto = localIngre.descripcion;
                string unidadM  = localIngre.unidadMedida;
                tblInv.Rows.Add(fecha, producto, invInic, unidadM, entradas, salidas, mermas, invFin, min, max);
            }
        }
Example #9
0
        public IActionResult RecetasUsuarios()
        {
            Ingredientes ingredientes = new Ingredientes();
            string       tipo1        = ingredientes.tipo;

            var detalleR = _dbContext.Registros
                           .Join(
                _dbContext.recetas,
                usuario => usuario.idusuario,
                recetas => recetas.idusuario,
                (usuario, recetas) => new detalle_receta
            {
                id_receta      = recetas.IdReceta,
                id_usuario     = usuario.idusuario,
                estado         = recetas.Estado,
                nombre         = recetas.nombre,
                nombre_usuario = usuario.nombre,
                tipo           = tipo1,
                fecha          = recetas.Fecha,
            }
                ).Where(e => e.estado == true).ToList();
            List <Ingredientes> r = _dbContext.ingredientes.ToList();

            ViewData["lista"] = r;
            return(View(detalleR));
        }
Example #10
0
        public List <Receitas> NovaReceitas(int index)
        {
            List <Receitas> Lista            = new List <Receitas>();
            Receitas        NovaListaReceita = new Receitas();

            if (index == 1)
            {
                Ingredientes PaoDeQueijo = receitas.Find(x => x.NomeDaReceita.Equals("Pão de Queijo"));
                NovaListaReceita.receita = PaoDeQueijo;
                Lista.Add(NovaListaReceita);
            }
            if (index == 2)
            {
                Ingredientes PaoDeQueijo = receitas.Find(x => x.NomeDaReceita.Equals("Bolo de Fubá"));
                NovaListaReceita.receita = PaoDeQueijo;
                Lista.Add(NovaListaReceita);
            }
            if (index == 3)
            {
                Ingredientes PaoDeQueijo = receitas.Find(x => x.NomeDaReceita.Equals("Canjica"));
                NovaListaReceita.receita = PaoDeQueijo;
                Lista.Add(NovaListaReceita);
            }
            else
            {
                index = 0;
            }
            return(Lista);
        }
Example #11
0
        private void BtnMod_Click(object sender, EventArgs e)
        {
            string prod;
            int    idIngrediente, merm, entr;

            prod = txtProd.Text;
            merm = Convert.ToInt32(txtMerma.Text);
            entr = Convert.ToInt32(txtEntradas.Text);
            Ingredientes seleccionadoI = listaIngredientes.Where(ingre => ingre.descripcion == prod).FirstOrDefault();

            idIngrediente = Convert.ToInt32(seleccionadoI.idIngrediente);
            InventarioIng seleccionado = listaInventario.Where(ingre => ingre.idIngrediente == seleccionadoI.idIngrediente).FirstOrDefault();
            //idIngrediente = Convert.ToString(tblInv[10, poc].Value);



            int idInv = seleccionado.idInventario;

            if (cnn.actualizarInventario(seleccionado.inventarioInicial, merm, entr, seleccionado.salidas, idInv))
            {
                MessageBox.Show("Inventario actualizado");
                int final = seleccionado.inventarioInicial + entr - seleccionado.salidas - merm;
                tblInv[4, poc].Value = txtEntradas.Text;
                tblInv[6, poc].Value = txtMerma.Text;
                tblInv[7, poc].Value = final.ToString();
            }

            limpiar();
        }
Example #12
0
 public Malte(Boolean _permitirEditar, Ingredientes _ingrediente)
 {
     this.permitirEditar = _permitirEditar;
     InitializeComponent();
     modelMalte       = new MalteModel();
     this.ingrediente = _ingrediente;
 }
Example #13
0
        public IActionResult GuardarIngrediente(Ingredientes ingrediente)
        {
            if (ingrediente.Imagenes != null)
            {
                var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Imagenes", ingrediente.Imagenes.FileName);
                using (var stream = System.IO.File.Create(path))
                {
                    ingrediente.Imagenes.CopyTo(stream);
                    ingrediente.imagen = ingrediente.Imagenes.FileName;
                }
            }
            else
            {
                ingrediente.imagen = "encontrar.png";
            }

            if (ingrediente.idingrediente == 0)
            {
                _dbContext.Add(ingrediente);
            }
            else
            {
                _dbContext.Update(ingrediente);
            }
            _dbContext.SaveChanges();
            return(RedirectToAction("ListarIngrediente"));
        }
Example #14
0
        private decimal PromocaoMuitoQueijo()
        {
            var queijo = Ingredientes.FirstOrDefault(i => i.Descricao.ToUpper() == "QUEIJO");

            int qtdePorcoesPromocao = 0;

            TemMuitoQueijo = false;

            if (queijo != null)
            {
                for (int i = 1; i <= queijo.Quantidade; i++)
                {
                    var calculo1 = i % promocaoPorcaoQueijo;

                    if (calculo1 == 0)
                    {
                        qtdePorcoesPromocao++;
                        TemMuitoQueijo = true;
                    }
                }

                var desconto = qtdePorcoesPromocao * queijo.Valor;

                return(desconto);
            }
            else
            {
                return(0);
            }
        }
        public static void CarregarBase()
        {
            var Alface = new Ingrediente {
                Id = 1, Nome = "Alface", Preco = 0.40m
            };
            var Bacon = new Ingrediente {
                Id = 2, Nome = "Bacon", Preco = 2.00m
            };
            var Hamburguer = new Ingrediente {
                Id = 3, Nome = "Hambúrguer de carne", Preco = 3.00m
            };
            var Ovo = new Ingrediente {
                Id = 4, Nome = "Ovo", Preco = 0.80m
            };
            var Queijo = new Ingrediente {
                Id = 5, Nome = "Queijo", Preco = 1.50m
            };

            Ingredientes.AddRange(new List <Ingrediente> {
                Alface,
                Bacon,
                Hamburguer,
                Ovo,
                Queijo
            });
        }
Example #16
0
        private decimal PromocaoMuitoHamburguer()
        {
            Ingrediente hamburguer = Ingredientes.FirstOrDefault(i =>
            {
                return(i.Descricao.ToUpper() == "HAMBÚRGUER DE CARNE");
            });

            int qtdePorcoesPromocao = 0;

            TemMuitoHamburguer = false;

            if (hamburguer != null)
            {
                for (int i = 1; i <= hamburguer.Quantidade; i++)
                {
                    var calculo1 = i % promocaoPorcaoHamburguerCarne;

                    if (calculo1 == 0)
                    {
                        qtdePorcoesPromocao++;
                        TemMuitoHamburguer = true;
                    }
                }

                var desconto = qtdePorcoesPromocao * hamburguer.Valor;

                return(desconto);
            }
            else
            {
                return(0);
            }
        }
Example #17
0
        public async Task <IActionResult> Edit(int id, [Bind("IdIngrediente, NombreIngrediente,Cantidad,IdUniMed,Status,Observaciones")] Ingredientes ingrediente)
        {
            if (id != ingrediente.IdIngrediente)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ingrediente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IngredientesExists(ingrediente.IdIngrediente))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", new { id = ingrediente.IdIngrediente }));
            }
            ViewData["IdUniMed"] = new SelectList(_context.UnidadesMedida, "IdUniMed", "DescripcionUniMed", ingrediente.IdUniMed);
            ViewData["Status"]   = new SelectList(_context.Status, "Status1", "DescripcionStatus", ingrediente.Status);
            return(View(ingrediente));
        }
Example #18
0
        private void Leveduratbn_Click(object sender, EventArgs e)
        {
            ingrediente = new Ingredientes();
            Levedura levedura = new Levedura(false, ingrediente);

            levedura.ShowDialog();
            PopulaGridIngredientes(ingrediente);
        }
Example #19
0
 public Levedura(Boolean _permitirEditar, Ingredientes _ingrediente)
 {
     InitializeComponent();
     modelLevedura       = new LeveduraModel();
     this.permitirEditar = _permitirEditar;
     this.ingrediente    = new Ingredientes();
     this.ingrediente    = _ingrediente;
 }
Example #20
0
 public DetallePizzas(string nombre, Ingredientes ingredientes, Sizes tamano, double precio, int idDetalleOrden)
 {
     Nombre           = nombre;
     Ingredientes     = ingredientes;
     Tamano           = tamano;
     Precio           = precio;
     IdDetalleOrdenes = idDetalleOrden;
 }
Example #21
0
        private void Adjuntotbn_Click(object sender, EventArgs e)
        {
            ingrediente = new Ingredientes();
            Adjunto adjunto = new Adjunto(false, ingrediente);

            adjunto.ShowDialog();
            PopulaGridIngredientes(ingrediente);
        }
Example #22
0
        private void Maltebtn_Click(object sender, EventArgs e)
        {
            ingrediente = new Ingredientes();
            Malte malte = new Malte(false, ingrediente);

            malte.ShowDialog();
            PopulaGridIngredientes(ingrediente);
        }
Example #23
0
        private void Lupulotbn_Click(object sender, EventArgs e)
        {
            ingrediente = new Ingredientes();
            Lupulo lupulo = new Lupulo(false, ingrediente);

            lupulo.ShowDialog();
            PopulaGridIngredientes(ingrediente);
        }
Example #24
0
 public Lupulo(Boolean _permitirEditar, Ingredientes _ingrediente)
 {
     InitializeComponent();
     modelLupulo         = new LupuloModel();
     this.permitirEditar = _permitirEditar;
     this.ingrediente    = new Ingredientes();
     this.ingrediente    = _ingrediente;
 }
Example #25
0
        public override global::System.Data.DataSet Clone()
        {
            Ingredientes cln = ((Ingredientes)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Example #26
0
        private void LerIngredientes()
        {
            var valores = LerMultiplasEntradas(NumeroDeIngredientes);

            for (int i = 0; i < NumeroDeIngredientes; i++)
            {
                Ingredientes.Add(new Ingrediente(i, valores[i]));
            }
        }
Example #27
0
 public override void CriarIngredientes()
 {
     Ingredientes.Add(new Pao());
     Ingredientes.Add(new Alface());
     Ingredientes.Add(new Peru());
     Ingredientes.Add(new Maionese());
     Ingredientes.Add(new Alface());
     Ingredientes.Add(new Peru());
 }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Ingredientes ingredientes = await db.Ingredientes.FindAsync(id);

            db.Ingredientes.Remove(ingredientes);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public ActionResult AgregarIngredientes(IngredienteModel model)
        {
            _token = Session["Token"].ToString();
            var ingredientes = new Ingredientes()
            {
            };

            ingredientes.CrearIngrediente(ingredientes);
            return(RedirectToAction("VerIngredientes"));
        }
Example #30
0
        public override decimal Calcular(decimal valorPedido)
        {
            var ingredienteCarne  = Ingredientes.FirstOrDefault(x => x.Nome.ToLower().Contains("carne"));
            var ingredienteQueijo = Ingredientes.FirstOrDefault(x => x.Nome.ToLower().Contains("queijo"));

            var valorDescontoCarne  = (Pedido.ItensPedido.FirstOrDefault(x => x.IdIngrediente == ingredienteCarne?.Id)?.Quantidade / 3) * ingredienteCarne?.Valor;
            var valorDescontoQueijo = (Pedido.ItensPedido.FirstOrDefault(x => x.IdIngrediente == ingredienteQueijo?.Id)?.Quantidade / 3) * ingredienteQueijo?.Valor;

            return(valorDescontoCarne ?? 0 + valorDescontoQueijo ?? 0);
        }