--Se crean los métodos faltantes del CRUD para la tabla de destinos, rutas e importes con sus respectivos procedimientos almacenados. Se agregan los datakeys a los Gv de Rutas, Destinos e importes, se agregan códigos de color a los estatus, se unifican los botones para agregar y modificar las clases y se agrega un modal dinámico con el panel apropiado para cada textbox. Se agrega una Cve para guardar el valor de la clave al ser modificado, se agregan los dropdownlist de CveOrigen y CveFinal para los importes y CveRuta, se crea el método para mostrar modal dinámico y los métodos del CRUD.
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Partial Class CatRutas
|
||||
Inherits ClsPaginas
|
||||
|
||||
Private Property Cve As Integer
|
||||
Get
|
||||
Return ViewState("Cve").ToString().ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("Cve") = value
|
||||
End Set
|
||||
End Property
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
InicializaCalendar()
|
||||
ViewState("Cve") = 0
|
||||
InicializarCombos()
|
||||
CargaDatos()
|
||||
End If
|
||||
|
||||
@@ -34,48 +45,243 @@ Partial Class CatRutas
|
||||
GvImportes.DataBind()
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub InicializaCalendar()
|
||||
UpPanel.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub InicializarCombos()
|
||||
Dim ObjDestinos As New ClsTransportes()
|
||||
|
||||
If ObjDestinos.GetDestinos() Then
|
||||
|
||||
If ObjDestinos.DtResultados.Rows.Count > 0 Then
|
||||
|
||||
DdlOrigen.DataSource = ObjDestinos.DtResultados
|
||||
DdlOrigen.DataBind()
|
||||
DdlOrigen.Items.Insert(0, New ListItem("Seleccione Partida", ""))
|
||||
|
||||
DdlFinal.DataSource = ObjDestinos.DtResultados
|
||||
DdlFinal.DataBind()
|
||||
DdlFinal.Items.Insert(0, New ListItem("Seleccione Destino", ""))
|
||||
End If
|
||||
End If
|
||||
ObjDestinos.Dispose()
|
||||
|
||||
|
||||
Dim ObjRutas As New ClsTransportes()
|
||||
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
|
||||
End Sub
|
||||
|
||||
Protected Sub MostrarModal(sender As Object, e As EventArgs)
|
||||
TxtRuta.Text = ""
|
||||
DdlRutaEstatus.SelectedValue = ""
|
||||
TxtDestino.Text = ""
|
||||
DdlEsNacional.SelectedValue = ""
|
||||
DdlDestinoEstatus.SelectedValue = ""
|
||||
DdlOrigen.SelectedValue = ""
|
||||
DdlFinal.SelectedValue = ""
|
||||
TxtImporte.Text = ""
|
||||
BtnAddRuta.Visible = False
|
||||
BtnAddDestino.Visible = False
|
||||
BtnAddImporte.Visible = False
|
||||
PnRuta.Visible = False
|
||||
PnDestino.Visible = False
|
||||
PnImporte.Visible = False
|
||||
Dim id As String = DirectCast(sender, LinkButton).ID
|
||||
|
||||
If id.Contains("Editar") Then
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
Select Case id
|
||||
Case "BtnEditarRuta"
|
||||
ModalLabel.Text = "Editar Ruta"
|
||||
PnRuta.Visible = True
|
||||
TxtRuta.Text = GvRow.DataKey("Ruta")
|
||||
DdlRutaEstatus.SelectedValue = GvRow.DataKey("Estatus")
|
||||
BtnAddRuta.Visible = True
|
||||
BtnAddRuta.Text = "Editar"
|
||||
ViewState("Cve") = GvRow.DataKey("CveRuta").ToEntero
|
||||
|
||||
|
||||
Case "BtnEditarDestino"
|
||||
ModalLabel.Text = "Editar Destino"
|
||||
TxtDestino.Text = GvRow.DataKey("Destino")
|
||||
DdlEsNacional.SelectedValue = GvRow.DataKey("EsNacional")
|
||||
DdlDestinoEstatus.SelectedValue = GvRow.DataKey("Estatus")
|
||||
PnDestino.Visible = True
|
||||
BtnAddDestino.Visible = True
|
||||
BtnAddDestino.Text = "Editar"
|
||||
ViewState("Cve") = GvRow.DataKey("CveDestino").ToEntero
|
||||
|
||||
|
||||
Case "BtnEditarImporte"
|
||||
ModalLabel.Text = "Editar Importe"
|
||||
DdlRutas.SelectedValue = GvRow.DataKey("CveRuta")
|
||||
DdlOrigen.SelectedValue = GvRow.DataKey("CveDestinoOrigen")
|
||||
DdlFinal.SelectedValue = GvRow.DataKey("CveDestinoFinal")
|
||||
TxtImporte.Text = GvRow.DataKey("Importe")
|
||||
PnImporte.Visible = True
|
||||
BtnAddImporte.Visible = True
|
||||
BtnAddImporte.Text = "Editar"
|
||||
ViewState("Cve") = GvRow.DataKey("CveDestinoTarifa").ToEntero
|
||||
|
||||
|
||||
End Select
|
||||
End If
|
||||
|
||||
If id.Contains("Agregar") Then
|
||||
Select Case id
|
||||
Case "BtnAgregarRuta"
|
||||
ModalLabel.Text = "Agregar Ruta"
|
||||
PnRuta.Visible = True
|
||||
BtnAddRuta.Visible = True
|
||||
BtnAddRuta.Text = "Guardar"
|
||||
Case "BtnAgregarDestino"
|
||||
ModalLabel.Text = "Agregar Destino"
|
||||
PnDestino.Visible = True
|
||||
BtnAddDestino.Visible = True
|
||||
BtnAddDestino.Text = "Guardar"
|
||||
Case "BtnAgregarImporte"
|
||||
ModalLabel.Text = "Agregar Importe"
|
||||
PnImporte.Visible = True
|
||||
BtnAddImporte.Visible = True
|
||||
BtnAddImporte.Text = "Guardar"
|
||||
|
||||
End Select
|
||||
End If
|
||||
UpModal.Update()
|
||||
RegistraScript(String.Format("$('#{0}').modal('show');", "Modal"))
|
||||
End Sub
|
||||
|
||||
|
||||
#Region "Rutas"
|
||||
Protected Sub AddRuta(sender As Object, e As EventArgs)
|
||||
|
||||
End Sub
|
||||
Protected Sub UpdateRuta(sender As Object, e As EventArgs)
|
||||
Dim ObjRuta As New ClsTransportes
|
||||
ObjRuta.IniciaTransacSQL()
|
||||
Try
|
||||
If BtnAddRuta.Text = "Guardar" Then
|
||||
If ObjRuta.AddRuta(TxtRuta.Text, DdlRutaEstatus.SelectedValue, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) > 1 Then
|
||||
ObjRuta.Commit()
|
||||
Alert("Ruta Agregada Correctamente.")
|
||||
End If
|
||||
End If
|
||||
|
||||
If BtnAddRuta.Text = "Editar" Then
|
||||
If ObjRuta.UpdateRuta(Cve, TxtRuta.Text, DdlRutaEstatus.SelectedValue, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||||
ObjRuta.Commit()
|
||||
Alert("Ruta Actualizada Correctamente.")
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ObjRuta.RollBack()
|
||||
Finally
|
||||
CargaDatos()
|
||||
ObjRuta.Dispose()
|
||||
End Try
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub RemoveRuta(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim ObjRuta As New ClsTransportes
|
||||
|
||||
If ObjRuta.RemoveRuta(GvRow.DataKey("CveRuta").ToEntero) Then
|
||||
Alert("Ruta eliminada correctamente")
|
||||
CargaDatos()
|
||||
End If
|
||||
|
||||
ObjRuta.Dispose()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "Destinos"
|
||||
Protected Sub AddDestino(sender As Object, e As EventArgs)
|
||||
|
||||
End Sub
|
||||
Protected Sub UpdateDestino(sender As Object, e As EventArgs)
|
||||
Dim ObjDestino As New ClsTransportes
|
||||
ObjDestino.IniciaTransacSQL()
|
||||
Try
|
||||
If BtnAddDestino.Text = "Guardar" Then
|
||||
If ObjDestino.AddDestino(TxtDestino.Text, DdlDestinoEstatus.SelectedValue, DdlEsNacional.SelectedValue, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) > 1 Then
|
||||
ObjDestino.Commit()
|
||||
Alert("Destino agregado correctamente.")
|
||||
End If
|
||||
End If
|
||||
|
||||
If BtnAddDestino.Text = "Editar" Then
|
||||
If ObjDestino.UpdateDestino(Cve, TxtDestino.Text, DdlDestinoEstatus.SelectedValue, DdlEsNacional.SelectedValue, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
||||
ObjDestino.Commit()
|
||||
Alert("Destino actualizado correctamente.")
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ObjDestino.RollBack()
|
||||
Finally
|
||||
CargaDatos()
|
||||
ObjDestino.Dispose()
|
||||
End Try
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub RemoveDestino(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim ObjDestino As New ClsTransportes
|
||||
|
||||
If ObjDestino.RemoveDestino(GvRow.DataKey("CveDestino").ToEntero) Then
|
||||
Alert("Destino eliminado correctamente")
|
||||
CargaDatos()
|
||||
End If
|
||||
|
||||
ObjDestino.Dispose()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#Region "Importes"
|
||||
Protected Sub AddImporte(sender As Object, e As EventArgs)
|
||||
|
||||
End Sub
|
||||
Protected Sub UpdateImporte(sender As Object, e As EventArgs)
|
||||
Dim ObjImporte As New ClsTransportes
|
||||
ObjImporte.IniciaTransacSQL()
|
||||
Try
|
||||
If BtnAddImporte.Text = "Guardar" Then
|
||||
If ObjImporte.AddDestinosTarifas(DdlRutas.SelectedValue, DdlOrigen.SelectedValue, DdlFinal.SelectedValue, TxtImporte.Text) > 1 Then
|
||||
ObjImporte.Commit()
|
||||
Alert("Importe agregado correctamente.")
|
||||
End If
|
||||
End If
|
||||
|
||||
If BtnAddImporte.Text = "Editar" Then
|
||||
If ObjImporte.UpdateDestinosTarifas(Cve, DdlRutas.SelectedValue, DdlOrigen.SelectedValue, DdlFinal.SelectedValue, TxtImporte.Text) Then
|
||||
ObjImporte.Commit()
|
||||
Alert("Importe actualizado correctamente.")
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
ObjImporte.RollBack()
|
||||
Finally
|
||||
CargaDatos()
|
||||
ObjImporte.Dispose()
|
||||
End Try
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub RemoveImporte(sender As Object, e As EventArgs)
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim ObjImporte As New ClsTransportes
|
||||
|
||||
If ObjImporte.RemoveDestinosTarifas(GvRow.DataKey("CveDestinoTarifa").ToEntero) Then
|
||||
Alert("Importe eliminada correctamente")
|
||||
CargaDatos()
|
||||
End If
|
||||
|
||||
ObjImporte.Dispose()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
Reference in New Issue
Block a user