Se trabajo en los listados de Viajes y Contratos de V&A con su CRUD y PA. Se eliminó Crear Viajes y ContratoTransporte, ya que lo termina absorbiendo los listados

This commit is contained in:
AbrahamCastilloV
2023-12-13 09:16:58 -07:00
parent 47caaa3997
commit f4eba5924f
8 changed files with 641 additions and 648 deletions

View File

@@ -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