I've recently been given the task of finishing an incomplete project for my University. It'll count as credit for one Class so I'll shave a month off of my studies!
Here's the thing. The that was left behind is horrible: unorganized and not well thought-out. For example:
Protected Sub btnAceptar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAceptar.Click
Try
If accion = "Nuevo" Then 'Para crear uno nuevo
If txtIdMotivo.Text <> "" And txtDescripcion.Text <> "" Then
Dim cmd As New SqlCommand("insert into Motivos values(" & CInt(txtIdMotivo.Text) & ",'" & txtDescripcion.Text & "')", cn)
cn.Open()
Resp = cmd.ExecuteNonQuery() 'Devuelve 1 si no hubo error al guardar
cn.Close()
Else
MsgBox("Hay datos en blanco", MsgBoxStyle.Critical, "Revisar")
End If
Else
If txtIdMotivo.Text <> "" And txtDescripcion.Text <> "" Then
Dim cmd As New SqlCommand("update Motivos set descripcion= '" & txtDescripcion.Text & "' where IdMotivo= " & CInt(txtIdMotivo.Text), cn)
cn.Open()
Resp = cmd.ExecuteNonQuery() 'Devuelve 1 si no hubo error al modificar
cn.Close()
Else
MsgBox("Hay datos en blanco", MsgBoxStyle.Critical, "Revisar")
End If
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
'Verificamos si todo salio ok
If Resp = 1 Then
btnAceptar.Enabled = False
btnCancelar.Enabled = False
MsgBox("Accion realizada exitosamente", MsgBoxStyle.Information, "Listo")
Response.Redirect("frmMotivosRecuperacionListado.aspx")
Else
MsgBox("Error al intentar realizar la acción", MsgBoxStyle.Exclamation, "Revisar")
cn.Close()
End If
End Sub
Methods returning numbers just for the hell of it, passwords being saved in plaintext, you name it.
I have a meeting with the original author and I don't know how to handle this situation because I'm quite green in this area.
How can I tactfully mention that I want to rewrite the whole thing?