-
-
-
-
+
+
+
+
+
diff --git a/Transportes/RepContratos.aspx.vb b/Transportes/RepContratos.aspx.vb
index 49595fc44..3877a3cdb 100644
--- a/Transportes/RepContratos.aspx.vb
+++ b/Transportes/RepContratos.aspx.vb
@@ -5,13 +5,20 @@ Imports Extensiones.ModExtensiones
Partial Class ListadoContratos
Inherits ClsPaginas
+ Private Property CveContrato As Integer
+ Get
+ Return ViewState("CveContrato").ToString().ToEntero
+ End Get
+ Set(value As Integer)
+ ViewState("CveContrato") = value
+ End Set
+ End Property
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
InicializaCombos()
CargaDatos()
End If
End Sub
-
Private Sub InicializaCombos()
DdlClientes.setEsWebService(True)
'Lista Activos Fijos'
@@ -25,7 +32,6 @@ Partial Class ListadoContratos
DdlTransporte.DataBind()
ObjAF.Dispose()
End Sub
-
Private Sub CargaDatos()
Dim ObjContratos As New ClsContratos
If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, TipoContrato:=2) Then
@@ -34,7 +40,6 @@ Partial Class ListadoContratos
ObjContratos.Dispose()
GvContratos.DataBind()
End Sub
-
Protected Sub MostrarModal()
TxtDescripcion.Text = ""
TxtFechaSalida.Text = ""
@@ -43,6 +48,8 @@ Partial Class ListadoContratos
TxtUbicacion.Text = ""
DdlTransporte.SelectedValue = ""
BtnGuardar.Text = "Guardar"
+ myModalLabel.InnerHtml = "Agregar Contrato"
+
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar"))
End Sub
Private Sub LBAgregarContrato_Click(sender As Object, e As EventArgs) Handles LBAgregarContrato.Click
@@ -63,27 +70,39 @@ Partial Class ListadoContratos
Dim CveEstatusInicial As Integer = 10
Dim CveContratoHijo As Integer = -1
Dim CveContratoTipo As Integer = 2
+ Dim retorno As Boolean = False
If ObjContratos.GetContratosEstatus(UsuarioActual.CveEmpresa) Then
CveEstatusInicial = ObjContratos.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus=1").ToEntero
End If
-
- CveContratoHijo = ObjContratos.AddContratos("", TxtDescripcion.Text, "", UsuarioActual.CveProveedor, DdlClientes.SelectedValue.ToEntero, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", 10, -1, -1, -1, -1, "", "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, -1, -1, -1, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1, CveTipoAF:=DdlTransporte.SelectedValue.ToEntero)
-
+ 'Agregar contrato
+ If BtnGuardar.Text = "Guardar" Then
+ CveContratoHijo = ObjContratos.AddContratos("", TxtDescripcion.Text, "", UsuarioActual.CveProveedor, DdlClientes.SelectedValue.ToEntero, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", 10, -1, -1, -1, -1, "", "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, -1, -1, -1, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1, CveTipoAF:=DdlTransporte.SelectedValue.ToEntero)
+ End If
If CveContratoHijo > 0 Then
ObjContratos.Commit()
Alert("Agregado Correctamente.")
- TxtDescripcion.Text = ""
- TxtFechaSalida.Text = ""
- TxtFechaRegreso.Text = ""
- TxtObservaciones.Text = ""
- TxtUbicacion.Text = ""
- DdlClientes.SelectedValue = ""
- DdlTransporte.SelectedValue = ""
-
End If
+ 'Actualizar contrato
+ If BtnGuardar.Text = "Editar" Then
+ retorno = ObjContratos.UpdateContratos(CveContrato, "", TxtDescripcion.Text, "", -1, DdlClientes.SelectedValue.ToEntero, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", 10, -1, -1, -1, -1, "", "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, -1, -1, -1, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1)
+ End If
+
+ If retorno Then
+ ObjContratos.Commit()
+ Alert("Actualizado Correctamente.")
+ End If
+
+ TxtDescripcion.Text = ""
+ TxtFechaSalida.Text = ""
+ TxtFechaRegreso.Text = ""
+ TxtObservaciones.Text = ""
+ TxtUbicacion.Text = ""
+ DdlClientes.SelectedValue = ""
+ DdlTransporte.SelectedValue = ""
+ BtnGuardar.Text = "Guardar"
Catch ex As Exception
Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError)
ObjContratos.RollBack()
@@ -94,7 +113,6 @@ Partial Class ListadoContratos
End Try
End Sub
-
Protected Sub UpdateContrato(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
@@ -102,7 +120,11 @@ Partial Class ListadoContratos
Dim fechaInicial As DateTime
Dim fechaFinal As DateTime
+ CveContrato = GvRow.DataKey("CveContrato").ToEntero
DdlClientes.SelectedValue = GvRow.DataKey("CveCliente")
+ If GvRow.DataKey("CveCliente").ToEntero > 0 Then
+ DdlClientes.SelectedText = GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=GvRow.DataKey("CveCliente").ToEntero).FiltroPrimeroValor("NombreComercial")
+ End If
TxtDescripcion.Text = GvRow.DataKey("DescripcionContrato")
TxtObservaciones.Text = GvRow.DataKey("DescripcionContrato")
TxtUbicacion.Text = GvRow.DataKey("Ubicacion")
@@ -112,12 +134,10 @@ Partial Class ListadoContratos
TxtFechaRegreso.Text = fechaFinal.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T")
End If
-
BtnGuardar.Text = "Editar"
-
+ myModalLabel.InnerHtml = "Editar Contrato"
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar"))
End Sub
-
Protected Sub RemoveContrato(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim ObjContratos As New ClsContratos