コード例 #1
0
        private void btn_crear_Click(object sender, RoutedEventArgs e)
        {
            bool           nombre      = true;
            bool           precio      = true;
            bool           seleccionar = true;
            bool           cantidad    = true;
            bool           descripcion = true;
            bool           categ       = true;
            bool           hab         = true;
            IngredienteBLL ib          = new IngredienteBLL();
            PlatoBLL       plbll       = new PlatoBLL();

            if (txt_nomb.Text.Trim() == "")
            {
                nombre       = false;
                lb12.Content = "Debe ingresar el Nombre del Plato";
            }
            if (txt_precio.Text.Trim() == "")
            {
                precio       = false;
                lb13.Content = "Debe ingresar el Precio del Plato";
            }

            if (cbb_ingre.Text == "")
            {
                nombre       = false;
                lb14.Content = "Debe ingresar Los Ingredientes del Plato";
            }
            if (txt_cant.Text.Trim() == "")
            {
                cantidad     = false;
                lb15.Content = "Debe ingresar la Cantidad del ingrediente";
            }
            if (txt_desc.Text.Trim() == "")
            {
                descripcion  = false;
                lb16.Content = "Debe ingresar una Descripcion para el plato";
            }
            if (cbb_catego.Text == "")
            {
                categ        = false;
                lb17.Content = "Debe ingresar una Categoria al plato";
            }
            if (cbb_habi.Text.Trim() == "")
            {
                hab          = false;
                lb18.Content = "Debe ingresar el estado del Pato";
            }

            if (nombre && precio && seleccionar && cantidad && descripcion && categ && hab)
            {
                plbll.Categoria    = cbb_catego.Text;
                plbll.Habilitado   = cbb_habi.Text;
                plbll.Nombre_plato = txt_nomb.Text;
                plbll.Precio       = int.Parse(txt_precio.Text);
                plbll.Imagen       = imageBt;
                plbll.descripcion  = txt_desc.Text;
                int cantinicial = Int32.Parse(txt_cantinicial.Text);
                plbll.insert_plato(plbll, cantinicial);


                foreach (DataRow line in dtl.Rows)
                {
                    int      id    = int.Parse(line["id"].ToString());
                    int      cant  = int.Parse(line["cantidad"].ToString());
                    PlatoBLL ptbll = new PlatoBLL();
                    ptbll.crea_relacion_plato_ing(id, cant);
                }

                MessageBox.Show("Receta creada correctamente");
            }
        }