Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/12/2007, 14:12
yohannita
 
Fecha de Ingreso: noviembre-2007
Mensajes: 39
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: problemas al guardar....

lo unico que modifique fue lo siguiente: habia 1 departamento que contenia nombres de empleados que no era correcta... lo que hice m fui a las tablas y solo cambie los datos, no campos, por ejemplo si en el departamento en el que estaban el departq.... y su id era el 1 lo modifique al depart2 con su id 2...(cree este nuevo depart2)...... pero no lo toma!!!

en el boton save tengo este codigo:

Private Sub btn_save_Click()
Dim weekRepId As Integer
Dim appProfile As Integer
Dim projId As String
Dim actId As String
Dim comp As Integer
Dim siExiste As Boolean
Dim countreg As Integer

On Error Resume Next


If Text1.Visible Then
fgd_timesheet = Text1
Text1.Visible = False
RecalcTotal (fgd_timesheet.Col)
End If

'checa si ya esta cerrado el registro
Set rst = New ADODB.Recordset
strSQL = " SELECT distinct id " & _
" FROM current_week_report, current_daily_entry " & _
" WHERE id = week_report_id " & _
" AND signature = '" & TRUser & "' " & _
" AND current_week_report.week_id = " & txt_week & " " & _
" AND completed = 1 "
rst.Open strSQL, de_TimeReportDB.cnn_TimeReportDB, adOpenStatic, adLockReadOnly, adCmdText

If Not rst.EOF Then Exit Sub

' clean up
rst.Close
Set rst = Nothing

countreg = 0
'adquiere el week_report_id
Set rst = New ADODB.Recordset
strSQL = " SELECT distinct id " & _
" FROM current_week_report, current_daily_entry " & _
" WHERE id = week_report_id " & _
" AND signature = '" & TRUser & "' " & _
" AND current_week_report.week_id = " & txt_week & " " & _
" AND completed = 0 " & _
" AND current_week_report.approved = 0 "
rst.Open strSQL, de_TimeReportDB.cnn_TimeReportDB, adOpenStatic, adLockReadOnly, adCmdText

siExiste = False

Do While Not rst.EOF
siExiste = True
weekRepId = Val(rst!id)
rst.MoveNext
Loop

' clean up
rst.Close
Set rst = Nothing

If siExiste = True Then
'Elimina registros
strSQL = "Delete from current_daily_entry where week_report_id = " & weekRepId & " "
de_TimeReportDB.cnn_TimeReportDB.Execute strSQL
Else
'si no existe el registro sacar week_report_id
Set rst = New ADODB.Recordset
rst.Open "select MAX(id) from current_week_report", de_TimeReportDB.cnn_TimeReportDB, , , adCmdText
weekRepId = Val(rst.GetString) + 1
rst.Close
'sacar el apprProfile
Set rst = New ADODB.Recordset
rst.Open "select id from appusr_profile where appr_dept_id = '" & TRDept & "' and isDrag=1 ", de_TimeReportDB.cnn_TimeReportDB, , , adCmdText
appProfile = Val(rst.GetString)
rst.Close
'Escribe registro en current_week_report
strSQL = "Insert into current_week_report values (" & weekRepId & "," & _
appProfile & "," & txt_week & ",0)"
de_TimeReportDB.cnn_TimeReportDB.Execute strSQL
End If

'Ya esta completo?
If chk_readyapp.Value = 1 Then comp = 1 Else comp = 0

If ((fgd_timesheet.Rows - 1) >= 2) Then

For Col = 1 To fgd_timesheet.Cols - 1
For Ren = 2 To fgd_timesheet.Rows - 1
If fgd_timesheet.TextMatrix(Ren, Col) > 0 Then
'Adquiere projId y actId
projId = Mid(fgd_timesheet.TextMatrix(Ren, 0), InStr(fgd_timesheet.TextMatrix(Ren, 0), "(") + 1, InStrRev(fgd_timesheet.TextMatrix(Ren, 0), "-") - (InStr(fgd_timesheet.TextMatrix(Ren, 0), "(") + 1))
actId = Mid(fgd_timesheet.TextMatrix(Ren, 0), InStrRev(fgd_timesheet.TextMatrix(Ren, 0), "-") + 1, InStrRev(fgd_timesheet.TextMatrix(Ren, 0), ")") - (InStrRev(fgd_timesheet.TextMatrix(Ren, 0), "-") + 1))
'Salva registro
strSQL = "Insert into current_daily_entry values (" & weekRepId & "," & _
Col & "," & actId & "," & projId & ",'" & _
TRUser & "'," & txt_week & "," & TRDept & "," & fgd_timesheet.TextMatrix(Ren, Col) & "," & comp & ",0)"
de_TimeReportDB.cnn_TimeReportDB.Execute strSQL
Else
If siExiste = True Then
countreg = countreg + 1
End If
End If
Next Ren
Next Col

If countreg = ((fgd_timesheet.Cols - 1) * (fgd_timesheet.Rows - 2)) Then
strSQL = "Delete from current_week_report where id = " & weekRepId & " "
de_TimeReportDB.cnn_TimeReportDB.Execute strSQL
siExiste = False
End If

Else
If siExiste = True Then
strSQL = "Delete from current_week_report where id = " & weekRepId & " "
de_TimeReportDB.cnn_TimeReportDB.Execute strSQL
End If
End If


'REcargar el timesheet
Call Get_Time_Information(TRUser, TRDept)

'Devuelve el focus al grid despues de salvado
fgd_timesheet.Row = 0
fgd_timesheet.Col = 0
fgd_timesheet.SetFocus

madeChanges = False

End Sub