5436 lines
224 KiB
VB.net
5436 lines
224 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
Imports System.Data
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports System.Globalization
|
|
Imports GemBox.Spreadsheet
|
|
|
|
Partial Class Contratos_ContratoObra
|
|
Inherits ClsPaginas
|
|
|
|
#Region " PROPIEDADES "
|
|
Private Property CveContrato As Integer
|
|
Get
|
|
If ViewState("CveContrato") Is Nothing Then
|
|
Return 0
|
|
Else
|
|
Return ViewState("CveContrato").ToString.ToEntero
|
|
End If
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveContrato") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveTipoContrato As Integer
|
|
Get
|
|
If ViewState("CveTipoContrato") Is Nothing Then
|
|
Return 0
|
|
Else
|
|
Return ViewState("CveTipoContrato").ToString.ToEntero
|
|
End If
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveTipoContrato") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveMovimiento As Integer
|
|
Get
|
|
Return ViewState("CveMovimiento").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMovimiento") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveMovimientoDevolucion As Integer
|
|
Get
|
|
Return ViewState("CveMovimientoDevolucion").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMovimientoDevolucion") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property FolioSugerido As String
|
|
Get
|
|
Return ViewState("FolioSugerido").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("FolioSugerido") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveVenta As Integer
|
|
Get
|
|
Return ViewState("CveVenta").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveVenta") = value
|
|
End Set
|
|
End Property
|
|
Public Property Autorizado As Boolean
|
|
Get
|
|
Return DirectCast(ViewState("Autorizado"), Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("Autorizado") = value
|
|
End Set
|
|
End Property
|
|
Private Property ArchivoUpdate As String
|
|
Get
|
|
Return ViewState("ArchivoUpdate").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("ArchivoUpdate") = value
|
|
End Set
|
|
End Property
|
|
Private Property TipoContrato As Integer
|
|
Get
|
|
Return ViewState("TipoContrato").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoContrato") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtDatos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtDatos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatos") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtPlantillasContratos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtPlantillasContratos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtPlantillasContratos") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtPeriodo As DataTable
|
|
Get
|
|
Return CType(ViewState("DtPeriodo"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtPeriodo") = value
|
|
End Set
|
|
End Property
|
|
Private Property TmpDT As DataTable
|
|
Get
|
|
Return CType(ViewState("TmpDT"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("TmpDT") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property ModalidadDetalle As Integer
|
|
Get
|
|
Return DirectCast(ViewState(" ModalidadDetalle"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState(" ModalidadDetalle") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtMovimientos() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DtGastos() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtGastos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtGastos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DtSuministros() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtSuministros"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtSuministros") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtAvance() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtAvance"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtAvance") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Public Property DtPresupuestos() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtPresupuestos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtPresupuestos") = value
|
|
End Set
|
|
End Property
|
|
Private Property FechaI As DateTime
|
|
Get
|
|
Return CType(ViewState("FechaI"), DateTime)
|
|
End Get
|
|
Set(value As DateTime)
|
|
ViewState("FechaI") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property FechaF As DateTime
|
|
Get
|
|
Return CType(ViewState("FechaF"), DateTime)
|
|
End Get
|
|
Set(value As DateTime)
|
|
ViewState("FechaF") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DtActivosFijos() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtActivosFijos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtActivosFijos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CvePSSerieLote As Integer
|
|
Get
|
|
Return CType(ViewState("CvePSSerieLote"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePSSerieLote") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveUMSerieLote As Integer
|
|
Get
|
|
Return CType(ViewState("CveUMSerieLote"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveUMSerieLote") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtAvanceDocumento As DataTable
|
|
Get
|
|
Return CType(ViewState("DtAvanceDocumento"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtAvanceDocumento") = value
|
|
End Set
|
|
End Property
|
|
Private Property Titulo As String
|
|
Get
|
|
Return ViewState("Titulo").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Titulo") = value
|
|
End Set
|
|
End Property
|
|
Private Property TituloCorto As String
|
|
Get
|
|
Return ViewState("TituloCorto").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("TituloCorto") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property TipoDocumento As String
|
|
Get
|
|
Return ViewState("TipoDocumento").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("TipoDocumento") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property Contratante As String
|
|
Get
|
|
Return ViewState("Contratante").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Contratante") = value
|
|
End Set
|
|
End Property
|
|
Private Property SumaAvance As Double
|
|
Get
|
|
Return If(ViewState("SumaAvance") IsNot Nothing, ViewState("SumaAvance").ToString.ToDouble, 0)
|
|
End Get
|
|
Set(value As Double)
|
|
ViewState("SumaAvance") = value
|
|
End Set
|
|
End Property
|
|
Private Property SumaUtilidad As Double
|
|
Get
|
|
Return If(ViewState("SumaUtilidad") IsNot Nothing, ViewState("SumaUtilidad").ToString.ToDouble, 0)
|
|
End Get
|
|
Set(value As Double)
|
|
ViewState("SumaUtilidad") = value
|
|
End Set
|
|
End Property
|
|
Private Property SumaGasto As Double
|
|
Get
|
|
Return If(ViewState("SumaGasto") IsNot Nothing, ViewState("SumaGasto").ToString.ToDouble, 0)
|
|
End Get
|
|
Set(value As Double)
|
|
ViewState("SumaGasto") = value
|
|
End Set
|
|
End Property
|
|
Private Property NumRow As Integer
|
|
|
|
Private Property EsEditarFianza As Boolean
|
|
Get
|
|
Return CType(ViewState("EsEditarFianza"), Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsEditarFianza") = value
|
|
End Set
|
|
End Property
|
|
Private Property IndexFianzaEditar As Integer
|
|
Get
|
|
Return CType(ViewState("IndexFianzaEditar"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IndexFianzaEditar") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtTmpFianzas() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtTmpFianzas"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtTmpFianzas") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtTmpFianzasInicial() As DataTable
|
|
Get
|
|
Return CType(ViewState("DtTmpFianzasInicial"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtTmpFianzasInicial") = value
|
|
End Set
|
|
End Property
|
|
Private Property MensajeAlert As StringBuilder
|
|
Get
|
|
Return CType(ViewState("MensajeAlert"), StringBuilder)
|
|
End Get
|
|
Set(value As StringBuilder)
|
|
ViewState("MensajeAlert") = value
|
|
End Set
|
|
End Property
|
|
Private Property DsDatosPedDev As DataSet
|
|
Get
|
|
DsDatosPedDev = DirectCast(ViewState("DsDatosPedDev"), DataSet)
|
|
End Get
|
|
|
|
Set(ByVal value As DataSet)
|
|
ViewState("DsDatosPedDev") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveSubProyecto As Integer
|
|
Get
|
|
|
|
If ViewState("CveSubProyecto") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return CType(ViewState("CveSubProyecto"), Integer)
|
|
End If
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveSubProyecto") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Property TotalAvanceVentas As Decimal
|
|
Get
|
|
|
|
If ViewState("TotalAvanceVentas") Is Nothing Then
|
|
Return 0D
|
|
Else
|
|
Return ViewState("TotalAvanceVentas").ToString.ToDecimal
|
|
End If
|
|
End Get
|
|
Set(value As Decimal)
|
|
ViewState("TotalAvanceVentas") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Property TotalAvanceInterno As Decimal
|
|
Get
|
|
|
|
If ViewState("TotalAvanceInterno") Is Nothing Then
|
|
Return 0D
|
|
Else
|
|
Return ViewState("TotalAvanceInterno").ToString.ToDecimal
|
|
End If
|
|
End Get
|
|
Set(value As Decimal)
|
|
ViewState("TotalAvanceInterno") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
CargaValoresIniciales()
|
|
CreaDtTmpFianzas()
|
|
|
|
|
|
cargaClientes()
|
|
|
|
|
|
If Request("CveContrato") IsNot Nothing AndAlso IsNumeric(Request("CveContrato")) AndAlso Request("CveContrato").ToEntero > 0 Then
|
|
ViewState("CveContrato") = Request("CveContrato")
|
|
|
|
DvBitacora.Visible = True
|
|
DdlEstatus.Enabled = False
|
|
If UsuarioActual.TienePermisoProceso(126) Then
|
|
BtnAutorizar.Visible = True
|
|
End If
|
|
DivContent.Visible = True
|
|
' DivTipoContrato.Visible = False
|
|
'TxtArchivo.Visible = True
|
|
|
|
CargaDatos()
|
|
|
|
CargaDatosAvance()
|
|
CargaDatosAvancePorDocumento()
|
|
CargaInventarios()
|
|
|
|
'12/04/2018 - Si el tipo de contrato es convenio de precio fijo configura campos
|
|
If CveTipoContrato = 28 Then
|
|
CargaConvenioPrecioFijo()
|
|
End If
|
|
|
|
'Configuración de Modalidad Update
|
|
BtnGuardar.Text = "Guardar Cambios"
|
|
|
|
If Request("Opt") IsNot Nothing AndAlso IsNumeric(Request("Opt")) Then Tab.ActiveTabIndex = Request("Opt").ToEntero
|
|
|
|
If CveContrato > 0 Then
|
|
|
|
LnkModalAddPSVentas.Visible = True
|
|
LnkModalAddPSControl.Visible = True
|
|
LnkModalAddPresupuestoVentas.Visible = True
|
|
LnkModalAddPresupuestoControl.Visible = True
|
|
LnkModalAddMaquinariaFlotilla.Visible = True
|
|
|
|
End If
|
|
|
|
CargaEstadoCueta()
|
|
|
|
TabEstadoCuenta.Visible = True
|
|
|
|
|
|
If TxtLimiteGastos.Text.ToDecimal > 0 Then
|
|
TabGastos.Visible = True
|
|
LnkModalAddGastos.Visible = True
|
|
CargaGastos()
|
|
|
|
End If
|
|
|
|
Indicadores()
|
|
|
|
Else
|
|
'Configuración de Modalidad Insert
|
|
LblFechaCaptura.Text = Now.ToShortDateString()
|
|
LblUsuarioCapturo.Text = UsuarioActual.Usuario
|
|
ViewState("CveContrato") = -1
|
|
|
|
DvBitacora.Visible = False
|
|
TabContratosGastos.Visible = False
|
|
TabAF.Visible = False
|
|
TabReporteAvance.Visible = False
|
|
TabAvanveDocumento.Visible = False
|
|
|
|
TAB.ActiveTabIndex = 0
|
|
|
|
|
|
|
|
End If
|
|
|
|
'carga combos
|
|
CargaClasificaciones()
|
|
CargaPS()
|
|
CargaPSInsumos()
|
|
ConfiguraTipos()
|
|
'CargaDatosEncabezado()
|
|
|
|
|
|
CargaDLLCargaGVCentrosConsto()
|
|
tabalCentrosdecotso()
|
|
|
|
End If
|
|
|
|
|
|
'[IPP] PORQUE ESTA TODO ESTO EN TODOS LOS POSTBACK ??? - REVISEN BIEN DONDE PONEN EL CODIGO
|
|
|
|
If UsuarioActual.TienePermisoProceso(165) Then
|
|
BtnGuardar.Visible = True
|
|
Else
|
|
BtnGuardar.Visible = False
|
|
End If
|
|
|
|
If CveContrato > 0 Then
|
|
If UsuarioActual.TienePermisoProceso(164) Then
|
|
BtnEliminar.Visible = True
|
|
Gv.Columns(8).Visible = True
|
|
GvInsumos.Columns(7).Visible = True
|
|
Else
|
|
BtnEliminar.Visible = False
|
|
Gv.Columns(8).Visible = False
|
|
GvInsumos.Columns(7).Visible = False
|
|
End If
|
|
|
|
Else
|
|
TabPres.Visible = False
|
|
Gv.Columns(8).Visible = True
|
|
GvInsumos.Columns(7).Visible = True
|
|
|
|
End If
|
|
|
|
|
|
TabAvanveDocumento.Visible = False
|
|
TabContratosGastos.Visible = False
|
|
TabPed.Visible = False
|
|
|
|
End Sub
|
|
|
|
#Region " CARGA VALORES INICIALES "
|
|
Private Sub CargaValoresIniciales()
|
|
CveContrato = -1
|
|
ViewState("TipoContrato") = 0
|
|
CveVenta = -1
|
|
Autorizado = False
|
|
BtnAutorizar.Visible = False
|
|
Session("FileUpload") = ""
|
|
Session("FileExtension") = ""
|
|
Session("FileFolder") = ""
|
|
ArchivoUpdate = ""
|
|
ModalidadDetalle = 1
|
|
FolioSugerido = ""
|
|
|
|
CargaProyecto()
|
|
CargaContratista()
|
|
|
|
|
|
DdlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
|
|
DdlUM.DataBind()
|
|
DdlMoneda.DataSource = GlobalDTMonedas
|
|
DdlMoneda.DataBind()
|
|
|
|
|
|
|
|
CargaContratosEstatus()
|
|
CreaDT()
|
|
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(72, 80) Then divResponsable.Visible = False
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlMoneda.SelectedIndexChanged
|
|
|
|
If DdlMoneda.SelectedIndex = 0 Then
|
|
tipoCambio.Visible = False
|
|
TxtTipoCambio.Text = ""
|
|
UpGral.Update()
|
|
Else
|
|
tipoCambio.Visible = True
|
|
TxtTipoCambio.Text = ""
|
|
UpGral.Update()
|
|
End If
|
|
End Sub
|
|
Public Function isWithFamily() As Boolean
|
|
Return UsuarioActual.CveEmpresa = 66
|
|
End Function
|
|
|
|
Private Sub cargaClientes()
|
|
DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1)
|
|
DdlCliente.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CreaDT()
|
|
TmpDT = New DataTable
|
|
TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer))
|
|
TmpDT.Columns.Add("Cantidad", GetType(Double))
|
|
TmpDT.Columns.Add("CantidadContratada", GetType(Double))
|
|
TmpDT.Columns.Add("CveUM", GetType(Integer))
|
|
TmpDT.Columns.Add("UM", GetType(String))
|
|
TmpDT.Columns.Add("CveClasificacion", GetType(Integer))
|
|
TmpDT.Columns.Add("Clasificacion", GetType(String))
|
|
TmpDT.Columns.Add("CvePS", GetType(Integer))
|
|
TmpDT.Columns.Add("PS", GetType(String))
|
|
TmpDT.Columns.Add("CodigoPS", GetType(String))
|
|
TmpDT.Columns.Add("PU", GetType(Double))
|
|
TmpDT.Columns.Add("Total", GetType(Double))
|
|
TmpDT.Columns.Add("CveTipoPresupuesto", GetType(Integer))
|
|
TmpDT.Columns.Add("PermitirAvance", GetType(Integer))
|
|
TmpDT.Columns.Add("PermitirEstimacion", GetType(Integer))
|
|
TmpDT.Columns.Add("UsuarioAvance", GetType(Integer))
|
|
TmpDT.Columns.Add("Cantidad_Original", GetType(Double))
|
|
TmpDT.Columns.Add("PU_Original", GetType(Double))
|
|
TmpDT.Columns.Add("Total_Original", GetType(Double))
|
|
TmpDT.Columns.Add("NoIdentificacion", GetType(String))
|
|
TmpDT.Columns.Add("LimitarCantidad", GetType(Integer))
|
|
TmpDT.Columns.Add("OCInterna", GetType(String))
|
|
TmpDT.Columns.Add("Observacion", GetType(String))
|
|
|
|
|
|
TmpDT.Columns.Add("CveRubro", GetType(Integer))
|
|
TmpDT.Columns.Add("CveActividad", GetType(Integer))
|
|
TmpDT.Columns.Add("CveSubTipoActivoFijo", GetType(Integer))
|
|
|
|
TmpDT.Columns.Add("Rubro", GetType(String))
|
|
TmpDT.Columns.Add("Actividad", GetType(String))
|
|
TmpDT.Columns.Add("SubTipoActivoFijo", GetType(String))
|
|
|
|
TmpDT.Columns.Add("Dias", GetType(Integer))
|
|
|
|
|
|
End Sub
|
|
Protected Sub Limpiar()
|
|
TxtNumeroContrato.Text = ""
|
|
TxtDescripcionContrato.Text = ""
|
|
DdlContratista.SelectedValue = "-1"
|
|
DdlCliente.SelectedValue = "-1"
|
|
TxtFechaInicial.Text = ""
|
|
TxtFechaFinal.Text = ""
|
|
TxtPorIVA.Text = ""
|
|
|
|
'DdlProyecto.SelectedValue = "-1"
|
|
|
|
TxtCantidad.Text = ""
|
|
TxtPU.Text = ""
|
|
TmpDT.Clear()
|
|
CargaGVPresupuestos(TmpDT)
|
|
CargaGVPresupuestosInsumos(TmpDT)
|
|
LbTotalGeneral.Text = "0.00"
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " CONFIGURA TIPOS CONTRATO "
|
|
|
|
Private Sub ConfiguraTipos()
|
|
If Not TipoContrato.Contiene({7, 9, 13, 16, 18, 21}) Then
|
|
TabAF.Visible = False
|
|
End If
|
|
|
|
|
|
|
|
'DONDE OCUPA ALMACEN
|
|
Dim CveTipoAlmacenOrigen = "12,15"
|
|
Dim CveTipoAlmacenDestino = "11,12"
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub MuestraPermiteAvance()
|
|
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " INICIO DE PAGINA "
|
|
|
|
|
|
|
|
Private Sub modalidades(modalidadDetalleInt As Integer)
|
|
|
|
If modalidadDetalleInt = 1 Then
|
|
ModalidadDetalle = 1
|
|
|
|
|
|
DvTotal.Visible = True
|
|
|
|
|
|
'If CveContrato > 0 AndAlso CveTipoContrato <> 25 Then
|
|
' TableDatosCabecera.Visible = True
|
|
'End If
|
|
|
|
If CveTipoContrato = 25 Then
|
|
|
|
DvTotal.Visible = False
|
|
|
|
|
|
End If
|
|
|
|
ElseIf modalidadDetalleInt = 2 Then
|
|
ModalidadDetalle = 2
|
|
|
|
|
|
DvTotal.Visible = True
|
|
|
|
|
|
'If CveContrato > 0 AndAlso CveTipoContrato <> 25 Then
|
|
' TableDatosCabecera.Visible = True
|
|
'End If
|
|
|
|
|
|
|
|
End If
|
|
|
|
UpGral.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " CARGA DATOS "
|
|
Private Sub CargaDatos()
|
|
Dim ObjContratos As New ClsContratos()
|
|
Dim Ruta = Request.ApplicationPath + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos\"
|
|
'DivTipoContrato.Visible = False
|
|
|
|
|
|
If ObjContratos.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
If ObjContratos.DtResultados.Rows.Count > 0 Then
|
|
|
|
GRidsPresupuestos.Visible = True
|
|
msjpresupuestos.Visible = False
|
|
|
|
If ArchivoUpdate = ObjContratos.Archivo.ToString Then
|
|
'LinkArchivo.Visible = True
|
|
'LinkArchivo.HRef = String.Format("{0}{1}", Ruta, ObjContratos.Archivo.ToString)
|
|
End If
|
|
Titulo = $"{ObjContratos.NumeroContrato} - {ObjContratos.DescripcionContrato} ({ObjContratos.DtResultados.Rows(0)("ContratoTipo")})"
|
|
TituloCorto = $"{ObjContratos.NumeroContrato} - {ObjContratos.DescripcionContrato} "
|
|
TipoDocumento = ObjContratos.DtResultados.Rows(0)("ContratoTipo").ToString
|
|
LtlTitulo.Text = $"Contrato: {Titulo})"
|
|
'Pestaña Datos Generales
|
|
TxtObservaciones.Text = ObjContratos.Observaciones
|
|
TxtDescripcionContrato.Text = ObjContratos.DescripcionContrato
|
|
TxtNumeroContrato.Text = ObjContratos.NumeroContrato
|
|
TxtNumeroLicitacion.Text = ObjContratos.NumeroLicitacion
|
|
TipoContrato = ObjContratos.CveContratoTipo
|
|
CveTipoContrato = ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero
|
|
TxtCorreoNotificacion.Text = ObjContratos.DtResultados.Rows(0)("CorreoNotificacionPedDev").ToString
|
|
DdlCliente.SelectedValueExist(ObjContratos.DtResultados.Rows(0)("CveCliente").ToString)
|
|
|
|
If ObjContratos.CveProveedor > 0 Then
|
|
' TrProveedor.Visible = True
|
|
TrCliente.Visible = False
|
|
CargaContratista()
|
|
DdlContratista.SelectedValue = ObjContratos.CveProveedor.ToString
|
|
Else
|
|
cargaClientes()
|
|
DdlCliente.SelectedValueExist(ObjContratos.CveCliente.ToString)
|
|
UpGral.Update()
|
|
CargaSucursalCliente()
|
|
DdlSucursalCliente.SelectedValue = ObjContratos.CveSucursalCliente.ToString
|
|
End If
|
|
|
|
CargaContratoAddendum()
|
|
|
|
If ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero = 14 Then
|
|
RFVEstatus.ValidationGroup = ""
|
|
DvTotal.Visible = True
|
|
RowEstatus.Visible = False
|
|
CargaPlantillas()
|
|
TabPres.HeaderText = "Partidas"
|
|
End If
|
|
|
|
If ObjContratos.DtResultados.Rows(0)("CveContratoTipo").ToString.ToEntero = 25 Then
|
|
trLicitacion.Visible = False
|
|
divResponsable.Visible = False
|
|
trIva.Visible = False
|
|
trAnticipo.Visible = False
|
|
trAmortizacion.Visible = False
|
|
trPorGarantia.Visible = False
|
|
DvTotal.Visible = False
|
|
TabPVInsumos.Visible = False
|
|
RowEstatus.Visible = False
|
|
TabPres.HeaderText = "Partidas"
|
|
'TableDatosCabecera.Visible = False
|
|
TabAvanveDocumento.Visible = False
|
|
TabSistema.Visible = False
|
|
TabContratosGastos.Visible = False
|
|
TDAvance.Style.Add("display", "none")
|
|
'TxtNoIdentificacionv.Visible = False
|
|
DvObservaciones.Visible = True
|
|
TxtObservaciones.Text = ObjContratos.DtResultados.Rows(0)("Observaciones").ToString
|
|
Gv.Columns(3).Visible = True
|
|
|
|
End If
|
|
|
|
|
|
|
|
FechaF = ObjContratos.FechaFinal
|
|
FechaI = ObjContratos.FechaInicial
|
|
TxtFechaFinal.Text = ObjContratos.FechaFinal.ToShortDateString
|
|
TxtFechaInicial.Text = ObjContratos.FechaInicial.ToShortDateString
|
|
TxtUbicacion.Text = ObjContratos.Ubicacion
|
|
TxtResponsable.Text = ObjContratos.Responsable
|
|
TxtLugar.Text = ObjContratos.Lugar
|
|
TxtPorAnticipo.Text = ObjContratos.PorAmortizacionAnticipo.FormatoNumero
|
|
TxtPorAmortizacionAnticipo.Text = ObjContratos.PorAmortizacionAnticipo.FormatoNumero
|
|
TxtPorGarantia.Text = ObjContratos.PorGarantia.FormatoNumero
|
|
'DdlProyecto.SelectedValue = ObjContratos.CveProyecto.ToString
|
|
LblSubProyecto.Text = ObjContratos.SubProyectoContrato
|
|
DdlTipoContratoObra.SelectedValueExist(ObjContratos.CveContratoTipo)
|
|
'CargaSubProyectoContrato(DdlProyecto.SelectedValue.ToEntero)
|
|
|
|
'DdlSubProyectoContrato.SelectedValue = ObjContratos.CveSubProyecto.ToString
|
|
|
|
|
|
|
|
TxtPorIVA.Text = ObjContratos.PorIVA.ToString
|
|
TxtLimiteGastos.Text = ObjContratos.LimiteDeGasto.ToString
|
|
TxtTotal.Text = ObjContratos.Importe.FormatoNumero
|
|
|
|
|
|
DdlEstatus.SelectedValueExist(ObjContratos.CveContratosEstatus.ToString)
|
|
CargarFianzas()
|
|
|
|
If ObjContratos.TipoEstatus = 2 Then
|
|
DdlEstatus.Enabled = False
|
|
Else
|
|
DdlEstatus.Items.Clear()
|
|
'Se esta ocultando concluido'
|
|
DdlEstatus.DataSource = CType(DdlEstatus.DataSource, DataTable).FiltraParametros("TipoEstatus NOT IN (2)")
|
|
DdlEstatus.DataBind()
|
|
|
|
|
|
End If
|
|
TxtTipoCambio.Text = ObjContratos.TipoCambio.ToString
|
|
|
|
ModalidadDetalle = ObjContratos.ModalidadDetalle
|
|
modalidades(ModalidadDetalle)
|
|
|
|
CargaGVGastos()
|
|
|
|
DdlMoneda.SelectedValue = ObjContratos.CveMoneda.ToString
|
|
If DdlMoneda.SelectedIndex > 0 Then
|
|
tipoCambio.Visible = True
|
|
End If
|
|
|
|
|
|
If ObjContratos.CveProveedor > 0 Then
|
|
Contratante = ObjContratos.RazonSocial.ToString
|
|
Else
|
|
Contratante = ObjContratos.NombreComercial.ToString
|
|
End If
|
|
|
|
LblFechaCaptura.Text = ObjContratos.FechaIng.ToShortDateString
|
|
|
|
CargaPresupuesto()
|
|
|
|
cargarBitacora()
|
|
If LblImporte.Text.ToDecimal <= 0 Then
|
|
LblImporte.Text = ObjContratos.ImporteTotal.ToString.FormatoNumero
|
|
End If
|
|
|
|
If Not IsDBNull(ObjContratos.Archivo) AndAlso ObjContratos.Archivo <> "" AndAlso ObjContratos.Archivo <> "-1" AndAlso ObjContratos.Archivo <> $"{ObjContratos.CveContrato}." Then
|
|
ViewState("FUrl") = Path.Combine(UsuarioActual.Empresa.Ruta, "CONTRATOS", ObjContratos.Archivo)
|
|
|
|
BtnDescargar.Visible = True
|
|
Else
|
|
BtnDescargar.Visible = False
|
|
A1.Visible = True
|
|
End If
|
|
|
|
|
|
DVSubProyecto.Visible = True
|
|
DVddlproyecto.Visible = False
|
|
|
|
Else
|
|
CveContrato = -1
|
|
Alert("El Contrato Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
|
BtnGuardar.Enabled = False
|
|
End If
|
|
Else
|
|
CveContrato = -1
|
|
Alert("Ocurrió un error al cargar el Contrato. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
BtnGuardar.Enabled = False
|
|
End If
|
|
UpGral.Update()
|
|
UPAFUL.Update()
|
|
UpProyecto.Update()
|
|
' UpImpuestos.Update()
|
|
UpTitulos.Update()
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
Private Sub CargaContratoAddendum()
|
|
'Dim ObjContratos As New ClsContratos
|
|
'If ObjContratos.GetContratosAddendum(CveContrato) Then
|
|
' If ObjContratos.DtResultados.Rows.Count > 0 Then
|
|
' TabAddendum.Visible = True
|
|
' GvAddendum.DataSource = ObjContratos.DtResultados
|
|
' GvAddendum.DataBind()
|
|
' End If
|
|
'End If
|
|
End Sub
|
|
Private Sub CargaPresupuesto()
|
|
Dim ObjContratos As New ClsContratos
|
|
TabPres.Visible = True
|
|
|
|
If TipoContrato = 4 Then
|
|
TabPI.Visible = True
|
|
End If
|
|
If ObjContratos.GetContratosDetalle(CveContrato) Then
|
|
TmpDT = ObjContratos.DtResultados
|
|
If TmpDT.MAX("Cantidad_Original").ToString.ToEntero > 0 OrElse TmpDT.MAX("PU_Original").ToString.ToEntero > 0 Then
|
|
BtnAutorizar.Visible = False
|
|
Autorizado = True
|
|
BtnAgregarDetalle.Visible = False
|
|
AgregarInt.Visible = UsuarioActual.TienePermisoProceso(129)
|
|
End If
|
|
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1"))
|
|
|
|
GvInt.DataSource = TmpDT.FiltraParametros("CveTipoPresupuesto=1")
|
|
GvInt.DataBind()
|
|
|
|
UpGV.Update()
|
|
UpGVInsumos.Update()
|
|
UPGVInt.Update()
|
|
|
|
|
|
TotalAvanceVentas = TmpDT.FiltraParametros("CveTipoPresupuesto=2").SUM("Total").ToDecimal
|
|
TotalAvanceInterno = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").ToDecimal
|
|
|
|
LbTotalGeneral.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=2").SUM("Total").FormatoNumero()
|
|
LbTotalGeneralInsumos.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").FormatoNumero()
|
|
|
|
LbTotalGeneralInt.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").FormatoNumero()
|
|
'LblImporte.Text = "$" & TmpDT.FiltraParametros("CveTipoPresupuesto=2").SUM("Total").FormatoNumero()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargarFianzas()
|
|
|
|
|
|
Dim ObjContrato As ClsContratos = New ClsContratos()
|
|
|
|
If ObjContrato.GetContratoFianza(CveContrato, -1, "-1", "-1", UsuarioActual.CveEmpresa, -1) Then
|
|
DtTmpFianzas = ObjContrato.DtResultados
|
|
|
|
|
|
DtTmpFianzasInicial = DtTmpFianzas.Copy()
|
|
|
|
End If
|
|
|
|
ObjContrato.Dispose()
|
|
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " GUARDAR "
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
|
|
|
If DdlContratista.SelectedValue.ToEntero = -1 And DdlCliente.SelectedValue.ToEntero = -1 Then
|
|
Alert("Debe seleccionar con quién está haciendo el contrato. Proveedor o Cliente", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If TxtPorAmortizacionAnticipo.Text.ToDecimal < TxtPorAnticipo.Text.ToDecimal Then
|
|
Alert("El porcentaje de amortización no debe de ser menor al porcentaje de anticipo.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
|
|
Dim TieneError = False
|
|
Dim Modificado = False
|
|
' Dim Extension = Session("FileExtension").ToString
|
|
Dim Archivo = Session("FileUpload").ToString
|
|
Dim Ruta = Session("FileFolder").ToString
|
|
|
|
Dim Minimo, Maximo, Total As Double
|
|
|
|
Minimo = 0 'txtMinimo.Text.ToDouble
|
|
Maximo = 0 'txtMaximo.Text.ToDouble
|
|
Total = TxtTotal.Text.ToDouble
|
|
|
|
|
|
|
|
If DdlMoneda.SelectedIndex > 0 Then
|
|
If TxtTipoCambio.Text.Trim.Length = 0 Or TxtTipoCambio.Text.Trim.ToDouble = 0.0 Then
|
|
Alert("Cuando seleccione una moneda diferente a peso debe especificar el tipo de cambio.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If CveContrato > 0 Then
|
|
If DdlContratista.SelectedValue.ToEntero = -1 And DdlCliente.SelectedValue.ToEntero = -1 Then
|
|
Alert("Debe seleccionar con quién está haciendo el contrato. Proveedor o Cliente", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
Dim ObjInventarios As New ClsInventarios(ObjContratos.IniciaTransacSQL)
|
|
|
|
TipoContrato = DdlTipoContratoObra.SelectedValue.ToEntero
|
|
|
|
'Crear Contrato
|
|
If Not CveContrato > 0 Then
|
|
|
|
Dim EstatusContrato As Integer = 1
|
|
|
|
CveContrato = ObjContratos.AddContratosObra(TxtNumeroContrato.Text, TxtDescripcionContrato.Text, TxtNumeroLicitacion.Text.Trim, DdlContratista.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero, -1, TxtFechaInicial.Text.ToDate, TxtFechaFinal.Text.ToDate,
|
|
TxtUbicacion.Text, TxtResponsable.Text, DdlProyecto.SelectedValue.ToEntero, TxtPorIVA.Text.ToDouble, TxtPorAnticipo.Text.ToDouble, TxtPorAmortizacionAnticipo.Text.ToDouble,
|
|
TxtPorGarantia.Text.ToDouble, "." & Session("FileExtension").ToString, "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, Minimo, Maximo, Total,
|
|
DdlMoneda.SelectedValue.ToEntero, ModalidadDetalle, EstatusContrato, TipoContrato,
|
|
TxtTipoCambio.Text.ToDouble, CveSucursalCliente:=DdlSucursalCliente.SelectedValue.ToEntero, CveAlmacenOrigen:=-1, CveAlmacenDestino:=-1,
|
|
PorcentajeComision:=0, TipoGarantia:=-1, Folio:=0, FechaVenc:=Nothing, EstatusFianza:=1,
|
|
CvePeriodo:=-1, CveCuentaEquipo:=-1, CveContratoPlantilla:=-1, CveVendedor:=-1,
|
|
Observaciones:=TxtObservaciones.Text, CveDireccionEnvio:=-1, AplicaImpuestosLocales:=False, CorreoNotificacionPedDev:=TxtCorreoNotificacion.Text.Trim(), Lugar:=TxtLugar.Text.Trim, LimiteDeGasto:=TxtLimiteGastos.Text.ToDouble)
|
|
|
|
|
|
TieneError = Not GuardaFianzas(ObjContratos)
|
|
|
|
|
|
If CveContrato > 0 AndAlso Not TieneError Then
|
|
'Renombrar archivo
|
|
If ViewState("extencion") IsNot Nothing Then
|
|
If ViewState("FUrl").ToString.Length > 0 AndAlso ViewState("extencion").ToString.Length > 0 Then
|
|
If Not Directory.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos") Then
|
|
Directory.CreateDirectory(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos")
|
|
End If
|
|
Ruta = ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos\"
|
|
|
|
'ViewState("extencion") = FileExtension
|
|
'ViewState("FUrl") = Path.Combine(UsuarioActual.Empresa.Ruta, "Contratos", "Temp", ViewState("FName").ToString)
|
|
Try
|
|
If File.Exists(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString)) Then
|
|
File.Delete(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
|
End If
|
|
System.IO.File.Move(ViewState("FUrl").ToString, String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
If TxtNumeroContrato.Text = FolioSugerido Then
|
|
Dim ObjFolios As New ClsGralFolios
|
|
|
|
If Not ObjFolios.UpdateFolioActual(CveSubProyecto, "Con", True, UsuarioActual.CveEmpresa) Then
|
|
TieneError = True
|
|
End If
|
|
|
|
ObjFolios.Dispose()
|
|
End If
|
|
|
|
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
Else
|
|
Modificado = True
|
|
|
|
Dim ArchivoUpdate As String = "-1"
|
|
|
|
If Session("FileExtension").ToString <> "" Then
|
|
ArchivoUpdate = "." & Session("FileExtension").ToString
|
|
Else
|
|
|
|
End If
|
|
|
|
If ObjContratos.UpdateContratosObra(CveContrato, TxtNumeroContrato.Text, TxtDescripcionContrato.Text, TxtNumeroLicitacion.Text.Trim, DdlContratista.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero, -1, TxtFechaInicial.Text.ToDate, TxtFechaFinal.Text.ToDate,
|
|
TxtUbicacion.Text, TxtResponsable.Text, TxtPorIVA.Text.ToDouble, TxtPorAnticipo.Text.ToDouble, TxtPorAmortizacionAnticipo.Text.ToDouble,
|
|
TxtPorGarantia.Text.ToDouble, ArchivoUpdate, "", -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, Minimo, Maximo, Total, DdlMoneda.SelectedValue.ToEntero,
|
|
ModalidadDetalle, If(UsuarioActual.Empresa.CvePlataforma = 3 OrElse CveTipoContrato = 25, 1, DdlEstatus.SelectedValue.ToEntero), TipoContrato, TxtTipoCambio.Text.ToDouble, CveSucursalCliente:=DdlSucursalCliente.SelectedValue.ToEntero,
|
|
CveAlmacenOrigen:=-1, CveAlmacenDestino:=-1, PorcentajeComision:=0,
|
|
TipoGarantia:=-1, Folio:=-1, FechaVenc:=Nothing, EstatusFianza:=-1, CveContratoPlantilla:=-1,
|
|
CveCuentaEquipo:=-1, CveVendedor:=-1, Observaciones:=TxtObservaciones.Text, CveDireccionEnvio:=-1, AplicaImpuestosLocales:=False,
|
|
CorreoNotificacionPedDev:=TxtCorreoNotificacion.Text.Trim(), Lugar:=TxtLugar.Text.Trim, LimiteDeGasto:=TxtLimiteGastos.Text.ToDouble) Then
|
|
|
|
|
|
TieneError = Not GuardaFianzas(ObjContratos)
|
|
|
|
'Renombrar archivo
|
|
If Not TieneError Then
|
|
|
|
|
|
If ViewState("extencion") IsNot Nothing Then
|
|
|
|
If ViewState("FUrl").ToString.Length > 0 AndAlso ViewState("extencion").ToString.Length > 0 Then
|
|
If Not Directory.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos") Then
|
|
Directory.CreateDirectory(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos")
|
|
End If
|
|
Ruta = ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Contratos\"
|
|
|
|
Try
|
|
If File.Exists(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString)) Then
|
|
File.Delete(String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
|
End If
|
|
System.IO.File.Move(ViewState("FUrl").ToString, String.Format("{0}{1}.{2}", Ruta, CveContrato.ToString, ViewState("extencion").ToString))
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
End If
|
|
|
|
If TieneError Then
|
|
ObjContratos.RollBack()
|
|
Else
|
|
ObjContratos.Commit()
|
|
|
|
If ObjContratos.GetContratos(-1, -1) Then
|
|
Application("GlobalDTContratos") = ObjContratos.DtResultados
|
|
End If
|
|
|
|
Limpiar()
|
|
If Modificado Then
|
|
Alert("El Contrato se modificó Correctamente.", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/ContratoObra.aspx?CveContrato={0}""", CveContrato))
|
|
Else
|
|
Alert("El Contrato se registró Correctamente.", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/ContratoObra.aspx?CveContrato={0}""", CveContrato))
|
|
End If
|
|
|
|
End If
|
|
|
|
UpGral.Update()
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " ELIMINAR "
|
|
Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
|
|
Dim objContratos As New ClsContratos
|
|
|
|
If objContratos.RemoveContrato(CveContrato, UsuarioActual.Empresa.CveEmpresa) Then
|
|
Response.Redirect("./Contratos.aspx")
|
|
Else
|
|
' Alert("Ocurrio un error al eliminar el contrato", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " TERMINAR/CANCELAR CONTRATO "
|
|
Protected Sub LBTerminarContrato_Click(sender As Object, e As EventArgs)
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.TerminarContrato(CveContrato, 2, UsuarioActual.CveEmpresa) > 0 Then
|
|
Alert("El Contrato fue terminado Correctamente.", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/Contrato.aspx?CveContrato={0}""", CveContrato))
|
|
End If
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LBCancelarContrato_Click(sender As Object, e As EventArgs)
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.TerminarContrato(CveContrato, 3, UsuarioActual.CveEmpresa) > 0 Then
|
|
Alert("El Contrato fue cancelado Correctamente.", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/Contrato.aspx?CveContrato={0}""", CveContrato))
|
|
End If
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LBVigenteContrato_Click(sender As Object, e As EventArgs)
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.TerminarContrato(CveContrato, 1, UsuarioActual.CveEmpresa) > 0 Then
|
|
Alert("El Contrato fue cancelado Correctamente.", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/Contrato.aspx?CveContrato={0}""", CveContrato))
|
|
End If
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region " TABS "
|
|
|
|
#Region " TAB: INFORMACION GENERAL"
|
|
|
|
#Region "COMBOS - INFO GENERAL"
|
|
Private Sub CargaProyecto()
|
|
|
|
'trddlproyecto.Visible = LblProyecto.Visible
|
|
CargarCentrosDeCosto(DdlProyecto, Nothing, LblProyecto, LblSubProyectoTitulo)
|
|
|
|
DdlProyecto.Visible = True
|
|
LblProyecto.Visible = True
|
|
|
|
|
|
'LblCentroCosto.Text = LblSubProyectoTitulo.Text
|
|
LblSubProyectoTitulo.Text = LblSubProyectoTitulo.Text & ":"
|
|
|
|
'If UsuarioActual.Empresa.GralSoloProyecto Then
|
|
' CargaSubProyectoContrato(-1)
|
|
' lblsubproyecto.Text = "Proyecto"
|
|
'Else
|
|
' DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa).FiltraParametros("", "", {"CveProyecto", "Proyecto"})
|
|
' DdlProyecto.DataBind()
|
|
'End If
|
|
End Sub
|
|
'Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
|
' CargaSubProyectoContrato(DdlProyecto.SelectedValue.ToEntero)
|
|
'End Sub
|
|
'Protected Sub CargaSubProyectoContrato(CveProyecto As Integer)
|
|
' DdlSubProyectoContrato.Items.Clear()
|
|
' DdlSubProyectoContrato.DataSource = GlobalDTSubProyectos(CveProyecto, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubproyecto", "SubProyecto"})
|
|
' DdlSubProyectoContrato.DataBind()
|
|
' DdlSubProyectoContrato.Items.Insert(0, New ListItem("Seleccione un Proyecto", "-1"))
|
|
'End Sub
|
|
Private Sub CargaContratista()
|
|
DdlContratista.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
DdlContratista.DataBind()
|
|
End Sub
|
|
|
|
'Private Sub CargaVendedores()
|
|
' DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
|
|
' DdlVendedor.DataBind()
|
|
'End Sub
|
|
'Private Sub CargaContratoPadre()
|
|
' DdlContratoPadre.Items.Clear()
|
|
' DdlContratoPadre.DataSource = GlobalDTContratos.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveContratoTipo = {TipoContrato} {If(DdlCliente.SelectedValue.ToEntero > 0, $"AND CveCliente = {DdlCliente.SelectedValue}", "")} {If(CveContrato > 0, $"AND CveContrato <> {CveContrato}", "")} ")
|
|
' DdlContratoPadre.DataBind()
|
|
' DdlContratoPadre.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
'End Sub
|
|
Private Sub CargaContratosEstatus()
|
|
Dim ObjContratos As New ClsContratos
|
|
ObjContratos.GetContratosEstatus(UsuarioActual.CveEmpresa)
|
|
DdlEstatus.DataSource = ObjContratos.DtResultados
|
|
DdlEstatus.DataBind()
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
Protected Sub DdlCliente_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaSucursalCliente()
|
|
' CargaDireccionesEnvios(DdlCliente.SelectedValue.ToEntero)
|
|
UPPDatos.Update()
|
|
End Sub
|
|
Private Sub CargaSucursalCliente()
|
|
TrClienteSucursal.Visible = False
|
|
|
|
Dim ObjCliente As New ClsClientes()
|
|
|
|
If DdlCliente.SelectedValue.ToEntero > 0 Then
|
|
|
|
If ObjCliente.GetSucursales(DdlCliente.SelectedValue.ToEntero) Then
|
|
DdlSucursalCliente.DataSource = ObjCliente.DtResultados
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
TrClienteSucursal.Visible = True
|
|
End If
|
|
DdlSucursalCliente.DataBind()
|
|
' DdlTipoContrato.Items.Insert(0, New ListItem("Matriz", "-1"))
|
|
End If
|
|
'If UsuarioActual.Empresa.CvePlataforma = 3 Then ' QUITAR
|
|
' CargaCuentasEquipos()
|
|
'End If
|
|
End If
|
|
|
|
ObjCliente.Dispose()
|
|
|
|
'CargaContratoPadre()
|
|
UpProyecto.Update()
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " ARCHIVO "
|
|
|
|
Private Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
|
|
DescargarArchivo()
|
|
End Sub
|
|
|
|
Private Sub DescargarArchivo()
|
|
Dim File As New FileInfo(ViewState("FUrl").ToString)
|
|
|
|
If File.Exists Then 'set appropriate headers
|
|
Response.Clear()
|
|
Response.ClearHeaders()
|
|
Response.ClearContent()
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" & TxtNumeroContrato.Text & ".pdf")
|
|
Response.AddHeader("Content-Length", File.Length.ToString())
|
|
'Response.ContentType = "text/plain"
|
|
Response.ContentType = "application/octet-stream"
|
|
Response.Flush()
|
|
' Response.TransmitFile(File.FullName)
|
|
Response.WriteFile(File.FullName)
|
|
Response.End()
|
|
'if file does not exist
|
|
|
|
Alert("Descargado Correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrio un error al descargar el archivo", TipoMensaje.MsgAdvertencia, "window.close()")
|
|
|
|
End If 'nothing in the URL as HTTP GET
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardarArchivo_Click1(sender As Object, e As EventArgs) Handles BtnGuardarArchivo.Click
|
|
Dim FileExtension As String = "-1"
|
|
Dim Filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
Dim folderContratosPath As String = Path.Combine(UsuarioActual.Empresa.Ruta, "Contratos")
|
|
|
|
If Not Directory.Exists(folderContratosPath) Then
|
|
Directory.CreateDirectory(folderContratosPath)
|
|
End If
|
|
|
|
If Not Directory.Exists(Path.Combine(folderContratosPath, "Temp")) Then
|
|
Directory.CreateDirectory(Path.Combine(folderContratosPath, "Temp"))
|
|
End If
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
Session("FileExtension") = FileExtension
|
|
Dim tempArray() As String
|
|
tempArray = fileItem.filename.ToString().Split("-".ToCharArray())
|
|
|
|
|
|
ViewState("extencion") = FileExtension
|
|
ViewState("FUrl") = Path.Combine(UsuarioActual.Empresa.Ruta, "Contratos", "Temp", fileItem.filename)
|
|
|
|
File.Move(fileItem.FileUrl, ViewState("FUrl").ToString)
|
|
TxtArchivo.Text = tempArray(1)
|
|
' imgFileOk.Visible = True
|
|
'ImgArchivo.Src = "/imagenes/accept.png"
|
|
Next
|
|
|
|
UPAFUL.Update()
|
|
|
|
RegistraScript("$('#ModalUpload').modal('hide')", "hidemodal1")
|
|
A1.Visible = True
|
|
If Not FileExtension = "-1" Then
|
|
BtnDescargar.Visible = True
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region " TAB: PRESUPUESTOS "
|
|
|
|
#Region "C O M B O S - PRESUPUESTOS"
|
|
Private Function isWhitFamily() As Boolean
|
|
Return (UsuarioActual.CveEmpresa = 66)
|
|
End Function
|
|
|
|
Private Sub CargaClasificaciones()
|
|
DdlClasificacionAdd.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) ' GlobalDTClasificacionesPresupuestos(UsuarioActual.CveEmpresa)
|
|
DdlClasificacionAdd.DataBind()
|
|
DdlClasificacionAdd.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlClasificacionAddInsumos.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) ' GlobalDTClasificacionesPresupuestos(UsuarioActual.CveEmpresa)
|
|
DdlClasificacionAddInsumos.DataBind()
|
|
DdlClasificacionAddInsumos.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlClasificacionInt.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) 'GlobalDTSubFamilias(UsuarioActual.CveEmpresa)
|
|
DdlClasificacionInt.DataBind()
|
|
DdlClasificacionInt.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
#Region " FUNCIONALIDAD 105 "
|
|
Private Sub CargaPS()
|
|
DdlProductows.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
If Not DdlProductows.UsaWebService AndAlso CType(DdlProductows.DataSource, DataTable) Is Nothing Then
|
|
DdlProductows.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
|
DdlProductows.DataBind()
|
|
Else
|
|
DdlProductows.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacionAdd.SelectedValue)
|
|
End If
|
|
ElProductoChange()
|
|
End Sub
|
|
Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProductows.selectedindexchange
|
|
ElProductoChange()
|
|
End Sub
|
|
Private Sub ElProductoChange()
|
|
DdlUM.Items.Clear()
|
|
DdlUM.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductows.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
DdlUM.DataBind()
|
|
UpTitulos.Update()
|
|
End Sub
|
|
Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacionAdd.SelectedIndexChanged
|
|
ChangeDdlProducto()
|
|
End Sub
|
|
Private Sub ChangeDdlProducto()
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "" Then
|
|
DdlProductows.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacionAdd.SelectedValue.ToEntero).FiltraParametros("", "PSCodigo")
|
|
DdlProductows.DataBind()
|
|
DdlProductows.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
Else
|
|
DdlProductows.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacionAdd.SelectedValue)
|
|
DdlProductows.SelectedText = "Seleccione"
|
|
DdlProductows.SelectedValue = "-1"
|
|
End If
|
|
|
|
UpModalVentasAddPS.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaPSInsumos()
|
|
DdlProductowsInsumos.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
If Not DdlProductowsInsumos.UsaWebService AndAlso CType(DdlProductowsInsumos.DataSource, DataTable) Is Nothing Then
|
|
DdlProductowsInsumos.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
|
DdlProductowsInsumos.DataBind()
|
|
End If
|
|
ElProductoChangeInsumos()
|
|
End Sub
|
|
Protected Sub DdlProductoInsumos_ValueChanged(sender As Object, e As EventArgs) Handles DdlProductowsInsumos.selectedindexchange
|
|
ElProductoChangeInsumos()
|
|
End Sub
|
|
Private Sub ElProductoChangeInsumos()
|
|
DdlUMInsumos.Items.Clear()
|
|
DdlUMInsumos.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductowsInsumos.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
DdlUMInsumos.DataBind()
|
|
UpTitulos.Update()
|
|
End Sub
|
|
Protected Sub DdlClasificacionInsumos_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacionAddInsumos.SelectedIndexChanged
|
|
ChangeDdlProductoInsumos()
|
|
End Sub
|
|
Private Sub ChangeDdlProductoInsumos()
|
|
If UsuarioActual.Empresa.Funcionalidad(105) = "" Then
|
|
'Dim filtro As String = ""
|
|
'If Not (DdlClasificacionAddInsumos.SelectedValue = "-1") Then
|
|
|
|
' If isWhitFamily() Then
|
|
' filtro = String.Format("CveSubFamilia={0}", DdlClasificacionAddInsumos.SelectedValue)
|
|
' Else
|
|
' filtro = String.Format("CveClasificacion={0}", DdlClasificacionAddInsumos.SelectedValue)
|
|
' End If
|
|
'End If
|
|
DdlProductowsInsumos.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacionAddInsumos.SelectedValue.ToEntero).FiltraParametros("", "PSCodigo")
|
|
DdlProductowsInsumos.DataBind()
|
|
DdlProductowsInsumos.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
Else
|
|
'If isWhitFamily() Then
|
|
' DdlProductowsInsumos.ddlWS.Attributes.Add("data-idSubFamilia", DdlClasificacionAddInsumos.SelectedValue)
|
|
'Else
|
|
DdlProductowsInsumos.ddlWS.Attributes.Add("data-idClasificacion", DdlClasificacionAddInsumos.SelectedValue)
|
|
'End If
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region " TAB PRESUPUESTOS VENTAS "
|
|
Private Sub CargaGVPresupuestos(DtTemp As DataTable)
|
|
Gv.DataSource = DtTemp
|
|
DtPresupuestos = DtTemp
|
|
Gv.DataBind()
|
|
If CveTipoContrato = 25 Then
|
|
' Gv.Columns(0).Visible = False
|
|
Gv.Columns(1).Visible = False
|
|
' Gv.Columns(3).Visible = False
|
|
Gv.Columns(6).Visible = False
|
|
End If
|
|
'If (Gv.Rows.Count > 0) Then
|
|
' Gv.UseAccessibleHeader = True
|
|
' Gv.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
' RegistraScript("OrdenarGVPresupuestos();")
|
|
'End If
|
|
UpGV.Update()
|
|
End Sub
|
|
Protected Sub BtnAutorizar_Click(sender As Object, e As EventArgs) Handles BtnAutorizar.Click
|
|
Dim pinterno = TmpDT.SUM("Total", "CveTipoPresupuesto=1").ToString.ToDouble
|
|
Dim pventas = TmpDT.SUM("Total", "CveTipoPresupuesto=2").ToString.ToDouble
|
|
If (pinterno < pventas) Then
|
|
Dim objContrato As New ClsContratos
|
|
|
|
If objContrato.AutorizarContratos(CveContrato, UsuarioActual.CveUsuario) Then
|
|
BtnAutorizar.Visible = False
|
|
Autorizado = True
|
|
Alert("Contrato Autorizado", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/Contrato.aspx?CveContrato={0}""", CveContrato))
|
|
End If
|
|
objContrato.Dispose()
|
|
Else
|
|
Alert("el presupuesto de ventas debe ser mayor al presupuesto interno!", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarDetalle_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
If CveContratoDetalleEditar = -1 Then
|
|
|
|
Dim Row As DataRow = TmpDT.NewRow()
|
|
Row("Cantidad") = TxtCantidad.Text.ToDouble.FormatoNumero
|
|
Row("CantidadContratada") = TxtCantidad.Text.ToDouble.FormatoNumero
|
|
Row("CveUM") = DdlUM.SelectedValue.ToEntero
|
|
Row("UM") = DdlUM.SelectedItem
|
|
Row("CveClasificacion") = DdlClasificacionAdd.SelectedValue
|
|
Row("Clasificacion") = DdlClasificacionAdd.SelectedItem
|
|
Row("CvePS") = DdlProductows.SelectedValue.ToEntero
|
|
Row("PS") = DdlProductows.SelectedText
|
|
Row("CodigoPS") = DdlProductows.SelectedText
|
|
Row("PU") = TxtPU.Text.ToDouble.FormatoNumero
|
|
Row("Total") = (TxtCantidad.Text.ToDouble * TxtPU.Text.ToDouble).FormatoNumero
|
|
Row("CveTipoPresupuesto") = 2
|
|
Row("NoIdentificacion") = "" 'TxtNoIdentificacionv.Text.Trim
|
|
Row("OCInterna") = "" 'TxtOCInterna.Text.Trim
|
|
Row("LimitarCantidad") = ChkLimitarCantidadAdd.Checked 'If(ChkLimitarVenta.Checked, 1, 0)
|
|
Row("Observacion") = "" 'TxtObservacionesDetalles.Text
|
|
|
|
Row("CveRubro") = 1
|
|
|
|
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
|
|
If ObjContratos.AddContratosDetalle(CveContrato, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, UsuarioActual.CveUsuario, Row("CveTipoPresupuesto").ToString.ToEntero, Row("NoIdentificacion").ToString, Convert.ToBoolean(Row("LimitarCantidad")), "", Observacion:=Row("Observacion").ToString, CveRubro:=1) Then
|
|
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con un precio ${3}.", Row("Cantidad"), Row("UM"), Row("PS"), Row("PU"))
|
|
guardarBitacora(msj)
|
|
End If
|
|
|
|
Row("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle")
|
|
TmpDT.Rows.Add(Row)
|
|
TmpDT.AcceptChanges()
|
|
Dim TotalRow = Row("Total").ToString.ToDouble
|
|
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
|
|
UpGV.Update()
|
|
LimpiarModalVentas()
|
|
|
|
LbTotalGeneral.Text = (LbTotalGeneral.Text.ToDouble + TotalRow).ToString.FormatoNumero
|
|
LblImporte.Text = LbTotalGeneral.Text
|
|
TxtCantidad.Focus()
|
|
UpGral.Update()
|
|
|
|
|
|
If Not ChkContinualAgregandoVentas.Checked Then
|
|
RegistraScript("$('#ModalVentasAddPS').modal('hide')")
|
|
End If
|
|
|
|
Else
|
|
Alert("Ocurrio un error al agregar el detalle", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
Else
|
|
|
|
|
|
Dim Cantidad, PU As Double : Dim CvePS, CveUM As Integer
|
|
Dim NoIdentificacion As String = ""
|
|
'Dim OCInterna As String = ""
|
|
' Dim LimitarCantidad As Boolean
|
|
Dim Observaciones As String = ""
|
|
|
|
Cantidad = TxtCantidad.Text.ToDouble
|
|
PU = TxtPU.Text.ToDouble
|
|
CvePS = DdlProductows.SelectedValue.ToEntero
|
|
CveUM = DdlUM.SelectedValue.ToEntero
|
|
'NoIdentificacion = TxtNoIdentificacionv.Text.Trim
|
|
'OCInterna = TxtOCInterna.Text.Trim
|
|
'LimitarCantidad = If(ChkLimitarVenta.Checked, True, False)
|
|
Observaciones = ""
|
|
Dim limitarCantidad As Boolean = ChkLimitarCantidad.Checked
|
|
|
|
|
|
Dim row = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalleEditar))(0)
|
|
Dim LimitarCantidadValidator As Boolean = row("LimitarCantidad").ToString = "True"
|
|
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.UpdateContratosDetalle(CveContratoDetalleEditar, CveContrato, CvePS, Cantidad, PU, UsuarioActual.CveUsuario, NoIdentificacion, limitarCantidad, "", Observaciones, CveRubro:=1) Then
|
|
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se realizaron los siguientes cambios, el Presupuesto Interno se modificó: {1} {0} {2:C2} a {3} {0} {4:C2}",
|
|
row("PS").ToString, row("Cantidad").ToString, row("PU").ToString, Cantidad, PU)
|
|
guardarBitacora(msj)
|
|
End If
|
|
|
|
row("Cantidad") = Cantidad
|
|
row("CantidadContratada") = Cantidad
|
|
row("PU") = PU
|
|
row("Total") = Cantidad * PU
|
|
row("CveUM") = CveUM
|
|
row("UM") = DdlUM.SelectedItem.Text
|
|
row("NoIdentificacion") = NoIdentificacion
|
|
row("OCInterna") = ""
|
|
row("LimitarCantidad") = limitarCantidad
|
|
row("Observacion") = Observaciones
|
|
|
|
TmpDT.AcceptChanges()
|
|
Alert("Cambios realizados correctamente.", TipoMensaje.MsgInformacion)
|
|
RegistraScript("$('#ModalVentasAddPS').modal('hide')")
|
|
Else
|
|
Alert("Error al Actualizar Detalle", TipoMensaje.MsgError)
|
|
End If
|
|
ObjContratos.Dispose()
|
|
|
|
|
|
Gv.EditIndex = -1
|
|
LbTotalGeneral.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=2").SUM("Total").FormatoNumero
|
|
LblImporte.Text = LbTotalGeneral.Text
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
|
|
End If
|
|
CveContratoDetalleEditar = -1
|
|
End Sub
|
|
|
|
Private Sub CargaDatosPresup()
|
|
Dim ContratosSecciones As New ClsContratos()
|
|
|
|
If ContratosSecciones.GetContratosSecciones(-1, CveContrato, -1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
'If ContratosSecciones.GetContratosSecciones(-1, DdlEstatus.SelectedValue.ToEntero, DdlPS.SelectedValue.ToEntero, DdlContrato.SelectedValue.ToEntero, -1, -1, FechaI, FechaF) Then
|
|
DtDatos = ContratosSecciones.DtResultados
|
|
' DtDatos.Rows.RemoveAt(0)
|
|
CargaGVPresupuestos(DtDatos)
|
|
LblImporte.Text = "$" & DtDatos.MAX("Total").FormatoNumero()
|
|
Else
|
|
Gv.DataSource = Nothing
|
|
End If
|
|
|
|
ContratosSecciones.Dispose()
|
|
|
|
UpGral.Update()
|
|
End Sub
|
|
|
|
#Region "GV PRESUPUESTOS"
|
|
|
|
Protected Sub EstClick(sender As Object, e As System.EventArgs)
|
|
'Get the button that raised the event
|
|
Dim btn As CheckBox = DirectCast(sender, CheckBox)
|
|
Dim gvr As GridViewRow = DirectCast(btn.NamingContainer, GridViewRow)
|
|
Dim CveContratoDetalle As Integer = gvr.DataKey("CveContratoDetalle").ToString.ToEntero
|
|
Dim objContrato As New ClsContratos
|
|
If objContrato.UpdateContratosDetalleEstimacion(CveContratoDetalle, IIf(btn.Checked, 1, 0).ToString.ToEntero) Then
|
|
Dim row = TmpDT.Select(String.Format("CveContratoDetalle={0}", CveContratoDetalle))(0)
|
|
row("PermitirEstimacion") = IIf(btn.Checked, 1, 0).ToString.ToEntero
|
|
Alert("Se ha permitido estimar", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("no se pudo permitir avance")
|
|
End If
|
|
objContrato.Dispose()
|
|
|
|
End Sub
|
|
|
|
Protected Sub AvaClick(sender As Object, e As System.EventArgs)
|
|
'Get the button that raised the event
|
|
Dim btn As CheckBox = DirectCast(sender, CheckBox)
|
|
Dim gvr As GridViewRow = DirectCast(btn.NamingContainer, GridViewRow)
|
|
Dim CveContratoDetalle As Integer = gvr.DataKey("CveContratoDetalle").ToString.ToEntero
|
|
Dim objContrato As New ClsContratos
|
|
If objContrato.UpdateContratosDetalleAvance(CveContratoDetalle, IIf(btn.Checked, 1, 0).ToString.ToEntero) Then
|
|
Dim row = TmpDT.Select(String.Format("CveContratoDetalle={0}", CveContratoDetalle))(0)
|
|
row("PermitirAvance") = IIf(btn.Checked, 1, 0).ToString.ToEntero
|
|
|
|
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
|
|
|
|
Alert("Se ha permitido levantar avance", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("no se pudo permitir avance", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
objContrato.Dispose()
|
|
End Sub
|
|
Protected Sub GV_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles Gv.RowDataBound
|
|
|
|
If e.Row.RowIndex > -1 Then
|
|
|
|
Dim LnkHabilitaAvance As LinkButton = e.Row.FCLinkButton("LnkHabilitaAvance")
|
|
' e.Row.FCCheckBox("CHKPAvance").Visible = Autorizado
|
|
'e.Row.FCCheckBox("CHKPEstimacion").Visible = Autorizado
|
|
If UsuarioActual.TienePermisoProceso(124) Then
|
|
e.Row.FCCheckBox("CHKPAvance").Enabled = True
|
|
LnkHabilitaAvance.Enabled = True
|
|
End If
|
|
|
|
If e.Row.DBCampo("PermitirAvance").ToString = "1" Then
|
|
e.Row.FCCheckBox("CHKPAvance").Checked = True
|
|
' If UsuarioActual.TienePermisoProceso(125) Then : e.Row.FCCheckBox("CHKPEstimacion").Enabled = True : End If
|
|
End If
|
|
|
|
If e.Row.DBCampo("PermitirEstimacion").ToString = "1" Then
|
|
' e.Row.FCCheckBox("CHKPEstimacion").Checked = True
|
|
End If
|
|
If Autorizado Then
|
|
' e.Row.FCLinkButton("imgE").Visible = False
|
|
'e.Row.FCLinkButton("imgD").Visible = False
|
|
End If
|
|
If CveTipoContrato = 25 Then
|
|
e.Row.Cells(1).Width = Unit.Pixel(10)
|
|
e.Row.Cells(6).Width = Unit.Pixel(250)
|
|
End If
|
|
|
|
|
|
|
|
|
|
If e.Row.DBCampo("PermitirAvance").ToString = "1" Then
|
|
LnkHabilitaAvance.Text = "<i class='fa fa-check-square-o' aria-hidden='true'></i>"
|
|
LnkHabilitaAvance.Attributes.Add("data-original-title", "¿Deshabilitar avance?")
|
|
Else
|
|
LnkHabilitaAvance.Text = "<i class='fa fa-square-o' aria-hidden='true'></i>"
|
|
LnkHabilitaAvance.Attributes.Add("data-original-title", "¿Habilitar avance?")
|
|
End If
|
|
|
|
|
|
End If
|
|
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
|
|
e.Row.FCDropDownList("DdlUMEdit").DataSource = GlobalDTProductosServiciosEquivalencias(e.Row.DataKey("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
e.Row.FCDropDownList("DdlUMEdit").DataBind()
|
|
e.Row.FCDropDownList("DdlUMEdit").SelectedValue = e.Row.DataKey("CveUM")
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub GV_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles Gv.RowEditing
|
|
Gv.EditIndex = e.NewEditIndex
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
End Sub
|
|
Protected Sub Gv_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles Gv.RowUpdating
|
|
Dim Cantidad, PU As Double : Dim CvePS, CveContratoDetalle, CveUM As Integer
|
|
Dim NoIdentificacion As String = ""
|
|
Dim OCInterna As String = ""
|
|
Dim LimitarCantidad As Boolean
|
|
Dim Observaciones As String = ""
|
|
CveContratoDetalle = Gv.Rows(e.RowIndex).DataKey("CveContratoDetalle").ToString.ToEntero
|
|
Cantidad = Gv.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.Trim.ToDouble
|
|
PU = Gv.Rows(e.RowIndex).FCTextBox("TxtPU").Text.Trim.ToDouble
|
|
CvePS = Gv.Rows(e.RowIndex).DataKey("CvePS").ToString.ToEntero
|
|
CveUM = Gv.Rows(e.RowIndex).FCDropDownList("DdlUMEdit").SelectedValue.ToEntero
|
|
NoIdentificacion = Gv.Rows(e.RowIndex).FCTextBox("TxtNoIdentificacion").Text.ToString
|
|
OCInterna = Gv.Rows(e.RowIndex).FCTextBox("TxtOCInternaEdit").Text.ToString
|
|
LimitarCantidad = Gv.Rows(e.RowIndex).FCCheckBox("ChkLimitarCantidad").Checked
|
|
Observaciones = Gv.Rows(e.RowIndex).FCTextBox("TxtObservacion").Text.ToString
|
|
Dim row = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalle))(0)
|
|
Dim LimitarCantidadValidator As Boolean = row("LimitarCantidad").ToString = "True"
|
|
If row("CantidadContratada").ToString.ToEntero <> Cantidad OrElse row("PU").ToString.ToEntero <> PU OrElse CveUM <> row("CveUM").ToString.ToEntero OrElse row("NoIdentificacion").ToString <> NoIdentificacion OrElse row("OCInterna").ToString <> OCInterna OrElse LimitarCantidadValidator <> LimitarCantidad Then
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.UpdateContratosDetalle(CveContratoDetalle, CveContrato, CvePS, Cantidad, PU, UsuarioActual.CveUsuario, NoIdentificacion, LimitarCantidad, OCInterna, Observaciones) Then
|
|
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se realizaron los siguientes cambios, el Presupuesto Interno se modificó: {1} {0} {2:C2} a {3} {0} {4:C2}",
|
|
row("PS").ToString, row("Cantidad").ToString, row("PU").ToString, Cantidad, PU)
|
|
guardarBitacora(msj)
|
|
End If
|
|
|
|
row("Cantidad") = Cantidad
|
|
row("CantidadContratada") = Cantidad
|
|
row("PU") = PU
|
|
row("Total") = Cantidad * PU
|
|
row("CveUM") = CveUM
|
|
row("UM") = Gv.Rows(e.RowIndex).FCDropDownList("DdlUMEdit").SelectedItem.Text
|
|
row("NoIdentificacion") = NoIdentificacion
|
|
row("OCInterna") = OCInterna
|
|
row("LimitarCantidad") = LimitarCantidad
|
|
row("Observacion") = Observaciones
|
|
|
|
TmpDT.AcceptChanges()
|
|
Alert("Cambios realizados correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Error al Actualizar Detalle", TipoMensaje.MsgError)
|
|
End If
|
|
ObjContratos.Dispose()
|
|
|
|
Else
|
|
Alert("Cambios realizados correctamente")
|
|
End If
|
|
|
|
Gv.EditIndex = -1
|
|
LbTotalGeneral.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=2").SUM("Total").FormatoNumero
|
|
LblImporte.Text = LbTotalGeneral.Text
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
|
|
End Sub
|
|
Protected Sub GV_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles Gv.RowCancelingEdit
|
|
Gv.EditIndex = -1
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
End Sub
|
|
Protected Sub GV_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles Gv.RowDeleting
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
Dim DbRow As DataRow = Nothing
|
|
Dim CveContratoDetalle As Integer = Gv.Rows(e.RowIndex).DataKey("CveContratoDetalle").ToString.ToEntero
|
|
DbRow = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalle))(0)
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se eliminaron {0} {1} producto {2} con el precio {3}", DbRow("Cantidad"), DbRow("UM"), DbRow("PS"), DbRow("PU"))
|
|
guardarBitacora(msj)
|
|
End If
|
|
|
|
If ObjContratos.RemoveContratosDetalle(CveContratoDetalle, CveContrato) Then
|
|
TmpDT.Rows.Remove(DbRow)
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
LbTotalGeneral.Text = Gv.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.FCLabel("LtTotal").Text.ToDouble).ToString.FormatoNumero
|
|
Alert("Detalle eliminado eliminado correctamente.")
|
|
Else
|
|
Alert("Ocurrió un error al eliminar el detalle (Producto/Servicio). Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
Protected Sub GV_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles Gv.RowCommand
|
|
If e.CommandName = "Sel" Then
|
|
' Seleccionado = e.CommandArgument.ToString
|
|
Gv.SelectRow(e.CommandArgument.ToString.ToEntero - 1)
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " TAB PRESUPUESTOS INSUMOS "
|
|
Private Sub CargaGVPresupuestosInsumos(DtTemp As DataTable)
|
|
GvInsumos.DataSource = DtTemp
|
|
DtSuministros = DtTemp
|
|
GvInsumos.DataBind()
|
|
'If (GvInsumos.Rows.Count > 0) Then
|
|
' GvInsumos.UseAccessibleHeader = True
|
|
' GvInsumos.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
' RegistraScript("OrdenarGVPresupuestosInsumos();")
|
|
'End If
|
|
UpGVInsumos.Update()
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarDetalleInsumos_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
'DdlProductowsInsumos.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
If Not DdlProductowsInsumos.UsaWebService Then
|
|
If DdlRubro.SelectedValue.ToEntero = 2 And DdlProductowsInsumos.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Debe de seleccionar un producto.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Else
|
|
|
|
|
|
If DdlRubro.SelectedValue.ToEntero = 1 And DdlProductowsInsumos.txtValue.Value.ToEntero <= 0 Then
|
|
Alert("Debe de seleccionar un producto.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
If CveContratoDetalleEditar = -1 Then
|
|
|
|
Dim Row As DataRow = TmpDT.NewRow()
|
|
Row("Cantidad") = TxtCantidadInsumos.Text.ToDouble.FormatoNumero
|
|
Row("CantidadContratada") = TxtCantidadInsumos.Text.ToDouble.FormatoNumero
|
|
|
|
Row("PU") = TxtPUInsumos.Text.ToDouble.FormatoNumero
|
|
Row("Total") = (TxtCantidadInsumos.Text.ToDouble * TxtPUInsumos.Text.ToDouble).FormatoNumero
|
|
Row("CveTipoPresupuesto") = 1
|
|
Row("NoIdentificacion") = "" 'TxtNoIdentificacionvInsumos.Text.Trim
|
|
Row("LimitarCantidad") = ChkLimitarCantidad.Checked
|
|
|
|
Row("CveRubro") = DdlRubro.SelectedValue.ToEntero
|
|
Row("Rubro") = DdlRubro.SelectedItem.Text
|
|
|
|
If DdlRubro.SelectedValue.ToEntero = 3 Then
|
|
|
|
Row("CveActividad") = DdlActividades.SelectedValue.ToEntero
|
|
Row("Actividad") = DdlActividades.SelectedItem.Text
|
|
Row("Dias") = TxtDias.Text.ToEntero
|
|
Row("CveSubTipoActivoFijo") = -1
|
|
|
|
|
|
Row("CveUM") = -1
|
|
Row("UM") = ""
|
|
Row("CveClasificacion") = -1
|
|
Row("Clasificacion") = ""
|
|
Row("CvePS") = -1
|
|
Row("PS") = DdlActividades.SelectedItem.Text
|
|
Row("CodigoPS") = DdlActividades.SelectedItem.Text
|
|
|
|
|
|
ElseIf DdlRubro.SelectedValue.ToEntero = 4 Then
|
|
|
|
Row("CveActividad") = -1
|
|
Row("Actividad") = ""
|
|
Row("Dias") = TxtDias.Text.ToEntero
|
|
Row("CveSubTipoActivoFijo") = DdlSubTipoActivoFijo.SelectedValue.ToEntero
|
|
|
|
|
|
Row("CveUM") = -1
|
|
Row("UM") = ""
|
|
Row("CveClasificacion") = -1
|
|
Row("Clasificacion") = ""
|
|
Row("CvePS") = -1
|
|
Row("PS") = DdlSubTipoActivoFijo.SelectedItem.Text
|
|
Row("CodigoPS") = DdlSubTipoActivoFijo.SelectedItem.Text
|
|
|
|
Else
|
|
Row("CveActividad") = -1
|
|
Row("Actividad") = ""
|
|
Row("CveSubTipoActivoFijo") = -1
|
|
Row("Dias") = 0
|
|
|
|
|
|
Row("CveUM") = DdlUMInsumos.SelectedValue.ToEntero
|
|
Row("UM") = DdlUMInsumos.SelectedItem
|
|
Row("CveClasificacion") = DdlClasificacionAddInsumos.SelectedValue
|
|
Row("Clasificacion") = DdlClasificacionAddInsumos.SelectedItem
|
|
Row("CvePS") = DdlProductowsInsumos.SelectedValue.ToEntero
|
|
Row("PS") = DdlProductowsInsumos.SelectedText
|
|
Row("CodigoPS") = DdlProductowsInsumos.SelectedText
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.AddContratosDetalle(CveContrato, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, UsuarioActual.CveUsuario, Row("CveTipoPresupuesto").ToString.ToEntero, Row("NoIdentificacion").ToString, Convert.ToBoolean(Row("LimitarCantidad")), "",
|
|
CveRubro:=Row("CveRubro").ToString.ToEntero, CveActividad:=Row("CveActividad").ToString.ToEntero, CveSubTipoActivoFijo:=Row("CveSubTipoActivoFijo").ToString.ToEntero, Dias:=Row("Dias").ToString.ToEntero) Then
|
|
'If Autorizado Then
|
|
' Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con un precio ${3}.", Row("Cantidad"), Row("UM"), Row("PS"), Row("PU"))
|
|
' guardarBitacora(msj)
|
|
'End If
|
|
|
|
Row("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle")
|
|
TmpDT.Rows.Add(Row)
|
|
Dim TotalRow = Row("Total").ToString.ToDouble
|
|
|
|
CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1"))
|
|
|
|
UpGVInsumos.Update()
|
|
LimpiarModalControl()
|
|
LbTotalGeneralInsumos.Text = (LbTotalGeneralInsumos.Text.ToDouble + TotalRow).ToString.FormatoNumero
|
|
'LblImporte.Text = LbTotalGeneral.Text
|
|
TxtCantidadInsumos.Focus()
|
|
UpGral.Update()
|
|
|
|
|
|
If Not ChkContinualAgregandoControl.Checked Then
|
|
RegistraScript("$('#ModalControlAddPS').modal('hide')")
|
|
End If
|
|
|
|
Else
|
|
Alert("Ocurrio un error al agregar el detalle", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
|
|
Else
|
|
|
|
Dim Cantidad, PU As Double
|
|
Dim CvePS, CveUM As Integer
|
|
|
|
Dim CveRubro As Integer = DdlRubro.SelectedValue.ToEntero
|
|
|
|
Dim CveActividad As Integer = -1
|
|
Dim CveSubTipoActivoFijo As Integer = -1
|
|
Dim Dias As Integer = 0
|
|
|
|
If CveRubro = 3 Then
|
|
|
|
CveSubTipoActivoFijo = -1
|
|
CveActividad = DdlActividades.SelectedValue.ToEntero
|
|
Dias = TxtDias.Text.ToEntero
|
|
|
|
CvePS = -1
|
|
CveUM = -1
|
|
|
|
ElseIf CveRubro = 4 Then
|
|
|
|
CveSubTipoActivoFijo = DdlSubTipoActivoFijo.SelectedValue.ToEntero
|
|
CveActividad = -1
|
|
Dias = TxtDias.Text.ToEntero
|
|
|
|
CvePS = -1
|
|
CveUM = -1
|
|
|
|
Else
|
|
CvePS = DdlProductowsInsumos.SelectedValue.ToEntero
|
|
CveUM = DdlUMInsumos.SelectedValue.ToEntero
|
|
End If
|
|
|
|
|
|
Cantidad = TxtCantidadInsumos.Text.ToDouble
|
|
PU = TxtPUInsumos.Text.ToDouble
|
|
Dim limitarCantidad As Boolean = ChkLimitarCantidad.Checked
|
|
|
|
|
|
|
|
Dim row = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalleEditar))(0)
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.UpdateContratosDetalle(CveContratoDetalleEditar, CveContrato, CvePS, Cantidad, PU, UsuarioActual.CveUsuario, "", limitarCantidad, "", CveRubro:=CveRubro, CveActividad:=CveActividad, CveSubTipoActivoFijo:=CveSubTipoActivoFijo, Dias:=Dias) Then
|
|
|
|
'If Autorizado Then
|
|
' Dim msj As String = String.Format("Se realizaron los siguientes cambios, el Presupuesto Interno se modificó: {1} {0} {2:C2} a {3} {0} {4:C2}",
|
|
' row("PS").ToString, row("Cantidad").ToString, row("PU").ToString, Cantidad, PU)
|
|
' guardarBitacora(msj)
|
|
'End If
|
|
|
|
|
|
|
|
row("Cantidad") = Cantidad
|
|
row("CantidadContratada") = Cantidad
|
|
row("PU") = PU
|
|
row("Total") = Cantidad * PU
|
|
row("CveUM") = CveUM
|
|
|
|
row("NoIdentificacion") = "" 'NoIdentificacion
|
|
row("LimitarCantidad") = limitarCantidad
|
|
|
|
row("CveActividad") = CveActividad
|
|
row("CveSubTipoActivoFijo") = CveSubTipoActivoFijo
|
|
row("Dias") = Dias
|
|
|
|
|
|
If CveRubro = 3 Then
|
|
row("PS") = DdlActividades.SelectedItem.Text
|
|
row("CodigoPS") = DdlActividades.SelectedItem.Text
|
|
row("UM") = ""
|
|
ElseIf CveRubro = 4 Then
|
|
row("PS") = DdlSubTipoActivoFijo.SelectedItem.Text
|
|
row("CodigoPS") = DdlSubTipoActivoFijo.SelectedItem.Text
|
|
row("UM") = ""
|
|
Else
|
|
row("UM") = DdlUMInsumos.SelectedItem.Text
|
|
End If
|
|
|
|
TmpDT.AcceptChanges()
|
|
|
|
Alert("Cambios realizados correctamente.", TipoMensaje.MsgInformacion)
|
|
RegistraScript("$('#ModalControlAddPS').modal('hide')")
|
|
|
|
Else
|
|
Alert("Error al Actualizar Detalle", TipoMensaje.MsgError)
|
|
End If
|
|
ObjContratos.Dispose()
|
|
|
|
GvInsumos.EditIndex = -1
|
|
LbTotalGeneralInsumos.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").FormatoNumero
|
|
CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1"))
|
|
CveContratoDetalleEditar = -1
|
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
#Region "GV PRESUPUESTOS"
|
|
|
|
Protected Sub GVInsumos_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvInsumos.RowDataBound
|
|
|
|
If e.Row.RowIndex > -1 Then
|
|
|
|
e.Row.FCCheckBox("CHKPAvance").Visible = Autorizado
|
|
'e.Row.FCCheckBox("CHKPEstimacion").Visible = Autorizado
|
|
If UsuarioActual.TienePermisoProceso(124) Then
|
|
e.Row.FCCheckBox("CHKPAvance").Enabled = True
|
|
End If
|
|
|
|
If e.Row.DBCampo("PermitirAvance").ToString = "1" Then
|
|
e.Row.FCCheckBox("CHKPAvance").Checked = True
|
|
' If UsuarioActual.TienePermisoProceso(125) Then : e.Row.FCCheckBox("CHKPEstimacion").Enabled = True : End If
|
|
End If
|
|
|
|
If e.Row.DBCampo("PermitirEstimacion").ToString = "1" Then
|
|
' e.Row.FCCheckBox("CHKPEstimacion").Checked = True
|
|
End If
|
|
If Autorizado Then
|
|
'e.Row.FCLinkButton("imgE").Visible = False
|
|
'e.Row.FCLinkButton("imgD").Visible = False
|
|
End If
|
|
If e.Row.FCLabel("LtlLimitarCantidad").Text.ToString = "True" Then
|
|
e.Row.FCLabel("LtlLimitarCantidad").Text = "Si"
|
|
Else
|
|
e.Row.FCLabel("LtlLimitarCantidad").Text = "No"
|
|
End If
|
|
|
|
End If
|
|
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
|
|
e.Row.FCDropDownList("DdlUMEdit").DataSource = GlobalDTProductosServiciosEquivalencias(e.Row.DataKey("CvePS").ToString.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
e.Row.FCDropDownList("DdlUMEdit").DataBind()
|
|
e.Row.FCDropDownList("DdlUMEdit").SelectedValue = e.Row.DataKey("CveUM")
|
|
End If
|
|
|
|
End Sub
|
|
Protected Sub GVInsumos_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvInsumos.RowEditing
|
|
GvInsumos.EditIndex = e.NewEditIndex
|
|
CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1"))
|
|
End Sub
|
|
Protected Sub GvInsumos_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvInsumos.RowUpdating
|
|
Dim Cantidad, PU As Double
|
|
Dim CvePS, CveContratoDetalle, CveUM As Integer
|
|
Dim NoIdentificacion As String = ""
|
|
Dim LimitarCantidad As Boolean
|
|
|
|
CveContratoDetalle = GvInsumos.Rows(e.RowIndex).DataKey("CveContratoDetalle").ToString.ToEntero
|
|
Cantidad = GvInsumos.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.Trim.ToDouble
|
|
PU = GvInsumos.Rows(e.RowIndex).FCTextBox("TxtPU").Text.Trim.ToDouble
|
|
CvePS = GvInsumos.Rows(e.RowIndex).DataKey("CvePS").ToString.ToEntero
|
|
CveUM = GvInsumos.Rows(e.RowIndex).FCDropDownList("DdlUMEdit").SelectedValue.ToEntero
|
|
NoIdentificacion = GvInsumos.Rows(e.RowIndex).FCTextBox("TxtNoIdentificacion").Text.ToString
|
|
LimitarCantidad = GvInsumos.Rows(e.RowIndex).FCCheckBox("ChkLimitarCantidad").Checked
|
|
|
|
Dim row = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalle))(0)
|
|
|
|
If row("Cantidad").ToString.ToEntero <> Cantidad OrElse row("PU").ToString.ToEntero <> PU OrElse CveUM <> row("CveUM").ToString.ToEntero OrElse row("NoIdentificacion").ToString <> NoIdentificacion OrElse (row("LimitarCantidad").ToString = "True") <> LimitarCantidad Then
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.UpdateContratosDetalle(CveContratoDetalle, CveContrato, CvePS, Cantidad, PU, UsuarioActual.CveUsuario, NoIdentificacion, LimitarCantidad, "") Then
|
|
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se realizaron los siguientes cambios, el Presupuesto Interno se modificó: {1} {0} {2:C2} a {3} {0} {4:C2}",
|
|
row("PS").ToString, row("Cantidad").ToString, row("PU").ToString, Cantidad, PU)
|
|
guardarBitacora(msj)
|
|
End If
|
|
|
|
row("Cantidad") = Cantidad
|
|
row("CantidadContratada") = Cantidad
|
|
row("PU") = PU
|
|
row("Total") = Cantidad * PU
|
|
row("CveUM") = CveUM
|
|
row("UM") = GvInsumos.Rows(e.RowIndex).FCDropDownList("DdlUMEdit").SelectedItem.Text
|
|
row("NoIdentificacion") = NoIdentificacion
|
|
row("LimitarCantidad") = LimitarCantidad
|
|
TmpDT.AcceptChanges()
|
|
Alert("Cambios realizados correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Error al Actualizar Detalle", TipoMensaje.MsgError)
|
|
End If
|
|
ObjContratos.Dispose()
|
|
|
|
Else
|
|
Alert("Cambios realizados correctamente")
|
|
End If
|
|
|
|
GvInsumos.EditIndex = -1
|
|
LbTotalGeneralInsumos.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").FormatoNumero
|
|
'LblImporte.Text = LbTotalGeneral.Text
|
|
CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1"))
|
|
|
|
End Sub
|
|
Protected Sub GVInsumos_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvInsumos.RowCancelingEdit
|
|
GvInsumos.EditIndex = -1
|
|
CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1"))
|
|
End Sub
|
|
Protected Sub GVInsumos_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvInsumos.RowDeleting
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
Dim DbRow As DataRow = Nothing
|
|
Dim CveContratoDetalle As Integer = GvInsumos.Rows(e.RowIndex).DataKey("CveContratoDetalle").ToString.ToEntero
|
|
DbRow = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalle))(0)
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se eliminaron {0} {1} producto {2} con el precio {3}", DbRow("Cantidad"), DbRow("UM"), DbRow("PS"), DbRow("PU"))
|
|
guardarBitacora(msj)
|
|
End If
|
|
|
|
If ObjContratos.RemoveContratosDetalle(CveContratoDetalle, CveContrato) Then
|
|
TmpDT.Rows.Remove(DbRow)
|
|
CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1"))
|
|
LbTotalGeneralInsumos.Text = GvInsumos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.FCLabel("LtTotal").Text.ToDouble).ToString.FormatoNumero
|
|
Alert("Detalle eliminado eliminado correctamente.")
|
|
Else
|
|
Alert("Ocurrió un error al eliminar el detalle (Producto/Servicio). Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
Protected Sub GVInsumos_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvInsumos.RowCommand
|
|
If e.CommandName = "Sel" Then
|
|
' Seleccionado = e.CommandArgument.ToString
|
|
GvInsumos.SelectRow(e.CommandArgument.ToString.ToEntero - 1)
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " TAB PRESUPUESTOS INTERNOS"
|
|
|
|
Protected Sub AgregarInt_Click(sender As Object, e As EventArgs) Handles AgregarInt.Click
|
|
Dim Row As DataRow = TmpDT.NewRow()
|
|
Row("Cantidad") = TxtCantidadInt.Text.ToDouble.FormatoNumero
|
|
Row("CveUM") = DdlUMInt.SelectedValue.ToEntero
|
|
Row("UM") = DdlUMInt.SelectedItem
|
|
Row("CveClasificacion") = DdlClasificacionInt.SelectedValue
|
|
Row("Clasificacion") = DdlClasificacionInt.SelectedItem
|
|
Row("CvePS") = HFProductoInt.Value
|
|
Row("PS") = HFTProductoInt.Value
|
|
Row("PU") = TxtPUInt.Text.ToDouble.FormatoNumero
|
|
Row("Total") = (TxtCantidadInt.Text.ToDouble * TxtPUInt.Text.ToDouble).FormatoNumero
|
|
Row("CveTipoPresupuesto") = 1
|
|
Row("NoIdentificacion") = "" ' TxtNoIdentificacionv.Text.Trim
|
|
Row("LimitarCantidad") = False 'ChkLimitar.Checked <-- Estaba usando un checkbox de un logar muy diferente a donde esta ese formilario, posiblemente se copio codigo y se fue por equivocacion
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.AddContratosDetalle(CveContrato, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, UsuarioActual.CveUsuario, Row("CveTipoPresupuesto").ToString.ToEntero, Row("NoIdentificacion").ToString, Row("LimitarCantidad").ToString.ToEntero = 1, "") Then
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con un precio ${3}.", Row("Cantidad"), Row("UM"), Row("PS"), Row("PU"))
|
|
guardarBitacora(msj)
|
|
End If
|
|
Row("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle")
|
|
TmpDT.Rows.Add(Row)
|
|
Dim TotalRow = Row("Total").ToString.ToDouble
|
|
GvInt.DataSource = TmpDT.FiltraParametros("CveTipoPresupuesto=1")
|
|
GvInt.DataBind()
|
|
|
|
HFProductoInt.Value = ""
|
|
HFTProductoInt.Value = ""
|
|
TxtCantidadInt.Text = ""
|
|
TxtPUInt.Text = ""
|
|
DdlClasificacionInt.SelectedValue = "-1"
|
|
LbTotalGeneralInt.Text = (LbTotalGeneralInt.Text.ToDouble + TotalRow).ToString.FormatoNumero
|
|
TxtCantidad.Focus()
|
|
UPGVInt.Update()
|
|
Else
|
|
'Alert("No se pudo agregar el detalle")
|
|
End If
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
|
|
|
|
#Region "GVInternos"
|
|
|
|
|
|
Protected Sub GVInt_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvInt.RowEditing
|
|
GvInt.EditIndex = e.NewEditIndex
|
|
GvInt.DataSource = TmpDT.FiltraParametros("CveTipoPresupuesto=1")
|
|
GvInt.DataBind()
|
|
UPGVInt.Update()
|
|
End Sub
|
|
Protected Sub GvInt_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvInt.RowUpdating
|
|
Dim Cantidad, PU As Double : Dim CvePS, CveContratoDetalle, CveUM As Integer
|
|
CveContratoDetalle = GvInt.Rows(e.RowIndex).DataKey("CveContratoDetalle").ToString.ToEntero
|
|
Dim NoIdentificacion As String = ""
|
|
Dim LimitarCantidad As Boolean
|
|
'Row("NoIdentificacion") = txtNoIdentificacion.Text.Trim
|
|
Cantidad = GvInt.Rows(e.RowIndex).FCTextBox("TxtCantidad").Text.Trim.ToDouble
|
|
PU = GvInt.Rows(e.RowIndex).FCTextBox("TxtPU").Text.Trim.ToDouble
|
|
LimitarCantidad = False
|
|
CvePS = GvInt.Rows(e.RowIndex).DataKey("CvePS").ToString.ToEntero
|
|
CveUM = GvInt.Rows(e.RowIndex).FCDropDownList("DdlUMEdit").SelectedValue.ToEntero
|
|
|
|
'NoIdentificacion = GvInt.Rows(e.RowIndex).FCDropDownList("NoIdentificacion").ToString
|
|
Dim row = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalle))(0)
|
|
Dim c1 = row("Cantidad").ToString.ToEntero
|
|
Dim p1 = row("PU").ToString.ToEntero
|
|
Dim cvum1 = row("CveUM").ToString.ToEntero
|
|
If c1 <> Cantidad OrElse p1 <> PU OrElse CveUM <> cvum1 Then
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.UpdateContratosDetalle(CveContratoDetalle, CveContrato, CvePS, Cantidad, PU, UsuarioActual.CveUsuario, Nothing, LimitarCantidad, "") Then
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se realizaron los siguientes cambios, el Presupuesto Interno se modificó: {1} {0} {2:C2} a {3} {0} {4:C2}",
|
|
row("PS").ToString, row("Cantidad"), row("PU").ToString, Cantidad, PU)
|
|
guardarBitacora(msj)
|
|
End If
|
|
row("Cantidad") = Cantidad
|
|
row("PU") = PU
|
|
row("Total") = Cantidad * PU
|
|
row("CveUM") = CveUM
|
|
row("UM") = GvInt.Rows(e.RowIndex).FCDropDownList("DdlUMEdit").SelectedItem.Text
|
|
Else
|
|
End If
|
|
ObjContratos.Dispose()
|
|
Else
|
|
Alert("No realizaste ningun Cambio")
|
|
End If
|
|
GvInt.EditIndex = -1
|
|
GvInt.DataSource = TmpDT.FiltraParametros("CveTipoPresupuesto=1")
|
|
GvInt.DataBind()
|
|
LbTotalGeneralInt.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=1").SUM("Total").FormatoNumero
|
|
End Sub
|
|
Protected Sub GVInt_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvInt.RowCancelingEdit
|
|
GvInt.EditIndex = -1
|
|
GvInt.DataSource = TmpDT.FiltraParametros("CveTipoPresupuesto=1")
|
|
GvInt.DataBind()
|
|
UPGVInt.Update()
|
|
End Sub
|
|
Protected Sub GVInt_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvInt.RowDeleting
|
|
Dim ObjContratos As New ClsContratos
|
|
Dim DbRow As DataRow = Nothing
|
|
Dim CveContratoDetalle As Integer = GvInt.Rows(e.RowIndex).DataKey("CveContratoDetalle").ToString.ToEntero
|
|
|
|
If ObjContratos.RemoveContratosDetalle(CveContratoDetalle, CveContrato) Then
|
|
DbRow = TmpDT.Select(String.Format(" CveContratoDetalle={0}", CveContratoDetalle))(0)
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se eliminaron {0} {1} {2} con el precio {3:C2}", DbRow("Cantidad"), DbRow("UM"), DbRow("PS"), DbRow("PU"))
|
|
guardarBitacora(msj)
|
|
End If
|
|
TmpDT.Rows.Remove(DbRow)
|
|
GvInt.DataSource = TmpDT.FiltraParametros("CveTipoPresupuesto=1")
|
|
GvInt.DataBind()
|
|
UPGVInt.Update()
|
|
LbTotalGeneralInt.Text = GvInt.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.FCLabel("LtTotal").Text.ToDouble).ToString.FormatoNumero
|
|
Else
|
|
Alert("Ocurrió un error al eliminar el detalle (Producto/Servicio). Por favor vuelva a intentar", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
Protected Sub GVInt_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvInt.RowCommand
|
|
If e.CommandName = "Sel" Then
|
|
' Seleccionado = e.CommandArgument.ToString
|
|
GvInt.SelectRow(e.CommandArgument.ToString.ToEntero - 1)
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region " TAB: REPORTE AVANCES "
|
|
Private Sub CargaDatosAvance()
|
|
If CveContrato <= 0 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
TabReporteAvance.Visible = True
|
|
'lbImprimirAvance.Visible = True
|
|
|
|
Dim Modalidad = IfNull(Request("Tipo"), 1, 2)
|
|
|
|
If Modalidad.ToString.ToEntero = 2 Then
|
|
TAB.ActiveTabIndex = 2
|
|
End If
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
If ObjContratos.GetReporteContratosObraAvancesDetalle(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
GvDatosAvance.DataSource = ObjContratos.DtResultados
|
|
SumaAvance = ObjContratos.DtResultados.SUM("AvanceImporte", "CveClasificacion IS NULL")
|
|
SumaUtilidad = ObjContratos.DtResultados.SUM("AvanceUtilidad", "CveClasificacion IS NULL")
|
|
DtAvance = ObjContratos.DtResultados
|
|
Else
|
|
Alert("Ocurrió un Error al obtener el Reporte de Avances. Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
'ObjContratos.Dispose()
|
|
GvDatosAvance.DataBind()
|
|
|
|
If (GvDatosAvance.Rows.Count > 0) Then
|
|
GvDatosAvance.UseAccessibleHeader = True
|
|
GvDatosAvance.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGV();")
|
|
End If
|
|
|
|
|
|
If ObjContratos.GetReporteContratosAvancesDetalleControl(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
|
|
GvDatosAvanceControl.DataSource = ObjContratos.DtResultados
|
|
Else
|
|
Alert("Ocurrió un Error al obtener el Reporte de Avances de control. Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
|
|
GvDatosAvanceControl.DataBind()
|
|
|
|
ObjContratos.Dispose()
|
|
UpGral.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvDatosAvance_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosAvance.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DBCampo("CveClasificacion").ToString.ToEntero = 0 Then
|
|
e.Row.CssClass = "Totales white"
|
|
ElseIf e.Row.DBCampo("CvePS").ToString.ToEntero = 0 Then
|
|
e.Row.CssClass = "SubTotales"
|
|
End If
|
|
|
|
Dim Liga1 = $"{e.Row.DBCampo("CveClasificacion").ToEntero}|{e.Row.DBCampo("Clasificacion")}|{e.Row.DBCampo("CvePS").ToEntero}|{e.Row.DBCampo("CodigoPS")}|1"
|
|
e.Row.FCLinkButton("LBAvanceCantidad").CommandArgument = Liga1
|
|
e.Row.FCLinkButton("LBAvanceImporte").CommandArgument = Liga1
|
|
|
|
Dim Liga2 = $"{e.Row.DBCampo("CveClasificacion").ToEntero}|{e.Row.DBCampo("Clasificacion")}|{e.Row.DBCampo("CvePS").ToEntero}|{e.Row.DBCampo("CodigoPS")}|2"
|
|
e.Row.FCLinkButton("LBAvanceXFacturarCantidad").CommandArgument = Liga2
|
|
e.Row.FCLinkButton("LBAvanceXFacturarImporte").CommandArgument = Liga2
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub GvDatosAvanceControl_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosAvanceControl.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DBCampo("CveClasificacion").ToString.ToEntero = 0 Then
|
|
e.Row.CssClass = "Totales white"
|
|
ElseIf e.Row.DBCampo("CveContratoDetalle").ToString.Length = 0 And e.Row.DBCampo("CveClasificacion").ToString.ToEntero <> 0 Then
|
|
e.Row.CssClass = "SubTotales"
|
|
End If
|
|
|
|
'Dim Liga1 = $"{e.Row.DBCampo("CveClasificacion").ToEntero}|{e.Row.DBCampo("Clasificacion")}|{e.Row.DBCampo("CvePS").ToEntero}|{e.Row.DBCampo("CodigoPS")}|1"
|
|
'e.Row.FCLinkButton("LBAvanceCantidad").CommandArgument = Liga1
|
|
'e.Row.FCLinkButton("LBAvanceImporte").CommandArgument = Liga1
|
|
|
|
'Dim Liga2 = $"{e.Row.DBCampo("CveClasificacion").ToEntero}|{e.Row.DBCampo("Clasificacion")}|{e.Row.DBCampo("CvePS").ToEntero}|{e.Row.DBCampo("CodigoPS")}|2"
|
|
'e.Row.FCLinkButton("LBAvanceXFacturarCantidad").CommandArgument = Liga2
|
|
'e.Row.FCLinkButton("LBAvanceXFacturarImporte").CommandArgument = Liga2
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub MuestaModalVentasAvance(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = CType(((CType(sender, LinkButton)).NamingContainer), GridViewRow)
|
|
|
|
GvDatosVentasAvance.Visible = True
|
|
GvDatosVentasAvanceInterno.Visible = False
|
|
GvDatosVentasAvanceInternoRH.Visible = False
|
|
GvDatosVentasAvanceInternoMaquinaria.Visible = False
|
|
|
|
'Dim Btn = CType(sender, LinkButton)
|
|
'Dim Parametros = Btn.CommandArgument.Split("|"c)
|
|
|
|
|
|
Dim CveClasificacion As Integer = GvRow.DataKey("CveClasificacion").ToEntero
|
|
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
|
|
Dim CodigoPS As String = GvRow.DataKey("CodigoPS")
|
|
Dim Clasificacion As String = GvRow.DataKey("Clasificacion")
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
If ObjContratos.GetVentasAvanceObra(CveContrato, CveClasificacion, CvePS, 1, -1, UsuarioActual.CveEmpresa) Then
|
|
GvDatosVentasAvance.DataSource = ObjContratos.DtResultados
|
|
RegistraScript("$('#ModalVentasAvance').modal('show');RecargaAvances = true;")
|
|
Else
|
|
Alert("Ocurrió un error al obtener el Listado de Ventas de Avance. Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
GvDatosVentasAvance.DataBind()
|
|
|
|
LbTituloModalVentasAvance.Text = "Ventas de Avance"
|
|
|
|
LbClasificacionVentasAvance.Text = Clasificacion
|
|
LbPSVentasAvance.Text = CodigoPS
|
|
|
|
UpVentasAvance.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub MuestaModalVentasAvanceInterno(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = CType(((CType(sender, LinkButton)).NamingContainer), GridViewRow)
|
|
|
|
Dim CveClasificacion As Integer = GvRow.DataKey("CveClasificacion").ToEntero
|
|
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
|
|
Dim CodigoPS As String = GvRow.DataKey("CodigoPS")
|
|
Dim Clasificacion As String = GvRow.DataKey("Clasificacion")
|
|
Dim CveRubro As Integer = GvRow.DataKey("CveRubro").ToEntero
|
|
|
|
GvDatosVentasAvance.Visible = False
|
|
|
|
If CveRubro = 3 Then
|
|
GvDatosVentasAvanceInterno.Visible = False
|
|
GvDatosVentasAvanceInternoRH.Visible = True
|
|
GvDatosVentasAvanceInternoMaquinaria.Visible = False
|
|
ElseIf CveRubro = 4 Then
|
|
GvDatosVentasAvanceInterno.Visible = False
|
|
GvDatosVentasAvanceInternoRH.Visible = False
|
|
GvDatosVentasAvanceInternoMaquinaria.Visible = True
|
|
Else
|
|
GvDatosVentasAvanceInterno.Visible = True
|
|
GvDatosVentasAvanceInternoRH.Visible = False
|
|
GvDatosVentasAvanceInternoMaquinaria.Visible = False
|
|
End If
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
If ObjContratos.GetVentasAvanceObra(CveContrato, CveClasificacion, CvePS, 2, CveRubro, UsuarioActual.CveEmpresa) Then
|
|
|
|
If CveRubro = 3 Then
|
|
GvDatosVentasAvanceInternoRH.DataSource = ObjContratos.DtResultados
|
|
ElseIf CveRubro = 4 Then
|
|
GvDatosVentasAvanceInternoMaquinaria.DataSource = ObjContratos.DtResultados
|
|
Else
|
|
GvDatosVentasAvanceInterno.DataSource = ObjContratos.DtResultados
|
|
End If
|
|
|
|
RegistraScript("$('#ModalVentasAvance').modal('show');RecargaAvances = true;")
|
|
Else
|
|
Alert("Ocurrió un error al obtener el Listado de Ventas de Avance. Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
|
|
If CveRubro = 3 Then
|
|
GvDatosVentasAvanceInternoRH.DataBind()
|
|
ElseIf CveRubro = 4 Then
|
|
GvDatosVentasAvanceInternoMaquinaria.DataBind()
|
|
Else
|
|
GvDatosVentasAvanceInterno.DataBind()
|
|
End If
|
|
|
|
|
|
LbTituloModalVentasAvance.Text = "Compras de Avance"
|
|
|
|
LbClasificacionVentasAvance.Text = Clasificacion
|
|
LbPSVentasAvance.Text = CodigoPS
|
|
|
|
UpVentasAvance.Update()
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " TAB: REPORTE AVANCES POR DOCUMENTO "
|
|
Protected Sub RBLTipoDocto_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaDatosAvancePorDocumento()
|
|
End Sub
|
|
Private Sub CargaDatosAvancePorDocumento()
|
|
If CveContrato <= 0 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
If ObjContratos.GetContratosAvancePorDocumento(CveContrato, RBLTipoDocto.SelectedValue, UsuarioActual.CveEmpresa) Then
|
|
GVAvanceXDocumento.DataSource = ObjContratos.DtResultados
|
|
DtAvanceDocumento = ObjContratos.DtResultados
|
|
If DtAvanceDocumento.Rows.Count > 0 Then
|
|
'LBImprimir.Visible = True
|
|
End If
|
|
' LBImprimirInformacionG.Visible = True
|
|
Else
|
|
Alert("Ocurrió un error al obtener el Reporte de Avances por Documento. Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
GVAvanceXDocumento.DataBind()
|
|
|
|
If (GVAvanceXDocumento.Rows.Count > 0) Then
|
|
GVAvanceXDocumento.UseAccessibleHeader = True
|
|
GVAvanceXDocumento.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGVPorDocumento();")
|
|
End If
|
|
|
|
UpGral.Update()
|
|
End Sub
|
|
|
|
Private Sub GVAvanceXDocumento_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVAvanceXDocumento.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If Not e.Row.DBCampo("CveVenta").ToEntero > 0 Then
|
|
e.Row.Cells(2).Text = "TOTAL: "
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Right
|
|
e.Row.Cells(0).Text = e.Row.DBCampo("Cantidad").FormatoNumero(0)
|
|
e.Row.CssClass = "Totales"
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " TAB: CONTRATO GASTOS "
|
|
Private Sub MandaCorreo(Para As String, Asunto As String, Body As String)
|
|
Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para)
|
|
Dim Mail As New ClsSisMail()
|
|
Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body)
|
|
End Sub
|
|
Protected Sub EnvioCorreo(Dr As DataRow)
|
|
Dim Body As String = GeneraCorreoContratoGasto(Dr)
|
|
Dim Asunto As String = $"Se agrego un gasto en el {LtlTitulo.Text}"
|
|
Dim Correo As String = ""
|
|
If UsuarioActual.CveEmpresa = 72 Then
|
|
Correo = "anamartinez@compuproveedores.com;benjamincarrillo@compuproveedores.com"
|
|
Else
|
|
Correo = "signotificaciones@adssistemas.mx"
|
|
End If
|
|
Try
|
|
Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Correo, Asunto, Body))
|
|
Hilo.Start()
|
|
Catch ex As Exception
|
|
OnError("Ocurrió error al mandar MAIL", ex)
|
|
End Try
|
|
End Sub
|
|
Public Function GeneraCorreoContratoGasto(Dr As DataRow) As String
|
|
Dim strBody As New StringBuilder
|
|
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
|
|
strBody.Append("<head> ")
|
|
strBody.Append(" <style type=""text/css""> ")
|
|
strBody.Append(" body ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" margin:0px; ")
|
|
strBody.Append(" padding:0px 0px 0px 0px; ")
|
|
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
|
|
strBody.Append(" font-size: 10px; ")
|
|
strBody.Append(" background-color:#F0F0F0; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" a.Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" font-size:11px; ")
|
|
strBody.Append(" background-color:#F7F6F3; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Texto ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:left; vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .TextoAlterno ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:left; ")
|
|
strBody.Append(" vertical-align:middle; height:20px;")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .BarraIdentidad ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" color:#FFFFFF; ")
|
|
strBody.Append(" background:#F0F0F0; ")
|
|
strBody.Append(" font-weight:bold; ")
|
|
strBody.Append(" font-size:19px; ")
|
|
strBody.Append(" font-style:oblique; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Titulos ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: Gray;")
|
|
strBody.Append(" color:White; ")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Contenido2 ")
|
|
strBody.Append(" { ")
|
|
strBody.Append(" background-color: White;")
|
|
strBody.Append(" font-family:Verdana; font-size:12px; text-align:left; ")
|
|
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
|
|
strBody.Append(" text-decoration:none; ")
|
|
strBody.Append(" } ")
|
|
strBody.Append(" .Verde {color: #00CC00;} ")
|
|
strBody.Append(" .Negro {color: #000000;} ")
|
|
strBody.Append(" .Rojo {color: #FF0000;} ")
|
|
strBody.Append(" </style> ")
|
|
strBody.Append("</head> ")
|
|
strBody.Append("<body> ")
|
|
strBody.Append("<div class='Contenido2' style='display: table!important'>")
|
|
strBody.AppendFormat(" <div id=""C_divOP"" style=""width: 800px""> <fieldset> <legend><b>Datos {0}</b></legend> ", "del contrato")
|
|
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%""> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td style=""width: 90px""> No. Contrato:</td><td colspan=""3""> <a href=" + "http://sig.adssistemas.mx/" + "Contratos/Contrato.aspx?CveContrato=" + CveContrato.ToString + "> <b>" + Dr("NumeroContrato").ToString + "</b><a/></td>")
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Descripcion:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", Dr("DescripcionContrato").ToString)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Cliente:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", Dr("NombreComercial").ToString)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Monto Adjudicado:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", Dr("Monto").ToString.FormatoNumero)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>SubProyecto:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", Dr("SubProyectoContrato"))
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Fecha Inicio:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", Dr("FechaInicial"))
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Fecha Final:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", Dr("FechaFinal"))
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Avance:</td><td><b>{0}%</b></td><td> </td><td><b> </b></td> ", Dr("ContratoAvance").ToString.FormatoNumero)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
strBody.AppendFormat(" <div id=""C_divOC"" style=""width: 300px""> <fieldset> <legend><b>Datos {0}</b></legend> ", "del gasto")
|
|
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""100%""> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Descripción:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", TxtDescripcion.Text)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Importe:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", TxtImporteC.Text.FormatoNumero)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" <tr style=""height: 22px""> ")
|
|
strBody.AppendFormat(" <td>Fecha:</td><td><b>{0}</b></td><td> </td><td><b> </b></td> ", TxtFecha.Text.ToDate.ToShortDateString)
|
|
strBody.Append(" </tr> ")
|
|
strBody.Append(" </table> ")
|
|
strBody.Append(" </fieldset> ")
|
|
strBody.Append(" </div> ")
|
|
strBody.Append(" <br> ")
|
|
strBody.AppendFormat("<a href={0}Contratos/Contrato.aspx?CveContrato={1}> Ir al contrato <a/>", "http://sig.adssistemas.mx/", CveContrato)
|
|
strBody.Append("</div>")
|
|
strBody.Append("</body></html>")
|
|
Return strBody.ToString
|
|
End Function
|
|
|
|
Protected Sub LBAgregar_Click(sender As Object, e As EventArgs) Handles LBAgregar.Click
|
|
Dim ObjContrato As New ClsContratos
|
|
If ObjContrato.AddContratoGasto(CveContrato, TxtDescripcion.Text, TxtImporteC.Text.ToDecimal, TxtFecha.Text.ToDate, UsuarioActual.CveUsuario) Then
|
|
MensajeAlert = New StringBuilder
|
|
MensajeAlert.AppendFormat("El Gasto del contrato se guardó correctamente.")
|
|
MensajeAlert.AppendFormat("<br><ul><li><a class=""Texto"" href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir Gasto</a></li></ul><br/>", Encripta(String.Format("OP=CONG&CVECONTRATO={0}&CVECONTRATOGASTO={1}", CveContrato, ObjContrato.CveContratoGasto)))
|
|
If ObjContrato.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
If ObjContrato.DtResultados.Rows.Count > 0 Then
|
|
EnvioCorreo(ObjContrato.DtResultados.Rows(0))
|
|
End If
|
|
End If
|
|
TxtDescripcion.Text = ""
|
|
TxtImporteC.Text = ""
|
|
TxtFecha.Text = ""
|
|
Alert(MensajeAlert.ToString, TipoMensaje.MsgInformacion)
|
|
CargaGVGastos()
|
|
RegistraScript("$('#ModalAgregarGastos').modal('hide');")
|
|
MensajeAlert = Nothing
|
|
End If
|
|
ObjContrato.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaGVGastos()
|
|
Dim objContrato As New ClsContratos
|
|
If objContrato.GetContratoGastos(CveContrato) Then
|
|
DtGastos = objContrato.DtResultados
|
|
GvContratosGastos.DataSource = DtGastos
|
|
SumaGasto = objContrato.DtResultados.SUM("Importe", "CveContratoGasto IS NULL")
|
|
Else
|
|
GvContratosGastos.DataSource = Nothing
|
|
End If
|
|
objContrato.Dispose()
|
|
GvContratosGastos.DataBind()
|
|
|
|
If GvContratosGastos.Rows.Count > 0 Then
|
|
GvContratosGastos.HeaderRow.CssClass = "SinColor"
|
|
'LBImprimirGastos.Visible = True
|
|
End If
|
|
|
|
UpContratoGasto.Update()
|
|
End Sub
|
|
|
|
Protected Sub GvContratoGastos_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvContratosGastos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DBCampo("CveContrato").ToString.ToEntero = 0 Or e.Row.DBCampo("CveVenta").ToString.ToEntero > 0 Then
|
|
If e.Row.DBCampo("CveContrato").ToString.ToEntero = 0 Then e.Row.CssClass = "SubTotales" : e.Row.Cells(0).Text = e.Row.DBCampo("Cantidad").FormatoNumero(0)
|
|
e.Row.FCLinkButton("imgE").Visible = False
|
|
e.Row.FCLinkButton("imgD").Visible = False
|
|
e.Row.FCLinkButton("LnkDescargar").Visible = False
|
|
Else
|
|
Dim lb As LinkButton = CType(e.Row.FindControl("LnkDescargar"), LinkButton)
|
|
ScriptManager.GetCurrent(Me).RegisterAsyncPostBackControl(lb)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvContratoGastos_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles GvContratosGastos.RowDeleting
|
|
Dim objContrato As New ClsContratos
|
|
If objContrato.RemoveContratoGasto(GvContratosGastos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvContratosGastos.EditIndex = -1
|
|
Alert("Se eliminó correctamente el gasto del contrato")
|
|
CargaGVGastos()
|
|
End If
|
|
objContrato.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub GvContratosGastos_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles GvContratosGastos.RowEditing
|
|
GvContratosGastos.EditIndex = e.NewEditIndex
|
|
CargaGVGastos()
|
|
End Sub
|
|
|
|
Protected Sub GvContratosGastos_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GvContratosGastos.RowUpdating
|
|
Dim objContrato As New ClsContratos
|
|
|
|
Dim CveContratoGasto As Integer = GvContratosGastos.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
Dim Observaciones As String = GvContratosGastos.Rows(e.RowIndex).FCTextBox("TxtDescripcion").Text.Trim
|
|
Dim Importe As Decimal = GvContratosGastos.Rows(e.RowIndex).FCTextBox("TxtImporteC").Text.Trim.ToDecimal
|
|
Dim Fecha As Date = GvContratosGastos.Rows(e.RowIndex).FCTextBox("TxtFecha").Text.Trim.ToDate
|
|
|
|
If objContrato.UpdateContratoGasto(CveContratoGasto, Observaciones, Importe, Fecha, UsuarioActual.CveUsuario) Then
|
|
GvContratosGastos.EditIndex = -1
|
|
CargaGVGastos()
|
|
End If
|
|
objContrato.Dispose()
|
|
End Sub
|
|
Protected Sub GvContratosGastos_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvContratosGastos.RowCancelingEdit
|
|
GvContratosGastos.EditIndex = -1
|
|
CargaGVGastos()
|
|
End Sub
|
|
|
|
Protected Sub LnkDescargar_Click1(sender As Object, e As EventArgs)
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
RegistraScript($"window.location.href = '/Compras/PopUpVerFactura.aspx?P={Encripta(String.Format("OP=CONG&CVECONTRATO={0}&CVECONTRATOGASTO={1}", CveContrato, gvRow.DataKey("CveContratoGasto").ToString))}'")
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "TAB: PEDIDOS / DEVOLUCIONES"
|
|
Private Sub CargaDatosPedDev()
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.GetRepDevolucionesPedidos(Me.CveContrato, MinFecha, MaxFecha, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
DsDatosPedDev = ObjContratos.DsResultados
|
|
|
|
GvPedidos.DataSource = DsDatosPedDev.Tables(0)
|
|
GvDevs.DataSource = DsDatosPedDev.Tables(1)
|
|
End If
|
|
ObjContratos.Dispose()
|
|
|
|
GvPedidos.DataBind()
|
|
GvDevs.DataBind()
|
|
|
|
UpPedidosDevoluciones.Update()
|
|
End Sub
|
|
'Protected Sub ImgExcelPedDev_Click(sender As Object, e As EventArgs) Handles LbImprimirPedDevExcel.Click
|
|
' GenerarPDFPedDev("Excel")
|
|
'End Sub
|
|
'Protected Sub ImgImprimirPedDev_Click(sender As Object, e As EventArgs) Handles LbImprimirPedDev.Click
|
|
' GenerarPDFPedDev()
|
|
'End Sub
|
|
Private Sub GenerarPDFPedDev(Optional Formato As String = "PDF")
|
|
If DsDatosPedDev Is Nothing Then
|
|
Alert("No se pudieron consultar los pedidos y devoluciones", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("FechaInicio", "-1"))
|
|
params.Add(New ReportParameter("FechaFin", "-1"))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("Contrato", Me.Titulo))
|
|
params.Add(New ReportParameter("Estatus", ""))
|
|
params.Add(New ReportParameter("Tipo", "-1"))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
|
|
Dim lrds As New List(Of ReportDataSource)
|
|
lrds.Add(New ReportDataSource("DataSet1", DsDatosPedDev.Tables(0)))
|
|
lrds.Add(New ReportDataSource("DataSet2", DsDatosPedDev.Tables(1)))
|
|
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepPedDevolucionesXContrato.rdlc", lrds, params, "ReportePedidosDevoluciones", Formato)
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvPedidos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
'CABECERA
|
|
If e.Row.DBCampo("CodigoPS") = "" Then
|
|
e.Row.CssClass = "SubTotales2"
|
|
e.Row.Attributes.Add("style", "background-color:#B9B5B4 !important;")
|
|
e.Row.Cells(0).Text = ""
|
|
e.Row.Cells(4).Text = ""
|
|
e.Row.Cells(5).Text = ""
|
|
|
|
Dim Texto = $"Pedido: <b><a href='/Ventas/Ventas.aspx?CveVenta={e.Row.DBCampo("CveVenta")}' target='_blank'>{e.Row.DBCampo("SerieFolio")}</a></b> | "
|
|
Texto += If(e.Row.DBCampo("CveMovimiento").ToString = "", " SIN MOVIMIENTO DE ALMACÉN", $"Folio Almacén: <b><a href ='/Inventarios/EntradasSalidas.aspx?CveMovimiento={e.Row.DBCampo("CveMovimiento")}' target='_blank'>{e.Row.DBCampo("Folio")}</a></b>")
|
|
|
|
e.Row.Cells(0).ColumnSpan = 2
|
|
e.Row.Cells(1).Visible = False
|
|
e.Row.Cells(0).Text = Texto
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
Else
|
|
|
|
If e.Row.DBCampo("CveMovimiento").ToString = "" Then
|
|
e.Row.Cells(1).Text = "SIN MOVIMIENTO DE ALMACÉN"
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
Protected Sub GvDevs_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
'CABECERA
|
|
If e.Row.DBCampo("CodigoPS") = "" Then
|
|
e.Row.CssClass = "SubTotales2"
|
|
e.Row.Attributes.Add("style", "background-color:#B9B5B4 !important;")
|
|
e.Row.Cells(0).Text = ""
|
|
e.Row.Cells(4).Text = ""
|
|
e.Row.Cells(5).Text = ""
|
|
|
|
Dim Texto = $"Devolución: <b><a href='/Ventas/Ventas.aspx?CveVenta={e.Row.DBCampo("CveVenta")}' target='_blank'>{e.Row.DBCampo("SerieFolio")}</a></b> | "
|
|
Texto += If(e.Row.DBCampo("CveMovimiento").ToString = "", " SIN MOVIMIENTO DE ALMACÉN", $"Folio Almacén: <b><a href ='/Inventarios/EntradasSalidas.aspx?CveMovimiento={e.Row.DBCampo("CveMovimiento")}' target='_blank'>{e.Row.DBCampo("Folio")}</a></b>")
|
|
|
|
e.Row.Cells(0).ColumnSpan = 2
|
|
e.Row.Cells(1).Visible = False
|
|
e.Row.Cells(0).Text = Texto
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
Else
|
|
|
|
If e.Row.DBCampo("CveMovimiento").ToString = "" Then
|
|
e.Row.Cells(1).Text = "SIN MOVIMIENTO DE ALMACÉN"
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " TAB: ALMACEN - ACTIVOS FIJBtnAlmacenEsInterno_ClickOS "
|
|
Private Sub CargaInventarios()
|
|
|
|
Dim ObjInventarios As New ClsInventarios
|
|
'cargar también los movimentos detalle
|
|
If ObjInventarios.GetMovimientosDetalleContrato(CveContrato, UsuarioActual.CveEmpresa, DdlEsinternoExternoFiltro.SelectedValue.ToEntero) Then
|
|
DtMovimientos = ObjInventarios.DtResultados
|
|
Else
|
|
Alert("Ocurrió un error al cargar la información de los Activos Fijos. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjInventarios.Dispose()
|
|
|
|
If DtMovimientos.Rows.Count > 0 Then
|
|
CargaGVDatosInventarios()
|
|
CargaDatosPedDev()
|
|
'BtnDevolucionAlmacen.Visible = True
|
|
CveMovimientoDevolucion = -1
|
|
If CveMovimientoDevolucion > 0 Then
|
|
HLSurtirAF.Visible = False
|
|
BtnDevolucionAlmacen.Visible = False
|
|
End If
|
|
Else
|
|
DivSinRegistrosAlmacen.Visible = True
|
|
GvDatosAlmacen.DataSource = Nothing
|
|
GvDatosAlmacen.DataBind()
|
|
|
|
End If
|
|
|
|
'CARGA MODALIDAD ALMACEN
|
|
If TipoContrato.Contiene(8, 17) Then ' cuando es consignacion
|
|
HLSurtirAF.Visible = False
|
|
HLSurtirMercancia.NavigateUrl = $"/Ventas/Ventas.aspx?CveContrato={CveContrato}&Tipo=1"
|
|
Else
|
|
HLSurtirMercancia.Visible = False
|
|
HLSurtirAF.NavigateUrl = $"/Ventas/Ventas.aspx?CveContrato={CveContrato}&Tipo=0"
|
|
End If
|
|
|
|
UpAlmacen.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub RBLAlmacen_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CargaGVDatosInventarios()
|
|
End Sub
|
|
Private Sub CargaGVDatosInventarios()
|
|
Select Case RBLAlmacen.SelectedValue
|
|
Case "-1"
|
|
GvDatosAlmacen.DataSource = DtMovimientos
|
|
Actualiza(DtMovimientos)
|
|
Case "Vig"
|
|
GvDatosAlmacen.DataSource = DtMovimientos.FiltraParametros($"(CodigoPS IS NULL AND Cantidad - CantidadDevolucion > 0) OR (CodigoPS IS NOT NULL AND SerieFolioDevolucion IS NULL)")
|
|
Actualiza(DtMovimientos.FiltraParametros($"(CodigoPS IS NULL AND Cantidad - CantidadDevolucion > 0) OR (CodigoPS IS NOT NULL AND SerieFolioDevolucion IS NULL)"))
|
|
Case "Dev"
|
|
GvDatosAlmacen.DataSource = DtMovimientos.FiltraParametros($"SerieFolioDevolucion IS NOT NULL")
|
|
Actualiza(DtMovimientos.FiltraParametros($"SerieFolioDevolucion IS NOT NULL"))
|
|
Case Else
|
|
End Select
|
|
GvDatosAlmacen.DataBind()
|
|
End Sub
|
|
|
|
Public Sub Actualiza(DT As DataTable)
|
|
|
|
LblAFInternos.Text = DT.SUM("Cantidad", "CveMovimientoDetalle > 0 AND EsInterno = 1 ").ToString
|
|
LblAFExternos.Text = DT.SUM("Cantidad", "CveMovimientoDetalle > 0 AND (EsInterno = 0 OR EsInterno IS NULL)").ToString
|
|
|
|
'Dim ValorAF = DT.SUM("ValorImporte", "CveMovimientoDetalle > 0 AND TipoDocto = 'Ped'") - DT.SUM("ValorImporte", "TipoDocto = 'DPe'")
|
|
|
|
LBLAFValorActivo.Text = DT.SUM("ValorImporte", "CveMovimientoDetalle > 0").ToString("###,###,###.00")
|
|
|
|
Dim Total = DT.SUM("Cantidad", "CveMovimientoDetalle > 0 AND TipoDocto = 'Ped'") - DT.SUM("Cantidad", "TipoDocto = 'DPe'")
|
|
|
|
LBLAFTotal.Text = DT.SUM("Cantidad", "CveMovimientoDetalle > 0").ToString()
|
|
UPAFResumen.Update()
|
|
|
|
End Sub
|
|
Protected Sub GvDatosAlmacen_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosAlmacen.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
'CABECERA
|
|
If e.Row.DBCampo("CodigoPS") = "" Then
|
|
e.Row.CssClass = "SubTotales2"
|
|
e.Row.Attributes.Add("style", "background-color:#B9B5B4 !important;")
|
|
e.Row.Cells(0).Text = ""
|
|
e.Row.Cells(4).Text = ""
|
|
e.Row.Cells(5).Text = ""
|
|
|
|
Dim Texto = $"{If(e.Row.DBCampo("TipoDocto") = "Ped", "Pedido", "Devolución") }: <b><a href='/Ventas/Ventas.aspx?CveVenta={e.Row.DBCampo("CveVenta")}' target='_blank'>{e.Row.DBCampo("SerieFolio")}</a></b> | "
|
|
Texto += If(e.Row.DBCampo("CveMovimiento").ToString = "", " SIN MOVIMIENTO DE ALMACÉN", $"Folio Almacén: <b><a href ='/Inventarios/EntradasSalidas.aspx?CveMovimiento={e.Row.DBCampo("CveMovimiento")}' target='_blank'>{e.Row.DBCampo("Folio")}</a></b>")
|
|
|
|
|
|
e.Row.Cells(0).ColumnSpan = 2
|
|
e.Row.Cells(1).Visible = False
|
|
'e.Row.Cells(2).Visible = False
|
|
e.Row.Cells(0).Text = Texto
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
|
|
If e.Row.DBCampo("TipoDocto") = "Ped" Then
|
|
If e.Row.DBCampo("Cantidad").ToDecimal - e.Row.DBCampo("CantidadDevolucion").ToDecimal > 0 Then
|
|
e.Row.Cells(9).Text = If(e.Row.DBCampo("CveMovimiento").ToString = "", "", $" <b><a href='/Ventas/Ventas.aspx?DevPed={e.Row.DBCampo("CveVenta")}&MovInv={e.Row.DBCampo("CveMovimiento")}' target='_blank'>Solicitud de devolución de pedido</a></b>")
|
|
Else
|
|
e.Row.Cells(9).Text = ""
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
If e.Row.DBCampo("CveMovimiento").ToString = "" Then
|
|
e.Row.Cells(1).Text = "SIN MOVIMIENTO DE ALMACÉN"
|
|
End If
|
|
If e.Row.DBCampo("TipoDocto") = "Ped" Then
|
|
If e.Row.DBCampo("Cantidad").ToDecimal - e.Row.DBCampo("CantidadDevolucion").ToDecimal > 0 Then
|
|
e.Row.Cells(9).Text = If(e.Row.DBCampo("CveMovimiento").ToString = "", "", $" <b><a href='/Ventas/Ventas.aspx?DevPed={e.Row.DBCampo("CveVenta")}&MovInv={e.Row.DBCampo("CveMovimiento")}&CveMovimientoDetalle={e.Row.DBCampo("CveMovimientoDetalle")}' target='_blank'>Solicitud de devolución de pedido</a></b>")
|
|
End If
|
|
End If
|
|
|
|
|
|
e.Row.FCCheckBox("ChkEsInterno").Visible = True
|
|
|
|
End If
|
|
|
|
'If e.Row.DBCampo("SerieLote").ToString = "-1" Then
|
|
' e.Row.Cells(7).Text = ""
|
|
'End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BtnFiltraInternosExternos_Click(sender As Object, e As EventArgs) Handles BtnFiltraInternosExternos.Click
|
|
CargaInventarios()
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnAlmacenEsInterno_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ObjInv As New ClsInventarios()
|
|
|
|
For Each GRow As GridViewRow In GvDatosAlmacen.Rows
|
|
Dim CveMovimientoDetalle As Integer = GRow.DataKey("CveMovimientoDetalle").ToEntero
|
|
Dim ChkEsInterno = GRow.FCCheckBox("ChkEsInterno")
|
|
|
|
If CveMovimientoDetalle > 0 And ChkEsInterno.Checked And DdlEsInterno.SelectedValue.ToEntero > 0 Then
|
|
Dim EsInterno As Boolean
|
|
|
|
Select Case DdlEsInterno.SelectedValue.ToEntero
|
|
Case 1
|
|
EsInterno = True
|
|
Case 2
|
|
EsInterno = False
|
|
End Select
|
|
|
|
If Not (ObjInv.UpdateMovimientoDetalleEsInterno(UsuarioActual.CveEmpresa, CveMovimientoDetalle, EsInterno)) Then
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
|
|
ObjInv.Dispose()
|
|
|
|
'LnkAjusteAF.Visible = True
|
|
DivHajusteAF.Visible = False
|
|
GvDatosAlmacen.Columns(6).Visible = False
|
|
|
|
CargaInventarios()
|
|
UPHajusteAF.Update()
|
|
' UpHajusteAcciones.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkAjusteAF_Click(sender As Object, e As EventArgs)
|
|
|
|
' LnkAjusteAF.Visible = False
|
|
DivHajusteAF.Visible = True
|
|
GvDatosAlmacen.Columns(6).Visible = True
|
|
|
|
CargaInventarios()
|
|
|
|
UPHajusteAF.Update()
|
|
' UpHajusteAcciones.Update()
|
|
UpAlmacen.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
#Region " DEVOLUCION ALMACEN "
|
|
Protected Sub BtnDevolucionAlmacen_Click(sender As Object, e As EventArgs)
|
|
Dim ObjVentas As New ClsVentas
|
|
ObjVentas.IniciaTransacSQL()
|
|
Dim TieneError = False
|
|
|
|
For Each Dr As DataRow In DtMovimientos.FiltraParametros("CveVenta IS NOT NULL AND CveMovimiento IS NOT NULL AND EsDevolucionVenta = 0", "", {"CveVenta"}).Rows
|
|
If Not ObjVentas.UpdateVentasDevolucionAlmacen(1, Dr("CveVenta").ToString.ToEntero) Then
|
|
TieneError = True
|
|
End If
|
|
Next
|
|
|
|
|
|
If Not TieneError Then
|
|
ObjVentas.Commit()
|
|
Alert("La solicitud de devolución se guardo correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
ObjVentas.RollBack()
|
|
Alert("Ocurrió un error al guardar la solicitud de devolución. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
'Public Sub CargaDatosEncabezado()
|
|
|
|
' TablaUtilidad.Visible = True
|
|
' LblUtilidad.Text = $"$ {(SumaAvance - SumaGasto).ToString.FormatoNumero()}"
|
|
|
|
' If (SumaAvance - SumaGasto) < 0 Then LblUtilidad.ForeColor = Drawing.Color.Red
|
|
' LblFacturado.Text = SumaAvance.FormatoNumero
|
|
' LblPorFacturar.Text = (LblImporte.Text.ToDouble - SumaAvance).FormatoNumero
|
|
|
|
'End Sub
|
|
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region "TAB SISTEMA"
|
|
Protected Sub ChkPermitirAvance_CheckedChanged(sender As Object, e As EventArgs)
|
|
Dim ObjContrato As New ClsContratos
|
|
Dim Row As GridViewRow = DirectCast(DirectCast(sender, CheckBox).NamingContainer, GridViewRow)
|
|
ObjContrato.PermitirAvance(Gv.DataKeys(Row.RowIndex).Value.ToString.ToEntero, DirectCast(sender, CheckBox).Checked)
|
|
ObjContrato.Dispose()
|
|
Alert("Se ha permitido avance a la sección", TipoMensaje.MsgInformacion)
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
Protected Sub ChkPermitirEstimacion_CheckedChanged(sender As Object, e As EventArgs)
|
|
Dim ObjContrato As New ClsContratos
|
|
Dim Row As GridViewRow = DirectCast(DirectCast(sender, CheckBox).NamingContainer, GridViewRow)
|
|
ObjContrato.PermitirEstimacion(Gv.DataKeys(Row.RowIndex).Value.ToString.ToEntero, DirectCast(sender, CheckBox).Checked)
|
|
ObjContrato.Dispose()
|
|
Alert("Se ha permitido estimar en la sección", TipoMensaje.MsgInformacion)
|
|
CargaDatos()
|
|
End Sub
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region " BITACORA "
|
|
Private Sub guardarBitacora(Descripcion As String)
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
If ObjEventoBitacora.AddEventoBitacora(Descripcion, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato) Then
|
|
cargarBitacora()
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
End Sub
|
|
|
|
Private Sub cargarBitacora()
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
If ObjEventoBitacora.GetEventos(-1, -1, -1, "-1", "-1", -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato) Then
|
|
GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2")
|
|
GvEB.DataBind()
|
|
HlEvento.NavigateUrl = "/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveContrato=" & ViewState("CveContrato").ToString & "&TB_iframe=true&height=370&width=600;"
|
|
' UpBitacora.Update()
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
End Sub
|
|
Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(200)
|
|
e.Row.Cells(1).Width = Unit.Pixel(200)
|
|
e.Row.Cells(2).Width = Unit.Pixel(100)
|
|
'e.Row.Cells(3).Width = Unit.Pixel(500) 'VARIABLE PARA QUE SEA LO MAS GRANDE POSIBLE
|
|
e.Row.Cells(4).Width = Unit.Pixel(100)
|
|
e.Row.Cells(5).Width = Unit.Pixel(5)
|
|
End If
|
|
Dim asd As String = e.Row.DBCampo("Archivo").ToString
|
|
|
|
If e.Row.DBCampo("Archivo").ToString <> "" And e.Row.DBCampo("Archivo").ToString <> "-1" Then
|
|
e.Row.FCLinkButton("LinkArchivo").Visible = True
|
|
e.Row.FCLinkButton("LinkArchivo").CommandArgument = String.Format("OI\{0}", e.Row.DBCampo("Archivo").ToString)
|
|
ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FCLinkButton("LinkArchivo")) 'Registro un evento Postbacktrigger, que recargue toda la pagina para que funcione
|
|
End If
|
|
|
|
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
|
|
|
|
If e.Row.DataKey("CveUsuarioIng").ToEntero = UsuarioActual.CveUsuario Then
|
|
e.Row.FCLinkButton("LinkEliminarBitacora").Visible = True
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
|
|
Dim FileExtension As String = "-1"
|
|
Dim Filesgral As List(Of Archivo) = txtFileBit.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
Filename = fileItem.filename
|
|
Next
|
|
|
|
If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, String.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveContrato:=CveContrato) Then
|
|
If Filename <> "" Then
|
|
Filename.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("Empresas\{0}\OI", UsuarioActual.CveEmpresa))
|
|
End If
|
|
|
|
cargarBitacora()
|
|
TxtEventoDescripcion.Text = ""
|
|
txtFileBit.getfiles().Archivos.Clear()
|
|
|
|
txtFileBit.Text = ""
|
|
Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion)
|
|
RegistraScript("$('#ModalBitacora').modal('hide')", "hidemodal")
|
|
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
GvEB.DataBind()
|
|
|
|
UPEventoBitacora.Update()
|
|
'CargaEventoBitacora()
|
|
UPAddEventoBitacora.Update()
|
|
End Sub
|
|
|
|
|
|
Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim filePath As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, CType(sender, LinkButton).CommandArgument)
|
|
Dim Archivo As New System.IO.FileInfo(filePath)
|
|
|
|
HttpContext.Current.Response.Clear()
|
|
HttpContext.Current.Response.ClearContent()
|
|
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
|
HttpContext.Current.Response.AppendHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filePath))
|
|
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
HttpContext.Current.Response.TransmitFile(filePath)
|
|
HttpContext.Current.Response.Flush()
|
|
HttpContext.Current.Response.End()
|
|
|
|
Archivo = Nothing
|
|
End Sub
|
|
|
|
Protected Sub GvEB_RowDeleting(sender As Object, e As GridViewDeleteEventArgs)
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
If ObjEventoBitacora.RemoveEvento(GvEB.Rows(e.RowIndex).DataKey("CveEvento").ToEntero(), UsuarioActual.CveEmpresa) Then
|
|
cargarBitacora()
|
|
LimpiaModalBitacora()
|
|
Alert("El evento se elimino correctamente de la bitácora.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LimpiaModalBitacora()
|
|
TxtEventoDescripcion.Text = ""
|
|
txtFileBit.getfiles().Archivos.Clear()
|
|
|
|
txtFileBit.Text = ""
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "SUBIR EXCEL"
|
|
Public Sub DescargarFormato()
|
|
Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\FormatoContrato.xlsx"
|
|
Dim Archivo As New IO.FileInfo(Directorio)
|
|
If Archivo.Exists Then
|
|
Response.Clear()
|
|
Response.ClearHeaders()
|
|
Response.ClearContent()
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + Archivo.Name)
|
|
Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
Response.ContentType = "text/plain"
|
|
Response.Flush()
|
|
Response.TransmitFile(Archivo.FullName)
|
|
Response.End()
|
|
End If
|
|
End Sub
|
|
'Public Sub LbDescargarExcel_Click(sender As Object, e As EventArgs) Handles LbDescargarExcel.Click
|
|
' DescargarFormato()
|
|
'End Sub
|
|
Private Function ReadExcelFile(ByVal flatFilePath As String, ByVal firstRowHasHeaders As Boolean) As DataTable
|
|
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
|
Dim excelFile As ExcelFile = ExcelFile.Load(flatFilePath)
|
|
|
|
Dim unnamed As Integer = 0
|
|
Dim cols As Integer
|
|
Dim columns As String()
|
|
Dim curRow As Integer = 0
|
|
Dim curCol As Integer = 0
|
|
Dim dataTable As DataTable = New DataTable()
|
|
Dim worksheet As ExcelWorksheet = excelFile.Worksheets(0)
|
|
|
|
For cols = 0 To worksheet.Rows(0).AllocatedCells.Count - 1
|
|
|
|
If firstRowHasHeaders Then
|
|
|
|
If worksheet.Rows(0).Cells(cols).Value IsNot Nothing Then
|
|
dataTable.Columns.Add(worksheet.Rows(0).Cells(cols).Value.ToString())
|
|
Else
|
|
dataTable.Columns.Add("Unnamed Column " & (System.Threading.Interlocked.Increment(unnamed)))
|
|
End If
|
|
|
|
curRow = 1
|
|
Else
|
|
dataTable.Columns.Add("Column " & (cols + 1))
|
|
End If
|
|
Next
|
|
|
|
While curRow < worksheet.Rows.Count
|
|
columns = New String(cols - 1) {}
|
|
|
|
For curCol = 0 To cols - 1
|
|
|
|
If worksheet.Rows(curRow).Cells(curCol).Value Is Nothing Then
|
|
columns(curCol) = ""
|
|
Else
|
|
columns(curCol) = worksheet.Rows(curRow).Cells(curCol).Value.ToString()
|
|
End If
|
|
Next
|
|
|
|
dataTable.Rows.Add(columns)
|
|
curRow += 1
|
|
End While
|
|
|
|
Return dataTable
|
|
End Function
|
|
|
|
|
|
|
|
Private Function GetPS(Opt As String, Valor As String) As String
|
|
|
|
Dim StrReturn As String = String.Empty
|
|
Dim CvePS As Integer = 0
|
|
|
|
CvePS = GlobalDTPS(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", Opt & " = '" & Valor & "'").ToString.ToEntero
|
|
|
|
If CvePS > 0 Then
|
|
StrReturn = "True|" & CvePS.ToString
|
|
Else
|
|
StrReturn = "False|" & Valor & " en la fila " & NumRow & ", columna " & Opt
|
|
End If
|
|
|
|
Return StrReturn
|
|
|
|
End Function
|
|
|
|
Private Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
|
|
If TxtExcel.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
|
|
Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & file.patch
|
|
Dim Tipo As String = If(file.Extencion.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
|
' CargarArchivo(Directorio, file.filename, Tipo)
|
|
Else
|
|
Alert("No existe el archivo. Favor de subir un archivo excel a la plataforma.", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " IMPRESION "
|
|
|
|
#Region " IMPRIMIR AVANCE POR DOCUMENTO "
|
|
'Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles LBImprimir.Click
|
|
' GenerarPDF()
|
|
'End Sub
|
|
Private Sub GenerarPDF(Optional Formato As String = "PDF")
|
|
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
|
|
Dim dt As DataTable = DtAvanceDocumento.FiltraParametros("CveVenta > 0")
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("Contrato", Titulo))
|
|
|
|
'Datos NUEVOS
|
|
params.Add(New ReportParameter("Proveedor", Contratante))
|
|
params.Add(New ReportParameter("FechaInicio", TxtFechaInicial.Text.Trim))
|
|
params.Add(New ReportParameter("FechaFin", TxtFechaFinal.Text.Trim))
|
|
params.Add(New ReportParameter("TipoContrato", TipoDocumento))
|
|
params.Add(New ReportParameter("TotalContrato", LblImporte.Text))
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
Dim Nombre As String = If(LtlTitulo.Text.Length > 20, LtlTitulo.Text.Substring(0, 20), LtlTitulo.Text)
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepContratoAvanceDocumento.rdlc", dt, params, $"{Nombre}-AvanceDocumento", Formato:=Formato)
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "I M P R E S I O N D E G A S T O S"
|
|
'Protected Sub ImgImprimirGastos_Click(sender As Object, e As EventArgs) Handles LBImprimirGastos.Click
|
|
' GenerarPDFGastos()
|
|
'End Sub
|
|
Private Sub GenerarPDFGastos(Optional Formato As String = "PDF")
|
|
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
' Dim UtilidadGastos As String = IIf(LblUtilidad.Text <> "", LblUtilidad.Text, "-").ToString
|
|
|
|
|
|
Dim dt As DataTable = DtGastos
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("Contrato", TituloCorto))
|
|
|
|
'Datos NUEVOS
|
|
params.Add(New ReportParameter("Proveedor", Contratante))
|
|
params.Add(New ReportParameter("FechaInicio", TxtFechaInicial.Text.Trim))
|
|
params.Add(New ReportParameter("FechaFin", TxtFechaFinal.Text.Trim))
|
|
params.Add(New ReportParameter("TipoContrato", TipoDocumento))
|
|
params.Add(New ReportParameter("TotalContrato", LblImporte.Text))
|
|
' params.Add(New ReportParameter("Utilidad", UtilidadGastos))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
Dim Nombre As String = If(LtlTitulo.Text.Length > 20, LtlTitulo.Text.Substring(0, 20), LtlTitulo.Text)
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepContratoGastos.rdlc", dt, params, $"{Nombre}-Gastos", Formato:=Formato)
|
|
End Sub
|
|
|
|
'Private Sub LBAgregarGasto_Click(sender As Object, e As EventArgs) Handles LBAgregarGasto.Click
|
|
' TxtDescripcion.Text = ""
|
|
' TxtImporteC.Text = ""
|
|
' TxtFecha.Text = ""
|
|
' UpAgregarGastos.Update()
|
|
' RegistraScript("$('#ModalAgregarGastos').modal();")
|
|
'End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "I M P R E S I O N D E S U M I N I S T R O S"
|
|
'Protected Sub ImgImprimirSuministros_Click(sender As Object, e As EventArgs) Handles LbImprimirSuministros.Click
|
|
' GenerarPDFSuministros()
|
|
'End Sub
|
|
Private Sub GenerarPDFSuministros(Optional Formato As String = "PDF")
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
|
|
Dim dt As DataTable = DtSuministros
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("Contrato", TituloCorto))
|
|
|
|
'Datos NUEVOS
|
|
params.Add(New ReportParameter("Proveedor", Contratante))
|
|
params.Add(New ReportParameter("FechaInicio", TxtFechaInicial.Text.Trim))
|
|
params.Add(New ReportParameter("FechaFin", TxtFechaFinal.Text.Trim))
|
|
params.Add(New ReportParameter("TipoContrato", TipoDocumento))
|
|
params.Add(New ReportParameter("TotalContrato", LblImporte.Text))
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
Dim Nombre As String = If(LtlTitulo.Text.Length > 20, LtlTitulo.Text.Substring(0, 20), LtlTitulo.Text)
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepContratoSuministros.rdlc", dt, params, $"{Nombre}-Suministros", Formato:=Formato)
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "I M P R E S I O N D E A V A N C E "
|
|
'Private Sub lbImprimirAvance_Click(sender As Object, e As EventArgs) Handles lbImprimirAvance.Click
|
|
' GenerarPDFAvance()
|
|
'End Sub
|
|
Private Sub GenerarPDFAvance(Optional Formato As String = "PDF")
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
|
|
Dim dt As DataTable = DtAvance
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("Contrato", TituloCorto))
|
|
|
|
'Datos NUEVOS
|
|
params.Add(New ReportParameter("Proveedor", Contratante))
|
|
params.Add(New ReportParameter("FechaInicio", TxtFechaInicial.Text.Trim))
|
|
params.Add(New ReportParameter("FechaFin", TxtFechaFinal.Text.Trim))
|
|
params.Add(New ReportParameter("TipoContrato", TipoDocumento))
|
|
params.Add(New ReportParameter("TotalContrato", LblImporte.Text))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
Dim Nombre As String = If(LtlTitulo.Text.Length > 20, LtlTitulo.Text.Substring(0, 20), LtlTitulo.Text)
|
|
ImprimirPDF("Empresas/Grales/Formatos/ContratoAvance.rdlc", dt, params, $"{Nombre}-Avance", Formato:=Formato)
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "I M P R E S I O N D E P R E S U P U E S T O "
|
|
'Private Sub lLbImprimirPresupuesto_Click(sender As Object, e As EventArgs) Handles LbImprimirPresupuesto.Click
|
|
' GenerarPDFPPresupuesto()
|
|
'End Sub
|
|
Private Sub GenerarPDFPPresupuesto(Optional Formato As String = "PDF")
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
|
|
Dim dt As DataTable = DtPresupuestos
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("Contrato", TituloCorto))
|
|
|
|
'Datos NUEVOS
|
|
params.Add(New ReportParameter("Proveedor", Contratante))
|
|
params.Add(New ReportParameter("FechaInicio", TxtFechaInicial.Text.Trim))
|
|
params.Add(New ReportParameter("FechaFin", TxtFechaFinal.Text.Trim))
|
|
params.Add(New ReportParameter("TipoContrato", TipoDocumento))
|
|
params.Add(New ReportParameter("TotalContrato", LblImporte.Text))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
Dim Nombre As String = If(LtlTitulo.Text.Length > 20, LtlTitulo.Text.Substring(0, 20), LtlTitulo.Text)
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepContratoPresupuestos.rdlc", dt, params, $"{Nombre}-Presupuestos", Formato:=Formato)
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "I M P R E S I O N D E A C T I V O S F I J O S "
|
|
'Private Sub LbImprmirAF_Click(sender As Object, e As EventArgs) Handles LbImprmirAF.Click
|
|
' GenerarPDFActivosFijos()
|
|
'End Sub
|
|
'Private Sub LbImprmirAFExcel_Click(sender As Object, e As EventArgs) Handles LbImprmirAFExcel.Click
|
|
' GenerarPDFActivosFijos("Excel")
|
|
'End Sub
|
|
Private Sub GenerarPDFActivosFijos(Optional Formato As String = "PDF")
|
|
Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta))
|
|
Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
|
|
|
Dim dt As DataTable = Nothing
|
|
|
|
Select Case RBLAlmacen.SelectedValue
|
|
Case "-1"
|
|
dt = DtMovimientos
|
|
Case "Vig"
|
|
dt = DtMovimientos.FiltraParametros($"(CodigoPS IS NULL AND Cantidad - CantidadDevolucion > 0) OR (CodigoPS IS NOT NULL AND SerieFolioDevolucion IS NULL)")
|
|
Case "Dev"
|
|
dt = DtMovimientos.FiltraParametros($"SerieFolioDevolucion IS NOT NULL")
|
|
Case Else
|
|
End Select
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString))
|
|
params.Add(New ReportParameter("Contrato", TituloCorto))
|
|
|
|
'Datos NUEVOS
|
|
params.Add(New ReportParameter("Proveedor", Contratante))
|
|
params.Add(New ReportParameter("FechaInicio", TxtFechaInicial.Text.Trim))
|
|
params.Add(New ReportParameter("FechaFin", TxtFechaFinal.Text.Trim))
|
|
params.Add(New ReportParameter("TipoContrato", TipoDocumento))
|
|
params.Add(New ReportParameter("TotalContrato", LblImporte.Text))
|
|
|
|
Dim Filtro As String = If(RBLAlmacen.SelectedValue = "-1", "Todos", If(RBLAlmacen.SelectedValue = "Vig", "Vigentes", "Devueltos"))
|
|
|
|
params.Add(New ReportParameter("CantInternos", LblAFInternos.Text))
|
|
params.Add(New ReportParameter("CantExternos", LblAFExternos.Text))
|
|
params.Add(New ReportParameter("TotalCant", LBLAFTotal.Text))
|
|
params.Add(New ReportParameter("ValorActivo", LBLAFValorActivo.Text))
|
|
params.Add(New ReportParameter("FiltroContratos", Filtro))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
Dim Nombre As String = If(LtlTitulo.Text.Length > 20, LtlTitulo.Text.Substring(0, 20), LtlTitulo.Text)
|
|
ImprimirPDF("Empresas/Grales/Formatos/RepContratoActivosFijos.rdlc", dt, params, $"{Nombre}-ActivosFijos", Formato:=Formato)
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
#Region " IMPRIMIR DOCUMENTO - SABE "
|
|
Public Sub DescarFormato(documento As String)
|
|
|
|
Dim PathRoot As String = Server.MapPath("/")
|
|
Dim PathSource As String
|
|
Dim pathDesti As String
|
|
|
|
PathSource = $"{UsuarioActual.Empresa.Ruta}\Formatos\Plantillas\{documento}"
|
|
pathDesti = PathRoot & "Temp\" & CveContrato & documento
|
|
|
|
If File.Exists(pathDesti) Then
|
|
File.Delete(pathDesti)
|
|
End If
|
|
|
|
File.Copy(PathSource, pathDesti)
|
|
|
|
Dim objDoc As New clsGemBoxDocument(pathDesti)
|
|
Dim FechaActual As String = Now.Day.ToString("0#") & " de " & CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1).ToString & " del " & Now.Year.ToString()
|
|
|
|
objDoc.SustituirTags(GetDatosTagsDocumentos)
|
|
objDoc.Guardar(pathDesti)
|
|
|
|
Dim fileinfo As New FileInfo(pathDesti)
|
|
|
|
Dim baseUrl As String = Request.Url.GetLeftPart(UriPartial.Authority)
|
|
baseUrl = baseUrl & "/temp/" & fileinfo.Name
|
|
|
|
RegistraScript("Download('" & baseUrl & "')")
|
|
End Sub
|
|
|
|
Private Function GetDatosTagsDocumentos() As List(Of TagsDocumentos)
|
|
Dim ListaTagsDocumentost = New List(Of TagsDocumentos)
|
|
Dim ObjContratos As New ClsContratos
|
|
If CveContrato <> -1 Then
|
|
If ObjContratos.GetContratos(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{NumeroContrato}}", ObjContratos.NumeroContrato))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{DescripcionContrato}}", ObjContratos.DescripcionContrato))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{Ubicacion}}", ObjContratos.Ubicacion))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{Responsable}}", ObjContratos.Responsable))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{FechaInicial}}", ObjContratos.FechaInicial.ToString("d")))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{FechaFinal}}", ObjContratos.FechaFinal.ToString("d")))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{Moneda}}", GlobalDTMonedas().FiltroPrimeroValor("Moneda", $"CveMoneda = {ObjContratos.CveMoneda}")))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{IVA}}", ObjContratos.PorIVA.ToString))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{Anticipo}}", ObjContratos.PorAnticipo.ToString))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{AmortizacionAnticipo}}", ObjContratos.PorAmortizacionAnticipo.ToString))
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{Garantia}}", ObjContratos.PorGarantia.ToString))
|
|
If Not IsDBNull(ObjContratos.DtResultados(0)("Periodo")) Then
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{Periodo}}", ObjContratos.DtResultados(0)("Periodo").ToString))
|
|
End If
|
|
If Not IsDBNull(ObjContratos.DtResultados(0)("CveCuentaEquipo")) Then
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{CuentaEquipo}}", "-1"))
|
|
End If
|
|
If Not IsDBNull(ObjContratos.DtResultados(0)("NombreComercial")) Then
|
|
ListaTagsDocumentost.Add(New TagsDocumentos("{{NombreComercial}}", ObjContratos.DtResultados(0)("NombreComercial").ToString))
|
|
End If
|
|
End If
|
|
End If
|
|
ObjContratos.Dispose()
|
|
Return ListaTagsDocumentost
|
|
End Function
|
|
Private Sub CargaPlantillas()
|
|
Dim ObjGral As New ClsGenerales
|
|
If ObjGral.ContratosPlantillaGet(-1, UsuarioActual.CveEmpresa) Then
|
|
DtPlantillasContratos = ObjGral.DtResultados.FiltraParametros("Tipo = 'Con'")
|
|
' DdlPlantillaContrato.DataSource = DtPlantillasContratos
|
|
Else
|
|
DtPlantillasContratos = Nothing
|
|
End If
|
|
ObjGral.Dispose()
|
|
'DdlPlantillaContrato.DataSource = DtPlantillasContratos
|
|
'DdlPlantillaContrato.DataBind()
|
|
End Sub
|
|
|
|
'Protected Sub BtnImprimirC_Click(sender As Object, e As EventArgs) Handles liImprimir.Click
|
|
' ' Dim docx As String = DtPlantillasContratos.FiltroPrimeroValor("URL", $"CveContratoPlantilla = {DdlPlantillaContrato.SelectedValue}")
|
|
' ' DescarFormato(docx)
|
|
'End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "CREAR A PARTIR DE"
|
|
Private Sub BtnAgregarContratoHijo_Click(sender As Object, e As EventArgs) Handles BtnAgregarContratoHijo.Click
|
|
Dim TieneError = False
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
ObjContratos.IniciaTransacSQL()
|
|
|
|
Try
|
|
Dim CveContratoHijo As Integer = -1
|
|
Dim Minimo, Maximo, Total As Double
|
|
|
|
Minimo = -1
|
|
Maximo = -1
|
|
Total = -1
|
|
|
|
'If txtMinimo.Text.ToDouble > 0 And chkDetalleContrato.Checked Then Minimo = txtMinimo.Text.ToDouble Else Minimo = -1
|
|
'If txtMaximo.Text.ToDouble > 0 And chkDetalleContrato.Checked Then Maximo = txtMaximo.Text.ToDouble Else Maximo = -1
|
|
'If TxtTotal.Text.ToDouble > 0 And chkDetalleContrato.Checked Then Total = TxtTotal.Text.ToDouble Else Total = -1
|
|
|
|
Dim CveEstatusInicial As Integer = 10 'falta sacar por
|
|
If ObjContratos.GetContratosEstatus(UsuarioActual.CveEmpresa) Then
|
|
CveEstatusInicial = ObjContratos.DtResultados.FiltroPrimeroValor("CveContratoEstatus", "TipoEstatus=1").ToEntero
|
|
End If
|
|
|
|
CveContratoHijo = ObjContratos.AddContratos(TxtCodigoApartirDe.Text, TxtDescripcionApartirDe.Text, TxtNumeroLicitacion.Text.Trim, DdlContratista.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero, -1, txtFechaI4.Text.ToDate, txtFechaF4.Text.ToDate,
|
|
TxtUbicacion.Text, TxtResponsable.Text, CveSubProyecto, TxtPorIVA.Text.ToDouble, TxtPorAnticipo.Text.ToDouble, TxtPorAmortizacionAnticipo.Text.ToDouble,
|
|
TxtPorGarantia.Text.ToDouble, "." & Session("FileExtension").ToString, "", CveContrato, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, Minimo, Maximo, Total,
|
|
DdlMoneda.SelectedValue.ToEntero, ModalidadDetalle, If(UsuarioActual.Empresa.CvePlataforma = 3, 1, CveEstatusInicial), TipoContrato, TxtTipoCambio.Text.ToDouble, CveSucursalCliente:=DdlSucursalCliente.SelectedValue.ToEntero, CveAlmacenOrigen:=-1, CveAlmacenDestino:=-1, PorcentajeComision:=0,
|
|
TipoGarantia:=-1, Folio:=0, FechaVenc:=Nothing, EstatusFianza:=-1, CvePeriodo:=-1, CveCuentaEquipo:=-1, CveContratoPlantilla:=-1, CveVendedor:=-1)
|
|
|
|
|
|
If CveContratoHijo > 0 Then
|
|
|
|
If ChkCantidades.Checked Then
|
|
TieneError = AgregarDetalleHijo(CveContratoHijo, ObjContratos)
|
|
End If
|
|
|
|
If ChkTrasAF.Checked Then
|
|
TieneError = AgregarMovimientosAFHijo(CveContratoHijo, ObjContratos)
|
|
End If
|
|
|
|
Else
|
|
TieneError = True
|
|
Alert("Ocurrió un error al generar el contrato.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
ObjContratos.Commit()
|
|
Dim Msj As New StringBuilder
|
|
Msj.Append($"Se ha generado correctamente el contrato {TxtCodigoApartirDe.Text}, a partir del contrato: {TxtNumeroContrato.Text}")
|
|
Msj.AppendFormat("<br/><a class=""Texto"" target='_blank' href=""/Contratos/Contrato.aspx?CveContrato={0}"">Ver Contrato</a>", CveContratoHijo)
|
|
RegistraScript("$('#ModalCrearApartirDe').modal('hide');")
|
|
Alert(Msj.ToString, TipoMensaje.MsgInformacion)
|
|
Else
|
|
ObjContratos.RollBack()
|
|
End If
|
|
Catch ex As Exception
|
|
ObjContratos.RollBack()
|
|
OnError("Ocurrió un error al crear un nuevo contrato.", ex)
|
|
Finally
|
|
ObjContratos.Dispose()
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
|
|
Private Function AgregarDetalleHijo(CveContratoHijo As Integer, ByRef ObjContratos As ClsContratos) As Boolean
|
|
Dim TieneError = False
|
|
|
|
Dim Cantidades As Double
|
|
For Each Row As DataRow In TmpDT.Rows
|
|
Cantidades = Row("CantidadContratada").ToString.ToDouble
|
|
'If ChkCantidades.Checked Then
|
|
' Cantidades = Row("CantidadContratada").ToString.ToDouble
|
|
'Else
|
|
' Cantidades = 0
|
|
'End If
|
|
|
|
If Row("CveTipoPresupuesto").ToString.ToEntero = 1 Then
|
|
If ObjContratos.AddContratosDetalle(CveContratoHijo, Row("CvePS").ToString.ToEntero, Cantidades, Row("PU").ToString.ToDouble, UsuarioActual.CveUsuario, Row("CveTipoPresupuesto").ToString.ToEntero, Row("NoIdentificacion").ToString, Row("LimitarCantidad").ToString.ToEntero = 1, "") Then
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con un precio ${3}.", Row("Cantidad"), Row("UM"), Row("PS"), Row("PU"))
|
|
guardarBitacora(msj)
|
|
End If
|
|
Row("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle")
|
|
Else
|
|
TieneError = True
|
|
Alert("Ocurrió un error al agregar el detalle del contrato", TipoMensaje.MsgError)
|
|
Exit For
|
|
End If
|
|
ElseIf Row("CveTipoPresupuesto").ToString.ToEntero = 2 Then
|
|
If ObjContratos.AddContratosDetalle(CveContratoHijo, Row("CvePS").ToString.ToEntero, Cantidades, Row("PU").ToString.ToDouble, UsuarioActual.CveUsuario, Row("CveTipoPresupuesto").ToString.ToEntero, Row("NoIdentificacion").ToString, Row("LimitarCantidad").ToString.ToEntero = 1, Row("OCInterna").ToString) Then
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con un precio ${3}.", Row("Cantidad"), Row("UM"), Row("PS"), Row("PU"))
|
|
guardarBitacora(msj)
|
|
End If
|
|
Row("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle")
|
|
Else
|
|
TieneError = True
|
|
Alert("Ocurrió un error al agregar el detalle del contrato", TipoMensaje.MsgError)
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
Return TieneError
|
|
End Function
|
|
|
|
Private Function AgregarMovimientosAFHijo(CveContratoHijo As Integer, ByRef ObjContratos As ClsContratos) As Boolean
|
|
Dim TieneError As Boolean = False
|
|
|
|
'BUSCA LOS ACTIVOS FIJOS VIGENTES
|
|
Dim Dt As DataTable = DtMovimientos.FiltraParametros($"(CodigoPS IS NULL AND Cantidad - CantidadDevolucion > 0) OR (CodigoPS IS NOT NULL AND SerieFolioDevolucion IS NULL)")
|
|
|
|
Dim DtVentas As DataTable = Dt.FiltraParametros($"No = 0")
|
|
|
|
For Each Dr As DataRow In DtVentas.Rows
|
|
Dim CveVenta As Integer = Dr("CveVenta").ToString.ToEntero
|
|
Dim CveMovimiento As Integer = Dr("CveMovimiento").ToString.ToEntero
|
|
|
|
TieneError = Not ObjContratos.UpdateMovimientoContrato(CveContratoHijo, CveMovimiento)
|
|
|
|
If Not TieneError Then
|
|
TieneError = Not ObjContratos.UpdateVentasContrato(CveContratoHijo, CveVenta)
|
|
End If
|
|
|
|
If TieneError Then
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
If TieneError Then
|
|
Alert("Ocurrió un error al traspasar los activos fijos del contrato", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
Return TieneError
|
|
End Function
|
|
|
|
'Private Sub AgregarMovimientosAFHijo(CveContratoHijo As Integer)
|
|
' 'BUSCA LOS ACTIVOS FIJOS VIGENTES
|
|
' Dim Dt As DataTable = DtMovimientos.FiltraParametros($"(CodigoPS IS NULL AND Cantidad - CantidadDevolucion > 0) OR (CodigoPS IS NOT NULL AND SerieFolioDevolucion IS NULL)")
|
|
|
|
|
|
' Dim DtVentas As DataTable = Dt.FiltraParametros($"No = 0")
|
|
|
|
' Dim CveAlmacenOrigen As Integer = DdlAlmacenOrigen.SelectedValue.ToEntero
|
|
' Dim CveAlmacenDestino As Integer = DdlAlmacenDestino.SelectedValue.ToEntero
|
|
' Dim CveMoneda As Integer = DdlMoneda.SelectedValue.ToEntero
|
|
|
|
' Dim CveConceptoSalida As Integer = 8
|
|
' Dim CveConceptoEntrada As Integer = 9
|
|
' Dim CveCliente As Integer = If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, DdlCliente.SelectedValue.ToEntero)
|
|
|
|
' Dim ObjInv As New ClsInventarios()
|
|
' Try
|
|
' ObjInv.IniciaTransacSQL()
|
|
' Dim TieneError As Boolean = False
|
|
|
|
' For Each Dr As DataRow In DtVentas.Rows
|
|
|
|
' Dim CveVentaAlmacen As Integer = Dr("CveVenta").ToString.ToEntero
|
|
|
|
' 'Movimiento de salida por traspaso al almacen destino
|
|
' Dim CveMovimientoSalida As Integer = ObjInv.AddMovimiento(CveAlmacenDestino, CveConceptoSalida, CveMoneda, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, DdlSubProyectoContrato.SelectedValue.ToEntero, -1, CveContrato:=CveContrato, CveCliente:=CveCliente, CveAlmacenDestino:=CveAlmacenOrigen)
|
|
|
|
' If CveMovimientoSalida > 0 Then
|
|
' For Each Row As DataRow In Dt.FiltraParametros($"CvePS IS NOT NULL AND CveVenta = {CveVentaAlmacen}").Rows
|
|
|
|
' Dim Cantidad As Double = Row("Cantidad").ToString.ToDouble
|
|
' Dim CvePS As Integer = Row("CvePS").ToString.ToEntero
|
|
' Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString.ToEntero
|
|
' Dim CveUnidadMedida As Integer = Row("CveUnidadMedida").ToString.ToEntero
|
|
' Dim PU As Double = Row("PU").ToString.ToDouble
|
|
|
|
' If Not ObjInv.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUnidadMedida, CvePS, PU, -1) Then
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
' Else
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
|
|
' 'Movimeinto de entrada por traspaso al almacen origen
|
|
' Dim CveMovimientoEntrada As Integer = ObjInv.AddMovimiento(CveAlmacenOrigen, CveConceptoEntrada, CveMoneda, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, DdlSubProyectoContrato.SelectedValue.ToEntero, -1, CveContrato:=CveContratoHijo, CveCliente:=CveCliente, CveAlmacenDestino:=CveAlmacenDestino)
|
|
|
|
' If CveMovimientoEntrada > 0 Then
|
|
' For Each Row As DataRow In Dt.FiltraParametros($"CvePS IS NOT NULL AND CveVenta = {CveVentaAlmacen}").Rows
|
|
|
|
' Dim Cantidad As Double = Row("Cantidad").ToString.ToDouble
|
|
' Dim CvePS As Integer = Row("CvePS").ToString.ToEntero
|
|
' Dim CveVentaDetalle As Integer = Row("CveVentaDetalle").ToString.ToEntero
|
|
' Dim CveUnidadMedida As Integer = Row("CveUnidadMedida").ToString.ToEntero
|
|
' Dim PU As Double = Row("PU").ToString.ToDouble
|
|
|
|
' If Not ObjInv.AddMovimientoDetalle(CveMovimientoEntrada, Cantidad, CveUnidadMedida, CvePS, PU, -1) Then
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
' Next
|
|
' Else
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
|
|
' Next
|
|
' If TieneError Then
|
|
' Alert("Ocurrió un error al traspasar los activos fijos", TipoMensaje.MsgAdvertencia)
|
|
' ObjInv.RollBack()
|
|
' Else
|
|
' ObjInv.Commit()
|
|
' End If
|
|
|
|
' Catch ex As Exception
|
|
' ObjInv.RollBack()
|
|
' OnError("Ocurrió un error al traspasar los activos fijos", ex)
|
|
' End Try
|
|
' ObjInv.Dispose()
|
|
|
|
|
|
'End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "FIANZAS"
|
|
Protected Sub LimpiarCamposModalFianzas()
|
|
txtFolioFianza.Text = ""
|
|
TxtModalAdjuntoArchivo.Text = ""
|
|
DdlFianza.SelectedValue = "-1"
|
|
txtFechaVenFianza.Text = DateTime.Today.ToShortDateString
|
|
End Sub
|
|
Protected Sub btnAgregarFianza_Click(sender As Object, e As EventArgs)
|
|
|
|
LimpiarCamposModalFianzas()
|
|
EsEditarFianza = False
|
|
txth4Fianza.InnerText = "Agregar Fianza"
|
|
LnkDescargar.Visible = False
|
|
'BtnGuardarFianza.Text = "Guardar"
|
|
UPModalFianza.Update()
|
|
Me.RegistraScript("$('#DvModalFianza').modal();")
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub GuardaAdjunto(FolioFechaVencimiento As String)
|
|
If Not TxtModalAdjuntoArchivo.getfiles.Archivos.Count > 0 Then
|
|
Exit Sub
|
|
End If
|
|
Dim ArchivoAdjunto As Archivo = TxtModalAdjuntoArchivo.getfiles.Archivos(0)
|
|
If ArchivoAdjunto.filenameO.Length > 114 Then
|
|
Alert("El nombre del archivo excede los 115 caracteres permitidos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Try
|
|
Dim Path As String = String.Format("{0}\\{1}\\{2}\\{3}", UsuarioActual.Empresa.Ruta, "Contratos", "Fianzas", FolioFechaVencimiento)
|
|
DirectoryExistsCreate(Path)
|
|
Dim ArchivoDestino As String = String.Format("{0}\\{1}", Path, ArchivoAdjunto.filenameO)
|
|
If File.Exists(ArchivoDestino) Then
|
|
System.IO.File.Delete(ArchivoDestino)
|
|
End If
|
|
System.IO.File.Move(ArchivoAdjunto.FileUrl, ArchivoDestino)
|
|
Catch ex As Exception
|
|
Alert("Ocurrió un error al guardar el archivo Adjunto. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkDescargar_Click(sender As Object, e As EventArgs)
|
|
'DescargarAdjunto()
|
|
End Sub
|
|
|
|
Protected Sub imgEFianzaGv_Click(sender As Object, e As EventArgs)
|
|
LimpiarCamposModalFianzas()
|
|
EsEditarFianza = True
|
|
|
|
Dim GvRow As GridViewRow = CType(((CType(sender, LinkButton)).NamingContainer), GridViewRow)
|
|
|
|
IndexFianzaEditar = GvRow.DataItemIndex
|
|
|
|
txtFolioFianza.Text = GvRow.DataKey("Folio").ToString()
|
|
DdlFianza.SelectedValue = GvRow.DataKey("CveEstatusFianza").ToString()
|
|
txtFechaVenFianza.Text = GvRow.DataKey("FechaVencimiento").ToString()
|
|
LnkDescargar.Visible = GvRow.DataKey("Adjunto").ToString <> ""
|
|
|
|
txth4Fianza.InnerText = "Editar Fianza"
|
|
|
|
UPModalFianza.Update()
|
|
Me.RegistraScript("$('#DvModalFianza').modal();")
|
|
|
|
End Sub
|
|
Protected Sub CreaDtTmpFianzas()
|
|
DtTmpFianzas = New DataTable()
|
|
|
|
|
|
DtTmpFianzas.Columns.Add("CveContratoFianza", GetType(String))
|
|
DtTmpFianzas.Columns.Add("Folio", GetType(String))
|
|
DtTmpFianzas.Columns.Add("CveEstatusFianza", GetType(String))
|
|
DtTmpFianzas.Columns.Add("EstatusFianza", GetType(String))
|
|
DtTmpFianzas.Columns.Add("FechaVencimiento", GetType(String))
|
|
DtTmpFianzas.Columns.Add("Adjunto", GetType(String))
|
|
|
|
DtTmpFianzasInicial = DtTmpFianzas.Copy
|
|
|
|
End Sub
|
|
|
|
Protected Function GuardaFianzas(ObjContrato As ClsContratos) As Boolean
|
|
|
|
Dim TieneError As Boolean = False
|
|
|
|
For Each row As DataRow In DtTmpFianzas.Rows
|
|
Dim Folio As String = row("Folio").ToString()
|
|
Dim CveEstatus As Integer = row("CveEstatusFianza").ToString().ToEntero
|
|
Dim FechaVen As Date = Date.Parse(row("FechaVencimiento").ToString())
|
|
Dim Adjunto As String = row("Adjunto").ToString()
|
|
|
|
' Si la cve es -1 es nuevo y lo agrega
|
|
If row("CveContratoFianza").ToString() = "-1" Then
|
|
|
|
If Not ObjContrato.AddContratoFianza(CveContrato, Folio, CveEstatus, FechaVen, Adjunto) Then
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
Else
|
|
Dim CveFianza As Integer = row("CveContratoFianza").ToString().ToEntero
|
|
|
|
If Not ObjContrato.UpdateContratoFianza(CveFianza, Folio, CveEstatus, FechaVen, Adjunto) Then
|
|
TieneError = True
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
Next
|
|
' Compara si aun existe la fianza, si ya no existe la elimina
|
|
For Each row As DataRow In DtTmpFianzasInicial.Rows
|
|
|
|
Dim CveFianza As Integer = row("CveContratoFianza").ToString().ToEntero
|
|
Dim filtro As String = String.Format("CveContratoFianza ={0}", CveFianza)
|
|
|
|
If DtTmpFianzas.FiltraParametros(filtro).Rows.Count = 0 Then
|
|
TieneError = Not ObjContrato.RemoveContratoFianza(CveFianza)
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Return Not TieneError
|
|
End Function
|
|
|
|
Protected Sub LnkDescargaAdjunto_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = CType(((CType(sender, LinkButton)).NamingContainer), GridViewRow)
|
|
IndexFianzaEditar = GvRow.DataItemIndex
|
|
' DescargarAdjunto()
|
|
End Sub
|
|
Protected Sub GvFianzas_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.DBCampo("Adjunto").ToString <> "" Then
|
|
e.Row.FCLinkButton("LnkDescargaAdjunto").Visible = True
|
|
Dim lb As LinkButton = CType(e.Row.FindControl("LnkDescargaAdjunto"), LinkButton)
|
|
ScriptManager.GetCurrent(Me).RegisterPostBackControl(lb)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "CONVENIO DE PRECIO FIJO"
|
|
Protected Sub CargaConvenioPrecioFijo()
|
|
'12/04/2018 - oculta campo de licitacion, portlet finanzas y campo tipo de garantia
|
|
trLicitacion.Visible = False
|
|
'DivFianzas.Visible = False
|
|
'DivTipoGarantia.Visible = False
|
|
|
|
UpGral.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "NOMENCLATURA CONTRATOS"
|
|
Protected Sub GetNoContratoNuevo()
|
|
Dim ObjContratos As New ClsContratos()
|
|
|
|
'Dim TipoContrato As Integer = DdlTipoContrato.SelectedValue.ToEntero()
|
|
|
|
|
|
Dim SufijoContrato As String = ""
|
|
|
|
Select Case TipoContrato
|
|
Case 7 'Contrato Comodato
|
|
SufijoContrato = "COM"
|
|
Case 8 'Contrato Consignacion
|
|
SufijoContrato = "CONSIG"
|
|
Case 10 'Contrato de Financiamiento
|
|
SufijoContrato = "FIN"
|
|
Case 13 'Contrato Servicio Administrado de Impresion (?)
|
|
SufijoContrato = "MPS"
|
|
Case 28 'Convenio Precio Fijo
|
|
SufijoContrato = "CON"
|
|
End Select
|
|
|
|
Dim Serie As String = String.Format("-{0}-{1}", DateTime.Today.Year, SufijoContrato)
|
|
|
|
If ObjContratos.GetContratoNomenclatura(Serie, UsuarioActual.CveEmpresa) Then
|
|
TxtNumeroContrato.Text = ObjContratos.DtResultados.Rows(0)("NoContrato").ToString
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "IMPUESOS LOCALES"
|
|
'Protected Sub ChkImpuestosLocales_CheckedChanged(sender As Object, e As EventArgs)
|
|
' If ChkImpuestosLocales.Checked Then
|
|
' GvImpuestosLocales.Visible = True
|
|
' Else
|
|
' GvImpuestosLocales.Visible = False
|
|
' End If
|
|
'End Sub
|
|
'Public Sub CargaImpuestosLocales()
|
|
' Dim ObjContratos As New ClsContratos
|
|
' If ObjContratos.GetContratoImpuestosLocales(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
' GvImpuestosLocales.DataSource = ObjContratos.DtResultados
|
|
' End If
|
|
' ObjContratos.Dispose()
|
|
' GvImpuestosLocales.DataBind()
|
|
' UpImpuestos.Update()
|
|
'End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
Property ModalVentasPSAdd As Boolean
|
|
Get
|
|
If ViewState("ModalVentasAdd") Is Nothing Then
|
|
Return False
|
|
Else
|
|
Return Boolean.Parse(ViewState("ModalVentasAdd").ToString)
|
|
End If
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("ModalVentasAdd") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Property ModalControlPSAdd As Boolean
|
|
Get
|
|
If ViewState("ModalControlPSAdd") Is Nothing Then
|
|
Return False
|
|
Else
|
|
Return Boolean.Parse(ViewState("ModalControlPSAdd").ToString)
|
|
End If
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("ModalControlPSAdd") = value
|
|
End Set
|
|
End Property
|
|
|
|
Property Carga As Boolean
|
|
Get
|
|
If ViewState("ModalControlPSAdd") Is Nothing Then
|
|
Return False
|
|
Else
|
|
Return Boolean.Parse(ViewState("ModalControlPSAdd").ToString)
|
|
End If
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("ModalControlPSAdd") = value
|
|
End Set
|
|
End Property
|
|
|
|
Enum EnumTipoCargaPresupuesto
|
|
Ventas
|
|
Control
|
|
End Enum
|
|
|
|
Property TipoCargaPresupuesto As EnumTipoCargaPresupuesto
|
|
Get
|
|
If ViewState("TipoCargaPresupuesto") Is Nothing Then
|
|
Return EnumTipoCargaPresupuesto.Ventas
|
|
Else
|
|
Return DirectCast(ViewState("TipoCargaPresupuesto"), EnumTipoCargaPresupuesto)
|
|
End If
|
|
End Get
|
|
Set(value As EnumTipoCargaPresupuesto)
|
|
ViewState("TipoCargaPresupuesto") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Property CveContratoDetalleEditar As Integer
|
|
Get
|
|
|
|
If ViewState("CveContratoDetalleEditar") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("CveContratoDetalleEditar").ToString.ToEntero
|
|
End If
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveContratoDetalleEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub LnkModalAddPresupuestoVentas_Click(sender As Object, e As EventArgs)
|
|
|
|
LnlModalcargaPresupuestoTitulo.Text = "Carga Presupuesto Ventas"
|
|
UpModalCargaPresupuesto.Update()
|
|
RegistraScript("$('#ModalUploadPresupuesto').modal('show')")
|
|
TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Ventas
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkModalAddPresupuestoControl_Click(sender As Object, e As EventArgs)
|
|
|
|
LnlModalcargaPresupuestoTitulo.Text = "Carga Presupuesto Control"
|
|
UpModalCargaPresupuesto.Update()
|
|
RegistraScript("$('#ModalUploadPresupuesto').modal('show')")
|
|
TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Control
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkModalAddPSVentas_Click(sender As Object, e As EventArgs)
|
|
CveContratoDetalleEditar = -1
|
|
ModalVentasPSAdd = True
|
|
ChkContinualAgregandoVentas.Visible = True
|
|
ChkContinualAgregandoVentas.Checked = True
|
|
LimpiarModalVentas()
|
|
RegistraScript("$('#ModalVentasAddPS').modal('show')")
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkModalAddPSControl_Click(sender As Object, e As EventArgs)
|
|
CveContratoDetalleEditar = -1
|
|
ModalControlPSAdd = True
|
|
ChkContinualAgregandoControl.Visible = True
|
|
ChkContinualAgregandoControl.Checked = True
|
|
LimpiarModalControl()
|
|
RegistraScript("$('#ModalControlAddPS').modal('show')")
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkEditarPresupuestoVentaDetalle_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
LimpiarModalVentas()
|
|
|
|
CveContratoDetalleEditar = GvRow.DataKey("CveContratoDetalle").ToEntero
|
|
|
|
TxtCantidad.Text = GvRow.DataKey("CantidadContratada").ToDouble.ToString
|
|
|
|
DdlClasificacionAdd.SelectedValueExist(GvRow.DataKey("CveClasificacion").ToEntero)
|
|
|
|
DdlProductows.txtText.Value = GvRow.DataKey("PS").ToString
|
|
DdlProductows.txtValue.Value = GvRow.DataKey("CvePS").ToString
|
|
|
|
DdlUM.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductows.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
DdlUM.DataBind()
|
|
DdlUM.SelectedValueExist(GvRow.DataKey("CveUM").ToDouble.ToString)
|
|
|
|
TxtPU.Text = GvRow.DataKey("PU").ToDouble.ToString
|
|
|
|
|
|
|
|
ModalVentasPSAdd = False
|
|
ChkContinualAgregandoVentas.Visible = False
|
|
ChkContinualAgregandoVentas.Checked = False
|
|
|
|
|
|
RegistraScript("$('#ModalVentasAddPS').modal('show')")
|
|
End Sub
|
|
Protected Sub LnkEditarPresupuestoControlDetalle_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
|
|
Dim CveRubro As Integer = gvRow.DataKey("CveRubro").ToEntero
|
|
|
|
LimpiarModalControl()
|
|
|
|
CveContratoDetalleEditar = gvRow.DataKey("CveContratoDetalle").ToEntero
|
|
|
|
TxtCantidadInsumos.Text = gvRow.DataKey("CantidadContratada").ToDouble.ToString
|
|
|
|
|
|
DdlClasificacionAddInsumos.SelectedValueExist(gvRow.DataKey("CveClasificacion").ToEntero)
|
|
|
|
DdlProductowsInsumos.ddl.SelectedValueExist(gvRow.DataKey("CvePS").ToString.ToEntero)
|
|
|
|
|
|
DdlUMInsumos.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductowsInsumos.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa)
|
|
DdlUMInsumos.DataBind()
|
|
DdlUMInsumos.SelectedValueExist(gvRow.DataKey("CveUM").ToDouble.ToString)
|
|
|
|
TxtPUInsumos.Text = gvRow.DataKey("PU").ToDouble.ToString
|
|
Dim limitarCantidad As String = gvRow.DataKey("LimitarCantidad").ToString
|
|
ChkLimitarCantidad.Checked = limitarCantidad = "True"
|
|
|
|
DdlRubro.SelectedValueExist(gvRow.DataKey("CveRubro").ToString)
|
|
|
|
If CveRubro = 3 Then
|
|
|
|
DVDias.Visible = True
|
|
DVActividadesRH.Visible = True
|
|
DVSubTipoActivoFijo.Visible = False
|
|
|
|
DVClasificacion.Visible = False
|
|
DVPS.Visible = False
|
|
DVUM.Visible = False
|
|
|
|
DdlActividades.SelectedValueExist(gvRow.DataKey("CveActividad"))
|
|
DdlSubTipoActivoFijo.SelectedValueExist(-1)
|
|
TxtDias.Text = gvRow.DataKey("Dias")
|
|
|
|
ElseIf CveRubro = 4 Then
|
|
|
|
|
|
DVDias.Visible = True
|
|
DVActividadesRH.Visible = False
|
|
DVSubTipoActivoFijo.Visible = True
|
|
|
|
|
|
DVClasificacion.Visible = False
|
|
DVPS.Visible = False
|
|
DVUM.Visible = False
|
|
|
|
DdlActividades.SelectedValueExist(-1)
|
|
DdlSubTipoActivoFijo.SelectedValueExist(gvRow.DataKey("CveSubTipoActivoFijo"))
|
|
TxtDias.Text = gvRow.DataKey("Dias")
|
|
|
|
Else
|
|
DVDias.Visible = False
|
|
DVActividadesRH.Visible = False
|
|
DVSubTipoActivoFijo.Visible = False
|
|
|
|
DVClasificacion.Visible = True
|
|
DVPS.Visible = True
|
|
DVUM.Visible = True
|
|
|
|
DdlActividades.SelectedValueExist(-1)
|
|
DdlSubTipoActivoFijo.SelectedValueExist(-1)
|
|
TxtDias.Text = "0"
|
|
|
|
End If
|
|
|
|
|
|
|
|
ModalControlPSAdd = False
|
|
ChkContinualAgregandoControl.Visible = False
|
|
ChkContinualAgregandoControl.Checked = False
|
|
|
|
UpModalControlAddPS.Update()
|
|
|
|
RegistraScript("$('#ModalControlAddPS').modal('show')")
|
|
End Sub
|
|
|
|
|
|
Private Sub LimpiarModalVentas()
|
|
|
|
'TxtOCInterna.Text = ""
|
|
TxtCantidad.Text = ""
|
|
'ChkLimitarVenta.Checked = False
|
|
'TxtNoIdentificacionv.Text = ""
|
|
DdlClasificacionAdd.SelectedValueExist(-1)
|
|
DdlProductows.txtText.Value = ""
|
|
DdlProductows.txtValue.Value = ""
|
|
DdlUM.SelectedValueExist(-1)
|
|
TxtPU.Text = ""
|
|
ChkLimitarCantidad.Checked = False
|
|
|
|
|
|
If ModalVentasPSAdd = True Then
|
|
LtlModalVentasPSTitulo.Text = "Agregar Producto Presupuesto de Ventas"
|
|
Else
|
|
LtlModalVentasPSTitulo.Text = "Editar Producto Presupuesto de Ventas"
|
|
End If
|
|
|
|
|
|
UpModalVentasAddPS.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub LimpiarModalControl()
|
|
|
|
DdlActividades.Items.Clear()
|
|
DdlSubTipoActivoFijo.Items.Clear()
|
|
|
|
|
|
DdlActividades.DataSource = GlobalDTRHActividades(UsuarioActual.CveEmpresa)
|
|
DdlActividades.DataBind()
|
|
DdlActividades.Items.Insert(0, New ListItem("Seleccione una", "-1"))
|
|
|
|
DdlSubTipoActivoFijo.DataSource = GlobalDTSubTipoActivoFijo(UsuarioActual.CveEmpresa)
|
|
DdlSubTipoActivoFijo.DataBind()
|
|
DdlSubTipoActivoFijo.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
|
|
TxtCantidadInsumos.Text = ""
|
|
|
|
DdlClasificacionAddInsumos.SelectedValueExist(-1)
|
|
DdlProductowsInsumos.txtText.Value = ""
|
|
DdlProductowsInsumos.txtValue.Value = ""
|
|
DdlUMInsumos.SelectedValueExist(-1)
|
|
TxtPUInsumos.Text = ""
|
|
|
|
DdlRubro.SelectedValue = "2"
|
|
|
|
DVClasificacion.Visible = True
|
|
DVPS.Visible = True
|
|
DVUM.Visible = True
|
|
|
|
DVDias.Visible = False
|
|
DVActividadesRH.Visible = False
|
|
|
|
TxtDias.Text = ""
|
|
DdlActividades.SelectedValueExist(-1)
|
|
|
|
|
|
|
|
If ModalControlPSAdd = True Then
|
|
LtlModalControlPSTitulo.Text = "Agregar Producto Presupuesto Control"
|
|
Else
|
|
LtlModalControlPSTitulo.Text = "Editar Producto Presupuesto Control"
|
|
End If
|
|
|
|
UpModalControlAddPS.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub LimpiarModalMaquinaria()
|
|
|
|
DdlPersonal.Items.Clear()
|
|
|
|
|
|
|
|
|
|
DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
|
|
DdlPersonal.DataBind()
|
|
DdlPersonal.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
|
|
Dim Objcontratos As New ClsContratos
|
|
If Objcontratos.GetContratosMaquinariaFlotillaSubTipoAF(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
DdlSubTipoAF.DataSource = Objcontratos.DtResultados
|
|
End If
|
|
Objcontratos.Dispose()
|
|
DdlSubTipoAF.DataBind()
|
|
DdlSubTipoAF.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
|
|
|
|
TxtFechaMaquinaria.Text = ""
|
|
|
|
|
|
|
|
UpModalMaquinariaFlotilla.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnCargaPresupuesto_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim DTCargaPresupuesto As New DataTable
|
|
Dim DTCargaPresupuestoInsumos As New DataTable
|
|
Dim DTCargaPresupuestoManoObra As New DataTable
|
|
Dim DTCargaPresupuestoFlotillas As New DataTable
|
|
|
|
|
|
If TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Ventas Then
|
|
|
|
DTCargaPresupuesto = CargaPreSupuestoExcel("Presupuesto")
|
|
|
|
If DTCargaPresupuesto.Rows.Count > 0 Then
|
|
ProcesaDatosCargaPresupuesto(DTCargaPresupuesto, Nothing, Nothing)
|
|
Else
|
|
Alert("No se encintraron partidas en el documento", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
Else
|
|
|
|
DTCargaPresupuesto = CargaPreSupuestoExcel("Insumos")
|
|
DTCargaPresupuestoManoObra = CargaPreSupuestoExcel("ManoObra")
|
|
DTCargaPresupuestoFlotillas = CargaPreSupuestoExcel("Maquinaria")
|
|
|
|
ProcesaDatosCargaPresupuesto(DTCargaPresupuesto, DTCargaPresupuestoManoObra, DTCargaPresupuestoFlotillas)
|
|
|
|
End If
|
|
|
|
TxtModalCargaPresupuesto.Text = ""
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnDecargaFormato_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
Dim FI As New IO.FileInfo($"{Extensiones.DirectorioBaseEmpresas}\Empresas\Grales\Formatos\FormatoPresupuestoObra.xlsx")
|
|
|
|
If TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Ventas Then
|
|
FI = New IO.FileInfo($"{Extensiones.DirectorioBaseEmpresas}\Empresas\Grales\Formatos\FormatoPresupuestoObra.xlsx")
|
|
Else
|
|
FI = New IO.FileInfo($"{Extensiones.DirectorioBaseEmpresas}\Empresas\Grales\Formatos\FormatoPresupuestoObraInterno.xlsx")
|
|
End If
|
|
|
|
|
|
If FI.Exists Then
|
|
|
|
Response.ContentType = "application/octet-stream"
|
|
|
|
If TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Ventas Then
|
|
Response.AppendHeader("Content-Disposition", $"attachment; filename=FormatoPresupuestoObra.xlsx")
|
|
Else
|
|
Response.AppendHeader("Content-Disposition", $"attachment; filename=FormatoPresupuestoObraInterno.xlsx")
|
|
End If
|
|
|
|
Response.TransmitFile(FI.FullName)
|
|
Response.End()
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Private Function CargaPreSupuestoExcel(Hoja As String) As DataTable
|
|
|
|
Dim FileExtension As String = "-1"
|
|
Dim Filesgral As List(Of Archivo) = TxtModalCargaPresupuesto.getfiles().Archivos
|
|
Dim Filename As String = ""
|
|
Dim DTPS = New DataTable
|
|
|
|
For Each fileItem As Archivo In Filesgral
|
|
|
|
FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
|
|
|
|
|
|
If Not FileExtension.ToUpper.Contiene("XLSX", "XSL") Then
|
|
Alert("El archivo no es una archivo de Excel", TipoMensaje.MsgAdvertencia)
|
|
Exit For
|
|
End If
|
|
|
|
|
|
Dim tempArray() As String
|
|
tempArray = fileItem.filename.ToString().Split("-".ToCharArray())
|
|
SpreadsheetInfo.SetLicense(Extensiones.SerialGemBoxSpreadsheet)
|
|
Dim workbook = ExcelFile.Load(fileItem.FileUrl)
|
|
Dim worksheet = workbook.Worksheets(Hoja)
|
|
DTPS = worksheet.CreateDataTable(New CreateDataTableOptions() With
|
|
{
|
|
.ColumnHeaders = True,
|
|
.StartRow = 0,
|
|
.NumberOfColumns = 6,
|
|
.NumberOfRows = worksheet.Rows.Count,
|
|
.Resolution = ColumnTypeResolution.AutoPreferStringCurrentCulture
|
|
})
|
|
|
|
Next
|
|
|
|
|
|
|
|
RegistraScript("$('#ModalUploadPresupuesto').modal('hide')")
|
|
|
|
UpModalCargaPresupuesto.Update()
|
|
|
|
|
|
DTPS = DTPS.FiltraParametros("Cantidad > 0")
|
|
|
|
|
|
Return DTPS
|
|
|
|
|
|
End Function
|
|
|
|
|
|
Private Sub ProcesaDatosCargaPresupuesto(DTPresupuesto As DataTable, DTCargaPresupuestoManoObra As DataTable, DTCargaPresupuestoFlotillas As DataTable)
|
|
|
|
|
|
If Not DTPresupuesto Is Nothing Then
|
|
DTPresupuesto.CaseSensitive = False
|
|
End If
|
|
|
|
If Not DTCargaPresupuestoManoObra Is Nothing Then
|
|
DTCargaPresupuestoManoObra.CaseSensitive = False
|
|
End If
|
|
|
|
If Not DTCargaPresupuestoFlotillas Is Nothing Then
|
|
DTCargaPresupuestoFlotillas.CaseSensitive = False
|
|
End If
|
|
|
|
Dim ErrorProceso = False
|
|
|
|
Dim DTPS = New DataTable
|
|
DTPS.Columns.Add("CveContratoDetalle", GetType(Integer))
|
|
DTPS.Columns.Add("Cantidad", GetType(Double))
|
|
DTPS.Columns.Add("CantidadContratada", GetType(Double))
|
|
DTPS.Columns.Add("CveUM", GetType(Integer))
|
|
DTPS.Columns.Add("UM", GetType(String))
|
|
DTPS.Columns.Add("CveClasificacion", GetType(Integer))
|
|
DTPS.Columns.Add("Clasificacion", GetType(String))
|
|
DTPS.Columns.Add("CvePS", GetType(Integer))
|
|
DTPS.Columns.Add("PS", GetType(String))
|
|
DTPS.Columns.Add("CodigoPS", GetType(String))
|
|
DTPS.Columns.Add("PU", GetType(Double))
|
|
DTPS.Columns.Add("Total", GetType(Double))
|
|
DTPS.Columns.Add("CveTipoPresupuesto", GetType(Integer))
|
|
DTPS.Columns.Add("PermitirAvance", GetType(Integer))
|
|
DTPS.Columns.Add("PermitirEstimacion", GetType(Integer))
|
|
DTPS.Columns.Add("UsuarioAvance", GetType(Integer))
|
|
DTPS.Columns.Add("Cantidad_Original", GetType(Double))
|
|
DTPS.Columns.Add("PU_Original", GetType(Double))
|
|
DTPS.Columns.Add("Total_Original", GetType(Double))
|
|
DTPS.Columns.Add("NoIdentificacion", GetType(String))
|
|
DTPS.Columns.Add("LimitarCantidad", GetType(Integer))
|
|
DTPS.Columns.Add("OCInterna", GetType(String))
|
|
DTPS.Columns.Add("Observacion", GetType(String))
|
|
|
|
DTPS.Columns.Add("CveRubro", GetType(Integer))
|
|
DTPS.Columns.Add("CveActividad", GetType(Integer))
|
|
DTPS.Columns.Add("CveSubTipoActivoFijo", GetType(Integer))
|
|
|
|
DTPS.Columns.Add("Rubro", GetType(String))
|
|
DTPS.Columns.Add("Actividad", GetType(String))
|
|
DTPS.Columns.Add("SubTipoActivoFijo", GetType(String))
|
|
DTPS.Columns.Add("Dias", GetType(Integer))
|
|
|
|
Dim RowNoEncontrados As String = ""
|
|
|
|
If Not DTPresupuesto Is Nothing Then
|
|
|
|
For Each DrowPS As DataRow In DTPresupuesto.Rows
|
|
|
|
Dim CvePS As Integer = -1
|
|
Dim CveUM As Integer = -1
|
|
Dim StrArray() As String
|
|
|
|
|
|
StrArray = GetPS("Codigo", DrowPS("Codigo").ToString).Split("|"c)
|
|
|
|
If StrArray.Length > 0 Then
|
|
|
|
If CBool(StrArray(0)) = True Then
|
|
CvePS = StrArray(1).ToEntero
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If CvePS = -1 Then
|
|
|
|
StrArray = GetPS("PS", DrowPS("Producto").ToString).Split("|"c)
|
|
|
|
If StrArray.Length > 0 Then
|
|
If CBool(StrArray(0)) = True Then
|
|
CvePS = StrArray(1).ToEntero
|
|
End If
|
|
End If
|
|
|
|
If CvePS = -1 Then
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
|
|
Dim CveClasificacion As Integer
|
|
If DrowPS.Table.Columns.Contains("Clasificacion") Then
|
|
CveClasificacion = GlobalDTClasificaciones(CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", String.Format("Clasificacion = '{0}'", DrowPS("Clasificacion").ToString.Trim)).ToEntero
|
|
Else
|
|
CveClasificacion = GlobalDTClasificaciones(CveEmpresa:=UsuarioActual.CveEmpresa).Rows(0)("CveClasificacion").ToString.ToEntero 'toma el primero
|
|
End If
|
|
|
|
Dim CveUnidadMedida As Integer = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"UnidadMedida = '{ DrowPS("UnidadMedida").ToString}' OR Abreviatura = '{ DrowPS("UnidadMedida").ToString}'").ToString.ToEntero
|
|
|
|
If Not CveUnidadMedida > 0 Then
|
|
CveUnidadMedida = GlobalDTUnidadesMedida(CveEmpresa:=UsuarioActual.CveEmpresa).Rows(0)("CveUnidadMedida").ToString.ToEntero
|
|
End If
|
|
|
|
If ObjPS.AddPS(CveClasificacion, 1, CveUnidadMedida, DrowPS("Codigo").ToString.Trim, "", "", DrowPS("Producto").ToString, DrowPS("PU").ToString.ToDouble, 0, 0, False, 0, False, If(TipoCargaPresupuesto = EnumTipoCargaPresupuesto.Ventas, True, False),
|
|
UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, 1, CveTipoPS:=2, CveSATPS:=-1, CveMarca:=-1, CveTamaño:=-1, CveMedida:=-1, CveRinTamaño:=-1, CveModelo:=-1, Litraje:=-1, IEPSPorcentaje:=-1, CveClasificacion2:=-1, CveClasificacionDetalle:=-1) > 0 Then
|
|
CvePS = ObjPS.CvePS
|
|
Else
|
|
CvePS = -1
|
|
RowNoEncontrados &= "Producto: " & StrArray(1) & "<\BR>"
|
|
End If
|
|
|
|
ObjPS.Dispose()
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If CvePS > 0 And DrowPS("Cantidad").ToString.ToDouble > 0 Then
|
|
|
|
CveUM = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $" UnidadMedida = '{ DrowPS("UnidadMedida").ToString.Trim }' OR Abreviatura = '{ DrowPS("UnidadMedida").ToString.Trim }'").ToEntero
|
|
|
|
If CveUM <= 0 Then
|
|
CveUM = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveUnidadMedida", "").ToString.ToEntero
|
|
End If
|
|
|
|
|
|
Dim Row As DataRow = DTPS.NewRow()
|
|
|
|
Row("Cantidad") = DrowPS("Cantidad").ToString.ToDouble
|
|
Row("CantidadContratada") = DrowPS("Cantidad").ToString.ToDouble
|
|
Row("CveUM") = CveUM
|
|
Row("UM") = ""
|
|
Row("CveClasificacion") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveClasificacion", "").ToString.ToEntero
|
|
Row("Clasificacion") = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = '{ Row("CveClasificacion").ToString }'").ToString
|
|
Row("CvePS") = CvePS
|
|
Row("PS") = DrowPS("Producto").ToString
|
|
Row("CodigoPS") = DrowPS("Producto").ToString
|
|
Row("PU") = DrowPS("PU").ToString.ToDouble
|
|
Row("Total") = DrowPS("Cantidad").ToString.ToDouble * DrowPS("PU").ToString.ToDouble
|
|
|
|
Select Case TipoCargaPresupuesto
|
|
Case EnumTipoCargaPresupuesto.Ventas
|
|
|
|
Row("CveTipoPresupuesto") = 2
|
|
Row("CveRubro") = 1
|
|
Row("CveActividad") = -1
|
|
Row("CveSubTipoActivoFijo") = -1
|
|
Row("Dias") = 0
|
|
|
|
Exit Select
|
|
Case EnumTipoCargaPresupuesto.Control
|
|
Row("CveTipoPresupuesto") = 1
|
|
Row("CveRubro") = 2
|
|
Row("CveActividad") = -1
|
|
Row("CveSubTipoActivoFijo") = -1
|
|
Row("Dias") = 0
|
|
Exit Select
|
|
Case Else
|
|
Row("CveTipoPresupuesto") = 1
|
|
Row("CveActividad") = -1
|
|
Row("CveSubTipoActivoFijo") = -1
|
|
Row("Dias") = 0
|
|
End Select
|
|
|
|
|
|
Row("NoIdentificacion") = ""
|
|
Row("OCInterna") = ""
|
|
Row("LimitarCantidad") = 0
|
|
Row("Observacion") = ""
|
|
|
|
DTPS.Rows.Add(Row)
|
|
Else
|
|
ErrorProceso = True
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
|
|
|
|
|
|
If Not DTCargaPresupuestoManoObra Is Nothing And Not ErrorProceso Then
|
|
|
|
|
|
For Each DrowPS As DataRow In DTCargaPresupuestoManoObra.Rows
|
|
|
|
Dim CveActividad As Integer = 0
|
|
Dim Actividad As String
|
|
|
|
|
|
If DrowPS("Actividad").ToString.Trim.Length > 0 Then
|
|
GlobalDTRHActividades(UsuarioActual.CveEmpresa) = Nothing
|
|
CveActividad = GlobalDTRHActividades(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveActividad", $" Actividad = '{ DrowPS("Actividad").ToString.Trim }'").ToEntero
|
|
|
|
If CveActividad <= 0 Then
|
|
|
|
|
|
Dim ObjRH As New ClsRH()
|
|
|
|
If ObjRH.AddActividades(DrowPS("Actividad").ToString.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
|
|
CveActividad = ObjRH.CveActividad
|
|
|
|
If CveActividad <= 0 Then
|
|
ErrorProceso = True
|
|
End If
|
|
|
|
GlobalDTRHActividades(UsuarioActual.CveEmpresa) = Nothing
|
|
|
|
Else
|
|
ErrorProceso = True
|
|
End If
|
|
|
|
ObjRH.Dispose()
|
|
|
|
End If
|
|
|
|
|
|
If CveActividad > 0 And DrowPS("Cantidad").ToString.ToDouble > 0 And Not ErrorProceso Then
|
|
|
|
Actividad = GlobalDTRHActividades(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Actividad", $" CveActividad = {CveActividad}")
|
|
|
|
Dim Row As DataRow = DTPS.NewRow()
|
|
Row("Cantidad") = DrowPS("Cantidad").ToString.ToDouble
|
|
Row("CantidadContratada") = DrowPS("Cantidad").ToString.ToDouble
|
|
Row("CveUM") = -1
|
|
Row("UM") = "Actividad RH"
|
|
Row("CveClasificacion") = -1
|
|
Row("Clasificacion") = ""
|
|
Row("CvePS") = -1
|
|
Row("PS") = Actividad
|
|
Row("CodigoPS") = Actividad
|
|
Row("PU") = DrowPS("PU").ToString.ToDouble
|
|
Row("Total") = DrowPS("Cantidad").ToString.ToDouble * DrowPS("PU").ToString.ToDouble
|
|
|
|
Row("CveTipoPresupuesto") = 1
|
|
Row("CveRubro") = 3
|
|
Row("CveActividad") = CveActividad
|
|
Row("CveSubTipoActivoFijo") = -1
|
|
Row("Dias") = DrowPS("Dias").ToString.ToEntero
|
|
|
|
Row("NoIdentificacion") = ""
|
|
Row("OCInterna") = ""
|
|
Row("LimitarCantidad") = 0
|
|
Row("Observacion") = ""
|
|
|
|
DTPS.Rows.Add(Row)
|
|
Else
|
|
ErrorProceso = True
|
|
End If
|
|
End If
|
|
|
|
|
|
Next
|
|
|
|
End If
|
|
|
|
If Not DTCargaPresupuestoFlotillas Is Nothing Then
|
|
|
|
For Each DrowPS As DataRow In DTCargaPresupuestoFlotillas.Rows
|
|
|
|
Dim CveSubTipoActivoFijo As Integer = 0
|
|
Dim SubTipoActivoFijo As String = DrowPS("SubTipoAF").ToString
|
|
|
|
CveSubTipoActivoFijo = GlobalDTSubTipoActivoFijo(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubTipoActivoFijo", $" SubTipoActivoFijo = '{DrowPS("SubTipoAF").ToString }'").ToEntero
|
|
|
|
If CveSubTipoActivoFijo > 0 Then
|
|
|
|
Dim Row As DataRow = DTPS.NewRow()
|
|
Row("Cantidad") = DrowPS("Cantidad").ToString.ToDouble
|
|
Row("CantidadContratada") = DrowPS("Cantidad").ToString.ToDouble
|
|
Row("CveUM") = -1
|
|
Row("UM") = "Maquinaria Flotilla"
|
|
Row("CveClasificacion") = -1
|
|
Row("Clasificacion") = ""
|
|
Row("CvePS") = -1
|
|
Row("PS") = SubTipoActivoFijo
|
|
Row("CodigoPS") = SubTipoActivoFijo
|
|
Row("PU") = DrowPS("PU").ToString.ToDouble
|
|
Row("Total") = DrowPS("Cantidad").ToString.ToDouble * DrowPS("PU").ToString.ToDouble
|
|
|
|
Row("CveTipoPresupuesto") = 1
|
|
Row("CveRubro") = 3
|
|
Row("CveActividad") = -1
|
|
Row("CveSubTipoActivoFijo") = CveSubTipoActivoFijo
|
|
Row("Dias") = DrowPS("Horas").ToString.ToEntero
|
|
|
|
Row("NoIdentificacion") = ""
|
|
Row("OCInterna") = ""
|
|
Row("LimitarCantidad") = 0
|
|
Row("Observacion") = ""
|
|
|
|
DTPS.Rows.Add(Row)
|
|
Else
|
|
ErrorProceso = True
|
|
RowNoEncontrados &= "Sub Tipo: " & DrowPS("SubTipoAF").ToString & "<\BR>"
|
|
End If
|
|
|
|
|
|
Next
|
|
|
|
|
|
End If
|
|
|
|
|
|
If Not ErrorProceso Then
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
Dim TotalRow As Double = 0
|
|
ObjContratos.IniciaTransacSQL()
|
|
|
|
For Each Row As DataRow In DTPS.Rows
|
|
|
|
If ObjContratos.AddContratosDetalle(CveContrato, Row("CvePS").ToString.ToEntero, Row("Cantidad").ToString.ToDouble, Row("PU").ToString.ToDouble, UsuarioActual.CveUsuario, Row("CveTipoPresupuesto").ToString.ToEntero,
|
|
Row("NoIdentificacion").ToString, Convert.ToBoolean(Row("LimitarCantidad")), Row("OCInterna").ToString, Observacion:=Row("Observacion").ToString, CveRubro:=Row("CveRubro").ToString.ToEntero,
|
|
CveActividad:=Row("CveActividad").ToString.ToEntero, CveSubTipoActivoFijo:=Row("CveSubTipoActivoFijo").ToString.ToEntero, Dias:=Row("Dias").ToString.ToEntero) Then
|
|
|
|
If Autorizado Then
|
|
Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con rubro {4} con un precio ${3}.", Row("Cantidad"), Row("UM"), Row("PS"), Row("PU"), Row("CveRubro"))
|
|
guardarBitacora(msj)
|
|
End If
|
|
|
|
Dim NrowTmpDT As DataRow = TmpDT.NewRow
|
|
|
|
|
|
NrowTmpDT("Cantidad") = Row("Cantidad")
|
|
NrowTmpDT("CantidadContratada") = Row("CantidadContratada")
|
|
NrowTmpDT("CveUM") = Row("CveUM")
|
|
NrowTmpDT("UM") = Row("UM")
|
|
NrowTmpDT("CveClasificacion") = Row("CveClasificacion")
|
|
NrowTmpDT("Clasificacion") = Row("Clasificacion")
|
|
NrowTmpDT("CvePS") = Row("CvePS")
|
|
|
|
|
|
NrowTmpDT("PS") = Row("PS")
|
|
NrowTmpDT("CodigoPS") = Row("CodigoPS")
|
|
|
|
|
|
|
|
|
|
NrowTmpDT("PU") = Row("PU")
|
|
NrowTmpDT("Total") = Row("Total")
|
|
NrowTmpDT("CveTipoPresupuesto") = Row("CveTipoPresupuesto")
|
|
NrowTmpDT("NoIdentificacion") = Row("NoIdentificacion")
|
|
NrowTmpDT("OCInterna") = Row("OCInterna")
|
|
NrowTmpDT("LimitarCantidad") = Row("LimitarCantidad")
|
|
NrowTmpDT("Observacion") = Row("Observacion")
|
|
|
|
NrowTmpDT("CveRubro") = Row("CveRubro")
|
|
NrowTmpDT("CveActividad") = Row("CveActividad")
|
|
NrowTmpDT("CveSubTipoActivoFijo") = Row("CveSubTipoActivoFijo")
|
|
|
|
NrowTmpDT("Rubro") = Row("Rubro")
|
|
NrowTmpDT("Actividad") = Row("Actividad")
|
|
NrowTmpDT("SubTipoActivoFijo") = Row("SubTipoActivoFijo")
|
|
NrowTmpDT("Dias") = Row("Dias")
|
|
|
|
|
|
NrowTmpDT("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle")
|
|
|
|
TmpDT.Rows.Add(NrowTmpDT)
|
|
TmpDT.AcceptChanges()
|
|
|
|
TotalRow = TotalRow + NrowTmpDT("Total").ToString.ToDouble
|
|
Else
|
|
ErrorProceso = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
|
|
If ErrorProceso Then
|
|
ObjContratos.RollBack()
|
|
Alert("Se presento un error al cargar el presupuesto.", TipoMensaje.MsgError)
|
|
Else
|
|
|
|
ObjContratos.Commit()
|
|
Alert("Presupuesto Cargado correctamente")
|
|
|
|
|
|
Select Case TipoCargaPresupuesto
|
|
Case EnumTipoCargaPresupuesto.Ventas
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
UpGV.Update()
|
|
Exit Select
|
|
Case EnumTipoCargaPresupuesto.Control
|
|
CargaGVPresupuestosInsumos(TmpDT.FiltraParametros("CveTipoPresupuesto=1"))
|
|
UpGVInsumos.Update()
|
|
Exit Select
|
|
Case Else
|
|
|
|
End Select
|
|
|
|
LbTotalGeneral.Text = (LbTotalGeneral.Text.ToDouble + TotalRow).ToString.FormatoNumero
|
|
LblImporte.Text = LbTotalGeneral.Text
|
|
UpGral.Update()
|
|
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
If RowNoEncontrados.Length > 0 Then
|
|
Alert($"Productos y Sub Tipos no encontrados <br> {RowNoEncontrados} ", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Sub LnkHabilitaAvance_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
|
|
Dim PermitirAvance As Integer = GvRow.DataKey("PermitirAvance").ToEntero
|
|
|
|
'Get the button that raised the event
|
|
'Dim btn As CheckBox = DirectCast(sender, CheckBox)
|
|
'Dim gvr As GridViewRow = DirectCast(btn.NamingContainer, GridViewRow)
|
|
|
|
Dim CveContratoDetalle As Integer = GvRow.DataKey("CveContratoDetalle").ToString.ToEntero
|
|
Dim objContrato As New ClsContratos
|
|
|
|
If objContrato.UpdateContratosDetalleAvance(CveContratoDetalle, IIf(PermitirAvance = 1, 0, 1).ToString.ToEntero) Then
|
|
Dim row = TmpDT.Select(String.Format("CveContratoDetalle={0}", CveContratoDetalle))(0)
|
|
|
|
row("PermitirAvance") = IIf(PermitirAvance = 1, 0, 1).ToString.ToEntero
|
|
|
|
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
|
|
|
|
Alert("Se ha permitido levantar avance", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("no se pudo permitir avance", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
objContrato.Dispose()
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaEstadoCueta()
|
|
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
If ObjContratos.GetContratosObraEstadoCuenta(CveContrato, UsuarioActual.CveEmpresa, 1) Then
|
|
GvEstadoCuentaAnticipos.DataSource = ObjContratos.DtResultados
|
|
Else
|
|
GvEstadoCuentaAnticipos.DataSource = Nothing
|
|
End If
|
|
|
|
If ObjContratos.GetContratosObraEstadoCuenta(CveContrato, UsuarioActual.CveEmpresa, 2) Then
|
|
GvEstadoCuentaFacturas.DataSource = ObjContratos.DtResultados
|
|
Else
|
|
GvEstadoCuentaFacturas.DataSource = Nothing
|
|
End If
|
|
|
|
|
|
ObjContratos.Dispose()
|
|
|
|
GvEstadoCuentaAnticipos.DataBind()
|
|
GvEstadoCuentaFacturas.DataBind()
|
|
|
|
|
|
|
|
UpEstoCuenta.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub CargaGastos()
|
|
|
|
Dim GastosCompras As Double = 0
|
|
Dim GastosVeiculos As Double = 0
|
|
Dim GatosNominas As Double = 0
|
|
Dim GastosProcentaje As Double = 0
|
|
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
If ObjContratos.GetContratosObragGastosVeiculos(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
GvGastosVeiculos.DataSource = ObjContratos.DtResultados
|
|
GastosVeiculos = ObjContratos.DtResultados.SUM("Importe", " CveContratoGasto > 0 ")
|
|
|
|
Else
|
|
GvGastosVeiculos.DataSource = Nothing
|
|
End If
|
|
|
|
If ObjContratos.GetContratosObragGastosCompras(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
GvGastosCompras.DataSource = ObjContratos.DtResultados
|
|
GastosCompras = ObjContratos.DtResultados.SUM("Importe", "CveContrato > 0")
|
|
Else
|
|
GvGastosCompras.DataSource = Nothing
|
|
End If
|
|
|
|
If ObjContratos.GetContratosObragGastosNomina(CveContrato, UsuarioActual.CveEmpresa) Then
|
|
GvGastosNomina.DataSource = ObjContratos.DtResultados
|
|
GatosNominas = ObjContratos.DtResultados.SUM("Importe", "CveContrato > 0")
|
|
Else
|
|
GvGastosNomina.DataSource = Nothing
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
|
|
GvGastosVeiculos.DataBind()
|
|
GvGastosCompras.DataBind()
|
|
GvGastosNomina.DataBind()
|
|
|
|
LblGastoContrato.Text = LblImporte.Text
|
|
LblGastoNomina.Text = "$ " & GatosNominas.ToString("###,###,###.00")
|
|
LblGastoGastos.Text = "$ " & GastosCompras.ToString("###,###,###.00")
|
|
LblGastoIndirectos.Text = "$ " & GastosVeiculos.ToString("###,###,###.00")
|
|
|
|
UpGastos.Update()
|
|
|
|
GastosProcentaje = (GastosVeiculos + GatosNominas + GastosCompras) * 100 / (LblGastoContrato.Text.ToDecimal)
|
|
LblGastoPorcentaje.Text = GastosProcentaje.ToString("###.00") & " %"
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub GvGastosVeiculos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvGastosVeiculos.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DataKey("ORDEN").ToEntero = 1 Then
|
|
e.Row.CssClass = "Totales"
|
|
e.Row.Cells(1).Text = "Total"
|
|
Dim LnkEliminarGasto As LinkButton = e.Row.FCLinkButton("LnkEliminarGasto")
|
|
LnkEliminarGasto.Visible = False
|
|
|
|
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub GvGastosCompras_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvGastosCompras.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DataKey("CveContrato").ToEntero > 0 Then
|
|
e.Row.CssClass = "Totales"
|
|
e.Row.Cells(1).Text = "Total"
|
|
|
|
ElseIf e.Row.DataKey("CveContrato").ToEntero = 0 And e.Row.DataKey("CveClasificacion").ToEntero > 0 And e.Row.DataKey("ORDEN").ToEntero = 1 Then
|
|
e.Row.CssClass = "SubTotales"
|
|
e.Row.Cells(0).Text = e.Row.DataKey("Clasificacion")
|
|
e.Row.Cells(0).Width = 250
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub GvGastosNomina_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvGastosNomina.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DataKey("CvePersonal").ToEntero = 0 Then
|
|
e.Row.CssClass = "Totales"
|
|
e.Row.Cells(1).Text = "Total"
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkModalAddGastos_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
RegistraScript("$('#ModalControlAddGastoVeiculo').modal('show');")
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkEliminarGasto_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
|
|
Dim CveContratoGasto As Integer = GvRow.DataKey("CveContratoGasto").ToString.ToEntero
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
Dim ErrorProceso As Boolean = True
|
|
|
|
|
|
If ObjContratos.RemoveContratoGasto(CveContratoGasto) Then
|
|
ErrorProceso = False
|
|
End If
|
|
|
|
If Not ErrorProceso Then
|
|
CargaGastos()
|
|
Alert("Gasto eliminado correctamente.")
|
|
End If
|
|
|
|
|
|
ObjContratos.Dispose()
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnModalAgreagrGasto_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ErrorProceso As Boolean = True
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
If ObjContratos.AddContratoGasto(CveContrato, TxtGastosDescripcion.Text, TxtGastosImporte.Text.ToDecimal, Now, UsuarioActual.CveUsuario) Then
|
|
ErrorProceso = False
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
|
|
If Not ErrorProceso Then
|
|
CargaGastos()
|
|
RegistraScript("$('#ModalControlAddGastoVeiculo').modal('hide');")
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub Indicadores()
|
|
|
|
|
|
|
|
Dim Con As New ClsContratos
|
|
Dim DTDatos As New DataTable
|
|
|
|
If Con.GetContratosObraRepAvances(MinFecha, MaxFecha, DdlCliente.SelectedValue.ToEntero, CveContrato, UsuarioActual.CveEmpresa) Then
|
|
DTDatos = Con.DtResultados
|
|
End If
|
|
|
|
Con.Dispose()
|
|
|
|
|
|
Try
|
|
If DTDatos.Rows.Count > 0 Then
|
|
|
|
Dim CantidadAvance As Decimal = DTDatos.Rows(0)("Cantidad").ToString.ToDecimal
|
|
Dim ImporteAvance As Decimal = DTDatos.Rows(0)("AvanceImporte").ToString.ToDecimal
|
|
Dim TotalAvancePorcentaje As Decimal = If(ImporteAvance > 0, (ImporteAvance * 100 / TotalAvanceVentas).RoundSQL(2), 0)
|
|
|
|
Dim CantidadInterno As Decimal = DTDatos.Rows(0)("CantidadInterno").ToString.ToDecimal
|
|
Dim ImporteInterno As Decimal = DTDatos.Rows(0)("ImporteInterno").ToString.ToDecimal
|
|
Dim TotalFaltantePorcentaje As Decimal = If(ImporteInterno > 0, (ImporteInterno * 100 / TotalAvanceInterno).RoundSQL(2), 0)
|
|
|
|
|
|
LtlAvanceImporte.Text = $"$ { ImporteAvance.ToString("###,###,###.00") }"
|
|
LtlAvanceImporteProcentaje1.Text = $"{TotalAvancePorcentaje.ToString("###.00")} %"
|
|
LtlAvanceImporteProcentaje2.Text = $"{TotalAvancePorcentaje.ToString("###.00")}%"
|
|
SPAvance1.Attributes.Add("style", $"width:{TotalAvancePorcentaje.ToString.ToEntero}%")
|
|
|
|
|
|
LtlAvanceInternoImporte.Text = $"$ {DTDatos.Rows(0)("ImporteInterno").ToString.ToDecimal.ToString("###,###,###.00")}"
|
|
LtlAvanceInternoImportePorcentaje1.Text = $"{TotalFaltantePorcentaje.ToString("###.00")} %"
|
|
LtlAvanceInternoImportePorcentaje2.Text = $"{TotalFaltantePorcentaje.ToString("###.00")}%"
|
|
SPFaltante.Attributes.Add("style", $"width:{TotalFaltantePorcentaje.ToString.ToEntero}%")
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
|
|
|
|
DVGraficas.Visible = True
|
|
|
|
UpGrafica.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Protected Sub DdlRubro_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
|
|
If DdlRubro.SelectedValue.ToEntero = 3 Then 'Rubro RH
|
|
DVDias.Visible = True
|
|
DVActividadesRH.Visible = True
|
|
|
|
DVClasificacion.Visible = False
|
|
DVPS.Visible = False
|
|
DVUM.Visible = False
|
|
|
|
DVSubTipoActivoFijo.Visible = False
|
|
|
|
|
|
ElseIf DdlRubro.SelectedValue.ToEntero = 4 Then 'Rubro Maquinaria florilla herramienta
|
|
|
|
DVDias.Visible = True
|
|
DVActividadesRH.Visible = False
|
|
|
|
DVClasificacion.Visible = False
|
|
DVPS.Visible = False
|
|
DVUM.Visible = False
|
|
|
|
DVSubTipoActivoFijo.Visible = True
|
|
|
|
Else
|
|
DVDias.Visible = False
|
|
DVActividadesRH.Visible = False
|
|
|
|
DVClasificacion.Visible = True
|
|
DVPS.Visible = True
|
|
DVUM.Visible = True
|
|
|
|
DVSubTipoActivoFijo.Visible = False
|
|
|
|
End If
|
|
|
|
UpModalControlAddPS.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkModalAddMaquinariaFlotilla_Click(sender As Object, e As EventArgs)
|
|
|
|
LimpiarModalMaquinaria()
|
|
RegistraScript("$('#ModalMaquinaria').modal('show');")
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub DdlSubTipoAF_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubTipoAF.SelectedIndexChanged
|
|
|
|
DdlAF.Items.Clear()
|
|
|
|
If DdlSubTipoAF.SelectedIndex > 0 Then
|
|
|
|
|
|
Dim CveSubTipoActivoFijo As Integer = 0
|
|
|
|
Dim Separador As Char() = {"-"c}
|
|
|
|
Try
|
|
CveSubTipoActivoFijo = DdlSubTipoAF.SelectedValue.Split(Separador)(0).ToEntero
|
|
Catch ex As Exception
|
|
CveSubTipoActivoFijo = 0
|
|
End Try
|
|
|
|
If CveSubTipoActivoFijo > 0 Then
|
|
DdlAF.DataSource = GlobalDTActivoFijos(UsuarioActual.CveEmpresa, -1).FiltraParametros(String.Format("CveSubTipoActivoFijo IN ({0})", CveSubTipoActivoFijo))
|
|
End If
|
|
|
|
Else
|
|
DdlAF.DataSource = Nothing
|
|
|
|
End If
|
|
|
|
DdlAF.DataBind()
|
|
|
|
|
|
|
|
DdlAF.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
UpModalMaquinariaFlotilla.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnModalMaquinariaAdd_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim CveContratoDetalle As Integer = 0
|
|
|
|
Dim Separador As Char() = {"-"c}
|
|
|
|
Try
|
|
CveContratoDetalle = DdlSubTipoAF.SelectedValue.Split(Separador)(1).ToEntero
|
|
Catch ex As Exception
|
|
CveContratoDetalle = 0
|
|
End Try
|
|
|
|
Dim ObjContrato As New ClsContratos
|
|
|
|
If ObjContrato.AddContratosMaquinariaFlotilla(DdlAF.SelectedValue.ToEntero, TxtFechaMaquinaria.Text.ToDate, DdlPersonal.SelectedValue.ToEntero, TxtMaquinariaImporte.Text.ToDecimal, CveContratoDetalle) Then
|
|
|
|
|
|
If Not ChkModalMaquinaria.Checked Then
|
|
RegistraScript("$('#ModalMaquinaria').modal('hide');")
|
|
End If
|
|
|
|
Alert("Registro agregado correctamente.")
|
|
|
|
End If
|
|
|
|
ObjContrato.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Property DTCentrosCostoGB As DataTable
|
|
|
|
Get
|
|
If ViewState("DTCentrosCosto") Is Nothing Then
|
|
Return New DataTable
|
|
Else
|
|
Return DirectCast(ViewState("DTCentrosCosto"), DataTable)
|
|
End If
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTCentrosCosto") = value
|
|
End Set
|
|
|
|
End Property
|
|
|
|
|
|
Private Sub tabalCentrosdecotso()
|
|
|
|
Dim DTCentrosCosto As New DataTable
|
|
DTCentrosCosto.Columns.Add("CveSubProyecto", GetType(Integer))
|
|
DTCentrosCosto.Columns.Add("SubProyecto", GetType(String))
|
|
DTCentrosCosto.Columns.Add("Porcentaje", GetType(Decimal))
|
|
DTCentrosCostoGB = DTCentrosCosto
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub AddtabalCentrosdecotso(CveSubProyecto As Integer, SubProyecto As String, porcentaje As Decimal)
|
|
|
|
Dim drow As DataRow = DTCentrosCostoGB.NewRow
|
|
|
|
drow("CveSubProyecto") = CveSubProyecto
|
|
drow("SubProyecto") = SubProyecto
|
|
drow("Porcentaje") = porcentaje
|
|
|
|
DTCentrosCostoGB.Rows.Add(drow)
|
|
|
|
|
|
|
|
TxtCentroCostosPorcentaje.Text = ""
|
|
|
|
CargaGVCentrosConsto()
|
|
|
|
End Sub
|
|
Private Sub RemovetabalCentrosdecotso(Indice As Integer)
|
|
|
|
|
|
|
|
CargaGVCentrosConsto()
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub CargaGVCentrosConsto()
|
|
|
|
GVCentrosConsto.DataSource = DTCentrosCostoGB
|
|
GVCentrosConsto.DataBind()
|
|
UpGVCentrosConsto.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaDLLCargaGVCentrosConsto()
|
|
|
|
DdlCentroCostos.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveSubproyecto", "SubProyecto"})
|
|
DdlCentroCostos.DataBind()
|
|
DdlCentroCostos.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkAgregarCentroCostosPorcentaj_Click(sender As Object, e As EventArgs)
|
|
|
|
AddtabalCentrosdecotso(DdlCentroCostos.SelectedValue.ToEntero, DdlCentroCostos.SelectedItem.Text, TxtCentroCostosPorcentaje.Text.ToDecimal)
|
|
|
|
End Sub
|
|
End Class
|
|
|
|
|