Ejemplo n.º 1
0
        private void btnAlta_Click(object sender, EventArgs e)
        {
            if (vacio() == true)
            {
                string   consulta = "";
                Docentes v        = new Docentes();
                v.pMatricula = Convert.ToInt32(txtmatricula.Text);
                v.pNombre    = txtnombre.Text;
                v.pApellido  = txtapellido.Text;
                v.pDni       = Convert.ToInt32(txtdni.Text);
                v.pCalle     = txtcalle.Text;
                v.pNumero    = Convert.ToInt32(txtnumero.Text);
                v.pTelefono  = Convert.ToInt32(txttelefono.Text);
                v.pEmail     = txtemail.Text;
                v.pIdbarrio  = Convert.ToInt32(cbobarrio.SelectedValue);
                v.pTip_dni   = Convert.ToInt32(cbotipo_dni.SelectedValue);
                v.pGenero    = Convert.ToInt32(cbogenero.SelectedValue);
                v.pIdcivil   = Convert.ToInt32(cbocivil.SelectedValue);

                if (validarpk(v.pMatricula) == false)
                {
                    consulta = "insert into Docentes values(" + v.pMatricula +
                               " , '" + v.pNombre +
                               "' , '" + v.pApellido +
                               "' , " + v.pDni +
                               " , '" + v.pCalle +
                               " ', " + v.pNumero +
                               " , " + v.pTelefono +
                               " , '" + v.pEmail +
                               "', " + v.pIdbarrio +
                               " , " + v.pTip_dni +
                               " , " + v.pGenero +
                               " , " + v.pIdcivil + ")";


                    ad.actualizarbd(consulta);
                    cargarlista("docentes");
                    desabilitar();

                    MessageBox.Show("Cargado con exito");
                }
                else
                {
                    MessageBox.Show("el codigo ya existe");
                }
            }
            else
            {
                MessageBox.Show("complete campo");
            }
        }
Ejemplo n.º 2
0
        private void btnModi_Click(object sender, EventArgs e)
        {
            if (vacio() == true)
            {
                string   consulta = "";
                Docentes v        = new Docentes();
                v.pMatricula = Convert.ToInt32(txtmatricula.Text);
                v.pNombre    = txtnombre.Text;
                v.pApellido  = txtapellido.Text;
                v.pDni       = Convert.ToInt32(txtdni.Text);
                v.pCalle     = txtcalle.Text;
                v.pNumero    = Convert.ToInt32(txtnumero.Text);
                v.pTelefono  = Convert.ToInt32(txttelefono.Text);
                v.pEmail     = txtemail.Text;
                v.pIdbarrio  = Convert.ToInt32(cbobarrio.SelectedValue);
                v.pTip_dni   = Convert.ToInt32(cbotipo_dni.SelectedValue);
                v.pGenero    = Convert.ToInt32(cbogenero.SelectedValue);
                v.pIdcivil   = Convert.ToInt32(cbocivil.SelectedValue);

                consulta = "Update docentes set  nombre= '" + v.pNombre +
                           "' , " + " apellido= '" + v.pApellido +
                           "' , " + " calle= '" + v.pCalle +
                           " ', " + " numero= " + v.pNumero +
                           " , " + " telefono= " + v.pTelefono +
                           " , " + " email= '" + v.pEmail +
                           "', " + " id_barrio= " + v.pIdbarrio +
                           " , " + " id_tipo_dni= " + v.pTip_dni +
                           " , " + " id_genero= " + v.pGenero +
                           " , " + " id_estado_civil= " + v.pIdcivil + "" +
                           " where dni= " + v.pDni + "and " + " id_matricula= " + v.pMatricula;


                ad.actualizarbd(consulta);
                cargarlista("docentes");
                desabilitar();
                MessageBox.Show("docente modificado con exito");
            }
            else
            {
                MessageBox.Show("Complete Campo");
            }
        }
Ejemplo n.º 3
0
        private void cargarlista(string nombretabla)
        {
            int c = 0;

            ad.leertabla(nombretabla);
            while (ad.Lector.Read())
            {
                vi[c] = new Docentes();

                if (!ad.Lector.IsDBNull(0))
                {
                    vi[c].pMatricula = ad.Lector.GetInt32(0);


                    if (!ad.Lector.IsDBNull(1))
                    {
                        vi[c].pNombre = ad.Lector.GetString(1);
                    }
                    if (!ad.Lector.IsDBNull(2))
                    {
                        vi[c].pApellido = ad.Lector.GetString(2);
                    }
                    if (!ad.Lector.IsDBNull(3))
                    {
                        vi[c].pDni = ad.Lector.GetInt32(3);
                    }
                    if (!ad.Lector.IsDBNull(4))
                    {
                        vi[c].pCalle = ad.Lector.GetString(4);
                    }
                    if (!ad.Lector.IsDBNull(5))
                    {
                        vi[c].pNumero = ad.Lector.GetInt32(5);
                    }
                    if (!ad.Lector.IsDBNull(6))
                    {
                        vi[c].pTelefono = ad.Lector.GetInt32(6);
                    }

                    if (!ad.Lector.IsDBNull(7))
                    {
                        vi[c].pEmail = ad.Lector.GetString(7);
                    }
                    if (!ad.Lector.IsDBNull(8))
                    {
                        vi[c].pIdbarrio = ad.Lector.GetInt32(8);
                    }
                    if (!ad.Lector.IsDBNull(9))
                    {
                        vi[c].pTip_dni = ad.Lector.GetInt32(9);
                    }
                    if (!ad.Lector.IsDBNull(10))
                    {
                        vi[c].pGenero = ad.Lector.GetInt32(10);
                    }
                    if (!ad.Lector.IsDBNull(11))
                    {
                        vi[c].pIdcivil = ad.Lector.GetInt32(11);
                    }
                    c++;
                }
            }

            ad.Lector.Close();
            ad.desconectar();
            listBox1.Items.Clear();
            for (int i = 0; i < c; i++)
            {
                listBox1.Items.Add(vi[i].tostring());
            }
        }