Visual Basic.NET - al darle click al boton registra familia me lo guarda el en DTGW

 
Vista:
sin imagen de perfil
Val: 20
Ha disminuido su posición en 2 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

al darle click al boton registra familia me lo guarda el en DTGW

Publicado por Oswal (14 intervenciones) el 01/08/2018 06:32:13
mi idea es que yo con lo datos que estan arriba al darle click al boton registra familia me lo guarda el en DTGW. sencillo para este metodo yo utilizada este codigo:



DTGWEntrada.Rows.Add(TBnpedido.Text, CBcodigoprodructo.Text, Tbnombredelproducto.Text, TbCantidadpedido.Text, "KGRs")

pero como pueden observa tiene varios RadioButton, de hacerlo así el codigo seria inmenso y dios casi infinito por que abria muchas variables vez... pues me puse a investigar expandir mi conocimiento, y me encontre con un mejor metodo que es este:



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
DTGWnucleofamiliar.SelectedRows(0).Cells("Cfamiliar").Value = TbCodigoFamiliar.Text
DTGWnucleofamiliar.SelectedRows(0).Cells("Cedula").Value = tbCedula.Text
 
If RBNacV.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("nacionalidad").Value = "V"
Else
    DTGWnucleofamiliar.SelectedRows(0).Cells("nacionalidad").Value = "E"
End If
 
DTGWnucleofamiliar.SelectedRows(0).Cells("nombres").Value = TBNombres.Text
DTGWnucleofamiliar.SelectedRows(0).Cells("Apellido").Value = TBApellido.Text
 
If RBsexoM.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("sexo").Value = "M"
Else
    DTGWnucleofamiliar.SelectedRows(0).Cells("sexo").Value = "F"
End If
 
DTGWnucleofamiliar.SelectedRows(0).Cells("telefono").Value = Tbtelefono.Text
DTGWnucleofamiliar.SelectedRows(0).Cells("Fnac").Value = DTPfechanac.Value
DTGWnucleofamiliar.SelectedRows(0).Cells("edad").Value = TBedad.Text
 
If RBDiscapacidadSi.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("discapacitado").Value = "Si"
Else
    DTGWnucleofamiliar.SelectedRows(0).Cells("discapacitado").Value = "No"
End If
 
DTGWnucleofamiliar.SelectedRows(0).Cells("parentesco").Value = TBParentesco.Text
 
If RBNintruccionSinIntruccion.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("Gint").Value = "Sin Intrucción"
ElseIf RBNInBasica.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("Gint").Value = "Básica"
ElseIf RBNIBachiller.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("Gint").Value = "Bachiller"
ElseIf RbNITecnicoMedio.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("Gint").Value = "Técnico Medio"
ElseIf RBNItecnicoSuperior.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("Gint").Value = "Técnico Superior"
ElseIf RBNIUniversitario.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("Gint").Value = "Universitario"
Else
    DTGWnucleofamiliar.SelectedRows(0).Cells("Gint").Value = "Post Grado"
End If
 
If RBCNEsi.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("CNE").Value = "Si"
Else
    DTGWnucleofamiliar.SelectedRows(0).Cells("CNE").Value = "No"
End If
 
DTGWnucleofamiliar.SelectedRows(0).Cells("profesion").Value = TBprofesion.Text
 
If RBAmormayorSI.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("Amayor").Value = "Si"
Else
    DTGWnucleofamiliar.SelectedRows(0).Cells("Amayor").Value = "No"
End If
 
If RBCpatriaSI.Checked = True Then
    DTGWnucleofamiliar.SelectedRows(0).Cells("cpatria").Value = "Si"
Else
    DTGWnucleofamiliar.SelectedRows(0).Cells("cpatria").Value = "No"
End If
 
DTGWnucleofamiliar.SelectedRows(0).Cells("ncalle").Value = Tbnombrecalle.Text



pero note que tiene una falla , esa falla es que si no selecciono la fila me explota, y seria muy engorroso ya que es un registro de una familia y en el país donde yo vivo las familias aveces exceden de 20 personas.. seleccionar 20 manual cansaria y no seria la idea del sistema....

trate de que se me seleccionara la fila al darle ENTER en la ultima caja de texto que es "Profesion" y lo hacia con este codigo:

1
DTGWnucleofamiliar.Rows(DTGWnucleofamiliar1.Rows.Count - 1).Selected = True



pero me seleccionaba la ultima fila y no me agrega un nuevo registro en blanco:

1
DTGWnucleofamiliar.Rows.Add()



Trate de hacer un For para que me seleccionara la primera fila y fuera así pero no me funciono y no hace el bucle:

1
2
3
4
5
6
7
8
9
10
11
Private Sub seleccionardTG()
 
    For i As Integer = (DTGWnucleofamiliar.Rows.Count = 0) To Val(DTGWnucleofamiliar.Rows.Count < 15) Step 1
 
        If DTGWnucleofamiliar.Rows.Count > 1 Then
 
            DTGWnucleofamiliar.Rows(i).Selected = True
 
        End If
    Next
End Sub



esto son el cuadro de texto para seleccionar la fila con el enter:

1
2
3
4
5
6
7
8
9
10
11
12
Private Sub TBprofesion_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TBprofesion.KeyDown
    If e.KeyCode = Keys.Enter Then
        If TBprofesion.Text = "" Then
            MsgBox("El Campo se Encuentra Vacío debe Tener algo Escrito", MsgBoxStyle.Critical, "Error")
        Else
            PBAgregar.Visible = True
            DTGWnucleofamiliar.Rows.Add()
            seleccionardTG()
        End If
    End If
 
End Sub



y el boton para agregar el registro:



1
2
3
4
5
6
7
Private Sub PBAgregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PBAgregar.Click
 
    agregardtgNucleofamiliar()
 
    inicio()
 
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 20
Ha disminuido su posición en 2 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

al darle click al boton registra familia me lo guarda el en DTGW

Publicado por Oswal (14 intervenciones) el 01/08/2018 06:50:20
Este es el formulario:


vdoosadfsd
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar