diff --git a/Transportes/ContratoTransporte.aspx b/Transportes/ContratoTransporte.aspx deleted file mode 100644 index faabd6ff8..000000000 --- a/Transportes/ContratoTransporte.aspx +++ /dev/null @@ -1,165 +0,0 @@ -<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/Site.master" CodeFile="ContratoTransporte.aspx.vb" - Inherits="ContratoTransportes" %> - - - Registro de Contratos - - - - - - - - -
-
-
-
- Datos del Contrato -
- ../SAT/ -
- -
- <%-- cveCliente--%> -
-
- -
-
- -
- -
- - - - -
-
- -
- -
- - - - -
-
- -
- -
-
- - - - - -
-
-
- -
- -
-
- - - - - -
-
-
-
-
- - - - - - - -
-
- -
- -
- - - - -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
- - - - -
- - -
-
- - diff --git a/Transportes/ContratoTransporte.aspx.vb b/Transportes/ContratoTransporte.aspx.vb deleted file mode 100644 index 550aad649..000000000 --- a/Transportes/ContratoTransporte.aspx.vb +++ /dev/null @@ -1,126 +0,0 @@ -Option Explicit On -Option Strict On -Imports ADSNetLibrary.SIGAPI.Helpers -Imports Extensiones -Imports Extensiones.ModExtensiones - -Partial Class ContratoTransportes - Inherits ClsPaginas - - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - - If Not IsPostBack Then - DdlClientes.setEsWebService(True) - 'Lista Activos Fijos' - Dim ObjAF As New ClsAF() - If ObjAF.GetActivosFijos(-1, 13, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, 1, "-1", -1, -1, -1) Then - If ObjAF.DtResultados.Rows.Count > 0 Then - DdlTransporte.DataSource = ObjAF.DtResultados - DdlTransporte.DataBind() - - DdlTransporte.Items.Insert(0, New ListItem("Seleccione Transporte", "")) - End If - End If - ObjAF.Dispose() - If Not String.IsNullOrEmpty(Request.QueryString("CveContrato")) Then - - Dim id As Integer = Convert.ToInt32(Request.QueryString("CveContrato")) - Dim ObjContratos As New ClsContratos - ObjContratos.GetContratos(id, UsuarioActual.CveEmpresa) - - Dim fechaSalida As DateTime - Dim fechaRegreso As DateTime - - If DateTime.TryParse(ObjContratos.FechaInicial.ToString, fechaSalida) And DateTime.TryParse(ObjContratos.FechaFinal.ToString, fechaRegreso) Then - TxtFechaSalida.Text = fechaSalida.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T") - TxtFechaRegreso.Text = fechaRegreso.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T") - End If - - TxtDescripcion.Text = ObjContratos.DescripcionContrato - TxtObservaciones.Text = ObjContratos.DescripcionContrato - TxtUbicacion.Text = ObjContratos.Ubicacion - - - DdlClientes.DataValueField = ObjContratos.CveCliente.ToString - BtnGuardar.Text = "Editar" - End If - - End If - End Sub - - - Protected Sub AddContrato(sender As Object, e As EventArgs) - Dim ObjContratos As New ClsContratos - - - ObjContratos.IniciaTransacSQL() - Page.Response.Write("") - If DdlClientes.SelectedValue = "" Then - Alert("Debe seleccionar al cliente", TipoMensaje.MsgAdvertencia) - Exit Sub - Else - Try - - If BtnGuardar.Text = "Guardar" Then - - Page.Response.Write("") - - Dim CveEstatusInicial As Integer = 10 - Dim CveContratoHijo As Integer = -1 - Dim CveContratoTipo As Integer = 2 - 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) - - - If CveContratoHijo > 0 Then - ObjContratos.Commit() - Alert("El Contrato se registró Correctamente.", TipoMensaje.MsgInformacion) - TxtDescripcion.Text = "" - TxtFechaSalida.Text = "" - TxtFechaRegreso.Text = "" - TxtObservaciones.Text = "" - TxtUbicacion.Text = "" - DdlClientes.SelectedValue = "" - - End If - Else - Dim id As Integer = Convert.ToInt32(Request.QueryString("CveContrato")) - - Dim ContratoEditado As New ClsContratos - ContratoEditado.GetContratos(id, UsuarioActual.CveEmpresa) - - Dim CveEstatusInicial As Integer = 10 - Dim Editar As Boolean = False - Dim CveContratoTipo As Integer = 2 - - If ContratoEditado.GetContratosEstatus(UsuarioActual.CveEmpresa) Then - CveEstatusInicial = ContratoEditado.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus=1").ToEntero - End If - - Editar = ContratoEditado.UpdateContratos(ContratoEditado.CveContrato, id.ToString, TxtDescripcion.Text, ContratoEditado.NumeroLicitacion, ContratoEditado.CveProveedor, ContratoEditado.CveCliente, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", ContratoEditado.CveSubProyecto, ContratoEditado.PorIVA, ContratoEditado.PorAnticipo, ContratoEditado.PorAmortizacionAnticipo, ContratoEditado.PorGarantia, "", "", ContratoEditado.CveContratoPadre, ContratoEditado.CveUsuario, ContratoEditado.CveEmpresa, False, -1, -1, -1, ContratoEditado.CveMoneda, ContratoEditado.ModalidadDetalle, CveContratoTipo:=ContratoEditado.CveContratoTipo, CveContratosEstatus:=ContratoEditado.CveContratosEstatus) - - Page.Response.Write("") - - If Editar = True Then - ContratoEditado.Commit() - Alert("El Contrato se modificó Correctamente.", TipoMensaje.MsgInformacion) - End If - End If - - Catch ex As Exception - ObjContratos.RollBack() - Finally - ObjContratos.Dispose() - Response.Redirect("ListadoContratos.aspx") - - End Try - End If - - End Sub - - - - -End Class diff --git a/Transportes/CrearViaje.aspx b/Transportes/CrearViaje.aspx deleted file mode 100644 index fe19847f4..000000000 --- a/Transportes/CrearViaje.aspx +++ /dev/null @@ -1,127 +0,0 @@ -<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/Site.master" CodeFile="CrearViaje.aspx.vb" - Inherits="CrearViaje" %> - - - - Crear Viaje - - - - - -
- -
-
- - - - - - - -
-
- -
-
- - - - - - -
-
- -
-
- - - - - - -
-
- -
-
- - - - - - -
-
- -
-
- - - - - - -
-
-
- -
-
- - - - - -
-
-
- - -
-
- -
diff --git a/Transportes/CrearViaje.aspx.vb b/Transportes/CrearViaje.aspx.vb deleted file mode 100644 index 514394678..000000000 --- a/Transportes/CrearViaje.aspx.vb +++ /dev/null @@ -1,129 +0,0 @@ -Imports ADSNetLibrary.Helpers -Imports ADSNetLibrary.SIGAPI.Helpers -Imports Extensiones.ModExtensiones - -Partial Class CrearViaje - Inherits ClsPaginas - - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - - If Not IsPostBack Then - CargaDatos() - - If Not String.IsNullOrEmpty(Request.QueryString("CveViaje")) Then - - Dim id As Integer = Convert.ToInt32(Request.QueryString("CveViaje")) - - Dim ObjViajes As New ClsViajes - If ObjViajes.GetViajes(CveViaje:=id) Then - Dim fecha As DateTime - - If DateTime.TryParse(ObjViajes.Fecha.ToString, fecha) Then - TxtFechaViaje.Text = fecha.ToString("yyyy-MM-dd").Replace(" ", "T") - End If - - DdlRutas.Text = ObjViajes.CveRuta.ToString - DdlTransporte.Text = ObjViajes.CveAF.ToString - DdlPartida.Text = ObjViajes.CvePartida.ToString - DdlDestino.Text = ObjViajes.CveDestino.ToString - DdlChofer.Text = ObjViajes.CvePersonal.ToString - - BtnGuardar.Text = "Editar" - End If - - End If - End If - End Sub - - Private Sub CargaDatos() - 'Lista Activos Fijos' - Dim ObjAF As New ClsAF() - If ObjAF.GetActivosFijos(-1, 13, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, 1, "-1", -1, -1, -1) Then - If ObjAF.DtResultados.Rows.Count > 0 Then - DdlTransporte.DataSource = ObjAF.DtResultados - DdlTransporte.DataBind() - - DdlTransporte.Items.Insert(0, New ListItem("Seleccione Transporte", "")) - End If - End If - ObjAF.Dispose() - - 'Lista Rutas' - Dim ObjRutas As New ClsRutas() - If ObjRutas.GetRutas(-1, -1, -1, "", True, DateTime.Now) Then - - If ObjRutas.DtResultados.Rows.Count > 0 Then - DdlRutas.DataSource = ObjRutas.DtResultados - DdlRutas.DataBind() - DdlRutas.Items.Insert(0, New ListItem("Seleccione Ruta", "")) - End If - End If - ObjRutas.Dispose() - - 'Lista Destinos' - Dim ObjDestinos As New ClsDestinos() - If ObjDestinos.GetDestinos(-1, -1, -1, "", True, True, DateTime.Now) Then - - If ObjDestinos.DtResultados.Rows.Count > 0 Then - - DdlPartida.DataSource = ObjDestinos.DtResultados - DdlPartida.DataBind() - DdlPartida.Items.Insert(0, New ListItem("Seleccione Partida", "")) - - DdlDestino.DataSource = ObjDestinos.DtResultados - DdlDestino.DataBind() - DdlDestino.Items.Insert(0, New ListItem("Seleccione Destino", "")) - End If - End If - ObjRutas.Dispose() - 'Lista Chofer' - DdlChofer.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) - DdlChofer.DataBind() - DdlChofer.Items.Insert(0, New ListItem("Seleccione Chofer", "")) - - End Sub - - Protected Sub AddViaje(sender As Object, e As EventArgs) - Dim ObjViajes As New ClsViajes - - - ObjViajes.IniciaTransacSQL() - - Try - - If BtnGuardar.Text = "Guardar" Then - Dim CveContratoHijo As Integer = -1 - CveContratoHijo = ObjViajes.AddViajes(DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, TxtFechaViaje.Text.ToDate, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero) - - If CveContratoHijo > 0 Then - ObjViajes.Commit() - Alert("El Viaje se registró Correctamente.", TipoMensaje.MsgInformacion) - DdlRutas.Text = "" - DdlTransporte.Text = "" - DdlChofer.Text = "" - TxtFechaViaje.Text = "" - DdlPartida.Text = "" - DdlDestino.SelectedValue = "" - - End If - - Else - Dim id As Integer = Convert.ToInt32(Request.QueryString("CveViaje")) - - If ObjViajes.UpdateViajes(id, DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, TxtFechaViaje.Text.ToDate, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero) = True Then - Alert("El viaje se modificó correctamente.", TipoMensaje.MsgInformacion) - ObjViajes.Commit() - - End If - End If - - Catch ex As Exception - ObjViajes.RollBack() - Finally - ObjViajes.Dispose() - Response.Redirect("ListadoViajes.aspx") - - End Try - End Sub - -End Class \ No newline at end of file diff --git a/Transportes/ListadoContratos.aspx b/Transportes/ListadoContratos.aspx index f8e63a7bc..8e32ed62c 100644 --- a/Transportes/ListadoContratos.aspx +++ b/Transportes/ListadoContratos.aspx @@ -35,26 +35,29 @@
  • - Agregar Contrato -
  • -
  • - Crear Viaje -
  • + Contratos +
  • Listado de Viajes + Target="_blank">Viajes
  • + + +
    + +
    + + data-sort="true" DataKeyNames="CveContrato, DescripcionContrato, Ubicacion, FechaInicial, FechaFinal, CveCliente, CveTipoAF"> @@ -69,7 +72,7 @@ - + @@ -95,17 +98,173 @@ - + - - + + + + +
    diff --git a/Transportes/ListadoContratos.aspx.vb b/Transportes/ListadoContratos.aspx.vb index 8a0cd53c3..0294ccb64 100644 --- a/Transportes/ListadoContratos.aspx.vb +++ b/Transportes/ListadoContratos.aspx.vb @@ -1,5 +1,7 @@ Option Explicit On Option Strict On +Imports ADSNetLibrary.SIGAPI.Helpers +Imports Extensiones.ModExtensiones Partial Class ListadoContratos @@ -14,44 +16,148 @@ Partial Class ListadoContratos Private Sub CargaDatos() Dim ObjContratos As New ClsContratos + ObjContratos.IniciaTransacSQL() + If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, TipoContrato:=2) Then GvContratos.DataSource = ObjContratos.DtResultados + ObjContratos.Dispose() + GvContratos.DataBind() Else Me.GvContratos.DataSource = Nothing End If + + DdlClientes.setEsWebService(True) + 'Lista Activos Fijos' + Dim ObjAF As New ClsAF() + If ObjAF.GetActivosFijos(-1, 13, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, 1, "-1", -1, -1, -1) Then + If ObjAF.DtResultados.Rows.Count > 0 Then + DdlTransporte.DataSource = ObjAF.DtResultados + DdlTransporte.DataBind() + + DdlTransporte.Items.Insert(0, New ListItem("Seleccione Transporte", "")) + End If + End If + ObjAF.Dispose() + ObjContratos.Dispose() - GvContratos.DataBind() End Sub - Protected Sub GvContratos_Comandos(sender As Object, e As GridViewCommandEventArgs) - Dim id As Integer = Convert.ToInt32(e.CommandArgument) - Dim url As String = $"ContratoTransporte.aspx?CveContrato={id}" + Protected Sub MostrarModal(sender As Object, e As System.EventArgs) + TxtDescripcion.Text = "" + TxtFechaSalida.Text = "" + TxtFechaRegreso.Text = "" + TxtObservaciones.Text = "" + TxtUbicacion.Text = "" + DdlTransporte.SelectedValue = "" + BtnGuardar.Text = "Guardar" + RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar")) + End Sub - If e.CommandName = "Editar" Then - Dim script As String = $"window.open('{url}', '_blank');" - Page.ClientScript.RegisterStartupScript(Me.GetType(), "OpenWindow", script, True) + Protected Sub AddContrato(sender As Object, e As EventArgs) + + Dim ObjContratos As New ClsContratos + + ObjContratos.IniciaTransacSQL() + If DdlClientes.SelectedValue = "" Then + Alert("Debe seleccionar al cliente", TipoMensaje.MsgAdvertencia) + Exit Sub End If - If e.CommandName = "Eliminar" Then - Dim ObjContratos As New ClsContratos - ObjContratos.IniciaTransacSQL() + Try - Try - ObjContratos.RemoveContrato(id, UsuarioActual.CveEmpresa) - ObjContratos.Commit() - Catch ex As Exception - ObjContratos.RollBack() - Finally - ObjContratos.Dispose() - Response.Redirect("ListadoContratos.aspx") - End Try + If BtnGuardar.Text = "Guardar" Then - End If + Dim CveEstatusInicial As Integer = 10 + Dim CveContratoHijo As Integer = -1 + Dim CveContratoTipo As Integer = 2 + 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) + 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 + Else + Dim id As Integer = Convert.ToInt32(Request.QueryString("CveContrato")) + + Dim ContratoEditado As New ClsContratos + ContratoEditado.GetContratos(id, UsuarioActual.CveEmpresa) + + Dim CveEstatusInicial As Integer = 10 + Dim Editar As Boolean = False + Dim CveContratoTipo As Integer = 2 + + If ContratoEditado.GetContratosEstatus(UsuarioActual.CveEmpresa) Then + CveEstatusInicial = ContratoEditado.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus=1").ToEntero + End If + + Editar = ContratoEditado.UpdateContratos(ContratoEditado.CveContrato, id.ToString, TxtDescripcion.Text, ContratoEditado.NumeroLicitacion, ContratoEditado.CveProveedor, ContratoEditado.CveCliente, -1, TxtFechaSalida.Text.ToDate, TxtFechaRegreso.Text.ToDate, TxtUbicacion.Text, "", ContratoEditado.CveSubProyecto, ContratoEditado.PorIVA, ContratoEditado.PorAnticipo, ContratoEditado.PorAmortizacionAnticipo, ContratoEditado.PorGarantia, "", "", ContratoEditado.CveContratoPadre, ContratoEditado.CveUsuario, ContratoEditado.CveEmpresa, False, -1, -1, -1, ContratoEditado.CveMoneda, ContratoEditado.ModalidadDetalle, CveContratoTipo:=ContratoEditado.CveContratoTipo, CveContratosEstatus:=ContratoEditado.CveContratosEstatus) + + If Editar = True Then + ContratoEditado.Commit() + Alert("El Contrato se modificó Correctamente.") + End If + End If + + Catch ex As Exception + Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError) + ObjContratos.RollBack() + Finally + ObjContratos.Dispose() + Response.Redirect("ListadoContratos.aspx") + + End Try End Sub + Protected Sub UpdateContrato(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim fechaInicial As DateTime + Dim fechaFinal As DateTime + + DdlClientes.SelectedValue = GvRow.DataKey("CveCliente") + TxtDescripcion.Text = GvRow.DataKey("DescripcionContrato") + TxtObservaciones.Text = GvRow.DataKey("DescripcionContrato") + TxtUbicacion.Text = GvRow.DataKey("Ubicacion") + DdlTransporte.SelectedValue = GvRow.DataKey("CveTipoAF") + If DateTime.TryParse(GvRow.DataKey("FechaInicial").ToString, fechaInicial) And DateTime.TryParse(GvRow.DataKey("FechaFinal").ToString, fechaFinal) Then + TxtFechaSalida.Text = fechaInicial.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T") + TxtFechaRegreso.Text = fechaFinal.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T") + End If + + + BtnGuardar.Text = "Editar" + + 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 + + ObjContratos.IniciaTransacSQL() + Try + ObjContratos.RemoveContrato(GvRow.DataKey("CveContrato").ToEntero, UsuarioActual.CveEmpresa) + ObjContratos.Commit() + Response.Redirect(Request.RawUrl) + + Catch ex As Exception + Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError) + Finally + ObjContratos.Dispose() + End Try + End Sub End Class diff --git a/Transportes/ListadoViajes.aspx b/Transportes/ListadoViajes.aspx index b26a1da91..f6b0ddc6f 100644 --- a/Transportes/ListadoViajes.aspx +++ b/Transportes/ListadoViajes.aspx @@ -2,7 +2,8 @@ Inherits="ListadoViajes" %> -Listado de Viajes + Listado de Viajes + + + +
  • + Contratos +
  • +
  • + Viajes +
  • +
    + +
    + - - - - - - - - + +
    + +
    - - - - - + + - - - - - + + + + + - - - - - + + + + + + + + + + - - - - - + + + + + - + + + + + - - - - - - - - + + + + + -
    + + + + + + + + + + +
    diff --git a/Transportes/ListadoViajes.aspx.vb b/Transportes/ListadoViajes.aspx.vb index b3f110e31..ce7af328a 100644 --- a/Transportes/ListadoViajes.aspx.vb +++ b/Transportes/ListadoViajes.aspx.vb @@ -1,6 +1,7 @@ Option Explicit On Option Strict On - +Imports ADSNetLibrary.SIGAPI.Helpers +Imports Extensiones.ModExtensiones Partial Class ListadoViajes Inherits ClsPaginas @@ -15,42 +16,148 @@ Partial Class ListadoViajes Private Sub CargaDatos() Dim ObjViajes As New ClsViajes + ObjViajes.IniciaTransacSQL() If ObjViajes.GetViajes() Then GvViajes.DataSource = ObjViajes.DtResultados + ObjViajes.Dispose() + GvViajes.DataBind() Else Me.GvViajes.DataSource = Nothing End If + 'Lista Activos Fijos' + Dim ObjAF As New ClsAF() + If ObjAF.GetActivosFijos(-1, 13, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, 1, "-1", -1, -1, -1) Then + If ObjAF.DtResultados.Rows.Count > 0 Then + DdlTransporte.DataSource = ObjAF.DtResultados + DdlTransporte.DataBind() + + DdlTransporte.Items.Insert(0, New ListItem("Seleccione Transporte", "")) + End If + End If + ObjAF.Dispose() + + 'Lista Rutas' + Dim ObjRutas As New ClsRutas() + If ObjRutas.GetRutas(-1, -1, -1, "", True, DateTime.Now) Then + + If ObjRutas.DtResultados.Rows.Count > 0 Then + DdlRutas.DataSource = ObjRutas.DtResultados + DdlRutas.DataBind() + DdlRutas.Items.Insert(0, New ListItem("Seleccione Ruta", "")) + End If + End If + ObjRutas.Dispose() + + 'Lista Destinos' + Dim ObjDestinos As New ClsDestinos() + If ObjDestinos.GetDestinos(-1, -1, -1, "", True, True, DateTime.Now) Then + + If ObjDestinos.DtResultados.Rows.Count > 0 Then + + DdlPartida.DataSource = ObjDestinos.DtResultados + DdlPartida.DataBind() + DdlPartida.Items.Insert(0, New ListItem("Seleccione Partida", "")) + + DdlDestino.DataSource = ObjDestinos.DtResultados + DdlDestino.DataBind() + DdlDestino.Items.Insert(0, New ListItem("Seleccione Destino", "")) + End If + End If + ObjRutas.Dispose() + 'Lista Chofer' + DdlChofer.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa) + DdlChofer.DataBind() + DdlChofer.Items.Insert(0, New ListItem("Seleccione Chofer", "")) - ObjViajes.Dispose() - GvViajes.DataBind() - Page.Response.Write("") End Sub - Protected Sub GvViajes_Comandos(sender As Object, e As GridViewCommandEventArgs) - Dim id As Integer = Convert.ToInt32(e.CommandArgument) - Dim url As String = $"CrearViaje.aspx?CveViaje={id}" + Protected Sub MostrarModal(sender As Object, e As System.EventArgs) + DdlRutas.Text = "" + DdlTransporte.Text = "" + DdlChofer.Text = "" + TxtFechaViaje.Text = "" + DdlPartida.Text = "" + DdlDestino.SelectedValue = "" + BtnGuardar.Text = "Guardar" + RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar")) + End Sub - If e.CommandName = "Editar" Then - Dim script As String = $"window.open('{url}', '_blank');" - Page.ClientScript.RegisterStartupScript(Me.GetType(), "OpenWindow", script, True) + Protected Sub AddViaje(sender As Object, e As EventArgs) + Dim ObjViajes As New ClsViajes + + ObjViajes.IniciaTransacSQL() + + Try + + If BtnGuardar.Text = "Guardar" Then + Dim CveContratoHijo As Integer = -1 + CveContratoHijo = ObjViajes.AddViajes(DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, TxtFechaViaje.Text.ToDate, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero) + + If CveContratoHijo > 0 Then + ObjViajes.Commit() + Alert("El Viaje se registró Correctamente.", TipoMensaje.MsgInformacion) + DdlRutas.Text = "" + DdlTransporte.Text = "" + DdlChofer.Text = "" + TxtFechaViaje.Text = "" + DdlPartida.Text = "" + DdlDestino.SelectedValue = "" + + End If + + Else + Dim id As Integer = Convert.ToInt32(Request.QueryString("CveViaje")) + + If ObjViajes.UpdateViajes(id, DdlRutas.Text.ToEntero, DdlTransporte.Text.ToEntero, DdlChofer.Text.ToEntero, UsuarioActual.CveEmpresa, TxtFechaViaje.Text.ToDate, DdlPartida.Text.ToEntero, DdlDestino.Text.ToEntero) = True Then + Alert("El viaje se modificó correctamente.", TipoMensaje.MsgInformacion) + ObjViajes.Commit() + + End If + End If + + Catch ex As Exception + ObjViajes.RollBack() + Finally + ObjViajes.Dispose() + Response.Redirect("ListadoViajes.aspx") + + End Try + End Sub + + Protected Sub UpdateViaje(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + DdlTransporte.SelectedValue = GvRow.DataKey("CveAF") + DdlRutas.SelectedValue = GvRow.DataKey("CveRuta") + DdlDestino.SelectedValue = GvRow.DataKey("CveDestino") + DdlPartida.SelectedValue = GvRow.DataKey("CvePartida") + DdlChofer.SelectedValue = GvRow.DataKey("CvePersonal") + Dim fecha As DateTime + + If DateTime.TryParse(GvRow.DataKey("Fecha").ToString, fecha) Then + TxtFechaViaje.Text = fecha.ToString("yyyy-MM-dd").Replace(" ", "T") End If - If e.CommandName = "Eliminar" Then - Dim ObjViajes As New ClsViajes - ObjViajes.IniciaTransacSQL() - Try - ObjViajes.RemoveViaje(id) - ObjViajes.Commit() - Catch ex As Exception - ObjViajes.RollBack() - Finally - ObjViajes.Dispose() - Response.Redirect("ListadoViajes.aspx") - End Try + BtnGuardar.Text = "Editar" - End If + RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar")) + End Sub + Protected Sub RemoveViaje(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim ObjViajes As New ClsViajes + + ObjViajes.IniciaTransacSQL() + Try + ObjViajes.RemoveViaje(GvRow.DataKey("CveViaje").ToEntero) + ObjViajes.Commit() + Response.Redirect(Request.RawUrl) + Catch ex As Exception + Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError) + Finally + ObjViajes.Dispose() + End Try End Sub End Class