Visual Basic - DATAGRID + CONTROLES Y BD

Life is soft - evento anual de software empresarial
 
Vista:

DATAGRID + CONTROLES Y BD

Publicado por sandra (86 intervenciones) el 19/10/2007 06:45:37
HOLA: TENGO ESTE CODIGO QUE HACE LO SIGUIENTE:
***********************************************************************************************
OPTION EXPLICIT
Dim os_grabar as integer
Dim paciente_grabar as integer

Private Sub cboos_Click()
os_grabar = cboos.ListIndex + 1
End Sub

Private Sub cbopaciente_Click()
paciente_grabar = cbopaciente.ListIndex + 1
End Sub

Private Sub Form_Load()
Dim recor As ADODB.Recordset
Set recor = New ADODB.Recordset
recor.Open "Select nombre_os From OBRAS_SOCIALES", bd_consultorio, adOpenStatic
For i = 1 To recor.RecordCount
cboos.AddItem recor!nombre_os
recor.MoveNext
Next i
Set recor = New ADODB.Recordset
recor.Open "Select nombre_paciente, apellido_paciente From PACIENTES", bd_consultorio, adOpenStatic
While Not recor.EOF
cbopaciente.AddItem recor("Apellido_paciente") & ", " & recor("Nombre_paciente")
recor.MoveNext
Wend
End Sub

Private Sub cmdgrabar_Click()
On Error GoTo errorsub
Select Case ACCION
Case agregar
tturnos.AddNew
tturnos(0) = txtid.Text
tturnos(1) = paciente_grabar
tturnos(2) = os_grabar
tturnos(3) = dpfecha.Value
tturnos(4) = dphora.Value
tturnos.UpdateBatch
tt.Close
tt.Open "Select TURNOS.id_turno as ID, PACIENTES.apellido_paciente as Apellido, PACIENTES.nombre_paciente as Nombre, OBRAS_SOCIALES.nombre_os as OBRA_SOCIAL, TURNOS.feCHa_atencion as FECHA_ATENCION, TURNOS.hora_atencion as HORA_ATENCION From TURNOS inner join PACIENTES ON TURNOS.id_paciente = PACIENTES.id_paciente inner join OBRA_SOCIAL_PACIENTE on PACIENTES.id_paciente = OBRA_SOCIAL_PACIENTE.id_paciente inner join OBRAS_SOCIALES on OBRA_SOCIAL_PACIENTE.id_os = OBRAS_SOCIALES.id_os order by TURNOS.id_turno", bd_consultorio
Set dgturnos.DataSource = tt
Case editar
bd_consultorio.Execute "UPDATE TURNOS set id_paciente = '" & paciente_grabar & _
"', id_os_paciente = '" & os_grabar & _
"', fecha_atencion = '" & dpfecha.Value & _
"', hora_atencion = '" & dphora.Value & _
"' where id_turno = " & txtid.Text & ""
tt.Close
tt.Open "Select TURNOS.id_turno as ID, PACIENTES.apellido_paciente as Apellido, PACIENTES.nombre_paciente as Nombre, OBRAS_SOCIALES.nombre_os as OBRA_SOCIAL, TURNOS.feCHa_atencion as FECHA_ATENCION, TURNOS.hora_atencion as HORA_ATENCION From TURNOS inner join PACIENTES ON TURNOS.id_paciente = PACIENTES.id_paciente inner join OBRA_SOCIAL_PACIENTE on PACIENTES.id_paciente = OBRA_SOCIAL_PACIENTE.id_paciente inner join OBRAS_SOCIALES on OBRA_SOCIAL_PACIENTE.id_os = OBRAS_SOCIALES.id_os order by TURNOS.id_turno", bd_consultorio
Set dgturnos.DataSource = tt
End Select
errorsub:
If Err Then
MsgBox Err.Description
End If
End Sub

Private Sub Dgturnos_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
On Error Resume Next
tturnos.Requery
tturnos.Move (tt.AbsolutePosition - 1)
LlenarLista
dgturnos.Refresh
End Sub
Public Sub LlenarLista()
If tturnos.BOF Then Exit Sub
If tturnos.EOF Then Exit Sub
Llenar txtid, tturnos, 0
Llenar cbopaciente, tturnos, 1
Llenar cboos, tturnos, 2
dpfecha.Value = IIf(IsNull(tturnos(3)), "", (tturnos(3)))
dphora.Value = IIf(IsNull(tturnos(4)), "", (tturnos(4)))
End Sub

Public Function Llenar(oText As Object, tp As ADODB.Recordset, w As Integer)
oText.Text = IIf(IsNull(tp(w)), "", tp(w))
End Function
**********************************************************************************************
**********************************************************************************************
EL PROBLEMA QUE TENGO ES QUE CUANDO AGO CLICK EN EL DATAGRID"Dgturnos" PARA LEVANTAR LOS DATOS EN LOS COMBOBOX ME LEVANTA EL ID_OS, EL ID_PACIENTE. Y LO QUE YO QUIERO ES QUE LEBANTE EL NOMBRE DE LA OBRA_SOIAL EN EL COMBO. EL APELLIDO,NOMBRE PACIENTE.

COMO PUEDO HACER ESTO---
SI ALGUIEN ME ENTENDIO PORFAVOR ME DE UNA RESPUESTA LO ANTES POSIBLE...........
GRACIAS!!!!!!!!!!!!!!!!!!!!!!!!
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