This commit is contained in:
2024-02-07 05:20:04 -07:00
26 changed files with 5100 additions and 551 deletions

View File

@@ -1,5 +1,6 @@
Option Explicit On
Option Strict On
Imports System.Data.SqlClient
Imports Extensiones
Imports Extensiones.ModExtensiones
@@ -22,15 +23,6 @@ Partial Class ListadoContratos
End If
End Sub
Private Sub InicializaCombos()
'Lista Activos Fijos'
'Dim ObjAF As New ClsAF()
'If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, 1, "-1", -1, -1, -1) Then
' If ObjAF.DtResultados.Rows.Count > 0 Then
' DdlAF.DataSource = ObjAF.DtResultados
' DdlAF.Items.Insert(0, New ListItem("Seleccione", ""))
' End If
'End If
'ObjAF.Dispose()
DdlTipoAF.DataSource = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa)
DdlTipoAF.DataBind()
DdlTipoAF.Items.Insert(0, New ListItem("Seleccione", ""))
@@ -40,7 +32,6 @@ Partial Class ListadoContratos
DdlChofer.DataBind()
DdlChofer.Items.Insert(0, New ListItem("Seleccione", ""))
UpModal.Update()
End Sub
Private Sub CargaDatos()
@@ -48,14 +39,15 @@ Partial Class ListadoContratos
If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, TipoContrato:=2) Then
GvContratos.DataSource = ObjContratos.DtResultados
End If
ObjContratos.Dispose()
GvContratos.DataBind()
UpTitulos.Update()
End Sub
Protected Sub MostrarModal(Optional Descripcion As String = "", Optional FechaSalida As String = "", Optional FechaRegreso As String = "", Optional Observaciones As String = "", Optional Ubicacion As String = "", Optional Transporte As String = "", Optional CveCliente As Integer = 0, Optional Dolares As String = "", Optional Pesos As String = "", Optional Anticipo As String = "", Optional Boton As String = "Guardar", Optional Chofer As String = "")
DdlClientes.SelectedText = Cliente
TxtDescripcion.Text = Descripcion
TxtUbicacion.Text = Ubicacion
TxtFechaSalida.Text = FechaSalida
TxtFechaRegreso.Text = FechaRegreso
TxtObservaciones.Text = Observaciones
@@ -64,10 +56,17 @@ Partial Class ListadoContratos
DdlClientes.SelectedText = GlobalDTCliente(UsuarioActual.CveEmpresa, -1, CveCliente:=CveCliente).FiltroPrimeroValor("NombreComercial")
DdlClientes.SelectedValue = CveCliente.ToString
DdlChofer.SelectedValue = Chofer
TxtObservaciones.Text = Observaciones
TxtDolares.Text = Dolares
TxtPesos.Text = Pesos
TxtAnticipo.Text = Anticipo
BtnGuardar.Text = Boton
If EstatusContrato <> "" Then
LbEstatus.Visible = True
DdlEstatusContrato.Visible = True
DdlEstatusContrato.SelectedValue = EstatusContrato
End If
'DdlEstatusContrato.Text = EstatusContrato
myModalLabel.InnerHtml = $"{Boton} Contrato"
UpModal.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "ModalAgregar"))
@@ -91,49 +90,54 @@ Partial Class ListadoContratos
Dim retorno As Boolean = False
If ObjContratos.GetContratosEstatus(UsuarioActual.CveEmpresa) Then
CveEstatusInicial = ObjContratos.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus=1").ToEntero
End If
CveEstatusInicial = ObjContratos.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus=1").ToEntero
End If
'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, TxtAnticipo.Text.ToDecimal, TxtPesos.Text.ToDecimal, TxtDolares.Text.ToDecimal, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1, CveTipoAF:=DdlTipoAF.SelectedValue.ToEntero, CveChofer:=DdlChofer.SelectedValue.ToEntero)
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, TxtAnticipo.Text.ToDecimal, TxtPesos.Text.ToDecimal, TxtDolares.Text.ToDecimal, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1, CveTipoAF:=DdlTransporte.SelectedValue.ToEntero, CveChofer:=DdlChofer.SelectedValue.ToEntero)
If CveContratoHijo > 0 Then
ObjContratos.Commit()
Alert("Agregado Correctamente.")
End If
Else
'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, TxtAnticipo.Text.ToDecimal, TxtPesos.Text.ToDecimal, TxtDolares.Text.ToDecimal, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1, CveChofer:=DdlChofer.SelectedValue.ToEntero, CveTipoAF:=DdlTipoAF.SelectedValue.ToEntero)
End If
If retorno Then
ObjContratos.Commit()
Alert("Actualizado Correctamente.")
End If
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, TxtAnticipo.Text.ToDecimal, TxtPesos.Text.ToDecimal, TxtDolares.Text.ToDecimal, -1, 0, CveContratoTipo:=2, CveContratosEstatus:=1, CveChofer:=DdlChofer.SelectedValue.ToEntero, CveTipoAF:=DdlTransporte.SelectedValue.ToEntero)
ObjContratos.Commit()
Alert("Actualizado Correctamente.")
End If
End If
End If
TxtDescripcion.Text = ""
TxtFechaSalida.Text = ""
TxtFechaRegreso.Text = ""
TxtObservaciones.Text = ""
TxtUbicacion.Text = ""
DdlClientes.SelectedText = ""
'DdlTipoAF.SelectedValue = "-1"
'DdlChofer.SelectedValue = "-1"
TxtFechaSalida.Text = ""
TxtFechaRegreso.Text = ""
TxtObservaciones.Text = ""
TxtUbicacion.Text = ""
DdlClientes.SelectedText = ""
DdlTransporte.SelectedValue = ""
DdlChofer.SelectedValue = ""
TxtDolares.Text = ""
TxtPesos.Text = ""
TxtAnticipo.Text = ""
BtnGuardar.Text = "Guardar"
Catch ex As Exception
Alert($"Ocurrió un error {ex}", TipoMensaje.MsgError)
ObjContratos.RollBack()
Finally
ObjContratos.Dispose()
CargaDatos()
End Try
End Sub
Protected Sub UpdateContrato(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
ViewState("CveContrato") = GvRow.DataKey("CveContrato")
MostrarModal(
Descripcion:=GvRow.DataKey("DescripcionContrato"), FechaSalida:=GvRow.DataKey("FechaInicial").ToDateTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T"), FechaRegreso:=GvRow.DataKey("FechaFinal").ToDateTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T"), Observaciones:=GvRow.DataKey("DescripcionContrato"), Ubicacion:=GvRow.DataKey("Ubicacion"), Transporte:=GvRow.DataKey("CveTipoAF"), CveCliente:=GvRow.DataKey("CveCliente").ToEntero, Dolares:=GvRow.DataKey("Importe"), Pesos:=GvRow.DataKey("ImporteMax"), Anticipo:=GvRow.DataKey("ImporteMin"), Boton:="Editar", Chofer:=GvRow.DataKey("CveChofer"))
Descripcion:=GvRow.DataKey("DescripcionContrato"), FechaSalida:=GvRow.DataKey("FechaInicial").ToDateTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T"), FechaRegreso:=GvRow.DataKey("FechaFinal").ToDateTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(" ", "T"), Observaciones:=GvRow.DataKey("DescripcionContrato"), Ubicacion:=GvRow.DataKey("Ubicacion"), Transporte:=GvRow.DataKey("CveTipoAF"), Cliente:=GvRow.DataKey("CveCliente"), Dolares:=GvRow.DataKey("Importe"), Pesos:=GvRow.DataKey("ImporteMax"), Anticipo:=GvRow.DataKey("ImporteMin"), Boton:="Editar", Chofer:=GvRow.DataKey("CveChofer"))
End Sub
Protected Sub RemoveContrato(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
@@ -150,4 +154,34 @@ Partial Class ListadoContratos
GvContratos.ExportToExcel("ReporteCompras" & NowADS().ToShortDateString)
End Sub
Protected Sub Consultar(sender As Object, e As EventArgs)
If DdlClientesConsulta.SelectedValue = "" Then
Alert("Debe seleccionar al cliente", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim cliente As Integer = DdlClientesConsulta.SelectedValue.ToEntero
Dim estatus As Integer = DdlEstatusConsulta.SelectedValue.ToEntero
Dim fechaInicial As DateTime = txtFechaI.Text.ToDate
Dim fechaFinal As DateTime = txtFechaF.Text.ToDate
Dim query As String = "SELECT *, ISNULL(Cli.NombreComercial,'') AS NombreComercial FROM Con_Contratos C LEFT JOIN Clientes Cli with(nolock) ON Cli.CveCliente = C.CveCliente WHERE C.CveCliente = @Cliente AND EstatusContrato = @Estatus AND FechaInicial BETWEEN @FechaInicial AND @FechaFinal"
Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings("Conexion").ConnectionString)
Using command As New SqlCommand(query, connection)
command.Parameters.AddWithValue("@Cliente", cliente)
command.Parameters.AddWithValue("@Estatus", estatus)
command.Parameters.AddWithValue("@FechaInicial", fechaInicial)
command.Parameters.AddWithValue("@FechaFinal", fechaFinal)
connection.Open()
Dim reader As SqlDataReader = command.ExecuteReader()
GvContratos.DataSource = reader
GvContratos.DataBind()
End Using
End Using
UpTitulos.Update()
End Sub
End Class