150 lines
7.4 KiB
VB.net
150 lines
7.4 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
Imports Extensiones
|
|
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
|
|
ViewState("CveContrato") = 0
|
|
InicializaCombos()
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
Private Sub InicializaCombos()
|
|
DdlTipoAF.DataSource = GlobalDTTipoActivoFijo(UsuarioActual.CveEmpresa)
|
|
DdlTipoAF.DataBind()
|
|
DdlTipoAF.Items.Insert(0, New ListItem("Seleccione", ""))
|
|
|
|
'Lista Chofer'
|
|
DdlChofer.DataSource = GlobalDTRHPersonal(185)
|
|
DdlChofer.DataBind()
|
|
DdlChofer.Items.Insert(0, New ListItem("Seleccione", ""))
|
|
|
|
UpModal.Update()
|
|
End Sub
|
|
Private Sub CargaDatos()
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.GetContratos(-1, UsuarioActual.CveEmpresa, TipoContrato:=2) Then
|
|
GvContratos.DataSource = ObjContratos.DtResultados
|
|
End If
|
|
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 Cliente As String = "", Optional Dolares As String = "", Optional Pesos As String = "", Optional Anticipo As String = "", Optional Boton As String = "Guardar", Optional AF As String = "", Optional Chofer As String = "", Optional EstatusContrato As String = "")
|
|
LbEstatus.Visible = False
|
|
DdlEstatusContrato.Visible = False
|
|
|
|
DdlClientes.SelectedText = Cliente
|
|
TxtDescripcion.Text = Descripcion
|
|
TxtUbicacion.Text = Ubicacion
|
|
TxtFechaSalida.Text = FechaSalida
|
|
TxtFechaRegreso.Text = FechaRegreso
|
|
DdlTipoAF.SelectedValue = AF
|
|
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"))
|
|
End Sub
|
|
Private Sub LBAgregarContrato_Click(sender As Object, e As EventArgs) Handles LBAgregarContrato.Click
|
|
MostrarModal()
|
|
End Sub
|
|
Protected Sub AddContrato(sender As Object, e As EventArgs)
|
|
|
|
If DdlClientes.SelectedValue = "" Then
|
|
Alert("Debe seleccionar al cliente", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
ObjContratos.IniciaTransacSQL()
|
|
Try
|
|
|
|
Dim CveEstatusInicial As Integer = 10
|
|
|
|
If ObjContratos.GetContratosEstatus(UsuarioActual.CveEmpresa) Then
|
|
CveEstatusInicial = ObjContratos.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus=1").ToEntero
|
|
End If
|
|
'Agregar contrato
|
|
If BtnGuardar.Text = "Guardar" Then
|
|
If 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, Observaciones:=TxtObservaciones.Text) > 0 Then
|
|
ObjContratos.Commit()
|
|
Alert("Agregado Correctamente.")
|
|
End If
|
|
End If
|
|
'Actualizar contrato
|
|
If BtnGuardar.Text = "Editar" Then
|
|
If 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, Observaciones:=TxtObservaciones.Text, EstatusContrato:=DdlEstatusContrato.SelectedValue.ToEntero) Then
|
|
|
|
ObjContratos.Commit()
|
|
Alert("Actualizado Correctamente.")
|
|
End If
|
|
End If
|
|
|
|
TxtDescripcion.Text = ""
|
|
TxtFechaSalida.Text = ""
|
|
TxtFechaRegreso.Text = ""
|
|
TxtObservaciones.Text = ""
|
|
TxtUbicacion.Text = ""
|
|
DdlClientes.SelectedText = ""
|
|
DdlTipoAF.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
|
|
CargaDatos()
|
|
ObjContratos.Dispose()
|
|
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("Observaciones"), 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"), EstatusContrato:=GvRow.DataKey("EstatusContrato"), AF:=GvRow.DataKey("CveTipoAF"))
|
|
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
|
|
|
|
If ObjContratos.RemoveContrato(GvRow.DataKey("CveContrato").ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Alert("Contrato eliminado correctamente")
|
|
CargaDatos()
|
|
End If
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LBExcel_Click(sender As Object, e As EventArgs) Handles LBExcel.Click
|
|
GvContratos.ExportToExcel("ReporteCompras" & NowADS().ToShortDateString)
|
|
End Sub
|
|
|
|
End Class
|