Guardar los datos de un listview en una tabla sql.
Publicado por DANIEL (9 intervenciones) el 10/08/2018 14:52:28
Buenas compañeros:
Mi problema se lo explico, yo tengo un formaulario donde ingreso unos diagnosticos que vienen de 2 cobobox y un campo de texto, luego le doy al boton agregar y este me lo inserta uno a uno en un listview, pero por ahy mismo lo inserta en la tabla diagnostico, pero que pasa este proceso se hace a mitad de la captación de los datos del formulario, lo que nesecito es saber como puedo hacer para agregarlos nama a listview y cuando termino de meter todos los datos en el formulario poder guardar todo.
codigo del listview
si alquien me puede ayudar....
Mi problema se lo explico, yo tengo un formaulario donde ingreso unos diagnosticos que vienen de 2 cobobox y un campo de texto, luego le doy al boton agregar y este me lo inserta uno a uno en un listview, pero por ahy mismo lo inserta en la tabla diagnostico, pero que pasa este proceso se hace a mitad de la captación de los datos del formulario, lo que nesecito es saber como puedo hacer para agregarlos nama a listview y cuando termino de meter todos los datos en el formulario poder guardar todo.
codigo del listview
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Private Sub cmdagregar_Click()
CONTADOR = "1"
Dim VerificaRs As ADODB.Recordset
Set VerificaRs = New ADODB.Recordset
With VerificaRs
.Open "select * from Tbl_Diagnostico where Di_num_rep = '" & txtnum_repo & "' and Di_CIE10 = '" & Me.cbo101.Text & "'", CONEXION_ADO, adOpenStatic, adLockOptimistic
If (VerificaRs.EOF = False And VerificaRs.BOF = False) Then
MsgBox "NO PUEDE INGRESAR ESTE DIAGNOSTICO, YA FUE INGRESADO"
Else
'//--------------------------------------------AQUI GUARDA LOS DIAGNOSTICOS EN LA TABLA-------------------------
Dim CIE10Rs As ADODB.Recordset
Set CIE10Rs = New ADODB.Recordset
With CIE10Rs
.Open "select * from Tbl_Diagnostico where Di_num_rep = '" & txtnum_repo & "'", CONEXION_ADO, adOpenStatic, adLockOptimistic
If .RecordCount <> 0 Then
txtcontador = .RecordCount
.AddNew
.Fields("Di_num_rep") = Me.txtnum_repo.Text
.Fields("Di_identificador") = Me.txtcedula.Text
.Fields("Di_CIE10") = Me.cbo101.Text
.Fields("Di_cieinterpretacion") = Me.txtdiag1.Text
.Fields("Di_diag_numero") = txtcontador + 1
.Update
Else
.AddNew
.Fields("Di_num_rep") = Me.txtnum_repo.Text
.Fields("Di_identificador") = Me.txtcedula.Text
.Fields("Di_CIE10") = Me.cbo101.Text
.Fields("Di_cieinterpretacion") = Me.txtdiag1.Text
.Fields("Di_diag_numero") = CONTADOR
.Update
End If
.Close
End With
Set CIE10Rs = Nothing
End If
.Close
End With
Set VerificaRs = Nothing
'//-----------------------------------------------------------------------------------------
'//-------------------------------------------------CARGA LOS DIAGNOSTICOS AL LISTVIEW--------------------------
Dim DiagnosticoRs As ADODB.Recordset
'Dim item As ListItem '//-------------------SE CANBIA PARA EL VB6 PORQUE EXISTE DOS COMPONENTES ACITVOS SP5, SP6-----
Dim item As Object
Me.lstListado.ListItems.Clear
COLUMNAS
Set DiagnosticoRs = New ADODB.Recordset
With DiagnosticoRs
.Open "select * from Tbl_Diagnostico where Di_num_rep = '" & txtnum_repo & "'", CONEXION_ADO, adOpenForwardOnly, adLockOptimistic
If .RecordCount <> 0 Then
.MoveFirst
Do While Not .EOF
If IsNull(.Fields("Di_num_rep")) Or .Fields("Di_num_rep") = "" Then
REPORTE = ""
Else
REPORTE = .Fields("Di_num_rep")
End If
If IsNull(.Fields("Di_identificador")) Or .Fields("Di_identificador") = "" Then
IDENTIFICACION = ""
Else
IDENTIFICACION = .Fields("Di_identificador")
End If
If IsNull(.Fields("Di_CIE10")) Or .Fields("Di_CIE10") = "" Then
DIAGNOSTICOSS = ""
Else
DIAGNOSTICOSS = .Fields("Di_CIE10")
End If
If IsNull(.Fields("Di_cieinterpretacion")) Or .Fields("Di_cieinterpretacion") = "" Then
INTERPRETACION = ""
Else
INTERPRETACION = .Fields("Di_cieinterpretacion")
End If
If IsNull(.Fields("Di_diag_numero")) Or .Fields("Di_diag_numero") = "" Then
ORDEN_ENTRADA = ""
Else
ORDEN_ENTRADA = .Fields("Di_diag_numero")
End If
If Me.lstListado.ListItems.Count > 4 Then
MsgBox "Se llegó al Máximo de Diagnosticos para este Paciente"
Else
'//---------------Variables---------------------------
Set item = lstListado.ListItems.Add(, , REPORTE)
item.SubItems(1) = IDENTIFICACION
item.SubItems(2) = DIAGNOSTICOSS
item.SubItems(3) = INTERPRETACION
item.SubItems(4) = ORDEN_ENTRADA
End If
.MoveNext
Loop
End If
.Close
End With
Set DiagnosticoRs = Nothing
REPORTE = txtnum_repo
DIAGNOSTICOSS = Me.cbo101.Text
txtcontador = ""
cbo101.ListIndex = -1
txtdiag1 = ""
End Sub
'//------------------------------------------COLUMNAS DEL LISTVIEW------------------------------------------------
Private Sub COLUMNAS()
Me.lstListado.ColumnHeaders.Clear
'//----------------------------Formato de las columnas-------------------------------
Me.lstListado.ColumnHeaders.Add , , "Reporte", 800
Me.lstListado.ColumnHeaders.Add , , "Identificador", 1500
Me.lstListado.ColumnHeaders.Add , , "Diagnostico", 1500
Me.lstListado.ColumnHeaders.Add , , "Interpretacion", 3500
Me.lstListado.ColumnHeaders.Add , , "Posición", 800
Me.lstListado.View = lvwReport
Me.lstListado.LabelEdit = lvwManual
Me.lstListado.FullRowSelect = True
End Sub
si alquien me puede ayudar....
Valora esta pregunta
0