public static int Guardar(ClsEventos variable)
        {
            int          bandera = 0;
            MySqlCommand comando = new MySqlCommand(string.Format("INSERT INTO tbleventos (intidevento, vchnombre, vchdescripcion, vchdireccion, vchfecha) VALUES ('{0}','{1}','{2}', '{3}', '{4}')",
                                                                  variable.IdEvento, variable.Nombre, variable.Descripcion, variable.Direccion, variable.Fecha), ClsConexion.ObtenerConexion());

            bandera = comando.ExecuteNonQuery();
            return(bandera);
        }
        public static int Actualizar(ClsEventos variable)
        {
            int             bandera  = 0;
            MySqlConnection conexion = ClsConexion.ObtenerConexion();

            MySqlCommand comando = new MySqlCommand(string.Format("Update tbleventos set vchNombre='{0}', vchDescripcion='{1}', vchDireccion='{2}', vchFecha='{3}' where intIdEvento='{4}'",
                                                                  variable.Nombre, variable.Descripcion, variable.Direccion, variable.Fecha, variable.IdEvento), conexion);

            bandera = comando.ExecuteNonQuery();
            conexion.Close();
            return(bandera);
        }
        //llena tabla
        public static List <ClsEventos> MostrarDatos()
        {
            List <ClsEventos> lista = new List <ClsEventos>();

            MySqlCommand    comando = new MySqlCommand(String.Format("select * from tblEventos"), ClsConexion.ObtenerConexion());
            MySqlDataReader _reader = comando.ExecuteReader();

            while (_reader.Read())
            {
                ClsEventos Evento = new ClsEventos();
                Evento.IdEvento    = _reader.GetInt32(0);
                Evento.Nombre      = _reader.GetString(1);
                Evento.Descripcion = _reader.GetString(2);
                Evento.Direccion   = _reader.GetString(3);
                Evento.Fecha       = _reader.GetString(4);

                lista.Add(Evento);
            }
            return(lista);
        }
Exemple #4
0
        private void btnActualizar_Click(object sender, EventArgs e)
        {
            ClsEventos Instancia = new ClsEventos();

            Instancia.IdEvento    = Convert.ToInt32(txtIdEvento.Text.Trim());
            Instancia.Nombre      = txtNombre.Text.Trim();
            Instancia.Descripcion = txtDescripcion.Text.Trim();
            Instancia.Direccion   = txtDireccion.Text.Trim();
            Instancia.Fecha       = dtFecha.Text.Trim();

            if (ClsEventos.Actualizar(Instancia) > 0)
            {
                MessageBox.Show("Los datos del Evento se actualizaron", "Datos Actualizados", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnGuardar.Enabled = true;
                limpia_cajas();
            }
            else
            {
                MessageBox.Show("No se pudo actualizar", "Error al Actualizar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            MostrarDatos_dgvEventos();
        }
Exemple #5
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            ClsEventos Instancia = new ClsEventos();

            Instancia.Nombre      = txtNombre.Text.Trim();
            Instancia.Descripcion = txtDescripcion.Text.Trim();
            Instancia.Direccion   = txtDireccion.Text.Trim();
            Instancia.Fecha       = dtFecha.Text.Trim();

            int respuesta = ClsEventos.Guardar(Instancia);

            if (respuesta > 0)
            {
                MessageBox.Show("Evento Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("No se pudo guardar el Evento", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            limpia_cajas();
            MostrarDatos_dgvEventos();
        }
Exemple #6
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Esta Seguro que desea eliminar el Empleado Actual", "Esta Seguro??", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                ClsEventos Instancia = new ClsEventos();
                Instancia.IdEvento = Convert.ToInt32(txtIdEvento.Text);

                if (ClsEventos.Eliminar(Instancia.IdEvento) > 0)
                {
                    MessageBox.Show("Evento Eliminado Correctamente!", "Evento Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MostrarDatos_dgvEventos();
                    btnGuardar.Enabled = true;
                    limpia_cajas();
                }
                else
                {
                    MessageBox.Show("No se pudo eliminar el Evento", "Evento No Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Se cancelo la eliminacion", "Eliminacion Cancelada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemple #7
0
 //muestra informacion en la tabla
 public void MostrarDatos_dgvEventos()
 {
     dgvEventos.DataSource = ClsEventos.MostrarDatos();
     // this.dgvEventos.Columns["IdEmpleado"].Visible = true;
     //this.dgvEmpleados.Columns["IdSucursal"].Visible = true;
 }