problema al trabajar con 3 capas
Publicado por djnilo (24 intervenciones) el 03/09/2016 15:22:44
hola buenas tardes
amisgo programadores si alguiien me puede hechar una mano por fa estoy realizando una aplicacion de escritorio
una aplicacion de esataciomiento en tres capas
es parte graba me da error en el boton
Result = objinsertarregistrovehiculo.Insert(eregistrovehiculo) (error el valor no se puede convertir en integer )
error en esta linea de codigo
esto es lo que tengo en la capa de negocios aqui debo tener el error integer
capa datos
amisgo programadores si alguiien me puede hechar una mano por fa estoy realizando una aplicacion de escritorio
una aplicacion de esataciomiento en tres capas
es parte graba me da error en el boton
Result = objinsertarregistrovehiculo.Insert(eregistrovehiculo) (error el valor no se puede convertir en integer )
error en esta linea de codigo
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
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BtnRegistroMatricula.Click
Dim datos As New vregistro
Dim insertar As New fregistro
Dim eregistrovehiculo As New vregistrovehiculo
Dim objinsertarregistrovehiculo As New BLLRegistroVehiculo
Dim Result As Integer = 0
Try
eregistrovehiculo.Fecha_Hora_Entrada = Convert.ToDateTime(TxtFechaHora.Text)
eregistrovehiculo.Placa_vehiculo = TxtMatricula.Text
eregistrovehiculo.Codigo = TxtCodigo.Text
Result = objinsertarregistrovehiculo.Insert(eregistrovehiculo) (error el valor no se puede convertir en integer )
If Result > 0 Then
MessageBox.Show("Se guardó el ticker satisfactoriamente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information)
BtnRegistroMatricula.Enabled = False
Else
MessageBox.Show("No se pudo grabar el ticker", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
esto es lo que tengo en la capa de negocios aqui debo tener el error integer
1
2
3
4
5
6
7
8
9
10
11
12
13
Imports Capa_Datos
Imports Capa_Entidad
Public Class BLLRegistroVehiculo
Public Function Insert(eregistrovehiculo As vregistrovehiculo) As vregistrovehiculo
Dim Oregistrovehiculo As New DAORegistroVehiculo
Try
Return Oregistrovehiculo.Insert(eregistrovehiculo)
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Function
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
Imports CAPA_ENTIDAD
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Public Class DAORegistroVehiculo
Public Function Insert(eregistrovehiculo As vregistrovehiculo) As vregistrovehiculo
Dim Conn As New SqlConnection(Conexion.Connectionstring)
Dim Comand As New SqlCommand()
Dim T As SqlTransaction
Try
Conn.Open()
T = Conn.BeginTransaction
Comand.CommandText = "SP_Inserta_RegistroVehiculo"
Comand.CommandType = CommandType.StoredProcedure
Comand.Connection = Conn
Comand.Transaction = T
Comand.Parameters.Add("@IdTicker", SqlDbType.Int).Direction = ParameterDirection.Output
Comand.Parameters.Add("@PlacaVehiculo", SqlDbType.VarChar, 10).Value = eregistrovehiculo.Placa_vehiculo
Comand.Parameters.Add("@FechaHoraEntrada", SqlDbType.DateTime).Value = eregistrovehiculo.Fecha_Hora_Entrada
Comand.Parameters.Add("@Codigo", SqlDbType.VarChar, 20).Value = eregistrovehiculo.Codigo
Dim Correcto As Integer = Comand.ExecuteNonQuery
If Correcto = 0 Then
T.Rollback()
Throw New Exception("Ha ocurrido un error al guardar los datos")
End If
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
If Conn.State = ConnectionState.Open Then
Conn.Close()
Conn.Dispose()
End If
End Try
Return eregistrovehiculo
End Function
End Class[/code
]
capa entidad
[code]Public Class vregistrovehiculo
Public Sub New()
End Sub
Public Property IdTicker As Integer
Public Property Fecha_Hora_Entrada As DateTime
Public Property Fecha_Hora_Salida As DateTime
Public Property Duracion As Integer
Public Property Valor_pagar As Integer
Public Property Placa_vehiculo As string
Public Property IdTipoUsuario As Integer
Public Property Codigo As String
End Class
Valora esta pregunta


0