public ActionResult Editar(Interprete interprete)
        {
            //para cargar la data
            bool exito = DAInterprete.ActualizarInterprete(interprete);

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        private void btnInsertarInterprete_Click(object sender, EventArgs e)
        {
            if (txtNombreInterprete.Text == "")
            {
                lblMensaje.ForeColor = Color.Red;
                lblMensaje.Text      = "No se permite dejar en blanco este campo, es obligatorio";
            }
            else
            {
                lblMensaje.Text = "";

                if (il.existe(txtNombreInterprete.Text) == true)
                {
                    lblMensaje.ForeColor = Color.Red;
                    lblMensaje.Text      = "El interprete ya existe, regitre otro";
                }
                else
                {
                    lblMensaje.Text = "";
                    Interprete i = new Interprete();
                    i.descripcion = txtNombreInterprete.Text;

                    il.InsertarInterprete(i);
                    refrescarInterprete();
                    refrescarComboInterprete();
                    txtNombreInterprete.Text = "";
                }
            }
        }
Exemple #3
0
 private void BorrarToolStripButton_Click(object sender, EventArgs e)
 {
     if (DatosDataGridView.SelectedRows.Count > 0)
     {
         DataGridViewRow r          = DatosDataGridView.SelectedRows[0];
         Interprete      interprete = (Interprete)r.Tag;
         DialogResult    dr         = MessageBox.Show($"¿Desea dar de baja al intérprete {interprete.Nombre}?",
                                                      "Confirmar Baja",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             try
             {
                 if (!servicio.EstaRelaciona(interprete))
                 {
                     servicio.Borrar(interprete);
                     DatosDataGridView.Rows.Remove(r);
                     MessageBox.Show("Registro Borrado", "Mensaje",
                                     MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     MessageBox.Show("Intérprete con Álbumes \nBaja Denegada", "Error",
                                     MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             catch (Exception exception)
             {
                 MessageBox.Show(exception.Message, "Error",
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (codigo == Convert.ToInt32(txtId.Text))
        {
            Interprete interprete = new Interprete();
            interprete.Id     = Convert.ToInt32(txtId.Text);
            interprete.Nombre = txtNombre.Text;
            interprete.Edad   = Convert.ToInt32(txtEdad.Text);

            WebService w = new WebService();

            if (w.ModificarInterprete(interprete) == 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Ha ocurrido un error al modificar');</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Se ha modificado correctamente');</script>");
            }
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Se ha modificado la clave IDInterprete');</script>");
        }
    }
Exemple #5
0
        private void NuevoToolStripButton_Click(object sender, EventArgs e)
        {
            InterpretesAEForm frm = new InterpretesAEForm();

            frm.Text = "Nuevo Intérprete";
            DialogResult dr = frm.ShowDialog(this);

            if (dr == DialogResult.OK)
            {
                try
                {
                    Interprete interprete = frm.GetInterprete();

                    if (!servicio.Existe(interprete))
                    {
                        servicio.Agregar(interprete);
                        DataGridViewRow r = ConstruirFila();
                        SetearFila(r, interprete);
                        AgregarFila(r);
                        MessageBox.Show("Registro agregado", "Mensaje",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Registro Duplicado \nAlta Denegada", "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #6
0
        public Interprete ObtenerInterprete(string interpreteId)
        {
            string sqltxt        = $"SELECT * FROM [dbo].[Interprete] WHERE id = {interpreteId}";
            var    tablaTemporal = _BD.consulta(sqltxt);

            if (tablaTemporal.Rows.Count == 0)
            {
                return(null);
            }

            var interprete = new Interprete();

            foreach (DataRow fila in tablaTemporal.Rows)
            {
                if (fila.HasErrors)
                {
                    continue;                                      // no corto el ciclo
                }
                interprete.Id      = fila.ItemArray[0].ToString(); // Codigo
                interprete.Nombre  = fila.ItemArray[1].ToString(); // Nombre
                interprete.Id_Pais = fila.ItemArray[2].ToString(); // Nacionalidad
            }

            return(interprete);
        }
        public ActionResult Registro(Interprete interprete)
        {
            //para cargar la data
            bool exito = DAInterprete.RegistrarInterprete(interprete);

            return(RedirectToAction("Index"));
        }
        public void Insertar(Interprete interprete)
        {
            //Creamos el objeto que se conecta con la base de datos
            //Es necesario enciarle la cadena de conexion para que
            //conozca cual es la base de datos
            SqlConnection conexion = new SqlConnection(Conexion.Cadena);

            try
            {
                // Se debe abrir la conexión
                conexion.Open();
                //Sentencia que se necesita ejecutar
                string sql = "PA_Insertar_Interprete";
                //El comando es el objeto que ejecuta la sebntencia
                SqlCommand comando = new SqlCommand(sql, conexion);
                // Nota: es obligatorio cambiar el tipo de comando
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@nombre", interprete.descripcion);

                // Ejecutar el comando
                comando.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }

            finally
            {
                conexion.Close();
            }
        }
Exemple #9
0
        //
        // GET: /Interpretes/Detalle/5
        public ActionResult Detalle(int id = 0, bool pdf = false)
        {
            Interprete interprete = _gestorDominio.TraerInterprete(id);

            if (interprete == null)
            {
                return(HttpNotFound());
            }

            var albumesInterprete = _gestorDominio.TraerAlbumesInterprete(id);
            var albumesDetallados = _gestorDominio.DetallarAlbumes(albumesInterprete);

            var modelo = new MVInterpreteDetallado
            {
                Id      = interprete.Id,
                Nombre  = interprete.Nombre,
                Albumes = new MVAlbumLista {
                    Albumes = albumesDetallados
                },
                CancionesSinAlbum = new MVCancionLista
                {
                    MostrarAlbum    = false,
                    MostrarCabecera = false,
                    Canciones       = _gestorDominio.TraerCancionesInterprete(id)
                }
            };

            ViewBag.Pdf = pdf;
            //return View(modelo);
            return(pdf ? new PdfActionResult(modelo) : (ActionResult)View(modelo));
        }
Exemple #10
0
        public EditarInterpreteSalida EditarInterprete(EditarInterpreteEntrada entrada)
        {
            var salida = new EditarInterpreteSalida();

            if (string.IsNullOrEmpty(entrada.Nombre))
            {
                return(SalidaBase.Fallo(salida, Cadenas.interprete_falta_nombre));
            }

            Interprete interprete;

            if (entrada.InterpreteId > 0)
            {
                interprete = _gestorPersistencia.TraerInterprete(entrada.InterpreteId);
                if (interprete == null)
                {
                    return(SalidaBase.Fallo(salida,
                                            string.Format(Cadenas.interprete_id_no_encontrado, entrada.InterpreteId)));
                }

                interprete.Nombre = entrada.Nombre;
            }
            else
            {
                interprete = new Interprete
                {
                    Nombre      = entrada.Nombre,
                    FchCreacion = DateTime.Now,
                };
            }
            _gestorPersistencia.Guardar(interprete);
            salida.Interprete = interprete;

            return(SalidaBase.Exito(salida));
        }
Exemple #11
0
    public Interprete ObtenerInterprete(int codigo)
    {
        Interprete interprete = new Interprete();

        MySqlCommand    c = new MySqlCommand();
        MySqlDataReader d;

        try
        {
            c.Connection  = cnx;
            c.CommandText = "SELECT * FROM `interprete` WHERE IDInt = '" + codigo + "'";
            d             = c.ExecuteReader();
            if (d.HasRows)
            {
                while (d.Read())
                {
                    interprete.Id     = d.GetInt32(0);
                    interprete.Nombre = d.GetString(1);
                    interprete.Edad   = d.GetInt32(2);
                }
            }
            d.Close();
        }
        catch (MySqlException ex)
        {
        }

        return(interprete);
    }
        //private Interprete ConstruirInterprete(SqlDataReader reader)
        //{
        //    return new Interprete
        //    {
        //        InterpreteId = reader.GetInt32(0),
        //        Nombre = reader.GetString(1)
        //    };
        //}

        public bool Existe(Interprete interprete)
        {
            try
            {
                SqlCommand    comando = null;
                SqlDataReader reader  = null;

                if (interprete.InterpreteId == 0)
                {
                    var cadenaComando = "SELECT InterpreteId, Interprete, NacionalidadId FROM Interpretes WHERE Interprete=@nombre AND NacionalidadId=@nacionalidadId";
                    comando = new SqlCommand(cadenaComando, _cn);
                    comando.Parameters.AddWithValue("@nombre", interprete.Nombre);
                    comando.Parameters.AddWithValue("@nacionalidadId", interprete.Nacionalidad.NacionalidadId);
                }
                else
                {
                    var cadenaComando = "SELECT InterpreteId, Interprete, NacionalidadId FROM Interpretes WHERE Interprete=@nombre AND NacionalidadId=@nacionalidadId AND InterpreteId<>@id";
                    comando = new SqlCommand(cadenaComando, _cn);
                    comando.Parameters.AddWithValue("@nombre", interprete.Nombre);
                    comando.Parameters.AddWithValue("@nacionalidadId", interprete.Nacionalidad.NacionalidadId);
                    comando.Parameters.AddWithValue("@id", interprete.InterpreteId);
                }

                reader = comando.ExecuteReader();
                return(reader.HasRows);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Exemple #13
0
    public int ModificarInterprete(Interprete interprete)
    {
        MySqlCommand c = new MySqlCommand();

        try
        {
            c.Connection  = cnx;
            c.CommandText = "UPDATE interprete SET Nombre='" + interprete.Nombre + "', Edad ='" + interprete.Edad + "' WHERE IDInt = " + interprete.Id;

            int r = c.ExecuteNonQuery();

            if (r == 1)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
        catch (MySqlException ex)
        {
            return(0);
        }
    }
Exemple #14
0
        public void lecturaInicial()
        {
            string ruta = "C:\\Users\\JohnnyBravo\\Desktop\\Proyecto1Reportes\\ArchivosEntrada\\Entrada1.xconf";

            if (!string.IsNullOrEmpty(ruta))
            {
                //MessageBox.Show(ruta);
                string leer      = File.ReadAllText(ruta);
                bool   resultado = Analizadores.Interprete.analizar1(leer);
                if (resultado == true && LErrores.Count == 0)
                {
                    MessageBox.Show("ANALISIS  COMPLETADO");
                    Analizadores.Interprete inter = new Interprete();
                    inter.RecorrerListas();
                    aux      = lista_figure.First();
                    tamLista = lista_figure.Count;
                    mostrarImagenes("inicio");
                }
                else
                {
                    MessageBox.Show("EXISTEN ERRORES LEXICOS O SINTACTICOS");
                    foreach (var item in LErrores)
                    {
                        txtConsola.Text = txtConsola.Text + "*" + item.tipo + "  " + item.mensaje + "  Linea: " + item.linea + "  Columna: " + item.columna + "\n";
                    }
                }
            }
            else
            {
                MessageBox.Show("Error con la ruta del archivo inicial");
            }
        }
Exemple #15
0
        public override string Validar(IDictionary <string, object> parametros)
        {
            string result = ValidarParametrosNoNull(parametros);

            if (!string.IsNullOrEmpty(result))
            {
                return(result);
            }

            if (!parametros.ContainsKey("Interprete") || parametros["Interprete"] == null)
            {
                return(Cadenas.rpt_val_no_interprete);
            }

            int    interpreteId;
            string interpreteEntrada = parametros["Interprete"].ToString();

            if (!int.TryParse(interpreteEntrada, out interpreteId))
            {
                return(string.Format(Cadenas.rpt_val_interprete_no_valido, interpreteEntrada));
            }

            _interprete = _gestorPersistencia.TraerInterprete(interpreteId);
            if (_interprete == null || _interprete.Id <= 0)
            {
                return(string.Format(Cadenas.rpt_val_interprete_no_valido, interpreteEntrada));
            }

            return("");
        }
Exemple #16
0
 public ModificarInterprete(string interpreteId)
 {
     InitializeComponent();
     interpretesRepositorio = new InterpretesRepositorio();
     paisRepositorio        = new PaisRepositorio();
     interprete             = interpretesRepositorio.ObtenerInterprete(interpreteId);
 }
Exemple #17
0
        public bool Editar(Interprete interprete)
        {
            string sqltxt = $"UPDATE [dbo].[interprete] SET nombre ='{ interprete.Nombre }'" +
                            $", id_pais= { interprete.Id_Pais }" +
                            $"WHERE id= {interprete.Id}";

            return(_BD.EjecutarSQL(sqltxt));
        }
Exemple #18
0
        private void SetearFila(DataGridViewRow r, Interprete interprete)
        {
            r.Cells[cmnInterprete.Index].Value = interprete.Nombre;
            r.Cells[cmnPais.Index].Value       = interprete.Pais.Nombre;


            r.Tag = interprete;
        }
        private void SetearFila(DataGridViewRow r, Interprete interprete)
        {
            r.Cells[cmnInterprete.Index].Value   = interprete.Nombre;
            r.Cells[cmnNacionalidad.Index].Value = interprete.Nacionalidad.Nombre;


            r.Tag = interprete;
        }
Exemple #20
0
 public ActionResult Edit(Interprete interprete)
 {
     if (ModelState.IsValid)
     {
         interpreteService.UpdateInterprete(interprete);
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Edit"));
 }
Exemple #21
0
        public void GuardarBasico()
        {
            var g          = new GestorPersistenciaEF();
            var interprete = new Interprete {
                Nombre = "pruebas"
            };

            g.Guardar(interprete);
        }
Exemple #22
0
 public ActionResult Create(Interprete interprete)
 {
     if (ModelState.IsValid)
     {
         interpreteService.CreateInterprete(interprete);
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Create"));
 }
Exemple #23
0
        public bool Guardar(Interprete interprete)
        {
            string sqltxt = $"INSERT[dbo].[interprete]([Nombre],[id_Pais])" +
                            $"VALUES " +
                            $"('{interprete.Nombre}', " +
                            $"'{interprete.Id_Pais}')";

            return(_BD.EjecutarSQL(sqltxt));
        }
Exemple #24
0
 public static void Init(string path)
 {
     //Tasks: Prepare code, read file, take decisions
     string[] lines = File.ReadAllLines(path); //read script
     foreach (string line in lines)
     {
         line.Trim();
         Interprete.Decide(line);
     }
 }
Exemple #25
0
        private void itemEjecutarConf_Click(object sender, EventArgs e)
        {
            if (tabPestanas.SelectedTab.Text != "")
            {
                //Se limpiaN laS listas cada vez que se compila para que no muestre errores ni datos anteriores a su correcion.
                LErrores.Clear();
                lista_design.Clear();
                lista_figure.Clear();
                lista_background.Clear();
                txtConsola.Text = "";
                //Ejecucion.Ejecutor ejecutor=new Ejecucion.Ejecutor();
                string entrada   = LP.leerEntrada(tabPestanas.SelectedTab.Text);
                bool   resultado = Analizadores.Interprete.analizar1(LP.leerEntrada(tabPestanas.SelectedTab.Text));
                // txtConsola.Text = ejecutor.MostrarSalida();
                //bool resultado2 = Analizadores.Interprete.analizar2(LP.leerEntrada(pestanas1.SelectedTab.Text), pestanas1.SelectedTab.Name);

                if (resultado == true && LErrores.Count == 0)
                {
                    MessageBox.Show("ANALISIS  COMPLETADO");
                    Analizadores.Interprete inter = new Interprete();
                    inter.RecorrerListas();
                    aux      = lista_figure.First();
                    tamLista = lista_figure.Count;
                    mostrarImagenes("inicio");
                }
                else
                {
                    MessageBox.Show("EXISTEN ERRORES LEXICOS O SINTACTICOS");
                    foreach (var item in LErrores)
                    {
                        txtConsola.Text = txtConsola.Text + "*" + item.tipo + "  " + item.mensaje + "  Linea: " + item.linea + "  Columna: " + item.columna + "\n";
                    }
                }

                /*if (resultado2 == true)
                 * {
                 *  MessageBox.Show("ANALISIS 2 COMPLETADO");
                 *  abrirImagen2();
                 * }
                 * else
                 * {
                 *
                 *  MessageBox.Show("EXISTEN ERRORES LEXICOS O SINTACTICOS entrada 2");
                 * }*/
            }
            else
            {
                MessageBox.Show("INGRESE ALGUN TEXTO");
            }

            for (int i = 0; i < LErrores.Count; i++)
            {
                Console.WriteLine("Error: {0} Linea: {1} Columna: {2} ", LErrores[i].tipo, LErrores[i].linea, LErrores[i].columna);
            }
        }
    protected void Button2_Click(object sender, EventArgs e)
    {
        codigo = Convert.ToInt32(txtId.Text);

        WebService w = new WebService();

        Interprete interprete = w.ObtenerInterprete(codigo);

        txtNombre.Text = interprete.Nombre;
        txtEdad.Text   = Convert.ToString(interprete.Edad);
    }
Exemple #27
0
        public static Variable obtenerVariable(Contexto ctx, String nombre)
        {
            Variable var = ctx.getVariable(nombre);

            if (var != null)
            {
                return(var);
            }
            var = Interprete.getContextoGlobal().getVariable(nombre);
            return(var);
        }
Exemple #28
0
 protected void setVariable(Contexto ctx, Variable var)
 {
     if (ctx.existeVariable(var.Nombre))
     {
         ctx.setVariable(var);
     }
     else if (Interprete.getContextoGlobal().existeVariable(var.Nombre))
     {
         Interprete.getContextoGlobal().setVariable(var);
     }
 }
Exemple #29
0
        //
        // GET: /Interpretes/Editar/5
        public ActionResult Editar(int id = 0)
        {
            Interprete interprete = _gestorDominio.TraerInterprete(id);

            if (interprete == null)
            {
                return(HttpNotFound());
            }

            return(View(interprete));
        }
Exemple #30
0
 public void Guardar(Interprete interprete)
 {
     try
     {
         _dbContext.Interpretes.Add(interprete);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }