Example #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (this.dgvEmpleado.Rows.Count != 0)
            {
                AccesoADatos.ConexionOracle con = new AccesoADatos.ConexionOracle();
                string idPersona = this.dgvEmpleado.CurrentRow.Cells[0].Value.ToString();

                string query = "Begin ELIMINARPERSONA(" + idPersona + "); end;";
                MessageBox.Show(query);
                try
                {
                    con.Update(query);
                    MessageBox.Show("se elimino", "Informacion del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LlenarGrid();
                }
                catch (Exception)
                {
                    MessageBox.Show("problemas al eliminar", "Informacion del sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("eliga un registro", "Informacion del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #2
0
 private void btnEditar_Click(object sender, EventArgs e)
 {
     if (ValidarCampos() == true)
     {
         AccesoADatos.ConexionOracle con = new AccesoADatos.ConexionOracle();
         string query = "Begin EditarPersona(" + idPersonaEditar + ",'" + txtNombre.Text + "','" + txtCedula.Text + "','" + dtpFecha.Value.ToString("dd/MM/yyyy") + "'); end;";
         con.Update(query);
         MessageBox.Show("se edito bien");
         this.Close();
     }
 }
Example #3
0
        private void btnInsertar_Click(object sender, EventArgs e)
        {
            AccesoADatos.ConexionOracle con = new AccesoADatos.ConexionOracle();

            if (ValidarCampos())
            {
                DateTime date  = new DateTime(2020, 08, 06);
                string   query = "Begin INSERTARPERSONA('" + txtNombre.Text + "', '" + txtCedula.Text + "', '" + dtpFecha.Value.ToString("d") + "'); end;";
                MessageBox.Show(query);

                try
                {
                    con.Update(query);

                    MessageBox.Show("insercion exitosa");
                    this.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("error en la insercion");
                }
            }
        }
Example #4
0
        private void btnLista_Click(object sender, EventArgs e)
        {
            //try
            //{ //esto es una prueba
            AccesoADatos.ConexionAcces  conexion       = new AccesoADatos.ConexionAcces();
            AccesoADatos.ConexionOracle conexionOracle = new AccesoADatos.ConexionOracle();
            string query         = "select * from TABLA_EMPLEADO;";
            string queryEliminar = "DELETE FROM TABLA_EMPLEADO;";

            //aqui obtengo los registros de la tabla empleados y lo meto en el data set
            var lista = conexion.obtenerRegistrosAcces(query, "TABLA_EMPLEADO");
            //prueba dataset
            String columnas = String.Empty;
            String vals     = String.Empty;

            DataTable dataTabla  = lista.Tables[0];
            var       listaTabla = dataTabla.Select(null, null, DataViewRowState.CurrentRows);


            if (listaTabla.Count() < 1)
            {
                MessageBox.Show("no hay registros");
            }
            else
            {
                String sql     = String.Empty;
                string comilla = "'";
                List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >();

                foreach (DataRow row in dataTabla.Rows)
                {
                    foreach (DataColumn column in dataTabla.Columns)
                    {
                        values.Add(new KeyValuePair <string, string>(
                                       column.ColumnName,
                                       comilla + row[column].ToString() + comilla
                                       ));
                    }
                    sql += insertBuilder("TABLA_EMPLEADO", values) + "\n";
                    values.Clear();
                }

                MessageBox.Show(sql);
                try
                {
                    conexionOracle.Update(queryEliminar);
                    MessageBox.Show("se eliminaron registros");
                }
                catch (Exception)
                {
                    MessageBox.Show("error al borrar");
                }
            }

            //dgvEmpleado.DataSource = lista.Tables[0];


            //    MessageBox.Show(this.dgvEmpleado.CurrentRow.Cells[1].Value.ToString()+ " "+ this.dgvEmpleado.CurrentRow.Cells[2].Value.ToString());


            //    string querycon = "insert into TABLA_PRUEBA(DNI,NOMBRE) values(" + this.dgvEmpleado.CurrentRow.Cells[1].Value.ToString() + "," + this.dgvEmpleado.CurrentRow.Cells[2].Value.ToString() + ");";
            //    conexion.Update(querycon);
            //    string prueba = "select * from TABLA_PRUEBA";
            //    conexion.LlenarGrid(prueba, dgvEmpleado);


            //}
            //catch (Exception)
            //{

            //    MessageBox.Show("error");
            //}
        }