//public Boolean checar() { // JuegosDAOS dao = new JuegosDAOS(); // JuegosModelo jm = new JuegosModelo(); // jm = dao.search((int)nudID.Value); // if (jm != null) { // txtNombre.Text = jm.nombre; // txtGenero.Text = jm.genero; // dtpFecha.Value = jm.fechalanzamiento; // txtDesarrollador.Text = jm.desarrollador; // txtPublicador.Text = jm.publicador; // cboClasificacion.SelectedItem = jm.clasificacion; // nudRating.Value = jm.rating; // nudPrecio.Value = jm.precio; // //Acá va la imagen // if (jm.imagen != null) { // picImagen.Image = ByteArrayToImage(jm.imagen); // } else { // picImagen.Image = null; // } // lblEstado.Text = "-"; // btnModificar.Enabled = true; // return true; // } else { // txtNombre.Text = ""; // txtGenero.Text = ""; // dtpFecha.Value = dtpFecha.MinDate; // txtDesarrollador.Text = ""; // txtPublicador.Text = ""; // cboClasificacion.SelectedItem = null; // nudRating.Value = nudRating.Minimum; // nudPrecio.Value = nudPrecio.Minimum; // //Acá va la imagen // picImagen.Image = null; // btnModificar.Enabled = false; // lblEstado.Text = "No existe."; // return false; // } //} public void llenado() { JuegosDAOS dao = new JuegosDAOS(); JuegosModelo jm = new JuegosModelo(); jm = dao.search(idbueno); txtNombre.Text = jm.nombre; txtGenero.Text = jm.genero; dtpFecha.Value = jm.fechalanzamiento; txtDesarrollador.Text = jm.desarrollador; txtPublicador.Text = jm.publicador; txtClasificacion.Text = jm.clasificacion; nudRating.Value = jm.rating; nudPrecio.Value = jm.precio; //Acá va la imagen if (jm.imagen != null) { picImagen.Image = ByteArrayToImage(jm.imagen); } else { picImagen.Image = null; } btnModificar.Enabled = true; }
private void btnGuardar_Click(object sender, EventArgs e) { if (val.validar(txtNombre.Text, txtGenero.Text, txtDesarrollador.Text, txtPublicador.Text, txtClasificacion.Text, (decimal)nudRating.Value, (decimal)nudPrecio.Value)) { JuegosModelo j = new JuegosModelo(); JuegosDAOS dao = new JuegosDAOS(); j.nombre = txtNombre.Text; j.genero = txtGenero.Text; j.fechalanzamiento = dtpFecha.Value; j.desarrollador = txtDesarrollador.Text; j.publicador = txtPublicador.Text; j.clasificacion = txtClasificacion.Text; j.rating = (decimal)nudRating.Value; j.precio = (decimal)nudPrecio.Value; if (img != null) { j.imagen = ImageToByteArray(img); } else { j.imagen = null; } dao.insert(j); MessageBox.Show("Agregado."); this.Close(); } else { MessageBox.Show("Algo está mal con los datos."); } }
private void eliminarSeleccionadoToolStripMenuItem_Click(object sender, EventArgs e) { int idSelec = (int)tblTabla.Rows[tblTabla.CurrentRow.Index].Cells[0].Value; string namSelec = (string)tblTabla.Rows[tblTabla.CurrentRow.Index].Cells[1].Value; if (MessageBox.Show("¿Seguro que desea borrar el registro " + namSelec + "?", "Eliminar registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { JuegosDAOS jd = new JuegosDAOS(); jd.delete(idSelec); MessageBox.Show("Se borró el registro " + namSelec); tblTabla.DataSource = new JuegosDAOS().getAll(); } else { MessageBox.Show("No se borró nada."); } }
private void btnModificar_Click(object sender, EventArgs e) { if (val.validar(txtNombre.Text, txtGenero.Text, txtDesarrollador.Text, txtPublicador.Text, txtClasificacion.Text, (decimal)nudRating.Value, (decimal)nudPrecio.Value)) { JuegosModelo i = new JuegosModelo(); JuegosDAOS dao = new JuegosDAOS(); img = picImagen.Image; i.idjuego = idbueno; i.nombre = txtNombre.Text; i.genero = txtGenero.Text; i.fechalanzamiento = dtpFecha.Value; i.desarrollador = txtDesarrollador.Text; i.publicador = txtPublicador.Text; i.clasificacion = txtClasificacion.Text; i.rating = nudRating.Value; i.precio = nudPrecio.Value; if (img != null) { i.imagen = ImageToByteArray(img); } else { i.imagen = null; } dao.update(i); MessageBox.Show("Modificado."); this.Close(); } else { MessageBox.Show("Algo está mal con los datos."); } }
private void btnFiltrar_Click(object sender, EventArgs e) { if (txtFiltro.Text != "") { string filtro = txtFiltro.Text; List <JuegosModelo> res = new JuegosDAOS().getFiltro(filtro); if (res.Count != 0) { tblTabla.DataSource = res; modificarSeleccionadoToolStripMenuItem.Enabled = true; eliminarSeleccionadoToolStripMenuItem.Enabled = true; } else { MessageBox.Show("No hay coincidencias."); } } else { MessageBox.Show("Escriba criterios de filtro."); } }