2167 lines
94 KiB
VB.net
2167 lines
94 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
Imports System.IO
|
|
Imports System.Data
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class Contratos_Default
|
|
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 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 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 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
|
|
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 NumRow As Integer
|
|
|
|
#End Region
|
|
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
CargaValoresIniciales()
|
|
|
|
If Request("CveCliente") IsNot Nothing Then
|
|
cargaClientes()
|
|
End If
|
|
|
|
If Request("CveContrato") IsNot Nothing AndAlso IsNumeric(Request("CveContrato")) AndAlso Request("CveContrato").ToEntero > 0 Then
|
|
ViewState("CveContrato") = Request("CveContrato")
|
|
|
|
DvBitacora.Visible = True
|
|
|
|
If UsuarioActual.TienePermisoProceso(126) Then
|
|
BtnAutorizar.Visible = True
|
|
End If
|
|
DivContent.Visible = True
|
|
' DivTipoContrato.Visible = False
|
|
'TxtArchivo.Visible = True
|
|
CargaDatos()
|
|
CargaDatosAvance()
|
|
CargaDatosAvancePorDocumento()
|
|
CargaInventarios()
|
|
'Configuración de Modalidad Update
|
|
BtnGuardar.Text = "Guardar Cambios"
|
|
|
|
If Request("Opt") IsNot Nothing AndAlso IsNumeric(Request("Opt")) Then Tab.ActiveTabIndex = Request("Opt").ToEntero
|
|
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()
|
|
ConfiguraTipos()
|
|
|
|
End If
|
|
|
|
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
|
|
Else
|
|
BtnEliminar.Visible = False
|
|
Gv.Columns(8).Visible = False
|
|
End If
|
|
|
|
Else
|
|
Gv.Columns(8).Visible = True
|
|
|
|
End If
|
|
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
|
|
|
|
CargaProyecto()
|
|
CargaContratista()
|
|
|
|
DdlUM.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
|
|
DdlUM.DataBind()
|
|
DdlMoneda.DataSource = GlobalDTMonedas
|
|
DdlMoneda.DataBind()
|
|
|
|
CargaContratoPadre()
|
|
CargaContratosEstatus()
|
|
CreaDT()
|
|
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa)
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
If UsuarioActual.TienePermisoProceso(172) Then
|
|
RowPorcentajeComision.Visible = True
|
|
End If
|
|
|
|
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()
|
|
TrCliente.Visible = True
|
|
TrProveedor.Visible = False
|
|
DdlCliente.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
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("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("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))
|
|
|
|
End Sub
|
|
Protected Sub Limpiar()
|
|
TxtNumeroContrato.Text = ""
|
|
TxtDescripcionContrato.Text = ""
|
|
DdlContratista.SelectedValue = "-1"
|
|
DdlCliente.SelectedValue = "-1"
|
|
TxtFechaInicial.Text = ""
|
|
TxtFechaFinal.Text = ""
|
|
TxtPorIVA.Text = ""
|
|
txtMinimo.Text = ""
|
|
txtMaximo.Text = ""
|
|
'TxtArchivo.Text = ""
|
|
|
|
DdlProyecto.SelectedValue = "-1"
|
|
DdlSubProyectoContrato.SelectedValue = "-1"
|
|
DdlContratoPadre.SelectedValue = "-1"
|
|
|
|
'Tab Presupuesto
|
|
TxtCantidad.Text = ""
|
|
TxtPU.Text = ""
|
|
TmpDT.Clear()
|
|
CargaGVPresupuestos(TmpDT)
|
|
LbTotalGeneral.Text = "0.00"
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " CONFIGURA TIPOS CONTRATO "
|
|
|
|
Private Sub ConfiguraTipos()
|
|
|
|
If Not TipoContrato.Contiene({7, 8, 9, 13}) Then
|
|
TabAF.Visible = False
|
|
|
|
End If
|
|
'TabContratosGastos.Visible = False
|
|
|
|
'CONSIGNACION
|
|
If TipoContrato.Contiene({8}) Then
|
|
RowAlmacen.Visible = True
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub MuestraPermiteAvance()
|
|
|
|
If Not TipoContrato.Contiene({4, 5}) Then
|
|
Gv.Columns(6).Visible = False
|
|
Gv.Columns(6).Visible = False
|
|
THAvance.Visible = False
|
|
' tdCol7.Visible = False
|
|
TDAvance.Visible = False
|
|
Else
|
|
Gv.Columns(6).Visible = True
|
|
Gv.Columns(6).Visible = True
|
|
THAvance.Visible = True
|
|
'tdCol7.Visible = True
|
|
TDAvance.Visible = True
|
|
End If
|
|
|
|
UpGral.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " PANTALLA INICIAL"
|
|
Protected Sub rpCompra_CheckedChanged(sender As Object, e As EventArgs) Handles rpCompra.CheckedChanged
|
|
loadComboTipoContrato(False)
|
|
End Sub
|
|
Protected Sub rdventa_CheckedChanged(sender As Object, e As EventArgs) Handles rdventa.CheckedChanged
|
|
loadComboTipoContrato(True)
|
|
End Sub
|
|
Private Sub loadComboTipoContrato(venta As Boolean)
|
|
|
|
Try
|
|
If venta Then
|
|
DdlTipoContrato.DataSource = GlobalDTContratosTipos.FiltraParametros($" CveEmpresa = {UsuarioActual.CveEmpresa} AND TipoMovimiento = 1")
|
|
Else
|
|
DdlTipoContrato.DataSource = GlobalDTContratosTipos.FiltraParametros($" CveEmpresa = {UsuarioActual.CveEmpresa} AND TipoMovimiento = 0")
|
|
End If
|
|
dvDetContrato.Visible = True
|
|
' DdlTipoContrato.Visible = True
|
|
DdlTipoContrato.DataBind()
|
|
DdlTipoContrato.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
|
If UsuarioActual.CveEmpresa.Contiene(1,11, 4, 12) And venta Then
|
|
DdlTipoContrato.Items.Insert(1, New ListItem("Contrato con facturación ciclica", "25"))
|
|
End If
|
|
UPTipo.Update()
|
|
Catch ex As Exception
|
|
Alert(ex.Message, TipoMensaje.MsgError)
|
|
|
|
End Try
|
|
|
|
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")})"
|
|
LtlTitulo.Text = $"Contrato: {Titulo})"
|
|
'Pestaña Datos Generales
|
|
TxtDescripcionContrato.Text = ObjContratos.DescripcionContrato
|
|
TxtNumeroContrato.Text = ObjContratos.NumeroContrato
|
|
TipoContrato = ObjContratos.CveContratoTipo
|
|
TxtPorcentajeComision.Text = ObjContratos.PorcentajeComision.ToString
|
|
|
|
If ObjContratos.CveProveedor > 0 Then
|
|
TrProveedor.Visible = True
|
|
TrCliente.Visible = False
|
|
CargaContratista()
|
|
DdlContratista.SelectedValue = ObjContratos.CveProveedor.ToString
|
|
Else
|
|
cargaClientes()
|
|
DdlCliente.SelectedValue = ObjContratos.CveCliente.ToString
|
|
DdlCliente_SelectedIndexChanged(DdlCliente, EventArgs.Empty)
|
|
DdlSucursalCliente.SelectedValue = ObjContratos.CveSucursalCliente.ToString
|
|
End If
|
|
|
|
CargaContratoPadre()
|
|
|
|
|
|
If (DdlAlmacen.Items.FindByValue(ObjContratos.CveAlmacen.ToString()) Is Nothing) Then
|
|
Dim dr As DataRow = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveAlmacen = {0}", ObjContratos.CveAlmacen))
|
|
If dr IsNot Nothing Then
|
|
DdlAlmacen.Items.Insert(1, New ListItem(dr("Almacen").ToString, dr("CveAlmacen").ToString)) ' lo genera Obj.SelectedValue = Valor.ToString
|
|
End If
|
|
End If
|
|
DdlAlmacen.SelectedValue = ObjContratos.CveAlmacen.ToString
|
|
|
|
TxtFechaFinal.Text = ObjContratos.FechaFinal.ToShortDateString
|
|
TxtFechaInicial.Text = ObjContratos.FechaInicial.ToShortDateString
|
|
TxtUbicacion.Text = ObjContratos.Ubicacion
|
|
TxtResponsable.Text = ObjContratos.Responsable
|
|
TxtPorAnticipo.Text = ObjContratos.PorAmortizacionAnticipo.FormatoNumero
|
|
TxtPorAmortizacionAnticipo.Text = ObjContratos.PorAmortizacionAnticipo.FormatoNumero
|
|
TxtPorGarantia.Text = ObjContratos.PorGarantia.FormatoNumero
|
|
DdlProyecto.SelectedValue = ObjContratos.CveProyecto.ToString
|
|
CargaSubProyectoContrato(DdlProyecto.SelectedValue.ToEntero)
|
|
DdlSubProyectoContrato.SelectedValue = ObjContratos.CveSubProyecto.ToString
|
|
TxtPorIVA.Text = ObjContratos.PorIVA.ToString
|
|
txtMinimo.Text = ObjContratos.Minimo.FormatoNumero
|
|
txtMaximo.Text = ObjContratos.Maximo.FormatoNumero
|
|
TxtTotal.Text = ObjContratos.Importe.FormatoNumero
|
|
'TxtArchivo.Text = ObjContratos.Archivo
|
|
DdlTipoGarantia.SelectedValueExist(ObjContratos.TipoGarantia)
|
|
DdlEstatusFianza.SelectedValueExist(ObjContratos.EstatusFianza)
|
|
TxtFolio.Text = ObjContratos.Folio.ToString
|
|
txtFechaVenc.Text = ObjContratos.FechaVenc.ToString
|
|
DdlEstatus.SelectedValueExist(ObjContratos.CveContratosEstatus.ToString)
|
|
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()
|
|
If ObjContratos.TipoEstatus = 1 Then
|
|
If UsuarioActual.TienePermisoProceso(173) Then
|
|
liTerminarContrato.Visible = True
|
|
LBTerminarContrato.Visible = True
|
|
End If
|
|
End If
|
|
End If
|
|
TxtTipoCambio.Text = ObjContratos.TipoCambio.ToString
|
|
|
|
ModalidadDetalle = ObjContratos.ModalidadDetalle
|
|
chkDetalleContrato.Checked = If(ModalidadDetalle = 2, True, False)
|
|
modalidades(ModalidadDetalle)
|
|
|
|
CargaGVGastos()
|
|
|
|
DdlMoneda.SelectedValue = ObjContratos.CveMoneda.ToString
|
|
If DdlMoneda.SelectedIndex > 0 Then
|
|
tipoCambio.Visible = True
|
|
End If
|
|
|
|
'AFU.Visible = False
|
|
|
|
'TxtArchivo.Text = ObjContratos.Archivo.ToString
|
|
TxtImporte.Text = "" 'ObjContratos.Importe.ToString
|
|
'ChkEstatusContrato.Checked = CBool(ObjContratos.EstatusContrato)
|
|
DdlContratoPadre.SelectedValue = ObjContratos.CveContratoPadre.ToString
|
|
LblFechaCaptura.Text = ObjContratos.FechaIng.ToShortDateString
|
|
'HplSecciones.NavigateUrl = "/Contratos/ContratosSecciones.aspx?CveContrato=" & CveContrato
|
|
'CargaDatosPresup()
|
|
|
|
CargaPresupuesto()
|
|
MuestraPermiteAvance()
|
|
cargarBitacora()
|
|
|
|
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)
|
|
'A2.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CONTRATO&CveEmpresa={0}&Archivo={1}", ObjContratos.CveEmpresa, ViewState("FUrl").ToString)))
|
|
BtnDescargar.Visible = True
|
|
Else
|
|
BtnDescargar.Visible = False
|
|
A1.Visible = True
|
|
End If
|
|
|
|
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
|
|
|
|
UPAFUL.Update()
|
|
UpProyecto.Update()
|
|
ObjContratos.Dispose()
|
|
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, UsuarioActual.CveEmpresa) 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"))
|
|
|
|
GvInt.DataSource = TmpDT.FiltraParametros("CveTipoPresupuesto=1")
|
|
GvInt.DataBind()
|
|
|
|
UpGV.Update()
|
|
UPGVInt.Update()
|
|
LbTotalGeneral.Text = TmpDT.FiltraParametros("CveTipoPresupuesto=2").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
|
|
#End Region
|
|
|
|
|
|
#Region " GUARDAR "
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
|
Dim ObjContratos As New ClsContratos
|
|
Dim ObjInventarios As New ClsInventarios(ObjContratos.IniciaTransacSQL)
|
|
|
|
Dim TieneError = False
|
|
Dim Modificado = False
|
|
Dim isnew = False
|
|
' Dim Extension = Session("FileExtension").ToString
|
|
Dim Archivo = Session("FileUpload").ToString
|
|
Dim Ruta = Session("FileFolder").ToString
|
|
|
|
Dim Minimo, Maximo, Total As Double
|
|
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
|
|
|
|
|
|
If DdlMoneda.SelectedIndex > 0 Then
|
|
If TxtTipoCambio.Text.Trim.Length = 0 Or TxtTipoCambio.Text.Trim.ToDouble = 0.0 Then
|
|
Alert("Cuando seleccione una moneda diferencte a peso debe especificar el tipo de cambio.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
|
|
'Crear Contrato
|
|
If Not 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
|
|
|
|
CveContrato = ObjContratos.AddContratos(TxtNumeroContrato.Text, TxtDescripcionContrato.Text, DdlContratista.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero, -1, TxtFechaInicial.Text.ToDate, TxtFechaFinal.Text.ToDate,
|
|
TxtUbicacion.Text, TxtResponsable.Text, DdlSubProyectoContrato.SelectedValue.ToEntero, TxtPorIVA.Text.ToDouble, TxtPorAnticipo.Text.ToDouble, TxtPorAmortizacionAnticipo.Text.ToDouble,
|
|
TxtPorGarantia.Text.ToDouble, "." & Session("FileExtension").ToString, "", DdlContratoPadre.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, Minimo, Maximo, Total,
|
|
DdlMoneda.SelectedValue.ToEntero, ModalidadDetalle, DdlEstatus.SelectedValue.ToEntero, TipoContrato, TxtTipoCambio.Text.ToDouble, CveSucursalCliente:=DdlSucursalCliente.SelectedValue.ToEntero, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero, PorcentajeComision:=TxtPorcentajeComision.Text.ToEntero,
|
|
TipoGarantia:=DdlTipoGarantia.SelectedValue.ToEntero, Folio:=TxtFolio.Text.ToEntero, FechaVenc:=txtFechaVenc.Text.ToDate, EstatusFianza:=DdlEstatusFianza.SelectedValue.ToEntero)
|
|
|
|
If CveContrato > 0 Then
|
|
isnew = True
|
|
'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(UsuarioActual.Empresa.Ruta & "Contratos") Then
|
|
Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "Contratos")
|
|
End If
|
|
Ruta = UsuarioActual.Empresa.Ruta & "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
|
|
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
Else
|
|
Modificado = True
|
|
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
|
|
Dim ArchivoUpdate As String = "-1"
|
|
|
|
If Session("FileExtension").ToString <> "" Then
|
|
ArchivoUpdate = "." & Session("FileExtension").ToString
|
|
Else
|
|
|
|
End If
|
|
|
|
If ObjContratos.UpdateContratos(CveContrato, TxtNumeroContrato.Text, TxtDescripcionContrato.Text, DdlContratista.SelectedValue.ToEntero, DdlCliente.SelectedValue.ToEntero, -1, TxtFechaInicial.Text.ToDate, TxtFechaFinal.Text.ToDate,
|
|
TxtUbicacion.Text, TxtResponsable.Text, DdlSubProyectoContrato.SelectedValue.ToEntero, TxtPorIVA.Text.ToDouble, TxtPorAnticipo.Text.ToDouble, TxtPorAmortizacionAnticipo.Text.ToDouble,
|
|
TxtPorGarantia.Text.ToDouble, ArchivoUpdate, "", DdlContratoPadre.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, False, Minimo, Maximo, Total, DdlMoneda.SelectedValue.ToEntero,
|
|
ModalidadDetalle, DdlEstatus.SelectedValue.ToEntero, TipoContrato, TxtTipoCambio.Text.ToDouble, CveSucursalCliente:=DdlSucursalCliente.SelectedValue.ToEntero, CveAlmacen:=DdlAlmacen.SelectedValue.ToEntero, PorcentajeComision:=TxtPorcentajeComision.Text.ToEntero,
|
|
TipoGarantia:=DdlTipoGarantia.SelectedValue.ToEntero, Folio:=TxtFolio.Text.ToEntero, FechaVenc:=txtFechaVenc.Text.ToDate, EstatusFianza:=DdlEstatusFianza.SelectedValue.ToEntero) 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(UsuarioActual.Empresa.Ruta & "Contratos") Then
|
|
Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "Contratos")
|
|
End If
|
|
Ruta = UsuarioActual.Empresa.Ruta & "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
|
|
' System.IO.File.Move(Archivo, String.Format("{0}{1}{2}", Ruta, CveContrato.ToString, Extension))
|
|
End If
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
'If Not TieneError Then
|
|
' TieneError = GuardarAlmacen(ObjInventarios)
|
|
'End If
|
|
|
|
If TieneError Then
|
|
ObjContratos.RollBack()
|
|
|
|
If Modificado Then
|
|
Alert("Ocurrió un Error al modificar el contrato. Por favor intente nuevamente.", TipoMensaje.MsgError)
|
|
Else
|
|
Alert("Ocurrió un Error al guardar el contrato. Por favor intente nuevamente.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
Else
|
|
ObjContratos.Commit()
|
|
|
|
If isnew Then
|
|
If ObjContratos.GetContratos(-1, -1) Then
|
|
Application("GlobalDTContratos") = ObjContratos.DtResultados
|
|
End If
|
|
End If
|
|
|
|
Limpiar()
|
|
If Modificado Then
|
|
Alert("El Contrato se modificó Correctamente.", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/Contrato.aspx?CveContrato={0}""", CveContrato))
|
|
Else
|
|
Alert("El Contrato se registró Correctamente.", TipoMensaje.MsgInformacion, String.Format("document.location.href=""/Contratos/Contrato.aspx?CveContrato={0}""", CveContrato))
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
UpGral.Update()
|
|
ObjContratos.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "INICIO DE PAGINA"
|
|
Protected Sub DdlTipoContrato_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
If DdlTipoContrato.SelectedIndex = 0 Then
|
|
TxtDescripcionTipoContrato.Text = ""
|
|
Exit Sub
|
|
End If
|
|
|
|
TipoContrato = DdlTipoContrato.SelectedValue.ToEntero
|
|
TxtDescripcionTipoContrato.Text = GlobalDTContratosTipos.FiltraParametros("CveContratoTipo = " & DdlTipoContrato.SelectedValue)(0)("Descripcion").ToString()
|
|
TxtDescripcionTipoContrato.Visible = True
|
|
|
|
CargaContratoPadre()
|
|
UpProyecto.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub modalidades(modalidadDetalleInt As Integer)
|
|
|
|
If modalidadDetalleInt = 1 Then
|
|
ModalidadDetalle = 1
|
|
|
|
DvMax.Visible = False
|
|
DvMin.Visible = False
|
|
DvTotal.Visible = False
|
|
'TxtCantidad.Visible = True
|
|
|
|
If CveContrato > 0 Then
|
|
End If
|
|
|
|
ElseIf modalidadDetalleInt = 2 Then
|
|
ModalidadDetalle = 2
|
|
|
|
DvMax.Visible = True
|
|
DvMin.Visible = True
|
|
DvTotal.Visible = True
|
|
'TxtCantidad.Visible = False
|
|
|
|
If CveContrato > 0 Then
|
|
TableDatosCabecera.Visible = True
|
|
End If
|
|
|
|
End If
|
|
|
|
UpGral.Update()
|
|
|
|
End Sub
|
|
Protected Sub chkDetalleContrato_CheckedChanged(sender As Object, e As EventArgs)
|
|
If chkDetalleContrato.Checked = False Then
|
|
modalidades(1)
|
|
Else
|
|
modalidades(2)
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnTipoContrato_Click(sender As Object, e As EventArgs) Handles BtnTipoContrato.Click
|
|
If DdlTipoContrato.SelectedIndex = 0 Then
|
|
Alert("Tiene que seleccionar un tipo de Contrato.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
DivTipoContrato.Visible = False
|
|
|
|
If rdventa.Checked Then
|
|
DdlCliente.Visible = True
|
|
TrCliente.Visible = True
|
|
|
|
DdlContratista.Visible = False
|
|
TrProveedor.Visible = False
|
|
|
|
|
|
Else
|
|
DdlCliente.Visible = False
|
|
TrCliente.Visible = False
|
|
|
|
TrProveedor.Visible = True
|
|
DdlContratista.Visible = True
|
|
End If
|
|
|
|
If rdventa.Checked Then
|
|
cargaClientes()
|
|
Else
|
|
CargaContratista()
|
|
End If
|
|
|
|
DivContent.Visible = True
|
|
ConfiguraTipos()
|
|
|
|
|
|
UpGral.Update()
|
|
UPTipo.Update()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "TAB INFORMACION GENERAL"
|
|
|
|
'Protected Sub CargarArchivo(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles AFU.UploadedComplete
|
|
' If AFU.HasFile Then
|
|
' If Not Directory.Exists(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Temp") Then
|
|
' Directory.CreateDirectory(ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Temp")
|
|
' End If
|
|
' Dim UploadFolder As String = ModExtensiones.DirectorioBaseEmpresas + "Empresas\" & UsuarioActual.CveEmpresa & "\Temp\"
|
|
' Dim Extension As String = System.IO.Path.GetExtension(AFU.PostedFile.FileName)
|
|
|
|
' If System.IO.File.Exists(UploadFolder & UsuarioActual.CveUsuario.ToString & Extension) Then
|
|
' System.IO.File.Delete(UploadFolder & UsuarioActual.CveUsuario.ToString & Extension)
|
|
' End If
|
|
|
|
' AFU.SaveAs(UploadFolder & UsuarioActual.CveUsuario.ToString & Extension)
|
|
' Session("FileUpload") = UploadFolder & UsuarioActual.CveUsuario.ToString & Extension
|
|
' Session("FileExtension") = Extension
|
|
' Session("FileFolder") = UploadFolder
|
|
' End If
|
|
'End Sub
|
|
|
|
|
|
#Region "COMBOS - INFO GENERAL"
|
|
Private Sub CargaProyecto()
|
|
If UsuarioActual.Empresa.GralSoloProyecto Then
|
|
CargaSubProyectoContrato(-1)
|
|
trddlproyecto.Visible = False
|
|
lblsubproyecto.Text = "Proyecto"
|
|
Else
|
|
DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa)
|
|
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", "SubProyecto2"})
|
|
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 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
|
|
#End Region
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " 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"))
|
|
|
|
|
|
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 = GlobalDTProductosServicios(UsuarioActual.CveEmpresa)
|
|
DdlProductows.DataBind()
|
|
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)
|
|
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
|
|
Dim filtro As String = ""
|
|
If Not (DdlClasificacionAdd.SelectedValue = "-1") Then
|
|
|
|
If isWhitFamily() Then
|
|
filtro = String.Format("CveSubFamilia={0}", DdlClasificacionAdd.SelectedValue)
|
|
Else
|
|
filtro = String.Format("CveClasificacion={0}", DdlClasificacionAdd.SelectedValue)
|
|
End If
|
|
End If
|
|
DdlProductows.DataSource = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltraParametros(filtro, "PS")
|
|
DdlProductows.DataBind()
|
|
DdlProductows.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
Else
|
|
If isWhitFamily() Then
|
|
DdlProductows.ddlWS.Attributes.Add("data-idSubFamilia", DdlClasificacionAdd.SelectedValue)
|
|
Else
|
|
DdlProductows.ddlWS.Attributes.Add("data-idClasificacion", DdlClasificacionAdd.SelectedValue)
|
|
End If
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
#Region " TAB PRESUPUESTOS "
|
|
Private Sub CargaGVPresupuestos(DtTemp As DataTable)
|
|
|
|
Gv.DataSource = DtTemp
|
|
Gv.DataBind()
|
|
|
|
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)
|
|
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
|
|
|
|
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) 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
|
|
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
|
|
UpGV.Update()
|
|
TxtCantidad.Text = ""
|
|
TxtPU.Text = ""
|
|
DdlClasificacionAdd.SelectedValue = "-1"
|
|
LbTotalGeneral.Text = (LbTotalGeneral.Text.ToDouble + TotalRow).ToString.FormatoNumero
|
|
LblImporte.Text = LbTotalGeneral.Text
|
|
TxtCantidad.Focus()
|
|
UpGral.Update()
|
|
Else
|
|
Alert("Ocurrio un error al agregar el detalle", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
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)
|
|
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 = ""
|
|
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
|
|
|
|
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 Then
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.UpdateContratosDetalle(CveContratoDetalle, CveContrato, CvePS, Cantidad, PU, UsuarioActual.CveUsuario, NoIdentificacion) 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
|
|
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
|
|
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 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
|
|
|
|
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) 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()
|
|
TxtNoIdentificacionv.Text = ""
|
|
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 = ""
|
|
'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
|
|
|
|
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) 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 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
|
|
|
|
|
|
#Region " ARCHIVO "
|
|
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=" & File.Name)
|
|
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
|
|
|
|
|
|
#Region "E V E N T O - B I T A C O R A"
|
|
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)
|
|
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
|
|
|
|
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("{0}OI", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
|
|
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
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " REPORTE AVANCES "
|
|
Private Sub CargaDatosAvance()
|
|
If CveContrato <= 0 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
TabReporteAvance.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.GetReporteContratosAvancesDetalleCP(CveContrato) Then
|
|
GvDatosAvance.DataSource = 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
|
|
|
|
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 MuestaModalVentasAvance(sender As Object, e As EventArgs)
|
|
Dim Btn = CType(sender, LinkButton)
|
|
Dim Parametros = Btn.CommandArgument.Split("|"c)
|
|
|
|
Dim ObjContratos As New ClsContratos
|
|
|
|
If ObjContratos.GetVentasAvance(CveContrato, If(Parametros(0).ToEntero > 0, Parametros(0).ToEntero, -1), If(Parametros(2).ToEntero > 0, Parametros(2).ToEntero, -1), If(Parametros(4).ToEntero > 0, Parametros(4).ToEntero, -1)) Then
|
|
GvDatosVentasAvance.DataSource = ObjContratos.DtResultados
|
|
RegistraScript("$('#ModalVentasAvance').modal('show');RecargaAvances = true;")
|
|
Else
|
|
Alert("Ocurrió un error al obtener el Listado de Ventas/Remisiones de Avance. Por favor vuelva a intentar", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContratos.Dispose()
|
|
GvDatosVentasAvance.DataBind()
|
|
|
|
|
|
LbTituloModalVentasAvance.Text = If(Parametros(4).ToEntero = 1, "Ventas de Avance", "Remisiones de Avance")
|
|
LbClasificacionVentasAvance.Text = Parametros(1)
|
|
LbPSVentasAvance.Text = If(Parametros(2).ToEntero > 0, Parametros(3), "")
|
|
|
|
UpVentasAvance.Update()
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " 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
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "C O N T R A T O S G A S T O S"
|
|
|
|
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
|
|
TxtDescripcion.Text = ""
|
|
TxtImporteC.Text = ""
|
|
TxtFecha.Text = ""
|
|
Alert("El Gasto del contrato se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
CargaGVGastos()
|
|
End If
|
|
ObjContrato.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaGVGastos()
|
|
Dim objContrato As New ClsContratos
|
|
If objContrato.GetContratoGastos(CveContrato) Then
|
|
GvContratosGastos.DataSource = objContrato.DtResultados
|
|
GvContratosGastos.DataBind()
|
|
Else
|
|
GvContratosGastos.DataSource = Nothing
|
|
End If
|
|
objContrato.Dispose()
|
|
|
|
If GvContratosGastos.Rows.Count > 0 Then
|
|
GvContratosGastos.HeaderRow.CssClass = "SinColor"
|
|
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 Then
|
|
e.Row.CssClass = "SubTotales"
|
|
e.Row.FCLinkButton("imgE").Visible = False
|
|
e.Row.FCLinkButton("imgD").Visible = False
|
|
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
|
|
#End Region
|
|
|
|
|
|
#Region " ALMACEN - ACTIVOS FIJOS "
|
|
Private Sub CargaInventarios()
|
|
|
|
Dim ObjInventarios As New ClsInventarios
|
|
'cargar también los movimentos detalle
|
|
If ObjInventarios.GetMovimientosDetalleContrato(CveContrato, UsuarioActual.CveEmpresa) 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()
|
|
BtnDevolucionAlmacen.Visible = True
|
|
|
|
CveMovimientoDevolucion = -1
|
|
If CveMovimientoDevolucion > 0 Then
|
|
HLSurtirAF.Visible = False
|
|
BtnDevolucionAlmacen.Visible = False
|
|
End If
|
|
|
|
Else
|
|
DivSinRegistrosAlmacen.Visible = True
|
|
End If
|
|
|
|
|
|
|
|
'CARGA MODALIDAD ALMACEN
|
|
If TipoContrato = 8 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
|
|
|
|
Private Sub CargaGVDatosInventarios()
|
|
GvDatosAlmacen.DataSource = DtMovimientos
|
|
GvDatosAlmacen.DataBind()
|
|
|
|
If (GvDatosAlmacen.Rows.Count > 0) Then
|
|
GvDatosAlmacen.UseAccessibleHeader = True
|
|
GvDatosAlmacen.HeaderRow.TableSection = TableRowSection.TableHeader
|
|
RegistraScript("OrdenarGVAlmacen();")
|
|
End If
|
|
|
|
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 = ""
|
|
|
|
Dim Texto = $"Folio Venta: <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>")
|
|
Texto += If(e.Row.DBCampo("CveMovimientoDevolucion").ToString = "", If(e.Row.DBCampo("EsDevolucionVenta").ToString = "1", " | PENDIENTE DE DEVOLUCIÓN", ""), $" | Folio Devolución Almacén: <b><a href ='/Inventarios/EntradasSalidas.aspx?CveMovimiento={e.Row.DBCampo("CveMovimientoDevolucion")}' target='_blank'>{e.Row.DBCampo("FolioDevolucion")}</a></b>")
|
|
e.Row.Cells(1).Text = Texto
|
|
End If
|
|
|
|
If e.Row.DBCampo("SerieLote").ToString = "-1" Then
|
|
e.Row.Cells(2).Text = ""
|
|
End If
|
|
End If
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " SUCURSAL CLIENTES "
|
|
Protected Sub DdlCliente_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
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
|
|
End If
|
|
|
|
ObjCliente.Dispose()
|
|
|
|
CargaContratoPadre()
|
|
UpProyecto.Update()
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#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
|
|
#End Region
|
|
|
|
|
|
#Region " ELIMINAR "
|
|
Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
|
|
Dim objContratos As New ClsContratos
|
|
|
|
If objContratos.RemoveContarto(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 CONTRATO "
|
|
Protected Sub LBTerminarContrato_Click(sender As Object, e As EventArgs)
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.TerminarContrato(CveContrato, UsuarioActual.CveEmpresa) 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
|
|
#End Region
|
|
|
|
|
|
#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
|
|
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))
|
|
|
|
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
|
|
Private Sub LBImprimirInformacionG_Click(sender As Object, e As EventArgs) Handles LBImprimirInformacionG.Click
|
|
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
|
|
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 DEL CONTRATO
|
|
params.Add(New ReportParameter("NoContrato", TxtNumeroContrato.Text.Trim))
|
|
params.Add(New ReportParameter("Descripcion", TxtDescripcionContrato.Text.Trim))
|
|
params.Add(New ReportParameter("Proveedor", If(TrProveedor.Visible = True, DdlContratista.SelectedItem.Text.Trim, "-")))
|
|
params.Add(New ReportParameter("Ubicacion", TxtUbicacion.Text.Trim))
|
|
params.Add(New ReportParameter("Responsable", TxtResponsable.Text.Trim))
|
|
params.Add(New ReportParameter("Almacen", If(RowAlmacen.Visible = True, DdlAlmacen.SelectedItem.Text.Trim, "-")))
|
|
params.Add(New ReportParameter("Porcentaje", If(RowPorcentajeComision.Visible = True, TxtPorcentajeComision.Text.Trim, "-")))
|
|
'CENTRO DE COSTOS
|
|
params.Add(New ReportParameter("Proyecto", If(trddlproyecto.Visible = True, DdlProyecto.SelectedItem.Text.Trim, "-")))
|
|
params.Add(New ReportParameter("SubProyecto", DdlSubProyectoContrato.SelectedItem.Text.Trim))
|
|
params.Add(New ReportParameter("Addendum", If(DdlContratoPadre.SelectedItem.Text.Trim = "Seleccione", "", DdlContratoPadre.SelectedItem.Text.Trim)))
|
|
'INFORMACION
|
|
params.Add(New ReportParameter("Cliente", If(TrCliente.Visible = True, DdlCliente.SelectedItem.Text.Trim, "-")))
|
|
params.Add(New ReportParameter("Sucursal", If(TrClienteSucursal.Visible = True, DdlSucursalCliente.SelectedItem.Text.Trim, "-")))
|
|
params.Add(New ReportParameter("FechaInicial", TxtFechaInicial.Text.Trim))
|
|
params.Add(New ReportParameter("FechaFinal", TxtFechaFinal.Text.Trim))
|
|
params.Add(New ReportParameter("Moneda", DdlMoneda.SelectedItem.Text.Trim))
|
|
params.Add(New ReportParameter("TipoCambio", If(tipoCambio.Visible = True, TxtTipoCambio.Text.Trim, "-")))
|
|
params.Add(New ReportParameter("IVA", TxtPorIVA.Text.Trim))
|
|
params.Add(New ReportParameter("Anticipo", TxtPorAnticipo.Text.Trim))
|
|
params.Add(New ReportParameter("Amortizacion", TxtPorAmortizacionAnticipo.Text.Trim))
|
|
params.Add(New ReportParameter("Garantia", TxtPorGarantia.Text.Trim))
|
|
params.Add(New ReportParameter("Minimo", If(DvMin.Visible = True, txtMinimo.Text.Trim, "-")))
|
|
params.Add(New ReportParameter("Maximo", If(DvMax.Visible = True, txtMaximo.Text.Trim, "-")))
|
|
params.Add(New ReportParameter("Total", If(DvTotal.Visible = True, TxtTotal.Text.Trim, "-")))
|
|
'Estatus
|
|
params.Add(New ReportParameter("Estatus", DdlEstatus.SelectedItem.Text.Trim))
|
|
params.Add(New ReportParameter("TipoGarantia", DdlTipoGarantia.SelectedItem.Text.Trim))
|
|
params.Add(New ReportParameter("EstatusFianza", DdlEstatusFianza.SelectedItem.Text.Trim))
|
|
params.Add(New ReportParameter("Folio", TxtFolio.Text.Trim))
|
|
params.Add(New ReportParameter("FechaVencimiento", txtFechaVenc.Text.Trim))
|
|
|
|
If Imagen.Exists Then
|
|
params.Add(New ReportParameter("LogoPath", logouri))
|
|
Else
|
|
params.Add(New ReportParameter("LogoPath", ""))
|
|
End If
|
|
ImprimirPDF("Empresas/Grales/Formatos/Contrato.rdlc", dt, params, $"Contrato-{Titulo}", Formato:="PDF")
|
|
|
|
End Sub
|
|
|
|
Private Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
|
|
DescargarArchivo()
|
|
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 Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
|
|
Dim dt As New DataTable
|
|
Dim Conexion As Odbc.OdbcConnection = Nothing
|
|
Dim ErrorArchivo = False
|
|
|
|
Try
|
|
Select Case Tipo
|
|
Case "EXCEL"
|
|
Conexion = New Odbc.OdbcConnection("Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" + Ruta + FileName + ";")
|
|
Conexion.Open()
|
|
Dim cmd = Conexion.CreateCommand()
|
|
cmd.CommandType = CommandType.Text
|
|
cmd.CommandText = "SELECT * FROM [Hoja1$]"
|
|
Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd)
|
|
DataAdapter.Fill(dt)
|
|
Case Else
|
|
Alert("El archivo no tiene el formato correcto", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End Select
|
|
Catch ex As Exception
|
|
ErrorArchivo = True
|
|
OnError("Ocurrio un error al leer el archivo <br/>" & ex.Message, ex)
|
|
End Try
|
|
Conexion.Close()
|
|
If Not ErrorArchivo Then
|
|
If Not dt.Columns(0).ColumnName = "Cantidad" Then
|
|
Alert("El nombre de la primera columna debe ser 'Cantidad'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(1).ColumnName = "Clave Interna" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Clave Interna'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(2).ColumnName = "Código" Then
|
|
Alert("El nombre de la tercera columna debe ser 'Código'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(3).ColumnName = "Código Barras" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Código Barras'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(4).ColumnName = "Producto/Servicio" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Producto/Servicio'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(5).ColumnName = "UM" Then
|
|
Alert("El nombre de la sexta columna debe ser 'U.M'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(6).ColumnName = "Precio Unitario" Then
|
|
Alert("El nombre de la septima columna debe ser 'Precio Unitario'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
dt.TableName = "Datos"
|
|
|
|
If Not ErrorArchivo Then
|
|
NumRow = 1
|
|
Dim RowNoEncontrados As String = String.Empty
|
|
Dim NumAgregados As Integer = 0
|
|
For Each Row As DataRow In dt.Rows
|
|
Dim Cantidad As Integer = Row("Cantidad").ToString.ToEntero
|
|
Dim Codigo As String = Row("Código").ToString.Trim.ToUpper
|
|
Dim CodigoBarras As String = Row("Código Barras").ToString.Trim.ToUpper
|
|
Dim UM As String = Row("UM").ToString
|
|
Dim ClaveInterna As String = Row("Clave Interna").ToString.Trim.ToUpper
|
|
Dim ProductoServicio As String = Row("Producto/Servicio").ToString.Trim.ToUpper
|
|
Dim PrecioUnitario As Double = Row("Precio Unitario").ToString.ToDouble
|
|
Dim CvePS As Integer = 0
|
|
Dim CveUM As Integer = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero
|
|
Dim CodigoPS As Integer = 0
|
|
Dim Total As Double = (Cantidad * PrecioUnitario)
|
|
|
|
|
|
NumRow = NumRow + 1
|
|
|
|
If Codigo.Length > 0 Then
|
|
Dim StrArray() As String = GetPS("Codigo", Codigo).Split("|"c)
|
|
If StrArray.Length > 0 Then
|
|
If CBool(StrArray(0)) = True Then
|
|
CvePS = StrArray(1).ToEntero
|
|
Else
|
|
RowNoEncontrados &= StrArray(1) & "<\BR>"
|
|
End If
|
|
End If
|
|
ElseIf CodigoBarras.Length > 0 Then
|
|
Dim StrArray() As String = GetPS("CodigoBarras", CodigoBarras).Split("|"c)
|
|
If StrArray.Length > 0 Then
|
|
If CBool(StrArray(0)) = True Then
|
|
CvePS = StrArray(1).ToEntero
|
|
Else
|
|
RowNoEncontrados &= StrArray(1) & "<\BR>"
|
|
End If
|
|
End If
|
|
ElseIf ProductoServicio.Length > 0 Then
|
|
Dim StrArray() As String = GetPS("PS", ProductoServicio).Split("|"c)
|
|
If StrArray.Length > 0 Then
|
|
If CBool(StrArray(0)) = True Then
|
|
CvePS = StrArray(1).ToEntero
|
|
Else
|
|
RowNoEncontrados &= StrArray(1) & "<\BR>"
|
|
End If
|
|
End If
|
|
Else
|
|
RowNoEncontrados &= "<\BR> - En la fila " & NumRow & " no se especificó código, código de barras ó descripción."
|
|
End If
|
|
CveUM = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveUnidadMedida", $"CvePS = '{CvePS}'").ToString.ToEntero
|
|
|
|
If TmpDT IsNot Nothing Then
|
|
Dim dr As DataRow = TmpDT.NewRow
|
|
dr("Cantidad") = Cantidad
|
|
dr("CantidadContratada") = Cantidad
|
|
dr("CveUM") = CveUM
|
|
dr("UM") = UM
|
|
dr("CveClasificacion") = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", $"CvePS = '{CvePS}'").ToString.ToEntero
|
|
dr("Clasificacion") = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Clasificacion", $"CveClasificacion = '{dr("CveClasificacion")}'").ToString
|
|
dr("CvePS") = CvePS
|
|
dr("PS") = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("PS", $"CvePS = '{dr("CvePS")}'").ToString
|
|
dr("CodigoPS") = dr("PS")
|
|
dr("PU") = PrecioUnitario
|
|
dr("Total") = Cantidad * PrecioUnitario
|
|
dr("CveTipoPresupuesto") = 2
|
|
dr("NoIdentificacion") = ClaveInterna
|
|
|
|
|
|
If CvePS > 0 Then
|
|
Dim ObjContratos As New ClsContratos
|
|
If ObjContratos.AddContratosDetalle(CveContrato, dr("CvePS").ToString.ToEntero, dr("Cantidad").ToString.ToDouble, dr("PU").ToString.ToDouble, UsuarioActual.CveUsuario, dr("CveTipoPresupuesto").ToString.ToEntero, dr("NoIdentificacion").ToString) Then
|
|
Dim msj As String = String.Format("Se agregaron {0} {1} del producto {2} con un precio ${3}.", dr("Cantidad"), dr("UM"), dr("PS"), dr("PU"))
|
|
guardarBitacora(msj)
|
|
dr("CveContratoDetalle") = ObjContratos.DtResultados.Rows(0)("CveContratoDetalle")
|
|
TmpDT.Rows.Add(dr)
|
|
Dim TotalRow = dr("Total").ToString.ToDouble
|
|
|
|
CargaGVPresupuestos(TmpDT.FiltraParametros("CveTipoPresupuesto=2"))
|
|
LbTotalGeneral.Text = (LbTotalGeneral.Text.ToDouble + TotalRow).ToString.FormatoNumero
|
|
LblImporte.Text = LbTotalGeneral.Text
|
|
Else
|
|
Alert("Ocurrio un error al agregar el detalle", TipoMensaje.MsgError)
|
|
End If
|
|
ObjContratos.Dispose()
|
|
End If
|
|
|
|
|
|
End If
|
|
Next
|
|
'Cargo el GridView
|
|
Gv.DataSource = TmpDT
|
|
Gv.DataBind()
|
|
UpGV.Update()
|
|
|
|
|
|
If RowNoEncontrados.Length > 0 Then
|
|
Alert("Los siguientes Productos o Servicios no se encontraron en la Base de Datos.<\BR>" & RowNoEncontrados, TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
Alert("Se Cargaron " & NumRow & " Productos o Servicios correctamente.")
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Function GetPS(Opt As String, Valor As String) As String
|
|
Dim StrReturn As String = String.Empty
|
|
Dim CvePS As Integer = 0
|
|
CvePS = GlobalDTProductosServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CvePS", Opt & " = '" & Valor & "'").ToString.ToEntero
|
|
If CvePS > 0 Then
|
|
StrReturn = "True|" & CvePS.ToString
|
|
Else
|
|
|
|
StrReturn = "False| - No se encontró " & 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 = ModExtensiones.DirectorioBaseEmpresas & file.path
|
|
Dim Tipo As String = If(file.Extension.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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End Class
|
|
|
|
|