From ba4d3b4937938fa29890f8b5265bdf487295edb6 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 13 May 2020 12:42:30 -0700 Subject: [PATCH] cambios en SeccionesAlmacen,Serie,Lote,Caducidad --- Compras/EvaluacionProveedor.aspx.vb | 2 +- Inventarios/CatSeccionesAlmacenes.aspx.vb | 10 +- Inventarios/KardexSeccionAlmacen.aspx | 140 - Inventarios/KardexSeccionAlmacen.aspx.vb | 337 - Inventarios/RecepcionEntrega.aspx | 1032 -- Inventarios/RecepcionEntrega.aspx.vb | 3112 ---- Ventas/Clientes.aspx.vb | 18654 ++++++++++---------- 7 files changed, 9333 insertions(+), 13954 deletions(-) delete mode 100644 Inventarios/KardexSeccionAlmacen.aspx delete mode 100644 Inventarios/KardexSeccionAlmacen.aspx.vb delete mode 100644 Inventarios/RecepcionEntrega.aspx delete mode 100644 Inventarios/RecepcionEntrega.aspx.vb diff --git a/Compras/EvaluacionProveedor.aspx.vb b/Compras/EvaluacionProveedor.aspx.vb index b842df48b..dfb5f0047 100644 --- a/Compras/EvaluacionProveedor.aspx.vb +++ b/Compras/EvaluacionProveedor.aspx.vb @@ -334,7 +334,7 @@ Partial Class Compras_EvaluacionProveedor ListaTagsDocumentost.Add(New TagsDocumentos("{{Proveedor}}", Proveedor)) ListaTagsDocumentost.Add(New TagsDocumentos("{{Dia}}", Dia)) ListaTagsDocumentost.Add(New TagsDocumentos("{{Mes}}", Mes)) - ListaTagsDocumentost.Add(New TagsDocumentos("{{Anio}}", Now.Year)) + ListaTagsDocumentost.Add(New TagsDocumentos("{{Anio}}", Now.Year.ToString)) ListaTagsDocumentost.Add(New TagsDocumentos("{{Calificacion}}", Calificacion)) ListaTagsDocumentost.Add(New TagsDocumentos("{{Resultado}}", Resultado)) 'ListaTagsDocumentost.Add(New TagsDocumentos("{{Usuario}}", UsuarioActual.Nombre)) diff --git a/Inventarios/CatSeccionesAlmacenes.aspx.vb b/Inventarios/CatSeccionesAlmacenes.aspx.vb index 3cbca21f3..15091d1ca 100644 --- a/Inventarios/CatSeccionesAlmacenes.aspx.vb +++ b/Inventarios/CatSeccionesAlmacenes.aspx.vb @@ -29,9 +29,9 @@ Partial Class Inventarios_CatSeccionesAlmacenes Public Sub CargaDatos() Dim ObjSeccion As New ClsInventarios - If ObjSeccion.GetSeccionesAlmacenes(-1) Then + If ObjSeccion.GetSeccionesAlmacenes(-1, -1) Then ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - GlobalDTSeccionAlmacen(-1) = ObjSeccion.DtResultados + GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) = ObjSeccion.DtResultados Else GvDatos.DataSource = Nothing End If @@ -62,7 +62,7 @@ Partial Class Inventarios_CatSeccionesAlmacenes Alert("La Seccion se guardó correctamente.", TipoMensaje.MsgInformacion) ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - GlobalDTSeccionAlmacen(-1) = ObjSeccion.DtResultados + GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) = ObjSeccion.DtResultados If ViewState("Orden").ToString() <> String.Empty Then CargaGrid(ViewState("Orden").ToString()) @@ -108,7 +108,7 @@ Partial Class Inventarios_CatSeccionesAlmacenes DdlAlmacen.SelectedIndex = 0 Alert("La Seccion se actualizo correctamente.", TipoMensaje.MsgInformacion) ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - GlobalDTSeccionAlmacen(-1) = ObjSeccion.DtResultados + GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) = ObjSeccion.DtResultados End If ObjSeccion.Dispose() @@ -134,7 +134,7 @@ Partial Class Inventarios_CatSeccionesAlmacenes If ObjSeccion.RemoveSeccion(GvRow.DataKey("CveSeccion").ToString.ToEntero) Then Alert("La Seccion se elimino correctamente.", TipoMensaje.MsgInformacion) ViewState("DTSeccionesAlmacenes") = ObjSeccion.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - GlobalDTSeccionAlmacen(-1) = ObjSeccion.DtResultados + GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa, -1) = ObjSeccion.DtResultados End If ObjSeccion.Dispose() If ViewState("Orden").ToString() <> String.Empty Then diff --git a/Inventarios/KardexSeccionAlmacen.aspx b/Inventarios/KardexSeccionAlmacen.aspx deleted file mode 100644 index ff55a29ce..000000000 --- a/Inventarios/KardexSeccionAlmacen.aspx +++ /dev/null @@ -1,140 +0,0 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="KardexSeccionAlmacen.aspx.vb" Inherits="Inventarios_KardexSeccionAlmacen" %> - - - - - - - Kardex Secciones de Almacen - - - - - - - - - - - -
-
-
- - -
-
-
- -
- -
- -
- - -
- -
- - -
-
-
-
-
-
-
-
-
- - - -
- " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
- - - - - - - - - - - - -
-
- - <%--SECCION DE ALMACEN--%> - -
- - - diff --git a/Inventarios/KardexSeccionAlmacen.aspx.vb b/Inventarios/KardexSeccionAlmacen.aspx.vb deleted file mode 100644 index d242ead2e..000000000 --- a/Inventarios/KardexSeccionAlmacen.aspx.vb +++ /dev/null @@ -1,337 +0,0 @@ -Option Strict On -Imports System.Data -Imports System.Collections.Generic -Imports System.Linq -Imports System.Web -Imports System.Web.UI.WebControls -Imports Extensiones -Partial Class Inventarios_KardexSeccionAlmacen - Inherits ClsPaginas - - -#Region "PROPIEDADES" - - Private Property DtSeccionAlmacen As DataTable - Get - Return CType(ViewState("DtSeccionAlmacen"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtSeccionAlmacen") = value - End Set - End Property - Private Property CantidadTotal As Decimal - Get - Return CType(ViewState("CantidadTotal"), Decimal) - End Get - Set(value As Decimal) - ViewState("CantidadTotal") = value - End Set - End Property - Private Property CvePS As Integer - Get - Return CType(ViewState("CvePS"), Integer) - End Get - Set(value As Integer) - ViewState("CvePS") = value - End Set - End Property - Private Property CveSeccionAlmacenOrigen As Integer - Get - Return CType(ViewState("CveSeccionAlmacenOrigen"), Integer) - End Get - Set(value As Integer) - ViewState("CveSeccionAlmacenOrigen") = value - End Set - End Property - Private Property SeccionAlmacenOrigen As String - Get - Return CType(ViewState("SeccionAlmacenOrigen"), String) - End Get - Set(value As String) - ViewState("SeccionAlmacenOrigen") = value - End Set - End Property - Private Property CveAlmacen As Integer - Get - Return CType(ViewState("CveAlmacen"), Integer) - End Get - Set(value As Integer) - ViewState("CveAlmacen") = value - End Set - End Property - Private Property CveUM As Integer - Get - Return CType(ViewState("CveUM"), Integer) - End Get - Set(value As Integer) - ViewState("CveUM") = value - End Set - End Property - Private Property CveSubProyecto As Integer - Get - Return CType(ViewState("CveSubProyecto"), Integer) - End Get - Set(value As Integer) - ViewState("CveSubProyecto") = value - End Set - End Property - Private Property SerieLote As String - Get - Return CType(ViewState("SerieLote"), String) - End Get - Set(value As String) - ViewState("SerieLote") = value - End Set - End Property - - -#End Region - - Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load - If Not IsPostBack Then - InicializaValores() - End If - End Sub - -#Region "CARGAS" - - Private Sub InicializaValores() - CantidadTotal = 0 - SeccionAlmacenOrigen = "" - CvePS = 0 - CveAlmacen = 0 - CveSeccionAlmacenOrigen = 0 - CveSubProyecto = 0 - CveUM = 0 - SerieLote = "" - - CreaDtSeccionAlmacen() - CargaDdlAlmacen() - CargaPS() - End Sub - - Private Sub CargaPS() - DdlPS.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then - DdlPS.ddlWS.Attributes.Add("data-cveclasificacion", "-1") - DdlPS.SelectedText = "Seleccione" - DdlPS.SelectedValue = "-1" - Else - DdlPS.ddl.Items.Clear() - DdlPS.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - DdlPS.ddl.DataBind() - DdlPS.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - End Sub - - Private Sub CargaDdlAlmacen() - DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlAlmacen.DataBind() - - DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacen.Items.Insert(0, New ListItem("Todos", "-1")) - DdlSeccionAlmacen.DataBind() - - DdlSeccionAlmacenDestino.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacenDestino.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccionAlmacenDestino.DataBind() - End Sub - - Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) - CargaDatos() - End Sub - - Private Sub CargaDatos() - If Not DdlPS.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un producto/servicio.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un alamacen.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim ObjInv As New ClsInventarios - If ObjInv.GetKardexSeccionAlmacen(DdlPS.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, DdlSeccionAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then - GvDatos.DataSource = ObjInv.DtResultados - End If - ObjInv.Dispose() - GvDatos.DataBind() - UpDatos.Update() - End Sub - -#End Region - - -#Region "SECCION ALMACEN" - Private Sub CreaDtSeccionAlmacen() - DtSeccionAlmacen = New DataTable - DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenOrigen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacenDestino", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacenOrigen", GetType(String)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacenDestino", GetType(String)) - DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) - End Sub - - Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - DtSeccionAlmacen.Rows.Clear() - CantidadTotal = gvRow.DataKey("Existencia").ToDecimal - CveSeccionAlmacenOrigen = gvRow.DataKey("CveAlmacenSeccion").ToEntero - SeccionAlmacenOrigen = gvRow.DataKey("AlmacenSeccion").ToString - CvePS = gvRow.DataKey("CvePS").ToEntero - SerieLote = gvRow.DataKey("SerieLote").ToString - CveAlmacen = gvRow.DataKey("CveAlmacen").ToEntero - CveUM = gvRow.DataKey("CveUM").ToEntero - CveSubProyecto = gvRow.DataKey("CveSubProyecto").ToEntero - RegistraScript("$('#DModalSeccionAlmacen').modal()") - CargaSeccionAlmacen() - End Sub - - Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) - - Dim ObjInv As New ClsInventarios - Dim CantidadDisponible As Decimal = 0 - If ObjInv.GetMovimientosDetalleSeccionesAlmacen(CveSeccionAlmacenOrigen, CveAlmacen, CvePS, UsuarioActual.CveEmpresa) Then - If ObjInv.DtResultados.Rows.Count > 0 Then - CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString.ToDecimal - End If - End If - ObjInv.Dispose() - - CantidadDisponible -= DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") - - If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then - Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: {CantidadDisponible}", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim Row As DataRow = Nothing - DtSeccionAlmacen.AcceptChanges() - Row = DtSeccionAlmacen.NewRow - Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal - Row("CveSeccionAlmacenOrigen") = CveSeccionAlmacenOrigen - Row("SeccionAlmacenOrigen") = SeccionAlmacenOrigen - Row("CveSeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedValue.ToEntero - Row("SeccionAlmacenDestino") = DdlSeccionAlmacenDestino.SelectedItem.Text - Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 - DtSeccionAlmacen.Rows.Add(Row) - DtSeccionAlmacen.AcceptChanges() - CargaSeccionAlmacen() - End Sub - - Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - Dim Index As Integer = 0 - For Each Dr As DataRow In DtSeccionAlmacen.Rows - If Dr("Consec").ToString.ToEntero = gvRow.DataKey("Consec").ToEntero() Then - Exit For - End If - Index += 1 - Next - DtSeccionAlmacen.Rows.RemoveAt(Index) - DtSeccionAlmacen.AcceptChanges() - CargaSeccionAlmacen() - End Sub - - Private Sub CargaSeccionAlmacen() - Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") - GvSeccion.DataSource = DtSeccionAlmacen - GvSeccion.DataBind() - - TxtCantidadSeccion.Text = "" - DdlSeccionAlmacenDestino.SelectedIndex = 0 - Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion - If CantidadRestante = 0 Then - RVTxtCantidad.MaximumValue = "1" - TxtCantidadSeccion.Enabled = False - Else - RVTxtCantidad.MaximumValue = CantidadRestante.ToString - TxtCantidadSeccion.Enabled = True - End If - - UpModalSeccionAlmacen.Update() - End Sub - - Protected Sub BtnTraspasar_Click(sender As Object, e As EventArgs) - Dim ObjInv As New ClsInventarios - ObjInv.IniciaTransacSQL() - Dim TieneError As Boolean = False - Dim MensajeError As String = "" - - 'SALIDA - Dim CveMovimientoSalida As Integer = ObjInv.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 3, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, CveSubProyecto, -1, CveAlmacenDestino:=CveAlmacen) - - If CveMovimientoSalida <= 0 Then - TieneError = True - MensajeError = "Ocurrió un error al guardar el movimiento de salida. Por favor vuelva a intentar." - End If - - Dim Cantidad As Decimal = DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") - - If Not ObjInv.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, 0, -1, SerieLote:=SerieLote) Then - MensajeError = "Ocurrió un error al guardar los detalles del movimiento de salida. Por favor vuelva a intentar." - TieneError = True - Else - If ObjInv.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.Rows - If Not ObjInv.AddMovimientosDetalleSeccionesAlmacen(ObjInv.CveMovimientoDetalle, Dr2("CveSeccionAlmacenOrigen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - TieneError = True - MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - - 'ENTRADA - If Not TieneError Then - Dim CveMovimientoEntrada As Integer = ObjInv.AddMovimiento(CveAlmacen, 2, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, CveSubProyecto, -1, CveMovimientoRelacionado:=CveMovimientoSalida) - - If CveMovimientoEntrada <= 0 Then - MensajeError = "Ocurrió un error al guardar el movimiento de entrada correctamente. Por favor vuelva a intentar." - TieneError = True - Else - If ObjInv.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInv.DtResultados.Rows - If Not ObjInv.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, Dr("Observaciones").ToString) Then - TieneError = True - MensajeError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For - Else - If ObjInv.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.Rows - If Not ObjInv.AddMovimientosDetalleSeccionesAlmacen(ObjInv.CveMovimientoDetalle, Dr2("CveSeccionAlmacenDestino").ToString.ToEntero, Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - TieneError = True - MensajeError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - Next - End If - End If - End If - - If Not TieneError Then - ObjInv.Commit() - Alert("El traspaso se ha hecho correctamente") - CargaDatos() - RegistraScript("$('#DModalSeccionAlmacen').modal('hide')") - Else - ObjInv.RollBack() - Alert(MensajeError, TipoMensaje.MsgError) - End If - - End Sub - -#End Region - - - -End Class diff --git a/Inventarios/RecepcionEntrega.aspx b/Inventarios/RecepcionEntrega.aspx deleted file mode 100644 index 91f95119b..000000000 --- a/Inventarios/RecepcionEntrega.aspx +++ /dev/null @@ -1,1032 +0,0 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RecepcionEntrega.aspx.vb" Inherits="Inventarios_RecepcionEntrega" %> - - - - - - - - Entrega Almacén (Surtir Mercancia) - - - - -
  • -   -
  • -
    - - - - <%--FILTROS--%> - - - -
    -
    -
    -
      -
    • Cliente: - - <%----%> -
    • -
    • Serie-Folio: - - - -
    • -
    -
    -
    - - <%----%> -
    -
    - -
    -
    -
    -
    - - - -
    - -
    - - <%--DATOS DE LA VENTA--%> -
    - - -
    -
    -
    -
    - - Venta a surtir -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - -
    Cliente: - -
    Folio: - - <%----%> -
    Observaciones Grales: - -
    Observaciones Almacén: - -
    -
    -
    -
    -
    -
    -
    - - - <%--DATOS DEL MOVIMIENTO--%> -
    - - -
    -
    -
    -
    - - Datos del movimiento -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    Almacén: - - - -
    Fecha: -
    -
    - - - - - - - - - - - - -
    -
    -
    Guía: - -
    Observaciones: - -
    Transitorio: - -
    - -
    - -
    - -
    - - - -
    -
    -
    -
    -
    -
    -
    -
    - -
    - - - - -
    -
    - - <%--PENDIENTES DE SURTIR--%> -
    -
    -
    -
    - - Ventas por surtir -
    -
    -
    -
    -
    -
    - - - - -   - Sucursal: - - - - - - - - - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - - - <%--ADVERTENCIA--%> -
    -
    -
    - - Información: - -
    -
    -
    - <%--ADVERTENCIA--%> -
    -
    -
    - - Información: - -
    -
    -
    -
    - - - - - - - - - - - - - - -
    -
    -
    -
    -
    - -
    - - - -
    -
    -
    - - Salida de Inventario -
    -
    -
    -
    -
    -
    - -
    -
    -
    - - <%--AGREGAR POR CODIGO DE BARRAS--%> - - -
    -
    - - - - - - -
    - - - - - - - -
    -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - - <%--GV DATOS--%> - - - - - - - - - - - <%-- - - - - - - --%> - - - - - - - - - - - - <%----%> - <%-- - - -
    - -
    - - -
    -
    -
    - -
    - -
    -
    - -
    --%> - <%-- - - - - - --%> - <%----%> - - - - <%----%> - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - -
    -
    -
    - - - - - - -
    -
    - -
    -
    - -
    -
    - - - <%--BOTON GUARDAR--%> - - -
    - -
    -
    - -
    -
    -
    - - - <%--SECCION DE ALMACEN--%> - - - <%--AGREGA POR SERIE--%> - - - - - - - - <%--CANTIDAD ESPECIAL--%> - - - - - - - - - - - <%--CANTIDAD ESPECIAL 2--%> - - - - - - - <%--NUMERO DE GUIA--%> - - - - - - - - <%--MODAL SECCION ALMACEN--%> - - - - - - -
    - - - - - - - diff --git a/Inventarios/RecepcionEntrega.aspx.vb b/Inventarios/RecepcionEntrega.aspx.vb deleted file mode 100644 index 30413d05c..000000000 --- a/Inventarios/RecepcionEntrega.aspx.vb +++ /dev/null @@ -1,3112 +0,0 @@ -Option Strict On -Option Explicit On - -Imports System.Data -Imports System.IO -Imports System.Linq -Imports Extensiones - -Partial Class Inventarios_RecepcionEntrega - Inherits ClsPaginas - -#Region "PROPIEDADES" - Private Property CveVentaAD As Integer - Get - Return CType(ViewState("CveVentaAD"), Integer) - End Get - Set(value As Integer) - ViewState("CveVentaAD") = 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 DtDatosDetalle As DataTable - Get - Return CType(ViewState("DtDatosDetalle"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtDatosDetalle") = value - End Set - End Property - Private Property DtDatosSugerencias As DataTable - Get - Return CType(ViewState("DtDatosSugerencias"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtDatosSugerencias") = value - End Set - End Property - Private Property DtDatosDetalleLote As DataTable - Get - Return CType(ViewState("DtDatosDetalleLote"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtDatosDetalleLote") = value - End Set - End Property - Private Property PSSerieLote As String - Get - Return CType(ViewState("PSSerieLote"), String) - End Get - Set(value As String) - ViewState("PSSerieLote") = value - End Set - End Property - Private Property CveConsecSerieLote As Integer - Get - Return CType(ViewState("CveConsecSerieLote"), Integer) - End Get - Set(value As Integer) - ViewState("CveConsecSerieLote") = 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 EsInterno As Boolean - Get - Return CBool(If(ViewState("EsInterno") Is Nothing, 0, ViewState("EsInterno"))) - End Get - Set(value As Boolean) - ViewState("EsInterno") = value - End Set - End Property - Private Property CveMetodoInventarioLote As Integer - Get - Return CType(ViewState("CveMetodoInventarioLote"), Integer) - End Get - Set(value As Integer) - ViewState("CveMetodoInventarioLote") = value - End Set - End Property - Private Property CveVentaSurtir As Integer - Get - Return CType(ViewState("CveVentaSurtir"), Integer) - End Get - Set(value As Integer) - ViewState("CveVentaSurtir") = value - End Set - End Property - Private Property TipoEstatus As Integer - Get - Return CType(ViewState("TipoEstatus"), Integer) - End Get - Set(value As Integer) - ViewState("TipoEstatus") = value - End Set - End Property - Private Property CveContrato As Integer - Get - Return CType(ViewState("CveContrato"), Integer) - End Get - Set(value As Integer) - ViewState("CveContrato") = value - End Set - End Property - Private Property CveAlmacenTraspasoOrigen As Integer - Get - Return CType(ViewState("CveAlmacenTraspasoOrigen"), Integer) - End Get - Set(value As Integer) - ViewState("CveAlmacenTraspasoOrigen") = value - End Set - End Property - Private Property CveAlmacenTraspasoDestino As Integer - Get - Return CType(ViewState("CveAlmacenTraspasoDestino"), Integer) - End Get - Set(value As Integer) - ViewState("CveAlmacenTraspasoDestino") = value - End Set - End Property - Private Property TipoMovimiento As Integer - Get - Return CType(ViewState("TipoMovimiento"), Integer) - End Get - Set(value As Integer) - ViewState("TipoMovimiento") = value - End Set - End Property - Private Property TipoDocto As String - Get - Return CType(ViewState("TipoDocto"), String) - End Get - Set(value As String) - ViewState("TipoDocto") = value - End Set - End Property - Private Property DtExistencias As DataTable - Get - Return CType(ViewState("DtExistencias"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtExistencias") = value - End Set - End Property - Private Property RowIndexCantidadEspecial As Integer - Get - Return CType(ViewState("RowIndexCantidadEspecial"), Integer) - End Get - Set(value As Integer) - ViewState("RowIndexCantidadEspecial") = value - End Set - End Property - Private Property CantidadEspecialTemp As Decimal - Get - Return CType(ViewState("CantidadEspecialTemp"), Decimal) - End Get - Set(value As Decimal) - ViewState("CantidadEspecialTemp") = value - End Set - End Property - Private Property EsDevolucionVenta As Integer - Get - Return CType(ViewState("EsDevolucionVenta"), Integer) - End Get - Set(value As Integer) - ViewState("EsDevolucionVenta") = value - End Set - End Property - Private Property CveVendedor As Integer - Get - Return CType(ViewState("CveVendedor"), Integer) - End Get - Set(value As Integer) - ViewState("CveVendedor") = value - End Set - End Property - Private Property CveSubProyecto As Integer - Get - Return CType(ViewState("CveSubProyecto"), Integer) - End Get - Set(value As Integer) - ViewState("CveSubProyecto") = value - End Set - End Property - Private Property CveCliente As Integer - Get - Return CType(ViewState("CveCliente"), Integer) - End Get - Set(value As Integer) - ViewState("CveCliente") = value - End Set - End Property - Private Property CveMovimiento As Integer - Get - Return CType(ViewState("CveMovimiento"), Integer) - End Get - Set(value As Integer) - ViewState("CveMovimiento") = value - End Set - End Property - Private Property CveTraspasoSurtir As Integer - Get - Return CType(ViewState("CveTraspasoSurtir"), Integer) - End Get - Set(value As Integer) - ViewState("CveTraspasoSurtir") = value - End Set - End Property - Private Property TipoEntrega As Integer - Get - Return CType(ViewState("TipoEntrega"), Integer) - End Get - Set(value As Integer) - ViewState("TipoEntrega") = value - End Set - End Property - - Private Property DtSeccionAlmacen As DataTable - Get - Return CType(ViewState("DtSeccionAlmacen"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtSeccionAlmacen") = value - End Set - End Property - Private Property IndexSeccionAlmacen As Integer - Get - Return CType(ViewState("IndexSeccionAlmacen"), Integer) - End Get - Set(value As Integer) - ViewState("IndexSeccionAlmacen") = value - End Set - End Property - Private Property CantidadTotal As Decimal - Get - Return CType(ViewState("CantidadTotal"), Decimal) - End Get - Set(value As Decimal) - ViewState("CantidadTotal") = value - End Set - End Property - Private Property CvePS As Integer - Get - Return CType(ViewState("CvePS"), Integer) - End Get - Set(value As Integer) - ViewState("CvePS") = value - End Set - End Property - - Private Property EsDevolucionDirecta As Boolean - Get - Return CBool(If(ViewState("EsDevolucionDirecta") Is Nothing, 0, ViewState("EsDevolucionDirecta"))) - End Get - Set(value As Boolean) - ViewState("EsDevolucionDirecta") = 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 - - InicializaValores() - CargaParametrosAD() - - End If - End Sub - - -#Region " INICIALIZA VALORES " - Private Sub InicializaValores() - TipoEstatus = -1 - CveVendedor = -1 - CveCliente = -1 - CveSubProyecto = -1 - - DtDatosSugerencias = New DataTable - - Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2)" - - If (UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1") Then - DdlClientes.setEsWebService(True) - DdlClientes.Attributes.Add("data-metodo", "getcliente") - DdlClientes.SelectedText = "Todos" - DdlClientes.SelectedValue = "-1" - Else - DdlClientes.setEsWebService(False) - DdlClientes.ddl.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) - DdlClientes.ddl.DataBind() - DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1")) - End If - - If UsuarioActual.CveSubProyecto = 8804 Then - StrAlmacenes = "CveTipoAlmacen IN (1,2,12)" - End If - - DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros(StrAlmacenes) 'GlobalDTAlmacen(UsuarioActual.CveEmpresa) - DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1")) - DdlAlmacen.SelectedValue = "-1" - DdlAlmacen.DataBind() - DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) - - DdlAlmacenTransitorio.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3) - DdlAlmacenTransitorio.DataBind() - DdlAlmacenTransitorio.Items.Insert(0, New ListItem("Seleccione", "-1")) - - DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1")) - - TxtFechaPendientes.Text = Now.ToShortDateString - TxtFechaCaducidad.Text = Now.ToShortDateString - TxtFecha.Text = Now.ToShortDateString - RVFecha.MaximumValue = MaxFecha.ToShortDateString - If UsuarioActual.CveEmpresa.Contiene(119) Then RVFecha.MinimumValue = Now.ToShortDateString : CEFecha.StartDate = Now Else RVFecha.MinimumValue = MinFecha.ToShortDateString - - If Not UsuarioActual.TienePermisoProceso(190) Then - 'CARGA SOLO LAS SUCURSALES DE LOS ALMCENES QUE TIENE ASIGNADO EL USUARIO - Dim ObjInventarios As New ClsInventarios - If ObjInventarios.GetSucursalesAlmacenUsuario(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - DdlSubProyectos.DataSource = ObjInventarios.DtResultados - End If - ObjInventarios.Dispose() - Else - DdlSubProyectos.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) - End If - DdlSubProyectos.DataBind() - DdlSubProyectos.SelectedValueExist(UsuarioActual.CveSubProyecto.ToString) - - If UsuarioActual.TienePermisoProceso(152) Then DdlSubProyectos.Enabled = False - - CreaDtDetalle() - CreaDtDetalleLote() - CargaPendientes() - - CantidadTotal = 0 - IndexSeccionAlmacen = 0 - CvePS = 0 - CreaDtSeccionAlmacen() - CargaDdlAlmacen() - - LnkVerSecciones.Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" - - End Sub - -#End Region - - -#Region " CARGA PARAMETROS - EXCLUSIVO USO AD " - Private Sub CargaParametrosAD() - - CveVentaAD = -1 - - If UsuarioActual.CveUsuario <> 100 Then - Exit Sub - End If - - If Not IsNothing(Request("CveVenta")) AndAlso IsNumeric(Request("CveVenta")) Then - CveVentaAD = Request("CveVenta").ToEntero - CargaVentaPorSurtir(Request("CveVenta").ToEntero) - LbSurtida.Visible = True - LbSurtida.Text = "SOLO MODO VISUAL" - BtnGuardar.Visible = False - End If - - End Sub -#End Region - -#Region " CARGA PENDIENTES POR SURTIR " - Protected Sub DdlCliente_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaFolios() - End Sub - Private Sub CargaFolios() - Dim ObjInventarios As New ClsInventarios - - DdlFolio.Items.Clear() - - If DdlClientes.SelectedValue.ToEntero > 0 Then - If ObjInventarios.VentasPendientesAlmacenGet(DdlClientes.SelectedValue.ToEntero, MinFecha, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then - DdlFolio.DataSource = ObjInventarios.DtResultados - Else - Alert("Ocurrió un error al obtener las Compras pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError) - End If - End If - - ObjInventarios.Dispose() - - DdlFolio.DataBind() - DdlFolio.Items.Insert(0, New ListItem("Seleccione", "-1")) - UpFiltros.Update() - End Sub - Protected Sub TimmerRefresh_Tick(sender As Object, e As EventArgs) - CargaPendientes() - End Sub - Protected Sub BtnConsultarPendientes_Click(sender As Object, e As EventArgs) - CargaPendientes() - End Sub - Private Sub CargaPendientes() - DivTipoCambioAdvertencia.Visible = False - - Dim ObjInventarios As New ClsInventarios - Dim DtPendientes As New DataTable - - If ObjInventarios.VentasPendientesAlmacenGet(-1, TxtFechaPendientes.Text.ToDate, DdlSubProyectos.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, UsuarioActual.CveUsuario) Then - - - If UsuarioActual.TienePermisoProceso(266) AndAlso UsuarioActual.TienePermisoProceso(267) Then - DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Dev','Rem','Traspaso','Ped','PDev','DPe','Ant')") - ElseIf UsuarioActual.TienePermisoProceso(266) AndAlso Not UsuarioActual.TienePermisoProceso(267) Then - DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ing','Dev','Rem','Traspaso','Ant')") - ElseIf UsuarioActual.TienePermisoProceso(267) AndAlso Not UsuarioActual.TienePermisoProceso(266) Then - DtPendientes = ObjInventarios.DtResultados.FiltraParametros("TipoDocto IN ('Ped','PDev','DPe')") - Else - DtPendientes = ObjInventarios.DtResultados - End If - Else - DtPendientes = Nothing - Alert("Ocurrió un error al obtener las Compras pendientes de recibir del proveedor. Por favor vuelva a intentar", TipoMensaje.MsgError) - End If - - If UsuarioActual.Empresa.Funcionalidad(540) = "1" Then - BtnGuardar.Enabled = False - Dim FI As Date = Now.AddDays(-1) - Dim FF As Date = Now.AddDays(-7) - If ObjInventarios.RepNotasSinAlmacen(1, -1, FI, FF, "-1", -1, UsuarioActual.Empresa.CveEmpresa) Then - If ObjInventarios.DtResultados IsNot Nothing AndAlso ObjInventarios.DtResultados.Rows.Count > 1 Then - BtnGuardar.Enabled = False - Alert("No se podrá realizar entrega de mercancía si no se les da salida a los documentos pendientes. Para más información ver el Reporte de notas sin entrada en la sección Ventas.", TipoMensaje.MsgAdvertencia) - Else - BtnGuardar.Enabled = True - - End If - End If - End If - - ObjInventarios.Dispose() - - If DtPendientes IsNot Nothing Then - GVPendientes.DataSource = DtPendientes - - End If - - LtActualizado.Text = String.Format("Actualizado: {0}", Now.ToString("H:mm")) - - GVPendientes.DataBind() - UpPendientes.Update() - If DtPendientes IsNot Nothing Then DtPendientes.Dispose() - - End Sub - Protected Sub GVPendientes_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GVPendientes.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.FCLinkButton("BtnSurtir").CommandArgument = If(e.Row.DBCampo("TipoEntrega") = "1", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("CveTraspasoSolicitud")) - - - - Select Case e.Row.DBCampo("TipoEntrega").ToString.ToEntero - Case 1 - If UsuarioActual.TienePermisoProceso(201) Then - Dim Css = "Texto" - Dim Liga = $"/Ventas/Ventas.aspx?&CveVenta={e.Row.DBCampo("CveVenta")}" - e.Row.FCLabel("LblFolio").Text = "" + e.Row.FCLabel("LblFolio").Text + "" - End If - - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - GVPendientes.Columns(4).Visible = True - e.Row.FCHyperLink("HplDownPDF").Visible = True - e.Row.FCHyperLink("HplDownPDF").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=VTA&CVEVENTA={0}", e.Row.DBCampo("CveVenta")))) - End If - - If e.Row.DBCampo("TipoDocto").ToString.Contiene({"Rem", "Ing", "Ped", "PeC", "Ant"}) And e.Row.DBCampo("EsDevolucionVenta").ToString.ToEntero = 0 Then - e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary btn-sm" - e.Row.FCLinkButton("BtnSurtir").Text = " Surtir " - Else - e.Row.FCLinkButton("BtnSurtir").CssClass = "btn yellow-gold btn-sm" - e.Row.FCLinkButton("BtnSurtir").Text = " Recibir" - End If - Case 2 - Dim Css = "Texto" - Dim Liga = $"/Inventarios/TrasladoSolicitud.aspx?&CveTraspasoSolicitud={e.Row.DBCampo("CveTraspasoSolicitud")}" - e.Row.FCLabel("LblFolio").Text = "" + e.Row.FCLabel("LblFolio").Text + "" - e.Row.FCLinkButton("BtnSurtir").CssClass = "btn btn-primary btn-sm" - e.Row.FCLinkButton("BtnSurtir").Text = " Traspasar " - End Select - UpPendientes.Update() - End If - End Sub - -#End Region - - -#Region " CARGA VENTA POR SURTIR " - Protected Sub BtnSurtir_Click(sender As Object, e As EventArgs) - - Dim Boton = CType(sender, LinkButton) - CveVentaAD = -1 - - If Boton.CommandArgument.ToEntero > 0 Then - TimmerRefresh.Enabled = False - - DivTransitorio1.Visible = False - ChkTransitorio.Checked = False - TxtResponsable.Text = "" - DivTransitorio2.Visible = False - - - Select Case CType(Boton.NamingContainer, GridViewRow).DataKey("TipoEntrega").ToEntero - Case 1 ' VENTA - CargaVentaPorSurtir(CType(sender, LinkButton).CommandArgument.ToEntero) - Case 2 ' TRASPASO - DivTransitorio1.Visible = True - CargaTraspasoPorSurtir(CType(Boton.NamingContainer, GridViewRow).DataKey("CveTraspasoSolicitud").ToEntero) - End Select - - End If - - End Sub - Protected Sub BtnBuscar_Click(sender As Object, e As EventArgs) - CveVentaAD = -2 - CargaVentaPorSurtir(DdlFolio.SelectedValue.ToEntero) - End Sub - Private Sub CargaVentaPorSurtir(CveVenta As Integer) - LbSurtida.Visible = False - CveContrato = -1 - CveSubProyecto = -1 - DtDatos = Nothing - TipoEntrega = 1 - BtnGuardar.Visible = True - - Dim StrAlmacenes As String = "CveTipoAlmacen IN (1,2)" - - If UsuarioActual.CveSubProyecto = 8804 Then - StrAlmacenes = "CveTipoAlmacen IN (1,2,12)" - End If - - Dim ObjInventario As New ClsInventarios - - If ObjInventario.EntregaAlmacenGet(CveVenta) Then - If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - - - DtDatos = ObjInventario.DtResultados - DtDatos.Columns.Add("Consec", GetType(Integer)) - DtDatos.Columns.Add("CantidadGV", GetType(Double)) - DtDatos.Columns.Add("CantidadTraspaso", GetType(Double)) - Dim Index = 1 - For Each Dr As DataRow In DtDatos.Rows - Dr("Consec") = Index - Index += 1 - Next - - DtDatosDetalle = Nothing - CreaDtDetalle() - - DtDatosDetalleLote = Nothing - CreaDtDetalleLote() - - If DtDatos.Rows(0) IsNot Nothing Then - EsDevolucionVenta = DtDatos.Rows(0)("EsDevolucionVenta").ToString.ToEntero - TipoDocto = DtDatos.Rows(0)("TipoDocto").ToString - TipoMovimiento = If(TipoDocto.Contiene({"Rem", "Ing", "Ped", "PeC", "Ant"}) And (EsDevolucionVenta = 0 Or CveVentaAD > 0), 1, 2) - - LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString - 'LbFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString - HLFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString - If UsuarioActual.TienePermisoProceso(201) Then - HLFolio.NavigateUrl = $"/Ventas/Ventas.aspx?CveVenta={CveVenta}" - End If - - LbObservaciones.Text = DtDatos.Rows(0)("Observaciones").ToString - LbObservacionesAlmacen.Text = DtDatos.Rows(0)("ObservacionesAlmacen").ToString - CveVentaSurtir = CveVenta - CveAlmacenTraspasoDestino = DtDatos.Rows(0)(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "CveAlmacenTraspasoOrigen", "CveAlmacenTraspasoDestino")).ToString.ToEntero - CveAlmacenTraspasoOrigen = DtDatos.Rows(0)(If(EsDevolucionVenta = 1 And TipoDocto <> "Rem", "CveAlmacenTraspasoDestino", "CveAlmacenTraspasoOrigen")).ToString.ToEntero - CveContrato = DtDatos.Rows(0)("CveContrato").ToString.ToEntero - CveVendedor = DtDatos.Rows(0)("CveVendedor").ToString.ToEntero - CveCliente = DtDatos.Rows(0)("CveCliente").ToString.ToEntero - CveSubProyecto = DtDatos.Rows(0)("CveSubProyecto").ToString.ToEntero - EsInterno = CBool(DtDatos.Rows(0)("EsInterno").ToString) - - If DtDatos.SUM("CantidadS") <= 0 Then - GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario gvEscondeColumna" - Else - GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario" - End If - - If CveAlmacenTraspasoDestino > 0 And Not (TipoMovimiento = 2 And TipoDocto = "Rem") Then - DivTipoCambioAdvertencia.Visible = True - LtTipoCambioAdvertencia.Text = $"Los productos seran Trasladados al Almacen: {GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoDestino}")}" - Else - DivTipoCambioAdvertencia.Visible = False - End If - - 'DEVOLUCION REMISION - If TipoMovimiento = 2 And TipoDocto = "Rem" And Not CveAlmacenTraspasoDestino > 0 Then - Alert("La remisión que se intenta devolver presenta inconsistencias. Comuniquese con servicio tecnico SIG.", TipoMensaje.MsgError) - BtnGuardar.Visible = False - End If - - DdlAlmacen.Items.Clear() - If CveAlmacenTraspasoOrigen > 0 Then 'Not (EsDevolucionVenta = 1 And DtDatos.Rows(0)("TipoDocto").ToString = "Rem" And UsuarioActual.Empresa.Funcionalidad(145) = "1") - ESTO ES PARA CUANDO SEA REMISION DE ENTREGA POR ADELANTADO FUNCIONA LA DEVOLUCION - DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString)) - Else - '[IPP] PARCHE - Debe hacerse permiso proceso - 17Enero2018 - Dim RestriccionAlmacenSubProyecto = If(UsuarioActual.CveEmpresa.Contiene(72, 80), $" AND CveSubProyecto = {CveSubProyecto}", "") - DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"{StrAlmacenes} {RestriccionAlmacenSubProyecto}") - End If - DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1")) - DdlAlmacen.SelectedValue = "-1" - DdlAlmacen.DataBind() - DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) - If CveAlmacenTraspasoOrigen > 0 Then - DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen) - End If - - - If Not DtDatos.Columns.Contains("Lote") Then - DtDatos.Columns.Add("Lote", GetType(String)) - End If - If Not DtDatos.Columns.Contains("CveSeccion") Then - DtDatos.Columns.Add("CveSeccion", GetType(Integer)) - End If - If Not DtDatos.Columns.Contains("Caducidad") Then - DtDatos.Columns.Add("Caducidad", GetType(Date)) - End If - If Not DtDatos.Columns.Contains("Seleccionado") Then - DtDatos.Columns.Add("Seleccionado", GetType(Boolean)) - End If - If Not DtDatos.Columns.Contains("CantidadSeleccionada") Then - DtDatos.Columns.Add("CantidadSeleccionada", GetType(Double)) - End If - - For Each Dr As DataRow In DtDatos.Rows - Dr("Caducidad") = Now - Next - - 'TxtFecha.Text = If(EsDevolucionVenta = 1, Now.ToShortDateString, DtDatos.Rows(0)("Fecha").ToString) - End If - - If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then - DivCodigoSeriePS.Visible = True - Else - DivCodigoSeriePS.Visible = False - End If - - If TipoMovimiento = 2 Then ' cuando es cancelación - Dim Filtro As String '= If(ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString.Contiene({"Ing", "Dev", "Ped"}), "CveConcepto = 3", "CveConcepto = 9") - Select Case ObjInventario.DtResultados.Rows(0)("TipoDocto").ToString - Case "Ing", "Ped" - Filtro = "CveConcepto IN (3,40)" - Case "Dev" - 'cuand es devolucionventa=1, es cancelación de la devolución - If EsDevolucionVenta = 1 Then Filtro = "CveConcepto = 18" Else Filtro = "CveConcepto IN (3,40)" - Case Else - Filtro = "CveConcepto = 9" - End Select - If ObjInventario.GetInv_Mov(ObjInventario.DtResultados.Rows(0)("CveVentaPadre").ToString.ToEntero, UsuarioActual.CveEmpresa) Then - DtExistencias = ObjInventario.DtResultados.FiltraParametros($"CvePS Is Not NULL AND {Filtro}") - - If Not DtExistencias.Rows.Count > 0 Then - Alert("La Venta original de la Devolución no tiene salida de Almacén.", TipoMensaje.MsgAdvertencia) - End If - - If TipoDocto.Contiene("Ing") AndAlso TipoMovimiento = 2 Then - Dim DtMov As DataTable = DtExistencias.FiltraParametros("CveConcepto = 40", "", {"CveAlmacen"}) - If DtMov.Rows.Count > 0 Then - Dim CveAlmacenDev As Integer = DtMov.Rows(0)("CveAlmacen").ToString().ToEntero() - DdlAlmacen.Items.Clear() - DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1).FiltraParametros($"CveAlmacen = {CveAlmacenDev}") - DdlAlmacen.DataBind() - - DdlAlmacen.SelectedValueExist(CveAlmacenDev) - EsDevolucionDirecta = True - End If - End If - - Else - Alert("Ocurrió un error al cargar los datos de devolución. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - End If - - CargaDocumentos(CveVenta) - Else - Alert("No se encontraron productos pendientes por surtir. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - End If - Else - DtDatos = Nothing - End If - - ObjInventario.Dispose() - UpGenerales.Update() - CargaGvDatos() - DtSeccionAlmacen.Rows.Clear() - DtSeccionAlmacen.AcceptChanges() - End Sub - Private Sub CargaTraspasoPorSurtir(CveTraspaso As Integer) - LbSurtida.Visible = False - CveContrato = -1 - CveSubProyecto = -1 - DtDatos = Nothing - TipoEntrega = 2 - - Dim ObjInventario As New ClsInventarios - - If ObjInventario.EntregaAlmacenTraspasosGet(CveTraspaso) Then - If ObjInventario.DtResultados IsNot Nothing AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - CveTraspasoSurtir = CveTraspaso - TipoMovimiento = 1 - - DtDatos = ObjInventario.DtResultados - DtDatos.Columns.Add("Consec", GetType(Integer)) - DtDatos.Columns.Add("CantidadGV", GetType(Double)) - DtDatos.Columns.Add("CantidadTraspaso", GetType(Double)) - - LbCliente.Text = DtDatos.Rows(0)("Nombre").ToString - HLFolio.Text = DtDatos.Rows(0)("SerieFolio").ToString - If UsuarioActual.TienePermisoProceso(201) Then - HLFolio.NavigateUrl = $"/Inventarios/TrasladoSolicitud.aspx?CveTraspasoSolicitud={CveTraspasoSurtir}" - End If - LbObservaciones.Text = DtDatos.Rows(0)("Observaciones").ToString - - Dim Index = 1 - For Each Dr As DataRow In DtDatos.Rows - Dr("Consec") = Index - Index += 1 - Next - - DtDatosDetalle = Nothing - CreaDtDetalle() - - DtDatosDetalleLote = Nothing - CreaDtDetalleLote() - - CveAlmacenTraspasoDestino = DtDatos.Rows(0)("CveAlmacenDestino").ToString.ToEntero - CveAlmacenTraspasoOrigen = DtDatos.Rows(0)("CveAlmacenOrigen").ToString.ToEntero - - If DtDatos.SUM("CantidadS") <= 0 Then - GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario gvEscondeColumna" - Else - GvDatos.CssClass = "table table-striped table-hover Widthall ScrollAD gvInventario" - End If - - If CveAlmacenTraspasoDestino > 0 Then - DivTipoCambioAdvertencia.Visible = True - LtTipoCambioAdvertencia.Text = $"Los productos seran Trasladados al Almacen: {GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoDestino}")}" - Else - DivTipoCambioAdvertencia.Visible = False - End If - - 'If DtDatos.Rows.Cast(Of DataRow).Any(Function(Row) Row("CveTamaño").ToString().ToEntero() > 0) Then - - 'End If - - - DdlAlmacen.Items.Clear() - If CveAlmacenTraspasoOrigen > 0 Then - DdlAlmacen.Items.Insert(0, New ListItem(GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("Almacen", $"CveAlmacen = {CveAlmacenTraspasoOrigen}"), CveAlmacenTraspasoOrigen.ToString)) - End If - - DdlAlmacen.Items.Insert(0, New ListItem(" Seleccione ", "-1")) - DdlAlmacen.SelectedValue = "-1" - DdlAlmacen.DataBind() - DdlAlmacen.SelectedValueExist(UsuarioActual.CveAlmacen) - If CveAlmacenTraspasoOrigen > 0 Then - DdlAlmacen.SelectedValueExist(CveAlmacenTraspasoOrigen) - End If - - 'TxtFecha.Text = DtDatos.Rows(0)("Fecha").ToString - - If UsuarioActual.Empresa.Funcionalidad(132) = "1" Then - DivCodigoSeriePS.Visible = True - Else - DivCodigoSeriePS.Visible = False - End If - - Else - Alert("No se encontraron productos pendientes por surtir. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - End If - Else - DtDatos = Nothing - End If - - ObjInventario.Dispose() - UpGenerales.Update() - CargaGvDatos() - - End Sub - Private Sub CargaGvDatos() - - If DtDatos IsNot Nothing Then - - For Each item As DataRow In DtDatos.Rows - Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, item("CvePS").ToString.ToEntero).FiltroPrimero("") - If Dr IsNot Nothing Then - item("AplicaSeccion") = CBool(Dr("AplicaSeccion")) - If CBool(Dr("AplicaSeccion")) Then GvDatos.Columns(9).Visible = True - item("AplicaSerie") = CBool(Dr("AplicaSerie")) - item("AplicaLote") = CBool(Dr("AplicaLote")) - If CBool(Dr("AplicaLote")) Then GvDatos.Columns(10).Visible = True - item("AplicaCaducidad") = CBool(Dr("AplicaCaducidad")) - If CBool(Dr("AplicaCaducidad")) Then GvDatos.Columns(11).Visible = True - If CBool(Dr("AplicaSeccion")) Or CBool(Dr("AplicaLote")) Or CBool(Dr("AplicaCaducidad")) Or CBool(Dr("AplicaSerie")) Then - GvDatos.Columns(12).Visible = True - End If - End If - Next - - GvDatos.DataSource = DtDatos - End If - - GvDatos.Columns(7).Visible = UsuarioActual.Empresa.Funcionalidad(147) = "1" - - GvDatos.Columns(8).Visible = UsuarioActual.Empresa.Funcionalidad(563) = "1" - - GvDatos.DataBind() - UpDatos.Update() - UpVenta.Update() - - 'CARGA LO PRECARGADO CON SERIELOTE - Dim Contador = 0 - For Each Gvr As GridViewRow In GvDatos.Rows - If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then - Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count - Gvr.FCCheckBox("cbInv").Enabled = False - Gvr.FCCheckBox("cbInv").Checked = True - Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString - End If - Next - - End Sub - - Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - If CBool(e.Row.DBCampo("AplicaSerie")) Then - e.Row.FCButton("BtnSerieLote").Visible = True - e.Row.FCButton("BtnSerieLote").Text = If(e.Row.DBCampo("Inv_CveMetodoInventario").ToString = "5", "SerieLote", "Lote-Batch") - e.Row.FCButton("BtnSerieLote").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec"), e.Row.DBCampo("Inv_CveMetodoInventario")) - e.Row.FCTextBox("TbCantidadF").Enabled = False - e.Row.FCCheckBox("cbInv").Enabled = False - Dim Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DBCampo("Consec"))).Rows.Count - e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString - 'e.Row.FCTextBox("TbCantidadF").Text = "0" - - If TipoDocto = "DPe" Then - CveConsecSerieLote = e.Row.DBCampo("Consec").ToString.ToEntero - PSSerieLote = e.Row.DBCampo("PS").ToString - CvePSSerieLote = e.Row.DBCampo("CvePS").ToEntero - CveUMSerieLote = e.Row.DBCampo("CveUM").ToEntero - LbCantidad.Text = e.Row.DBCampo("CantidadF") - LbCantidad2.Text = e.Row.DBCampo("CantidadF") - AgregaSerieLote(e.Row.DBCampo("ObservacionesDetalle"), 3) - End If - - Else - e.Row.FCButton("BtnSerieLote").Visible = False - e.Row.FCTextBox("TbCantidadF").Enabled = True - e.Row.FCTextBox("TbCantidadF").Attributes.Add("onblur", String.Format("ValidarCantidad(this, {0})", e.Row.DBCampo("CantidadF"))) - End If - - - If CBool(e.Row.DBCampo("AplicaSeccion")) Then - e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = True - Else - e.Row.FCDropDownList("DdlSeccionAlmacen").Visible = False - End If - - If CBool(e.Row.DBCampo("AplicaCaducidad")) Then - e.Row.FCTextBox("TxtCaducidad").Visible = True - e.Row.FCLinkButton("LnkCaducidad").Visible = True - e.Row.FCTextBox("TxtCaducidad").Text = Now.ToShortDateString - Else - e.Row.FCTextBox("TxtCaducidad").Visible = False - e.Row.FCLinkButton("LnkCaducidad").Visible = False - End If - - If CBool(e.Row.DBCampo("AplicaLote")) Then - e.Row.FCTextBox("TxtLote").Visible = True - Else - e.Row.FCTextBox("TxtLote").Visible = False - End If - - e.Row.FCButton("BtnDividir").Attributes.Add("onclick", String.Format("Dividir('{0}');", e.Row.FCTextBox("TxtDividir").ClientID)) - e.Row.FCButton("BtnDividir").CommandArgument = e.Row.RowIndex.ToString - e.Row.FCTextBox("TxtDividir").Attributes.Add("onkeyup", String.Format("LimitaCantidad({0},this,'{1}');", e.Row.DBCampo("CantidadF"), e.Row.FCButton("BtnDividir").ClientID)) - - - 'FUNCIONALIDAD PISTOLA DE CODIGOS - If UsuarioActual.Empresa.Funcionalidad(132) = "1" And e.Row.DBCampo("CodigoBarras").Trim <> "" Then - 'NO BLOQUEA PARA ROL AD - If UsuarioActual.CveRol = 1 Then - If e.Row.DBCampo("Inv_CveMetodoInventario").Contiene("5", "6") Then - e.Row.FCTextBox("TbCantidadF").Enabled = False - Else - e.Row.FCTextBox("TbCantidadF").Text = e.Row.DBCampo("CantidadF").FormatoNumero() - End If - End If - - If Not UsuarioActual.CveRol = 1 Then - e.Row.FCTextBox("TbCantidadF").Enabled = False - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then - e.Row.FCLinkButton("LBSeccionAlmacen").CommandArgument = $"{e.Row.DBCampo("CvePS").ToString.ToEntero}|{e.Row.DBCampo("CantidadF").ToString.ToDecimal}|{DdlAlmacen.SelectedValue.ToEntero}" - End If - - 'SI ES TRASPASO OBLIGATORIO SURTIR TODO - If TipoEntrega = 2 Then - e.Row.FCCheckBox("cbInv").Enabled = False - End If - - 'If UsuarioActual.Empresa.Funcionalidad(147) = "1" Then - ' Dim ObjInventarios As New ClsInventarios - ' If ObjInventarios.SeccionAlmacenRecomendadoSurtidoGet(e.Row.DBCampo("CvePS").ToString.ToEntero, e.Row.DBCampo("CantidadF").ToString.ToDecimal, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) Then - ' e.Row.FCLabel("LbSeccionAlmacen").Text = ObjInventarios.DtResultados().Rows(0)(0).ToString - ' End If - ' ObjInventarios.Dispose() - 'End If - - End If - End Sub - - Private Sub CargaDocumentos(tCveVenta As Integer) - Dim objInv As New ClsEdocumentacion - - If objInv.DocumentacionElectronicaGet(-1, -1, -1, UsuarioActual.CveEmpresa, -1, tCveVenta) Then - GvDocs.DataSource = objInv.DtResultados.FiltraParametros("Adjunto <> ''") - End If - objInv.Dispose() - GvDocs.DataBind() - End Sub - Protected Sub LBSeccionAlmacen_Click(sender As Object, e As EventArgs) - Dim Argumentos = CType(sender, LinkButton).CommandArgument.Split("|"c) - - Dim ObjInventarios As New ClsInventarios - If ObjInventarios.SeccionAlmacenRecomendadoSurtidoGet(Argumentos(0).ToEntero, Argumentos(1).ToEntero, UsuarioActual.CveEmpresa, Argumentos(2).ToEntero) Then - GVSeccionAlmacen.DataSource = ObjInventarios.DtResultados - End If - ObjInventarios.Dispose() - - GVSeccionAlmacen.DataBind() - UpSeccionAlmacen.Update() - - RegistraScript("$('#ModalSeccionAlmacen').modal('show')") - End Sub - -#End Region - - -#Region " AGREGAR " - - Protected Sub BtnSerieLote_Click(sender As Object, e As EventArgs) - - Dim Argumentos = CType(sender, Button).CommandArgument.Split("°"c) - - LbProducto.Text = Argumentos(2) - LbCantidad.Text = Argumentos(3) - - LbProducto2.Text = Argumentos(2) - LbCantidad2.Text = Argumentos(3) - - CvePSSerieLote = Argumentos(0).ToEntero - CveUMSerieLote = Argumentos(1).ToEntero - PSSerieLote = Argumentos(2).ToString - CveConsecSerieLote = Argumentos(4).ToEntero - CveMetodoInventarioLote = Argumentos(5).ToEntero - - If CveMetodoInventarioLote = 5 Then - RegistraScript("$('#DivSerie').modal('show')") - CargaSerie() - UpSerie.Update() - ElseIf CveMetodoInventarioLote = 6 Then - RegistraScript("$('#DivLote').modal('show')") - CargaLote() - UpLoteBatch.Update() - End If - - End Sub - -#Region " AGREGA POR SERIE/LOTE " - - Private Sub CreaDtDetalle() - If DtDatosDetalle Is Nothing Then - DtDatosDetalle = New DataTable - DtDatosDetalle.Columns.Add("CveVentaDetalle", GetType(Integer)) - DtDatosDetalle.Columns.Add("Consec", GetType(Integer)) - DtDatosDetalle.Columns.Add("ConsecId", GetType(Integer)) - DtDatosDetalle.Columns.Add("CvePS", GetType(Integer)) - DtDatosDetalle.Columns.Add("PS", GetType(String)) - DtDatosDetalle.Columns.Add("CveUM", GetType(Integer)) - DtDatosDetalle.Columns.Add("SerieLote", GetType(String)) - DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(String)) - DtDatosDetalle.Columns.Add("FueTraspaso", GetType(Integer)) - End If - End Sub - Private Sub CargaSerie(Optional CerrarCompletado As Boolean = False) - RegistraScript("$('#DivSerie').modal('show')", "show") - 'RegistraScript("document.getElementById(""TxtSerieLote"").focus();") - - Dim AplicaCaducidad = False - If GlobalDTPS(UsuarioActual.CveEmpresa, ).FiltraParametros("").Rows(0) IsNot Nothing Then - AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False) - End If - - If AplicaCaducidad Then - GvSerie.Columns(1).Visible = True - TdCaducidad1.Visible = True - TdCaducidad2.Visible = True - Else - GvSerie.Columns(1).Visible = False - TdCaducidad1.Visible = False - TdCaducidad2.Visible = False - End If - - GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote), "Consec DESC") - GvSerie.DataBind() - - 'SERIE LOTE RECOMENDADO - Dim DtSerieLote As New DataTable - If TipoMovimiento = 1 Then - Dim ObjInventarios As New ClsInventarios - If ObjInventarios.SerieLoteRecomendadoGet(CvePSSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, CveSubProyecto:=CveSubProyecto) Then - DtSerieLote = ObjInventarios.DtResultados - End If - ObjInventarios.Dispose() - Else - DtSerieLote = DtExistencias.FiltraParametros("SerieLote <> ''") - End If - 'SERIE LOTE RECOMENDADO - QUITA YA COMPLETADOS EN EL CLIENTE - If DtSerieLote.Rows.Count > 0 Then - 'CALCULA YA COMPLETADOS - Dim DrsRemove As New List(Of DataRow) - DtSerieLote.Columns.Add("CantidadSeleccionada", GetType(Integer)) - For Each dr As DataRow In DtSerieLote.Rows - dr("CantidadSeleccionada") = DtDatosDetalle.FiltraParametros(String.Format("Consec = {0} AND SerieLote = '{1}'", CveConsecSerieLote, dr("SerieLote").ToString.Replace("'", "''"))).Rows.Count - If dr("CantidadSeleccionada").ToString.ToDecimal = dr("Existencia").ToString.ToDecimal Then - DrsRemove.Add(dr) - End If - Next - - 'ELIMINA YA COMPLETADOS EN PAGINA - For Each dr As DataRow In DrsRemove - DtSerieLote.Rows.Remove(dr) - Next - - If DtSerieLote.Rows.Count > 0 Then - Dim Mensaje As New StringBuilder - Mensaje.AppendFormat("Serie / Lote Recomendado: {0}", DtSerieLote.Rows(0)("SerieLote")) - If AplicaCaducidad Then Mensaje.AppendFormat(", Caducicdad: {0}", DtSerieLote.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString) - LbSerieLoteRecomendado.Text = Mensaje.ToString 'String.Format("Serie / Lote Recomendado: {0}, Caducicdad: {1}", ObjInventarios.DtResultados.Rows(0)("SerieLote"), ObjInventarios.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString) - Else - LbSerieLoteRecomendado.Text = "No se encontro ningun Serie/Lote." - End If - Else - LbSerieLoteRecomendado.Text = "No se encontro ningun Serie/Lote." - End If - - 'SI TIENE SALIDA POR SERIE LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD - Dim Contador = 0 - For Each Gvr As GridViewRow In GvDatos.Rows - If Gvr.DataKey("AplicaSerieLote") = "True" Then - Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count - Gvr.FCCheckBox("cbInv").Enabled = False - Gvr.FCCheckBox("cbInv").Checked = True - Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString - End If - Next - UpDatos.Update() - - 'VALIDA QUE SIGA AGREGANDO - If DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote)).Rows.Count = LbCantidad.Text.ToEntero Then - BtnAgregarPS.Enabled = False - If CerrarCompletado Then - RegistraScript("$('#DivSerie').modal('hide')", "hide") - End If - UpSerie.Update() - Exit Sub - Else - BtnAgregarPS.Enabled = True - UpSerie.Update() - End If - - End Sub - - Protected Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) - If TxtSerieLote.Text.Trim.Length >= 2 AndAlso TxtSerieLote.Text.Trim.StartsWith("*") AndAlso TxtSerieLote.Text.Trim.EndsWith("*") Then - Dim ArraySeries() As String = Nothing - Dim Series As String = Nothing - - Series = TxtSerieLote.Text.Trim - Series = Series.Remove(0, 1) - Series = Series.Remove(Series.Length - 1, 1) - ArraySeries = Series.Trim.Split(","c) - - For i As Integer = 0 To ArraySeries.Length - 1 - If ArraySeries(i).Trim.Length > 1 Then AgregaSerieLote(ArraySeries(i).Trim, 1) - Next - Else - AgregaSerieLote(TxtSerieLote.Text.Trim, 1) - End If - End Sub - - Private Sub AgregaSerieLote(SerieLote As String, Tipo As Integer) - - If SerieLote.Trim = "" Then - Alert("El campo Serie es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If DtDatosDetalle.FiltraParametros($"CvePS = {CvePSSerieLote} AND SerieLote = '{SerieLote}'").Rows.Count > 0 Then - Alert("La SerieLote indicada ya esta registrada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')", "Error1") - TxtSerieLote.Text = "" - Exit Sub - End If - - Dim AplicaCaducidad = False - If GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0) IsNot Nothing Then - AplicaCaducidad = If(GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerieLote).FiltraParametros("").Rows(0)("AplicaCaducidad").ToString = "True", True, False) - End If - - - 'Valida Existencia - If TipoMovimiento = 1 Then - Dim ObjInventarios As New ClsInventarios - Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerieLote, CveUMSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=SerieLote, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=If(TipoEntrega = 2, 1, -1)) - If Existencia < 1 Then - Alert($"No hay existencia suficiente del producto ""{PSSerieLote}"" con la SerieLote definida ""{SerieLote}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia, If(Tipo = 2, "window.setTimeout(Focus,200);", "")) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')", "Error2") - ObjInventarios.Dispose() - Exit Sub - End If - Else - If DtExistencias IsNot Nothing Then - Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {CvePSSerieLote} AND CveUM = {CveUMSerieLote} AND SerieLote = '{SerieLote}'") - If Existencia < 1 Then - Alert($"No hay existencia suficiente del producto ""{PSSerieLote}"" con la SerieLote definida ""{SerieLote}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia, If(Tipo = 2, "window.setTimeout(Focus,200);", "")) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')", "Error3") - Exit Sub - End If - End If - End If - - - Dim Row = DtDatosDetalle.NewRow - - Row("ConsecId") = CveConsecSerieLote - Row("Consec") = DtDatosDetalle.Rows.Count + 1 - Row("PS") = PSSerieLote - Row("CvePS") = CvePSSerieLote - Row("CveUM") = CveUMSerieLote - Row("SerieLote") = SerieLote - Row("FechaCaducidad") = If(AplicaCaducidad, TxtFechaCaducidad.Text, MinFecha.ToShortDateString) - - DtDatosDetalle.Rows.Add(Row) - RegistraScript("playsonidito('beep-07.wav')", "Sonidito") - - If Tipo = 1 Then - TxtSerieLote.Text = "" - TxtFechaCaducidad.Text = Now.ToShortDateString - End If - - If Tipo < 3 Then - CargaSerie(True) - End If - - End Sub - - Protected Sub GvSerie_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvSerie.RowDeleting - - Dim keySerieLote As String = e.Keys("SerieLote").ToString - Try - For Each dr As DataRow In DtDatosDetalle.Rows - If dr("SerieLote").ToString = keySerieLote Then - dr.Delete() - End If - Next - Catch ex As Exception - - End Try - - DtDatosDetalle.AcceptChanges() - CargaSerie() - - End Sub -#End Region - -#Region " AGREGA CON LOTE BATCH " - - Private Sub CreaDtDetalleLote() - If DtDatosDetalleLote Is Nothing Then - DtDatosDetalleLote = New DataTable - DtDatosDetalleLote.Columns.Add("CveVentaDetalle", GetType(Integer)) - DtDatosDetalleLote.Columns.Add("Consec", GetType(Integer)) - DtDatosDetalleLote.Columns.Add("ConsecId", GetType(Integer)) - DtDatosDetalleLote.Columns.Add("Cantidad", GetType(Double)) - DtDatosDetalleLote.Columns.Add("CvePS", GetType(Integer)) - DtDatosDetalleLote.Columns.Add("PS", GetType(String)) - DtDatosDetalleLote.Columns.Add("CveUM", GetType(Integer)) - DtDatosDetalleLote.Columns.Add("Lote", GetType(String)) - DtDatosDetalleLote.Columns.Add("Batch", GetType(String)) - DtDatosDetalleLote.Columns.Add("FechaCaducidad", GetType(String)) - DtDatosDetalleLote.Columns.Add("FueTraspaso", GetType(Integer)) - End If - End Sub - Private Sub CargaLote(Optional CerrarCompletado As Boolean = False) - - RegistraScript("$('#DivLote').modal('show')") - GvLote.DataSource = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerieLote), "Consec DESC") - GvLote.DataBind() - - 'VALIDA QUE SIGA AGREGANDO - If DtDatosDetalleLote.SUM("Cantidad", String.Format("ConsecId = {0}", CveConsecSerieLote)) = LbCantidad2.Text.ToDecimal Then - BtnLote.Enabled = False - If CerrarCompletado Then - RegistraScript("$('#DivLote').modal('hide')", "hide") - End If - Else - BtnLote.Enabled = True - End If - - 'LOTE RECOMENDADO - Dim DtLotes As New DataTable - If TipoMovimiento = 1 Then - Dim ObjInventarios As New ClsInventarios - If ObjInventarios.LoteBatchRecomendadoGet(CvePSSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) Then - DtLotes = ObjInventarios.DtResultados - End If - ObjInventarios.Dispose() - Else - DtLotes = DtExistencias.FiltraParametros("Lote <> ''") - End If - - Dim DrsRemove As New List(Of DataRow) - - If DtLotes.Rows.Count > 0 Then - 'CALCULA YA COMPLETADOS - DtLotes.Columns.Add("CantidadSeleccionada", GetType(Integer)) - For Each dr As DataRow In DtLotes.Rows - dr("CantidadSeleccionada") = DtDatosDetalleLote.SUM("Cantidad", String.Format("Consec = {0} AND Lote = '{1}' AND Batch = '{2}'", CveConsecSerieLote, dr("Lote"), dr("Batch"))) - If dr("CantidadSeleccionada").ToString.ToDecimal = dr("Existencia").ToString.ToDecimal Then - DrsRemove.Add(dr) - End If - Next - - 'ELIMINA YA COMPLETADOS EN PAGINA - For Each dr As DataRow In DrsRemove - DtLotes.Rows.Remove(dr) - Next - - If DtLotes.Rows.Count > 0 Then - Dim Mensaje As New StringBuilder - Mensaje.AppendFormat("Recomendado: Existencia: {0} Lote: {1} Batch: {2} Fecha Caducidad: {3} ", DtLotes.Rows(0)("Existencia").ToString.FormatoNumero, DtLotes.Rows(0)("Lote"), DtLotes.Rows(0)("Batch"), DtLotes.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString) - LbLoteRecomendado.Text = Mensaje.ToString - Else - LbLoteRecomendado.Text = "No se encontro ningún Lote-Batch recomendato." - End If - Else - LbLoteRecomendado.Text = "No se encontro ningún Lote-Batch recomendato." - End If - - - 'SI TIENE SALIDA POR LOTE, BLOQUEAMOS CHECK Y TXTCANTIDAD - Dim Contador As Decimal = 0 - For Each Gvr As GridViewRow In GvDatos.Rows - If Gvr.DataKey("CvePS").ToEntero = CvePSSerieLote Then - Contador = DtDatosDetalleLote.SUM("Cantidad", String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).ToDecimal - Gvr.FCCheckBox("cbInv").Enabled = False - Gvr.FCCheckBox("cbInv").Checked = True - Gvr.FCTextBox("TbCantidadF").Text = Contador.ToString.FormatoNumero - End If - Next - - RVCantidadLote.MaximumValue = (If((LbCantidad2.Text.ToDecimal - Contador) = 0, 0.02, LbCantidad2.Text.ToDecimal - Contador)).ToString.FormatoNumero - - TxtCantidadLote.Text = "1" - TxtLote.Text = "" - TxtBatch.Text = "" - TxtLote.Focus() - - UpLoteBatch.Update() - UpDatos.Update() - - End Sub - - Protected Sub BtnAgregarPS2_Click(sender As Object, e As EventArgs) - AgregaLote(TxtLote.Text.Trim, TxtBatch.Text.Trim, 1) - End Sub - Private Sub AgregaLote(Lote As String, Batch As String, Tipo As Integer) - - If Lote = "" Then - Alert("El campo Lote es obligatorio. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'VALIDACION DE SERIES DUPLICADAS - Dim MensajeAlert As New StringBuilder - Dim DtDuplicado As New DataTable - Dim DtSeriesNuevas As New DataTable - DtSeriesNuevas.Columns.Add("Serie", GetType(String)) - - DtDuplicado = DtDatosDetalleLote.FiltraParametros($"ConsecId = {CveConsecSerieLote} AND Lote = '{Lote}' AND Batch = '{Batch}'") - If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then - Alert($"
    El numero de Lote ""{Lote}"" y Batch = '{Batch}' proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - - Dim Row = DtDatosDetalleLote.NewRow - Dim CantidadLote = TxtCantidadLote.Text.ToDecimal - - Dim MensajeSinExistencias As New StringBuilder - Dim ObjInventarios As New ClsInventarios - - 'VERIFICA EXISTENCIAS - If TipoMovimiento = 1 Then - Dim Existencia = ObjInventarios.GetExistenciasPS(CvePSSerieLote, CveUMSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), Lote:=Lote, Batch:=Batch, ExcluyeApartados:=If(TipoEntrega = 2, 1, -1)) - If Existencia < CantidadLote Then - Alert($"No hay existencia suficiente del producto ""{PSSerieLote}"" con el lote definido ""{Lote}"" y el batch ""{Batch}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - ObjInventarios.Dispose() - Exit Sub - End If - Else - If DtExistencias IsNot Nothing Then - Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {CvePSSerieLote} AND CveUM = {CveUMSerieLote} AND Lote = '{Lote}' AND Batch = '{Batch}'") - If Existencia < CantidadLote Then - Alert($"No hay existencia suficiente del producto ""{PSSerieLote}"" con el lote definido ""{Lote}"" y el batch ""{Batch}"". Por favor rectifique y vuelva a intentar", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - ObjInventarios.Dispose() - Exit Sub - End If - End If - End If - - Dim FechaCaducidad = "" - If ObjInventarios.LoteBatchRecomendadoGet(CvePSSerieLote, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero) AndAlso ObjInventarios.DtResultados.Rows.Count > 0 Then - FechaCaducidad = ObjInventarios.DtResultados.Rows(0)("FechaCaducidad").ToString.ToDate.ToShortDateString - End If - - Row("ConsecId") = CveConsecSerieLote - Row("Consec") = DtDatosDetalle.Rows.Count + 1 - Row("Cantidad") = CantidadLote - Row("CvePS") = CvePSSerieLote - Row("PS") = PSSerieLote - Row("CveUM") = CveUMSerieLote - Row("Lote") = Lote - Row("Batch") = Batch - Row("FechaCaducidad") = FechaCaducidad - - DtDatosDetalleLote.Rows.Add(Row) - ObjInventarios.Dispose() - - If Tipo = 1 Then - TxtCantidadLote.Text = "1" - TxtLote.Text = "" - TxtBatch.Text = "" - End If - - CargaLote(True) - - End Sub - - Protected Sub GvLote_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvLote.RowDeleting - - Dim keySerieLote As String = e.Keys("Lote").ToString - Try - For Each dr As DataRow In DtDatosDetalleLote.Rows - If dr("Lote").ToString = keySerieLote Then - dr.Delete() - End If - Next - Catch ex As Exception - - End Try - DtDatosDetalleLote.AcceptChanges() - CargaLote() - End Sub -#End Region - -#Region " AGREGA CON TXT | CODIGO - SERIE " - Protected Sub BtnCodigoPS_Click(sender As Object, e As EventArgs) - - If TxtCodigoPS.Text = "" Then - Exit Sub - End If - - TdSeriePS.Visible = False - Dim Existe = False - Dim PSTemp = "" - - For Each Gvr As GridViewRow In GvDatos.Rows - If Gvr.DataKey("CodigoBarras") = TxtCodigoPS.Text.Trim Then - Dim TxtCantidad = GvDatos.Rows(Gvr.RowIndex).FCTextBox("TbCantidadF") - If Gvr.DataKey("CantidadF").ToDecimal - TxtCantidad.Text.ToDecimal - 1 >= 0 Then - - ''VALIDA EXISTENCIA - If Not TipoDocto.Contiene("Dev") Then - If TipoMovimiento = 1 Then - Dim ObjInventario As New ClsInventarios - Dim Existencia = ObjInventario.GetExistenciasPS(Gvr.DataKey("CvePS").ToString.ToEntero, Gvr.DataKey("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, DdlAlmacen.SelectedValue.ToEntero, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=If(TipoEntrega = 2, 1, -1)) - ObjInventario.Dispose() - If Not Existencia >= TxtCantidad.Text.ToDecimal + 1 Then - TxtCodigoPS.Text = "" - Alert($"No hay existencias suficientes del producto:
    ""{Gvr.DataKey("Codigo")}-{Gvr.DataKey("PS")}"".
    Solo hay disponibles {Existencia.FormatoNumero} en Almacen. Por favor Verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - Else - If DtExistencias IsNot Nothing Then - Dim Existencia = DtExistencias.SUM("Cantidad", $"CvePS = {Gvr.DataKey("CvePS")} AND CveUM = {Gvr.DataKey("CveUM").ToString.ToEntero}") - If Not Existencia >= TxtCantidad.Text.ToDecimal + 1 Then - TxtCodigoPS.Text = "" - Alert($"No hay existencias suficientes del producto:
    ""{Gvr.DataKey("Codigo")}-{Gvr.DataKey("PS")}"".
    Solo hay disponibles {Existencia.FormatoNumero} en Almacen. Por favor Verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - End If - End If - End If - - - If Gvr.DataKey("AplicaSerieLote") = "True" Then - TdSeriePS.Visible = True - TxtSeriePS.Focus() - - CveConsecSerieLote = Gvr.DataKey("Consec").ToString.ToEntero - PSSerieLote = Gvr.DataKey("PS").ToString - CvePSSerieLote = Gvr.DataKey("CvePS").ToEntero - CveUMSerieLote = Gvr.DataKey("CveUM").ToEntero - Exit Sub - End If - - - Dim CantidadEspecial = Gvr.DataKey("CveClasificacion").ToString.ToEntero.Contiene(17601, 17881) OrElse Gvr.DataKey("CvePS").ToString.ToEntero.Contiene(343032, 343033) - - If CantidadEspecial Then - RegistraScript("CantidadEspecial();window.setTimeout(FocusCantidadEspecial,200);") - LtlProductoCantidad.Text = $"{Gvr.DataKey("Codigo")}" - RowIndexCantidadEspecial = Gvr.RowIndex - CantidadEspecialTemp = Gvr.DataKey("CantidadF").ToDecimal - TxtCodigoPS.Text = "" - Exit Sub - Else - TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + 1).ToString.FormatoNumero - TxtCodigoPS.Text = "" - UpDatos.Update() - Exit Sub - End If - - VerificaVentaSurtida() - Exit Sub - End If - - Existe = True - PSTemp = Gvr.DataKey("PS").ToString - 'Alert($"Ya se ha cargado la totalidad del Producto ""{Gvr.DataKey("PS").ToString}"" con el Codigo ""{TxtCodigoPS.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - 'VerificaVentaSurtida() - 'Exit Sub - End If - Next - - VerificaVentaSurtida() - If Existe Then - Alert($"Ya se ha cargado la totalidad del Producto ""{PSTemp}"" con el Codigo ""{TxtCodigoPS.Text}"".", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - Else - Alert($"No se ha encontrado un producto para surtir con el Codigo ""{TxtCodigoPS.Text}"". ", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - End If - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - TxtCodigoPS.Text = "" - - End Sub - Private Sub VerificaVentaSurtida() - Dim Surtida = True - - For Each Gvr As GridViewRow In GvDatos.Rows - If Gvr.DataKey("CantidadF").ToDecimal <> Gvr.FCTextBox("TbCantidadF").Text.ToDecimal Then - Surtida = False - Exit Sub - End If - Next - - If Surtida Then - LbSurtida.Visible = True - End If - End Sub - Protected Sub BtnSeriePS_Click(sender As Object, e As EventArgs) - AgregaSerieLote(TxtSeriePS.Text.Trim, 2) - - TdSeriePS.Visible = False - TxtSeriePS.Text = "" - TxtCodigoPS.Text = "" - TxtCodigoPS.Focus() - VerificaVentaSurtida() - - End Sub - Protected Sub BtnGuardarCantidadEspecial_Click(sender As Object, e As EventArgs) - AgregaCantidadEspecial() - End Sub - Private Sub AgregaCantidadEspecial() - Dim TxtCantidad = GvDatos.Rows(RowIndexCantidadEspecial).FCTextBox("TbCantidadF") - If CantidadEspecialTemp - TxtCantidadEspecialDiv.Text.ToDecimal - TxtCantidad.Text.ToDecimal >= 0 Then - TxtCantidad.Text = (TxtCantidad.Text.ToDecimal + TxtCantidadEspecialDiv.Text.ToDecimal).ToString.FormatoNumero - 'RegistraScript("$('#ModalCantidad').modal('hide');") - RegistraScript("$('#DivCantidadEspecial').hide(200);") - UpDatos.Update() - TxtCodigoPS.Focus() - Else - Alert("La cantidad excede la pendiente por surtir. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia, "window.setTimeout(Focus,200);") - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - - TxtCantidadEspecialDiv.Text = "1" - End Sub -#End Region - -#End Region - - -#Region " GUARDAR " - Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) - - Select Case TipoEntrega - Case 1 - GuardaVenta() - Case 2 - GuardaTraspaso() - End Select - - End Sub - - Private Sub GuardaVenta() - - - '' INICIA: VALIDACIONES - - 'Valida el estatus de la Venta, si es = 5 O DevolucionVenta = 2, NO SE SURTE! - Dim ObjVentaInv As New ClsInventarios - If ObjVentaInv.GetEstatusVentaPorSurir(CveVentaSurtir) Then - TipoEstatus = ObjVentaInv.TipoEstatus - EsDevolucionVenta = ObjVentaInv.EsDevolucionVenta - End If - ObjVentaInv.Dispose() - - If TipoEstatus = 5 Or EsDevolucionVenta.Contiene(2, 3) Then - Alert("No se puede surtir esta venta, verifique que no esté cancelada o ya registrado su movimiento en almacen", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - - 'VALIDA CANTIDAD DE SALIDA - Dim Cantidad As Decimal = 0.0D - For Each Gvr As GridViewRow In GvDatos.Rows - If Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then - Cantidad = Gvr.FCTextBox("TbCantidadF").Text.ToDecimal - Exit For - End If - Next - - If Not Cantidad > 0 Then - Alert("No se detecto ningun movimiento por hacer. Por favor verifique e intente nuevamente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'PROCESO , si tiene proceso "176" no lo valida - If Not UsuarioActual.TienePermisoProceso(176) Then - For Each Gvr As GridViewRow In GvDatos.Rows - If Gvr.DataKey("CantidadF").ToDecimal <> Gvr.FCTextBox("TbCantidadF").Text.ToDecimal Then - Alert("En la factura no se han especificado todos los productos a entregar, favor de especificarlos para poder dar salida.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - Next - End If - - If EsDevolucionVenta = 1 Or TipoDocto.Contiene({"Ped"}) Then - For Each Gvr As GridViewRow In GvDatos.Rows - If Not Gvr.FCCheckBox("cbInv").Checked Or (Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadC").ToString.ToDecimal) Then - Alert("Es necesario surtir todos los productos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - Next - End If - - If UsuarioActual.Empresa.Funcionalidad(563) = "1" Then - If Cantidad <> DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") Then - Alert("La seccion de almacen no ha sido agregada completamente.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - Dim EsInterno As Integer = -1 - If TipoDocto = "Ped" Then - EsInterno = If(Me.EsInterno, 1, 0) - End If - - Dim ObjInventario As New ClsInventarios - Dim ObjConta As New ClsContabilidad(ObjInventario.IniciaTransacSQL()) - Dim ObjVentas As New ClsVentas(ObjInventario.IniciaTransacSQL()) - Dim ObjEventos As New ClsOIEventos(ObjInventario.IniciaTransacSQL()) - Dim ObjAcumuladores As New ClsAcumuladores(ObjInventario.IniciaTransacSQL()) - Dim CveMovimiento As Integer - Dim Folio As Integer - Dim ErrorMovInv As Boolean - Dim DtDetalle As New DataTable - Dim DtDetalleLote As New DataTable - Dim TextoError = "" - - Dim CveMovimientoGarantia As Integer = -1 - Dim FolioGarantia As Integer = -1 - - Dim CveMovimientoVirtual As Integer = -1 - Dim FolioVirtual As Integer = -1 - - 'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH - Dim Index = 0 - For Each gvr As GridViewRow In GvDatos.Rows - If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then - DtDatos.Rows(Index)("CantidadGV") = gvr.FCTextBox("TbCantidadF").Text.ToDecimal - DtDatos.Rows(Index)("CveSeccion") = gvr.FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero - DtDatos.Rows(Index)("Caducidad") = gvr.FCTextBox("TxtCaducidad").Text.ToDate - DtDatos.Rows(Index)("Lote") = gvr.FCTextBox("TxtLote").Text - End If - Index += 1 - Next - - 'VALIDA SI HUBO CAMBIOS EN LA EXISTENCIA - Dim DtDatosVenta As New DataTable - If ObjInventario.EntregaAlmacenGet(CveVentaSurtir) Then - DtDatosVenta = ObjInventario.DtResultados - End If - Dim CantidadGV = GvDatos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDecimal) - If CantidadGV <> DtDatosVenta.SUM("CantidadF").ToDecimal Then - ObjInventario.RollBack() - ObjInventario.Dispose() - ObjConta.Dispose() - ObjVentas.Dispose() - ObjEventos.Dispose() - CargaVentaPorSurtir(CveVentaSurtir) - CargaPendientes() - Alert("Ha sido cambiada la informacion de existencias de la venta actual, se han recargado la información.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not ObjVentas.UpdateVentasDevolucionAlmacen(3, CveVentaSurtir) Then - ObjInventario.RollBack() - ObjInventario.Dispose() - ObjConta.Dispose() - ObjVentas.Dispose() - ObjEventos.Dispose() - Exit Sub - End If - - Dim DtTraspasos As New DataTable - DtTraspasos.Columns.Add("CveAlmacen", GetType(Integer)) - DtTraspasos.Columns.Add("Almacen", GetType(String)) - DtTraspasos.Columns.Add("CveMovimientoSalida", GetType(Integer)) - DtTraspasos.Columns.Add("FolioSalida", GetType(Integer)) - DtTraspasos.Columns.Add("CveMovimientoEntrada", GetType(Integer)) - DtTraspasos.Columns.Add("FolioEntrada", GetType(Integer)) - - Dim CveMovimientoSalida = -1, FolioSalida = -1, CveMovimientoEntrada = -1, CveMovimientoEntradaApartado = -1, FolioEntrada = -1, CveMovimientoSalidaDevRem = -1, FolioMovimientoSalidaDevRem = -1, CveMovimientoEntradaDevRem = -1, FolioMovimientoEntradaDevRem = -1 - - Try - 'VALIDA EXISTENCIA 2 - If TipoMovimiento = 1 Then - Dim StrXML As New StringBuilder - StrXML.Append("") - For Each Dr As DataRow In DtDatos.Rows - If Dr("CantidadGV").ToString.ToDecimal > 0 Then - If CBool(Dr("AplicaSeccion")) Then - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - For Each Dr1 As DataRow In DtDetalle.Rows - StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), 1, Dr1("SerieLote"), If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1), If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha)) - Next - ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then - DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - For Each Dr1 As DataRow In DtDetalle.Rows - StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'"), Dr1("Lote")) - Next - Else - StrXML.AppendFormat("", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), "-1", If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1), If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha)) - End If - End If - Next - StrXML.Append("") - - Dim TieneErrorExistencia = False - If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), If(TipoEntrega = 2, 1, -1), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - If ObjInventario.DtResultados.Rows.Count > 0 Then - TieneErrorExistencia = True - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - TextoError += $" - {Dr("CodigoPS")} Existencia: {Dr("Existencia").ToString.ToDecimal.ToString("#,##0.##")}
    " - Next - End If - Else - TieneErrorExistencia = True - End If - - If TieneErrorExistencia Then - ObjInventario.RollBack() - ObjInventario.Dispose() - ObjConta.Dispose() - ObjVentas.Dispose() - ObjEventos.Dispose() - If TextoError.Length > 0 Then - Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:

    {TextoError}", TipoMensaje.MsgAdvertencia) - End If - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - - End If - - '' TERMINA: VALIDACIONES - - - '' COMIENZA: APARTADOS - Dim CantidadPendiente As Decimal = 0 - Dim CantidadSaldo As Decimal = 0 - - - If CveVendedor > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(146) = "1" Or CveCliente > 0) Then 'no debe considerar cuando es pedido de contrato - If TipoMovimiento = 1 Then ' SI ES DEVOLUCION NO APLICA APARTADO - ' SALIDA POR TRASPASO DE LOS ALMACENES DE APARTADO - For Each Dr As DataRow In DtDatos.Rows - If Dr("CantidadGV").ToString.ToDecimal > 0 Then - - If CBool(Dr("AplicaSerieLote")) Then - - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - For Each Dr1 As DataRow In DtDetalle.Rows - If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), SerieLote:=Dr1("SerieLote").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows - - 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO - CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero - - If Not CveMovimientoSalida > 0 Then - CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, - Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), - CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G1") - FolioSalida = ObjInventario.Folio - - If Not CveMovimientoSalida > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - Dim DrMovto = DtTraspasos.NewRow - DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero - DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero - DrMovto("CveMovimientoSalida") = CveMovimientoSalida - DrMovto("FolioSalida") = FolioSalida - DtTraspasos.Rows.Add(DrMovto) - End If - - - CantidadPendiente = 1 - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1 - DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle") - Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente - Exit For - Next - End If - If ErrorMovInv Then Exit For - Next - - ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then - - DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - For Each Dr1 As DataRow In DtDetalle.Rows - If ObjInventario.GetExistenciasProducto(Dr1("CvePS").ToString.ToEntero, Dr1("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - - CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal - - For Each Dr2 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows - - 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO - CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr2("CveAlmacen")}").ToEntero - - If Not CveMovimientoSalida > 0 Then - CveMovimientoSalida = ObjInventario.AddMovimiento(Dr2("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, - Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), - CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G2") - FolioSalida = ObjInventario.Folio - - If Not CveMovimientoSalida > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - Dim DrMovto = DtTraspasos.NewRow - DrMovto("Almacen") = Dr2("Almacen").ToString.ToEntero - DrMovto("CveAlmacen") = Dr2("CveAlmacen").ToString.ToEntero - DrMovto("CveMovimientoSalida") = CveMovimientoSalida - DrMovto("FolioSalida") = FolioSalida - DtTraspasos.Rows.Add(DrMovto) - End If - - CantidadPendiente = If(Dr1("Cantidad").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("Cantidad").ToString.ToDecimal) - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("FueTraspaso") = 1 - DtDatosDetalle.Select($"Consec = {Dr1("Consec")}")(0)("CveVentaDetalle") = Dr("CveVentaDetalle") - - CantidadSaldo -= CantidadPendiente - Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente - If CantidadSaldo <= 0 Then Exit For - Next - End If - Next - - Else - - If ObjInventario.GetExistenciasProducto(Dr("CvePS").ToString.ToEntero, Dr("CveUM").ToString.ToEntero, UsuarioActual.CveEmpresa, -1, FechaMovto:=TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveTipoAlmacen:=9, CveVendedor:=CveVendedor, CveSubProyecto:=CveSubProyecto, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeApartados:=-1, Caducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - - CantidadSaldo = Dr("CantidadGV").ToString.ToDecimal - - For Each Dr1 As DataRow In ObjInventario.DtResultados.FiltraParametros("CveAlmacen > 0 AND ExistenciaFinal > 0").Rows - - 'BUSCA SI EXISTE YA UN TRASPASO DEL ALMACEN DE APARTADO - CveMovimientoSalida = DtTraspasos.FiltroPrimeroValor("CveMovimientoSalida", $"CveAlmacen = {Dr1("CveAlmacen")}").ToEntero - - If Not CveMovimientoSalida > 0 Then - CveMovimientoSalida = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, - Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, - CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G3") - FolioSalida = ObjInventario.Folio - - If Not CveMovimientoSalida > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - Dim DrMovto = DtTraspasos.NewRow - DrMovto("Almacen") = Dr1("Almacen").ToString.ToEntero - DrMovto("CveAlmacen") = Dr1("CveAlmacen").ToString.ToEntero - DrMovto("CveMovimientoSalida") = CveMovimientoSalida - DrMovto("FolioSalida") = FolioSalida - DtTraspasos.Rows.Add(DrMovto) - End If - - - CantidadPendiente = If(Dr1("ExistenciaFinal").ToString.ToDecimal > CantidadSaldo, CantidadSaldo, Dr1("ExistenciaFinal").ToString.ToDecimal) - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadPendiente.ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, - SerieLote:=Dr("SerieLote").ToString, - CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, - FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), - Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), - CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - CantidadSaldo -= CantidadPendiente - Dr("CantidadTraspaso") = Dr("CantidadTraspaso").ToString.ToDecimal + CantidadPendiente - If CantidadSaldo <= 0 Then Exit For - Next - - If ErrorMovInv Then Exit For - Else - ErrorMovInv = True - End If - - End If - If ErrorMovInv Then Exit For - - End If - - Next - - 'ENTRADA POR TRASPASO AL ALMACEN GENERAL - If Not ErrorMovInv Then - For Each Dr1 As DataRow In DtTraspasos.Rows - CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero - - CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(DdlAlmacen.SelectedValue.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, - Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, CveMovimientoRelacionado:=CveMovimientoSalida, - Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, Modulo:="RE/G4") - FolioEntrada = ObjInventario.Folio - - If Not CveMovimientoEntradaApartado > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado - Dr1("FolioEntrada") = FolioEntrada - - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, SerieLote:=Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - End If - - If ErrorMovInv Then Exit For - - Next - End If - End If - End If - '' TERMINA: APARTADOS - - ' COMIENZA: GARANTIAS - If TipoDocto.Contiene("Ing", "Rem") AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso TipoMovimiento = 1 Then - - Dim CveAlmacenGarantia As Integer = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 6).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() - Dim DtGarantias As DataTable = Nothing - - If ObjAcumuladores.GetGarantiasDetalle(CveVentaSurtir) Then - DtGarantias = ObjAcumuladores.DtResultados.Copy() - End If - - If DtGarantias IsNot Nothing AndAlso DtGarantias.Rows.Count > 0 AndAlso CveAlmacenGarantia > 0 Then - CveMovimientoGarantia = ObjInventario.AddMovimiento(CveAlmacenGarantia, 2, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, Modulo:="RE/G5") - FolioGarantia = ObjInventario.Folio - - For Each RowGarantia As DataRow In DtGarantias.Rows - Dim CvePS = RowGarantia("CvePS").ToString().ToEntero() - Dim CveTamaño As Integer = RowGarantia("CveTamaño").ToString().ToEntero() - Dim CveUM As Integer = RowGarantia("CveUnidadMedida").ToString().ToEntero() - Dim PU As Decimal = RowGarantia("Importe").ToString().ToDecimal() ' / RowGarantia("Cantidad").ToString().ToDouble() - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoGarantia, RowGarantia("Cantidad").ToString().ToDouble(), CveUM, CvePS, PU, -1) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - End If - End If - ' TERMINA: GARANTIAS - - - - If Not ErrorMovInv Then - Dim ConceptoMovimiento = 3 - ConceptoMovimiento = If(TipoMovimiento = 1, ConceptoMovimiento, 18) - ConceptoMovimiento = If(CveAlmacenTraspasoDestino > 0, 8, ConceptoMovimiento) - - Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero - - If TipoDocto = "Rem" AndAlso CveAlmacenTraspasoDestino = 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error. no se tiene definido el almacen destino" - End If - - 'DEVOLUCION REMISION - If TipoMovimiento = 2 And TipoDocto = "Rem" Then - ConceptoMovimiento = 8 - Almacen1 = CveAlmacenTraspasoDestino - CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero - End If - - 'CANCELACION DE DEVOLUCION - If TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1 Then - ConceptoMovimiento = 3 - Almacen1 = DdlAlmacen.SelectedValue.ToEntero - CveAlmacenTraspasoDestino = DdlAlmacen.SelectedValue.ToEntero - End If - - 'DEVOLUCION DIRECTA A ENTREGA POR ADELANTADO - If TipoMovimiento = 2 And ConceptoMovimiento = 18 AndAlso EsDevolucionDirecta Then - ConceptoMovimiento = 41 - End If - - CveMovimiento = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, - CveContrato:=CveContrato, CveAlmacenDestino:=CveAlmacenTraspasoDestino, Modulo:="RE/G7") - Folio = ObjInventario.Folio - - 'SALIDA DE ALMACEN - SALIDA POR TRASPASO CUANDO ES REMISION - DEVOLUCION (SI ES TRASPASO Y TIENE CONTRATO NO HACE DEVOLUCIóN) - 'If Not (CveContrato > 0 And CveAlmacenTraspasoDestino > 0) Then - If CveMovimiento > 0 Then - - 'SACA LO DE TRASPASOS - APARTADO - For Each Dr1 As DataRow In DtTraspasos.Rows - CveMovimientoSalida = Dr1("CveMovimientoEntrada").ToString.ToEntero - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - If ObjInventario.DtResultados.Rows.Count = 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error, no se tienen registros que ingresar" - Exit Sub - End If - - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, SerieLote:=Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - Else - ErrorMovInv = True - TextoError = "Ocurrió un error al obtener los registros" - End If - If ErrorMovInv Then Exit For - Next - - 'ES EL MOVIMIENTO PRINCIPAL - CantidadPendiente = 0 - Dim Cont As Integer = 0 - For Each Dr As DataRow In DtDatos.Rows - CantidadPendiente = Dr("CantidadGV").ToString.ToDecimal - Dr("CantidadTraspaso").ToString.ToDecimal - If CantidadPendiente > 0 Then - Dim PU As Decimal = 0 - - 'SI FUE POR SERIELOTE - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) - DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) - If DtDetalle.Rows.Count > 0 Then - For Each Dr1 As DataRow In DtDetalle.Rows - If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." - Exit For - End If - Next - ElseIf DtDetalleLote.Rows.Count > 0 Then - For Each Dr1 As DataRow In DtDetalleLote.Rows - If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero} AND SerieLote = '{Dr1("SerieLote").ToString}'").ToString.ToDecimal - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, Dr1("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." - Exit For - End If - Next - Else - If TipoMovimiento = 2 AndAlso DtExistencias IsNot Nothing Then - PU = DtExistencias.FiltroPrimeroValor("PU", $"CvePS = {Dr("CvePS")} AND CveUM = {Dr("CveUM").ToString.ToEntero}").ToString.ToDecimal - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimiento, CantidadPendiente, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, PU, -1, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, FechaCaducidad:=If(CBool(Dr("AplicaCaducidad")), Dr("Caducidad").ToString.ToDate, MinFecha), Lote:=If(CBool(Dr("AplicaLote")), Dr("Lote").ToString, "-1"), CveSeccionAlmacen:=If(CBool(Dr("AplicaSeccion")), Dr("CveSeccion").ToString.ToEntero, -1)) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." - Exit For - End If - End If - If ObjInventario.CveMovimientoDetalle > 0 AndAlso DtSeccionAlmacen.Rows.Count > 0 Then - For Each Dr2 As DataRow In DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {Cont}").Rows - If Not ObjInventario.AddMovimientosDetalleSeccionesAlmacen(ObjInventario.CveMovimientoDetalle, Dr2("CveSeccionAlmacen").ToString.ToEntero, -Dr2("CantidadSeccionAlmacen").ToString.ToDecimal) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar las secciones de almacen. Por favor vuelva a intentar." - Exit For - End If - Next - End If - Cont += 1 - End If - Next - Else - ErrorMovInv = True - End If - End If - 'End If - - - 'ENTRADA POR TRASPASO CUANDO ES REMISION - If Not ErrorMovInv Then - If CveAlmacenTraspasoDestino > 0 AndAlso Not (TipoMovimiento = 2 And TipoDocto = "Dev" And EsDevolucionVenta = 1) Then ' TRASPASO CUANDO ES REMISION - CveMovimientoEntrada = ObjInventario.AddMovimiento(CveAlmacenTraspasoDestino, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, - CveMovimientoRelacionado:=CveMovimiento, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, Modulo:="RE/G8") - FolioEntrada = ObjInventario.Folio - - If CveMovimientoEntrada <= 0 Then - TextoError = "No se pudo generar el movimiento de entrada correctamente" - ErrorMovInv = True - Else - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDouble, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString, EsInterno:=EsInterno, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero()) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For - End If - Next - Else - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de entrada" - End If - End If - - Else 'REGISTRO LA PREPOLIZA DE COSTO VS ALMACEN - SALIDA ALMACEN - Dim DtCostos As DataTable = Nothing - Dim ValorInventario As Decimal = 0 - If ObjInventario.GetMovimientosDetalle(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtCostos = ObjInventario.DtResultados - - Dim tmpCostos As DataTable = DtCostos.FiltraParametros("", "", {"CveClasificacion"}) - Dim IdCtaContableAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContable", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero - Dim CveCuentaAlmacen As Integer = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCtaContableSIG", $"CveAlmacen = {DdlAlmacen.SelectedValue}").ToEntero - Dim IdCtaContable As Integer = 0 - Dim CveCuenta As Integer = 0 - If tmpCostos.Rows.Count > 0 Then - - - If ObjVentas.GetVenta(CveVentaSurtir, UsuarioActual.CveEmpresa) Then - Dim Fecha As Date = TxtFecha.Text.ToDate ' If(TipoMovimiento <> 1, TxtFecha.Text.ToDate, ObjVentas.DtResultados(0)("Fecha").ToString.ToDate) - Dim CveCliente As Integer = ObjVentas.DtResultados(0)("CveCliente").ToString.ToEntero - Dim ClienteNombre As String = ObjVentas.DtResultados(0)("ClienteNombre").ToString - Dim SerieFolio As String = ObjVentas.DtResultados(0)("SerieFolio").ToString - Dim TotalCosto As Decimal = DtCostos.SUMD("Total").RoundSQL() - Dim TotalCostoAcumulado As Decimal = 0 - Dim cont As Integer = 1 - - Dim ValorMultiplicador = 1 - - If TipoMovimiento = 1 Then - ValorMultiplicador = 1 - ElseIf TipoMovimiento = 2 Then - ValorMultiplicador = -1 - ElseIf TipoMovimiento = 2 AndAlso TipoDocto.Contiene({"Dev"}) And (EsDevolucionVenta = 1) Then - ValorMultiplicador = 1 - End If - - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Inventario/RecepcionEntrega", 4, TotalCosto, TotalCosto, 1, Fecha, ClienteNombre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - 'Se agrega movimiento separado por la cuenta de ventas (ER) - - If CvePrePoliza > 0 Then - - For Each RowInv As DataRow In tmpCostos.Rows - ValorInventario = DtCostos.SUMD("Total", $"CveClasificacion = {RowInv("CveClasificacion")}").RoundSQL() - TotalCostoAcumulado += ValorInventario - - 'cuando es el último movimiento y hay diferencias en los importes - If cont = DtCostos.FiltraParametros("", "", {"CveClasificacion"}).Rows.Count AndAlso TotalCosto <> TotalCostoAcumulado Then - ValorInventario = ValorInventario + (TotalCosto - TotalCostoAcumulado) - End If - - 'Concepto = String.Format("{0} - {1}", Row2("Clasificacion").ToString, Row2("SubProyecto").ToString) - IdCtaContable = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostos", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - CveCuenta = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("IdCuentaCostosSIG", $"CveClasificacion = {RowInv("CveClasificacion")}").ToEntero - - If Not ErrorMovInv Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ValorMultiplicador * ValorInventario, SerieFolio, 69, SerieFolio, Fecha, IdCtaContable, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * ValorInventario, CveCuenta:=CveCuenta, CveClasificacion:=RowInv("CveClasificacion").ToString.ToEntero) Then - ErrorMovInv = True - End If - End If - - cont += 1 - Next - - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ValorMultiplicador * TotalCosto, SerieFolio, 68, SerieFolio, Fecha, IdCtaContableAlmacen, -1, CveVenta:=CveVentaSurtir, CveCliente:=CveCliente, CveMovimientoAlmacen:=CveMovimiento, CveSubProyecto:=CveSubProyecto, ImporteMX:=ValorMultiplicador * TotalCosto, CveCuenta:=CveCuentaAlmacen) Then - ErrorMovInv = True - End If - - 'AutoConta - El movimiento 1 es el de Venta - Dim AutoConta As Boolean = UsuarioActual.Empresa.Funcionalidad(200) = "1" - - If AutoConta And Not ErrorMovInv Then - Dim ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa) - - If IdCtaContable > 0 Then - If Not ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjContPaq) Then - Alert("Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico") - ErrorMovInv = True - TextoError = "Ocurrio un Error al contabilizar, pongase en contacto con Soporte Técnico" - End If - Else - Alert(String.Format("No se puede contabilizar ya que falta asignación de las cuentas contables"), TipoMensaje.MsgAdvertencia) - End If - - ObjContPaq.Dispose() - End If - Else - ErrorMovInv = True - TextoError = "Ocurrió un Error al ingresar la prepoliza.1" - End If - Else - ErrorMovInv = True - TextoError = "Ocurrió un Error al ingresar las prepolizas.2" - End If - Else - ErrorMovInv = True - TextoError = "Ocurrió un Error al ingresar las prepolizas.3" - End If - Else - ErrorMovInv = True - TextoError = "Ocurrió un Error al ingresar las prepolizas.4" - End If - End If - - End If - - 'DEVOLUCION APARTADOS - If Not ErrorMovInv Then - If TipoMovimiento = 2 Then - If ObjInventario.VentasAlmacenApartadosGet(CveVentaSurtir) Then - - Dim DtTempApartados = ObjInventario.DtResultados.FiltraParametros("CveTipoAlmacen = 9", "CveAlmacen") - Dim CveMovimientoSalidaApartado = -1 - Dim CveAlmacenApartado = -1 - Dim CveAlmacenOrigen = If(CveAlmacenTraspasoDestino > 0, CveAlmacenTraspasoDestino, DdlAlmacen.SelectedValue.ToEntero) - - For Each Dr As DataRow In DtTempApartados.Rows - - If CveMovimientoSalidaApartado = -1 Or CveAlmacenApartado <> Dr("CveAlmacen").ToString.ToEntero Then - CveMovimientoSalidaApartado = ObjInventario.AddMovimiento(CveAlmacenOrigen, 8, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, - Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, CveCliente:=CveCliente, - CveAlmacenDestino:=Dr("CveAlmacen").ToString.ToEntero, Modulo:="RE/G9") - FolioSalida = ObjInventario.Folio - CveAlmacenApartado = Dr("CveAlmacen").ToString.ToEntero - - Dim DrMovto = DtTraspasos.NewRow - DrMovto("Almacen") = Dr("Almacen").ToString.ToEntero - DrMovto("CveAlmacen") = Dr("CveAlmacen").ToString.ToEntero - DrMovto("CveMovimientoSalida") = CveMovimientoSalidaApartado - DrMovto("FolioSalida") = FolioSalida - DtTraspasos.Rows.Add(DrMovto) - End If - - If Not CveMovimientoSalidaApartado > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de control de apartados" - Exit For - End If - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalidaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de control de apartados" - Exit For - End If - Next - - If Not ErrorMovInv Then - For Each Dr1 As DataRow In DtTraspasos.Rows - CveMovimientoSalida = Dr1("CveMovimientoSalida").ToString.ToEntero - - CveMovimientoEntradaApartado = ObjInventario.AddMovimiento(Dr1("CveAlmacen").ToString.ToEntero, 9, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, - -1, CveVentaSurtir, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, CveAlmacenDestino:=DdlAlmacen.SelectedValue.ToEntero, - CveMovimientoRelacionado:=CveMovimientoSalida, Guia:=TxtGuia.Text, CveContrato:=CveContrato, CveVendedor:=CveVendedor, - CveCliente:=CveCliente, Modulo:="RE/G10") - FolioEntrada = ObjInventario.Folio - - If Not CveMovimientoEntradaApartado > 0 Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los movimientos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - - Dr1("CveMovimientoEntrada") = CveMovimientoEntradaApartado - Dr1("FolioEntrada") = FolioEntrada - - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntradaApartado, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - End If - - If ErrorMovInv Then Exit For - - Next - End If - - End If - End If - End If - - 'QUEMAR REMISIONES - If Not ErrorMovInv And EsDevolucionVenta = 1 And TipoDocto = "Ing" Then - Dim DtDevRem As New DataTable - - 'CARGA REMISIONES DE LA VENTA DEVUELTA - If ObjInventario.GetDevolucionRemisionesFacturadas(CveVentaSurtir) Then - DtDevRem = ObjInventario.DtResultados.FiltraParametros("CantidadAlmacen = 0") - Else - ErrorMovInv = True - End If - - If Not ErrorMovInv Then - If DtDevRem.Rows.Count > 0 Then - For Each DrMovtos As DataRow In DtDevRem.FiltraParametros("", "CveRem", {"CveRem"}).Rows - If Not ObjInventario.ActualizarEsDevolucionVenta(DrMovtos("CveRem").ToString.ToEntero, 2) Then - TextoError = "Ocurrió un error al hacer la devolución hacia la remision. Por favor vuelva a intentar." - ErrorMovInv = True - Exit For - End If - Next - End If - Else - TextoError = "Ocurrió un error al hacer la devolucion a remisión. Por favor vuelva a intentar." - ErrorMovInv = True - End If - - End If - - 'QUEMA DEVOLUCION | QUEMA = LA QUITA DE PENDIENTE POR RECIBIR (DEVOLVER) - If Not ErrorMovInv And EsDevolucionVenta = 1 Then - If Not ObjVentas.UpdateVentasDevolucionAlmacen(2, CveVentaSurtir) Then - TextoError = "Ocurrió un error al hacer la devolución. Por favor vuelva a intentar." - ErrorMovInv = True - End If - End If - - If Not ErrorMovInv And EsDevolucionVenta = 0 Then - If Not ObjVentas.UpdateVentasDevolucionAlmacen(0, CveVentaSurtir) Then - TextoError = "Ocurrió un error al hacer la devolucion. Por favor vuelva a intentar." - ErrorMovInv = True - End If - End If - - ' COMIENZA: VIRTUAL - If Not ErrorMovInv AndAlso TipoDocto.Contiene("Ing", "Dev") AndAlso UsuarioActual.Empresa.Funcionalidad(573) = "1" AndAlso CveMovimiento > 0 Then - Dim DtPSVirtual As New DataTable("DtTamanios") - - If ObjInventario.GetMovimientosDetalleVirtual(CveMovimiento, UsuarioActual.CveEmpresa) Then - DtPSVirtual = ObjInventario.DtResultados - End If - - ' - 'DtPSVirtual.Columns.Add(New DataColumn("CvePS", GetType(Integer))) - 'DtPSVirtual.Columns.Add(New DataColumn("Cantidad", GetType(Decimal))) - 'DtPSVirtual.Columns.Add(New DataColumn("PU", GetType(Decimal))) - 'DtPSVirtual.Columns.Add(New DataColumn("CveUM", GetType(Integer))) - - 'Dim DtTamanios As DataTable = Nothing - - 'If ObjAcumuladores.TamañoGet(-1, UsuarioActual.CveEmpresa) Then - ' DtTamanios = ObjAcumuladores.DtResultados.Copy() - 'End If - - Dim CveConceptoMovimientoVirtual As Integer = -1 - Dim CveAlmacenVirtual As Integer = -1 - Dim CveMovimientoRelacionadoVirtual As Integer = CveMovimiento - Dim ValidaVirtual As Boolean = False - CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() - - If TipoMovimiento = 1 Then - CveConceptoMovimientoVirtual = 37 - - ElseIf TipoMovimiento = 2 Then - ValidaVirtual = True - CveConceptoMovimientoVirtual = 36 - End If - - If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then - CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVentaSurtir, -1, -1, - Observaciones:=TxtObservaciones.Text.Trim, Guia:=TxtGuia.Text, CveMovimientoRelacionado:=CveMovimientoRelacionadoVirtual, Modulo:="RE/G6") - FolioVirtual = ObjInventario.Folio - - If CveMovimientoVirtual > 0 Then - For Each RowUsado As DataRow In DtPSVirtual.Rows - Dim CvePS = RowUsado("CvePS").ToString().ToEntero() - Dim CantidadUsado As Double = RowUsado("Cantidad").ToString().ToDouble() - Dim PU As Decimal = RowUsado("PU").ToString().ToDecimal() - Dim CveUM As Integer = RowUsado("CveUM").ToString().ToEntero() - - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoVirtual, CantidadUsado, CveUM, CvePS, PU, -1) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de traspaso de apartado. Por favor vuelva a intentar." - Exit For - End If - Next - Else - ErrorMovInv = True - End If - - Else - If ValidaVirtual Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar el movimiento en almacen virtual. Por favor vuelva a intentar." - - End If - End If - - If DtPSVirtual.Rows.Count = 0 AndAlso ValidaVirtual = True Then - ErrorMovInv = True - TextoError = "No se tienen productos para el almacen virtual." - End If - End If - - ' TERMINA: VIRTUAL - - - 'AGREGA BITACORA A VENTA - If Not ErrorMovInv Then - Dim MensajeBitacora = If(TipoMovimiento = 1, "Surtida", "Devuelta") - If Not ObjEventos.AddEventoBitacora(String.Format("Venta {2} en Folio: {1}", CveMovimiento, Folio, MensajeBitacora), "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveVenta:=CveVentaSurtir) Then - ErrorMovInv = True - End If - End If - - Catch ex As Exception - ErrorMovInv = True - OnError("Ocurrió un error al guardar", ex) - End Try - - If Not ErrorMovInv Then - ObjInventario.Commit() - RegistraScript("playsonidito('beep-07.wav')") - Dim Msg As New StringBuilder - - Msg.AppendFormat("Movimiento {2}: {1}", CveMovimiento, Folio, If(TipoMovimiento = 1, "Salida", "Entrada")) - Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimiento))) - - If CveMovimientoEntrada > 0 Then - Msg.AppendFormat("

    Movimiento Entrada (Traspaso): {1}", CveMovimientoEntrada, FolioEntrada) - Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) - End If - - If DtTraspasos.Rows.Count > 0 Then - Msg.AppendFormat("

    Movimientos de Control (Apartados):") - For Each Dr As DataRow In DtTraspasos.Rows - Msg.AppendFormat("
    Almacén {0} | Salida por Traspaso: {2} | Entrada por Traspaso: {4} ", Dr("Almacen"), Dr("CveMovimientoSalida"), Dr("FolioSalida"), Dr("CveMovimientoEntrada"), Dr("FolioEntrada")) - Next - End If - - If CveMovimientoGarantia > 0 Then - Msg.AppendFormat("
    Movimiento de Entrada (garantías): {1}", CveMovimientoGarantia, FolioGarantia) - Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoGarantia))) - End If - - If CveMovimientoVirtual > 0 Then - Msg.AppendFormat("

    {0} Almacen Virtual: ", If(TipoMovimiento = 1, "Salida", "Entrada")) - Msg.AppendFormat("{1}", CveMovimientoVirtual, FolioVirtual) - Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoVirtual))) - End If - - Alert(Msg.ToString, TipoMensaje.MsgInformacion) - - Limpia() - CargaPendientes() - Else - ObjInventario.RollBack() - Alert(TextoError, TipoMensaje.MsgError) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - End If - - ObjAcumuladores.Dispose() - ObjInventario.Dispose() - ObjConta.Dispose() - ObjVentas.Dispose() - ObjEventos.Dispose() - - End Sub - - Private Sub GuardaTraspaso() - - 'OBLIGA A SURTIR TODO - For Each Gvr As GridViewRow In GvDatos.Rows - If Not Gvr.FCCheckBox("cbInv").Checked Or (Gvr.FCCheckBox("cbInv").Checked AndAlso Gvr.FCTextBox("TbCantidadF").Text.ToDecimal <> Gvr.DataKey("CantidadC").ToString.ToDecimal) Then - Alert("Es necesario surtir todos los productos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - Next - - 'VALIDA TRANSITORIO - If ChkTransitorio.Checked Then - If TxtResponsable.Text.Trim = "" Then - Alert("Debe seleccionar un responsable para el traspaso transitorio.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);") - Exit Sub - End If - - If DdlAlmacenTransitorio.SelectedValue.ToEntero <= 0 Then - Alert("Debe seleccionar un almacen transitorio.", TipoMensaje.MsgAdvertencia) - RegistraScript("playsonidito(''142608__autistic-lucario__error.wav'')") - If ChkTransitorio.Checked Then RegistraScript("$('#DivTransitorio').show(200);") - Exit Sub - End If - End If - - Dim ObjInventario As New ClsInventarios : ObjInventario.IniciaTransacSQL() - Dim CveMovimientoSalida As Integer - Dim ConceptoMovimiento = 0 - Dim FolioSalida As Integer - Dim CveMovimientoEntrada As Integer - Dim FolioEntrada As Integer - Dim ErrorMovInv As Boolean - Dim DtDetalle As New DataTable - Dim DtDetalleLote As New DataTable - Dim TextoError = "" - - 'PASA DATOS DEL GV A DATATABLE PARA MANEJOR CON FOR EACH - Dim Index = 0 - For Each gvr As GridViewRow In GvDatos.Rows - If gvr.FCCheckBox("cbInv").Checked AndAlso gvr.FCTextBox("TbCantidadF").Text.ToDecimal > 0 Then - DtDatos.Rows(Index)("CantidadGV") = gvr.FCTextBox("TbCantidadF").Text.ToDecimal - End If - Index += 1 - Next - - 'VALIDA SI HUBO CAMBIOS EN LA EXISTENCIA - Dim DtDatosTraspaso As New DataTable - If ObjInventario.EntregaAlmacenTraspasosGet(CveTraspasoSurtir) Then - DtDatosTraspaso = ObjInventario.DtResultados - End If - Dim CantidadGV = GvDatos.Rows.Cast(Of GridViewRow)().Sum(Function(gvr) gvr.DataKey("CantidadF").ToDecimal) - If DtDatos.SUM("CantidadF") <> DtDatosTraspaso.SUM("CantidadF") Then - ObjInventario.RollBack() - ObjInventario.Dispose() - CargaTraspasoPorSurtir(CveTraspasoSurtir) - CargaPendientes() - Alert("Ha sido cambiada la informacion de existencias del traspaso actual. Por favor verifique.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'VALIDA QUE EL TRASPASO SIGA VIGENTE - If ObjInventario.AddTrasladoSolicitudGet(CveTraspasoSurtir, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 AndAlso ObjInventario.DtResultados.Rows(0)("CveTrasladoEstatus").ToString = "2" Then - ObjInventario.RollBack() - ObjInventario.Dispose() - CargaTraspasoPorSurtir(CveTraspasoSurtir) - CargaPendientes() - Alert("Ha sido cambiada la informacion del traspaso actual. Por favor verifique.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'VALIDA ALMACENES - Dim Almacen1 = DdlAlmacen.SelectedValue.ToEntero - Dim Almacen2 = CveAlmacenTraspasoDestino - If Almacen1 <= 0 Or Almacen2 <= 0 Then - Alert("Ocurrió un error al obtener los almacenes del movimiento. Por favor recargue y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - ObjInventario.RollBack() - ObjInventario.Dispose() - Exit Sub - End If - - 'VERIFICAR EXISTENCIA - Dim StrXML As New StringBuilder - StrXML.Append("") - For Each Dr As DataRow In DtDatos.Rows - If Dr("CantidadGV").ToString.ToDecimal > 0 Then - If Dr("Inv_CveMetodoInventario").ToString = "5" Then - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - For Each Dr1 As DataRow In DtDetalle.Rows - StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), 1, Dr1("SerieLote")) - Next - ElseIf Dr("Inv_CveMetodoInventario").ToString = "6" Then - DtDetalle = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0}", Dr("Consec"))) - For Each Dr1 As DataRow In DtDetalle.Rows - StrXML.AppendFormat("", Dr1("CvePS"), Dr1("CveUM"), DtDatosDetalleLote.SUM("Cantidad", $"Lote = '{Dr1("Lote").ToString}' AND Batch = '{Dr1("Batch").ToString}'"), Dr1("Lote")) - Next - Else - StrXML.AppendFormat("", Dr("CvePS"), Dr("CveUM"), Dr("CantidadGV"), "-1") - End If - End If - Next - StrXML.Append("") - - Dim TieneErrorExistencia = False - If ObjInventario.GetExistenciasPSXML(StrXML.ToString(), DdlAlmacen.SelectedValue.ToEntero, TxtFecha.Text.ToDateTime.ToString("yyyy/MM/dd HH:mm"), CveSubProyecto, CveVendedor, If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), If(TipoEntrega = 2, 1, -1), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - If ObjInventario.DtResultados.Rows.Count > 0 Then - TieneErrorExistencia = True - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - TextoError += $" - {Dr("CodigoPS")} Existencia: {Dr("Existencia").ToString.ToDecimal.ToString("#,##0.##")}
    " - Next - End If - Else - TieneErrorExistencia = True - End If - - If TieneErrorExistencia Then - ObjInventario.RollBack() - ObjInventario.Dispose() - If TextoError.Length > 0 Then - Alert($" Lo(s) siguiente(s) Productos no tienen existencia suficiente:

    {TextoError}", TipoMensaje.MsgAdvertencia) - End If - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - Exit Sub - End If - - 'SALIDA POR TRASPASO - If Not ErrorMovInv Then - ConceptoMovimiento = 26 - CveMovimientoSalida = ObjInventario.AddMovimiento(Almacen1, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, Guia:="", - CveContrato:=-1, CveAlmacenDestino:=CveAlmacenTraspasoDestino, Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT") - FolioSalida = ObjInventario.Folio - If CveMovimientoSalida > 0 Then - Dim CantidadPendiente As Decimal = 0 - - For Each Dr As DataRow In DtDatos.Rows - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) - DtDetalleLote = DtDatosDetalleLote.FiltraParametros(String.Format("ConsecId = {0} AND FueTraspaso IS NULL", Dr("Consec"))) - If DtDetalle.Rows.Count > 0 Then 'SI FUE POR SERIELOTE - For Each Dr1 As DataRow In DtDetalle.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, 1, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, SerieLote:=Dr1("SerieLote").ToString, CveVentaDetalle:=-1, CveContratoDetalle:=Dr("CveContratoDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." - Exit For - End If - Next - ElseIf DtDetalleLote.Rows.Count > 0 Then 'SI FUE POR LOTE BATCH - For Each Dr1 As DataRow In DtDetalleLote.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr1("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, Lote:=Dr1("Lote").ToString, Batch:=Dr1("Batch").ToString, CveVentaDetalle:=-1, CveContratoDetalle:=Dr("CveContratoDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos con serie. Por favor vuelva a intentar." - Exit For - End If - Next - Else 'NORMAL - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Dr("CantidadGV").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, 0, -1, -1, CveContratoDetalle:=Dr("CveContratoDetalle").ToString.ToEntero) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al procesar los conceptos de salida. Por favor vuelva a intentar." - Exit For - End If - End If - Next - Else - TextoError = "Ocurrió un error al generar el movimiento de salida." - ErrorMovInv = True - End If - End If - - 'ENTRADA POR TRASPASO - If Not ErrorMovInv Then - 'sino es transitorio, los transitorios, ya no se hace otro movimiento - If Not ChkTransitorio.Checked Then - ConceptoMovimiento = 27 ' If(ChkTransitorio.Checked, 2, 27) - Almacen2 = If(ChkTransitorio.Checked, DdlAlmacenTransitorio.SelectedValue.ToEntero, CveAlmacenTraspasoDestino) - CveMovimientoEntrada = ObjInventario.AddMovimiento(Almacen2, ConceptoMovimiento, 1, TxtFecha.Text.ToDate, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, -1, Observaciones:=TxtObservaciones.Text.Trim, - Guia:="", CveContrato:=CveContrato, CveMovimientoRelacionado:=CveMovimientoSalida, CveAlmacenDestino:=CveAlmacenTraspasoDestino, - Recibio:=If(ChkTransitorio.Checked, TxtResponsable.Text.Trim, ""), Modulo:="RE/GT1") - FolioEntrada = ObjInventario.Folio - If CveMovimientoEntrada > 0 Then - If ObjInventario.GetMovimientosDetalle(CveMovimientoSalida, UsuarioActual.CveEmpresa) Then - For Each Dr As DataRow In ObjInventario.DtResultados.Rows - If Not ObjInventario.AddMovimientoDetalle(CveMovimientoEntrada, Dr("Cantidad").ToString.ToDecimal, Dr("CveUM").ToString.ToEntero, Dr("CvePS").ToString.ToEntero, Dr("PU").ToString.ToDecimal, Dr("CveAF").ToString.ToEntero, -1, Dr("SerieLote").ToString, CveMovimientoDetalleEntrada:=Dr("CveMovimientoDetalle").ToString.ToEntero, CveVentaDetalle:=Dr("CveVentaDetalle").ToString.ToEntero, Lote:=Dr("Lote").ToString, Batch:=Dr("Batch").ToString) Then - ErrorMovInv = True - TextoError = "Ocurrió un error al guardar los movimientos de entrada" - Exit For - End If - Next - End If - Else - TextoError = "Ocurrió un error al generar el movimiento de entrada" - ErrorMovInv = True - End If - End If - - End If - - 'MARCA SOLICITUD CON EL MOVIMIENTO GENERADO - If Not ErrorMovInv Then - If Not ObjInventario.UpdateTraspasoSolicitudMovimiento(CveTraspasoSurtir, CveMovimientoSalida) Then - TextoError = "Ocurrió un error al vincular los movimientos con la solicitud de traspaso. Por favor verifique y vuelva a intentar" - ErrorMovInv = True - End If - End If - - - If Not ErrorMovInv Then - ObjInventario.Commit() - RegistraScript("playsonidito('beep-07.wav')") - - Dim Msg As New StringBuilder - Msg.AppendFormat("Movimiento Salida: {1}", CveMovimientoSalida, FolioSalida) - Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoSalida))) - - Msg.AppendFormat("

    Movimiento Entrada (Traspaso): {1}", CveMovimientoEntrada, FolioEntrada) - Msg.AppendFormat("
    Imprimir Movimiento ", Encripta(String.Format("OP=Alm&CveMovimiento={0}", CveMovimientoEntrada))) - - Alert(Msg.ToString, TipoMensaje.MsgInformacion) - - Limpia() - CargaPendientes() - Else - Alert(TextoError, TipoMensaje.MsgError) - RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") - ObjInventario.RollBack() - End If - - ObjInventario.Dispose() - - End Sub - - Private Sub Limpia() - - 'DATOS DE LA VENTA - LbCantidad.Text = "" - LbCliente.Text = "" - LbObservaciones.Text = "" - 'LbFolio.Text = "" - HLFolio.Text = "" - - 'DATOS DEL MOVIMINETO - TxtObservaciones.Text = "" - TxtFecha.Text = Now.ToShortDateString - DdlAlmacen.SelectedValueExist(-1) - CargaFolios() - - 'VARIABLES GENERALES - CveVentaSurtir = -1 - DtDatosDetalle = Nothing - DtDatosDetalleLote = Nothing - DtDatos = Nothing - - DivTipoCambioAdvertencia.Visible = False - - 'TRASPASO - DivTransitorio1.Visible = False - ChkTransitorio.Checked = False - TxtResponsable.Text = "" - DivTransitorio2.Visible = False - - LbSurtida.Visible = False - TimmerRefresh.Enabled = True - UpGenerales.Update() - CargaGvDatos() - End Sub - -#End Region - -#Region " TRASPASO - TRANSITORIO " - Protected Sub ChkTransitorio_CheckedChanged(sender As Object, e As EventArgs) - - TxtResponsable.Text = "" - DivTransitorio2.Visible = ChkTransitorio.Checked - - End Sub -#End Region - -#Region "SECCION ALMACEN" - Private Sub CreaDtSeccionAlmacen() - DtSeccionAlmacen = New DataTable - DtSeccionAlmacen.Columns.Add("CantidadSeccionAlmacen", GetType(Decimal)) - DtSeccionAlmacen.Columns.Add("IndexSeccionAlmacen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CveSeccionAlmacen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CvePS", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("SeccionAlmacen", GetType(String)) - DtSeccionAlmacen.Columns.Add("Consec", GetType(Integer)) - End Sub - Private Sub CargaDdlAlmacen() - DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSeccionAlmacen.DataBind() - End Sub - Protected Sub LnkSeccionAlmacen_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - - If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then - Alert("Tiene que tener seleccionado un almacen para registrar seccion almacen.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - CantidadTotal = gvRow.FCTextBox("TbCantidadF").Text.ToDecimal - IndexSeccionAlmacen = gvRow.RowIndex - CvePS = gvRow.DataKey("CvePS").ToEntero - CargaSeccionAlmacen() - RegistraScript("$('#DModalSeccionAlmacen').modal()") - End Sub - - Private Sub CargaSeccionAlmacen() - Dim CantidadTotalSeccion As Decimal = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}").SUMD("CantidadSeccionAlmacen") - GvSeccion.DataSource = DtSeccionAlmacen.FiltraParametros($"IndexSeccionAlmacen = {IndexSeccionAlmacen}") - GvSeccion.DataBind() - - TxtCantidadSeccion.Text = "" - DdlSeccionAlmacen.SelectedIndex = 0 - Dim CantidadRestante As Decimal = CantidadTotal - CantidadTotalSeccion - If CantidadRestante = 0 Then - RVTxtCantidad.MaximumValue = "1" - TxtCantidadSeccion.Enabled = False - Else - RVTxtCantidad.MaximumValue = CantidadRestante.ToString - TxtCantidadSeccion.Enabled = True - End If - - If CantidadTotalSeccion > 0 Then - GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = False - GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "Cuenta con sección almacen" - - Else - GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").Enabled = True - GvDatos.Rows(IndexSeccionAlmacen).FCTextBox("TbCantidadF").ToolTip = "" - - End If - - If DtSeccionAlmacen.SUMD("CantidadSeccionAlmacen") > 0 Then - DdlAlmacen.Enabled = False - DdlAlmacen.ToolTip = "Cuenta con sección almacen" - Else - DdlAlmacen.Enabled = True - DdlAlmacen.ToolTip = "" - End If - - UpModalSeccionAlmacen.Update() - UpDatos.Update() - UpGenerales.Update() - End Sub - - Protected Sub LnkAddSeccionAlmacen_Click(sender As Object, e As EventArgs) - - Dim ObjInv As New ClsInventarios - Dim CantidadDisponible As Decimal = 0 - If ObjInv.GetMovimientosDetalleSeccionesAlmacen(DdlSeccionAlmacen.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, - CvePS, UsuarioActual.CveEmpresa) Then - If ObjInv.DtResultados.Rows.Count > 0 Then - CantidadDisponible = ObjInv.DtResultados.Rows(0)("CantidadRestante").ToString.ToDecimal - End If - End If - ObjInv.Dispose() - - CantidadDisponible -= DtSeccionAlmacen.FiltraParametros($"CvePS = {CvePS} AND CveSeccionAlmacen = {DdlSeccionAlmacen.SelectedValue}").SUMD("CantidadSeccionAlmacen") - - If TxtCantidadSeccion.Text.ToDecimal > CantidadDisponible Then - Alert($"No tiene cantidad de producto suficiente en esta seccion de almacen, su cantidad restante es: {CantidadDisponible}", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim Row As DataRow = Nothing - DtSeccionAlmacen.AcceptChanges() - Row = DtSeccionAlmacen.NewRow - Row("CantidadSeccionAlmacen") = TxtCantidadSeccion.Text.ToDecimal - Row("IndexSeccionAlmacen") = IndexSeccionAlmacen - Row("CveSeccionAlmacen") = DdlSeccionAlmacen.SelectedValue.ToEntero - Row("SeccionAlmacen") = DdlSeccionAlmacen.SelectedItem.Text - Row("CvePS") = CvePS - Row("Consec") = DtSeccionAlmacen.Rows.Count + 1 - DtSeccionAlmacen.Rows.Add(Row) - DtSeccionAlmacen.AcceptChanges() - CargaSeccionAlmacen() - End Sub - - Protected Sub LnkEliminarSeccion_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - Dim Index As Integer = 0 - For Each Dr As DataRow In DtSeccionAlmacen.Rows - If Dr("Consec").ToString.ToEntero = gvRow.DataKey("Consec").ToEntero() Then - Exit For - End If - Index += 1 - Next - DtSeccionAlmacen.Rows.RemoveAt(Index) - DtSeccionAlmacen.AcceptChanges() - CargaSeccionAlmacen() - End Sub - - Protected Sub LnkVerSecciones_Click(sender As Object, e As EventArgs) - If Not CveVentaSurtir > 0 Then - Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim ObjInv As New ClsInventarios - If ObjInv.GetExistenciaSeccionAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then - GvVerSeccionesAlmacen.DataSource = ObjInv.DtResultados - End If - ObjInv.Dispose() - GvVerSeccionesAlmacen.DataBind() - UpVerSeccionesAlmacen.Update() - RegistraScript("$('#ModalVerSeccionesAlmacen').modal()") - End Sub - -#End Region - -#Region "DIVIDIR" - - Protected Sub Dividir(sender As Object, e As EventArgs) - Dim index2 As Integer = 0 - - For Each Row As DataRow In DtDatos.Rows - Row("Seleccionado") = GvDatos.Rows(index2).FCCheckBox("cbInv").Checked - If GvDatos.Rows(index2).FCTextBox("TbCantidadF").Text <> "" Then - Row("CantidadSeleccionada") = GvDatos.Rows(index2).FCTextBox("TbCantidadF").Text - End If - If GvDatos.Rows(index2).FCTextBox("TxtLote").Text <> "" Then - Row("Lote") = GvDatos.Rows(index2).FCTextBox("TxtLote").Text - End If - If GvDatos.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue <> "-1" Then - Row("CveSeccion") = GvDatos.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue.ToEntero - End If - If GvDatos.Rows(index2).FCTextBox("TxtCaducidad").Text <> "" Then - Row("Caducidad") = GvDatos.Rows(index2).FCTextBox("TxtCaducidad").Text.ToDate - End If - index2 += 1 - Next - DtDatos.AcceptChanges() - - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, Button)).NamingContainer, GridViewRow) - Dim Index As Integer = gvRow.RowIndex - Dim Cantidad As String = HdnCantidadMovimiento.Value - Dim dr1 As DataRow = DtDatos.Rows(Index) - Dim dr As DataRow = DtDatos.NewRow - dr.ItemArray = dr1.ItemArray - dr1("CantidadC") = (dr1("CantidadC").ToString.ToDouble - Cantidad.ToDouble) - Dim CantidadFOriginal As Double = dr1("CantidadF").ToString.ToDouble - dr1("CantidadF") = (dr1("CantidadF").ToString.ToDouble - Cantidad.ToDouble) - Dim CantidadSOriginal As Double = dr1("CantidadS").ToString.ToDouble - dr1("CantidadS") = (CantidadSOriginal * dr1("CantidadF").ToString.ToDouble) / CantidadFOriginal - Dim CantidadSeleccionadaOriginal As Double = dr1("CantidadSeleccionada").ToString.ToDouble - dr1("CantidadSeleccionada") = If(CantidadSeleccionadaOriginal > dr1("CantidadF").ToString.ToDouble, dr1("CantidadF").ToString.ToDouble, CantidadSeleccionadaOriginal) - CantidadSeleccionadaOriginal = CantidadSeleccionadaOriginal - dr1("CantidadF").ToString.ToDouble - - 'Dim CostoIndirectoOriginal As Double = dr1("CostoIndirecto").ToString.ToDouble - 'dr1("CostoIndirecto") = (CostoIndirectoOriginal * dr1("CantidadF").ToString.ToDouble) / CantidadFOriginal - 'Dim CostoIndirectoExtranjeroOriginal As Double = dr1("CostoIndirectoExtranjero").ToString.ToDouble - 'dr1("CostoIndirectoExtranjero") = (CostoIndirectoExtranjeroOriginal * dr1("CantidadF").ToString.ToDouble) / CantidadFOriginal - - DtDatos.AcceptChanges() - - dr("CantidadC") = Cantidad.ToDouble - dr("CantidadF") = Cantidad.ToDouble - dr("CantidadS") = (CantidadSOriginal * dr("CantidadF").ToString.ToDouble) / CantidadFOriginal - dr("CantidadSeleccionada") = If(CantidadSeleccionadaOriginal > 0, CantidadSeleccionadaOriginal, 0) - dr("Seleccionado") = If(CantidadSeleccionadaOriginal > 0, True, False) - 'dr("CostoIndirecto") = (CostoIndirectoOriginal * dr("CantidadF").ToString.ToDouble) / CantidadFOriginal - 'dr("CostoIndirectoExtranjero") = (CostoIndirectoExtranjeroOriginal * dr("CantidadF").ToString.ToDouble) / CantidadFOriginal - DtDatos.Rows.InsertAt(dr, Index) - DtDatos.AcceptChanges() - - index2 = 1 - For Each Row As DataRow In DtDatos.Rows - Row("Consec") = index2 - index2 += 1 - Next - DtDatos.AcceptChanges() - - CargaGvDatos() - - index2 = 0 - For Each Row As DataRow In DtDatos.Rows - GvDatos.Rows(index2).FCCheckBox("cbInv").Checked = CBool(Row("Seleccionado")) - If Row("CantidadSeleccionada").ToString <> "" Then - GvDatos.Rows(index2).FCTextBox("TbCantidadF").Text = Row("CantidadSeleccionada").ToString - End If - If Row("Lote").ToString <> "" Then - GvDatos.Rows(index2).FCTextBox("TxtLote").Text = Row("Lote").ToString - End If - If Row("CveSeccion").ToString <> "" Then - GvDatos.Rows(index2).FCDropDownList("DdlSeccionAlmacen").SelectedValue = Row("CveSeccion").ToString - End If - If Row("Caducidad").ToString <> "" Then - GvDatos.Rows(index2).FCTextBox("TxtCaducidad").Text = Row("Caducidad").ToString.ToDate.ToShortDateString - End If - index2 += 1 - Next - - End Sub - - -#End Region - -#Region " GUIAS - SABE QUE ES PORQUE NO VEO QUE SE UTILIZE EN ALGUNA PARTE - EN MIRAS DE ELIMINAR - IPP 24 AGOSTO 2017 " - Private Sub BtnNumeroGuia_Click(sender As Object, e As EventArgs) Handles BtnNumeroGuia.Click - Dim Objeto As New ClsInventarios - If Objeto.UpdateMovimientoGuia(TxtGuia.Text, CveMovimiento, UsuarioActual.CveEmpresa) Then - Alert("Se ha guardado correctamente la póliza", TipoMensaje.MsgConfirmacion) - End If - Objeto.Dispose() - End Sub - - Private Sub GvDocs_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocs.RowDataBound - - If e.Row.RowType = DataControlRowType.DataRow Then - - Dim ImgDownLoad As Literal = e.Row.FCLiteral("HplDown") - Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString - Dim ArchivoRuta As String = "" - - If Adjunto.Trim.Length > 0 Then - ArchivoRuta = UsuarioActual.Empresa.Ruta & "Documentacion\Ventas\" & Adjunto - Dim fi As New FileInfo(ArchivoRuta) - Dim linkDescarga As String = "" - If fi.Exists() Then - linkDescarga = $"/Empresas/{UsuarioActual.CveEmpresa}/Documentacion/ventas/{fi.Name}" - ImgDownLoad.Visible = True - ImgDownLoad.Text = String.Format(" ", linkDescarga) - - - End If - - End If - - End If - - End Sub -#End Region - -#Region "SUGERENCIAS" - - Protected Sub BtnVerSugerencias_Click(sender As Object, e As EventArgs) - If Not CveVentaSurtir > 0 Then - Alert("Tiene que seleccionar la venta a surtir", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlAlmacen.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar el almacen", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim ObjInv As New ClsInventarios - If ObjInv.GetSugerenciasSalidaAlmacen(CveVentaSurtir, DdlAlmacen.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then - GvSugerencias.DataSource = ObjInv.DtResultados - - - DtDatosSugerencias = ObjInv.DtResultados - - DtDatos.Columns.Add("Consec", GetType(Integer)) - DtDatos.Columns.Add("CantidadGV", GetType(Double)) - DtDatos.Columns.Add("CantidadTraspaso", GetType(Double)) - DtDatos.Columns.Add("AplicaSeccion", GetType(Boolean)) - DtDatos.Columns.Add("AplicaSerie", GetType(Boolean)) - DtDatos.Columns.Add("AplicaLote", GetType(Boolean)) - DtDatos.Columns.Add("AplicaCaducidad", GetType(Boolean)) - If Not DtDatos.Columns.Contains("Lote") Then - DtDatos.Columns.Add("Lote", GetType(String)) - End If - If Not DtDatos.Columns.Contains("CveSeccion") Then - DtDatos.Columns.Add("CveSeccion", GetType(Integer)) - End If - If Not DtDatos.Columns.Contains("Caducidad") Then - DtDatos.Columns.Add("Caducidad", GetType(Date)) - End If - If Not DtDatos.Columns.Contains("Seleccionado") Then - DtDatos.Columns.Add("Seleccionado", GetType(Boolean)) - End If - If Not DtDatos.Columns.Contains("CantidadSeleccionada") Then - DtDatos.Columns.Add("CantidadSeleccionada", GetType(Double)) - End If - - Dim Index = 1 - For Each Dr As DataRow In DtDatosSugerencias.Rows - Dr("Consec") = Index - Dr("Caducidad") = Now - Index += 1 - Next - - DtDatosSugerencias.AcceptChanges() - - - End If - ObjInv.Dispose() - GvSugerencias.DataBind() - - UpVerSugerencias.Update() - - RegistraScript("$('#ModalVerSugerencias').modal()") - End Sub - Protected Sub BtnAplicarSugerencias_Click(sender As Object, e As EventArgs) - - DtDatos = Nothing - DtDatos = New DataTable - DtDatos = DtDatosSugerencias - - DtDatosDetalle = Nothing - CreaDtDetalle() - - DtDatosDetalleLote = Nothing - CreaDtDetalleLote() - - CargaGvDatos() - - RegistraScript("$('#ModalVerSugerencias').modal('hide')") - End Sub - - -#End Region - - - -End Class diff --git a/Ventas/Clientes.aspx.vb b/Ventas/Clientes.aspx.vb index 849a7129d..26da6c8fe 100644 --- a/Ventas/Clientes.aspx.vb +++ b/Ventas/Clientes.aspx.vb @@ -1,1052 +1,1052 @@ -Option Explicit On -Option Strict On - -Imports Extensiones -Imports System.Runtime.InteropServices -Imports System.IO -Imports Microsoft.Reporting.WebForms -Imports System.Data -Imports System.Globalization - -Partial Class Clientes - Inherits ClsPaginas - - 'Configuración -#Region "P R O P I E D A D E S" - Private Const NumeroDecimales As Integer = 2 - Private CveVentaDeduccion As Integer - Private Opcion As Integer - - Public ReadOnly Property RowStyle As TableItemStyle - Private ReadOnly Property CveCliente As Integer - Get - Return ViewState("CveCliente").ToString.ToEntero - End Get - End Property - Private Property DTCuentasBancos As DataTable - Get - Return CType(ViewState("DTCuentasBancos"), DataTable) - End Get - Set(value As DataTable) - ViewState("DTCuentasBancos") = value - End Set - End Property - Private Property DTHistorialVentas As DataTable - Get - Return CType(ViewState("DTHistorialVentas"), DataTable) - End Get - Set(value As DataTable) - ViewState("DTHistorialVentas") = value - End Set - End Property - Private Property TempDTCuentasBancos As DataTable - Get - Return CType(ViewState("TempDTCuentasBancos"), DataTable) - End Get - Set(value As DataTable) - ViewState("TempDTCuentasBancos") = value - End Set - End Property - - Private Property Modalidad As String - Get - Return ViewState("Modalidad").ToString - End Get - Set(value As String) - ViewState("Modalidad") = value - End Set - End Property - - Private Property IdCtaCliente As String - Get - Return If(IsNothing(ViewState("IdCtaCliente")), "", ViewState("IdCtaCliente").ToString) - End Get - Set(value As String) - ViewState("IdCtaCliente") = value - End Set - End Property - Private Property IdCtaAnticipos As String - Get - - Return If(IsNothing(ViewState("IdCtaAnticipos")), "", ViewState("IdCtaAnticipos").ToString) - End Get - Set(value As String) - ViewState("IdCtaAnticipos") = value - End Set - End Property - Private Property IdCtaRetIVA As String - Get - Return If(IsNothing(ViewState("IdCtaRetIVA")), "", ViewState("IdCtaRetIVA").ToString) - End Get - Set(value As String) - ViewState("IdCtaRetIVA") = value - End Set - End Property - Private Property IdCtaFondoGarantia As String - Get - Return If(IsNothing(ViewState("IdCtaFondoGarantia")), "", ViewState("IdCtaFondoGarantia").ToString) - End Get - Set(value As String) - ViewState("IdCtaFondoGarantia") = value - End Set - End Property - Private Property IdCtaRetISR As String - Get - Return If(IsNothing(ViewState("IdCtaRetISR")), "", ViewState("IdCtaRetISR").ToString) - End Get - Set(value As String) - ViewState("IdCtaRetISR") = value - End Set - End Property - - Private Property CveCuentaBancaria As Integer - Get - Return ViewState("CveCuentaBancaria").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveCuentaBancaria") = value - End Set - End Property - - Private Property CveClienteSuc As Integer - Get - If ViewState("CveClienteSuc") Is Nothing Then - Return -1 - Else - Return ViewState("CveClienteSuc").ToString.ToEntero - End If - End Get - Set(value As Integer) - ViewState("CveClienteSuc") = value - End Set - End Property - - Private Property Actualizar As Boolean - Get - Return Convert.ToBoolean(ViewState("Actualizar")) - End Get - Set(value As Boolean) - ViewState("Actualizar") = value - End Set - End Property - - Private Property Existe As Boolean - Get - Return Convert.ToBoolean(ViewState("Existe")) - End Get - Set(value As Boolean) - ViewState("Existe") = value - End Set - End Property - - Private Property IdCtaCompCliente As String - Get - Return If(IsNothing(ViewState("IdCtaCompCliente")), "", ViewState("IdCtaCompCliente").ToString) - End Get - Set(value As String) - ViewState("IdCtaCompCliente") = value - End Set - End Property - - Private Property ArrayDisp As String - Get - Return If(IsNothing(ViewState("ArrayDisp")), "", ViewState("ArrayDisp").ToString) - End Get - Set(value As String) - ViewState("ArrayDisp") = value - End Set - End Property - Private Property NombreDispositivo As String - Get - Return If(IsNothing(ViewState("NombreDispositivo")), "", ViewState("NombreDispositivo").ToString) - End Get - Set(value As String) - ViewState("NombreDispositivo") = value - End Set - End Property - - Private Property IdCtaCompAnticipo As String - Get - Return If(IsNothing(ViewState("IdCtaCompAnticipo")), "", ViewState("IdCtaCompAnticipo").ToString) - End Get - Set(value As String) - ViewState("IdCtaCompAnticipo") = value - End Set - End Property - - Private Property CveDireccionEnvio As Integer - Get - If ViewState("CveDireccionEnvio") Is Nothing Then - Return -1 - Else - Return ViewState("CveDireccionEnvio").ToString.ToEntero - End If - End Get - Set(value As Integer) - ViewState("CveDireccionEnvio") = value - End Set - End Property - - Private Property CveCuentaEquipo As Integer - Get - If ViewState("CveCuentaEquipo") Is Nothing Then - Return -1 - Else - Return ViewState("CveCuentaEquipo").ToString.ToEntero - End If - End Get - Set(value As Integer) - ViewState("CveCuentaEquipo") = value - End Set - End Property - - - Private Property IdCtaMonedaExtranjera As String - Get - Return If(IsNothing(ViewState("IdCtaMonedaExtranjera")), "", ViewState("IdCtaMonedaExtranjera").ToString) - End Get - Set(value As String) - ViewState("IdCtaMonedaExtranjera") = value - End Set - End Property - - Private Property IdCtaMonedaExtranjeraAnticipos As String - Get - Return If(IsNothing(ViewState("IdCtaMonedaExtranjeraAnticipos")), "", ViewState("IdCtaMonedaExtranjeraAnticipos").ToString) - End Get - Set(value As String) - ViewState("IdCtaMonedaExtranjeraAnticipos") = value - End Set - End Property - - Private Property TempDTSucursales As DataTable - Get - Return CType(ViewState("TempDTSucursales"), DataTable) - End Get - Set(value As DataTable) - ViewState("TempDTSucursales") = value - End Set - End Property - - Private Property EstatusAnteriorCliente As Boolean - Get - If ViewState("EstatusAnteriorCliente") Is Nothing Then - Return True - Else - Return Boolean.Parse(ViewState("EstatusAnteriorCliente").ToString) - End If - End Get - Set(value As Boolean) - ViewState("EstatusAnteriorCliente") = value - End Set - End Property - - Private Property DtSubProyectos As DataTable - Get - Return If(IsNothing(ViewState("DtSubProyectos")), Nothing, CType(ViewState("DtSubProyectos"), DataTable)) - End Get - Set(value As DataTable) - ViewState("DtSubProyectos") = value - End Set - End Property - Private Property CveSucursal As Integer - Get - If ViewState("CveSucursal") Is Nothing Then - Return -1 - Else - Return ViewState("CveSucursal").ToString.ToEntero - End If - End Get - Set(value As Integer) - ViewState("CveSucursal") = value - End Set - End Property - - - Private Property DTCobrosRealizados As DataTable - Get - If ViewState("DTCobrosRealizados") Is Nothing Then - Return New DataTable - Else - Return DirectCast(ViewState("DTCobrosRealizados"), DataTable) - End If - End Get - Set(value As DataTable) - ViewState("DTCobrosRealizados") = value - End Set - End Property - - Private Property ObjFactura As Modelos.Factura - Get - Return CType(ViewState("ObjFactura"), Modelos.Factura) - End Get - Set(value As Modelos.Factura) - ViewState("ObjFactura") = value - End Set - End Property - - Private Property CobranzaTelefono As String - Get - CobranzaTelefono = ViewState("CobranzaTelefono").ToString - End Get - Set(value As String) - ViewState("CobranzaTelefono") = value - End Set - End Property - Private Property CodigoCliente As String - Get - CodigoCliente = ViewState("CodigoCliente").ToString - End Get - Set(value As String) - ViewState("CodigoCliente") = value - End Set - End Property - Private Property DtVencido As DataTable - Get - DtVencido = CType(ViewState("DtVencido"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtVencido") = value - End Set - End Property - Private Property DtRotacion As DataTable - Get - DtRotacion = CType(ViewState("DtRotacion"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtRotacion") = value - End Set - End Property - Private Property DtSaldoMensual As DataTable - Get - DtSaldoMensual = CType(ViewState("DtSaldoMensual"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtSaldoMensual") = value - End Set - End Property - Private Property DtComportamientoVentas As DataTable - Get - DtComportamientoVentas = CType(ViewState("DtComportamientoVentas"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtComportamientoVentas") = value - End Set - End Property - Private Property CveEmpresaCRM As Integer - Get - If ViewState("CveEmpresaCRM") Is Nothing Then - Return -1 - Else - Return ViewState("CveEmpresaCRM").ToString.ToEntero - End If - End Get - Set(value As Integer) - ViewState("CveEmpresaCRM") = value - End Set - End Property - - Private Property DtEmpresasCRM As DataTable - Get - DtEmpresasCRM = CType(ViewState("DtEmpresasCRM"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtEmpresasCRM") = value - End Set - End Property - - Private Property CveEmpresaCRMUnificar As Integer - Get - If ViewState("CveEmpresaCRMUnificar") Is Nothing Then - Return -1 - Else - Return ViewState("CveEmpresaCRMUnificar").ToString.ToEntero - End If - End Get - Set(value As Integer) - ViewState("CveEmpresaCRMUnificar") = value - End Set - End Property - - Private Property DTPorcentajePrecios As DataTable - Get - Return CType(ViewState("DTPorcentajePrecios"), DataTable) - End Get - Set(value As DataTable) - ViewState("DTPorcentajePrecios") = value - End Set - End Property - Private Property TmpDT As DataTable - Get - Return If(IsNothing(ViewState("TmpDT")), Nothing, CType(ViewState("TmpDT"), DataTable)) - End Get - Set(value As DataTable) - ViewState("TmpDT") = value - End Set - End Property - Private Property DtPromociones As DataTable - Get - Return If(IsNothing(ViewState("DtPromociones")), Nothing, CType(ViewState("DtPromociones"), DataTable)) - End Get - Set(value As DataTable) - ViewState("DtPromociones") = value - End Set - End Property - Private Property DtPagos As DataTable - Get - Return CType(ViewState("DtPagos"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtPagos") = value - End Set +Option Explicit On +Option Strict On + +Imports Extensiones +Imports System.Runtime.InteropServices +Imports System.IO +Imports Microsoft.Reporting.WebForms +Imports System.Data +Imports System.Globalization + +Partial Class Clientes + Inherits ClsPaginas + + 'Configuración +#Region "P R O P I E D A D E S" + Private Const NumeroDecimales As Integer = 2 + Private CveVentaDeduccion As Integer + Private Opcion As Integer + + Public ReadOnly Property RowStyle As TableItemStyle + Private ReadOnly Property CveCliente As Integer + Get + Return ViewState("CveCliente").ToString.ToEntero + End Get + End Property + Private Property DTCuentasBancos As DataTable + Get + Return CType(ViewState("DTCuentasBancos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DTCuentasBancos") = value + End Set + End Property + Private Property DTHistorialVentas As DataTable + Get + Return CType(ViewState("DTHistorialVentas"), DataTable) + End Get + Set(value As DataTable) + ViewState("DTHistorialVentas") = value + End Set + End Property + Private Property TempDTCuentasBancos As DataTable + Get + Return CType(ViewState("TempDTCuentasBancos"), DataTable) + End Get + Set(value As DataTable) + ViewState("TempDTCuentasBancos") = value + End Set End Property - Private Property DtCotizaciones As DataTable - Get - Return CType(ViewState("DtCotizaciones"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtCotizaciones") = value - End Set - End Property - Private Property DtCxCActivas As DataTable - Get - Return CType(ViewState("DtCxCActivas"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtCxCActivas") = value - End Set - End Property - Private Property DtHistorialCxC As DataTable - Get - Return CType(ViewState("DtHistorialCxC"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtHistorialCxC") = value - End Set - End Property - Private Property DtClientesAnticipo As DataTable - Get - Return CType(ViewState("DtClientesAnticipo"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtClientesAnticipo") = value - End Set - End Property - Private Property DtAnticipoHistorial As DataTable - Get - Return CType(ViewState("DtAnticipoHistorial"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtAnticipoHistorial") = value - End Set - End Property - 'Private Property EstatusAnteriorCliente As Boolean - ' Get - ' If ViewState("EstatusAnteriorCliente") Is Nothing Then - ' Return True - ' Else - ' Return Boolean.Parse(ViewState("EstatusAnteriorCliente").ToString) - ' End If - ' End Get - ' Set(value As Boolean) - ' ViewState("EstatusAnteriorCliente") = value - ' End Set - 'End Property - - Private Property CargoUsado As Boolean - Get - If ViewState("CargoUsado") Is Nothing Then - Return True - Else - Return Boolean.Parse(ViewState("CargoUsado").ToString) - End If - End Get - Set(value As Boolean) - ViewState("CargoUsado") = value - End Set - End Property - - Private Property BonificacionUsado As Boolean - Get - If ViewState("BonificacionUsado") Is Nothing Then - Return True - Else - Return Boolean.Parse(ViewState("BonificacionUsado").ToString) - End If - End Get - Set(value As Boolean) - ViewState("BonificacionUsado") = value - End Set + Private Property Modalidad As String + Get + Return ViewState("Modalidad").ToString + End Get + Set(value As String) + ViewState("Modalidad") = value + End Set End Property - Private Property linkDescargaPagare As String - Get - Return If(IsNothing(ViewState("linkDescargaPagare")), "", ViewState("linkDescargaPagare").ToString) - End Get - Set(value As String) - ViewState("linkDescargaPagare") = value - End Set + Private Property IdCtaCliente As String + Get + Return If(IsNothing(ViewState("IdCtaCliente")), "", ViewState("IdCtaCliente").ToString) + End Get + Set(value As String) + ViewState("IdCtaCliente") = value + End Set + End Property + Private Property IdCtaAnticipos As String + Get + + Return If(IsNothing(ViewState("IdCtaAnticipos")), "", ViewState("IdCtaAnticipos").ToString) + End Get + Set(value As String) + ViewState("IdCtaAnticipos") = value + End Set + End Property + Private Property IdCtaRetIVA As String + Get + Return If(IsNothing(ViewState("IdCtaRetIVA")), "", ViewState("IdCtaRetIVA").ToString) + End Get + Set(value As String) + ViewState("IdCtaRetIVA") = value + End Set + End Property + Private Property IdCtaFondoGarantia As String + Get + Return If(IsNothing(ViewState("IdCtaFondoGarantia")), "", ViewState("IdCtaFondoGarantia").ToString) + End Get + Set(value As String) + ViewState("IdCtaFondoGarantia") = value + End Set + End Property + Private Property IdCtaRetISR As String + Get + Return If(IsNothing(ViewState("IdCtaRetISR")), "", ViewState("IdCtaRetISR").ToString) + End Get + Set(value As String) + ViewState("IdCtaRetISR") = value + End Set End Property -#End Region + Private Property CveCuentaBancaria As Integer + Get + Return ViewState("CveCuentaBancaria").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveCuentaBancaria") = value + End Set + End Property -#Region "Documentacion" - Private Property DTDocumentacion As DataTable - Get - If ViewState("DTDocumentacion") Is Nothing Then - Return New DataTable - Else - Return DirectCast(ViewState("DTDocumentacion"), DataTable) - End If - End Get - Set(value As DataTable) - ViewState("DTDocumentacion") = value - End Set - End Property - - Property Documentacion As String - Get - If ViewState("Documentacion") Is Nothing Then - Return "-1" - Else - Return ViewState("Documentacion").ToString - End If - End Get - Set(value As String) - ViewState("Documentacion") = value - End Set - End Property - Property CveDocumentacion As Integer - Get - If ViewState("CveDocumentacion") Is Nothing Then - Return -1 - Else - Return DirectCast(ViewState("CveDocumentacion"), Integer) - End If - End Get - Set(value As Integer) - ViewState("CveDocumentacion") = value - End Set - End Property - Property CveDocumentacionElectronica As Integer - Get - If ViewState("CvePersonalClienteDocumentacion") Is Nothing Then - Return -1 - Else - Return DirectCast(ViewState("CvePersonalClienteDocumentacion"), Integer) - End If - End Get - Set(value As Integer) - ViewState("CvePersonalClienteDocumentacion") = value - End Set - End Property - Property ActualizarDocumentacion As Boolean - Get - If ViewState("ActualizarDocumentacion") Is Nothing Then - Return True - Else - Return DirectCast(ViewState("ActualizarDocumentacion"), Boolean) - End If - End Get - Set(value As Boolean) - ViewState("ActualizarDocumentacion") = value - End Set - End Property - Private Property FechaLimite As Date - Get - If ViewState("FechaLimite") Is Nothing Then - Return Date.Now.AddDays(15) - Else - Return ViewState("FechaLimite").ToString.ToDate - End If - End Get - Set(value As Date) - ViewState("FechaLimite") = value - End Set - - End Property - Property Estatus As Integer - Get - If ViewState("Estatus") Is Nothing Then - Return 0 - Else - Return DirectCast(ViewState("Estatus"), Integer) - End If - End Get - Set(value As Integer) - ViewState("Estatus") = value - End Set - End Property - Property ObservacionDocumentacion As String - Get - If ViewState("ObservacionDocumentacion") Is Nothing Then - Return "" - Else - Return ViewState("ObservacionDocumentacion").ToString - End If - End Get - Set(value As String) - ViewState("ObservacionDocumentacion") = value - End Set - End Property - Property AdjuntoDocumentacion As String - Get - If ViewState("AdjuntoDocumentacion") Is Nothing Then - Return "" - Else - Return ViewState("AdjuntoDocumentacion").ToString - End If - End Get - Set(value As String) - ViewState("AdjuntoDocumentacion") = value - End Set - End Property - 'Private ReadOnly Property CvePersonal As Integer - ' Get - ' If ViewState("CvePersonal") Is Nothing Then - ' Return -1 - ' Else - ' Return ViewState("CvePersonal").ToString.ToEntero - ' End If - ' End Get - 'End Property - -#End Region - - - -#Region " A C U M U L A D O R E S" - Property CveVentaNota As Integer - Get - If ViewState("CveVentaNota") Is Nothing Then - Return 0 - Else - Return ViewState("CveVentaNota").ToString.ToEntero - End If - End Get - Set(value As Integer) - ViewState("CveVentaNota") = value - End Set - - End Property - - Property FolioNotaAcumulador As Integer - Get - If ViewState("FolioNotaAcumulador") Is Nothing Then - Return 0 - Else - Return ViewState("FolioNotaAcumulador").ToString.ToEntero - End If - End Get - Set(value As Integer) - ViewState("FolioNotaAcumulador") = value - End Set - End Property - Property SerieNotaAcumulador As String - Get - If ViewState("SerieNotaAcumulador") Is Nothing Then - Return "" - - Else - Return ViewState("SerieNotaAcumulador").ToString - End If - End Get - Set(value As String) - ViewState("SerieNotaAcumulador") = 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 - - Actualizar = False - SetValues() - CargaCombos() - CreaDTVentas() - CreaDtPago() - RegistraScript("CargaHeader();") - - - If UsuarioActual.Empresa.CvePlataforma = 3 Then 'SI ES USUARIO GPS - TabFiscalContable.Visible = True - TabRetenciones.Visible = False - TabOS.Visible = False - TabComplementos.Visible = False - TabOtros.Visible = False - TabCuentasEquipos.Visible = True - ReporteDispositivos.Visible = True - TabCuentasEquipos.HeaderText = "Equipos GPS" - TabRH.Visible = False - TabUsuarios.Visible = True - TabUsuarios.HeaderText = "Usuarios" - dvZH.Visible = True - CargaZonasHorarias() - dvPlataformaSig.Style.Add("display", "none") - dvPlataformGPS.Style.Add("display", "") - BtnAgregarCtaEquipo.Visible = False - HyperLink1.Text = "Georef" - HyperLink1.ToolTip = "Creación de geocercas y rutas" - HyperLink2.Text = "Rastreo" - HyperLink2.ToolTip = "Rastreo de equipos" - HyperLink3.Text = "P.Interes" - HyperLink3.ToolTip = "Creación y reportes de puntos de interés" - ThBusqueda.Visible = True - TdBusqueda.Visible = True - HyperLink7.Visible = False - ChkSist.Visible = False - - CargaEmpresasUsuario(UsuarioActual.CveEmpresa) - End If - - 'ROL DE GPS - If UsuarioActual.CveRol = 1198 Then - TabUsuarios.HeaderText = "Usuarios" - End If - - '02/07/2018 - PRUEBAS USUARIOS PLATAFORMA CLIENTES - If UsuarioActual.Empresa.CvePlataforma = 1 Then 'SI ES USUARIO SIG - TabUsuarios.Visible = True - End If - - If UsuarioActual.Empresa.Funcionalidad(510) <> "" Then - TabCuentasEquipos.HeaderText = UsuarioActual.Empresa.Funcionalidad(510) - TabCuentasEquipos.Visible = True - End If - - If UsuarioActual.Empresa.Funcionalidad(504).ToEntero > 0 Then - If UsuarioActual.TienePermisoProceso(162) Then - ChkPermiteCredito.Enabled = True - TxtLimiteCreditoSucursal.Enabled = True - Else - ChkPermiteCredito.Enabled = False - TxtLimiteCreditoSucursal.Enabled = False - End If - ChkEstado.Enabled = False - If UsuarioActual.TienePermisoProceso(180) Then - ChkEstado.Enabled = True - End If + Private Property CveClienteSuc As Integer + Get + If ViewState("CveClienteSuc") Is Nothing Then + Return -1 + Else + Return ViewState("CveClienteSuc").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveClienteSuc") = value + End Set + End Property + + Private Property Actualizar As Boolean + Get + Return Convert.ToBoolean(ViewState("Actualizar")) + End Get + Set(value As Boolean) + ViewState("Actualizar") = value + End Set + End Property + + Private Property Existe As Boolean + Get + Return Convert.ToBoolean(ViewState("Existe")) + End Get + Set(value As Boolean) + ViewState("Existe") = value + End Set + End Property + + Private Property IdCtaCompCliente As String + Get + Return If(IsNothing(ViewState("IdCtaCompCliente")), "", ViewState("IdCtaCompCliente").ToString) + End Get + Set(value As String) + ViewState("IdCtaCompCliente") = value + End Set + End Property + + Private Property ArrayDisp As String + Get + Return If(IsNothing(ViewState("ArrayDisp")), "", ViewState("ArrayDisp").ToString) + End Get + Set(value As String) + ViewState("ArrayDisp") = value + End Set + End Property + Private Property NombreDispositivo As String + Get + Return If(IsNothing(ViewState("NombreDispositivo")), "", ViewState("NombreDispositivo").ToString) + End Get + Set(value As String) + ViewState("NombreDispositivo") = value + End Set + End Property + + Private Property IdCtaCompAnticipo As String + Get + Return If(IsNothing(ViewState("IdCtaCompAnticipo")), "", ViewState("IdCtaCompAnticipo").ToString) + End Get + Set(value As String) + ViewState("IdCtaCompAnticipo") = value + End Set + End Property + + Private Property CveDireccionEnvio As Integer + Get + If ViewState("CveDireccionEnvio") Is Nothing Then + Return -1 + Else + Return ViewState("CveDireccionEnvio").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveDireccionEnvio") = value + End Set + End Property + + Private Property CveCuentaEquipo As Integer + Get + If ViewState("CveCuentaEquipo") Is Nothing Then + Return -1 + Else + Return ViewState("CveCuentaEquipo").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveCuentaEquipo") = value + End Set + End Property + + + Private Property IdCtaMonedaExtranjera As String + Get + Return If(IsNothing(ViewState("IdCtaMonedaExtranjera")), "", ViewState("IdCtaMonedaExtranjera").ToString) + End Get + Set(value As String) + ViewState("IdCtaMonedaExtranjera") = value + End Set + End Property + + Private Property IdCtaMonedaExtranjeraAnticipos As String + Get + Return If(IsNothing(ViewState("IdCtaMonedaExtranjeraAnticipos")), "", ViewState("IdCtaMonedaExtranjeraAnticipos").ToString) + End Get + Set(value As String) + ViewState("IdCtaMonedaExtranjeraAnticipos") = value + End Set + End Property + + Private Property TempDTSucursales As DataTable + Get + Return CType(ViewState("TempDTSucursales"), DataTable) + End Get + Set(value As DataTable) + ViewState("TempDTSucursales") = value + End Set + End Property + + Private Property EstatusAnteriorCliente As Boolean + Get + If ViewState("EstatusAnteriorCliente") Is Nothing Then + Return True + Else + Return Boolean.Parse(ViewState("EstatusAnteriorCliente").ToString) + End If + End Get + Set(value As Boolean) + ViewState("EstatusAnteriorCliente") = value + End Set + End Property + + Private Property DtSubProyectos As DataTable + Get + Return If(IsNothing(ViewState("DtSubProyectos")), Nothing, CType(ViewState("DtSubProyectos"), DataTable)) + End Get + Set(value As DataTable) + ViewState("DtSubProyectos") = value + End Set + End Property + Private Property CveSucursal As Integer + Get + If ViewState("CveSucursal") Is Nothing Then + Return -1 + Else + Return ViewState("CveSucursal").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveSucursal") = value + End Set + End Property + + + Private Property DTCobrosRealizados As DataTable + Get + If ViewState("DTCobrosRealizados") Is Nothing Then + Return New DataTable + Else + Return DirectCast(ViewState("DTCobrosRealizados"), DataTable) + End If + End Get + Set(value As DataTable) + ViewState("DTCobrosRealizados") = value + End Set + End Property + + Private Property ObjFactura As Modelos.Factura + Get + Return CType(ViewState("ObjFactura"), Modelos.Factura) + End Get + Set(value As Modelos.Factura) + ViewState("ObjFactura") = value + End Set + End Property + + Private Property CobranzaTelefono As String + Get + CobranzaTelefono = ViewState("CobranzaTelefono").ToString + End Get + Set(value As String) + ViewState("CobranzaTelefono") = value + End Set + End Property + Private Property CodigoCliente As String + Get + CodigoCliente = ViewState("CodigoCliente").ToString + End Get + Set(value As String) + ViewState("CodigoCliente") = value + End Set + End Property + Private Property DtVencido As DataTable + Get + DtVencido = CType(ViewState("DtVencido"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtVencido") = value + End Set + End Property + Private Property DtRotacion As DataTable + Get + DtRotacion = CType(ViewState("DtRotacion"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtRotacion") = value + End Set + End Property + Private Property DtSaldoMensual As DataTable + Get + DtSaldoMensual = CType(ViewState("DtSaldoMensual"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtSaldoMensual") = value + End Set + End Property + Private Property DtComportamientoVentas As DataTable + Get + DtComportamientoVentas = CType(ViewState("DtComportamientoVentas"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtComportamientoVentas") = value + End Set + End Property + Private Property CveEmpresaCRM As Integer + Get + If ViewState("CveEmpresaCRM") Is Nothing Then + Return -1 + Else + Return ViewState("CveEmpresaCRM").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveEmpresaCRM") = value + End Set + End Property + + Private Property DtEmpresasCRM As DataTable + Get + DtEmpresasCRM = CType(ViewState("DtEmpresasCRM"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtEmpresasCRM") = value + End Set + End Property + + Private Property CveEmpresaCRMUnificar As Integer + Get + If ViewState("CveEmpresaCRMUnificar") Is Nothing Then + Return -1 + Else + Return ViewState("CveEmpresaCRMUnificar").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveEmpresaCRMUnificar") = value + End Set + End Property + + Private Property DTPorcentajePrecios As DataTable + Get + Return CType(ViewState("DTPorcentajePrecios"), DataTable) + End Get + Set(value As DataTable) + ViewState("DTPorcentajePrecios") = value + End Set + End Property + Private Property TmpDT As DataTable + Get + Return If(IsNothing(ViewState("TmpDT")), Nothing, CType(ViewState("TmpDT"), DataTable)) + End Get + Set(value As DataTable) + ViewState("TmpDT") = value + End Set + End Property + Private Property DtPromociones As DataTable + Get + Return If(IsNothing(ViewState("DtPromociones")), Nothing, CType(ViewState("DtPromociones"), DataTable)) + End Get + Set(value As DataTable) + ViewState("DtPromociones") = value + End Set + End Property + Private Property DtPagos As DataTable + Get + Return CType(ViewState("DtPagos"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtPagos") = value + End Set + End Property + + Private Property DtCotizaciones As DataTable + Get + Return CType(ViewState("DtCotizaciones"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtCotizaciones") = value + End Set + End Property + Private Property DtCxCActivas As DataTable + Get + Return CType(ViewState("DtCxCActivas"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtCxCActivas") = value + End Set + End Property + Private Property DtHistorialCxC As DataTable + Get + Return CType(ViewState("DtHistorialCxC"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtHistorialCxC") = value + End Set + End Property + Private Property DtClientesAnticipo As DataTable + Get + Return CType(ViewState("DtClientesAnticipo"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtClientesAnticipo") = value + End Set + End Property + Private Property DtAnticipoHistorial As DataTable + Get + Return CType(ViewState("DtAnticipoHistorial"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtAnticipoHistorial") = value + End Set + End Property + 'Private Property EstatusAnteriorCliente As Boolean + ' Get + ' If ViewState("EstatusAnteriorCliente") Is Nothing Then + ' Return True + ' Else + ' Return Boolean.Parse(ViewState("EstatusAnteriorCliente").ToString) + ' End If + ' End Get + ' Set(value As Boolean) + ' ViewState("EstatusAnteriorCliente") = value + ' End Set + 'End Property + + Private Property CargoUsado As Boolean + Get + If ViewState("CargoUsado") Is Nothing Then + Return True + Else + Return Boolean.Parse(ViewState("CargoUsado").ToString) + End If + End Get + Set(value As Boolean) + ViewState("CargoUsado") = value + End Set + End Property + + Private Property BonificacionUsado As Boolean + Get + If ViewState("BonificacionUsado") Is Nothing Then + Return True + Else + Return Boolean.Parse(ViewState("BonificacionUsado").ToString) + End If + End Get + Set(value As Boolean) + ViewState("BonificacionUsado") = value + End Set + End Property + + Private Property linkDescargaPagare As String + Get + Return If(IsNothing(ViewState("linkDescargaPagare")), "", ViewState("linkDescargaPagare").ToString) + End Get + Set(value As String) + ViewState("linkDescargaPagare") = value + End Set + End Property + +#End Region + +#Region "Documentacion" + Private Property DTDocumentacion As DataTable + Get + If ViewState("DTDocumentacion") Is Nothing Then + Return New DataTable + Else + Return DirectCast(ViewState("DTDocumentacion"), DataTable) + End If + End Get + Set(value As DataTable) + ViewState("DTDocumentacion") = value + End Set + End Property + + Property Documentacion As String + Get + If ViewState("Documentacion") Is Nothing Then + Return "-1" + Else + Return ViewState("Documentacion").ToString + End If + End Get + Set(value As String) + ViewState("Documentacion") = value + End Set + End Property + Property CveDocumentacion As Integer + Get + If ViewState("CveDocumentacion") Is Nothing Then + Return -1 + Else + Return DirectCast(ViewState("CveDocumentacion"), Integer) + End If + End Get + Set(value As Integer) + ViewState("CveDocumentacion") = value + End Set + End Property + Property CveDocumentacionElectronica As Integer + Get + If ViewState("CvePersonalClienteDocumentacion") Is Nothing Then + Return -1 + Else + Return DirectCast(ViewState("CvePersonalClienteDocumentacion"), Integer) + End If + End Get + Set(value As Integer) + ViewState("CvePersonalClienteDocumentacion") = value + End Set + End Property + Property ActualizarDocumentacion As Boolean + Get + If ViewState("ActualizarDocumentacion") Is Nothing Then + Return True + Else + Return DirectCast(ViewState("ActualizarDocumentacion"), Boolean) + End If + End Get + Set(value As Boolean) + ViewState("ActualizarDocumentacion") = value + End Set + End Property + Private Property FechaLimite As Date + Get + If ViewState("FechaLimite") Is Nothing Then + Return Date.Now.AddDays(15) + Else + Return ViewState("FechaLimite").ToString.ToDate + End If + End Get + Set(value As Date) + ViewState("FechaLimite") = value + End Set + + End Property + Property Estatus As Integer + Get + If ViewState("Estatus") Is Nothing Then + Return 0 + Else + Return DirectCast(ViewState("Estatus"), Integer) + End If + End Get + Set(value As Integer) + ViewState("Estatus") = value + End Set + End Property + Property ObservacionDocumentacion As String + Get + If ViewState("ObservacionDocumentacion") Is Nothing Then + Return "" + Else + Return ViewState("ObservacionDocumentacion").ToString + End If + End Get + Set(value As String) + ViewState("ObservacionDocumentacion") = value + End Set + End Property + Property AdjuntoDocumentacion As String + Get + If ViewState("AdjuntoDocumentacion") Is Nothing Then + Return "" + Else + Return ViewState("AdjuntoDocumentacion").ToString + End If + End Get + Set(value As String) + ViewState("AdjuntoDocumentacion") = value + End Set + End Property + 'Private ReadOnly Property CvePersonal As Integer + ' Get + ' If ViewState("CvePersonal") Is Nothing Then + ' Return -1 + ' Else + ' Return ViewState("CvePersonal").ToString.ToEntero + ' End If + ' End Get + 'End Property + +#End Region + + + +#Region " A C U M U L A D O R E S" + Property CveVentaNota As Integer + Get + If ViewState("CveVentaNota") Is Nothing Then + Return 0 + Else + Return ViewState("CveVentaNota").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("CveVentaNota") = value + End Set + + End Property + + Property FolioNotaAcumulador As Integer + Get + If ViewState("FolioNotaAcumulador") Is Nothing Then + Return 0 + Else + Return ViewState("FolioNotaAcumulador").ToString.ToEntero + End If + End Get + Set(value As Integer) + ViewState("FolioNotaAcumulador") = value + End Set + End Property + Property SerieNotaAcumulador As String + Get + If ViewState("SerieNotaAcumulador") Is Nothing Then + Return "" + + Else + Return ViewState("SerieNotaAcumulador").ToString + End If + End Get + Set(value As String) + ViewState("SerieNotaAcumulador") = 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 + + Actualizar = False + SetValues() + CargaCombos() + CreaDTVentas() + CreaDtPago() + RegistraScript("CargaHeader();") + + + If UsuarioActual.Empresa.CvePlataforma = 3 Then 'SI ES USUARIO GPS + TabFiscalContable.Visible = True + TabRetenciones.Visible = False + TabOS.Visible = False + TabComplementos.Visible = False + TabOtros.Visible = False + TabCuentasEquipos.Visible = True + ReporteDispositivos.Visible = True + TabCuentasEquipos.HeaderText = "Equipos GPS" + TabRH.Visible = False + TabUsuarios.Visible = True + TabUsuarios.HeaderText = "Usuarios" + dvZH.Visible = True + CargaZonasHorarias() + dvPlataformaSig.Style.Add("display", "none") + dvPlataformGPS.Style.Add("display", "") + BtnAgregarCtaEquipo.Visible = False + HyperLink1.Text = "Georef" + HyperLink1.ToolTip = "Creación de geocercas y rutas" + HyperLink2.Text = "Rastreo" + HyperLink2.ToolTip = "Rastreo de equipos" + HyperLink3.Text = "P.Interes" + HyperLink3.ToolTip = "Creación y reportes de puntos de interés" + ThBusqueda.Visible = True + TdBusqueda.Visible = True + HyperLink7.Visible = False + ChkSist.Visible = False + + CargaEmpresasUsuario(UsuarioActual.CveEmpresa) + End If + + 'ROL DE GPS + If UsuarioActual.CveRol = 1198 Then + TabUsuarios.HeaderText = "Usuarios" + End If + + '02/07/2018 - PRUEBAS USUARIOS PLATAFORMA CLIENTES + If UsuarioActual.Empresa.CvePlataforma = 1 Then 'SI ES USUARIO SIG + TabUsuarios.Visible = True + End If + + If UsuarioActual.Empresa.Funcionalidad(510) <> "" Then + TabCuentasEquipos.HeaderText = UsuarioActual.Empresa.Funcionalidad(510) + TabCuentasEquipos.Visible = True + End If + + If UsuarioActual.Empresa.Funcionalidad(504).ToEntero > 0 Then + If UsuarioActual.TienePermisoProceso(162) Then + ChkPermiteCredito.Enabled = True + TxtLimiteCreditoSucursal.Enabled = True + Else + ChkPermiteCredito.Enabled = False + TxtLimiteCreditoSucursal.Enabled = False + End If + ChkEstado.Enabled = False + If UsuarioActual.TienePermisoProceso(180) Then + ChkEstado.Enabled = True + End If End If If UsuarioActual.Empresa.Funcionalidad(579) = "1" Then DivTipoRetenciones.Visible = True DivRetIVA.Visible = False - End If - - If Request("CveCliente") IsNot Nothing AndAlso IsNumeric(Request("CveCliente")) AndAlso Request("CveCliente").ToEntero > 0 Then - 'If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 AndAlso Not Request("CveCliente").Contiene("10450", "10460", "10458") Then - ' BtnGuardar.Enabled = False : BtnEliminar.Enabled = False : LbAgregarSucursal.Enabled = False : LbEnviarActivacionPortal.Enabled = False - ' Exit Sub - 'ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 AndAlso Not Request("CveCliente").Contiene("27448") Then - ' BtnGuardar.Enabled = False : BtnEliminar.Enabled = False : LbAgregarSucursal.Enabled = False : LbEnviarActivacionPortal.Enabled = False - ' Exit Sub - 'Else - ViewState("CveCliente") = Request("CveCliente") - CargaDatos() - If Existe Then - 'Configuración de Modalidad Update - BtnGuardar.Text = "Guardar Cambios" - LtlTitulo.Text = "Consulta del Cliente:" - CargaDatosContrato() - - - 'ImgAddVenta - HplAddVenta.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveCliente={0}", CveCliente) - HplAddCotizacion.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveCliente={0}&Op=Cot", CveCliente) - 'ImgAddObs.Attributes.Add("onclick", "javascript:PosicionaObjeto(this.id,'DivEventoBitacora',null,-250,-250); $('#DivEventoBitacora').show(1000); ") - If Request("Opt") IsNot Nothing AndAlso IsNumeric(Request("Opt")) Then Tab.ActiveTabIndex = Request("Opt").ToEntero - CargaDireccionesEnvio() - CargaAFAsignados() - - 'CARGA LOS FILTROS DEL TAB COMPORTAMIENTO VENTA - TabComportamientoVentas.Visible = True - CargaFiltros() - - 'JM 05-02-19: CRM - If UsuarioActual.Empresa.UsaCRM Then - VerificaVinculacion() - UpAccionesCRM.Update() - End If - End If - 'End If - HlEvento.Visible = True - HlEvento.NavigateUrl = "/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveCliente=" & CveCliente & "&TB_iframe=true&height=370&width=600;" - - If UsuarioActual.Empresa.CvePlataforma = 3 Then - dvPlataformaSig.Style.Add("display", "none") - dvPlataformGPS.Style.Add("display", "") - CargaUsuarios() - BtnAgregarCtaEquipo.Visible = False - End If - - '02/07/2018 - PRUEBAS USUARIOS PLATAFORMA CLIENTES - If UsuarioActual.Empresa.CvePlataforma = 1 Then - CargaUsuariosPortalCliente() - End If - - If Request("ATI") IsNot Nothing AndAlso IsNumeric(Request("ATI")) Then - Tab.ActiveTabIndex = Request("ATI").ToEntero - End If - CargaCuentasyConceptos() - Else - 'Configuración de Modalidad Insert - - If UsuarioActual.Empresa.Funcionalidad(525) = "1" Then - Dim ObjClientes As New ClsClientes - TxtCodigo.Text = ObjClientes.GetSiguienteCodigoCliente(UsuarioActual.CveEmpresa).ToString - ObjClientes.Dispose() - End If - - ImgAddObs.Visible = False - LblFechaCaptura.Text = Now.ToShortDateString() - LblUsuarioCapturo.Text = UsuarioActual.Usuario - ViewState("CveCliente") = -1 - BtnEliminar.Visible = False - LbAgregarSucursal.Enabled = True - CreaDTSucursales() - CargaDocumentacionCliente() - - TxtPais.Text = "México" - End If - - If UsuarioActual.Empresa.CvePlataforma = 3 Then - LbAddDispositivo.Visible = True - LbAddDispositivo.Attributes.Add("onclick", $"javascript:AbrirVentana('/GPS/WizardDispositivos.aspx?CveCliente={CveCliente}', 801, 700);") - LnkAddUsuario.Visible = True - LnkAddUsuario.Attributes.Add("onclick", $"javascript:AbrirVentana('/Sistemas/PopUpAddUsuario.aspx?CveCliente={CveCliente}', 801, 700);") - End If - - '02/07/2018 - PRUEBAS USUARIOS PLATAFORMA CLIENTES - If UsuarioActual.Empresa.CvePlataforma = 1 And CveCliente > 0 Then - LnkAddUsuario.Visible = True - LnkAddUsuario.Attributes.Add("onclick", $"javascript:AbrirVentana('/Sistemas/PopUpAddUsuario.aspx?CveCliente={CveCliente}', 801, 700);") - End If - - TrImprimeNombreSucursal.Visible = True - - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - DivRetenciones.Visible = False - DivRetFletes.Visible = False - DivDiasRevision.Visible = True - DivDiasRevisionObs.Visible = True - UpParametros.Update() - UpFiscalContable.Update() - End If - - If Request("CveEmpresaCRM") IsNot Nothing AndAlso IsNumeric(Request("CveEmpresaCRM")) AndAlso Request("CveEmpresaCRM").ToEntero > 0 Then - ViewState("CveEmpresaCRM") = Request("CveEmpresaCRM") - CargaDatosCRM() - End If - - ChecaPermiteCredito() - - - 'Crea y carga CuentasBancarias - tab:Bancos - CargaCuentasBancarias() - - - 'PERMISOS PAGINA - If CveCliente > 0 Then - BtnEliminar.Visible = PermiteEliminar() - BtnGuardar.Visible = PermiteEditar() - Else - BtnGuardar.Visible = PermiteGuardar() - End If - UpGuardar.Update() - - '[IPP]: SOLO PARA JAM - 'CORPORATIVO - Div2.Visible = UsuarioActual.CveEmpresa = 119 - - 'ENVIO SMS SOLO VSH - BtnCobranzaSMS.Visible = CobranzaTelefono.Length = 10 And UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12) - - If TxtRFC.Text.Length = 13 Then - LnkPersonaFisica.Visible = True - End If - - InicializaDevolverDinero() - - TxtFechaICredito.Text = Now.AddYears(-2).ToShortDateString - TxtFechaFCredito.Text = Now.ToShortDateString - - - - If UsuarioActual.TienePermisoProceso(257) Then 'Falta agregar proceso - DivMapAddSucursal.Visible = True - LiLnkAgragarDireccion.Visible = True - End If - - End If - - 'EN SERIO SE OCUPA EN CADA POSTBACK ??? IPP 7 SEPTIEMNRE 2017 - ChkPermiso4.Enabled = False - ChkPermiso5.Enabled = False - ChkPermiso6.Enabled = False - - End Sub - -#Region " PERMISOS PAGINAS " - Private Function PermiteGuardar() As Boolean - Return UsuarioActual.TienePermisoProceso(192) - End Function - Private Function PermiteEditar() As Boolean - Return UsuarioActual.TienePermisoProceso(193) - End Function - Private Function PermiteEliminar() As Boolean - Return UsuarioActual.TienePermisoProceso(194) - End Function - -#End Region - - -#Region "C A R G A S" - Private Sub CreaDtPago() - DtPagos = New DataTable - DtPagos.Columns.Add("CveTipoMovimiento", GetType(String)) - DtPagos.Columns.Add("TipoMovimiento", GetType(String)) - DtPagos.Columns.Add("CveCuenta", GetType(String)) - DtPagos.Columns.Add("Cuenta", GetType(String)) - DtPagos.Columns.Add("Folio", GetType(String)) - DtPagos.Columns.Add("Importe", GetType(Decimal)) - DtPagos.Columns.Add("Observaciones", GetType(String)) - DtPagos.Columns.Add("Tipo", GetType(String)) - DtPagos.Columns.Add("CveMetodoPago", GetType(Integer)) - End Sub - Private Sub CargaClasificaciones() - Dim Dt As DataTable = GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa) - DdlClasificacion.DataSource = Dt - DdlClasificacion.DataBind() - DdlClasificacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - UpDatos.Update() - End Sub - Private Sub CargaResponsables() - Dim Dt As DataTable = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltraParametros("True", "Nombre") - DdlResponsable.DataSource = Dt.FiltraParametros("", "", {"CveUsuario", "Nombre"}) - DdlResponsable.DataBind() - DdlResponsable.Items.Insert(0, New ListItem("Seleccione", "-1")) - - DdlResponsableSucursal.DataSource = Dt - DdlResponsableSucursal.DataBind() - DdlResponsableSucursal.Items.Insert(0, New ListItem("Seleccione", "-1")) - - UpAgregarSucursal.Update() - UpDatos.Update() - End Sub - Private Sub CargaCondicionesEntrega() - Dim Dt As DataTable = GlobalDTVtaCondicionesEntrega(UsuarioActual.CveEmpresa) - DdlCondicionesEntrega.DataSource = Dt - DdlCondicionesEntrega.DataBind() - DdlCondicionesEntrega.Items.Insert(0, New ListItem("-", "-1")) - UpDatos.Update() - End Sub - Private Sub CargaZonasHorarias() - Dim GPS As New ClsGPS - If GPS.GetZonasHorarias() Then - DdlZonaHoraria.DataSource = GPS.DtResultados - Else - DdlZonaHoraria.DataSource = Nothing - End If - DdlZonaHoraria.DataBind() - DdlZonaHoraria.Items.Insert(0, New ListItem("-", "-1")) - GPS.Dispose() - End Sub - Private Sub CargaUsuarios() - GvUsuarios.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa, CveCliente, -1) - GvUsuarios.DataBind() - UpGvUsuarios.Update() - End Sub - Protected Sub CargaDdlSucursalCliente() - Dim ObjCliente As New ClsClientes - - DdlClienteSucursal.Items.Clear() - DdlClienteSucursalEnvio.Items.Clear() - - If ObjCliente.GetSucursales(CveCliente) Then - If ObjCliente.DtResultados.Rows.Count > 0 Then - DivFiltraSucursal.Visible = True - DdlSucursalCliente.DataSource = ObjCliente.DtResultados - DdlClienteSucursal.DataSource = ObjCliente.DtResultados - DdlClienteSucursalEnvio.DataSource = ObjCliente.DtResultados - End If - End If - - ObjCliente.Dispose() - DdlSucursalCliente.DataBind() - DdlSucursalCliente.Items.Insert(0, New ListItem("Matriz", "0")) - DdlSucursalCliente.Items.Insert(0, New ListItem("Todas", "-1")) - DdlSucursalCliente.SelectedValue = "-1" - - DdlClienteSucursal.DataBind() - DdlClienteSucursal.Items.Insert(0, New ListItem("Todas", "-1")) - DdlClienteSucursal.SelectedValue = "-1" - - DdlClienteSucursalEnvio.DataBind() - DdlClienteSucursalEnvio.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlClienteSucursalEnvio.SelectedValue = "-1" - End Sub - Private Sub CargaGridRetenciones() - Dim ObjClientes As New ClsClientes - If ObjClientes.RetencionesGet(CveCliente, -1, UsuarioActual.CveEmpresa) Then - GvRetenciones.DataSource = ObjClientes.DtResultados - If ObjClientes.DtResultados.Rows.Count > 0 Then TabRetenciones.Visible = True - End If - ObjClientes.Dispose() - GvRetenciones.DataBind() - End Sub - Private Sub CargaCuentasEquipos() - Dim Objeto As New ClsGenerales - If Objeto.GetCuentasEquipos(CveCliente, -1) Then - If Objeto.DtResultados.Rows.Count > 0 Then TabOS.Visible = True - GvCuentasEquipos.DataSource = Objeto.DtResultados - End If - - If Objeto.GetTipoCuentasEquipos() Then - DdlTipoCuentaDetalle.Items.Clear() - DdlTipoCuentaDetalle.DataSource = Objeto.DtResultados - - DdlTipoCuentaDetalle.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - Objeto.Dispose() - GvCuentasEquipos.DataBind() - DdlTipoCuentaDetalle.DataBind() - End Sub - Private Sub CargaCuentasContablesDdls() - DdlCtaContableClientes.AutoPostBack = True - DdlCtaContableAnticipos.AutoPostBack = True - DdlCtaContableRetIVA.AutoPostBack = True - DdlCtaContableRetISR.AutoPostBack = True - DdlCtaContableFondoGarantia.AutoPostBack = True - DdlCtaContableCompClientes.AutoPostBack = True - DdlCtaContableCompAnticipos.AutoPostBack = True - DdlMonedaExtranjeraClientes.AutoPostBack = True - DdlMonedaExtranjeraAnticipos.AutoPostBack = True - - If UsuarioActual.Empresa.Funcionalidad(246).ToEntero > 0 Then - DdlCtaContableClientes.Attributes.Add("onclick", "CargaCuentas(1);") - End If - - If UsuarioActual.Empresa.Funcionalidad(237).ToEntero > 0 Then - DdlCtaContableAnticipos.Attributes.Add("onclick", "CargaCuentas(2);") - End If - - 'DdlCtaContableRetIVA.Attributes.Add("onclick", "CargaCuentas(3);") - 'DdlCtaContableRetISR.Attributes.Add("onclick", "CargaCuentas(4);") - 'DdlCtaContableFondoGarantia.Attributes.Add("onclick", "CargaCuentas(5);") - - If UsuarioActual.Empresa.Funcionalidad(248).ToEntero > 0 Then - DdlCtaContableCompClientes.Attributes.Add("onclick", "CargaCuentas(6);") - End If - - DdlCtaContableCompAnticipos.Attributes.Add("onclick", "CargaCuentas(7);") - - If UsuarioActual.Empresa.Funcionalidad(247).ToEntero > 0 Then - DdlMonedaExtranjeraClientes.Attributes.Add("onclick", "CargaCuentas(8);") - End If - DdlMonedaExtranjeraAnticipos.Attributes.Add("onclick", "CargaCuentas(9);") - - End Sub + End If + + If Request("CveCliente") IsNot Nothing AndAlso IsNumeric(Request("CveCliente")) AndAlso Request("CveCliente").ToEntero > 0 Then + 'If UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 77 AndAlso Not Request("CveCliente").Contiene("10450", "10460", "10458") Then + ' BtnGuardar.Enabled = False : BtnEliminar.Enabled = False : LbAgregarSucursal.Enabled = False : LbEnviarActivacionPortal.Enabled = False + ' Exit Sub + 'ElseIf UsuarioActual.CveEmpresa = 2 AndAlso UsuarioActual.CveUsuario = 21 AndAlso Not Request("CveCliente").Contiene("27448") Then + ' BtnGuardar.Enabled = False : BtnEliminar.Enabled = False : LbAgregarSucursal.Enabled = False : LbEnviarActivacionPortal.Enabled = False + ' Exit Sub + 'Else + ViewState("CveCliente") = Request("CveCliente") + CargaDatos() + If Existe Then + 'Configuración de Modalidad Update + BtnGuardar.Text = "Guardar Cambios" + LtlTitulo.Text = "Consulta del Cliente:" + CargaDatosContrato() + + + 'ImgAddVenta + HplAddVenta.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveCliente={0}", CveCliente) + HplAddCotizacion.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveCliente={0}&Op=Cot", CveCliente) + 'ImgAddObs.Attributes.Add("onclick", "javascript:PosicionaObjeto(this.id,'DivEventoBitacora',null,-250,-250); $('#DivEventoBitacora').show(1000); ") + If Request("Opt") IsNot Nothing AndAlso IsNumeric(Request("Opt")) Then Tab.ActiveTabIndex = Request("Opt").ToEntero + CargaDireccionesEnvio() + CargaAFAsignados() + + 'CARGA LOS FILTROS DEL TAB COMPORTAMIENTO VENTA + TabComportamientoVentas.Visible = True + CargaFiltros() + + 'JM 05-02-19: CRM + If UsuarioActual.Empresa.UsaCRM Then + VerificaVinculacion() + UpAccionesCRM.Update() + End If + End If + 'End If + HlEvento.Visible = True + HlEvento.NavigateUrl = "/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveCliente=" & CveCliente & "&TB_iframe=true&height=370&width=600;" + + If UsuarioActual.Empresa.CvePlataforma = 3 Then + dvPlataformaSig.Style.Add("display", "none") + dvPlataformGPS.Style.Add("display", "") + CargaUsuarios() + BtnAgregarCtaEquipo.Visible = False + End If + + '02/07/2018 - PRUEBAS USUARIOS PLATAFORMA CLIENTES + If UsuarioActual.Empresa.CvePlataforma = 1 Then + CargaUsuariosPortalCliente() + End If + + If Request("ATI") IsNot Nothing AndAlso IsNumeric(Request("ATI")) Then + Tab.ActiveTabIndex = Request("ATI").ToEntero + End If + CargaCuentasyConceptos() + Else + 'Configuración de Modalidad Insert + + If UsuarioActual.Empresa.Funcionalidad(525) = "1" Then + Dim ObjClientes As New ClsClientes + TxtCodigo.Text = ObjClientes.GetSiguienteCodigoCliente(UsuarioActual.CveEmpresa).ToString + ObjClientes.Dispose() + End If + + ImgAddObs.Visible = False + LblFechaCaptura.Text = Now.ToShortDateString() + LblUsuarioCapturo.Text = UsuarioActual.Usuario + ViewState("CveCliente") = -1 + BtnEliminar.Visible = False + LbAgregarSucursal.Enabled = True + CreaDTSucursales() + CargaDocumentacionCliente() + + TxtPais.Text = "México" + End If + + If UsuarioActual.Empresa.CvePlataforma = 3 Then + LbAddDispositivo.Visible = True + LbAddDispositivo.Attributes.Add("onclick", $"javascript:AbrirVentana('/GPS/WizardDispositivos.aspx?CveCliente={CveCliente}', 801, 700);") + LnkAddUsuario.Visible = True + LnkAddUsuario.Attributes.Add("onclick", $"javascript:AbrirVentana('/Sistemas/PopUpAddUsuario.aspx?CveCliente={CveCliente}', 801, 700);") + End If + + '02/07/2018 - PRUEBAS USUARIOS PLATAFORMA CLIENTES + If UsuarioActual.Empresa.CvePlataforma = 1 And CveCliente > 0 Then + LnkAddUsuario.Visible = True + LnkAddUsuario.Attributes.Add("onclick", $"javascript:AbrirVentana('/Sistemas/PopUpAddUsuario.aspx?CveCliente={CveCliente}', 801, 700);") + End If + + TrImprimeNombreSucursal.Visible = True + + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + DivRetenciones.Visible = False + DivRetFletes.Visible = False + DivDiasRevision.Visible = True + DivDiasRevisionObs.Visible = True + UpParametros.Update() + UpFiscalContable.Update() + End If + + If Request("CveEmpresaCRM") IsNot Nothing AndAlso IsNumeric(Request("CveEmpresaCRM")) AndAlso Request("CveEmpresaCRM").ToEntero > 0 Then + ViewState("CveEmpresaCRM") = Request("CveEmpresaCRM") + CargaDatosCRM() + End If + + ChecaPermiteCredito() + + + 'Crea y carga CuentasBancarias - tab:Bancos + CargaCuentasBancarias() + + + 'PERMISOS PAGINA + If CveCliente > 0 Then + BtnEliminar.Visible = PermiteEliminar() + BtnGuardar.Visible = PermiteEditar() + Else + BtnGuardar.Visible = PermiteGuardar() + End If + UpGuardar.Update() + + '[IPP]: SOLO PARA JAM + 'CORPORATIVO + Div2.Visible = UsuarioActual.CveEmpresa = 119 + + 'ENVIO SMS SOLO VSH + BtnCobranzaSMS.Visible = CobranzaTelefono.Length = 10 And UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12) + + If TxtRFC.Text.Length = 13 Then + LnkPersonaFisica.Visible = True + End If + + InicializaDevolverDinero() + + TxtFechaICredito.Text = Now.AddYears(-2).ToShortDateString + TxtFechaFCredito.Text = Now.ToShortDateString + + + + If UsuarioActual.TienePermisoProceso(257) Then 'Falta agregar proceso + DivMapAddSucursal.Visible = True + LiLnkAgragarDireccion.Visible = True + End If + + End If + + 'EN SERIO SE OCUPA EN CADA POSTBACK ??? IPP 7 SEPTIEMNRE 2017 + ChkPermiso4.Enabled = False + ChkPermiso5.Enabled = False + ChkPermiso6.Enabled = False + + End Sub + +#Region " PERMISOS PAGINAS " + Private Function PermiteGuardar() As Boolean + Return UsuarioActual.TienePermisoProceso(192) + End Function + Private Function PermiteEditar() As Boolean + Return UsuarioActual.TienePermisoProceso(193) + End Function + Private Function PermiteEliminar() As Boolean + Return UsuarioActual.TienePermisoProceso(194) + End Function + +#End Region + + +#Region "C A R G A S" + Private Sub CreaDtPago() + DtPagos = New DataTable + DtPagos.Columns.Add("CveTipoMovimiento", GetType(String)) + DtPagos.Columns.Add("TipoMovimiento", GetType(String)) + DtPagos.Columns.Add("CveCuenta", GetType(String)) + DtPagos.Columns.Add("Cuenta", GetType(String)) + DtPagos.Columns.Add("Folio", GetType(String)) + DtPagos.Columns.Add("Importe", GetType(Decimal)) + DtPagos.Columns.Add("Observaciones", GetType(String)) + DtPagos.Columns.Add("Tipo", GetType(String)) + DtPagos.Columns.Add("CveMetodoPago", GetType(Integer)) + End Sub + Private Sub CargaClasificaciones() + Dim Dt As DataTable = GlobalDTClienteClasificaciones(UsuarioActual.CveEmpresa) + DdlClasificacion.DataSource = Dt + DdlClasificacion.DataBind() + DdlClasificacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + UpDatos.Update() + End Sub + Private Sub CargaResponsables() + Dim Dt As DataTable = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltraParametros("True", "Nombre") + DdlResponsable.DataSource = Dt.FiltraParametros("", "", {"CveUsuario", "Nombre"}) + DdlResponsable.DataBind() + DdlResponsable.Items.Insert(0, New ListItem("Seleccione", "-1")) + + DdlResponsableSucursal.DataSource = Dt + DdlResponsableSucursal.DataBind() + DdlResponsableSucursal.Items.Insert(0, New ListItem("Seleccione", "-1")) + + UpAgregarSucursal.Update() + UpDatos.Update() + End Sub + Private Sub CargaCondicionesEntrega() + Dim Dt As DataTable = GlobalDTVtaCondicionesEntrega(UsuarioActual.CveEmpresa) + DdlCondicionesEntrega.DataSource = Dt + DdlCondicionesEntrega.DataBind() + DdlCondicionesEntrega.Items.Insert(0, New ListItem("-", "-1")) + UpDatos.Update() + End Sub + Private Sub CargaZonasHorarias() + Dim GPS As New ClsGPS + If GPS.GetZonasHorarias() Then + DdlZonaHoraria.DataSource = GPS.DtResultados + Else + DdlZonaHoraria.DataSource = Nothing + End If + DdlZonaHoraria.DataBind() + DdlZonaHoraria.Items.Insert(0, New ListItem("-", "-1")) + GPS.Dispose() + End Sub + Private Sub CargaUsuarios() + GvUsuarios.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa, CveCliente, -1) + GvUsuarios.DataBind() + UpGvUsuarios.Update() + End Sub + Protected Sub CargaDdlSucursalCliente() + Dim ObjCliente As New ClsClientes + + DdlClienteSucursal.Items.Clear() + DdlClienteSucursalEnvio.Items.Clear() + + If ObjCliente.GetSucursales(CveCliente) Then + If ObjCliente.DtResultados.Rows.Count > 0 Then + DivFiltraSucursal.Visible = True + DdlSucursalCliente.DataSource = ObjCliente.DtResultados + DdlClienteSucursal.DataSource = ObjCliente.DtResultados + DdlClienteSucursalEnvio.DataSource = ObjCliente.DtResultados + End If + End If + + ObjCliente.Dispose() + DdlSucursalCliente.DataBind() + DdlSucursalCliente.Items.Insert(0, New ListItem("Matriz", "0")) + DdlSucursalCliente.Items.Insert(0, New ListItem("Todas", "-1")) + DdlSucursalCliente.SelectedValue = "-1" + + DdlClienteSucursal.DataBind() + DdlClienteSucursal.Items.Insert(0, New ListItem("Todas", "-1")) + DdlClienteSucursal.SelectedValue = "-1" + + DdlClienteSucursalEnvio.DataBind() + DdlClienteSucursalEnvio.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlClienteSucursalEnvio.SelectedValue = "-1" + End Sub + Private Sub CargaGridRetenciones() + Dim ObjClientes As New ClsClientes + If ObjClientes.RetencionesGet(CveCliente, -1, UsuarioActual.CveEmpresa) Then + GvRetenciones.DataSource = ObjClientes.DtResultados + If ObjClientes.DtResultados.Rows.Count > 0 Then TabRetenciones.Visible = True + End If + ObjClientes.Dispose() + GvRetenciones.DataBind() + End Sub + Private Sub CargaCuentasEquipos() + Dim Objeto As New ClsGenerales + If Objeto.GetCuentasEquipos(CveCliente, -1) Then + If Objeto.DtResultados.Rows.Count > 0 Then TabOS.Visible = True + GvCuentasEquipos.DataSource = Objeto.DtResultados + End If + + If Objeto.GetTipoCuentasEquipos() Then + DdlTipoCuentaDetalle.Items.Clear() + DdlTipoCuentaDetalle.DataSource = Objeto.DtResultados + + DdlTipoCuentaDetalle.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + Objeto.Dispose() + GvCuentasEquipos.DataBind() + DdlTipoCuentaDetalle.DataBind() + End Sub + Private Sub CargaCuentasContablesDdls() + DdlCtaContableClientes.AutoPostBack = True + DdlCtaContableAnticipos.AutoPostBack = True + DdlCtaContableRetIVA.AutoPostBack = True + DdlCtaContableRetISR.AutoPostBack = True + DdlCtaContableFondoGarantia.AutoPostBack = True + DdlCtaContableCompClientes.AutoPostBack = True + DdlCtaContableCompAnticipos.AutoPostBack = True + DdlMonedaExtranjeraClientes.AutoPostBack = True + DdlMonedaExtranjeraAnticipos.AutoPostBack = True + + If UsuarioActual.Empresa.Funcionalidad(246).ToEntero > 0 Then + DdlCtaContableClientes.Attributes.Add("onclick", "CargaCuentas(1);") + End If + + If UsuarioActual.Empresa.Funcionalidad(237).ToEntero > 0 Then + DdlCtaContableAnticipos.Attributes.Add("onclick", "CargaCuentas(2);") + End If + + 'DdlCtaContableRetIVA.Attributes.Add("onclick", "CargaCuentas(3);") + 'DdlCtaContableRetISR.Attributes.Add("onclick", "CargaCuentas(4);") + 'DdlCtaContableFondoGarantia.Attributes.Add("onclick", "CargaCuentas(5);") + + If UsuarioActual.Empresa.Funcionalidad(248).ToEntero > 0 Then + DdlCtaContableCompClientes.Attributes.Add("onclick", "CargaCuentas(6);") + End If + + DdlCtaContableCompAnticipos.Attributes.Add("onclick", "CargaCuentas(7);") + + If UsuarioActual.Empresa.Funcionalidad(247).ToEntero > 0 Then + DdlMonedaExtranjeraClientes.Attributes.Add("onclick", "CargaCuentas(8);") + End If + DdlMonedaExtranjeraAnticipos.Attributes.Add("onclick", "CargaCuentas(9);") + + End Sub Private Sub CargaCuentasyConceptos() Dim ObjConta As New ClsContabilidad If ObjConta.GetCuentasyConceptos(CveCliente) Then @@ -1055,1519 +1055,1519 @@ Partial Class Clientes ObjConta.Dispose() GvCuentasContable.DataBind() UpCuentaConceptos.Update() - End Sub - Protected Sub BtnCargarCuentas_Click(sender As Object, e As EventArgs) Handles BtnCargarCuentas.Click - If UsuarioActual.Empresa.ServerContPAQi = "" Then Exit Sub - - Select Case HdnCuenta.Value - Case "1" - CargaDdlCuentasContables(DdlCtaContableClientes, UsuarioActual.Empresa.Funcionalidad(246).ToEntero) - Case "2" - CargaDdlCuentasContables(DdlCtaContableAnticipos, UsuarioActual.Empresa.Funcionalidad(237).ToEntero) - Case "3" - CargaDdlCuentasContables(DdlCtaContableRetIVA, -1) - Case "4" - CargaDdlCuentasContables(DdlCtaContableRetISR, -1) - Case "5" - CargaDdlCuentasContables(DdlCtaContableFondoGarantia, -1) - Case "6" - CargaDdlCuentasContables(DdlCtaContableCompClientes, UsuarioActual.Empresa.Funcionalidad(248).ToEntero) - Case "7" - CargaDdlCuentasContables(DdlCtaContableCompAnticipos, -1) - Case "8" - CargaDdlCuentasContables(DdlMonedaExtranjeraClientes, UsuarioActual.Empresa.Funcionalidad(247).ToEntero) - Case "9" - CargaDdlCuentasContables(DdlMonedaExtranjeraAnticipos, UsuarioActual.Empresa.Funcionalidad(542).ToEntero) - End Select - UpFiscalContable.Update() - - ' Las funcionalidades 246, 247 y 248 para DdlCtaContableClientes, DdlMonedaExtranjeraClientes y DdlCtaContableCompClientes tienen prioridad sobre las demas. - 'If UsuarioActual.Empresa.UsaContabilidad Then CargaCuentasContablesClientes() - - - End Sub - - 'Private Sub CargaCuentasContablesClientes() - ' If UsuarioActual.Empresa.ServerContPAQi = "" Then Exit Sub - ' ' Verifica si la empresas tienen las funcionalidades 246, 247 y 248 - ' Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) - - ' If UsuarioActual.Empresa.Funcionalidad(246).ToEntero > 0 Then - ' If ObjContabilidad.GetCuentas(UsuarioActual.Empresa.Funcionalidad(246).ToEntero, "-1", 1) Then - ' DdlCtaContableClientes.Items.Clear() - ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) - ' DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados - ' DdlCtaContableClientes.DataBind() - ' End If - ' End If - - ' If UsuarioActual.Empresa.Funcionalidad(247).ToEntero > 0 Then - ' If ObjContabilidad.GetCuentas(UsuarioActual.Empresa.Funcionalidad(247).ToEntero, "-1", 1) Then - ' DdlMonedaExtranjeraClientes.Items.Clear() - ' DdlMonedaExtranjeraClientes.Items.Add(New ListItem("Seleccione", "0")) - ' DdlMonedaExtranjeraClientes.DataSource = ObjContabilidad.DtResultados - ' DdlMonedaExtranjeraClientes.DataBind() - ' End If - ' End If - - ' If UsuarioActual.Empresa.Funcionalidad(248).ToEntero > 0 Then - ' If ObjContabilidad.GetCuentas(UsuarioActual.Empresa.Funcionalidad(248).ToEntero, "-1", 1) Then - ' DdlCtaContableCompClientes.Items.Clear() - ' DdlCtaContableCompClientes.Items.Add(New ListItem("Seleccione", "0")) - ' DdlCtaContableCompClientes.DataSource = ObjContabilidad.DtResultados - ' DdlCtaContableCompClientes.DataBind() - ' End If - ' End If - - ' ObjContabilidad.Dispose() - - 'End Sub - Private Sub CargaDdlCuentasContables(Ddl As DropDownList, Optional CveFuncionalidad As Integer = -1) - Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) - If ObjContabilidad.GetCuentasRecursiva(CveFuncionalidad, 1) Then - Dim Seleccionado = Ddl.SelectedValue - Ddl.Items.Clear() - Ddl.Items.Add(New ListItem("Seleccione", "0")) - Ddl.DataSource = ObjContabilidad.DtResultados - Ddl.DataBind() - Ddl.AutoPostBack = False - Ddl.Attributes.Remove("onclick") - Ddl.CssClass &= " select2me" - Ddl.SelectedValueExist(Seleccionado) - End If - ObjContabilidad.Dispose() - End Sub - - - Private Sub CargaCombos() - CargaSubProyectoss() - CargaMetodosPago() - CargaPrecioLista() - CargaVendedores() - - - CargaCorporativo() - - CargaMetodosPago33() - CargaFormaPago33() - CargaComboCFDI() - - CargaClasificaciones() - - If UsuarioActual.Empresa.UsaContabilidad Then - 'CargaCuentasContables() - End If - - - CargaCombosComercioExterior() - - End Sub - Private Sub CargaSubProyectoss() - DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1).FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - DdlSubProyecto.DataBind() - - 'If UsuarioActual.CveSucursal = -1 Then - ' DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) - 'Else - ' DdlSubProyecto.SelectedValue = UsuarioActual.CveSucursal.ToString - 'End If - End Sub - Private Sub CargaMetodosPago() - DdlMetodoPago.DataSource = GlobalDTMetodosPago.FiltraParametros("Estatus = 'Activo'", "ClaveSAT") '.FiltraParametros("CveMetodoPago > 0 ") - DdlMetodoPagoSucursal.DataSource = GlobalDTMetodosPago.FiltraParametros("Estatus = 'Activo'", "ClaveSAT") - DdlMetodoPagoSucursal.DataBind() - DdlMetodoPago.DataBind() - End Sub - Private Sub CargaPrecioLista() - DdlPrecioLista.DataSource = GlobalDTPrecioListas(UsuarioActual.CveEmpresa) - DdlPrecioLista.DataBind() - DdlPrecioLista.Items.Insert(0, New ListItem(" - ", "-1")) - End Sub - Private Sub CargaCuentasContables() - If UsuarioActual.Empresa.ServerContPAQi = "" Then Exit Sub - Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) - If ObjContabilidad.GetCuentas(-1, "-1", -1) Then - DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados - DdlCtaContableAnticipos.DataSource = ObjContabilidad.DtResultados - DdlCtaContableRetIVA.DataSource = ObjContabilidad.DtResultados - DdlCtaContableRetISR.DataSource = ObjContabilidad.DtResultados - DdlCtaContableFondoGarantia.DataSource = ObjContabilidad.DtResultados - DdlCtaContableCompClientes.DataSource = ObjContabilidad.DtResultados - DdlCtaContableCompAnticipos.DataSource = ObjContabilidad.DtResultados - DdlMonedaExtranjeraClientes.DataSource = ObjContabilidad.DtResultados - DdlMonedaExtranjeraAnticipos.DataSource = ObjContabilidad.DtResultados - Else - DdlCtaContableClientes.DataSource = Nothing - DdlCtaContableAnticipos.DataSource = Nothing - DdlCtaContableRetIVA.DataSource = Nothing - DdlCtaContableRetISR.DataSource = Nothing - DdlCtaContableFondoGarantia.DataSource = Nothing - DdlCtaContableCompClientes.DataSource = Nothing - DdlCtaContableCompAnticipos.DataSource = Nothing - DdlMonedaExtranjeraClientes.DataSource = Nothing - DdlMonedaExtranjeraAnticipos.DataSource = Nothing - End If - - If UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 Then - If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(211).ToEntero) Then - DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(212).ToEntero > 0 Then - If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(212).ToEntero) Then - DdlCtaContableAnticipos.DataSource = ObjContabilidad.DtResultados - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(213).ToEntero > 0 Then - If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(213).ToEntero) Then - DdlCtaContableRetIVA.DataSource = ObjContabilidad.DtResultados - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(214).ToEntero > 0 Then - If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then - DdlCtaContableRetISR.DataSource = ObjContabilidad.DtResultados - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(214).ToEntero > 0 Then - If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then - DdlCtaContableFondoGarantia.DataSource = ObjContabilidad.DtResultados - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 Then - If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then - DdlCtaContableCompClientes.DataSource = ObjContabilidad.DtResultados - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(212).ToEntero > 0 Then - If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then - DdlCtaContableCompAnticipos.DataSource = ObjContabilidad.DtResultados - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 Then - If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then - DdlMonedaExtranjeraClientes.DataSource = ObjContabilidad.DtResultados - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(212).ToEntero > 0 Then - If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then - DdlMonedaExtranjeraAnticipos.DataSource = ObjContabilidad.DtResultados - End If - End If - - ObjContabilidad.Dispose() - DdlCtaContableClientes.DataBind() - DdlCtaContableAnticipos.DataBind() - DdlCtaContableRetIVA.DataBind() - DdlCtaContableRetISR.DataBind() - DdlCtaContableFondoGarantia.DataBind() - - DdlCtaContableCompClientes.DataBind() - DdlCtaContableCompAnticipos.DataBind() - - DdlMonedaExtranjeraClientes.DataBind() - DdlMonedaExtranjeraAnticipos.DataBind() - End Sub - Private Sub CargaVendedores() - Dim dt As DataTable = GlobalDTVendedores(UsuarioActual.CveEmpresa) - Dim item As New ListItem("Seleccione", "-1") - DdlVendedor.DataSource = dt - DdlVendedorSucursal.DataSource = dt - - DdlVendedor.DataBind() - DdlVendedorSucursal.DataBind() - - DdlVendedor.Items.Insert(0, item) - DdlVendedorSucursal.Items.Insert(0, New ListItem("Seleccione", "-1")) - - - End Sub - Private Sub CargaCorporativo() - - Dim ObjCorporativo As New ClsClientes - - If ObjCorporativo.GetCorporativo(UsuarioActual.CveEmpresa, 1) Then - If ObjCorporativo.DtResultados.Rows.Count > 0 Then - Dim dt As DataTable = ObjCorporativo.DtResultados - DdlCorporativo.DataSource = dt - DdlCorporativo.DataBind() - DdlCorporativo.Items.Insert(0, New ListItem("Seleccione", "-1")) - Else - DdlCorporativo.DataSource = Nothing - End If - End If - ObjCorporativo.Dispose() - End Sub - Protected Sub CargaCuentasExistentes() - 'SELECTED VALUES - DdlCtaContableClientes.SelectedValue = IdCtaCliente - DdlCtaContableAnticipos.SelectedValue = IdCtaAnticipos - DdlCtaContableRetIVA.SelectedValue = IdCtaRetIVA - DdlCtaContableRetISR.SelectedValue = IdCtaRetISR - DdlCtaContableFondoGarantia.SelectedValue = IdCtaFondoGarantia - - DdlMonedaExtranjeraClientes.SelectedValue = IdCtaMonedaExtranjera - DdlMonedaExtranjeraAnticipos.SelectedValue = IdCtaMonedaExtranjeraAnticipos - - ActivarRegistroAutomatico() - HeedarContable.Attributes.Remove("onclick") - UpFiscalContable.Update() - End Sub - Private Function CargaDatos() As Boolean - Dim watch As New Diagnostics.Stopwatch() - watch.Start() - Dim Retorno As Boolean = False - Dim ObjClientes As New ClsClientes() - If ObjClientes.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, Estatus:=-1, TipoCliente:=-1) Then - If ObjClientes.DtResultados.Rows.Count > 0 Then - Existe = True - Retorno = True - - CargaDdlSucursalCliente() - CargaDocumentosVenta(CveCliente) - - Dim RetSC As Boolean = CargaSucursalesCliente() - Dim RetCC As Boolean = CargaCotizaciones() - CargaHistorial() - Dim RetCxC As Boolean = CargaCxC() - CargaAnticipos() - CargaPersonalAsignado() - CargaUsuariosPortal() - CargaBancos() - CargaOrdenesServiciosCliente() - CargaImpuestosLocales() - CargaCuentasContablesDdls() - CargaResponsables() - CargaCondicionesEntrega() - 'CargaClasificaciones() - CargaGridRetenciones() - ' CargaDocs() - CargaCombos() - CargaDocumentacionCliente() - 'CargaMetodosPago33() - 'CargaFormaPago33() - 'CargaComboCFDI() - + End Sub + Protected Sub BtnCargarCuentas_Click(sender As Object, e As EventArgs) Handles BtnCargarCuentas.Click + If UsuarioActual.Empresa.ServerContPAQi = "" Then Exit Sub + + Select Case HdnCuenta.Value + Case "1" + CargaDdlCuentasContables(DdlCtaContableClientes, UsuarioActual.Empresa.Funcionalidad(246).ToEntero) + Case "2" + CargaDdlCuentasContables(DdlCtaContableAnticipos, UsuarioActual.Empresa.Funcionalidad(237).ToEntero) + Case "3" + CargaDdlCuentasContables(DdlCtaContableRetIVA, -1) + Case "4" + CargaDdlCuentasContables(DdlCtaContableRetISR, -1) + Case "5" + CargaDdlCuentasContables(DdlCtaContableFondoGarantia, -1) + Case "6" + CargaDdlCuentasContables(DdlCtaContableCompClientes, UsuarioActual.Empresa.Funcionalidad(248).ToEntero) + Case "7" + CargaDdlCuentasContables(DdlCtaContableCompAnticipos, -1) + Case "8" + CargaDdlCuentasContables(DdlMonedaExtranjeraClientes, UsuarioActual.Empresa.Funcionalidad(247).ToEntero) + Case "9" + CargaDdlCuentasContables(DdlMonedaExtranjeraAnticipos, UsuarioActual.Empresa.Funcionalidad(542).ToEntero) + End Select + UpFiscalContable.Update() + + ' Las funcionalidades 246, 247 y 248 para DdlCtaContableClientes, DdlMonedaExtranjeraClientes y DdlCtaContableCompClientes tienen prioridad sobre las demas. + 'If UsuarioActual.Empresa.UsaContabilidad Then CargaCuentasContablesClientes() + + + End Sub + + 'Private Sub CargaCuentasContablesClientes() + ' If UsuarioActual.Empresa.ServerContPAQi = "" Then Exit Sub + ' ' Verifica si la empresas tienen las funcionalidades 246, 247 y 248 + ' Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) + + ' If UsuarioActual.Empresa.Funcionalidad(246).ToEntero > 0 Then + ' If ObjContabilidad.GetCuentas(UsuarioActual.Empresa.Funcionalidad(246).ToEntero, "-1", 1) Then + ' DdlCtaContableClientes.Items.Clear() + ' DdlCtaContableClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados + ' DdlCtaContableClientes.DataBind() + ' End If + ' End If + + ' If UsuarioActual.Empresa.Funcionalidad(247).ToEntero > 0 Then + ' If ObjContabilidad.GetCuentas(UsuarioActual.Empresa.Funcionalidad(247).ToEntero, "-1", 1) Then + ' DdlMonedaExtranjeraClientes.Items.Clear() + ' DdlMonedaExtranjeraClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlMonedaExtranjeraClientes.DataSource = ObjContabilidad.DtResultados + ' DdlMonedaExtranjeraClientes.DataBind() + ' End If + ' End If + + ' If UsuarioActual.Empresa.Funcionalidad(248).ToEntero > 0 Then + ' If ObjContabilidad.GetCuentas(UsuarioActual.Empresa.Funcionalidad(248).ToEntero, "-1", 1) Then + ' DdlCtaContableCompClientes.Items.Clear() + ' DdlCtaContableCompClientes.Items.Add(New ListItem("Seleccione", "0")) + ' DdlCtaContableCompClientes.DataSource = ObjContabilidad.DtResultados + ' DdlCtaContableCompClientes.DataBind() + ' End If + ' End If + + ' ObjContabilidad.Dispose() + + 'End Sub + Private Sub CargaDdlCuentasContables(Ddl As DropDownList, Optional CveFuncionalidad As Integer = -1) + Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) + If ObjContabilidad.GetCuentasRecursiva(CveFuncionalidad, 1) Then + Dim Seleccionado = Ddl.SelectedValue + Ddl.Items.Clear() + Ddl.Items.Add(New ListItem("Seleccione", "0")) + Ddl.DataSource = ObjContabilidad.DtResultados + Ddl.DataBind() + Ddl.AutoPostBack = False + Ddl.Attributes.Remove("onclick") + Ddl.CssClass &= " select2me" + Ddl.SelectedValueExist(Seleccionado) + End If + ObjContabilidad.Dispose() + End Sub + + + Private Sub CargaCombos() + CargaSubProyectoss() + CargaMetodosPago() + CargaPrecioLista() + CargaVendedores() + + + CargaCorporativo() + + CargaMetodosPago33() + CargaFormaPago33() + CargaComboCFDI() + + CargaClasificaciones() + + If UsuarioActual.Empresa.UsaContabilidad Then + 'CargaCuentasContables() + End If + + + CargaCombosComercioExterior() + + End Sub + Private Sub CargaSubProyectoss() + DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1).FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + DdlSubProyecto.DataBind() + + 'If UsuarioActual.CveSucursal = -1 Then + ' DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1")) + 'Else + ' DdlSubProyecto.SelectedValue = UsuarioActual.CveSucursal.ToString + 'End If + End Sub + Private Sub CargaMetodosPago() + DdlMetodoPago.DataSource = GlobalDTMetodosPago.FiltraParametros("Estatus = 'Activo'", "ClaveSAT") '.FiltraParametros("CveMetodoPago > 0 ") + DdlMetodoPagoSucursal.DataSource = GlobalDTMetodosPago.FiltraParametros("Estatus = 'Activo'", "ClaveSAT") + DdlMetodoPagoSucursal.DataBind() + DdlMetodoPago.DataBind() + End Sub + Private Sub CargaPrecioLista() + DdlPrecioLista.DataSource = GlobalDTPrecioListas(UsuarioActual.CveEmpresa) + DdlPrecioLista.DataBind() + DdlPrecioLista.Items.Insert(0, New ListItem(" - ", "-1")) + End Sub + Private Sub CargaCuentasContables() + If UsuarioActual.Empresa.ServerContPAQi = "" Then Exit Sub + Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) + If ObjContabilidad.GetCuentas(-1, "-1", -1) Then + DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados + DdlCtaContableAnticipos.DataSource = ObjContabilidad.DtResultados + DdlCtaContableRetIVA.DataSource = ObjContabilidad.DtResultados + DdlCtaContableRetISR.DataSource = ObjContabilidad.DtResultados + DdlCtaContableFondoGarantia.DataSource = ObjContabilidad.DtResultados + DdlCtaContableCompClientes.DataSource = ObjContabilidad.DtResultados + DdlCtaContableCompAnticipos.DataSource = ObjContabilidad.DtResultados + DdlMonedaExtranjeraClientes.DataSource = ObjContabilidad.DtResultados + DdlMonedaExtranjeraAnticipos.DataSource = ObjContabilidad.DtResultados + Else + DdlCtaContableClientes.DataSource = Nothing + DdlCtaContableAnticipos.DataSource = Nothing + DdlCtaContableRetIVA.DataSource = Nothing + DdlCtaContableRetISR.DataSource = Nothing + DdlCtaContableFondoGarantia.DataSource = Nothing + DdlCtaContableCompClientes.DataSource = Nothing + DdlCtaContableCompAnticipos.DataSource = Nothing + DdlMonedaExtranjeraClientes.DataSource = Nothing + DdlMonedaExtranjeraAnticipos.DataSource = Nothing + End If + + If UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 Then + If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(211).ToEntero) Then + DdlCtaContableClientes.DataSource = ObjContabilidad.DtResultados + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(212).ToEntero > 0 Then + If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(212).ToEntero) Then + DdlCtaContableAnticipos.DataSource = ObjContabilidad.DtResultados + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(213).ToEntero > 0 Then + If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(213).ToEntero) Then + DdlCtaContableRetIVA.DataSource = ObjContabilidad.DtResultados + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(214).ToEntero > 0 Then + If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then + DdlCtaContableRetISR.DataSource = ObjContabilidad.DtResultados + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(214).ToEntero > 0 Then + If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then + DdlCtaContableFondoGarantia.DataSource = ObjContabilidad.DtResultados + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 Then + If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then + DdlCtaContableCompClientes.DataSource = ObjContabilidad.DtResultados + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(212).ToEntero > 0 Then + If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then + DdlCtaContableCompAnticipos.DataSource = ObjContabilidad.DtResultados + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 Then + If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then + DdlMonedaExtranjeraClientes.DataSource = ObjContabilidad.DtResultados + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(212).ToEntero > 0 Then + If ObjContabilidad.GetCuentas(-1, "-1", 1, IdPadre:=UsuarioActual.Empresa.Funcionalidad(214).ToEntero) Then + DdlMonedaExtranjeraAnticipos.DataSource = ObjContabilidad.DtResultados + End If + End If + + ObjContabilidad.Dispose() + DdlCtaContableClientes.DataBind() + DdlCtaContableAnticipos.DataBind() + DdlCtaContableRetIVA.DataBind() + DdlCtaContableRetISR.DataBind() + DdlCtaContableFondoGarantia.DataBind() + + DdlCtaContableCompClientes.DataBind() + DdlCtaContableCompAnticipos.DataBind() + + DdlMonedaExtranjeraClientes.DataBind() + DdlMonedaExtranjeraAnticipos.DataBind() + End Sub + Private Sub CargaVendedores() + Dim dt As DataTable = GlobalDTVendedores(UsuarioActual.CveEmpresa) + Dim item As New ListItem("Seleccione", "-1") + DdlVendedor.DataSource = dt + DdlVendedorSucursal.DataSource = dt + + DdlVendedor.DataBind() + DdlVendedorSucursal.DataBind() + + DdlVendedor.Items.Insert(0, item) + DdlVendedorSucursal.Items.Insert(0, New ListItem("Seleccione", "-1")) + + + End Sub + Private Sub CargaCorporativo() + + Dim ObjCorporativo As New ClsClientes + + If ObjCorporativo.GetCorporativo(UsuarioActual.CveEmpresa, 1) Then + If ObjCorporativo.DtResultados.Rows.Count > 0 Then + Dim dt As DataTable = ObjCorporativo.DtResultados + DdlCorporativo.DataSource = dt + DdlCorporativo.DataBind() + DdlCorporativo.Items.Insert(0, New ListItem("Seleccione", "-1")) + Else + DdlCorporativo.DataSource = Nothing + End If + End If + ObjCorporativo.Dispose() + End Sub + Protected Sub CargaCuentasExistentes() + 'SELECTED VALUES + DdlCtaContableClientes.SelectedValue = IdCtaCliente + DdlCtaContableAnticipos.SelectedValue = IdCtaAnticipos + DdlCtaContableRetIVA.SelectedValue = IdCtaRetIVA + DdlCtaContableRetISR.SelectedValue = IdCtaRetISR + DdlCtaContableFondoGarantia.SelectedValue = IdCtaFondoGarantia + + DdlMonedaExtranjeraClientes.SelectedValue = IdCtaMonedaExtranjera + DdlMonedaExtranjeraAnticipos.SelectedValue = IdCtaMonedaExtranjeraAnticipos + + ActivarRegistroAutomatico() + HeedarContable.Attributes.Remove("onclick") + UpFiscalContable.Update() + End Sub + Private Function CargaDatos() As Boolean + Dim watch As New Diagnostics.Stopwatch() + watch.Start() + Dim Retorno As Boolean = False + Dim ObjClientes As New ClsClientes() + If ObjClientes.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, Estatus:=-1, TipoCliente:=-1) Then + If ObjClientes.DtResultados.Rows.Count > 0 Then + Existe = True + Retorno = True + + CargaDdlSucursalCliente() + CargaDocumentosVenta(CveCliente) + + Dim RetSC As Boolean = CargaSucursalesCliente() + Dim RetCC As Boolean = CargaCotizaciones() + CargaHistorial() + Dim RetCxC As Boolean = CargaCxC() + CargaAnticipos() + CargaPersonalAsignado() + CargaUsuariosPortal() + CargaBancos() + CargaOrdenesServiciosCliente() + CargaImpuestosLocales() + CargaCuentasContablesDdls() + CargaResponsables() + CargaCondicionesEntrega() + 'CargaClasificaciones() + CargaGridRetenciones() + ' CargaDocs() + CargaCombos() + CargaDocumentacionCliente() + 'CargaMetodosPago33() + 'CargaFormaPago33() + 'CargaComboCFDI() + If UsuarioActual.TienePermisoProceso(279) Then LnkPorcentajeMarcas.Visible = True LnkPorcentajePrecios.Visible = True - End If - - If UsuarioActual.TienePermisoProceso(261) Then LnkVerGrafica.Visible = True - - If UsuarioActual.Empresa.CvePlataforma = 3 Then ' SI ES USUARIO DE GPS. - CargaDispositivos() - Else - CargaCuentasEquipos() - End If - - CargaCuentasCaracteristicas() - - If ObjClientes.Pais = "" Then ObjClientes.Pais = "México" - - 'Campos para Modificación - LtlCliente.Text = ObjClientes.Nombre - TxtNombre.Text = ObjClientes.Nombre - TxtNombreComercial.Text = ObjClientes.NombreComercial - TxtCodigo.Text = ObjClientes.Codigo - CodigoCliente = ObjClientes.Codigo - TxtDireccion.Text = ObjClientes.Direccion - TxtNoExt.Text = ObjClientes.NoExt - TxtNoInt.Text = ObjClientes.NoInt - TxtColonia.Text = ObjClientes.Colonia - TxtLocalidad.Text = ObjClientes.Localidad - TxtCiudad.Text = ObjClientes.Ciudad - TxtEstado.Text = ObjClientes.Estado - TxtPais.Text = ObjClientes.Pais - TxtRFC.Text = ObjClientes.RFC - TxtCP.Text = ObjClientes.CP.ToString - TxtTelefono.Text = ObjClientes.Telefono - TxtContacto.Text = ObjClientes.Contacto - TxtEmail.Text = ObjClientes.Mail - TxtEmailCotizacion.Text = ObjClientes.MailCotizacion - TxtNotificar.Text = ObjClientes.NotificarA - TxtPagina.Text = ObjClientes.Pagina - TxtGiro.Text = ObjClientes.Giro - DdlPrecioLista.SelectedValue = ObjClientes.CvePrecioLista.ToString - TxtCC.Text = ObjClientes.NotificarA + End If + + If UsuarioActual.TienePermisoProceso(261) Then LnkVerGrafica.Visible = True + + If UsuarioActual.Empresa.CvePlataforma = 3 Then ' SI ES USUARIO DE GPS. + CargaDispositivos() + Else + CargaCuentasEquipos() + End If + + CargaCuentasCaracteristicas() + + If ObjClientes.Pais = "" Then ObjClientes.Pais = "México" + + 'Campos para Modificación + LtlCliente.Text = ObjClientes.Nombre + TxtNombre.Text = ObjClientes.Nombre + TxtNombreComercial.Text = ObjClientes.NombreComercial + TxtCodigo.Text = ObjClientes.Codigo + CodigoCliente = ObjClientes.Codigo + TxtDireccion.Text = ObjClientes.Direccion + TxtNoExt.Text = ObjClientes.NoExt + TxtNoInt.Text = ObjClientes.NoInt + TxtColonia.Text = ObjClientes.Colonia + TxtLocalidad.Text = ObjClientes.Localidad + TxtCiudad.Text = ObjClientes.Ciudad + TxtEstado.Text = ObjClientes.Estado + TxtPais.Text = ObjClientes.Pais + TxtRFC.Text = ObjClientes.RFC + TxtCP.Text = ObjClientes.CP.ToString + TxtTelefono.Text = ObjClientes.Telefono + TxtContacto.Text = ObjClientes.Contacto + TxtEmail.Text = ObjClientes.Mail + TxtEmailCotizacion.Text = ObjClientes.MailCotizacion + TxtNotificar.Text = ObjClientes.NotificarA + TxtPagina.Text = ObjClientes.Pagina + TxtGiro.Text = ObjClientes.Giro + DdlPrecioLista.SelectedValue = ObjClientes.CvePrecioLista.ToString + TxtCC.Text = ObjClientes.NotificarA ChkMail.Checked = ObjClientes.EnviarFactura - DdlTipoRetencion.SelectedValueExist(ObjClientes.DtResultados(0)("CveTipoRetencion").ToString) - DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty) - TxtRetIVA.Text = ObjClientes.RetIVA.ToString - TxtRetISR.Text = ObjClientes.RetISR.ToString - ChkRetIVAFletesAcarreos.Checked = ObjClientes.RetieneIVAFletes - DdlSubProyecto.SelectedValue = ObjClientes.CveSubProyecto.ToString - DdlZonaHoraria.SelectedValueExist(ObjClientes.DtResultados(0)("CveZonaHoraria").ToString) - ChkEstado.Checked = ObjClientes.Estatus - EstatusAnteriorCliente = ObjClientes.Estatus - LblFechaCaptura.Text = ObjClientes.FechaIng.ToShortDateString - LblUsuarioCapturo.Text = ObjClientes.Usuario - TxtNombreCorto.Text = ObjClientes.NombreCorto - DdlVendedor.SelectedValueExist(ObjClientes.Vendedor.ToString) - 'TxtVendedor.Text = ObjClientes.Vendedor - TxtPlazoCobranza.Text = ObjClientes.PlazoCobranza.ToString - TxtPlazoCobranzaRemision.Text = ObjClientes.PlazoCobranzaRemision.ToString - ' TxtSucursalCliente.Text = ObjClientes.Sucursal - 'TxtRecepcionPago.Text = ObjClientes.RecepcionPagos - DdlTipoPago.SelectedValueExist(ObjClientes.TipoPago) - 'TxtCuentaContable.Text = ObjClientes.CuentaContable - TxtExtension.Text = ObjClientes.TelefonoExtension - TxtTelefonoOtro.Text = ObjClientes.TelefonoOtros - IdCtaCliente = ObjClientes.IdCtaContClientes.ToString - IdCtaAnticipos = ObjClientes.IdCtaContAnticipos.ToString - IdCtaRetIVA = ObjClientes.IdCtaContRetIVA.ToString - IdCtaRetISR = ObjClientes.IdCtaContRetISR.ToString - IdCtaFondoGarantia = ObjClientes.IdCtaContFondoGarantia.ToString - TxtConvenioCIE.Text = ObjClientes.ConvenioCIE - TxtNumCtaPago.Text = ObjClientes.NumCtaPago - DdlMetodoPago.SelectedValue = ObjClientes.CveMetodoPago.ToString - TxtFormaFacturacion.Text = ObjClientes.FormaFacturacion - ChkPermiteCredito.Checked = ObjClientes.PermiteCredito - TxtLimiteCredito.Text = ObjClientes.LimiteCredito.FormatoNumero - ChkAplicaFEMSA.Checked = ObjClientes.AplicaFEMSA - TxtFEMSA_NumSociedad.Text = ObjClientes.FEMSA_NumSociedad - TxtFEMSA_NumProveedor.Text = ObjClientes.FEMSA_NumProveedor - TxtFEMA_Mail.Text = ObjClientes.FEMSA_Mail - ChkAplicaDetallista.Checked = ObjClientes.AplicaDetallista - TxtDet_GLNComprador.Text = ObjClientes.Detallista_GLNComprador - TxtDet_Departamento.Text = ObjClientes.Detallista_Departamento - TxtDet_GLNVendedor.Text = ObjClientes.Detallista_GLNVendedor - TxtDet_NumProveedor.Text = ObjClientes.Detallista_NumProveedor - HplAbonarMasivo.NavigateUrl = String.Format("/Ventas/ClientesAbonar.aspx?CveCliente={0}&CveMoneda={1}", CveCliente, -1) - DdlResponsable.SelectedValueExist(ObjClientes.CveUsuarioResponsable) - DdlClasificacion.SelectedValueExist(ObjClientes.CveClasificacion) - DdlCondicionesEntrega.SelectedValueExist(ObjClientes.CveCondicionEntrega) - DdlTipoCliente.SelectedValueExist(ObjClientes.TipoCliente) - TxtCobranzaContacto.Text = ObjClientes.CobranzaContacto - TxtCobranzaTelefono.Text = ObjClientes.CobranzaTelefono - ChkRequiereOC.Checked = ObjClientes.RequiereOC - ChkEsDistribuidor.Checked = Boolean.Parse(ObjClientes.DtResultados(0)("EsDistribuidor").ToString) - CobranzaTelefono = ObjClientes.CobranzaTelefono - If CobranzaTelefono.Length = 10 Then - BtnCobranzaSMS.ToolTip = $"El mensaje SMS será enviado al número celular {CobranzaTelefono}
    con #referencia ""{If(UsuarioActual.CveEmpresa = 4, TxtNombreCorto.Text, CodigoCliente)}""" - End If - - TxtCobranzaExt.Text = ObjClientes.CobranzaNoExt - TxtCobranzaCorreo.Text = ObjClientes.CobranzaCorreo - - TxtPortalFacturacion.Text = ObjClientes.PortalFacturacion - TxtDiasEspecifico.Text = ObjClientes.DiasEspecificos - TxtDocumentacion.Text = ObjClientes.Documentacion - TxtUsuarioPortalFacturacion.Text = ObjClientes.UsuarioPortal - TxtContraseñaPortalFacturacion.Text = ObjClientes.ContraseñaPortal - - IdCtaCompCliente = ObjClientes.IdCtaContComplementaria.ToString - IdCtaCompAnticipo = ObjClientes.IdCtaContCompAnticipos.ToString - - IdCtaMonedaExtranjera = ObjClientes.IdCtaMonedaExtranjera.ToString - IdCtaMonedaExtranjeraAnticipos = ObjClientes.IdCtaMonedaExtranjeraAnticipos.ToString - - ChkMuestraNombre.Checked = ObjClientes.ImprimeNombreSucursal - - - DdlUsoCFDI.SelectedValueExist(ObjClientes.CveUsoCFDI.ToString) - DdlMetodoPago33.SelectedValueExist(ObjClientes.CveMetodoPago33.ToString) - DdlFormaPago33.SelectedValueExist(ObjClientes.CveFormaPago33.ToString) - - ChkDesglosarIEPS.Checked = ObjClientes.DesglosaIEPS - DdlCorporativo.SelectedValueExist(ObjClientes.CveClienteCorporativo.ToString) - ChkCargoUsado.Checked = ObjClientes.CargoUsados - ChkBonificacionUsado.Checked = ObjClientes.BonificacionUsado - 'COMERCIO EXTERIOR - ChkAplicaComercioExterior.Checked = ObjClientes.AplicaComercioExterior - DdlTipoOperacion.SelectedValueExist(ObjClientes.CveTipoOperacion) - DdlClavePedimento.SelectedValueExist(ObjClientes.CvePedimento) - DdlIncoterm.SelectedValueExist(ObjClientes.CveIncoterm) - - 'PERSONA FISICA - If ObjClientes.RFC.Length = 13 Then - TxtApellidoPaternoPF.Text = ObjClientes.ApellidoPaterno - TxtApellidoMaternoPF.Text = ObjClientes.ApellidoMaterno - TxtNombrePF.Text = ObjClientes.Nombres - - TxtApellidoPaterno.Text = ObjClientes.ApellidoPaterno - TxtApellidoMaterno.Text = ObjClientes.ApellidoMaterno - TxtNombres.Text = ObjClientes.Nombres - - If ObjClientes.Nombres <> "" AndAlso ObjClientes.ApellidoPaterno <> "" AndAlso ObjClientes.ApellidoMaterno <> "" Then - DivPersonaFisica.Visible = True - DivRazonSocial.Visible = False - End If - End If - - HDLT.Value = If(ObjClientes.DtResultados(0)("LT").ToString = "", "0", ObjClientes.DtResultados(0)("LT").ToString) - HDLG.Value = If(ObjClientes.DtResultados(0)("LG").ToString = "", "0", ObjClientes.DtResultados(0)("LG").ToString) - - DdlPais.SelectedValueExist(ObjClientes.CvePais) - CargaEstado() - - If DdlPais.SelectedValue.Contiene("151", "66", "40") Then - DdlEstado.Visible = True - DdlEstado.SelectedValueExist(ObjClientes.CveEstado) - - If DdlPais.SelectedValue.Contiene("151") Then - - CargaMunicipio() - DdlMunicipio.Visible = True - DdlMunicipio.SelectedValueExist(ObjClientes.CveMunicipio) - - CargaColonia() - DdlColonia.Visible = True - DdlColonia.SelectedValueExist(ObjClientes.CveColonia) - Else - DdlMunicipio.Visible = False - TxtComExtMunicipio.Visible = True - TxtComExtMunicipio.Text = ObjClientes.ComExtMunicipio - - DdlColonia.Visible = False - TxtComExtColonia.Visible = True - TxtComExtColonia.Text = ObjClientes.ComExtColonia - End If - Else - DdlEstado.Visible = False - TxtComExtEstado.Visible = True - TxtComExtEstado.Text = ObjClientes.ComExtEstado - - DdlMunicipio.Visible = False - TxtComExtMunicipio.Visible = True - TxtComExtMunicipio.Text = ObjClientes.ComExtMunicipio - - DdlColonia.Visible = False - TxtComExtColonia.Visible = True - TxtComExtColonia.Text = ObjClientes.ComExtColonia - End If - - DdlMotivoTraslado.SelectedValueExist(ObjClientes.CveMotivoTraslado) - TxtNumRegIdTrib.Text = ObjClientes.NumRegIdTrib - - - 'If ObjClientes.CveUsoCFDI > 0 Then DdlUsoCFDI.Items.RemoveAt(0) - 'If ObjClientes.CveMetodoPago33 > 0 Then DdlMetodoPago33.Items.RemoveAt(0) - 'If ObjClientes.CveFormaPago33 > 0 Then DdlFormaPago33.Items.RemoveAt(0) - - 'DIAS DE PAGO - If ObjClientes.RecepcionPagos <> "" AndAlso ObjClientes.RecepcionPagos.Length = 11 Then - Dim array As String() = ObjClientes.RecepcionPagos.Split(New Char() {"-"c}) - If array(0) = "1" Then ChkLunes.Checked = True - If array(1) = "1" Then ChkMartes.Checked = True - If array(2) = "1" Then ChkMiercoles.Checked = True - If array(3) = "1" Then ChkJueves.Checked = True - If array(4) = "1" Then ChkViernes.Checked = True - If array(5) = "1" Then ChkSabado.Checked = True - End If - - 'DIAS DE REVSION - If ObjClientes.DiasRevision <> "" AndAlso ObjClientes.DiasRevision.Length = 11 Then - Dim array As String() = ObjClientes.DiasRevision.Split(New Char() {"-"c}) - If array(0) = "1" Then ChkRevLunes.Checked = True - If array(1) = "1" Then ChkRevMartes.Checked = True - If array(2) = "1" Then ChkRevMiercoles.Checked = True - If array(3) = "1" Then ChkRevJueves.Checked = True - If array(4) = "1" Then ChkRevViernes.Checked = True - If array(5) = "1" Then ChkRevSabado.Checked = True - End If - - - 'Horario - TxtHorario.Text = ObjClientes.Horario - 'If ObjClientes.Horario <> "" Then - ' Dim arrayHorario As String() = ObjClientes.Horario.Split(New Char() {"|"c}) - ' If arrayHorario.Count = 1 Then - ' TxtHorario1.Text = arrayHorario(0) - ' End If - ' If arrayHorario.Count = 2 Then - ' TxtHorario2.Text = arrayHorario(1) - ' End If - 'End If - - TxtObsDiasRevision.Text = ObjClientes.ObservacionRevision - TxtReferenciaFiscal.Text = ObjClientes.ReferenciaFiscal - TxtCelular.Text = ObjClientes.Celular - TxtExtOtro.Text = ObjClientes.ExtOtros - - - If ObjClientes.IdCtaContClientes > 0 Then DdlCtaContableClientes.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContClientes), ObjClientes.IdCtaContClientes.ToString)) : DdlCtaContableClientes.SelectedValue = ObjClientes.IdCtaContClientes.ToString - If ObjClientes.IdCtaContAnticipos > 0 Then - DdlCtaContableAnticipos.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContAnticipos), ObjClientes.IdCtaContAnticipos.ToString)) - DdlCtaContableAnticipos.SelectedValue = ObjClientes.IdCtaContAnticipos.ToString - End If - If ObjClientes.IdCtaContRetISR > 0 Then DdlCtaContableRetISR.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContRetISR), ObjClientes.IdCtaContRetISR.ToString)) : DdlCtaContableRetISR.SelectedValue = ObjClientes.IdCtaContRetISR.ToString - If ObjClientes.IdCtaContRetIVA > 0 Then DdlCtaContableRetIVA.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContRetIVA), ObjClientes.IdCtaContRetIVA.ToString)) : DdlCtaContableRetIVA.SelectedValue = ObjClientes.IdCtaContRetIVA.ToString - If ObjClientes.IdCtaContFondoGarantia > 0 Then DdlCtaContableFondoGarantia.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContFondoGarantia), ObjClientes.IdCtaContFondoGarantia.ToString)) : DdlCtaContableFondoGarantia.SelectedValue = ObjClientes.IdCtaContFondoGarantia.ToString - - - If ObjClientes.IdCtaContComplementaria > 0 Then DdlCtaContableCompClientes.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContComplementaria), ObjClientes.IdCtaContComplementaria.ToString)) : DdlCtaContableCompClientes.SelectedValue = ObjClientes.IdCtaContComplementaria.ToString - If ObjClientes.IdCtaContCompAnticipos > 0 Then DdlCtaContableCompAnticipos.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContCompAnticipos), ObjClientes.IdCtaContCompAnticipos.ToString)) : DdlCtaContableCompAnticipos.SelectedValue = ObjClientes.IdCtaContCompAnticipos.ToString - - If ObjClientes.IdCtaMonedaExtranjera > 0 Then DdlMonedaExtranjeraClientes.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaMonedaExtranjera), ObjClientes.IdCtaMonedaExtranjera.ToString)) : DdlMonedaExtranjeraClientes.SelectedValue = ObjClientes.IdCtaMonedaExtranjera.ToString - If ObjClientes.IdCtaMonedaExtranjeraAnticipos > 0 Then DdlMonedaExtranjeraAnticipos.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaMonedaExtranjeraAnticipos), ObjClientes.IdCtaMonedaExtranjeraAnticipos.ToString)) : DdlMonedaExtranjeraAnticipos.SelectedValue = ObjClientes.IdCtaMonedaExtranjeraAnticipos.ToString - ActivarRegistroAutomatico() - - '7eleven - TxtProveedor.Text = ObjClientes.SevenEleven_NumProveedor - - 'FORD - TxtFordGSDB.Text = ObjClientes.Ford_GSDB - ChkAplicaFord.Checked = ObjClientes.AplicaFord - - If TxtEmail.Text <> "" Then - LbEnviarActivacionPortal.Enabled = True - LbEnviarActivacionPortal.Visible = True - LblActivacionPortal.Visible = False - LblUsuarioPortalCliente.Text = TxtEmail.Text - - LblUsuarioPortalCliente.Attributes("style") = "font-weight: bold;" - - ElseIf TxtEmail.Text <> "" And UsuarioActual.Empresa.CvePlataforma = 3 Then - LbEnviarActivacionPortal.Enabled = True - Else - - LblActivacionPortal.Attributes("style") = "color:red;" - LblActivacionPortal.Visible = True - LbEnviarActivacionPortal.Visible = False - LblUsuarioPortalCliente.Text = "" - End If - - If Not ObjClientes.Estatus Then - Alert("El cliente actualmente se encuentra Inactivo.", TipoMensaje.MsgAdvertencia) - End If - - CargaEventoBitacora() - - 'Ocultamos la mayoria de informacion si es no-frecuente - If ObjClientes.TipoCliente = 2 Then - TabFiscalContable.Visible = False - TabCxC.Visible = False - TabAnticipos.Visible = False - TabRetenciones.Visible = False - TabOS.Visible = False - TabComplementos.Visible = False - TabOtros.Visible = False - TabRH.Visible = False - TabCuentasEquipos.Visible = False - TabSistema.Visible = False - - DivPortletSucursales.Visible = False - DivPortletDireccionEnvio.Visible = False - DivPortletAsignaciones.Visible = False - DivPortletBitacora.Visible = False - BtnEliminar.Visible = False - - DivProtletRegistrar.Visible = True - End If - - Else - Existe = False - Alert("El Cliente Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) - BtnGuardar.Enabled = False - End If - - - - If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then ' Funcionalidad Es Distribuidor - - DivEsDistribuidor.Visible = True - TabUsados.Visible = True - DivCargoUsado.Visible = True - DivBonificacionUsado.Visible = True - CargaUsados() - + DdlTipoRetencion.SelectedValueExist(ObjClientes.DtResultados(0)("CveTipoRetencion").ToString) + DdlTipoRetencion_SelectedIndexChanged(DdlTipoRetencion, EventArgs.Empty) + TxtRetIVA.Text = ObjClientes.RetIVA.ToString + TxtRetISR.Text = ObjClientes.RetISR.ToString + ChkRetIVAFletesAcarreos.Checked = ObjClientes.RetieneIVAFletes + DdlSubProyecto.SelectedValue = ObjClientes.CveSubProyecto.ToString + DdlZonaHoraria.SelectedValueExist(ObjClientes.DtResultados(0)("CveZonaHoraria").ToString) + ChkEstado.Checked = ObjClientes.Estatus + EstatusAnteriorCliente = ObjClientes.Estatus + LblFechaCaptura.Text = ObjClientes.FechaIng.ToShortDateString + LblUsuarioCapturo.Text = ObjClientes.Usuario + TxtNombreCorto.Text = ObjClientes.NombreCorto + DdlVendedor.SelectedValueExist(ObjClientes.Vendedor.ToString) + 'TxtVendedor.Text = ObjClientes.Vendedor + TxtPlazoCobranza.Text = ObjClientes.PlazoCobranza.ToString + TxtPlazoCobranzaRemision.Text = ObjClientes.PlazoCobranzaRemision.ToString + ' TxtSucursalCliente.Text = ObjClientes.Sucursal + 'TxtRecepcionPago.Text = ObjClientes.RecepcionPagos + DdlTipoPago.SelectedValueExist(ObjClientes.TipoPago) + 'TxtCuentaContable.Text = ObjClientes.CuentaContable + TxtExtension.Text = ObjClientes.TelefonoExtension + TxtTelefonoOtro.Text = ObjClientes.TelefonoOtros + IdCtaCliente = ObjClientes.IdCtaContClientes.ToString + IdCtaAnticipos = ObjClientes.IdCtaContAnticipos.ToString + IdCtaRetIVA = ObjClientes.IdCtaContRetIVA.ToString + IdCtaRetISR = ObjClientes.IdCtaContRetISR.ToString + IdCtaFondoGarantia = ObjClientes.IdCtaContFondoGarantia.ToString + TxtConvenioCIE.Text = ObjClientes.ConvenioCIE + TxtNumCtaPago.Text = ObjClientes.NumCtaPago + DdlMetodoPago.SelectedValue = ObjClientes.CveMetodoPago.ToString + TxtFormaFacturacion.Text = ObjClientes.FormaFacturacion + ChkPermiteCredito.Checked = ObjClientes.PermiteCredito + TxtLimiteCredito.Text = ObjClientes.LimiteCredito.FormatoNumero + ChkAplicaFEMSA.Checked = ObjClientes.AplicaFEMSA + TxtFEMSA_NumSociedad.Text = ObjClientes.FEMSA_NumSociedad + TxtFEMSA_NumProveedor.Text = ObjClientes.FEMSA_NumProveedor + TxtFEMA_Mail.Text = ObjClientes.FEMSA_Mail + ChkAplicaDetallista.Checked = ObjClientes.AplicaDetallista + TxtDet_GLNComprador.Text = ObjClientes.Detallista_GLNComprador + TxtDet_Departamento.Text = ObjClientes.Detallista_Departamento + TxtDet_GLNVendedor.Text = ObjClientes.Detallista_GLNVendedor + TxtDet_NumProveedor.Text = ObjClientes.Detallista_NumProveedor + HplAbonarMasivo.NavigateUrl = String.Format("/Ventas/ClientesAbonar.aspx?CveCliente={0}&CveMoneda={1}", CveCliente, -1) + DdlResponsable.SelectedValueExist(ObjClientes.CveUsuarioResponsable) + DdlClasificacion.SelectedValueExist(ObjClientes.CveClasificacion) + DdlCondicionesEntrega.SelectedValueExist(ObjClientes.CveCondicionEntrega) + DdlTipoCliente.SelectedValueExist(ObjClientes.TipoCliente) + TxtCobranzaContacto.Text = ObjClientes.CobranzaContacto + TxtCobranzaTelefono.Text = ObjClientes.CobranzaTelefono + ChkRequiereOC.Checked = ObjClientes.RequiereOC + ChkEsDistribuidor.Checked = Boolean.Parse(ObjClientes.DtResultados(0)("EsDistribuidor").ToString) + CobranzaTelefono = ObjClientes.CobranzaTelefono + If CobranzaTelefono.Length = 10 Then + BtnCobranzaSMS.ToolTip = $"El mensaje SMS será enviado al número celular {CobranzaTelefono}
    con #referencia ""{If(UsuarioActual.CveEmpresa = 4, TxtNombreCorto.Text, CodigoCliente)}""" + End If + + TxtCobranzaExt.Text = ObjClientes.CobranzaNoExt + TxtCobranzaCorreo.Text = ObjClientes.CobranzaCorreo + + TxtPortalFacturacion.Text = ObjClientes.PortalFacturacion + TxtDiasEspecifico.Text = ObjClientes.DiasEspecificos + TxtDocumentacion.Text = ObjClientes.Documentacion + TxtUsuarioPortalFacturacion.Text = ObjClientes.UsuarioPortal + TxtContraseñaPortalFacturacion.Text = ObjClientes.ContraseñaPortal + + IdCtaCompCliente = ObjClientes.IdCtaContComplementaria.ToString + IdCtaCompAnticipo = ObjClientes.IdCtaContCompAnticipos.ToString + + IdCtaMonedaExtranjera = ObjClientes.IdCtaMonedaExtranjera.ToString + IdCtaMonedaExtranjeraAnticipos = ObjClientes.IdCtaMonedaExtranjeraAnticipos.ToString + + ChkMuestraNombre.Checked = ObjClientes.ImprimeNombreSucursal + + + DdlUsoCFDI.SelectedValueExist(ObjClientes.CveUsoCFDI.ToString) + DdlMetodoPago33.SelectedValueExist(ObjClientes.CveMetodoPago33.ToString) + DdlFormaPago33.SelectedValueExist(ObjClientes.CveFormaPago33.ToString) + + ChkDesglosarIEPS.Checked = ObjClientes.DesglosaIEPS + DdlCorporativo.SelectedValueExist(ObjClientes.CveClienteCorporativo.ToString) + ChkCargoUsado.Checked = ObjClientes.CargoUsados + ChkBonificacionUsado.Checked = ObjClientes.BonificacionUsado + 'COMERCIO EXTERIOR + ChkAplicaComercioExterior.Checked = ObjClientes.AplicaComercioExterior + DdlTipoOperacion.SelectedValueExist(ObjClientes.CveTipoOperacion) + DdlClavePedimento.SelectedValueExist(ObjClientes.CvePedimento) + DdlIncoterm.SelectedValueExist(ObjClientes.CveIncoterm) + + 'PERSONA FISICA + If ObjClientes.RFC.Length = 13 Then + TxtApellidoPaternoPF.Text = ObjClientes.ApellidoPaterno + TxtApellidoMaternoPF.Text = ObjClientes.ApellidoMaterno + TxtNombrePF.Text = ObjClientes.Nombres + + TxtApellidoPaterno.Text = ObjClientes.ApellidoPaterno + TxtApellidoMaterno.Text = ObjClientes.ApellidoMaterno + TxtNombres.Text = ObjClientes.Nombres + + If ObjClientes.Nombres <> "" AndAlso ObjClientes.ApellidoPaterno <> "" AndAlso ObjClientes.ApellidoMaterno <> "" Then + DivPersonaFisica.Visible = True + DivRazonSocial.Visible = False + End If + End If + + HDLT.Value = If(ObjClientes.DtResultados(0)("LT").ToString = "", "0", ObjClientes.DtResultados(0)("LT").ToString) + HDLG.Value = If(ObjClientes.DtResultados(0)("LG").ToString = "", "0", ObjClientes.DtResultados(0)("LG").ToString) + + DdlPais.SelectedValueExist(ObjClientes.CvePais) + CargaEstado() + + If DdlPais.SelectedValue.Contiene("151", "66", "40") Then + DdlEstado.Visible = True + DdlEstado.SelectedValueExist(ObjClientes.CveEstado) + + If DdlPais.SelectedValue.Contiene("151") Then + + CargaMunicipio() + DdlMunicipio.Visible = True + DdlMunicipio.SelectedValueExist(ObjClientes.CveMunicipio) + + CargaColonia() + DdlColonia.Visible = True + DdlColonia.SelectedValueExist(ObjClientes.CveColonia) + Else + DdlMunicipio.Visible = False + TxtComExtMunicipio.Visible = True + TxtComExtMunicipio.Text = ObjClientes.ComExtMunicipio + + DdlColonia.Visible = False + TxtComExtColonia.Visible = True + TxtComExtColonia.Text = ObjClientes.ComExtColonia + End If + Else + DdlEstado.Visible = False + TxtComExtEstado.Visible = True + TxtComExtEstado.Text = ObjClientes.ComExtEstado + + DdlMunicipio.Visible = False + TxtComExtMunicipio.Visible = True + TxtComExtMunicipio.Text = ObjClientes.ComExtMunicipio + + DdlColonia.Visible = False + TxtComExtColonia.Visible = True + TxtComExtColonia.Text = ObjClientes.ComExtColonia + End If + + DdlMotivoTraslado.SelectedValueExist(ObjClientes.CveMotivoTraslado) + TxtNumRegIdTrib.Text = ObjClientes.NumRegIdTrib + + + 'If ObjClientes.CveUsoCFDI > 0 Then DdlUsoCFDI.Items.RemoveAt(0) + 'If ObjClientes.CveMetodoPago33 > 0 Then DdlMetodoPago33.Items.RemoveAt(0) + 'If ObjClientes.CveFormaPago33 > 0 Then DdlFormaPago33.Items.RemoveAt(0) + + 'DIAS DE PAGO + If ObjClientes.RecepcionPagos <> "" AndAlso ObjClientes.RecepcionPagos.Length = 11 Then + Dim array As String() = ObjClientes.RecepcionPagos.Split(New Char() {"-"c}) + If array(0) = "1" Then ChkLunes.Checked = True + If array(1) = "1" Then ChkMartes.Checked = True + If array(2) = "1" Then ChkMiercoles.Checked = True + If array(3) = "1" Then ChkJueves.Checked = True + If array(4) = "1" Then ChkViernes.Checked = True + If array(5) = "1" Then ChkSabado.Checked = True + End If + + 'DIAS DE REVSION + If ObjClientes.DiasRevision <> "" AndAlso ObjClientes.DiasRevision.Length = 11 Then + Dim array As String() = ObjClientes.DiasRevision.Split(New Char() {"-"c}) + If array(0) = "1" Then ChkRevLunes.Checked = True + If array(1) = "1" Then ChkRevMartes.Checked = True + If array(2) = "1" Then ChkRevMiercoles.Checked = True + If array(3) = "1" Then ChkRevJueves.Checked = True + If array(4) = "1" Then ChkRevViernes.Checked = True + If array(5) = "1" Then ChkRevSabado.Checked = True + End If + + + 'Horario + TxtHorario.Text = ObjClientes.Horario + 'If ObjClientes.Horario <> "" Then + ' Dim arrayHorario As String() = ObjClientes.Horario.Split(New Char() {"|"c}) + ' If arrayHorario.Count = 1 Then + ' TxtHorario1.Text = arrayHorario(0) + ' End If + ' If arrayHorario.Count = 2 Then + ' TxtHorario2.Text = arrayHorario(1) + ' End If + 'End If + + TxtObsDiasRevision.Text = ObjClientes.ObservacionRevision + TxtReferenciaFiscal.Text = ObjClientes.ReferenciaFiscal + TxtCelular.Text = ObjClientes.Celular + TxtExtOtro.Text = ObjClientes.ExtOtros + + + If ObjClientes.IdCtaContClientes > 0 Then DdlCtaContableClientes.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContClientes), ObjClientes.IdCtaContClientes.ToString)) : DdlCtaContableClientes.SelectedValue = ObjClientes.IdCtaContClientes.ToString + If ObjClientes.IdCtaContAnticipos > 0 Then + DdlCtaContableAnticipos.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContAnticipos), ObjClientes.IdCtaContAnticipos.ToString)) + DdlCtaContableAnticipos.SelectedValue = ObjClientes.IdCtaContAnticipos.ToString + End If + If ObjClientes.IdCtaContRetISR > 0 Then DdlCtaContableRetISR.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContRetISR), ObjClientes.IdCtaContRetISR.ToString)) : DdlCtaContableRetISR.SelectedValue = ObjClientes.IdCtaContRetISR.ToString + If ObjClientes.IdCtaContRetIVA > 0 Then DdlCtaContableRetIVA.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContRetIVA), ObjClientes.IdCtaContRetIVA.ToString)) : DdlCtaContableRetIVA.SelectedValue = ObjClientes.IdCtaContRetIVA.ToString + If ObjClientes.IdCtaContFondoGarantia > 0 Then DdlCtaContableFondoGarantia.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContFondoGarantia), ObjClientes.IdCtaContFondoGarantia.ToString)) : DdlCtaContableFondoGarantia.SelectedValue = ObjClientes.IdCtaContFondoGarantia.ToString + + + If ObjClientes.IdCtaContComplementaria > 0 Then DdlCtaContableCompClientes.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContComplementaria), ObjClientes.IdCtaContComplementaria.ToString)) : DdlCtaContableCompClientes.SelectedValue = ObjClientes.IdCtaContComplementaria.ToString + If ObjClientes.IdCtaContCompAnticipos > 0 Then DdlCtaContableCompAnticipos.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaContCompAnticipos), ObjClientes.IdCtaContCompAnticipos.ToString)) : DdlCtaContableCompAnticipos.SelectedValue = ObjClientes.IdCtaContCompAnticipos.ToString + + If ObjClientes.IdCtaMonedaExtranjera > 0 Then DdlMonedaExtranjeraClientes.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaMonedaExtranjera), ObjClientes.IdCtaMonedaExtranjera.ToString)) : DdlMonedaExtranjeraClientes.SelectedValue = ObjClientes.IdCtaMonedaExtranjera.ToString + If ObjClientes.IdCtaMonedaExtranjeraAnticipos > 0 Then DdlMonedaExtranjeraAnticipos.Items.Add(New ListItem(NombreCuenta(ObjClientes.IdCtaMonedaExtranjeraAnticipos), ObjClientes.IdCtaMonedaExtranjeraAnticipos.ToString)) : DdlMonedaExtranjeraAnticipos.SelectedValue = ObjClientes.IdCtaMonedaExtranjeraAnticipos.ToString + ActivarRegistroAutomatico() + + '7eleven + TxtProveedor.Text = ObjClientes.SevenEleven_NumProveedor + + 'FORD + TxtFordGSDB.Text = ObjClientes.Ford_GSDB + ChkAplicaFord.Checked = ObjClientes.AplicaFord + + If TxtEmail.Text <> "" Then + LbEnviarActivacionPortal.Enabled = True + LbEnviarActivacionPortal.Visible = True + LblActivacionPortal.Visible = False + LblUsuarioPortalCliente.Text = TxtEmail.Text + + LblUsuarioPortalCliente.Attributes("style") = "font-weight: bold;" + + ElseIf TxtEmail.Text <> "" And UsuarioActual.Empresa.CvePlataforma = 3 Then + LbEnviarActivacionPortal.Enabled = True + Else + + LblActivacionPortal.Attributes("style") = "color:red;" + LblActivacionPortal.Visible = True + LbEnviarActivacionPortal.Visible = False + LblUsuarioPortalCliente.Text = "" + End If + + If Not ObjClientes.Estatus Then + Alert("El cliente actualmente se encuentra Inactivo.", TipoMensaje.MsgAdvertencia) + End If + + CargaEventoBitacora() + + 'Ocultamos la mayoria de informacion si es no-frecuente + If ObjClientes.TipoCliente = 2 Then + TabFiscalContable.Visible = False + TabCxC.Visible = False + TabAnticipos.Visible = False + TabRetenciones.Visible = False + TabOS.Visible = False + TabComplementos.Visible = False + TabOtros.Visible = False + TabRH.Visible = False + TabCuentasEquipos.Visible = False + TabSistema.Visible = False + + DivPortletSucursales.Visible = False + DivPortletDireccionEnvio.Visible = False + DivPortletAsignaciones.Visible = False + DivPortletBitacora.Visible = False + BtnEliminar.Visible = False + + DivProtletRegistrar.Visible = True + End If + + Else + Existe = False + Alert("El Cliente Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) + BtnGuardar.Enabled = False + End If + + + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then ' Funcionalidad Es Distribuidor + + DivEsDistribuidor.Visible = True + TabUsados.Visible = True + DivCargoUsado.Visible = True + DivBonificacionUsado.Visible = True + CargaUsados() + If UsuarioActual.TienePermisoProceso(280) Then UPUsadosReset.Visible = True - End If - - End If - - - - End If - UpActivacionPortal.Update() - UpModalPersonaFisica.Update() - ObjClientes.Dispose() - - - watch.Stop() - 'Alert(watch.ElapsedMilliseconds.ToString) - - Return Retorno - End Function - Private Sub CargaHistorial(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1, Optional TipoDocto As String = "-1") - Dim ObjClientes As New ClsClientes() - If ObjClientes.GetHistorialVentas(CveCliente, SelectTop, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero, TipoDocto:=TipoDocto) Then - If ObjClientes.DtResultados.Rows.Count > 0 Then - 'Carga Generales - LtlCantidad.Text = ObjClientes.DtResultados.Rows(0)("CountTotal").ToString.FormatoNumero(0) - LtlTotalVendido.Text = ObjClientes.DtResultados.Rows(0)("Total").ToString.FormatoNumero(2) - LtlMinima.Text = ObjClientes.DtResultados.Rows(0)("MIN_Total").ToString.FormatoNumero(2) - LtlPromedio.Text = ObjClientes.DtResultados.Rows(0)("AVG_Total").ToString.FormatoNumero(2) - LtlMaxima.Text = ObjClientes.DtResultados.Rows(0)("MAX_Total").ToString.FormatoNumero(2) - 'Carga Grid - DTHistorialVentas = ObjClientes.DtResultados - GVHistorial.DataSource = ObjClientes.DtResultados - Else - GVHistorial.DataSource = Nothing - End If - Else - GVHistorial.DataSource = Nothing - End If - ObjClientes.Dispose() - GVHistorial.DataBind() - End Sub - Private Function CargaCxC(Optional CveClienteSucursal As Integer = -1) As Boolean - Dim Retorno As Boolean = False - Dim ObjMovtos As New ClsMovimientos() - 'Dim ObjClientesVentas As New ClsMovimientos - 'CxC Clientes - If ObjMovtos.GetCxCClienteDetalle(CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, DdlSucursalCliente.SelectedValue.ToEntero) Then - DtCxCActivas = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'", "Moneda, OrdenVencimiento, FechaVencimiento") - GvCxC.DataSource = DtCxCActivas - 'solo tomo los 10 ultimos mas el totalizador general - Dim dt As DataTable = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Hist'") + End If + + End If + + + + End If + UpActivacionPortal.Update() + UpModalPersonaFisica.Update() + ObjClientes.Dispose() + + + watch.Stop() + 'Alert(watch.ElapsedMilliseconds.ToString) + + Return Retorno + End Function + Private Sub CargaHistorial(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1, Optional TipoDocto As String = "-1") + Dim ObjClientes As New ClsClientes() + If ObjClientes.GetHistorialVentas(CveCliente, SelectTop, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero, TipoDocto:=TipoDocto) Then + If ObjClientes.DtResultados.Rows.Count > 0 Then + 'Carga Generales + LtlCantidad.Text = ObjClientes.DtResultados.Rows(0)("CountTotal").ToString.FormatoNumero(0) + LtlTotalVendido.Text = ObjClientes.DtResultados.Rows(0)("Total").ToString.FormatoNumero(2) + LtlMinima.Text = ObjClientes.DtResultados.Rows(0)("MIN_Total").ToString.FormatoNumero(2) + LtlPromedio.Text = ObjClientes.DtResultados.Rows(0)("AVG_Total").ToString.FormatoNumero(2) + LtlMaxima.Text = ObjClientes.DtResultados.Rows(0)("MAX_Total").ToString.FormatoNumero(2) + 'Carga Grid + DTHistorialVentas = ObjClientes.DtResultados + GVHistorial.DataSource = ObjClientes.DtResultados + Else + GVHistorial.DataSource = Nothing + End If + Else + GVHistorial.DataSource = Nothing + End If + ObjClientes.Dispose() + GVHistorial.DataBind() + End Sub + Private Function CargaCxC(Optional CveClienteSucursal As Integer = -1) As Boolean + Dim Retorno As Boolean = False + Dim ObjMovtos As New ClsMovimientos() + 'Dim ObjClientesVentas As New ClsMovimientos + 'CxC Clientes + If ObjMovtos.GetCxCClienteDetalle(CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, DdlSucursalCliente.SelectedValue.ToEntero) Then + DtCxCActivas = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'", "Moneda, OrdenVencimiento, FechaVencimiento") + GvCxC.DataSource = DtCxCActivas + 'solo tomo los 10 ultimos mas el totalizador general + Dim dt As DataTable = ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Hist'") DtHistorialCxC = dt - If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then - GvCxCHistorial.DataSource = dt.AsEnumerable().Take(22).CopyToDataTable() - End If - Retorno = True - Else - GvCxC.DataSource = Nothing - DtCxCActivas = Nothing - GvCxCHistorial.DataSource = Nothing - DtHistorialCxC = Nothing - End If - - - ObjMovtos.Dispose() - GvCxC.DataBind() - GvCxCHistorial.DataBind() - UpParametros.Update() - Return Retorno - End Function - Private Sub CargaAnticipos(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1) - Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) Then + If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then + GvCxCHistorial.DataSource = dt.AsEnumerable().Take(22).CopyToDataTable() + End If + Retorno = True + Else + GvCxC.DataSource = Nothing + DtCxCActivas = Nothing + GvCxCHistorial.DataSource = Nothing + DtHistorialCxC = Nothing + End If + + + ObjMovtos.Dispose() + GvCxC.DataBind() + GvCxCHistorial.DataBind() + UpParametros.Update() + Return Retorno + End Function + Private Sub CargaAnticipos(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1) + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) Then DtClientesAnticipo = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0 ") GVAnticipos.DataSource = DtClientesAnticipo DtAnticipoHistorial = ObjMovtos.DtResultados.FiltraParametros("Saldo <= 0 ") GVAnticiposHistorial.DataSource = DtAnticipoHistorial - Else - GVAnticipos.DataSource = Nothing - DtClientesAnticipo = Nothing - GVAnticiposHistorial.DataSource = Nothing - DtAnticipoHistorial = Nothing - End If - ObjMovtos.Dispose() - GVAnticipos.DataBind() - GVAnticiposHistorial.DataBind() - - If (GVAnticipos.Rows.Count > 0) Then - GVAnticipos.UseAccessibleHeader = True - GVAnticipos.HeaderRow.TableSection = TableRowSection.TableHeader - RegistraScript("OrdenarGVAnticipos();") - End If - - If (GVAnticiposHistorial.Rows.Count > 0) Then - GVAnticiposHistorial.UseAccessibleHeader = True - GVAnticiposHistorial.HeaderRow.TableSection = TableRowSection.TableHeader - RegistraScript("OrdenarGVAnticiposHistorial();") - End If - - - End Sub - Private Sub CargaOrdenesServiciosCliente() - Dim ObjOS As New ClsOS - If ObjOS.GetOrdenesServiciosCliente(CveCliente) Then - If ObjOS.DtResultados.Rows.Count > 0 Then TabOS.Visible = True - GVOSActivas.DataSource = ObjOS.DtResultados.FiltraParametros("Activa = 1") - 'GVOSNoActivas.DataSource = ObjOS.DtResultados - GVOSNoActivas.DataSource = ObjOS.DtResultados.FiltraParametros("Activa = 0") - Else - GVOSActivas.DataSource = Nothing - GVOSNoActivas.DataSource = Nothing - End If - ObjOS.Dispose() - GVOSActivas.DataBind() - GVOSNoActivas.DataBind() - End Sub - Private Sub CargaUsuariosPortal() - Dim ObjUsrs As New ClsSisUsuarios() - - - If ObjUsrs.GetUsuariosPortal(-1, CveCliente, -1) Then - Dim dtUsr As DataTable = ObjUsrs.DtResultados - - 'busco la clave del admin, si es que existe - Dim dr As DataRow = dtUsr.FiltroPrimero("Nombre = 'Admin'") - - If dr IsNot Nothing Then - HdnCveUsuarioPortalAdmin.Value = dr("CveUsuario").ToString - - If Convert.ToBoolean(dr("Estatus").ToString) Then - LblUsuarioActivo.Text = "Si" - 'divUsuariosPortal.Visible = True - HdnCveUsuarioPortalActivado.Value = "1" - trDesactivarUsuario.Visible = True - - 'DivPermisosPortal.Visible = True - End If - - End If - - If HdnCveUsuarioPortalActivado.Value.ToEntero > 0 Then - trEnviarActivacion.Visible = False - End If - - GvUsuariosPortal.DataSource = dtUsr - ViewState("DTUsuariosCliente") = ObjUsrs.DtResultados - Else - GvUsuariosPortal.DataSource = Nothing - ViewState("DTUsuariosCliente") = Nothing - End If - ObjUsrs.Dispose() - GvUsuariosPortal.DataBind() - End Sub - Public Sub CargaImpuestosLocales() - Dim ObjClientes As New ClsClientes - If ObjClientes.GetClienteImpuestosLocales(CveCliente) Then - GvImpuestosLocales.DataSource = ObjClientes.DtResultados - End If - ObjClientes.Dispose() - GvImpuestosLocales.DataBind() - End Sub - Public Sub CargaDireccionesEnvio() - Dim ObjClientes As New ClsClientes - If ObjClientes.DireccionEnvioGet(-1, CveCliente, -1) Then - GvDireccionesEnvio.DataSource = ObjClientes.DtResultados - End If - ObjClientes.Dispose() - GvDireccionesEnvio.DataBind() - UpDatos.Update() - End Sub - Public Sub CargaAFAsignados() - Dim ObjAF As New ClsAF() - If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "-1", CveCliente) Then - GvAFAsignado.DataSource = ObjAF.DtResultados - Else - GvAFAsignado.DataSource = Nothing - End If - GvAFAsignado.DataBind() - ObjAF.Dispose() - End Sub - Private Sub CargaMetodosPago33() - DdlMetodoPago33.Items.Clear() - DdlMetodoPago33.DataSource = GlobalDTVtaMetodoPago - DdlMetodoPago33.DataBind() - - DdlSucursalMetodoPago33.Items.Clear() - DdlSucursalMetodoPago33.DataSource = GlobalDTVtaMetodoPago - DdlSucursalMetodoPago33.DataBind() - - End Sub - Private Sub CargaFormaPago33() - DdlFormaPago33.Items.Clear() - DdlFormaPago33.DataSource = GlobalDTVtaFormaPago - DdlFormaPago33.DataBind() - - DdlSucursalFormaPago33.Items.Clear() - DdlSucursalFormaPago33.DataSource = GlobalDTVtaFormaPago - DdlSucursalFormaPago33.DataBind() - End Sub - Private Sub CargaComboCFDI() - DdlUsoCFDI.Items.Clear() - DdlUsoCFDI.DataSource = GlobalDTSATUsosCFDI(UsuarioActual.Empresa.EsPersonaFisica) + Else + GVAnticipos.DataSource = Nothing + DtClientesAnticipo = Nothing + GVAnticiposHistorial.DataSource = Nothing + DtAnticipoHistorial = Nothing + End If + ObjMovtos.Dispose() + GVAnticipos.DataBind() + GVAnticiposHistorial.DataBind() + + If (GVAnticipos.Rows.Count > 0) Then + GVAnticipos.UseAccessibleHeader = True + GVAnticipos.HeaderRow.TableSection = TableRowSection.TableHeader + RegistraScript("OrdenarGVAnticipos();") + End If + + If (GVAnticiposHistorial.Rows.Count > 0) Then + GVAnticiposHistorial.UseAccessibleHeader = True + GVAnticiposHistorial.HeaderRow.TableSection = TableRowSection.TableHeader + RegistraScript("OrdenarGVAnticiposHistorial();") + End If + + + End Sub + Private Sub CargaOrdenesServiciosCliente() + Dim ObjOS As New ClsOS + If ObjOS.GetOrdenesServiciosCliente(CveCliente) Then + If ObjOS.DtResultados.Rows.Count > 0 Then TabOS.Visible = True + GVOSActivas.DataSource = ObjOS.DtResultados.FiltraParametros("Activa = 1") + 'GVOSNoActivas.DataSource = ObjOS.DtResultados + GVOSNoActivas.DataSource = ObjOS.DtResultados.FiltraParametros("Activa = 0") + Else + GVOSActivas.DataSource = Nothing + GVOSNoActivas.DataSource = Nothing + End If + ObjOS.Dispose() + GVOSActivas.DataBind() + GVOSNoActivas.DataBind() + End Sub + Private Sub CargaUsuariosPortal() + Dim ObjUsrs As New ClsSisUsuarios() + + + If ObjUsrs.GetUsuariosPortal(-1, CveCliente, -1) Then + Dim dtUsr As DataTable = ObjUsrs.DtResultados + + 'busco la clave del admin, si es que existe + Dim dr As DataRow = dtUsr.FiltroPrimero("Nombre = 'Admin'") + + If dr IsNot Nothing Then + HdnCveUsuarioPortalAdmin.Value = dr("CveUsuario").ToString + + If Convert.ToBoolean(dr("Estatus").ToString) Then + LblUsuarioActivo.Text = "Si" + 'divUsuariosPortal.Visible = True + HdnCveUsuarioPortalActivado.Value = "1" + trDesactivarUsuario.Visible = True + + 'DivPermisosPortal.Visible = True + End If + + End If + + If HdnCveUsuarioPortalActivado.Value.ToEntero > 0 Then + trEnviarActivacion.Visible = False + End If + + GvUsuariosPortal.DataSource = dtUsr + ViewState("DTUsuariosCliente") = ObjUsrs.DtResultados + Else + GvUsuariosPortal.DataSource = Nothing + ViewState("DTUsuariosCliente") = Nothing + End If + ObjUsrs.Dispose() + GvUsuariosPortal.DataBind() + End Sub + Public Sub CargaImpuestosLocales() + Dim ObjClientes As New ClsClientes + If ObjClientes.GetClienteImpuestosLocales(CveCliente) Then + GvImpuestosLocales.DataSource = ObjClientes.DtResultados + End If + ObjClientes.Dispose() + GvImpuestosLocales.DataBind() + End Sub + Public Sub CargaDireccionesEnvio() + Dim ObjClientes As New ClsClientes + If ObjClientes.DireccionEnvioGet(-1, CveCliente, -1) Then + GvDireccionesEnvio.DataSource = ObjClientes.DtResultados + End If + ObjClientes.Dispose() + GvDireccionesEnvio.DataBind() + UpDatos.Update() + End Sub + Public Sub CargaAFAsignados() + Dim ObjAF As New ClsAF() + If ObjAF.GetActivosFijos(-1, UsuarioActual.CveEmpresa, "-1", "-1", -1, -1, "-1", -1, -1, -1, -1, -1, "-1", CveCliente) Then + GvAFAsignado.DataSource = ObjAF.DtResultados + Else + GvAFAsignado.DataSource = Nothing + End If + GvAFAsignado.DataBind() + ObjAF.Dispose() + End Sub + Private Sub CargaMetodosPago33() + DdlMetodoPago33.Items.Clear() + DdlMetodoPago33.DataSource = GlobalDTVtaMetodoPago + DdlMetodoPago33.DataBind() + + DdlSucursalMetodoPago33.Items.Clear() + DdlSucursalMetodoPago33.DataSource = GlobalDTVtaMetodoPago + DdlSucursalMetodoPago33.DataBind() + + End Sub + Private Sub CargaFormaPago33() + DdlFormaPago33.Items.Clear() + DdlFormaPago33.DataSource = GlobalDTVtaFormaPago + DdlFormaPago33.DataBind() + + DdlSucursalFormaPago33.Items.Clear() + DdlSucursalFormaPago33.DataSource = GlobalDTVtaFormaPago + DdlSucursalFormaPago33.DataBind() + End Sub + Private Sub CargaComboCFDI() + DdlUsoCFDI.Items.Clear() + DdlUsoCFDI.DataSource = GlobalDTSATUsosCFDI(UsuarioActual.Empresa.EsPersonaFisica) DdlUsoCFDI.DataBind() DdlUsoCFDI.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlSucursalUsoCFDI.Items.Clear() - DdlSucursalUsoCFDI.DataSource = GlobalDTSATUsosCFDI(UsuarioActual.Empresa.EsPersonaFisica) - DdlSucursalUsoCFDI.DataBind() - End Sub -#End Region - -#Region "V E R M Á S" - - Protected Sub BtnVerMasVentas_Click(sender As Object, e As EventArgs) - If BtnVerMasVentas.Text = "Ver Más" Then - CargaHistorial(-1, TipoDocto:=RblTipo.SelectedValue) - BtnVerMasVentas.Text = "Ver Menos" - Else - CargaHistorial(21, TipoDocto:=RblTipo.SelectedValue) - BtnVerMasVentas.Text = "Ver Más" - End If - End Sub - - Protected Sub BtnVerMasAnticipos_Click(sender As Object, e As EventArgs) - If BtnVerMasAnticipos.Text = "Ver Más" Then - CargaAnticipos(-1) - BtnVerMasAnticipos.Text = "Ver Menos" - Else - CargaAnticipos(21) - BtnVerMasAnticipos.Text = "Ver Más" - End If - End Sub - - Protected Sub BtnVerMasBancos_Click(sender As Object, e As EventArgs) - If BtnVerMasBancos.Text = "Ver Más" Then - CargaBancos(1000000) - BtnVerMasBancos.Text = "Ver Menos" - Else - CargaBancos(51) - BtnVerMasBancos.Text = "Ver Más" - End If + DdlSucursalUsoCFDI.Items.Clear() + DdlSucursalUsoCFDI.DataSource = GlobalDTSATUsosCFDI(UsuarioActual.Empresa.EsPersonaFisica) + DdlSucursalUsoCFDI.DataBind() + End Sub +#End Region + +#Region "V E R M Á S" + + Protected Sub BtnVerMasVentas_Click(sender As Object, e As EventArgs) + If BtnVerMasVentas.Text = "Ver Más" Then + CargaHistorial(-1, TipoDocto:=RblTipo.SelectedValue) + BtnVerMasVentas.Text = "Ver Menos" + Else + CargaHistorial(21, TipoDocto:=RblTipo.SelectedValue) + BtnVerMasVentas.Text = "Ver Más" + End If End Sub -#End Region + Protected Sub BtnVerMasAnticipos_Click(sender As Object, e As EventArgs) + If BtnVerMasAnticipos.Text = "Ver Más" Then + CargaAnticipos(-1) + BtnVerMasAnticipos.Text = "Ver Menos" + Else + CargaAnticipos(21) + BtnVerMasAnticipos.Text = "Ver Más" + End If + End Sub -#Region "B A N C O S" + Protected Sub BtnVerMasBancos_Click(sender As Object, e As EventArgs) + If BtnVerMasBancos.Text = "Ver Más" Then + CargaBancos(1000000) + BtnVerMasBancos.Text = "Ver Menos" + Else + CargaBancos(51) + BtnVerMasBancos.Text = "Ver Más" + End If + End Sub + +#End Region + +#Region "B A N C O S" 'CuentasxCobrar Activas (Pagos Recibidos) - Private Sub CargaBancos(Optional SelectTop As Integer = 51, Optional CveClienteSucursal As Integer = -1) - Dim ObjMovtos As New ClsMovimientos() - 'CxC Activas - If ObjMovtos.GetClienteAbonos(CveCliente, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero, SelectTop:=SelectTop) AndAlso ObjMovtos.DtResultados.Rows.Count > 0 Then - GvBancos.DataSource = ObjMovtos.DtResultados - DTCobrosRealizados = ObjMovtos.DtResultados - DTCobrosRealizados.Rows.Remove(DTCobrosRealizados.Rows(0)) - Else - DTCobrosRealizados = Nothing - End If - ObjMovtos.Dispose() - GvBancos.DataBind() - End Sub - - Protected Sub GvBancos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvBancos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - 'Dim HLSendMail As HtmlAnchor = DirectCast(e.Row.FindControl("HLSendMail"), HtmlAnchor) - - If e.Row.DBCampo("CveVenta") = "" Then - If e.Row.DBCampo("CveIE") <> "" Then - Dim ObjBancos As New ClsBancos - - e.Row.Cells(0).Text = String.Format("{0} - {1}", e.Row.DBCampo("Banco"), e.Row.DBCampo("NumCuenta")) - e.Row.FCLiteral("LtlFechaVenci").Text = e.Row.DBCampo("FechaDocumento").ToDate.ToShortDateString - e.Row.FCHyperLink("HplCheque").Visible = True - e.Row.FCLiteral("LtlImp").Text = e.Row.DBCampo("ImporteIE").FormatoNumero - e.Row.FCLiteral("LtlMon").Text = e.Row.DBCampo("MonedaIE") - - - 'HLSendMail.HRef = String.Format("javascript:$get('HdnCveIE').value='{0}';$get('HdnSerieFolio').value='{1}';$get('HdnFolioPago').value='{2}';$get('TxtParaMail').value='{3}';$('#ModalDivMail').modal();", e.Row.DBCampo("CveIE"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("FolioCobro"), TxtCobranzaCorreo.Text) - - If ObjBancos.GetComplementoPagos(-1, e.Row.DBCampo("CveIE").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) Then - If ObjBancos.DtResultados.Rows.Count > 0 Then - e.Row.FCHyperLink("HplXML").Visible = True : e.Row.FCHyperLink("HplXML").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CompP&EXT=xml&CveComplementoPago={0}&SerieFolio={1}&CveIE={2}", ObjBancos.DtResultados(0)("CveComplementoPago").ToString, ObjBancos.DtResultados(0)("SerieFolio").ToString, ObjBancos.DtResultados(0)("CveIE").ToString))) - e.Row.FCHyperLink("HplPDF").Visible = True : e.Row.FCHyperLink("HplPDF").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CompP&EXT=pdf&CveComplementoPago={0}&SerieFolio={1}&CveIE={2}", ObjBancos.DtResultados(0)("CveComplementoPago").ToString, ObjBancos.DtResultados(0)("SerieFolio").ToString, ObjBancos.DtResultados(0)("CveIE").ToString))) - - e.Row.FCLinkButton("LnkSendMail").Visible = True - End If - End If - - ObjBancos.Dispose() - End If - e.Row.BackColor = Drawing.Color.LightGray - End If - - If e.Row.DBCampo("CveVenta") = "" And e.Row.DBCampo("Banco") = "" Then - e.Row.Visible = False - End If - End If - End Sub - - Protected Sub LnkSendMail_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - HdnSerieFolioPago.Value = gvRow.DataKey("SerieFolioCP").ToString - TxtParaMail.Text = TxtCobranzaCorreo.Text - UpSendMail.Update() - RegistraScript("$('#ModalDivMail').modal('show');") - End Sub -#End Region - -#Region "B T N ´ S" - Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click - Dim ObjClientes As New ClsClientes() - If ObjClientes.RemoveCliente(CveCliente) Then - Alert("El Cliente se Eliminó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatClientes.aspx""") - End If - ObjClientes.Dispose() - End Sub - Protected Sub BtnSendMail_Click(sender As Object, e As System.EventArgs) Handles BtnSendMail.Click - Try - - If HdnCveVenta.Value <> "-1" AndAlso HdnFolioVenta.Value <> "-1" Then - - Dim ObjMail As New ClsSisMail() - Dim Ruta As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\" - - Dim Cuerpo As String = TxtBody.Text - Dim Asunto As String = "" - Dim TipoComprobante = "" - - If HdnTipoDocto.Value.ToString = "Ing" Then TipoComprobante = "Factura" - If HdnTipoDocto.Value.ToString = "Egs" Then TipoComprobante = "Nota de Crédito" - If HdnTipoDocto.Value.ToString = "Dev" Then TipoComprobante = "Nota de Devolución" - If HdnTipoDocto.Value.ToString = "Rem" Then TipoComprobante = "Remisión" - If HdnTipoDocto.Value.ToString = "Cot" Then TipoComprobante = "Cotización" - If HdnTipoDocto.Value.ToString = "Ant" Then TipoComprobante = "Anticipo" - - Dim DisplayName As String = "" - If UsuarioActual.CveEmpresa = 119 Then DisplayName = "Facturación Agroquímicos JAM" - - Dim ObjVenta As New ClsVentas - Dim Dr As DataRow = Nothing - If ObjVenta.GetVenta(HdnCveVenta.Value.ToEntero, UsuarioActual.CveEmpresa) Then - If ObjVenta.DtResultados.Rows.Count > 0 Then - Dr = ObjVenta.DtResultados.Rows(0) - End If - End If - ObjVenta.Dispose() - - If UsuarioActual.Empresa.PlantillaMailVenta.Trim.Length > 0 Then - Cuerpo = UsuarioActual.Empresa.PlantillaMailVenta - Cuerpo = Cuerpo.Replace("{""NombreEmpresa""}", UsuarioActual.Empresa.Empresa) - Cuerpo = Cuerpo.Replace("{""NombreCliente""}", LtlCliente.Text.Trim) - Cuerpo = Cuerpo.Replace("{""TipoDocumento""}", TipoComprobante) - Cuerpo = Cuerpo.Replace("{""SerieFolio""}", HdnSerieFolio.Value.ToString) - If Dr IsNot Nothing Then - Cuerpo = Cuerpo.Replace("{""Fecha""}", Dr("Fecha").ToString.ToDate.ToShortDateString) - Cuerpo = Cuerpo.Replace("{""Total""}", Dr("Total").ToString.FormatoNumero) - Cuerpo = Cuerpo.Replace("{""FechaVencimiento""}", Dr("FechaVencimiento").ToString.ToDate.ToShortDateString) - End If - End If - - - If UsuarioActual.Empresa.AsuntoPlantillaMailVenta.Trim.Length > 0 Then - Asunto = UsuarioActual.Empresa.AsuntoPlantillaMailVenta - Asunto = Asunto.Replace("{""TipoDocumento""}", TipoComprobante) - Asunto = Asunto.Replace("{""Sucursal""}", HdnSubProyecto.Value.ToString) - Asunto = Asunto.Replace("{""SerieFolio""}", HdnSerieFolio.Value.ToString) - End If - - If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso HdnTipoDocto.Value.Contiene("Ing", "Egs", "Ant", "Dev") Then - If File.Exists($"{Ruta}PDF\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.pdf") AndAlso File.Exists($"{Ruta}XML\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.xml") Then - Dim PDF As String = $"{Ruta}PDF\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.pdf" - Dim XML As String = $"{Ruta}XML\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.xml" - - Dim ResultadoMail As Integer = 0 - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = XML}) - - 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then - If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, Asunto, Cuerpo, TxtCC.Text.Trim, LSRutasMail, Displayname:=DisplayName) Then - ResultadoMail = 1 - TxtCC.Text = "" - TxtBody.Text = "" - RegistraScript("$('#ModalDivMail').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - CargaHistorial() - 'UpnHistorial.Update() - Else - ResultadoMail = 3 - Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) - End If - - Dim ObjVentas As New ClsVentas - ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta.Value.ToEntero) - ObjVentas.Dispose() - Else - Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) - End If - ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" AndAlso HdnTipoDocto.Value.Contiene("Ing", "Egs", "Ant", "Dev") Then - If File.Exists(Ruta & "PDF\" & HdnFolioVenta.Value & ".pdf") Then - Dim PDF As String = Ruta & "PDF\" & HdnFolioVenta.Value & ".pdf" - - Dim ResultadoMail As Integer = 0 - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) - - - 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then - If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, Asunto, Cuerpo, TxtCC.Text.Trim, LSRutasMail) Then - ResultadoMail = 1 - TxtCC.Text = "" - TxtBody.Text = "" - RegistraScript("$('#ModalDivMail').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - CargaHistorial() - UpnHistorial.Update() - Else - ResultadoMail = 3 - End If - - Dim ObjVentas As New ClsVentas - ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta.Value.ToEntero) - ObjVentas.Dispose() - Else - Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) - End If - ElseIf HdnTipoDocto.Value = "Cot" Then - If File.Exists($"{Ruta}PDF\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.pdf") Then - Dim PDF As String = $"{Ruta}PDF\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.pdf" - - Dim ResultadoMail As Integer = 0 - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) - - 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then - If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, Asunto, Cuerpo, TxtCC.Text.Trim, LSRutasMail) Then - ResultadoMail = 1 - TxtCC.Text = "" - TxtBody.Text = "" - RegistraScript("$('#ModalDivMail').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - CargaHistorial() - UpnHistorial.Update() - Else - ResultadoMail = 3 - End If - - Dim ObjVentas As New ClsVentas - ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta.Value.ToEntero) - ObjVentas.Dispose() - Else - Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) - End If - End If - - 'End If - 'ObjEmprea.Dispose() - ElseIf HdnSerieFolioPago.Value <> "-1" Then - - Dim ObjMail As New ClsSisMail() - Dim RutaXML As String = String.Format("{0}XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, HdnSerieFolioPago.Value) - Dim RutaPDF As String = String.Format("{0}PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, HdnSerieFolioPago.Value) - - Dim Cuerpo As String = "Se hace entrega del comprobante de pago" - Dim Asunto As String = "Entrega de comprobante de pago" - - If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then - - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF}) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML}) - - If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, Asunto, Cuerpo, TxtCC.Text.Trim, LSRutasMail) Then - TxtCC.Text = "" - RegistraScript("$('#ModalDivMail').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - End If - Else - Alert("No se encontraron los archivos para enviar.", TipoMensaje.MsgAdvertencia) - End If - Else - Alert("No se seleccionó ninguna factura para envíar.", TipoMensaje.MsgAdvertencia) - End If - Catch ex As Exception - OnError("Ocurrió error al mandar MAIL", ex) - Dim ObjVentas As New ClsVentas - ObjVentas.UpdateVentaMail(3, HdnCveVenta.Value.ToEntero) - ObjVentas.Dispose() - End Try - End Sub - Protected Sub BtnAbonar_Click(sender As Object, e As System.EventArgs) Handles BtnAbonar.Click - Dim ObjMovtos As New ClsMovimientos() - - - If ObjMovtos.AddMovimiento(2, "Cli", CveCliente.ToString, HdnCveVentaAbono.Value, 1, 0, TxtCantidad.Text.Trim.ToDouble, Now, TxtFechaPago.Text.ToDate, TxtReferencia.Text.Trim, DdlCtaContableClientes.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("El abono se guardó correctamente", TipoMensaje.MsgInformacion, "$get(""DivAddPago"").style.display=""none"";") - CargaCxC() - TxtCantidad.Text = "" - TxtReferencia.Text = "" - - 'UpAbono.Update() - UPPUsuarios.Update() - End If - ObjMovtos.Dispose() - AbonaaCuenta() - End Sub - - Private Function AsignaCuentasAutomaticas(ObjClientes As ClsClientes) As Boolean - Dim IdCtaContableClientes As Integer = UsuarioActual.Empresa.Funcionalidad(246).ToEntero - Dim IdCtaContableAnticipos As Integer = UsuarioActual.Empresa.Funcionalidad(319).ToEntero - Dim IdCtaContableComplementaria As Integer = UsuarioActual.Empresa.Funcionalidad(320).ToEntero - Dim IdCtaContMonedaExtranjera As Integer = UsuarioActual.Empresa.Funcionalidad(331).ToEntero - Dim IdCtaContMonedaExtranjeraAnticipos As Integer = UsuarioActual.Empresa.Funcionalidad(332).ToEntero - Dim IdCtaContCompAnticipos As Integer = UsuarioActual.Empresa.Funcionalidad(333).ToEntero - - If Not ObjClientes.VincularCuentasContables(IdCtaContableClientes, IdCtaContableAnticipos, 0, 0, CveCliente, IdCtaContableComplementaria, IdCtaContMonedaExtranjera, IdCtaContMonedaExtranjeraAnticipos, IdCtaContCompAnticipos) Then - Return False - End If - Return True - End Function - - Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click - If UsuarioActual.CveUsuario = 1465 And TxtCodigo.Text.Trim = "" Then - Alert("El cliente no se puede registrar sin ingresar un Código.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If ChkAplicaComercioExterior.Checked Then - If Not DdlTipoOperacion.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un tipo de operacion para comercio exterior.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlClavePedimento.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar una clave de pedimento para comercio exterior.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlIncoterm.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un incoterm para comercio exterior.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlPais.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un pais para comercio exterior.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlPais.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un pais para comercio exterior.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If (Not DdlEstado.SelectedValue.ToEntero > 0 And DdlEstado.Visible) Or (Not DdlEstado.Visible And TxtComExtEstado.Text = "") Then - Alert("Tiene que seleccionar un estado para comercio exterior.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If DdlPais.SelectedValue.ToEntero = 151 Then - If Not DdlMunicipio.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar un municipio para comercio exterior si el pais es mexico.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - If Not DdlColonia.SelectedValue.ToEntero > 0 Then - Alert("Tiene que seleccionar una colonia para comercio exterior si el pais es mexico.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - End If - - End If - - 'CargaSucursal() - 'If UsuarioActual.TienePermisoProceso(170) AndAlso TxtCodigo.Text.Trim = "" Then - ' Alert("Es necesario ingresar un Código", TipoMensaje.MsgAdvertencia) - ' Exit Sub - 'End If - - 'Dim rowcodigo As DataTable = GlobalDTCliente.FiltraParametros(String.Format("Codigo='{0}' AND CveEmpresa={1} ", TxtCodigo.Text.Trim, UsuarioActual.CveEmpresa)) - 'If (Not IsNothing(rowcodigo)) AndAlso (rowcodigo.Rows.Count > 0) AndAlso (rowcodigo.Rows(0)("CveCliente").ToString.ToEntero <> CveCliente) Then - ' Alert(String.Format("ya existe un Cliente Con este Codigo '{0}'", TxtCodigo.Text.Trim), TipoMensaje.MsgAdvertencia) - ' Exit Sub - 'End If - Dim ObjClientes As New ClsClientes() - Dim objDoc As New ClsEdocumentacion(ObjClientes.IniciaTransacSQL()) - Dim MsgCuentaContable As String = "" - Dim ErrorProceso As Boolean = False - - 'Dias de pago - Dim SBDiasPago As New StringBuilder() - Dim DiasPago As String = "" - If ChkLunes.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") - If ChkMartes.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") - If ChkMiercoles.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") - If ChkJueves.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") - If ChkViernes.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") - If ChkSabado.Checked Then SBDiasPago.AppendFormat("1") Else SBDiasPago.AppendFormat("0") - DiasPago = SBDiasPago.ToString - - 'Dias de Revision - Dim SBDiasRevision As New StringBuilder() - Dim DiasRevision As String = "" - If ChkRevLunes.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") - If ChkRevMartes.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") - If ChkRevMiercoles.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") - If ChkRevJueves.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") - If ChkRevViernes.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") - If ChkRevSabado.Checked Then SBDiasRevision.AppendFormat("1") Else SBDiasRevision.AppendFormat("0") - DiasRevision = SBDiasRevision.ToString - - - Dim errorContPaq As Boolean = False - Dim IdContPaqi As Integer = 0 - Dim CodigoPersona As Integer = 0 - - -#Region "comentado" - 'If UsuarioActual.Empresa.Funcionalidad(522).ToString = "1" Then - - ' Dim ObjContPaqi As New ClsContPAQi(UsuarioActual.Empresa) - - ' If ObjContPaqi.GetPersona(TxtRFC.Text) Then - - ' If ObjContPaqi.DtResultados.Rows.Count > 0 Then - - ' IdContPaqi = ObjContPaqi.DtResultados.Rows(0)("Id").ToString.ToEntero - ' CodigoPersona = ObjContPaqi.DtResultados.Rows(0)("Codigo").ToString.ToEntero - - ' Dim Cont_EsProveedor As Integer = If(Boolean.Parse(ObjContPaqi.DtResultados.Rows(0)("EsProveedor").ToString), 1, 0) - ' Dim Cont_Nombre As String = ObjContPaqi.DtResultados(0)("Nombre").ToString - ' Dim Cont_RFC As String = ObjContPaqi.DtResultados(0)("RFC").ToString - - ' If ObjContPaqi.UpdatePersona(IdContPaqi, Cont_Nombre, Cont_RFC, 1, Cont_EsProveedor) Then - ' errorContPaq = False - ' Else - ' errorContPaq = True - ' End If - - ' Else - ' If ObjContPaqi.AddPersona(TxtNombre.Text.Trim, TxtRFC.Text.Trim, 1, 0) Then - - ' IdContPaqi = ObjContPaqi.DtResultados.Rows(0)("IdContPaqiPersona").ToString.ToEntero - ' CodigoPersona = ObjContPaqi.DtResultados.Rows(0)("Codigo").ToString.ToEntero - ' errorContPaq = False - ' Else - ' errorContPaq = True - ' End If - ' End If - ' End If - - - ' If Not errorContPaq Then - ' Dim IdContPaqiCliente As Integer - - ' If ObjContPaqi.GetCliente(-1, CodigoPersona) Then - - ' If ObjContPaqi.DtResultados.Rows.Count > 0 Then - - ' IdContPaqiCliente = ObjContPaqi.DtResultados.Rows(0)("IdContPaqiClient").ToString.ToEntero - - ' If ObjContPaqi.UpdateCliente(IdContPaqiCliente, CodigoPersona, CodigoPersona, "", "") Then - ' errorContPaq = False - ' Else - ' errorContPaq = True - ' End If - ' Else - ' If ObjContPaqi.AddCliente(CodigoPersona, CodigoPersona, "", "") Then - ' errorContPaq = False - ' Else - ' errorContPaq = True - ' End If - ' End If - ' Else - ' errorContPaq = True - ' End If - ' End If - - - ' If Not errorContPaq Then - ' ObjContPaqi.Commit() - ' ObjContPaqi.Dispose() - ' Else - ' ObjContPaqi.RollBack() - ' ObjContPaqi.Dispose() - ' Alert("Se presento un error al guardar en ContPAQi", TipoMensaje.MsgError) - ' Exit Sub - ' End If - - - 'End If -#End Region - - Dim LT As String = If(HDLT.Value.ToDouble <> 0, HDLT.Value, "0") - Dim LG As String = If(HDLG.Value.ToDouble <> 0, HDLG.Value, "0") - - If CveCliente = -1 Then - Dim ErrorAC As Boolean = False - Dim CtaCliente As Integer = DdlCtaContableClientes.SelectedValue.ToEntero - - ' si tiene la funcionalidad de la cuenta contable padre - If UsuarioActual.Empresa.Funcionalidad(114) <> "" Then - - Dim ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) - - ObjContaAC.IniciaTransacSQL() - 'se registra la cuenta contable automaticamente - - CtaCliente = ObjContaAC.AddSiguienteCuentaHijo(UsuarioActual.Empresa.Funcionalidad(114).ToEntero, TxtNombreComercial.Text.Trim, "A", 2) - - If CtaCliente > 0 Then - ObjContaAC.Commit() - DdlCtaContableClientes.Items.Add(New ListItem(TxtNombreComercial.Text.Trim, CtaCliente.ToString)) - DdlCtaContableClientes.SelectedValue = CtaCliente.ToString - 'MsgCuentaContable = String.Format("
    Con la cuenta contable: {0}", NewCuenta) - - Else - - ObjContaAC.RollBack() - ObjContaAC.Dispose() - Alert("Error al guardar la cuenta contable ", TipoMensaje.MsgError) - ObjClientes.Dispose() - Exit Sub - End If - ObjContaAC.Dispose() - End If - - 'Si tiene contabilizacion automatica y la funcionalidad de carga cuenta automatica o UsaAC le agregamos automaticamente una cuenta al cliente - If UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(200).ToEntero > 0 Or UsuarioActual.Empresa.UsaAC) AndAlso DdlCtaContableClientes.SelectedValue.ToEntero < 1 Then - If Not AgregarCuentaContable(BtnActivaRegistroClientes, DdlCtaContableClientes) Then - ErrorProceso = True - End If - End If - - Dim MetodoPago = DdlMetodoPago.SelectedValue.ToEntero - If UsuarioActual.Empresa.CvePlataforma = 3 Then - MetodoPago = 1 - End If - - - - - If ObjClientes.AddCliente(TxtNombre.Text.Trim, TxtNombreComercial.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim, TxtLocalidad.Text.Trim, TxtCiudad.Text.Trim, TxtEstado.Text.Trim, TxtPais.Text.Trim, TxtRFC.Text.Trim, TxtCP.Text.Trim, TxtTelefono.Text.Trim.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), - TxtContacto.Text.Trim, TxtEmail.Text.Trim, TxtEmailCotizacion.Text.Trim, TxtNotificar.Text.Trim, TxtPagina.Text.Trim, TxtGiro.Text.Trim, DdlPrecioLista.SelectedValue.ToEntero, ChkMail.Checked, TxtRetIVA.Text.ToDouble, - TxtRetISR.Text.ToDouble, ChkRetIVAFletesAcarreos.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TxtNombreCorto.Text.Trim, DdlVendedor.SelectedValue.ToEntero, TxtPlazoCobranza.Text.Trim.ToEntero, TxtPlazoCobranzaRemision.Text.Trim.ToEntero, - DiasPago, DdlTipoPago.SelectedValue, DdlCtaContableClientes.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableAnticipos.SelectedValue.ToEntero, - DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableRetIVA.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableRetISR.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableFondoGarantia.SelectedValue.ToEntero, - DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableCompClientes.SelectedValue.ToEntero, DdlCtaContableCompClientes.SelectedItem.Text, DdlCtaContableCompAnticipos.SelectedValue.ToEntero, DdlCtaContableCompAnticipos.SelectedItem.Text, - TxtConvenioCIE.Text.Trim, TxtFormaFacturacion.Text.Trim, TxtCodigo.Text.Trim, TxtLimiteCredito.Text.ToDouble, TxtNumCtaPago.Text.Trim, MetodoPago, ChkAplicaFEMSA.Checked, TxtFEMSA_NumSociedad.Text.Trim, - TxtFEMSA_NumProveedor.Text.Trim, TxtFEMA_Mail.Text.Trim, ChkAplicaDetallista.Checked, TxtDet_GLNComprador.Text.Trim, TxtDet_Departamento.Text.Trim, TxtDet_GLNVendedor.Text.Trim, TxtDet_NumProveedor.Text.Trim, TxtProveedor.Text.Trim, ChkAplicaFord.Checked, TxtFordGSDB.Text.Trim, - TxtExtension.Text.Trim, TxtTelefonoOtro.Text.Trim.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), ChkPermiteCredito.Checked, DdlSubProyecto.SelectedValue.ToEntero, DdlCorporativo.SelectedValue.ToEntero, - CveClienteClasificacion:=DdlClasificacion.SelectedValue.ToEntero, CveUsuarioResponsable:=DdlResponsable.SelectedValue.ToEntero, - CveCondicionEntrega:=DdlCondicionesEntrega.SelectedValue.ToEntero, ImprimeNombreSucursal:=ChkMuestraNombre.Checked, CveZonaHoraria:=DdlZonaHoraria.SelectedValue.ToEntero, CobranzaContacto:=TxtCobranzaContacto.Text.Trim, CobranzaTelefono:=TxtCobranzaTelefono.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), - CobranzaExt:=TxtCobranzaExt.Text, CobranzaCorreo:=TxtCobranzaCorreo.Text.Trim, Horario:=TxtHorario.Text.Trim, PortalFacturacion:=TxtPortalFacturacion.Text.Trim, Documentacion:=TxtDocumentacion.Text.Trim, DiasEspecifico:=TxtDiasEspecifico.Text.Trim, UsuarioPortal:=TxtUsuarioPortalFacturacion.Text, ContraseñaPortal:=TxtContraseñaPortalFacturacion.Text, - DiasRevision:=DiasRevision, ObservacionRevsion:=TxtObsDiasRevision.Text.Trim, ReferenciaFiscal:=TxtReferenciaFiscal.Text.Trim, Celular:=TxtCelular.Text.Trim.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), ExtOtros:=TxtExtOtro.Text.Trim, CveUsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, - CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, DesglosaIEPS:=ChkDesglosarIEPS.Checked, AplicaComercioExterior:=ChkAplicaComercioExterior.Checked, CveTipoOperacion:=DdlTipoOperacion.SelectedValue.ToEntero, CvePedimento:=DdlClavePedimento.SelectedValue.ToEntero, CveIncoterm:=DdlIncoterm.SelectedValue.ToEntero, - CvePais:=DdlPais.SelectedValue.ToEntero, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero, CveMotivoTraslado:=IIf(DdlMotivoTraslado.SelectedValue = "-1", "0", DdlMotivoTraslado.SelectedValue).ToString().ToEntero, NumRegIdTrib:=IIf(TxtNumRegIdTrib.Text = "", "-1", TxtNumRegIdTrib.Text).ToString(), - ComExtEstado:=IIf(TxtComExtEstado.Text = "", "-1", TxtComExtEstado.Text).ToString(), ComExtMunicipio:=IIf(TxtComExtMunicipio.Text = "", "-1", TxtComExtMunicipio.Text).ToString(), ComExtColonia:=IIf(TxtComExtColonia.Text = "", "-1", TxtComExtColonia.Text).ToString(), RequiereOC:=ChkRequiereOC.Checked, LT:=LT, LG:=LG, EsDistribuidor:=ChkEsDistribuidor.Checked, - TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CargoUsado:=ChkCargoUsado.Checked, BonificacionUsado:=ChkBonificacionUsado.Checked, CveTipoRetencion:=DdlTipoRetencion.SelectedValue.ToEntero()) Then - - ViewState("CveCliente") = ObjClientes.CveCliente - - - 'For Each gvr As GridViewRow In GvDocsVentas.Rows - ' If gvr.FCCheckBox("ChkDoc").Checked Then - - ' objDoc.DocumentacionElectronicaAdd(gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, Now, Observacion2:=gvr.FCTextBox("TxtObs2").Text, FechaVigencia:=gvr.FCTextBox("TxtFechaVigencia").Text.ToDate) - - ' End If - - 'Next - GuardarDocumentosClientes() - - If Not AsignaCuentasAutomaticas(ObjClientes) Then - ErrorProceso = True - End If - - For Each GVR As GridViewRow In GvImpuestosLocales.Rows - If GVR.FCCheckBox("ChkDeduccion").Checked Then - ObjClientes.AddClienteImpuestosLocales(CveCliente, GVR.DataKey("CveImpuestoLocal").ToEntero) - End If - Next - - For Each Row As DataRow In TempDTSucursales.Rows - If Not CveCliente > 0 Then - If ObjClientes.AddSucursal(ObjClientes.CveCliente, Row("SucursalCliente").ToString, UsuarioActual.CveUsuario, Row("CiudadSucursal").ToString, Row("ColoniaSucursal").ToString, Row("CPSucursal").ToString, Row("DireccionSucursal").ToString, Row("EstadoSucursal").ToString, Row("LocalidadSucursal").ToString, - Row("PaisSucursal").ToString, Row("NumExtSucursal").ToString, Row("NumIntSucursal").ToString, Row("TelefonoSucursal").ToString, Row("CorreoSucursal").ToString, Row("CorreoCotiziacionSucursal").ToString, Row("ContactoSucursal").ToString, - Row("CveVendedorSucursal").ToString.ToEntero, Row("NumCuenta").ToString, Row("CveMetodoPago").ToString.ToEntero, Row("LimiteCredito").ToString.ToDecimal, Row("CveResponsableCobranza").ToString.ToEntero, - Row("CveUsoCFDI").ToString.ToEntero, Row("CveFormaPago33").ToString.ToEntero, Row("CveMetodoPago33").ToString.ToEntero, LT:=Row("LT").ToString, LG:=Row("LG").ToString) Then - End If - End If - Next - - If UsuarioActual.Empresa.CvePlataforma = 3 AndAlso Not ErrorProceso Then - Dim GPS As New ClsGPS - GPS.IniciaTransacSQL() - For Each GvRow As GridViewRow In GvDatos.Rows - If Not GPS.DispositivosClienteUpdate(GvRow.DataKey("CveDispositivo").ToString.ToEntero, ObjClientes.CveCliente) Then - ErrorProceso = True - End If - Next - If ErrorProceso Then - GPS.RollBack() - Else - GPS.Commit() - End If - End If - - - If ErrorProceso Then - ObjClientes.RollBack() - Else + Private Sub CargaBancos(Optional SelectTop As Integer = 51, Optional CveClienteSucursal As Integer = -1) + Dim ObjMovtos As New ClsMovimientos() + 'CxC Activas + If ObjMovtos.GetClienteAbonos(CveCliente, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero, SelectTop:=SelectTop) AndAlso ObjMovtos.DtResultados.Rows.Count > 0 Then + GvBancos.DataSource = ObjMovtos.DtResultados + DTCobrosRealizados = ObjMovtos.DtResultados + DTCobrosRealizados.Rows.Remove(DTCobrosRealizados.Rows(0)) + Else + DTCobrosRealizados = Nothing + End If + ObjMovtos.Dispose() + GvBancos.DataBind() + End Sub + + Protected Sub GvBancos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvBancos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + 'Dim HLSendMail As HtmlAnchor = DirectCast(e.Row.FindControl("HLSendMail"), HtmlAnchor) + + If e.Row.DBCampo("CveVenta") = "" Then + If e.Row.DBCampo("CveIE") <> "" Then + Dim ObjBancos As New ClsBancos + + e.Row.Cells(0).Text = String.Format("{0} - {1}", e.Row.DBCampo("Banco"), e.Row.DBCampo("NumCuenta")) + e.Row.FCLiteral("LtlFechaVenci").Text = e.Row.DBCampo("FechaDocumento").ToDate.ToShortDateString + e.Row.FCHyperLink("HplCheque").Visible = True + e.Row.FCLiteral("LtlImp").Text = e.Row.DBCampo("ImporteIE").FormatoNumero + e.Row.FCLiteral("LtlMon").Text = e.Row.DBCampo("MonedaIE") + + + 'HLSendMail.HRef = String.Format("javascript:$get('HdnCveIE').value='{0}';$get('HdnSerieFolio').value='{1}';$get('HdnFolioPago').value='{2}';$get('TxtParaMail').value='{3}';$('#ModalDivMail').modal();", e.Row.DBCampo("CveIE"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("FolioCobro"), TxtCobranzaCorreo.Text) + + If ObjBancos.GetComplementoPagos(-1, e.Row.DBCampo("CveIE").ToString.ToEntero, -1, UsuarioActual.CveEmpresa) Then + If ObjBancos.DtResultados.Rows.Count > 0 Then + e.Row.FCHyperLink("HplXML").Visible = True : e.Row.FCHyperLink("HplXML").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CompP&EXT=xml&CveComplementoPago={0}&SerieFolio={1}&CveIE={2}", ObjBancos.DtResultados(0)("CveComplementoPago").ToString, ObjBancos.DtResultados(0)("SerieFolio").ToString, ObjBancos.DtResultados(0)("CveIE").ToString))) + e.Row.FCHyperLink("HplPDF").Visible = True : e.Row.FCHyperLink("HplPDF").NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CompP&EXT=pdf&CveComplementoPago={0}&SerieFolio={1}&CveIE={2}", ObjBancos.DtResultados(0)("CveComplementoPago").ToString, ObjBancos.DtResultados(0)("SerieFolio").ToString, ObjBancos.DtResultados(0)("CveIE").ToString))) + + e.Row.FCLinkButton("LnkSendMail").Visible = True + End If + End If + + ObjBancos.Dispose() + End If + e.Row.BackColor = Drawing.Color.LightGray + End If + + If e.Row.DBCampo("CveVenta") = "" And e.Row.DBCampo("Banco") = "" Then + e.Row.Visible = False + End If + End If + End Sub + + Protected Sub LnkSendMail_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + HdnSerieFolioPago.Value = gvRow.DataKey("SerieFolioCP").ToString + TxtParaMail.Text = TxtCobranzaCorreo.Text + UpSendMail.Update() + RegistraScript("$('#ModalDivMail').modal('show');") + End Sub +#End Region + +#Region "B T N ´ S" + Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click + Dim ObjClientes As New ClsClientes() + If ObjClientes.RemoveCliente(CveCliente) Then + Alert("El Cliente se Eliminó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatClientes.aspx""") + End If + ObjClientes.Dispose() + End Sub + Protected Sub BtnSendMail_Click(sender As Object, e As System.EventArgs) Handles BtnSendMail.Click + Try + + If HdnCveVenta.Value <> "-1" AndAlso HdnFolioVenta.Value <> "-1" Then + + Dim ObjMail As New ClsSisMail() + Dim Ruta As String = UsuarioActual.Empresa.Ruta + + Dim Cuerpo As String = TxtBody.Text + Dim Asunto As String = "" + Dim TipoComprobante = "" + + If HdnTipoDocto.Value.ToString = "Ing" Then TipoComprobante = "Factura" + If HdnTipoDocto.Value.ToString = "Egs" Then TipoComprobante = "Nota de Crédito" + If HdnTipoDocto.Value.ToString = "Dev" Then TipoComprobante = "Nota de Devolución" + If HdnTipoDocto.Value.ToString = "Rem" Then TipoComprobante = "Remisión" + If HdnTipoDocto.Value.ToString = "Cot" Then TipoComprobante = "Cotización" + If HdnTipoDocto.Value.ToString = "Ant" Then TipoComprobante = "Anticipo" + + Dim DisplayName As String = "" + If UsuarioActual.CveEmpresa = 119 Then DisplayName = "Facturación Agroquímicos JAM" + + Dim ObjVenta As New ClsVentas + Dim Dr As DataRow = Nothing + If ObjVenta.GetVenta(HdnCveVenta.Value.ToEntero, UsuarioActual.CveEmpresa) Then + If ObjVenta.DtResultados.Rows.Count > 0 Then + Dr = ObjVenta.DtResultados.Rows(0) + End If + End If + ObjVenta.Dispose() + + If UsuarioActual.Empresa.PlantillaMailVenta.Trim.Length > 0 Then + Cuerpo = UsuarioActual.Empresa.PlantillaMailVenta + Cuerpo = Cuerpo.Replace("{""NombreEmpresa""}", UsuarioActual.Empresa.Empresa) + Cuerpo = Cuerpo.Replace("{""NombreCliente""}", LtlCliente.Text.Trim) + Cuerpo = Cuerpo.Replace("{""TipoDocumento""}", TipoComprobante) + Cuerpo = Cuerpo.Replace("{""SerieFolio""}", HdnSerieFolio.Value.ToString) + If Dr IsNot Nothing Then + Cuerpo = Cuerpo.Replace("{""Fecha""}", Dr("Fecha").ToString.ToDate.ToShortDateString) + Cuerpo = Cuerpo.Replace("{""Total""}", Dr("Total").ToString.FormatoNumero) + Cuerpo = Cuerpo.Replace("{""FechaVencimiento""}", Dr("FechaVencimiento").ToString.ToDate.ToShortDateString) + End If + End If + + + If UsuarioActual.Empresa.AsuntoPlantillaMailVenta.Trim.Length > 0 Then + Asunto = UsuarioActual.Empresa.AsuntoPlantillaMailVenta + Asunto = Asunto.Replace("{""TipoDocumento""}", TipoComprobante) + Asunto = Asunto.Replace("{""Sucursal""}", HdnSubProyecto.Value.ToString) + Asunto = Asunto.Replace("{""SerieFolio""}", HdnSerieFolio.Value.ToString) + End If + + If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso HdnTipoDocto.Value.Contiene("Ing", "Egs", "Ant", "Dev") Then + If File.Exists($"{Ruta}PDF\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.pdf") AndAlso File.Exists($"{Ruta}XML\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.xml") Then + Dim PDF As String = $"{Ruta}PDF\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.pdf" + Dim XML As String = $"{Ruta}XML\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.xml" + + Dim ResultadoMail As Integer = 0 + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = XML}) + + 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then + If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, Asunto, Cuerpo, TxtCC.Text.Trim, LSRutasMail, Displayname:=DisplayName) Then + ResultadoMail = 1 + TxtCC.Text = "" + TxtBody.Text = "" + RegistraScript("$('#ModalDivMail').modal('hide');") + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + CargaHistorial() + 'UpnHistorial.Update() + Else + ResultadoMail = 3 + Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError) + End If + + Dim ObjVentas As New ClsVentas + ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta.Value.ToEntero) + ObjVentas.Dispose() + Else + Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) + End If + ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" AndAlso HdnTipoDocto.Value.Contiene("Ing", "Egs", "Ant", "Dev") Then + If File.Exists(Ruta & "PDF\" & HdnFolioVenta.Value & ".pdf") Then + Dim PDF As String = Ruta & "PDF\" & HdnFolioVenta.Value & ".pdf" + + Dim ResultadoMail As Integer = 0 + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) + + + 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then + If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, Asunto, Cuerpo, TxtCC.Text.Trim, LSRutasMail) Then + ResultadoMail = 1 + TxtCC.Text = "" + TxtBody.Text = "" + RegistraScript("$('#ModalDivMail').modal('hide');") + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + CargaHistorial() + UpnHistorial.Update() + Else + ResultadoMail = 3 + End If + + Dim ObjVentas As New ClsVentas + ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta.Value.ToEntero) + ObjVentas.Dispose() + Else + Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) + End If + ElseIf HdnTipoDocto.Value = "Cot" Then + If File.Exists($"{Ruta}PDF\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.pdf") Then + Dim PDF As String = $"{Ruta}PDF\{HdnTipoDocto.Value}\{HdnFolioVenta.Value}.pdf" + + Dim ResultadoMail As Integer = 0 + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) + + 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then + If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, Asunto, Cuerpo, TxtCC.Text.Trim, LSRutasMail) Then + ResultadoMail = 1 + TxtCC.Text = "" + TxtBody.Text = "" + RegistraScript("$('#ModalDivMail').modal('hide');") + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + CargaHistorial() + UpnHistorial.Update() + Else + ResultadoMail = 3 + End If + + Dim ObjVentas As New ClsVentas + ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta.Value.ToEntero) + ObjVentas.Dispose() + Else + Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) + End If + End If + + 'End If + 'ObjEmprea.Dispose() + ElseIf HdnSerieFolioPago.Value <> "-1" Then + + Dim ObjMail As New ClsSisMail() + Dim RutaXML As String = String.Format("{0}XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, HdnSerieFolioPago.Value) + Dim RutaPDF As String = String.Format("{0}PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, HdnSerieFolioPago.Value) + + Dim Cuerpo As String = "Se hace entrega del comprobante de pago" + Dim Asunto As String = "Entrega de comprobante de pago" + + If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then + + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF}) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML}) + + If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, Asunto, Cuerpo, TxtCC.Text.Trim, LSRutasMail) Then + TxtCC.Text = "" + RegistraScript("$('#ModalDivMail').modal('hide');") + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + End If + Else + Alert("No se encontraron los archivos para enviar.", TipoMensaje.MsgAdvertencia) + End If + Else + Alert("No se seleccionó ninguna factura para envíar.", TipoMensaje.MsgAdvertencia) + End If + Catch ex As Exception + OnError("Ocurrió error al mandar MAIL", ex) + Dim ObjVentas As New ClsVentas + ObjVentas.UpdateVentaMail(3, HdnCveVenta.Value.ToEntero) + ObjVentas.Dispose() + End Try + End Sub + Protected Sub BtnAbonar_Click(sender As Object, e As System.EventArgs) Handles BtnAbonar.Click + Dim ObjMovtos As New ClsMovimientos() + + + If ObjMovtos.AddMovimiento(2, "Cli", CveCliente.ToString, HdnCveVentaAbono.Value, 1, 0, TxtCantidad.Text.Trim.ToDouble, Now, TxtFechaPago.Text.ToDate, TxtReferencia.Text.Trim, DdlCtaContableClientes.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + Alert("El abono se guardó correctamente", TipoMensaje.MsgInformacion, "$get(""DivAddPago"").style.display=""none"";") + CargaCxC() + TxtCantidad.Text = "" + TxtReferencia.Text = "" + + 'UpAbono.Update() + UPPUsuarios.Update() + End If + ObjMovtos.Dispose() + AbonaaCuenta() + End Sub + + Private Function AsignaCuentasAutomaticas(ObjClientes As ClsClientes) As Boolean + Dim IdCtaContableClientes As Integer = UsuarioActual.Empresa.Funcionalidad(246).ToEntero + Dim IdCtaContableAnticipos As Integer = UsuarioActual.Empresa.Funcionalidad(319).ToEntero + Dim IdCtaContableComplementaria As Integer = UsuarioActual.Empresa.Funcionalidad(320).ToEntero + Dim IdCtaContMonedaExtranjera As Integer = UsuarioActual.Empresa.Funcionalidad(331).ToEntero + Dim IdCtaContMonedaExtranjeraAnticipos As Integer = UsuarioActual.Empresa.Funcionalidad(332).ToEntero + Dim IdCtaContCompAnticipos As Integer = UsuarioActual.Empresa.Funcionalidad(333).ToEntero + + If Not ObjClientes.VincularCuentasContables(IdCtaContableClientes, IdCtaContableAnticipos, 0, 0, CveCliente, IdCtaContableComplementaria, IdCtaContMonedaExtranjera, IdCtaContMonedaExtranjeraAnticipos, IdCtaContCompAnticipos) Then + Return False + End If + Return True + End Function + + Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click + If UsuarioActual.CveUsuario = 1465 And TxtCodigo.Text.Trim = "" Then + Alert("El cliente no se puede registrar sin ingresar un Código.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If ChkAplicaComercioExterior.Checked Then + If Not DdlTipoOperacion.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar un tipo de operacion para comercio exterior.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlClavePedimento.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar una clave de pedimento para comercio exterior.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlIncoterm.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar un incoterm para comercio exterior.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlPais.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar un pais para comercio exterior.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlPais.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar un pais para comercio exterior.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If (Not DdlEstado.SelectedValue.ToEntero > 0 And DdlEstado.Visible) Or (Not DdlEstado.Visible And TxtComExtEstado.Text = "") Then + Alert("Tiene que seleccionar un estado para comercio exterior.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If DdlPais.SelectedValue.ToEntero = 151 Then + If Not DdlMunicipio.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar un municipio para comercio exterior si el pais es mexico.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + If Not DdlColonia.SelectedValue.ToEntero > 0 Then + Alert("Tiene que seleccionar una colonia para comercio exterior si el pais es mexico.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + End If + + End If + + 'CargaSucursal() + 'If UsuarioActual.TienePermisoProceso(170) AndAlso TxtCodigo.Text.Trim = "" Then + ' Alert("Es necesario ingresar un Código", TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If + + 'Dim rowcodigo As DataTable = GlobalDTCliente.FiltraParametros(String.Format("Codigo='{0}' AND CveEmpresa={1} ", TxtCodigo.Text.Trim, UsuarioActual.CveEmpresa)) + 'If (Not IsNothing(rowcodigo)) AndAlso (rowcodigo.Rows.Count > 0) AndAlso (rowcodigo.Rows(0)("CveCliente").ToString.ToEntero <> CveCliente) Then + ' Alert(String.Format("ya existe un Cliente Con este Codigo '{0}'", TxtCodigo.Text.Trim), TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If + Dim ObjClientes As New ClsClientes() + Dim objDoc As New ClsEdocumentacion(ObjClientes.IniciaTransacSQL()) + Dim MsgCuentaContable As String = "" + Dim ErrorProceso As Boolean = False + + 'Dias de pago + Dim SBDiasPago As New StringBuilder() + Dim DiasPago As String = "" + If ChkLunes.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") + If ChkMartes.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") + If ChkMiercoles.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") + If ChkJueves.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") + If ChkViernes.Checked Then SBDiasPago.AppendFormat("1-") Else SBDiasPago.AppendFormat("0-") + If ChkSabado.Checked Then SBDiasPago.AppendFormat("1") Else SBDiasPago.AppendFormat("0") + DiasPago = SBDiasPago.ToString + + 'Dias de Revision + Dim SBDiasRevision As New StringBuilder() + Dim DiasRevision As String = "" + If ChkRevLunes.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") + If ChkRevMartes.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") + If ChkRevMiercoles.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") + If ChkRevJueves.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") + If ChkRevViernes.Checked Then SBDiasRevision.AppendFormat("1-") Else SBDiasRevision.AppendFormat("0-") + If ChkRevSabado.Checked Then SBDiasRevision.AppendFormat("1") Else SBDiasRevision.AppendFormat("0") + DiasRevision = SBDiasRevision.ToString + + + Dim errorContPaq As Boolean = False + Dim IdContPaqi As Integer = 0 + Dim CodigoPersona As Integer = 0 + + +#Region "comentado" + 'If UsuarioActual.Empresa.Funcionalidad(522).ToString = "1" Then + + ' Dim ObjContPaqi As New ClsContPAQi(UsuarioActual.Empresa) + + ' If ObjContPaqi.GetPersona(TxtRFC.Text) Then + + ' If ObjContPaqi.DtResultados.Rows.Count > 0 Then + + ' IdContPaqi = ObjContPaqi.DtResultados.Rows(0)("Id").ToString.ToEntero + ' CodigoPersona = ObjContPaqi.DtResultados.Rows(0)("Codigo").ToString.ToEntero + + ' Dim Cont_EsProveedor As Integer = If(Boolean.Parse(ObjContPaqi.DtResultados.Rows(0)("EsProveedor").ToString), 1, 0) + ' Dim Cont_Nombre As String = ObjContPaqi.DtResultados(0)("Nombre").ToString + ' Dim Cont_RFC As String = ObjContPaqi.DtResultados(0)("RFC").ToString + + ' If ObjContPaqi.UpdatePersona(IdContPaqi, Cont_Nombre, Cont_RFC, 1, Cont_EsProveedor) Then + ' errorContPaq = False + ' Else + ' errorContPaq = True + ' End If + + ' Else + ' If ObjContPaqi.AddPersona(TxtNombre.Text.Trim, TxtRFC.Text.Trim, 1, 0) Then + + ' IdContPaqi = ObjContPaqi.DtResultados.Rows(0)("IdContPaqiPersona").ToString.ToEntero + ' CodigoPersona = ObjContPaqi.DtResultados.Rows(0)("Codigo").ToString.ToEntero + ' errorContPaq = False + ' Else + ' errorContPaq = True + ' End If + ' End If + ' End If + + + ' If Not errorContPaq Then + ' Dim IdContPaqiCliente As Integer + + ' If ObjContPaqi.GetCliente(-1, CodigoPersona) Then + + ' If ObjContPaqi.DtResultados.Rows.Count > 0 Then + + ' IdContPaqiCliente = ObjContPaqi.DtResultados.Rows(0)("IdContPaqiClient").ToString.ToEntero + + ' If ObjContPaqi.UpdateCliente(IdContPaqiCliente, CodigoPersona, CodigoPersona, "", "") Then + ' errorContPaq = False + ' Else + ' errorContPaq = True + ' End If + ' Else + ' If ObjContPaqi.AddCliente(CodigoPersona, CodigoPersona, "", "") Then + ' errorContPaq = False + ' Else + ' errorContPaq = True + ' End If + ' End If + ' Else + ' errorContPaq = True + ' End If + ' End If + + + ' If Not errorContPaq Then + ' ObjContPaqi.Commit() + ' ObjContPaqi.Dispose() + ' Else + ' ObjContPaqi.RollBack() + ' ObjContPaqi.Dispose() + ' Alert("Se presento un error al guardar en ContPAQi", TipoMensaje.MsgError) + ' Exit Sub + ' End If + + + 'End If +#End Region + + Dim LT As String = If(HDLT.Value.ToDouble <> 0, HDLT.Value, "0") + Dim LG As String = If(HDLG.Value.ToDouble <> 0, HDLG.Value, "0") + + If CveCliente = -1 Then + Dim ErrorAC As Boolean = False + Dim CtaCliente As Integer = DdlCtaContableClientes.SelectedValue.ToEntero + + ' si tiene la funcionalidad de la cuenta contable padre + If UsuarioActual.Empresa.Funcionalidad(114) <> "" Then + + Dim ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa) + + ObjContaAC.IniciaTransacSQL() + 'se registra la cuenta contable automaticamente + + CtaCliente = ObjContaAC.AddSiguienteCuentaHijo(UsuarioActual.Empresa.Funcionalidad(114).ToEntero, TxtNombreComercial.Text.Trim, "A", 2) + + If CtaCliente > 0 Then + ObjContaAC.Commit() + DdlCtaContableClientes.Items.Add(New ListItem(TxtNombreComercial.Text.Trim, CtaCliente.ToString)) + DdlCtaContableClientes.SelectedValue = CtaCliente.ToString + 'MsgCuentaContable = String.Format("
    Con la cuenta contable: {0}", NewCuenta) + + Else + + ObjContaAC.RollBack() + ObjContaAC.Dispose() + Alert("Error al guardar la cuenta contable ", TipoMensaje.MsgError) + ObjClientes.Dispose() + Exit Sub + End If + ObjContaAC.Dispose() + End If + + 'Si tiene contabilizacion automatica y la funcionalidad de carga cuenta automatica o UsaAC le agregamos automaticamente una cuenta al cliente + If UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 AndAlso (UsuarioActual.Empresa.Funcionalidad(200).ToEntero > 0 Or UsuarioActual.Empresa.UsaAC) AndAlso DdlCtaContableClientes.SelectedValue.ToEntero < 1 Then + If Not AgregarCuentaContable(BtnActivaRegistroClientes, DdlCtaContableClientes) Then + ErrorProceso = True + End If + End If + + Dim MetodoPago = DdlMetodoPago.SelectedValue.ToEntero + If UsuarioActual.Empresa.CvePlataforma = 3 Then + MetodoPago = 1 + End If + + + + + If ObjClientes.AddCliente(TxtNombre.Text.Trim, TxtNombreComercial.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim, TxtLocalidad.Text.Trim, TxtCiudad.Text.Trim, TxtEstado.Text.Trim, TxtPais.Text.Trim, TxtRFC.Text.Trim, TxtCP.Text.Trim, TxtTelefono.Text.Trim.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), + TxtContacto.Text.Trim, TxtEmail.Text.Trim, TxtEmailCotizacion.Text.Trim, TxtNotificar.Text.Trim, TxtPagina.Text.Trim, TxtGiro.Text.Trim, DdlPrecioLista.SelectedValue.ToEntero, ChkMail.Checked, TxtRetIVA.Text.ToDouble, + TxtRetISR.Text.ToDouble, ChkRetIVAFletesAcarreos.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TxtNombreCorto.Text.Trim, DdlVendedor.SelectedValue.ToEntero, TxtPlazoCobranza.Text.Trim.ToEntero, TxtPlazoCobranzaRemision.Text.Trim.ToEntero, + DiasPago, DdlTipoPago.SelectedValue, DdlCtaContableClientes.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableAnticipos.SelectedValue.ToEntero, + DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableRetIVA.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableRetISR.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableFondoGarantia.SelectedValue.ToEntero, + DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableCompClientes.SelectedValue.ToEntero, DdlCtaContableCompClientes.SelectedItem.Text, DdlCtaContableCompAnticipos.SelectedValue.ToEntero, DdlCtaContableCompAnticipos.SelectedItem.Text, + TxtConvenioCIE.Text.Trim, TxtFormaFacturacion.Text.Trim, TxtCodigo.Text.Trim, TxtLimiteCredito.Text.ToDouble, TxtNumCtaPago.Text.Trim, MetodoPago, ChkAplicaFEMSA.Checked, TxtFEMSA_NumSociedad.Text.Trim, + TxtFEMSA_NumProveedor.Text.Trim, TxtFEMA_Mail.Text.Trim, ChkAplicaDetallista.Checked, TxtDet_GLNComprador.Text.Trim, TxtDet_Departamento.Text.Trim, TxtDet_GLNVendedor.Text.Trim, TxtDet_NumProveedor.Text.Trim, TxtProveedor.Text.Trim, ChkAplicaFord.Checked, TxtFordGSDB.Text.Trim, + TxtExtension.Text.Trim, TxtTelefonoOtro.Text.Trim.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), ChkPermiteCredito.Checked, DdlSubProyecto.SelectedValue.ToEntero, DdlCorporativo.SelectedValue.ToEntero, + CveClienteClasificacion:=DdlClasificacion.SelectedValue.ToEntero, CveUsuarioResponsable:=DdlResponsable.SelectedValue.ToEntero, + CveCondicionEntrega:=DdlCondicionesEntrega.SelectedValue.ToEntero, ImprimeNombreSucursal:=ChkMuestraNombre.Checked, CveZonaHoraria:=DdlZonaHoraria.SelectedValue.ToEntero, CobranzaContacto:=TxtCobranzaContacto.Text.Trim, CobranzaTelefono:=TxtCobranzaTelefono.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), + CobranzaExt:=TxtCobranzaExt.Text, CobranzaCorreo:=TxtCobranzaCorreo.Text.Trim, Horario:=TxtHorario.Text.Trim, PortalFacturacion:=TxtPortalFacturacion.Text.Trim, Documentacion:=TxtDocumentacion.Text.Trim, DiasEspecifico:=TxtDiasEspecifico.Text.Trim, UsuarioPortal:=TxtUsuarioPortalFacturacion.Text, ContraseñaPortal:=TxtContraseñaPortalFacturacion.Text, + DiasRevision:=DiasRevision, ObservacionRevsion:=TxtObsDiasRevision.Text.Trim, ReferenciaFiscal:=TxtReferenciaFiscal.Text.Trim, Celular:=TxtCelular.Text.Trim.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), ExtOtros:=TxtExtOtro.Text.Trim, CveUsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, + CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, DesglosaIEPS:=ChkDesglosarIEPS.Checked, AplicaComercioExterior:=ChkAplicaComercioExterior.Checked, CveTipoOperacion:=DdlTipoOperacion.SelectedValue.ToEntero, CvePedimento:=DdlClavePedimento.SelectedValue.ToEntero, CveIncoterm:=DdlIncoterm.SelectedValue.ToEntero, + CvePais:=DdlPais.SelectedValue.ToEntero, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero, CveMotivoTraslado:=IIf(DdlMotivoTraslado.SelectedValue = "-1", "0", DdlMotivoTraslado.SelectedValue).ToString().ToEntero, NumRegIdTrib:=IIf(TxtNumRegIdTrib.Text = "", "-1", TxtNumRegIdTrib.Text).ToString(), + ComExtEstado:=IIf(TxtComExtEstado.Text = "", "-1", TxtComExtEstado.Text).ToString(), ComExtMunicipio:=IIf(TxtComExtMunicipio.Text = "", "-1", TxtComExtMunicipio.Text).ToString(), ComExtColonia:=IIf(TxtComExtColonia.Text = "", "-1", TxtComExtColonia.Text).ToString(), RequiereOC:=ChkRequiereOC.Checked, LT:=LT, LG:=LG, EsDistribuidor:=ChkEsDistribuidor.Checked, + TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CargoUsado:=ChkCargoUsado.Checked, BonificacionUsado:=ChkBonificacionUsado.Checked, CveTipoRetencion:=DdlTipoRetencion.SelectedValue.ToEntero()) Then + + ViewState("CveCliente") = ObjClientes.CveCliente + + + 'For Each gvr As GridViewRow In GvDocsVentas.Rows + ' If gvr.FCCheckBox("ChkDoc").Checked Then + + ' objDoc.DocumentacionElectronicaAdd(gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, Now, Observacion2:=gvr.FCTextBox("TxtObs2").Text, FechaVigencia:=gvr.FCTextBox("TxtFechaVigencia").Text.ToDate) + + ' End If + + 'Next + GuardarDocumentosClientes() + + If Not AsignaCuentasAutomaticas(ObjClientes) Then + ErrorProceso = True + End If + + For Each GVR As GridViewRow In GvImpuestosLocales.Rows + If GVR.FCCheckBox("ChkDeduccion").Checked Then + ObjClientes.AddClienteImpuestosLocales(CveCliente, GVR.DataKey("CveImpuestoLocal").ToEntero) + End If + Next + + For Each Row As DataRow In TempDTSucursales.Rows + If Not CveCliente > 0 Then + If ObjClientes.AddSucursal(ObjClientes.CveCliente, Row("SucursalCliente").ToString, UsuarioActual.CveUsuario, Row("CiudadSucursal").ToString, Row("ColoniaSucursal").ToString, Row("CPSucursal").ToString, Row("DireccionSucursal").ToString, Row("EstadoSucursal").ToString, Row("LocalidadSucursal").ToString, + Row("PaisSucursal").ToString, Row("NumExtSucursal").ToString, Row("NumIntSucursal").ToString, Row("TelefonoSucursal").ToString, Row("CorreoSucursal").ToString, Row("CorreoCotiziacionSucursal").ToString, Row("ContactoSucursal").ToString, + Row("CveVendedorSucursal").ToString.ToEntero, Row("NumCuenta").ToString, Row("CveMetodoPago").ToString.ToEntero, Row("LimiteCredito").ToString.ToDecimal, Row("CveResponsableCobranza").ToString.ToEntero, + Row("CveUsoCFDI").ToString.ToEntero, Row("CveFormaPago33").ToString.ToEntero, Row("CveMetodoPago33").ToString.ToEntero, LT:=Row("LT").ToString, LG:=Row("LG").ToString) Then + End If + End If + Next + + If UsuarioActual.Empresa.CvePlataforma = 3 AndAlso Not ErrorProceso Then + Dim GPS As New ClsGPS + GPS.IniciaTransacSQL() + For Each GvRow As GridViewRow In GvDatos.Rows + If Not GPS.DispositivosClienteUpdate(GvRow.DataKey("CveDispositivo").ToString.ToEntero, ObjClientes.CveCliente) Then + ErrorProceso = True + End If + Next + If ErrorProceso Then + GPS.RollBack() + Else + GPS.Commit() + End If + End If + + + If ErrorProceso Then + ObjClientes.RollBack() + Else ObjClientes.Commit() 'JM 05-02-19: CRM ASIGAN CLIENTE A EMPRESACRM - Dim MensajeCRM As String = "" - If CveEmpresaCRM > 0 Then - If VincularEmpresaCRM() Then - MensajeCRM = "

    Se vinculo el cliente a la Empresa CRM" - Else - MensajeCRM = "

    Ocurrio un error al vincular la Empresa CRM, intente unificar el Cliente." - End If - End If - - Alert("El Cliente se guardó correctamente." & MsgCuentaContable & MensajeCRM, TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatClientes.aspx""") - End If - End If - Else - - Dim NombreCliente As String = "" - - If TxtRFC.Text.Length = 13 AndAlso TxtApellidoPaterno.Text <> "" AndAlso TxtApellidoMaterno.Text <> "" AndAlso TxtNombres.Text <> "" Then - NombreCliente = ($"{TxtNombres.Text} {TxtApellidoPaterno.Text} {TxtApellidoMaterno.Text}").Trim() - Else - NombreCliente = TxtNombre.Text.Trim() - End If - - If ObjClientes.UpdateCliente(NombreCliente, TxtNombreComercial.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim, TxtLocalidad.Text.Trim, TxtCiudad.Text.Trim, TxtEstado.Text.Trim, TxtPais.Text.Trim, TxtRFC.Text.Trim, TxtCP.Text.Trim, - TxtTelefono.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), TxtContacto.Text.Trim, TxtEmail.Text.Trim, TxtEmailCotizacion.Text.Trim, TxtNotificar.Text.Trim, TxtPagina.Text, TxtGiro.Text, DdlPrecioLista.SelectedValue.ToEntero, ChkMail.Checked, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, ChkRetIVAFletesAcarreos.Checked, - ChkEstado.Checked, TxtNombreCorto.Text.Trim, DdlVendedor.SelectedValue.ToEntero, TxtPlazoCobranza.Text.Trim.ToEntero, TxtPlazoCobranzaRemision.Text.Trim.ToEntero, DiasPago, DdlTipoPago.SelectedValue, - DdlCtaContableClientes.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableAnticipos.SelectedValue.ToEntero, DdlCtaContableAnticipos.SelectedItem.Text, DdlCtaContableRetIVA.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableRetISR.SelectedValue.ToEntero, - DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableFondoGarantia.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableCompClientes.SelectedValue.ToEntero, DdlCtaContableCompClientes.SelectedItem.Text, DdlCtaContableCompAnticipos.SelectedValue.ToEntero, DdlCtaContableCompAnticipos.SelectedItem.Text, - DdlMonedaExtranjeraClientes.SelectedValue.ToEntero, DdlMonedaExtranjeraClientes.SelectedItem.Text, DdlMonedaExtranjeraAnticipos.SelectedValue.ToEntero, DdlMonedaExtranjeraAnticipos.SelectedItem.Text, - TxtConvenioCIE.Text.Trim, TxtFormaFacturacion.Text.Trim, TxtCodigo.Text.Trim, TxtLimiteCredito.Text.ToDouble, TxtNumCtaPago.Text.Trim, DdlMetodoPago.SelectedValue.ToEntero, ChkAplicaFEMSA.Checked, TxtFEMSA_NumSociedad.Text.Trim, TxtFEMSA_NumProveedor.Text.Trim, TxtFEMA_Mail.Text.Trim, - ChkAplicaDetallista.Checked, TxtDet_GLNComprador.Text.Trim, TxtDet_Departamento.Text.Trim, TxtDet_GLNVendedor.Text.Trim, TxtDet_NumProveedor.Text.Trim, TxtProveedor.Text.Trim, ChkAplicaFord.Checked, TxtFordGSDB.Text.Trim, UsuarioActual.CveUsuario, - CveCliente, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TxtExtension.Text.Trim, TxtTelefonoOtro.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), ChkPermiteCredito.Checked, DdlSubProyecto.SelectedValue.ToEntero, DdlCorporativo.SelectedValue.ToEntero, CveClienteClasificacion:=DdlClasificacion.SelectedValue.ToEntero, CveUsuarioResponsable:=DdlResponsable.SelectedValue.ToEntero, - CveCondicionEntrega:=DdlCondicionesEntrega.SelectedValue.ToEntero, ImprimeNombreSucursal:=ChkMuestraNombre.Checked, CveZonaHoraria:=DdlZonaHoraria.SelectedValue.ToEntero, CobranzaContacto:=TxtCobranzaContacto.Text.Trim, CobranzaTelefono:=TxtCobranzaTelefono.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), CobranzaExt:=TxtCobranzaExt.Text, - CobranzaCorreo:=TxtCobranzaCorreo.Text.Trim, Horario:=TxtHorario.Text.Trim, PortalFacturacion:=TxtPortalFacturacion.Text.Trim, Documentacion:=TxtDocumentacion.Text.Trim, DiasEspecifico:=TxtDiasEspecifico.Text.Trim, UsuarioPortal:=TxtUsuarioPortalFacturacion.Text, ContraseñaPortal:=TxtContraseñaPortalFacturacion.Text, - DiasRevision:=DiasRevision, ObservacionRevsion:=TxtObsDiasRevision.Text.Trim, ReferenciaFiscal:=TxtReferenciaFiscal.Text.Trim, Celular:=TxtCelular.Text.Trim.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), ExtOtros:=TxtExtOtro.Text.Trim, CveUsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, DesglosaIEPS:=ChkDesglosarIEPS.Checked, - AplicaComercioExterior:=ChkAplicaComercioExterior.Checked, CveTipoOperacion:=DdlTipoOperacion.SelectedValue.ToEntero, CvePedimento:=DdlClavePedimento.SelectedValue.ToEntero, CveIncoterm:=DdlIncoterm.SelectedValue.ToEntero, CvePais:=DdlPais.SelectedValue.ToEntero, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero, - CveMotivoTraslado:=IIf(DdlMotivoTraslado.SelectedValue = "-1", "0", DdlMotivoTraslado.SelectedValue).ToString().ToEntero, NumRegIdTrib:=IIf(TxtNumRegIdTrib.Text = "", "-1", TxtNumRegIdTrib.Text).ToString(), - ComExtEstado:=IIf(TxtComExtEstado.Text = "", "-1", TxtComExtEstado.Text).ToString(), ComExtMunicipio:=IIf(TxtComExtMunicipio.Text = "", "-1", TxtComExtMunicipio.Text).ToString(), ComExtColonia:=IIf(TxtComExtColonia.Text = "", "-1", TxtComExtColonia.Text).ToString(), + Dim MensajeCRM As String = "" + If CveEmpresaCRM > 0 Then + If VincularEmpresaCRM() Then + MensajeCRM = "

    Se vinculo el cliente a la Empresa CRM" + Else + MensajeCRM = "

    Ocurrio un error al vincular la Empresa CRM, intente unificar el Cliente." + End If + End If + + Alert("El Cliente se guardó correctamente." & MsgCuentaContable & MensajeCRM, TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatClientes.aspx""") + End If + End If + Else + + Dim NombreCliente As String = "" + + If TxtRFC.Text.Length = 13 AndAlso TxtApellidoPaterno.Text <> "" AndAlso TxtApellidoMaterno.Text <> "" AndAlso TxtNombres.Text <> "" Then + NombreCliente = ($"{TxtNombres.Text} {TxtApellidoPaterno.Text} {TxtApellidoMaterno.Text}").Trim() + Else + NombreCliente = TxtNombre.Text.Trim() + End If + + If ObjClientes.UpdateCliente(NombreCliente, TxtNombreComercial.Text.Trim, TxtDireccion.Text.Trim, TxtNoExt.Text.Trim, TxtNoInt.Text.Trim, TxtColonia.Text.Trim, TxtLocalidad.Text.Trim, TxtCiudad.Text.Trim, TxtEstado.Text.Trim, TxtPais.Text.Trim, TxtRFC.Text.Trim, TxtCP.Text.Trim, + TxtTelefono.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), TxtContacto.Text.Trim, TxtEmail.Text.Trim, TxtEmailCotizacion.Text.Trim, TxtNotificar.Text.Trim, TxtPagina.Text, TxtGiro.Text, DdlPrecioLista.SelectedValue.ToEntero, ChkMail.Checked, TxtRetIVA.Text.ToDouble, TxtRetISR.Text.ToDouble, ChkRetIVAFletesAcarreos.Checked, + ChkEstado.Checked, TxtNombreCorto.Text.Trim, DdlVendedor.SelectedValue.ToEntero, TxtPlazoCobranza.Text.Trim.ToEntero, TxtPlazoCobranzaRemision.Text.Trim.ToEntero, DiasPago, DdlTipoPago.SelectedValue, + DdlCtaContableClientes.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableAnticipos.SelectedValue.ToEntero, DdlCtaContableAnticipos.SelectedItem.Text, DdlCtaContableRetIVA.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableRetISR.SelectedValue.ToEntero, + DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableFondoGarantia.SelectedValue.ToEntero, DdlCtaContableClientes.SelectedItem.Text, DdlCtaContableCompClientes.SelectedValue.ToEntero, DdlCtaContableCompClientes.SelectedItem.Text, DdlCtaContableCompAnticipos.SelectedValue.ToEntero, DdlCtaContableCompAnticipos.SelectedItem.Text, + DdlMonedaExtranjeraClientes.SelectedValue.ToEntero, DdlMonedaExtranjeraClientes.SelectedItem.Text, DdlMonedaExtranjeraAnticipos.SelectedValue.ToEntero, DdlMonedaExtranjeraAnticipos.SelectedItem.Text, + TxtConvenioCIE.Text.Trim, TxtFormaFacturacion.Text.Trim, TxtCodigo.Text.Trim, TxtLimiteCredito.Text.ToDouble, TxtNumCtaPago.Text.Trim, DdlMetodoPago.SelectedValue.ToEntero, ChkAplicaFEMSA.Checked, TxtFEMSA_NumSociedad.Text.Trim, TxtFEMSA_NumProveedor.Text.Trim, TxtFEMA_Mail.Text.Trim, + ChkAplicaDetallista.Checked, TxtDet_GLNComprador.Text.Trim, TxtDet_Departamento.Text.Trim, TxtDet_GLNVendedor.Text.Trim, TxtDet_NumProveedor.Text.Trim, TxtProveedor.Text.Trim, ChkAplicaFord.Checked, TxtFordGSDB.Text.Trim, UsuarioActual.CveUsuario, + CveCliente, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TxtExtension.Text.Trim, TxtTelefonoOtro.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), ChkPermiteCredito.Checked, DdlSubProyecto.SelectedValue.ToEntero, DdlCorporativo.SelectedValue.ToEntero, CveClienteClasificacion:=DdlClasificacion.SelectedValue.ToEntero, CveUsuarioResponsable:=DdlResponsable.SelectedValue.ToEntero, + CveCondicionEntrega:=DdlCondicionesEntrega.SelectedValue.ToEntero, ImprimeNombreSucursal:=ChkMuestraNombre.Checked, CveZonaHoraria:=DdlZonaHoraria.SelectedValue.ToEntero, CobranzaContacto:=TxtCobranzaContacto.Text.Trim, CobranzaTelefono:=TxtCobranzaTelefono.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), CobranzaExt:=TxtCobranzaExt.Text, + CobranzaCorreo:=TxtCobranzaCorreo.Text.Trim, Horario:=TxtHorario.Text.Trim, PortalFacturacion:=TxtPortalFacturacion.Text.Trim, Documentacion:=TxtDocumentacion.Text.Trim, DiasEspecifico:=TxtDiasEspecifico.Text.Trim, UsuarioPortal:=TxtUsuarioPortalFacturacion.Text, ContraseñaPortal:=TxtContraseñaPortalFacturacion.Text, + DiasRevision:=DiasRevision, ObservacionRevsion:=TxtObsDiasRevision.Text.Trim, ReferenciaFiscal:=TxtReferenciaFiscal.Text.Trim, Celular:=TxtCelular.Text.Trim.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), ExtOtros:=TxtExtOtro.Text.Trim, CveUsoCFDI:=DdlUsoCFDI.SelectedValue.ToEntero, CveFormaPago33:=DdlFormaPago33.SelectedValue.ToEntero, CveMetodoPago33:=DdlMetodoPago33.SelectedValue.ToEntero, DesglosaIEPS:=ChkDesglosarIEPS.Checked, + AplicaComercioExterior:=ChkAplicaComercioExterior.Checked, CveTipoOperacion:=DdlTipoOperacion.SelectedValue.ToEntero, CvePedimento:=DdlClavePedimento.SelectedValue.ToEntero, CveIncoterm:=DdlIncoterm.SelectedValue.ToEntero, CvePais:=DdlPais.SelectedValue.ToEntero, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero, + CveMotivoTraslado:=IIf(DdlMotivoTraslado.SelectedValue = "-1", "0", DdlMotivoTraslado.SelectedValue).ToString().ToEntero, NumRegIdTrib:=IIf(TxtNumRegIdTrib.Text = "", "-1", TxtNumRegIdTrib.Text).ToString(), + ComExtEstado:=IIf(TxtComExtEstado.Text = "", "-1", TxtComExtEstado.Text).ToString(), ComExtMunicipio:=IIf(TxtComExtMunicipio.Text = "", "-1", TxtComExtMunicipio.Text).ToString(), ComExtColonia:=IIf(TxtComExtColonia.Text = "", "-1", TxtComExtColonia.Text).ToString(), ApellidoPaternoPF:=IIf(TxtApellidoPaterno.Text = "", "-1", TxtApellidoPaterno.Text).ToString(), ApellidoMaternoPF:=IIf(TxtApellidoMaterno.Text = "", "-1", TxtApellidoMaterno.Text).ToString(), NombresPF:=IIf(TxtNombres.Text = "", "-1", TxtNombres.Text).ToString(), - RequiereOC:=ChkRequiereOC.Checked, LT:=LT, LG:=LG, EsDistribuidor:=ChkEsDistribuidor.Checked, TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CargoUsado:=ChkCargoUsado.Checked, BonificacionUsado:=ChkBonificacionUsado.Checked, CveTipoRetencion:=DdlTipoRetencion.SelectedValue.ToEntero()) Then - - - ObjClientes.LimpiaImpuestosLocales(CveCliente) - - For Each GVR As GridViewRow In GvImpuestosLocales.Rows - If GVR.FCCheckBox("ChkDeduccion").Checked Then - ObjClientes.AddClienteImpuestosLocales(CveCliente, GVR.DataKey("CveImpuestoLocal").ToEntero) - End If - Next - - GuardarDocumentosClientes() - - 'For Each gvr As GridViewRow In GvDocsVentas.Rows - ' 'sino está registrada y se selecciona, se va a insertar - ' If gvr.DataKey("CveDocumentacionElectronica").ToEntero <= 0 Then - ' objDoc.DocumentacionElectronicaAdd(gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, Now, Observacion2:=gvr.FCTextBox("TxtObs2").Text, FechaVigencia:=gvr.FCTextBox("TxtFechaVigencia").Text.ToDate) - ' Else - ' ', Observacion2:=gvr.FCTextBox("TxtObs2").Text - ' objDoc.DocumentacionElectronicaUpdate(gvr.DataKey("CveDocumentacionElectronica").ToEntero, gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, gvr.DataKey("FechaLimite").ToDate, Observacion2:=gvr.FCTextBox("TxtObs2").Text, FechaVigencia:=gvr.FCTextBox("TxtFechaVigencia").Text.ToDate) - ' End If - - ' 'si ya estaba registrada y no se selecciona, se va a insertar - ' If gvr.DataKey("CveDocumentacionElectronica").ToEntero > 0 AndAlso Not gvr.FCCheckBox("ChkDoc").Checked Then - ' objDoc.DocumentacionElectronicaRemove(gvr.DataKey("CveDocumentacionElectronica").ToEntero, -1) - ' End If - - 'Next - - ObjClientes.Commit() - + RequiereOC:=ChkRequiereOC.Checked, LT:=LT, LG:=LG, EsDistribuidor:=ChkEsDistribuidor.Checked, TipoCliente:=DdlTipoCliente.SelectedValue.ToEntero, CargoUsado:=ChkCargoUsado.Checked, BonificacionUsado:=ChkBonificacionUsado.Checked, CveTipoRetencion:=DdlTipoRetencion.SelectedValue.ToEntero()) Then + + + ObjClientes.LimpiaImpuestosLocales(CveCliente) + + For Each GVR As GridViewRow In GvImpuestosLocales.Rows + If GVR.FCCheckBox("ChkDeduccion").Checked Then + ObjClientes.AddClienteImpuestosLocales(CveCliente, GVR.DataKey("CveImpuestoLocal").ToEntero) + End If + Next + + GuardarDocumentosClientes() + + 'For Each gvr As GridViewRow In GvDocsVentas.Rows + ' 'sino está registrada y se selecciona, se va a insertar + ' If gvr.DataKey("CveDocumentacionElectronica").ToEntero <= 0 Then + ' objDoc.DocumentacionElectronicaAdd(gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, Now, Observacion2:=gvr.FCTextBox("TxtObs2").Text, FechaVigencia:=gvr.FCTextBox("TxtFechaVigencia").Text.ToDate) + ' Else + ' ', Observacion2:=gvr.FCTextBox("TxtObs2").Text + ' objDoc.DocumentacionElectronicaUpdate(gvr.DataKey("CveDocumentacionElectronica").ToEntero, gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, gvr.DataKey("FechaLimite").ToDate, Observacion2:=gvr.FCTextBox("TxtObs2").Text, FechaVigencia:=gvr.FCTextBox("TxtFechaVigencia").Text.ToDate) + ' End If + + ' 'si ya estaba registrada y no se selecciona, se va a insertar + ' If gvr.DataKey("CveDocumentacionElectronica").ToEntero > 0 AndAlso Not gvr.FCCheckBox("ChkDoc").Checked Then + ' objDoc.DocumentacionElectronicaRemove(gvr.DataKey("CveDocumentacionElectronica").ToEntero, -1) + ' End If + + 'Next + + ObjClientes.Commit() + Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) - If EstatusAnteriorCliente <> ChkEstado.Checked Then - - Dim DTVendedor As New DataTable + If EstatusAnteriorCliente <> ChkEstado.Checked Then + + Dim DTVendedor As New DataTable DTVendedor = GlobalDTVendedores(UsuarioActual.Empresa.CveEmpresa).FiltraParametros(" CveVendedor = " & DdlVendedor.SelectedValue.ToEntero) Dim ObjVendedores As New ClsVtaVendedores @@ -2575,9 +2575,9 @@ Partial Class Clientes If ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa) Then DtVendedores = ObjVendedores.DtResultados End If - ObjVendedores.Dispose() - - If DTVendedor.Rows.Count > 0 Then + ObjVendedores.Dispose() + + If DTVendedor.Rows.Count > 0 Then Dim _CorreoVendedor As String = DTVendedor(0)("Correo").ToString Dim _CorreoAsistente As String = "" Dim _CorreoCoordinador As String = "" @@ -2586,4295 +2586,4295 @@ Partial Class Clientes If DTVendedor.Rows.Count > 0 Then _CorreoAsistente = DtVendedores.FiltroPrimeroValor("Correo", "CveSuperior = " & DdlVendedor.SelectedValue.ToEntero) _CorreoCoordinador = DtVendedores.FiltroPrimeroValor("Correo", "CveVendedor = " & CveSuperior) - End If - - If (_CorreoVendedor.Length > 0 Or _CorreoAsistente.Length > 0 Or _CorreoCoordinador.Length > 0) And UsuarioActual.Empresa.Funcionalidad(571).ToEntero > 0 Then - - Dim Asunto As String = "" - Dim Para As String = If(_CorreoVendedor.Length > 0, _CorreoVendedor & ";", "") & If(_CorreoAsistente.Length > 0, _CorreoAsistente & ";", "") & _CorreoCoordinador - Dim SBBody As New StringBuilder - - If ChkEstado.Checked Then - Asunto = "Activación de cliente " & TxtNombre.Text - SBBody.Append(String.Format(" Por Medio de la presente se le notifica que el estatus del cliente {0} ha sido activado.", TxtNombre.Text)) - Else - Asunto = "Desactivación de cliente " & TxtNombre.Text - SBBody.Append(String.Format(" Por Medio de la presente se le notifica que el estatus del cliente {0} ha sido desactivado.", TxtNombre.Text)) + End If + + If (_CorreoVendedor.Length > 0 Or _CorreoAsistente.Length > 0 Or _CorreoCoordinador.Length > 0) And UsuarioActual.Empresa.Funcionalidad(571).ToEntero > 0 Then + + Dim Asunto As String = "" + Dim Para As String = If(_CorreoVendedor.Length > 0, _CorreoVendedor & ";", "") & If(_CorreoAsistente.Length > 0, _CorreoAsistente & ";", "") & _CorreoCoordinador + Dim SBBody As New StringBuilder + + If ChkEstado.Checked Then + Asunto = "Activación de cliente " & TxtNombre.Text + SBBody.Append(String.Format(" Por Medio de la presente se le notifica que el estatus del cliente {0} ha sido activado.", TxtNombre.Text)) + Else + Asunto = "Desactivación de cliente " & TxtNombre.Text + SBBody.Append(String.Format(" Por Medio de la presente se le notifica que el estatus del cliente {0} ha sido desactivado.", TxtNombre.Text)) End If - MandaCorreo(Asunto, Para + "", SBBody.ToString) - End If - End If - - End If - - CargaHistorial() - CargaDatos() - UpDatos.Update() + MandaCorreo(Asunto, Para + "", SBBody.ToString) + End If + End If + + End If + + CargaHistorial() + CargaDatos() + UpDatos.Update() UpnHistorial.Update() - End If - End If - ObjClientes.Dispose() - objDoc.Dispose() - RecargaGlobal() - End Sub - -#End Region - - -#Region "G L O B L A L" - Private Sub RecargaGlobal() - 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalDT) - 'Hilo.Start() - GeneraGlobalDT() - End Sub - Private Sub GeneraGlobalDT() - GlobalDTCliente(UsuarioActual.CveEmpresa) = Nothing - 'Dim Objclientes As New ClsClientes - 'If Objclientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus:=-1) Then - ' Application("GlobalDTCliente") = Objclientes.DtResultados - 'End If - 'Objclientes.Dispose() + End If + End If + ObjClientes.Dispose() + objDoc.Dispose() + RecargaGlobal() End Sub -#End Region + +#End Region -#Region "G R I D V I E W S" - Protected Sub GVHistorial_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVHistorial.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - Dim HLSendMail As HtmlAnchor = DirectCast(e.Row.FindControl("HLSendMail"), HtmlAnchor) - 'Dim HLRemision As HtmlAnchor = DirectCast(e.Row.FindControl("HLRemision"), HtmlAnchor) - - - e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right - - - If e.Row.RowIndex = 0 Then - e.Row.BackColor = Drawing.Color.LightGray - HLSendMail.Visible = False - 'HLRemision.Visible = False - End If - - - 'If e.Row.RowIndex > 0 AndAlso e.Row.DBCampo("TipoDocto") <> "Rem" Then - ' HLRemision.Visible = False - 'ElseIf e.Row.RowIndex > 0 AndAlso e.Row.DBCampo("TipoDocto") = "Rem" AndAlso e.Row.DBCampo("CveVentaFacturada") <> String.Empty Then - ' HLRemision.Visible = False - 'End If - 'HLRemision.HRef = $"/Ventas/Ventas.aspx?CveRemision={e.Row.DBCampo("CveVenta")}" - - Dim Liga As String = String.Format("< a class=""Texto"" href=""/Ventas/Ventas.aspx?CveVenta={0}"">", e.Row.DBCampo("CveVenta")) - HLSendMail.HRef = String.Format("javascript:$get('HdnTipoDocto').value='{0}';$get('HdnCveVenta').value='{1}';$get('HdnFolioVenta').value='{2}';$get('TxtParaMail').value='{3}';$get('HdnSerieFolio').value='{4}';$get('HdnSubProyecto').value='{5}';$('#ModalDivMail').modal();", e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("CveVenta"), e.Row.DBCampo("folio"), e.Row.DBCampo("Correo"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("SubProyecto")) - e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("Folio")) - - UpSendMail.Update() - End If - End Sub - Protected Sub GvCxC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxC.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 1 Then - e.Row.Cells(0).Width = Unit.Pixel(60) - e.Row.Cells(1).Width = Unit.Pixel(120) - e.Row.Cells(2).Width = Unit.Pixel(70) - e.Row.Cells(3).Width = Unit.Pixel(80) - e.Row.Cells(4).Width = Unit.Pixel(80) - e.Row.Cells(5).Width = Unit.Pixel(90) - e.Row.Cells(6).Width = Unit.Pixel(90) - e.Row.Cells(7).Width = Unit.Pixel(90) - e.Row.Cells(8).Width = Unit.Pixel(80) - e.Row.Cells(9).Width = Unit.Pixel(70) - End If - - e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Right - - If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(6).ForeColor = Drawing.Color.Red - If e.Row.DBCampo("DiasVencidos").ToDouble > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(4).ForeColor = Drawing.Color.Red - If e.Row.DBCampo("Original").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = "" - If e.Row.DBCampo("Abonado").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = "" - - If e.Row.DBCampo("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = "" - - If e.Row.DBCampo("CveVenta") <> "" Then - e.Row.FCHyperLink("LtlAux").NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=420&width=1000", CveCliente, e.Row.DBCampo("CveVenta")) - e.Row.FCHyperLink("ImgAbonar").NavigateUrl = String.Format("/Bancos/PopIEVentas.aspx?CveVenta={0}&TB_iframe=true&height=550&width=700", e.Row.DBCampo("CveVenta")) - e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("SerieFolio")) - Else - e.Row.FCLiteral("LtlFactura").Text = e.Row.DBCampo("SerieFolio") - e.Row.FCHyperLink("LtlAux").Visible = False - e.Row.BackColor = Drawing.Color.LightGray - e.Row.FCHyperLink("ImgAbonar").Visible = False - End If - - If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 72) Then - e.Row.Cells(9).Visible = True - e.Row.Cells(9).Font.Bold = True - Dim OBjClientes As New ClsClientes - If OBjClientes.GetVisitasCobranza(-1, e.Row.DBCampo("CveVenta").ToEntero, -1) Then - If OBjClientes.DtResultados.Rows.Count > 0 Then - e.Row.FCLinkButton("ImgVisitas").Visible = True - GvVisitas.DataSource = OBjClientes.DtResultados - GvVisitas.DataBind() - Else - e.Row.FCLinkButton("ImgVisitas").Visible = False - End If - End If - OBjClientes.Dispose() - End If - - If UsuarioActual.TienePermisoProceso(100) And e.Row.DBCampo("CveVenta") <> "" Then - e.Row.FCHyperLink("ImgAbonar").Visible = True - Else - e.Row.FCHyperLink("ImgAbonar").Visible = False - End If - - End If - End Sub - Protected Sub GvCxCHistorial_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxCHistorial.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - If e.Row.RowIndex = 1 Then - e.Row.Cells(0).Width = Unit.Pixel(90) - e.Row.Cells(1).Width = Unit.Pixel(125) - e.Row.Cells(2).Width = Unit.Pixel(155) - e.Row.Cells(3).Width = Unit.Pixel(232) - e.Row.Cells(4).Width = Unit.Pixel(302) - e.Row.Cells(5).Width = Unit.Pixel(90) - e.Row.Cells(6).Width = Unit.Pixel(90) - e.Row.Cells(7).Width = Unit.Pixel(90) - End If - e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right - - If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(6).ForeColor = Drawing.Color.Red - If e.Row.DBCampo("DiasVencidos").ToDouble > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(4).ForeColor = Drawing.Color.Red - If e.Row.DBCampo("Original").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = "" - If e.Row.DBCampo("Abonado").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = "" - If e.Row.DBCampo("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = "" - - If e.Row.DBCampo("CveVenta") <> "" Then - e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("SerieFolio")) - Else - e.Row.FCLiteral("LtlFactura").Text = e.Row.DBCampo("SerieFolio") - e.Row.BackColor = Drawing.Color.LightGray - End If - - - End If - End Sub - Protected Sub GVAnticipos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAnticipos.RowDataBound, GVAnticiposHistorial.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - If e.Row.DataKey("ISTotal") = "1" Then - e.Row.FCLiteral("LtlFecha").Text = String.Format("Total {0} ", e.Row.DataKey("Tipo")) - e.Row.BackColor = Drawing.Color.LightGray - End If - - 'If e.Row.DataKey("Saldo").ToDouble < 0 Then e.Row.Cells(2).ForeColor = Drawing.Color.Red - 'If e.Row.DataKey("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAnticipos"), Literal).Text = "" - - If e.Row.RowIndex > -1 Then - If e.Row.DBCampo("Folio") = "N/D" Then - e.Row.FCLiteral("LtlFactura").Text = e.Row.DataKey("Folio") - Else - If e.Row.DataKey("CveIE").ToString.ToEntero > 0 Then - e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DataKey("CveIE"), e.Row.DataKey("Folio")) - Else - e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DataKey("CveVenta"), e.Row.DataKey("Folio")) - End If - End If - End If - - If UsuarioActual.TienePermisoProceso(247) Then - If CType(sender, GridView).ID = "GVAnticipos" And e.Row.DBCampo("CveVenta").ToEntero > 0 And e.Row.DBCampo("Tipo") = "NC" Then - Dim Parametros = Encripta($"CveVenta={e.Row.DBCampo("CveVenta").ToEntero}&SerieFolio={e.Row.DBCampo("Folio")}&CveMoneda={e.Row.DBCampo("CveMoneda")}&CveCliente={CveCliente}&Saldo={e.Row.DBCampo("Saldo")}&Original={e.Row.DBCampo("Original")}&CvePrePoliza={e.Row.DBCampo("CvePrePoliza")}") - e.Row.FCHyperLink("HLDevolverDinero").Visible = True - e.Row.FCHyperLink("HLDevolverDinero").NavigateUrl = $"/Bancos/IE.aspx?Opcion=DevDinV&P={Parametros}" - End If - End If - - End If - End Sub -#End Region - -#Region "R H" - - Private Sub CargaPersonalAsignado() - Dim ObjPersonal As New ClsRH - If ObjPersonal.GetPersonal(-1, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, CveCliente, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then - GVPersonal.DataSource = ObjPersonal.DtResultados - Else - GVPersonal.DataSource = Nothing - End If - ObjPersonal.Dispose() - GVPersonal.DataBind() - End Sub - - Protected Sub GVPersonal_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVPersonal.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - e.Row.Cells(0).Width = Unit.Pixel(70) - e.Row.Cells(1).Width = Unit.Pixel(300) - e.Row.Cells(2).Width = Unit.Pixel(80) - e.Row.Cells(3).Width = Unit.Pixel(80) - e.Row.Cells(4).Width = Unit.Pixel(120) - e.Row.Cells(5).Width = Unit.Pixel(120) - e.Row.Cells(6).Width = Unit.Pixel(60) - End If - e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left - e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left - e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left - e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Left - e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Left - - Dim Liga As String = "" - e.Row.FCLiteral("LtlCodigo").Text = Liga & e.Row.FCLiteral("LtlCodigo").Text & "" - e.Row.FCLiteral("LtlPersonal").Text = Liga & e.Row.FCLiteral("LtlPersonal").Text & "" - End If - End Sub - - Protected Sub BtnConsultarAsistencia_Click(sender As Object, e As System.EventArgs) Handles BtnConsultarAsistencia.Click - Dim objpersonal As New ClsRH - If objpersonal.GetAsistencias(-1, CveCliente, -1, -1, -1, 1, txtFechaI.Text.Trim.ToDate, txtFechaF.Text.Trim.ToDate, UsuarioActual.CveEmpresa) Then - GVAsistencia.DataSource = objpersonal.DtResultados.FiltraParametros("Fecha IS NOT NULL") - Else - GVAsistencia.DataSource = Nothing - End If - objpersonal.Dispose() - GVAsistencia.DataBind() - UpDatos.Update() - End Sub - - Protected Sub GVAsistencia_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAsistencia.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - If e.Row.RowIndex = 0 Then - e.Row.Cells(0).Width = Unit.Pixel(75) - e.Row.Cells(1).Width = Unit.Pixel(145) - e.Row.Cells(2).Width = Unit.Pixel(70) - e.Row.Cells(3).Width = Unit.Pixel(100) - e.Row.Cells(4).Width = Unit.Pixel(100) - e.Row.Cells(5).Width = Unit.Pixel(145) - e.Row.Cells(6).Width = Unit.Pixel(220) - End If - - e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left - e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Left - e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Left - - If IsDate(e.Row.DBCampo("Fecha")) Then e.Row.FCLiteral("LtlFecha").Text = e.Row.DBCampo("Fecha").ToDate.ToShortDateString - - If e.Row.DBCampo("SeModifico") = "0" Then - e.Row.BackColor = Drawing.Color.LightBlue - ElseIf e.Row.DBCampo("SeModifico") = "1" Then - e.Row.ForeColor = Drawing.Color.Red - End If - - End If - End Sub -#End Region - -#Region "S U C U R S A L E S" - Private Sub LbAgregarSucursal_Click(sender As Object, e As EventArgs) Handles LbAgregarSucursal.Click - ChkEstatusSucursal.Checked = True - DivEstatusSucursal.Visible = False - TxtNumeroCuenta.Text = "" - DdlMetodoPagoSucursal.SelectedIndex = 0 - UpAgregarSucursal.Update() - Me.CveClienteSuc = -1 - Me.Actualizar = False - txtLg.Text = "" - txtLt.Text = "" - HDMAPOP.Value = "2" - - UpModalDivMapa.Update() - - - RegistraScript("showDivEC();") - End Sub - Public Function CargaSucursalesCliente() As Boolean - Dim Retorno As Boolean = False - Dim ObjCliente As New ClsClientes - If ObjCliente.GetSucursales(CveCliente) Then - ViewState("DTSucursalesCliente") = ObjCliente.DtResultados - Retorno = True - Else - ViewState("DTSucursalesCliente") = Nothing - Me.GVSucursales.DataSource = Nothing - End If - - ObjCliente.Dispose() - - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString(), 0) - Else - CargaGrid("", 0) - End If - Return Retorno - End Function - Protected Sub BtnAgregar_Click(sender As Object, e As System.EventArgs) Handles BtnAgregarSucursal.Click - Dim ObjCliente As New ClsClientes - - Dim LT As String = If(txtLt.Text.ToDouble <> 0, txtLt.Text, "0") - Dim LG As String = If(txtLg.Text.ToDouble <> 0, txtLg.Text, "0") - - If CveCliente > 0 Then - If Actualizar Then - - - Dim Estatus As Boolean = ChkEstatusSucursal.Checked - - - - If ObjCliente.UpdateSucursal(TxtNombreSucursal.Text.Trim, Estatus, CveCliente, CveClienteSuc, TxtCiudadSucursal.Text.Trim, TxtColoniaSucursal.Text.Trim, TxtCPSucursal.Text.Trim, TxtDireccionSucursal.Text.Trim, TxtEstadoSucursal.Text.Trim, TxtLocalidadSucursal.Text.Trim, TxtPaisSucursal.Text.Trim, TxtNumExtSucursal.Text.Trim, TxtNumIntSucursal.Text.Trim, - TxtTelefonoSucursal.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), TxtCorreoSucursal.Text.Trim, TxtCorreoSucursalCotizacion.Text.Trim, TxtContactoSucursal.Text.Trim, DdlVendedorSucursal.SelectedValue.ToEntero, TxtNumeroCuenta.Text, DdlMetodoPagoSucursal.SelectedValue.ToEntero, TxtLimiteCreditoSucursal.Text.ToDecimal, DdlResponsableSucursal.SelectedValue.ToEntero, - DdlSucursalUsoCFDI.SelectedValue.ToEntero, DdlSucursalFormaPago33.SelectedValue.ToEntero, DdlSucursalMetodoPago33.SelectedValue.ToEntero, LT:=LT, LG:=LG) Then - GVSucursales.EditIndex = -1 - ViewState("DTSucursalesCliente") = ObjCliente.DtResultados - Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) - End If - ObjCliente.Dispose() - - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString(), 0) - Else - CargaGrid("", 0) - End If - - Else - If ObjCliente.AddSucursal(CveCliente, TxtNombreSucursal.Text.Trim, UsuarioActual.CveUsuario, TxtCiudadSucursal.Text.Trim, TxtColoniaSucursal.Text.Trim, TxtCPSucursal.Text.Trim, TxtDireccionSucursal.Text.Trim, TxtEstadoSucursal.Text.Trim, TxtLocalidadSucursal.Text.Trim, TxtPaisSucursal.Text.Trim, TxtNumExtSucursal.Text.Trim, TxtNumIntSucursal.Text.Trim, TxtTelefonoSucursal.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", ""), TxtCorreoSucursal.Text.Trim, TxtCorreoSucursalCotizacion.Text.Trim, TxtContactoSucursal.Text.Trim, - DdlVendedorSucursal.SelectedValue.ToEntero, TxtNumeroCuenta.Text, DdlMetodoPagoSucursal.SelectedValue.ToEntero, TxtLimiteCreditoSucursal.Text.ToDecimal, DdlResponsableSucursal.SelectedValue.ToEntero, - DdlSucursalUsoCFDI.SelectedValue.ToEntero, DdlSucursalFormaPago33.SelectedValue.ToEntero, DdlSucursalMetodoPago33.SelectedValue.ToEntero, LT:=LT, LG:=LG) Then - TxtNombreSucursal.Text = "" - TxtCiudadSucursal.Text = "" - TxtColoniaSucursal.Text = "" - TxtCPSucursal.Text = "" - TxtDireccionSucursal.Text = "" - TxtEstadoSucursal.Text = "" - TxtLocalidadSucursal.Text = "" - TxtPaisSucursal.Text = "" - TxtNumExtSucursal.Text = "" - TxtNumIntSucursal.Text = "" - TxtTelefonoSucursal.Text = "" - TxtCorreoSucursal.Text = "" - TxtCorreoSucursalCotizacion.Text = "" - TxtContactoSucursal.Text = "" - DdlVendedorSucursal.SelectedIndex = 0 - DdlMetodoPagoSucursal.SelectedIndex = 0 - TxtNumeroCuenta.Text = "" - TxtLimiteCreditoSucursal.Text = "" - DdlResponsableSucursal.SelectedIndex = 0 - DdlSucursalUsoCFDI.SelectedIndex = 0 - DdlSucursalFormaPago33.SelectedIndex = 0 - DdlSucursalMetodoPago33.SelectedIndex = 0 - Alert("La nueva Sucursal del Cliente se guardó correctamente.", TipoMensaje.MsgInformacion) - ViewState("DTSucursalesCliente") = ObjCliente.DtResultados - - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString(), 0) - Else - CargaGrid("", 0) - End If - End If - End If - - Else - AddSucursalTemp() - End If - - txtLg.Text = "" - txtLt.Text = "" - - UpModalDivMapa.Update() - - - UpAgregarSucursal.Update() - CargaDdlSucursalCliente() - ObjCliente.Dispose() - +#Region "G L O B L A L" + Private Sub RecargaGlobal() + 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalDT) + 'Hilo.Start() + GeneraGlobalDT() + End Sub + Private Sub GeneraGlobalDT() + GlobalDTCliente(UsuarioActual.CveEmpresa) = Nothing + 'Dim Objclientes As New ClsClientes + 'If Objclientes.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, -1, Estatus:=-1) Then + ' Application("GlobalDTCliente") = Objclientes.DtResultados + 'End If + 'Objclientes.Dispose() + End Sub +#End Region + + +#Region "G R I D V I E W S" + Protected Sub GVHistorial_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVHistorial.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim HLSendMail As HtmlAnchor = DirectCast(e.Row.FindControl("HLSendMail"), HtmlAnchor) + 'Dim HLRemision As HtmlAnchor = DirectCast(e.Row.FindControl("HLRemision"), HtmlAnchor) + + + e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right + + + If e.Row.RowIndex = 0 Then + e.Row.BackColor = Drawing.Color.LightGray + HLSendMail.Visible = False + 'HLRemision.Visible = False + End If + + + 'If e.Row.RowIndex > 0 AndAlso e.Row.DBCampo("TipoDocto") <> "Rem" Then + ' HLRemision.Visible = False + 'ElseIf e.Row.RowIndex > 0 AndAlso e.Row.DBCampo("TipoDocto") = "Rem" AndAlso e.Row.DBCampo("CveVentaFacturada") <> String.Empty Then + ' HLRemision.Visible = False + 'End If + 'HLRemision.HRef = $"/Ventas/Ventas.aspx?CveRemision={e.Row.DBCampo("CveVenta")}" + + Dim Liga As String = String.Format("< a class=""Texto"" href=""/Ventas/Ventas.aspx?CveVenta={0}"">", e.Row.DBCampo("CveVenta")) + HLSendMail.HRef = String.Format("javascript:$get('HdnTipoDocto').value='{0}';$get('HdnCveVenta').value='{1}';$get('HdnFolioVenta').value='{2}';$get('TxtParaMail').value='{3}';$get('HdnSerieFolio').value='{4}';$get('HdnSubProyecto').value='{5}';$('#ModalDivMail').modal();", e.Row.DBCampo("TipoDocto"), e.Row.DBCampo("CveVenta"), e.Row.DBCampo("folio"), e.Row.DBCampo("Correo"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("SubProyecto")) + e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("Folio")) + + UpSendMail.Update() + End If + End Sub + Protected Sub GvCxC_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxC.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.RowIndex = 1 Then + e.Row.Cells(0).Width = Unit.Pixel(60) + e.Row.Cells(1).Width = Unit.Pixel(120) + e.Row.Cells(2).Width = Unit.Pixel(70) + e.Row.Cells(3).Width = Unit.Pixel(80) + e.Row.Cells(4).Width = Unit.Pixel(80) + e.Row.Cells(5).Width = Unit.Pixel(90) + e.Row.Cells(6).Width = Unit.Pixel(90) + e.Row.Cells(7).Width = Unit.Pixel(90) + e.Row.Cells(8).Width = Unit.Pixel(80) + e.Row.Cells(9).Width = Unit.Pixel(70) + End If + + e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Right + + If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(6).ForeColor = Drawing.Color.Red + If e.Row.DBCampo("DiasVencidos").ToDouble > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(4).ForeColor = Drawing.Color.Red + If e.Row.DBCampo("Original").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = "" + If e.Row.DBCampo("Abonado").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = "" + + If e.Row.DBCampo("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = "" + + If e.Row.DBCampo("CveVenta") <> "" Then + e.Row.FCHyperLink("LtlAux").NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=420&width=1000", CveCliente, e.Row.DBCampo("CveVenta")) + e.Row.FCHyperLink("ImgAbonar").NavigateUrl = String.Format("/Bancos/PopIEVentas.aspx?CveVenta={0}&TB_iframe=true&height=550&width=700", e.Row.DBCampo("CveVenta")) + e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("SerieFolio")) + Else + e.Row.FCLiteral("LtlFactura").Text = e.Row.DBCampo("SerieFolio") + e.Row.FCHyperLink("LtlAux").Visible = False + e.Row.BackColor = Drawing.Color.LightGray + e.Row.FCHyperLink("ImgAbonar").Visible = False + End If + + If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 72) Then + e.Row.Cells(9).Visible = True + e.Row.Cells(9).Font.Bold = True + Dim OBjClientes As New ClsClientes + If OBjClientes.GetVisitasCobranza(-1, e.Row.DBCampo("CveVenta").ToEntero, -1) Then + If OBjClientes.DtResultados.Rows.Count > 0 Then + e.Row.FCLinkButton("ImgVisitas").Visible = True + GvVisitas.DataSource = OBjClientes.DtResultados + GvVisitas.DataBind() + Else + e.Row.FCLinkButton("ImgVisitas").Visible = False + End If + End If + OBjClientes.Dispose() + End If + + If UsuarioActual.TienePermisoProceso(100) And e.Row.DBCampo("CveVenta") <> "" Then + e.Row.FCHyperLink("ImgAbonar").Visible = True + Else + e.Row.FCHyperLink("ImgAbonar").Visible = False + End If + + End If + End Sub + Protected Sub GvCxCHistorial_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCxCHistorial.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.RowIndex = 1 Then + e.Row.Cells(0).Width = Unit.Pixel(90) + e.Row.Cells(1).Width = Unit.Pixel(125) + e.Row.Cells(2).Width = Unit.Pixel(155) + e.Row.Cells(3).Width = Unit.Pixel(232) + e.Row.Cells(4).Width = Unit.Pixel(302) + e.Row.Cells(5).Width = Unit.Pixel(90) + e.Row.Cells(6).Width = Unit.Pixel(90) + e.Row.Cells(7).Width = Unit.Pixel(90) + End If + e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Right + + If e.Row.DBCampo("Saldo").ToDouble < 0 Then e.Row.Cells(6).ForeColor = Drawing.Color.Red + If e.Row.DBCampo("DiasVencidos").ToDouble > 0 AndAlso CType(sender, GridView).ID = "GvCxC" Then e.Row.Cells(4).ForeColor = Drawing.Color.Red + If e.Row.DBCampo("Original").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldoOriginal"), Literal).Text = "" + If e.Row.DBCampo("Abonado").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAbonado"), Literal).Text = "" + If e.Row.DBCampo("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlSaldo"), Literal).Text = "" + + If e.Row.DBCampo("CveVenta") <> "" Then + e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("SerieFolio")) + Else + e.Row.FCLiteral("LtlFactura").Text = e.Row.DBCampo("SerieFolio") + e.Row.BackColor = Drawing.Color.LightGray + End If + + + End If + End Sub + Protected Sub GVAnticipos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAnticipos.RowDataBound, GVAnticiposHistorial.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DataKey("ISTotal") = "1" Then + e.Row.FCLiteral("LtlFecha").Text = String.Format("Total {0} ", e.Row.DataKey("Tipo")) + e.Row.BackColor = Drawing.Color.LightGray + End If + + 'If e.Row.DataKey("Saldo").ToDouble < 0 Then e.Row.Cells(2).ForeColor = Drawing.Color.Red + 'If e.Row.DataKey("Saldo").ToDouble = 0 Then DirectCast(e.Row.FindControl("LtlAnticipos"), Literal).Text = "" + + If e.Row.RowIndex > -1 Then + If e.Row.DBCampo("Folio") = "N/D" Then + e.Row.FCLiteral("LtlFactura").Text = e.Row.DataKey("Folio") + Else + If e.Row.DataKey("CveIE").ToString.ToEntero > 0 Then + e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DataKey("CveIE"), e.Row.DataKey("Folio")) + Else + e.Row.FCLiteral("LtlFactura").Text = String.Format("{1}", e.Row.DataKey("CveVenta"), e.Row.DataKey("Folio")) + End If + End If + End If + + If UsuarioActual.TienePermisoProceso(247) Then + If CType(sender, GridView).ID = "GVAnticipos" And e.Row.DBCampo("CveVenta").ToEntero > 0 And e.Row.DBCampo("Tipo") = "NC" Then + Dim Parametros = Encripta($"CveVenta={e.Row.DBCampo("CveVenta").ToEntero}&SerieFolio={e.Row.DBCampo("Folio")}&CveMoneda={e.Row.DBCampo("CveMoneda")}&CveCliente={CveCliente}&Saldo={e.Row.DBCampo("Saldo")}&Original={e.Row.DBCampo("Original")}&CvePrePoliza={e.Row.DBCampo("CvePrePoliza")}") + e.Row.FCHyperLink("HLDevolverDinero").Visible = True + e.Row.FCHyperLink("HLDevolverDinero").NavigateUrl = $"/Bancos/IE.aspx?Opcion=DevDinV&P={Parametros}" + End If + End If + + End If + End Sub +#End Region + +#Region "R H" + + Private Sub CargaPersonalAsignado() + Dim ObjPersonal As New ClsRH + If ObjPersonal.GetPersonal(-1, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, CveCliente, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then + GVPersonal.DataSource = ObjPersonal.DtResultados + Else + GVPersonal.DataSource = Nothing + End If + ObjPersonal.Dispose() + GVPersonal.DataBind() + End Sub + + Protected Sub GVPersonal_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVPersonal.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.RowIndex = 0 Then + e.Row.Cells(0).Width = Unit.Pixel(70) + e.Row.Cells(1).Width = Unit.Pixel(300) + e.Row.Cells(2).Width = Unit.Pixel(80) + e.Row.Cells(3).Width = Unit.Pixel(80) + e.Row.Cells(4).Width = Unit.Pixel(120) + e.Row.Cells(5).Width = Unit.Pixel(120) + e.Row.Cells(6).Width = Unit.Pixel(60) + End If + e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left + e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left + e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left + e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Left + e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Left + + Dim Liga As String = "" + e.Row.FCLiteral("LtlCodigo").Text = Liga & e.Row.FCLiteral("LtlCodigo").Text & "" + e.Row.FCLiteral("LtlPersonal").Text = Liga & e.Row.FCLiteral("LtlPersonal").Text & "" + End If + End Sub + + Protected Sub BtnConsultarAsistencia_Click(sender As Object, e As System.EventArgs) Handles BtnConsultarAsistencia.Click + Dim objpersonal As New ClsRH + If objpersonal.GetAsistencias(-1, CveCliente, -1, -1, -1, 1, txtFechaI.Text.Trim.ToDate, txtFechaF.Text.Trim.ToDate, UsuarioActual.CveEmpresa) Then + GVAsistencia.DataSource = objpersonal.DtResultados.FiltraParametros("Fecha IS NOT NULL") + Else + GVAsistencia.DataSource = Nothing + End If + objpersonal.Dispose() + GVAsistencia.DataBind() + UpDatos.Update() + End Sub + + Protected Sub GVAsistencia_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVAsistencia.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.RowIndex = 0 Then + e.Row.Cells(0).Width = Unit.Pixel(75) + e.Row.Cells(1).Width = Unit.Pixel(145) + e.Row.Cells(2).Width = Unit.Pixel(70) + e.Row.Cells(3).Width = Unit.Pixel(100) + e.Row.Cells(4).Width = Unit.Pixel(100) + e.Row.Cells(5).Width = Unit.Pixel(145) + e.Row.Cells(6).Width = Unit.Pixel(220) + End If + + e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left + e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Left + e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Left + + If IsDate(e.Row.DBCampo("Fecha")) Then e.Row.FCLiteral("LtlFecha").Text = e.Row.DBCampo("Fecha").ToDate.ToShortDateString + + If e.Row.DBCampo("SeModifico") = "0" Then + e.Row.BackColor = Drawing.Color.LightBlue + ElseIf e.Row.DBCampo("SeModifico") = "1" Then + e.Row.ForeColor = Drawing.Color.Red + End If + + End If + End Sub +#End Region + +#Region "S U C U R S A L E S" + Private Sub LbAgregarSucursal_Click(sender As Object, e As EventArgs) Handles LbAgregarSucursal.Click + ChkEstatusSucursal.Checked = True + DivEstatusSucursal.Visible = False + TxtNumeroCuenta.Text = "" + DdlMetodoPagoSucursal.SelectedIndex = 0 + UpAgregarSucursal.Update() + Me.CveClienteSuc = -1 + Me.Actualizar = False + txtLg.Text = "" + txtLt.Text = "" + HDMAPOP.Value = "2" + + UpModalDivMapa.Update() + + + RegistraScript("showDivEC();") + End Sub + Public Function CargaSucursalesCliente() As Boolean + Dim Retorno As Boolean = False + Dim ObjCliente As New ClsClientes + If ObjCliente.GetSucursales(CveCliente) Then + ViewState("DTSucursalesCliente") = ObjCliente.DtResultados + Retorno = True + Else + ViewState("DTSucursalesCliente") = Nothing + Me.GVSucursales.DataSource = Nothing + End If + + ObjCliente.Dispose() + + If ViewState("Orden").ToString() <> String.Empty Then + CargaGrid(ViewState("Orden").ToString(), 0) + Else + CargaGrid("", 0) + End If + Return Retorno + End Function + Protected Sub BtnAgregar_Click(sender As Object, e As System.EventArgs) Handles BtnAgregarSucursal.Click + Dim ObjCliente As New ClsClientes + + Dim LT As String = If(txtLt.Text.ToDouble <> 0, txtLt.Text, "0") + Dim LG As String = If(txtLg.Text.ToDouble <> 0, txtLg.Text, "0") + + If CveCliente > 0 Then + If Actualizar Then + + + Dim Estatus As Boolean = ChkEstatusSucursal.Checked + + + + If ObjCliente.UpdateSucursal(TxtNombreSucursal.Text.Trim, Estatus, CveCliente, CveClienteSuc, TxtCiudadSucursal.Text.Trim, TxtColoniaSucursal.Text.Trim, TxtCPSucursal.Text.Trim, TxtDireccionSucursal.Text.Trim, TxtEstadoSucursal.Text.Trim, TxtLocalidadSucursal.Text.Trim, TxtPaisSucursal.Text.Trim, TxtNumExtSucursal.Text.Trim, TxtNumIntSucursal.Text.Trim, + TxtTelefonoSucursal.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", ""), TxtCorreoSucursal.Text.Trim, TxtCorreoSucursalCotizacion.Text.Trim, TxtContactoSucursal.Text.Trim, DdlVendedorSucursal.SelectedValue.ToEntero, TxtNumeroCuenta.Text, DdlMetodoPagoSucursal.SelectedValue.ToEntero, TxtLimiteCreditoSucursal.Text.ToDecimal, DdlResponsableSucursal.SelectedValue.ToEntero, + DdlSucursalUsoCFDI.SelectedValue.ToEntero, DdlSucursalFormaPago33.SelectedValue.ToEntero, DdlSucursalMetodoPago33.SelectedValue.ToEntero, LT:=LT, LG:=LG) Then + GVSucursales.EditIndex = -1 + ViewState("DTSucursalesCliente") = ObjCliente.DtResultados + Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) + End If + ObjCliente.Dispose() + + If ViewState("Orden").ToString() <> String.Empty Then + CargaGrid(ViewState("Orden").ToString(), 0) + Else + CargaGrid("", 0) + End If + + Else + If ObjCliente.AddSucursal(CveCliente, TxtNombreSucursal.Text.Trim, UsuarioActual.CveUsuario, TxtCiudadSucursal.Text.Trim, TxtColoniaSucursal.Text.Trim, TxtCPSucursal.Text.Trim, TxtDireccionSucursal.Text.Trim, TxtEstadoSucursal.Text.Trim, TxtLocalidadSucursal.Text.Trim, TxtPaisSucursal.Text.Trim, TxtNumExtSucursal.Text.Trim, TxtNumIntSucursal.Text.Trim, TxtTelefonoSucursal.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", ""), TxtCorreoSucursal.Text.Trim, TxtCorreoSucursalCotizacion.Text.Trim, TxtContactoSucursal.Text.Trim, + DdlVendedorSucursal.SelectedValue.ToEntero, TxtNumeroCuenta.Text, DdlMetodoPagoSucursal.SelectedValue.ToEntero, TxtLimiteCreditoSucursal.Text.ToDecimal, DdlResponsableSucursal.SelectedValue.ToEntero, + DdlSucursalUsoCFDI.SelectedValue.ToEntero, DdlSucursalFormaPago33.SelectedValue.ToEntero, DdlSucursalMetodoPago33.SelectedValue.ToEntero, LT:=LT, LG:=LG) Then + TxtNombreSucursal.Text = "" + TxtCiudadSucursal.Text = "" + TxtColoniaSucursal.Text = "" + TxtCPSucursal.Text = "" + TxtDireccionSucursal.Text = "" + TxtEstadoSucursal.Text = "" + TxtLocalidadSucursal.Text = "" + TxtPaisSucursal.Text = "" + TxtNumExtSucursal.Text = "" + TxtNumIntSucursal.Text = "" + TxtTelefonoSucursal.Text = "" + TxtCorreoSucursal.Text = "" + TxtCorreoSucursalCotizacion.Text = "" + TxtContactoSucursal.Text = "" + DdlVendedorSucursal.SelectedIndex = 0 + DdlMetodoPagoSucursal.SelectedIndex = 0 + TxtNumeroCuenta.Text = "" + TxtLimiteCreditoSucursal.Text = "" + DdlResponsableSucursal.SelectedIndex = 0 + DdlSucursalUsoCFDI.SelectedIndex = 0 + DdlSucursalFormaPago33.SelectedIndex = 0 + DdlSucursalMetodoPago33.SelectedIndex = 0 + Alert("La nueva Sucursal del Cliente se guardó correctamente.", TipoMensaje.MsgInformacion) + ViewState("DTSucursalesCliente") = ObjCliente.DtResultados + + If ViewState("Orden").ToString() <> String.Empty Then + CargaGrid(ViewState("Orden").ToString(), 0) + Else + CargaGrid("", 0) + End If + End If + End If + + Else + AddSucursalTemp() + End If + + txtLg.Text = "" + txtLt.Text = "" + + UpModalDivMapa.Update() + + + UpAgregarSucursal.Update() + CargaDdlSucursalCliente() + ObjCliente.Dispose() + Me.Actualizar = False Me.CveClienteSuc = -1 RegistraScript("hideDivEC();") - End Sub - Protected Sub LnkAgragarDireccion_Click(sender As Object, e As EventArgs) - - txtLg.Text = "0" - txtLt.Text = "0" - - RegistraScript("muestraMapa();") - HDMAPOP.Value = "1" - - UpModalDivMapa.Update() - - End Sub -#Region "G V S U C U R S A L E S" - Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVSucursales.RowDataBound - - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - ' e.Row.Cells(0).Width = Unit.Pixel(150) - e.Row.Cells(1).Width = Unit.Pixel(40) - e.Row.Cells(2).Width = Unit.Pixel(40) - End If - e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left - - - - If Not CveCliente > 0 Then - e.Row.Cells(3).Visible = False - End If - End If - - End Sub - - Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVSucursales.RowDeleting - Dim ObjCliente As New ClsClientes - - If CveCliente > 0 Then - If ObjCliente.RemoveSucursal(CveCliente, GVSucursales.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then - GVSucursales.EditIndex = -1 - ViewState("DTSucursalesCliente") = ObjCliente.DtResultados - Alert("La Sucursal del Cliente se eliminó correctamente.", TipoMensaje.MsgInformacion) - End If - Else - TempDTSucursales.Rows.RemoveAt(e.RowIndex) - TempDTSucursales.AcceptChanges() - GVSucursales.DataSource = TempDTSucursales - GVSucursales.DataBind() - UpDatos.Update() - End If - - ObjCliente.Dispose() - End Sub - Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GVSucursales.RowCancelingEdit - GVSucursales.EditIndex = -1 - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString(), 0) - Else - CargaGrid("", 0) - End If - End Sub - Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GVSucursales.RowUpdating - - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString(), 0) - Else - CargaGrid("", 0) - End If - - End Sub - Protected Sub GvDatos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GVSucursales.RowEditing - - Me.Actualizar = True - Me.CveClienteSuc = GVSucursales.DataKeys(e.NewEditIndex).Value.ToString.ToEntero - - - Dim ObjCliente As New ClsClientes - - If ObjCliente.GetSucursales(CveCliente, CveClienteSuc) Then - - DivEstatusSucursal.Visible = True - TxtNombreSucursal.Text = ObjCliente.DtResultados.Rows(0)("SucursalCliente").ToString - ChkEstatusSucursal.Checked = If(ObjCliente.DtResultados.Rows(0)("Estatus").ToString = "Activo", True, False) - TxtCiudadSucursal.Text = ObjCliente.DtResultados.Rows(0)("Ciudad").ToString - TxtColoniaSucursal.Text = ObjCliente.DtResultados.Rows(0)("Colonia").ToString - TxtCPSucursal.Text = ObjCliente.DtResultados.Rows(0)("CP").ToString - TxtDireccionSucursal.Text = ObjCliente.DtResultados.Rows(0)("Direccion").ToString - TxtEstadoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Estado").ToString - TxtLocalidadSucursal.Text = ObjCliente.DtResultados.Rows(0)("Localidad").ToString - TxtPaisSucursal.Text = ObjCliente.DtResultados.Rows(0)("Pais").ToString - TxtNumExtSucursal.Text = ObjCliente.DtResultados.Rows(0)("NoExt").ToString - TxtNumIntSucursal.Text = ObjCliente.DtResultados.Rows(0)("NoInt").ToString - TxtTelefonoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Telefono").ToString - TxtCorreoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Correo").ToString - TxtCorreoSucursalCotizacion.Text = ObjCliente.DtResultados(0)("CorreoCotizacion").ToString - TxtContactoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Contacto").ToString - DdlVendedorSucursal.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveVendedor").ToString) - DdlMetodoPagoSucursal.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveMetodoPago").ToString) - TxtNumeroCuenta.Text = ObjCliente.DtResultados.Rows(0)("NumCtaPago").ToString - LblUsuarioSucursal.Text = String.Format("Usuario Registró: {0}", ObjCliente.DtResultados.Rows(0)("Usuario").ToString) - LblFechaSucursal.Text = String.Format("Fecha de Registro: {0}", ObjCliente.DtResultados.Rows(0)("FechaIng").ToString.ToDate.ToShortDateString) - TxtLimiteCreditoSucursal.Text = ObjCliente.DtResultados.Rows(0)("LimiteCredito").ToString.FormatoNumero - DdlResponsableSucursal.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveResponsableCobranza").ToString) - - DdlSucursalUsoCFDI.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveUsoCFDI").ToString) - DdlSucursalMetodoPago33.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveMetodoPago33").ToString) - DdlSucursalFormaPago33.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveFormaPago33").ToString) - - txtLg.Text = ObjCliente.DtResultados.Rows(0)("LG").ToString - txtLt.Text = ObjCliente.DtResultados.Rows(0)("LT").ToString - HDMAPOP.Value = "2" - - - UpAgregarSucursal.Update() - UpModalDivMapa.Update() - - 'Dim scriptReg As String = $" SelTxtLat = '#{ GVSucursales.Rows(e.NewEditIndex).FCTextBox("txtLt").ClientID}'; SelTxtLon = '#{ GVSucursales.Rows(e.NewEditIndex).FCTextBox("txtLg").ClientID}''" - 'RegistraScript("$('#divAgregarSucursal').modal();" & scriptReg) - - RegistraScript("$('#divAgregarSucursal').modal();") - - Else - Alert("No se pudieron cargar los datos de la sucursal") - End If - - ObjCliente.Dispose() - - If ViewState("Orden").ToString() <> String.Empty Then - CargaGrid(ViewState("Orden").ToString(), 0) - Else - CargaGrid("", 0) - End If - End Sub -#End Region - -#Region "G V U S U A R I O S P O R T A L" - Protected Sub GvUsuariosPortal_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvUsuariosPortal.RowCommand - If e.CommandName = "RestablecerContraseña" Then - Dim cveUsuarioPortal As Integer = e.CommandArgument.ToString.ToEntero - Dim Usuario As New ClsSisUsuarios - If Usuario.GetUsuariosPortal(cveUsuarioPortal, -1, -1) Then - Dim dr As DataRow = Usuario.DtResultados.FiltroPrimero("") - - If Usuario.UpdateUsuarioPortal(dr("Usuario").ToString, dr("Nombre").ToString, dr("Correo").ToString, CType(dr("Estatus"), Boolean), ContraseñaPredeterminadaEncriptada, CveCliente, -1, cveUsuarioPortal, UsuarioActual.CveUsuario) Then - - GvUsuariosPortal.EditIndex = -1 - ViewState("DTUsuariosCliente") = Usuario.DtResultados.FiltraParametros("Usuario <> 'Admin'") - Alert("Contraseña Restablecida.
    La nueva contraseña es: """ & ContraseñaPredeterminada & "", TipoMensaje.MsgInformacion) - End If - - End If - - Usuario.Dispose() - - End If - End Sub - - Protected Sub GvUsuariosPortal_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvUsuariosPortal.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - If e.Row.RowIndex = 0 Then - ''e.Row.Cells(0).Width = Unit.Pixel(180) - ''e.Row.Cells(1).Width = Unit.Pixel(180) - ''e.Row.Cells(2).Width = Unit.Pixel(180) - - ''e.Row.Cells(3).Width = Unit.Pixel(50) - ''e.Row.Cells(4).Width = Unit.Pixel(50) - ''e.Row.Cells(5).Width = Unit.Pixel(50) - ''e.Row.Cells(6).Width = Unit.Pixel(50) - ''e.Row.Cells(7).Width = Unit.Pixel(50) - ''e.Row.Cells(8).Width = Unit.Pixel(50) - ''e.Row.Cells(9).Width = Unit.Pixel(50) - ''e.Row.Cells(10).Width = Unit.Pixel(50) - ''e.Row.Cells(11).Width = Unit.Pixel(50) - ''e.Row.Cells(12).Width = Unit.Pixel(45) - - ''e.Row.Cells(3).Width = Unit.Pixel(68) - ''e.Row.Cells(4).Width = Unit.Pixel(70) - ''e.Row.Cells(5).Width = Unit.Pixel(130) - End If - - If e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal Then - If e.Row.DBCampo("Usuario") = "Admin" Then - - End If - End If - - End If - End Sub - - Protected Sub GvUsuariosPortal_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles GvUsuariosPortal.RowEditing - - GvUsuariosPortal.EditIndex = e.NewEditIndex - - If ViewState("OrdenUsuarios").ToString() <> String.Empty Then - CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) - Else - CargaGrid("", 1) - End If - 'CargaUsuariosPortal() - - End Sub - - Protected Sub GvUsuariosPortal_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GvUsuariosPortal.RowUpdating - - Dim ObjUsuario As New ClsSisUsuarios - - Dim ErrorUsuario As Boolean = False - - Dim gvr As GridViewRow = GvUsuariosPortal.Rows(e.RowIndex) - - Dim Nombre As String = gvr.FCTextBox("TxtUsuarioPortalEdit").Text.Trim - Dim Correo As String = gvr.FCTextBox("TxtCorreoUsuarioPortalEdit").Text.Trim - Dim Estatus As Boolean = gvr.FCCheckBox("ChkEstatus").Checked - Dim CveUsuario As Integer = gvr.DataKey("CveUsuario").ToEntero - Dim pCveCliente As Integer = gvr.DataKey("CveCliente").ToEntero - - Dim PermisoHistorialCompras As Boolean = gvr.FCCheckBox("ChkPermiso1").Checked - Dim PermisoCxP As Boolean = gvr.FCCheckBox("ChkPermiso2").Checked - Dim PermisoAnticipo As Boolean = gvr.FCCheckBox("ChkPermiso3").Checked - Dim PermisoRH As Boolean = gvr.FCCheckBox("ChkPermiso4").Checked - Dim PermisoOS As Boolean = gvr.FCCheckBox("ChkPermiso5").Checked - Dim PermisoCotiza As Boolean = gvr.FCCheckBox("ChkPermiso6").Checked - Dim PermisoSistema As Boolean = gvr.FCCheckBox("ChkPermiso7").Checked - - ObjUsuario.IniciaTransacSQL() - - If ObjUsuario.UpdateUsuarioPortal(Correo, Nombre, Correo, Estatus, "-1", pCveCliente, -1, CveUsuario, UsuarioActual.CveUsuario) Then - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 229, PermisoHistorialCompras, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 230, PermisoCxP, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 231, PermisoAnticipo, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 232, PermisoOS, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 233, PermisoRH, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 234, PermisoSistema, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 235, PermisoCotiza, UsuarioActual.CveUsuario) Then ErrorUsuario = True - End If - - If ErrorUsuario Then - ObjUsuario.RollBack() - Else - ObjUsuario.Commit() - End If - - GvUsuariosPortal.EditIndex = -1 - - ObjUsuario.GetUsuariosPortal(-1, CveCliente, -1) - ViewState("DTUsuariosCliente") = ObjUsuario.DtResultados - - ObjUsuario.Dispose() - - If ViewState("OrdenUsuarios").ToString() <> String.Empty Then - CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) - Else - CargaGrid("", 1) - End If - - End Sub - - Protected Sub GvUsuariosPortal_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles GvUsuariosPortal.RowDeleting - - Dim Usuario As New ClsSisUsuarios - If Usuario.RemoveUsuarioPortal(GvUsuariosPortal.DataKeys(e.RowIndex).Value.ToString().ToEntero()) Then - GvUsuariosPortal.EditIndex = -1 - ViewState("DTUsuariosCliente") = Usuario.DtResultados - End If - - Usuario.Dispose() - - If ViewState("OrdenUsuarios").ToString() <> String.Empty Then - CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) - Else - CargaGrid("", 1) - End If - - End Sub - - Protected Sub GvUsuariosPortal_RowCancelingEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs) Handles GvUsuariosPortal.RowCancelingEdit - - GvUsuariosPortal.EditIndex = -1 - - If ViewState("OrdenUsuarios").ToString() <> String.Empty Then - CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) - Else - CargaGrid("", 1) - End If - - End Sub -#End Region - -#Region "O R D E N A M I E N T O" - Private Sub CargaGrid(Orden As String, gvi As Integer) - If gvi = 0 Then - If CType(ViewState("DTSucursalesCliente"), DataTable).Rows.Count > 0 Then - If Orden <> String.Empty Then - Dim DV As New DataView(CType(ViewState("DTSucursalesCliente"), DataTable), "", Orden, DataViewRowState.CurrentRows) - GVSucursales.DataSource = DV.ToTable() - DV.Dispose() - Else - GVSucursales.DataSource = CType(ViewState("DTSucursalesCliente"), DataTable) - End If - ViewState("Orden") = Orden - GVSucursales.DataBind() - UpDatos.Update() - End If - ElseIf gvi = 1 Then - If CType(ViewState("DTUsuariosCliente"), DataTable).Rows.Count > 0 Then - If Orden <> String.Empty Then - Dim DV As New DataView(CType(ViewState("DTUsuariosCliente"), DataTable), "", Orden, DataViewRowState.CurrentRows) - GvUsuariosPortal.DataSource = DV.ToTable() - DV.Dispose() - Else - GvUsuariosPortal.DataSource = CType(ViewState("DTUsuariosCliente"), DataTable) - End If - - End If - ViewState("OrdenUsuarios") = Orden - GvUsuariosPortal.DataBind() - UPPUsuarios.Update() - End If - - End Sub -#End Region - - -#End Region - -#Region "U S U A R I O S" - Protected Sub LbSolicitudPortal_Click(sender As Object, e As EventArgs) Handles LbEnviarActivacionPortal.Click - Dim ObjUsuario As New ClsSisUsuarios - Dim CveUsr As Integer = HdnCveUsuarioPortalAdmin.Value.ToEntero - Dim Usuario As String = TxtEmail.Text - Dim NomUsuario As String = "Admin" - Dim CorreoUsuario As String = TxtEmail.Text - Dim CvePlataforma As Integer = 6 - Dim ErrorUsuario As Boolean = True - 'DECLARAMOS PERMISOS DE ADMIN - Dim Permisos() As Integer = {234, 233, 232, 231, 230, 229} - - If Not CveCliente > 0 Then - Alert("Favor de guardar los datos del cliente antes de activar el Portal del Cliente.", TipoMensaje.MsgAdvertencia) - Return - End If - - ObjUsuario.IniciaTransacSQL() - - 'AGREGAMOS USUARIO ADMIN NUEVO - If CveUsr = 0 Then - 'CREA USUARIO - CveUsr = ObjUsuario.AddUsuarioPortal(Usuario, ContraseñaPredeterminadaEncriptada, NomUsuario, CorreoUsuario, CveCliente, -1, CvePlataforma, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CveUsr > 0 Then - ' AGREGA PERMISO A MODULO PORTALCLIENTE - If ObjUsuario.UpdateUsuariosModulos(CveUsr, 1101, True, UsuarioActual.CveUsuario) Then - 'AGREGAMOS PERMISOS A ADMIN - For Each permiso In Permisos - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsr, permiso, True, UsuarioActual.CveUsuario) Then - ErrorUsuario = True - Exit For - End If - ErrorUsuario = False - Next - If Not ErrorUsuario Then - HdnCveUsuarioPortalAdmin.Value = CveUsr.ToString - trDesactivarUsuario.Visible = True - trEnviarActivacion.Visible = False - LblUsuarioActivo.Text = "Si" - 'DivPermisosPortal.Visible = False - End If - End If - End If - Else - 'ACTUALIZAMOS ESTADO DE USARIO ADMIN INACTIVO - If ObjUsuario.UpdateUsuarioPortal(Usuario, "Admin", CorreoUsuario, True, ContraseñaPredeterminadaEncriptada, CveCliente, -1, CveUsr, UsuarioActual.CveUsuario) Then - - 'ACTUALIZAMOS PERMISOS A ADMIN - For Each permiso In Permisos - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsr, permiso, True, UsuarioActual.CveUsuario) Then - ErrorUsuario = True - Exit For - End If - ErrorUsuario = False - Next - If Not ErrorUsuario Then - HdnCveUsuarioPortalAdmin.Value = CveUsr.ToString - trDesactivarUsuario.Visible = True - trEnviarActivacion.Visible = False - LblUsuarioActivo.Text = "Si" - 'DivPermisosPortal.Visible = True - - End If - End If - End If - - 'VERIFICAMOS SI HUBO ERRORES - If ErrorUsuario Then - ObjUsuario.RollBack() - CveUsr = -1 - Else - ObjUsuario.Commit() - End If - - If CveUsr > 0 Then - 'ENVIA CORREO DE ACTIVACION - Dim ObjParametro As SisParametro = GlobalDTParametros(SisParametros.URL) - Dim Liga As String = ObjParametro.Cadena1 & "LogIn.aspx" - - If UsuarioActual.CveEmpresa = 43 Then - Liga = ObjParametro.Cadena1 & "AIMMGM/Portal.aspx" - End If - - Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsr & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa) - - If UsuarioActual.Empresa.CvePlataforma = 3 Then - EnviaCorreoGPS(Liga, LigaActivar) - Else - EnviaCorreo(Liga, LigaActivar) - End If - - 'HABILITA Y ACTUALIZA SECCION AGREGAR NUEVOS USUARIOS - ObjUsuario.GetUsuariosPortal(-1, CveCliente, -1) - - ViewState("DTUsuariosCliente") = ObjUsuario.DtResultados - GvUsuariosPortal.DataSource = ViewState("DTUsuariosCliente") - GvUsuariosPortal.DataBind() - 'divUsuariosPortal.Visible = True - ObjUsuario.Dispose() - - If UsuarioActual.Empresa.CvePlataforma = 1 Then - CargaUsuariosPortalCliente() - End If - - UpGvUsuarios.Update() - UPPUsuarios.Update() - End If - End Sub - - Protected Sub LnkAgregarUsuario_Click(sender As Object, e As EventArgs) Handles LnkAgregarUsuario.Click - Dim ObjParametro As SisParametro = GlobalDTParametros(SisParametros.URL) - Dim ObjUsuario As New ClsSisUsuarios - - Dim Liga As String = ObjParametro.Cadena1 & "Login.aspx" - Dim CveUsuario = -1 - Dim CvePlataforma As Integer = 6 - Dim ErrorUsuario As Boolean = False - - If UsuarioActual.CveEmpresa = 43 Then - Liga = ObjParametro.Cadena1 & "AIMMGM/Portal.aspx" - End If - - Dim PermisoHistorialCompras As Boolean = ChkPermiso1.Checked - Dim PermisoCxP As Boolean = ChkPermiso2.Checked - Dim PermisoAnticipo As Boolean = ChkPermiso3.Checked - Dim PermisoRH As Boolean = ChkPermiso4.Checked - Dim PermisoOS As Boolean = ChkPermiso5.Checked - Dim PermisoCotiza As Boolean = ChkPermiso6.Checked - Dim PermisoSistema As Boolean = ChkPermiso7.Checked - - ObjUsuario.IniciaTransacSQL() - - CveUsuario = ObjUsuario.AddUsuarioPortal(TxtCorreoUsuarioPortal.Text, ContraseñaPredeterminadaEncriptada, TxtNombreUsuarioPortal.Text, TxtCorreoUsuarioPortal.Text, CveCliente, -1, CvePlataforma, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - If CveUsuario > 0 Then - If ObjUsuario.UpdateUsuariosModulos(CveUsuario, 1101, True, UsuarioActual.CveUsuario) Then - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 229, PermisoHistorialCompras, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 230, PermisoCxP, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 231, PermisoAnticipo, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 232, PermisoOS, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 233, PermisoRH, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 234, PermisoSistema, UsuarioActual.CveUsuario) Then ErrorUsuario = True - If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 235, PermisoCotiza, UsuarioActual.CveUsuario) Then ErrorUsuario = True - End If - End If - - If ErrorUsuario Then - ObjUsuario.RollBack() - Else - ObjUsuario.Commit() - - Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsuario & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa) - EnviaCorreo2(Liga, LigaActivar) - - LimpiaAgregarUsuarioPortal() - - Alert("Usuario Creado.
    El usuario accesará con la contraseña '" & ContraseñaPredeterminada & "'", TipoMensaje.MsgInformacion) - End If - - ObjUsuario.GetUsuariosPortal(-1, CveCliente, -1) - ViewState("DTUsuariosCliente") = ObjUsuario.DtResultados - - ObjUsuario.Dispose() - - If ViewState("OrdenUsuarios").ToString() <> String.Empty Then - CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) - Else - CargaGrid("", 1) - End If - End Sub - - Protected Sub LimpiaAgregarUsuarioPortal() - TxtNombreUsuarioPortal.Text = "" - TxtCorreoUsuarioPortal.Text = "" - - ChkPermiso1.Checked = False - ChkPermiso2.Checked = False - ChkPermiso3.Checked = False - ChkPermiso4.Checked = False - ChkPermiso5.Checked = False - ChkPermiso6.Checked = False - ChkPermiso7.Checked = False - End Sub -#End Region - -#Region "E V E N T O - B I T A C O R A" - 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(175) - e.Row.Cells(1).Width = Unit.Pixel(175) - e.Row.Cells(2).Width = Unit.Pixel(100) - e.Row.Cells(4).Width = Unit.Pixel(30) - End If - - If e.Row.DBCampo("Archivo").ToString <> "" 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 - - 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) = Anexo.getfiles().Archivos - Dim filemove As String = "" - - For Each fileItem As Archivo In filesgral - FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") - filemove = fileItem.filename - Next - - If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, String.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, CveCliente, -1, -1, -1, -1, -1) Then - If filemove <> "" Then - filemove.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("Empresas\{0}\OI", UsuarioActual.CveEmpresa)) - End If - - GvEB.DataSource = ObjEventoBitacora.DtResultados - TxtEventoDescripcion.Text = "" - Anexo.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 - Private Sub CargaEventoBitacora() - Dim ObjEventoBitacora As New ClsOIEventos() - If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=CveCliente) Then - GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2") - Else - GvEB.DataSource = Nothing - End If - ObjEventoBitacora.Dispose() - GvEB.DataBind() - 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 - - - Private Sub BtnCancelarSucursal_Click(sender As Object, e As EventArgs) Handles BtnCancelarSucursal.ServerClick - GvDatos_RowCancelingEdit(Nothing, Nothing) - End Sub - - Public Sub BtnAgregaCuentaContable(sender As Object, e As EventArgs) Handles BtnActivaRegistroClientes.Click, BtnActivaRegistroAnticipos.Click, BtnActivaRegistroIVA.Click, BtnActivaRegistroISR.Click - Dim CuentaContable = DirectCast(sender, Button).CommandArgument.ToString - Dim Button = DirectCast(sender, Button) - Select Case CuentaContable - Case "Clientes" - AgregarCuentaContable(Button, DdlCtaContableClientes) - Case "Anticipos" - AgregarCuentaContable(Button, DdlCtaContableAnticipos) - Case "RetIVA" - AgregarCuentaContable(Button, DdlCtaContableRetIVA) - Case "RetISR" - AgregarCuentaContable(Button, DdlCtaContableRetISR) - End Select - - End Sub - - Private Function AgregarCuentaContable(btn As Button, ddl As DropDownList) As Boolean - Dim IdCuentaContable As Integer = -1 - Dim CtaCodigo As String = "" - Dim TieneError = False - Dim IdCtaContableClientes As Integer = -1, IdCtaContableAnticipos As Integer = -1, IdCtaContableRetIVA As Integer = -1, IdCtaContableRetISR As Integer = -1 - Dim ProcesoCorrecto As Boolean - - Dim ObjContaAC As New ClsContPAQi(UsuarioActual.Empresa) - - ObjContaAC.IniciaTransacSQL() - - Dim CuentaPadre = -1 - - Select Case btn.CommandArgument.ToString - Case "Clientes" - CuentaPadre = UsuarioActual.Empresa.Funcionalidad(211).ToEntero - Case "Anticipos" - CuentaPadre = UsuarioActual.Empresa.Funcionalidad(212).ToEntero - Case "RetIVA" - CuentaPadre = UsuarioActual.Empresa.Funcionalidad(213).ToEntero - Case "RetISR" - CuentaPadre = UsuarioActual.Empresa.Funcionalidad(214).ToEntero - - End Select - - 'SI EL NOMBRE DEL PROVEEDOR ES MAYOR DE 50 LO CORTAMOS - Dim NombreCuenta = If(TxtNombreComercial.Text.Trim.Length > 50, TxtNombreComercial.Text.Trim.Substring(0, 50), TxtNombreComercial.Text.Trim) - - IdCuentaContable = ObjContaAC.AddSiguienteCuentaHijo(CuentaPadre, NombreCuenta, Tipo:="A", CuentaMayor:=2) - If IdCuentaContable > 0 Then - - ObjContaAC.GetCuentas(IdCuentaContable, "-1", -1) - Dim dt = ObjContaAC.DtResultados - - If dt.Rows.Count = 1 Then - - Dim row As DataRow = dt.Rows(0) - CtaCodigo = CStr(row("CtaCodigo")) - - Select Case btn.CommandArgument.ToString - Case "Clientes" - IdCtaContableClientes = IdCuentaContable - Case "Anticipos" - IdCtaContableAnticipos = IdCuentaContable - Case "RetIVA" - IdCtaContableRetIVA = IdCuentaContable - Case "RetISR" - IdCtaContableRetISR = IdCuentaContable - End Select - - - Dim ObjClientes As New ClsClientes - If Not ObjClientes.VincularCuentasContables(IdCtaContableClientes, IdCtaContableAnticipos, IdCtaContableRetIVA, IdCtaContableRetISR, CveCliente) Then - TieneError = True - End If - - ObjClientes.Dispose() - - Else - TieneError = True - End If - - Else - TieneError = True - End If - - If Not TieneError Then - ObjContaAC.Commit() - Alert(String.Format("Se registo la Cuenta Contable: {0}", CtaCodigo, TipoMensaje.MsgInformacion)) - ddl.Items.Add(New ListItem(CtaCodigo, IdCuentaContable.ToString)) : ddl.SelectedValueExist(IdCuentaContable.ToString) - btn.Visible = False - ddl.Width = 206 - ProcesoCorrecto = True - Else - ObjContaAC.RollBack() - Alert("error", TipoMensaje.MsgError) - ProcesoCorrecto = False - End If - - - ObjContaAC.Dispose() - UpFiscalContable.Update() - - - Return ProcesoCorrecto - End Function - - Private Sub ActivarRegistroAutomatico() - - 'Clientes - If DdlCtaContableClientes.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 Then - BtnActivaRegistroClientes.Visible = True - End If - - 'Anticipos - If DdlCtaContableAnticipos.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(212).ToEntero > 0 Then - BtnActivaRegistroAnticipos.Visible = True - End If - - 'Ret IVA - If DdlCtaContableRetIVA.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(213).ToEntero > 0 Then - BtnActivaRegistroIVA.Visible = True - End If - - 'Ret ISR - If DdlCtaContableRetISR.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(214).ToEntero > 0 Then - BtnActivaRegistroISR.Visible = True - End If - - End Sub -#End Region - -#Region " I M P R I M I R P D F" - - Protected Sub ChkAntIXCNC_CheckedChanged(sender As Object, e As EventArgs) - DdlTipoDocto.ClearSelection() - If ChkAntIXCNC.Checked Then - DdlTipoDocto.SelectedValuesIfExistM("Ing,Rem,Ant,Egs,IxC") - Else - DdlTipoDocto.SelectedValuesIfExistM("Ing,Rem") - End If - End Sub - Protected Sub LnkGenerarReporteCxC_Click(sender As Object, e As EventArgs) Handles LnkGenerarReporteCxC.Click - GenerarPDFCrystal(RBLGenerarReporteCxC.SelectedValue) - End Sub - - Protected Sub GenerarReporte(sender As Object, e As EventArgs) - GenerarRepCrystal() - End Sub - Private Sub GenerarRepCrystal() - Dim Archivo As New FileInfo(Server.MapPath("~/Empresas/Grales/Formatos/EquiposGPS.rpt")) - Dim lista = New List(Of CrystalParametro) - lista.Add(New CrystalParametro("NombreEmpresa", UsuarioActual.Empresa.Empresa)) - lista.Add(New CrystalParametro("NombreUsuario", UsuarioActual.Nombre)) - - Dim ObjGPS As New ClsGPS - Dim tablaReporte As DataTable - If ObjGPS.DispositivosGet(-1, Estatus, CveCliente) Then - tablaReporte = ObjGPS.DtResultados - Dim VistaFiltro As DataView = New DataView(tablaReporte) - Dim reporteDatos As DataTable = VistaFiltro.ToTable("Selected", False, "TipoDispositivoDisplay", "Display", "Modelo", "Serie", "IMEI", "NumeroTelefono", "FechaIng") - Dim file As Byte() = ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/EquiposGPS.rpt"), reporteDatos, lista) - ImprimirbytesPDF(file) - Else - Alert("No hay lista de dispositivos para imprimir") - End If - - End Sub - - Private Sub GenerarPDFCrystal(Optional Formato As String = "PDF") - Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepClientesCxC.rpt", UsuarioActual.Empresa.Ruta)) - 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) - 'OBTENEMOS LOS DATOS - - Dim DtCxCFact As DataTable = Nothing - - Dim FI = If(TxtFechaInicioCxP.Text = "" Or TxtFechaInicioCxP.Text = "__/__/____", "-1", TxtFechaInicioCxP.Text) - Dim FF = If(TxtFechaFinCxP.Text = "" Or TxtFechaFinCxP.Text = "__/__/____", "-1", TxtFechaFinCxP.Text) - - Dim SaldoIngDolares As Double = 0 - Dim SaldoIngPesos As Double = 0 - Dim SaldoIngDolaresPesos As Double = 0 - Dim TotalIng As Double = 0 - - Dim SaldoAntDolares As Double = 0 - Dim SaldoAntPesos As Double = 0 - Dim SaldoAntDolaresPesos As Double = 0 - Dim TotalAnt As Double = 0 - Dim ContaIng As Integer = 0 - Dim ContaAnt As Integer = 0 - Dim FechaCorte As Date = ("9999/01/01").ToDate - Dim TipoDocto As String = If(DdlTipoDocto.GetSelectedValuesM = "", "-1", DdlTipoDocto.GetSelectedValuesM) - Dim TipoDocto2 As String = If(DdlTipoDocto.GetSelectedValuesM = "", "-1", DdlTipoDocto.GetSelectedValuesM(True)) - Dim FechaVencimientoI As String = If(TxtFechaVICxP.Text = "", "-1", TxtFechaVICxP.Text).ToString - Dim FechaVencimientoF As String = If(TxtFechaVFCxP.Text = "", "-1", TxtFechaVFCxP.Text).ToString - - Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetCxCClienteDetalle(CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, DdlSucursalCliente.SelectedValue.ToEntero) Then - DtCxCFact = If(DdlTipoCuentasCxC.SelectedValue = "-1", ObjMovtos.DtResultados.FiltraParametros("", "TipoDocto").Copy, ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'", "TipoDocto")) - 'cargo los anticipos NC - DtCxCFact.Columns.Add("SaldoAnticipo", GetType(Decimal)) - - Dim dtt As DataTable = Nothing - If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, -1, -1) Then - dtt = If(DdlTipoCuentasCxC.SelectedValue = "-1", ObjMovtos.DtResultados.FiltraParametros("SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) OR (Tipo = 'NC' AND CveVenta > 0) OR (Tipo = 'Egs' AND CveVenta > 0) )"), ObjMovtos.DtResultados.FiltraParametros("Saldo > 0 AND SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) OR (Tipo = 'NC' AND CveVenta > 0) OR (Tipo = 'Egs' AND CveVenta > 0) )")) ' que tenga saldo de anticipo y no de cliente - If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then - For Each drt As DataRow In dtt.Rows - Dim drr As DataRow = DtCxCFact.NewRow - - drr("TipoDocto") = drt("Tipo") - drr("SerieFolio") = drt("Folio") - drr("Original") = drt("Original") - drr("TipoCambio") = drt("TipoCambio") - drr("Saldo") = 0 - drr("SaldoAnticipo") = drt("Saldo") - drr("Fecha") = drt("Fecha") - drr("Moneda") = drt("Moneda") - drr("CveMoneda") = drt("CveMoneda") - DtCxCFact.Rows.Add(drr) - - Next - End If - - End If - - End If - ObjMovtos.Dispose() - - If DtCxCFact IsNot Nothing Then - For Each Row As DataRow In DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})").Rows - If Row("TipoDocto").ToString = "Ing" Or Row("TipoDocto").ToString = "Rem" Or (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble > 0) Then 'Ingresos - ContaIng = ContaIng + 1 - If Row("CveMoneda").ToString.ToEntero = 1 Then - SaldoIngPesos = SaldoIngPesos + Row("Saldo").ToString.ToDouble - ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then - SaldoIngDolares = SaldoIngDolares + Row("Saldo").ToString.ToDouble - SaldoIngDolaresPesos = SaldoIngDolaresPesos + (Row("Saldo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble) - End If - - ElseIf (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble = 0) Or Row("TipoDocto").ToString = "IxC" Or Row("TipoDocto").ToString = "NC" Or Row("TipoDocto").ToString = "Dev" Then 'Anticipos, NC, IxC - ContaAnt = ContaAnt + 1 - If Row("CveMoneda").ToString.ToEntero = 1 Then - If Row("TipoDocto").ToString = "Dev" Then - SaldoAntPesos = SaldoAntPesos + Row("Saldo").ToString.ToDouble - Else - SaldoAntPesos = SaldoAntPesos + Row("SaldoAnticipo").ToString.ToDouble - End If - ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then - SaldoAntDolares = SaldoAntDolares + Row("Saldo").ToString.ToDouble - SaldoAntDolaresPesos = SaldoAntDolaresPesos + (Row("SaldoAnticipo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble) - End If - End If - Next - End If - - TotalIng = SaldoIngPesos + SaldoIngDolaresPesos - TotalAnt = SaldoAntPesos + SaldoAntDolaresPesos - - Dim DtCxCFact2 As DataTable = DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})") - - 'INGRESOS - If SaldoIngPesos > 0 Then - Dim drr As DataRow = DtCxCFact2.NewRow - drr("SerieFolio") = "Total Ing Pesos" - drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") - drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") - drr("Saldo") = SaldoIngPesos - drr("CveMoneda") = 1 - DtCxCFact2.Rows.Add(drr) - End If - If SaldoIngDolares > 0 Then - Dim drr As DataRow = DtCxCFact2.NewRow - drr("SerieFolio") = "Total Ing Dólares" - drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") - drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") - drr("Saldo") = SaldoIngDolares - drr("CveMoneda") = 2 - DtCxCFact2.Rows.Add(drr) - End If - - 'ANTICIPOS - If SaldoAntPesos > 0 Then - Dim drr As DataRow = DtCxCFact2.NewRow - drr("SerieFolio") = "Total Pesos" - 'drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('IxC','Egs,'Dev') OR (TipoDocto = 'Ant' AND Saldo = 0)") - 'drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('IxC','Egs','Dev') OR (TipoDocto = 'Ant' AND Saldo = 0)") - drr("SaldoAnticipo") = SaldoAntPesos - drr("CveMoneda") = 1 - DtCxCFact2.Rows.Add(drr) - End If - If SaldoAntDolares > 0 Then - Dim drr As DataRow = DtCxCFact2.NewRow - drr("SerieFolio") = "Total Dólares" - ' drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Original", "TipoDocto IN ('IxC','Egs,'Dev') OR (TipoDocto = 'Ant' AND Saldo = 0)") - ' drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Abonado", "TipoDocto IN ('IxC','Egs,'Dev') OR (TipoDocto = 'Ant' AND Saldo = 0)") - drr("SaldoAnticipo") = SaldoAntDolares - drr("CveMoneda") = 2 - DtCxCFact2.Rows.Add(drr) - End If - - If DtCxCFact2 IsNot Nothing AndAlso DtCxCFact2.Rows.Count > 0 Then - Dim dr As DataRow = DtCxCFact2.Rows(0) - Dim lista = New List(Of CrystalParametro) - lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa)) - lista.Add(New CrystalParametro("TipoCuentas", DdlTipoCuentasCxC.SelectedItem.Text)) - lista.Add(New CrystalParametro("NombreCliente", LtlCliente.Text)) - lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI))) - lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF))) - lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) - lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", TxtDireccion.Text, If(TxtNoExt.Text = "", "S/N", TxtNoExt.Text), TxtColonia.Text))) - lista.Add(New CrystalParametro("ClienteCP", TxtCP.Text)) - lista.Add(New CrystalParametro("ClienteCiudad", TxtCiudad.Text)) - lista.Add(New CrystalParametro("ClienteRFC", TxtRFC.Text)) - lista.Add(New CrystalParametro("ClienteTelefono", TxtTelefono.Text)) - lista.Add(New CrystalParametro("DiasCredito", TxtPlazoCobranza.Text)) - lista.Add(New CrystalParametro("LimiteCredito", TxtLimiteCredito.Text)) - lista.Add(New CrystalParametro("SaldoDisponible", (TxtLimiteCredito.Text.ToDouble - DtCxCFact2(0)("Saldo").ToString.ToDouble).FormatoNumero)) - - lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero)) - lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero)) - lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero)) - lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero)) - lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero)) - lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero)) - lista.Add(New CrystalParametro("ContaIng", ContaIng)) - lista.Add(New CrystalParametro("ContaAnt", ContaAnt)) - - - - If Imagen.Exists Then - lista.Add(New CrystalParametro("LogoPath", logouri)) - Else - lista.Add(New CrystalParametro("LogoPath", "")) - End If - - If ChkCobranzaEnviarCorreo.Checked Then - Try - Dim File As Byte() - If Archivo.Exists Then - File = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato) - Else - File = ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato) - End If - - Try - Dim Cuerpo As String = String.Format("Estimado cliente {0}, al presente del correo se anexa su estado actual de cartera en {1}.
    -
    - Quedamos a sus ordenes para cualquier duda o aclaración con su agente de Ventas.
    -
    -
    - Gracias por la atención brindada al presente.
    Reciba un cordial saludo.
    -
    - ESTE CORREO SE GENERO EN FORMA AUTOMATICA.", TxtNombreComercial.Text, UsuarioActual.Empresa.Empresa) - Dim Hilo As New System.Threading.Thread(Sub() MandaCorreoEstadoCuenta(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Me.CveCliente, File, TxtCobranzaCorreo.Text, $"Estado Actual de Cartera {UsuarioActual.Empresa.Empresa}", Cuerpo, GuardarBitacora:=True)) - Hilo.Start() - Alert("El correo se envió con éxito", TipoMensaje.MsgInformacion) - Catch ex As Exception - Alert("Ocurrió un error al enviar el correo", TipoMensaje.MsgAdvertencia) - - End Try - - Catch ex As Exception - OnError("Ocurrió error al mandar MAIL de Orden de Compra", ex) - End Try - Else - If Archivo.Exists Then - ImprimirbytesPDF(ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) - Else - ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) - End If - - End If - Else - Dim lista = New List(Of CrystalParametro) - lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa)) - lista.Add(New CrystalParametro("TipoCuentas", DdlTipoCuentasCxC.SelectedItem.Text)) - lista.Add(New CrystalParametro("NombreCliente", LtlCliente.Text)) - lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI))) - lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF))) - lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) - lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", TxtDireccion.Text, If(TxtNoExt.Text = "", "S/N", TxtNoExt.Text), TxtColonia.Text))) - lista.Add(New CrystalParametro("ClienteCP", TxtCP.Text)) - lista.Add(New CrystalParametro("ClienteCiudad", TxtCiudad.Text)) - lista.Add(New CrystalParametro("ClienteRFC", TxtRFC.Text)) - lista.Add(New CrystalParametro("ClienteTelefono", TxtTelefono.Text)) - lista.Add(New CrystalParametro("DiasCredito", TxtPlazoCobranza.Text)) - lista.Add(New CrystalParametro("LimiteCredito", TxtLimiteCredito.Text)) - lista.Add(New CrystalParametro("SaldoDisponible", (TxtLimiteCredito.Text.ToDouble).FormatoNumero)) - - lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero)) - lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero)) - lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero)) - lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero)) - lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero)) - lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero)) - lista.Add(New CrystalParametro("ContaIng", ContaIng)) - lista.Add(New CrystalParametro("ContaAnt", ContaAnt)) - - If Imagen.Exists Then - lista.Add(New CrystalParametro("LogoPath", logouri)) - Else - lista.Add(New CrystalParametro("LogoPath", "")) - End If - - Dim drr As DataRow = DtCxCFact2.NewRow - drr("SerieFolio") = "Total Ing Pesos" - drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") - drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") - drr("Saldo") = 0 - drr("SaldoAnticipo") = 0 - drr("CveMoneda") = 1 - DtCxCFact2.Rows.Add(drr) - - If Archivo.Exists Then - ImprimirbytesPDF(ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) - Else - ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) - End If - End If - End Sub - Private Sub MandaCorreoEstadoCuenta(CveUsuario As Integer, CveEmpresa As Integer, CveCliente As Integer, File As Byte(), Para As String, Asunto As String, Body As String, Optional GuardarBitacora As Boolean = False) - - Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) - 'a.GuardaLog() - Dim Mail As New ClsSisMail() - - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.ArchivoBinario = File, .NombreArchivo = "EstadoDeCuenta.pdf"}) - + End Sub + Protected Sub LnkAgragarDireccion_Click(sender As Object, e As EventArgs) + + txtLg.Text = "0" + txtLt.Text = "0" + + RegistraScript("muestraMapa();") + HDMAPOP.Value = "1" + + UpModalDivMapa.Update() + + End Sub +#Region "G V S U C U R S A L E S" + Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVSucursales.RowDataBound + + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.RowIndex = 0 Then + ' e.Row.Cells(0).Width = Unit.Pixel(150) + e.Row.Cells(1).Width = Unit.Pixel(40) + e.Row.Cells(2).Width = Unit.Pixel(40) + End If + e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left + + + + If Not CveCliente > 0 Then + e.Row.Cells(3).Visible = False + End If + End If + + End Sub + + Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVSucursales.RowDeleting + Dim ObjCliente As New ClsClientes + + If CveCliente > 0 Then + If ObjCliente.RemoveSucursal(CveCliente, GVSucursales.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then + GVSucursales.EditIndex = -1 + ViewState("DTSucursalesCliente") = ObjCliente.DtResultados + Alert("La Sucursal del Cliente se eliminó correctamente.", TipoMensaje.MsgInformacion) + End If + Else + TempDTSucursales.Rows.RemoveAt(e.RowIndex) + TempDTSucursales.AcceptChanges() + GVSucursales.DataSource = TempDTSucursales + GVSucursales.DataBind() + UpDatos.Update() + End If + + ObjCliente.Dispose() + End Sub + Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GVSucursales.RowCancelingEdit + GVSucursales.EditIndex = -1 + If ViewState("Orden").ToString() <> String.Empty Then + CargaGrid(ViewState("Orden").ToString(), 0) + Else + CargaGrid("", 0) + End If + End Sub + Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GVSucursales.RowUpdating + + If ViewState("Orden").ToString() <> String.Empty Then + CargaGrid(ViewState("Orden").ToString(), 0) + Else + CargaGrid("", 0) + End If + + End Sub + Protected Sub GvDatos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GVSucursales.RowEditing + + Me.Actualizar = True + Me.CveClienteSuc = GVSucursales.DataKeys(e.NewEditIndex).Value.ToString.ToEntero + + + Dim ObjCliente As New ClsClientes + + If ObjCliente.GetSucursales(CveCliente, CveClienteSuc) Then + + DivEstatusSucursal.Visible = True + TxtNombreSucursal.Text = ObjCliente.DtResultados.Rows(0)("SucursalCliente").ToString + ChkEstatusSucursal.Checked = If(ObjCliente.DtResultados.Rows(0)("Estatus").ToString = "Activo", True, False) + TxtCiudadSucursal.Text = ObjCliente.DtResultados.Rows(0)("Ciudad").ToString + TxtColoniaSucursal.Text = ObjCliente.DtResultados.Rows(0)("Colonia").ToString + TxtCPSucursal.Text = ObjCliente.DtResultados.Rows(0)("CP").ToString + TxtDireccionSucursal.Text = ObjCliente.DtResultados.Rows(0)("Direccion").ToString + TxtEstadoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Estado").ToString + TxtLocalidadSucursal.Text = ObjCliente.DtResultados.Rows(0)("Localidad").ToString + TxtPaisSucursal.Text = ObjCliente.DtResultados.Rows(0)("Pais").ToString + TxtNumExtSucursal.Text = ObjCliente.DtResultados.Rows(0)("NoExt").ToString + TxtNumIntSucursal.Text = ObjCliente.DtResultados.Rows(0)("NoInt").ToString + TxtTelefonoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Telefono").ToString + TxtCorreoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Correo").ToString + TxtCorreoSucursalCotizacion.Text = ObjCliente.DtResultados(0)("CorreoCotizacion").ToString + TxtContactoSucursal.Text = ObjCliente.DtResultados.Rows(0)("Contacto").ToString + DdlVendedorSucursal.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveVendedor").ToString) + DdlMetodoPagoSucursal.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveMetodoPago").ToString) + TxtNumeroCuenta.Text = ObjCliente.DtResultados.Rows(0)("NumCtaPago").ToString + LblUsuarioSucursal.Text = String.Format("Usuario Registró: {0}", ObjCliente.DtResultados.Rows(0)("Usuario").ToString) + LblFechaSucursal.Text = String.Format("Fecha de Registro: {0}", ObjCliente.DtResultados.Rows(0)("FechaIng").ToString.ToDate.ToShortDateString) + TxtLimiteCreditoSucursal.Text = ObjCliente.DtResultados.Rows(0)("LimiteCredito").ToString.FormatoNumero + DdlResponsableSucursal.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveResponsableCobranza").ToString) + + DdlSucursalUsoCFDI.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveUsoCFDI").ToString) + DdlSucursalMetodoPago33.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveMetodoPago33").ToString) + DdlSucursalFormaPago33.SelectedValueExist(ObjCliente.DtResultados.Rows(0)("CveFormaPago33").ToString) + + txtLg.Text = ObjCliente.DtResultados.Rows(0)("LG").ToString + txtLt.Text = ObjCliente.DtResultados.Rows(0)("LT").ToString + HDMAPOP.Value = "2" + + + UpAgregarSucursal.Update() + UpModalDivMapa.Update() + + 'Dim scriptReg As String = $" SelTxtLat = '#{ GVSucursales.Rows(e.NewEditIndex).FCTextBox("txtLt").ClientID}'; SelTxtLon = '#{ GVSucursales.Rows(e.NewEditIndex).FCTextBox("txtLg").ClientID}''" + 'RegistraScript("$('#divAgregarSucursal').modal();" & scriptReg) + + RegistraScript("$('#divAgregarSucursal').modal();") + + Else + Alert("No se pudieron cargar los datos de la sucursal") + End If + + ObjCliente.Dispose() + + If ViewState("Orden").ToString() <> String.Empty Then + CargaGrid(ViewState("Orden").ToString(), 0) + Else + CargaGrid("", 0) + End If + End Sub +#End Region + +#Region "G V U S U A R I O S P O R T A L" + Protected Sub GvUsuariosPortal_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles GvUsuariosPortal.RowCommand + If e.CommandName = "RestablecerContraseña" Then + Dim cveUsuarioPortal As Integer = e.CommandArgument.ToString.ToEntero + Dim Usuario As New ClsSisUsuarios + If Usuario.GetUsuariosPortal(cveUsuarioPortal, -1, -1) Then + Dim dr As DataRow = Usuario.DtResultados.FiltroPrimero("") + + If Usuario.UpdateUsuarioPortal(dr("Usuario").ToString, dr("Nombre").ToString, dr("Correo").ToString, CType(dr("Estatus"), Boolean), ContraseñaPredeterminadaEncriptada, CveCliente, -1, cveUsuarioPortal, UsuarioActual.CveUsuario) Then + + GvUsuariosPortal.EditIndex = -1 + ViewState("DTUsuariosCliente") = Usuario.DtResultados.FiltraParametros("Usuario <> 'Admin'") + Alert("Contraseña Restablecida.
    La nueva contraseña es: """ & ContraseñaPredeterminada & "", TipoMensaje.MsgInformacion) + End If + + End If + + Usuario.Dispose() + + End If + End Sub + + Protected Sub GvUsuariosPortal_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvUsuariosPortal.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.RowIndex = 0 Then + ''e.Row.Cells(0).Width = Unit.Pixel(180) + ''e.Row.Cells(1).Width = Unit.Pixel(180) + ''e.Row.Cells(2).Width = Unit.Pixel(180) + + ''e.Row.Cells(3).Width = Unit.Pixel(50) + ''e.Row.Cells(4).Width = Unit.Pixel(50) + ''e.Row.Cells(5).Width = Unit.Pixel(50) + ''e.Row.Cells(6).Width = Unit.Pixel(50) + ''e.Row.Cells(7).Width = Unit.Pixel(50) + ''e.Row.Cells(8).Width = Unit.Pixel(50) + ''e.Row.Cells(9).Width = Unit.Pixel(50) + ''e.Row.Cells(10).Width = Unit.Pixel(50) + ''e.Row.Cells(11).Width = Unit.Pixel(50) + ''e.Row.Cells(12).Width = Unit.Pixel(45) + + ''e.Row.Cells(3).Width = Unit.Pixel(68) + ''e.Row.Cells(4).Width = Unit.Pixel(70) + ''e.Row.Cells(5).Width = Unit.Pixel(130) + End If + + If e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal Then + If e.Row.DBCampo("Usuario") = "Admin" Then + + End If + End If + + End If + End Sub + + Protected Sub GvUsuariosPortal_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles GvUsuariosPortal.RowEditing + + GvUsuariosPortal.EditIndex = e.NewEditIndex + + If ViewState("OrdenUsuarios").ToString() <> String.Empty Then + CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) + Else + CargaGrid("", 1) + End If + 'CargaUsuariosPortal() + + End Sub + + Protected Sub GvUsuariosPortal_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs) Handles GvUsuariosPortal.RowUpdating + + Dim ObjUsuario As New ClsSisUsuarios + + Dim ErrorUsuario As Boolean = False + + Dim gvr As GridViewRow = GvUsuariosPortal.Rows(e.RowIndex) + + Dim Nombre As String = gvr.FCTextBox("TxtUsuarioPortalEdit").Text.Trim + Dim Correo As String = gvr.FCTextBox("TxtCorreoUsuarioPortalEdit").Text.Trim + Dim Estatus As Boolean = gvr.FCCheckBox("ChkEstatus").Checked + Dim CveUsuario As Integer = gvr.DataKey("CveUsuario").ToEntero + Dim pCveCliente As Integer = gvr.DataKey("CveCliente").ToEntero + + Dim PermisoHistorialCompras As Boolean = gvr.FCCheckBox("ChkPermiso1").Checked + Dim PermisoCxP As Boolean = gvr.FCCheckBox("ChkPermiso2").Checked + Dim PermisoAnticipo As Boolean = gvr.FCCheckBox("ChkPermiso3").Checked + Dim PermisoRH As Boolean = gvr.FCCheckBox("ChkPermiso4").Checked + Dim PermisoOS As Boolean = gvr.FCCheckBox("ChkPermiso5").Checked + Dim PermisoCotiza As Boolean = gvr.FCCheckBox("ChkPermiso6").Checked + Dim PermisoSistema As Boolean = gvr.FCCheckBox("ChkPermiso7").Checked + + ObjUsuario.IniciaTransacSQL() + + If ObjUsuario.UpdateUsuarioPortal(Correo, Nombre, Correo, Estatus, "-1", pCveCliente, -1, CveUsuario, UsuarioActual.CveUsuario) Then + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 229, PermisoHistorialCompras, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 230, PermisoCxP, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 231, PermisoAnticipo, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 232, PermisoOS, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 233, PermisoRH, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 234, PermisoSistema, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 235, PermisoCotiza, UsuarioActual.CveUsuario) Then ErrorUsuario = True + End If + + If ErrorUsuario Then + ObjUsuario.RollBack() + Else + ObjUsuario.Commit() + End If + + GvUsuariosPortal.EditIndex = -1 + + ObjUsuario.GetUsuariosPortal(-1, CveCliente, -1) + ViewState("DTUsuariosCliente") = ObjUsuario.DtResultados + + ObjUsuario.Dispose() + + If ViewState("OrdenUsuarios").ToString() <> String.Empty Then + CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) + Else + CargaGrid("", 1) + End If + + End Sub + + Protected Sub GvUsuariosPortal_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles GvUsuariosPortal.RowDeleting + + Dim Usuario As New ClsSisUsuarios + If Usuario.RemoveUsuarioPortal(GvUsuariosPortal.DataKeys(e.RowIndex).Value.ToString().ToEntero()) Then + GvUsuariosPortal.EditIndex = -1 + ViewState("DTUsuariosCliente") = Usuario.DtResultados + End If + + Usuario.Dispose() + + If ViewState("OrdenUsuarios").ToString() <> String.Empty Then + CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) + Else + CargaGrid("", 1) + End If + + End Sub + + Protected Sub GvUsuariosPortal_RowCancelingEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs) Handles GvUsuariosPortal.RowCancelingEdit + + GvUsuariosPortal.EditIndex = -1 + + If ViewState("OrdenUsuarios").ToString() <> String.Empty Then + CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) + Else + CargaGrid("", 1) + End If + + End Sub +#End Region + +#Region "O R D E N A M I E N T O" + Private Sub CargaGrid(Orden As String, gvi As Integer) + If gvi = 0 Then + If CType(ViewState("DTSucursalesCliente"), DataTable).Rows.Count > 0 Then + If Orden <> String.Empty Then + Dim DV As New DataView(CType(ViewState("DTSucursalesCliente"), DataTable), "", Orden, DataViewRowState.CurrentRows) + GVSucursales.DataSource = DV.ToTable() + DV.Dispose() + Else + GVSucursales.DataSource = CType(ViewState("DTSucursalesCliente"), DataTable) + End If + ViewState("Orden") = Orden + GVSucursales.DataBind() + UpDatos.Update() + End If + ElseIf gvi = 1 Then + If CType(ViewState("DTUsuariosCliente"), DataTable).Rows.Count > 0 Then + If Orden <> String.Empty Then + Dim DV As New DataView(CType(ViewState("DTUsuariosCliente"), DataTable), "", Orden, DataViewRowState.CurrentRows) + GvUsuariosPortal.DataSource = DV.ToTable() + DV.Dispose() + Else + GvUsuariosPortal.DataSource = CType(ViewState("DTUsuariosCliente"), DataTable) + End If + + End If + ViewState("OrdenUsuarios") = Orden + GvUsuariosPortal.DataBind() + UPPUsuarios.Update() + End If + + End Sub +#End Region + + +#End Region + +#Region "U S U A R I O S" + Protected Sub LbSolicitudPortal_Click(sender As Object, e As EventArgs) Handles LbEnviarActivacionPortal.Click + Dim ObjUsuario As New ClsSisUsuarios + Dim CveUsr As Integer = HdnCveUsuarioPortalAdmin.Value.ToEntero + Dim Usuario As String = TxtEmail.Text + Dim NomUsuario As String = "Admin" + Dim CorreoUsuario As String = TxtEmail.Text + Dim CvePlataforma As Integer = 6 + Dim ErrorUsuario As Boolean = True + 'DECLARAMOS PERMISOS DE ADMIN + Dim Permisos() As Integer = {234, 233, 232, 231, 230, 229} + + If Not CveCliente > 0 Then + Alert("Favor de guardar los datos del cliente antes de activar el Portal del Cliente.", TipoMensaje.MsgAdvertencia) + Return + End If + + ObjUsuario.IniciaTransacSQL() + + 'AGREGAMOS USUARIO ADMIN NUEVO + If CveUsr = 0 Then + 'CREA USUARIO + CveUsr = ObjUsuario.AddUsuarioPortal(Usuario, ContraseñaPredeterminadaEncriptada, NomUsuario, CorreoUsuario, CveCliente, -1, CvePlataforma, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CveUsr > 0 Then + ' AGREGA PERMISO A MODULO PORTALCLIENTE + If ObjUsuario.UpdateUsuariosModulos(CveUsr, 1101, True, UsuarioActual.CveUsuario) Then + 'AGREGAMOS PERMISOS A ADMIN + For Each permiso In Permisos + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsr, permiso, True, UsuarioActual.CveUsuario) Then + ErrorUsuario = True + Exit For + End If + ErrorUsuario = False + Next + If Not ErrorUsuario Then + HdnCveUsuarioPortalAdmin.Value = CveUsr.ToString + trDesactivarUsuario.Visible = True + trEnviarActivacion.Visible = False + LblUsuarioActivo.Text = "Si" + 'DivPermisosPortal.Visible = False + End If + End If + End If + Else + 'ACTUALIZAMOS ESTADO DE USARIO ADMIN INACTIVO + If ObjUsuario.UpdateUsuarioPortal(Usuario, "Admin", CorreoUsuario, True, ContraseñaPredeterminadaEncriptada, CveCliente, -1, CveUsr, UsuarioActual.CveUsuario) Then + + 'ACTUALIZAMOS PERMISOS A ADMIN + For Each permiso In Permisos + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsr, permiso, True, UsuarioActual.CveUsuario) Then + ErrorUsuario = True + Exit For + End If + ErrorUsuario = False + Next + If Not ErrorUsuario Then + HdnCveUsuarioPortalAdmin.Value = CveUsr.ToString + trDesactivarUsuario.Visible = True + trEnviarActivacion.Visible = False + LblUsuarioActivo.Text = "Si" + 'DivPermisosPortal.Visible = True + + End If + End If + End If + + 'VERIFICAMOS SI HUBO ERRORES + If ErrorUsuario Then + ObjUsuario.RollBack() + CveUsr = -1 + Else + ObjUsuario.Commit() + End If + + If CveUsr > 0 Then + 'ENVIA CORREO DE ACTIVACION + Dim ObjParametro As SisParametro = GlobalDTParametros(SisParametros.URL) + Dim Liga As String = ObjParametro.Cadena1 & "LogIn.aspx" + + If UsuarioActual.CveEmpresa = 43 Then + Liga = ObjParametro.Cadena1 & "AIMMGM/Portal.aspx" + End If + + Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsr & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa) + + If UsuarioActual.Empresa.CvePlataforma = 3 Then + EnviaCorreoGPS(Liga, LigaActivar) + Else + EnviaCorreo(Liga, LigaActivar) + End If + + 'HABILITA Y ACTUALIZA SECCION AGREGAR NUEVOS USUARIOS + ObjUsuario.GetUsuariosPortal(-1, CveCliente, -1) + + ViewState("DTUsuariosCliente") = ObjUsuario.DtResultados + GvUsuariosPortal.DataSource = ViewState("DTUsuariosCliente") + GvUsuariosPortal.DataBind() + 'divUsuariosPortal.Visible = True + ObjUsuario.Dispose() + + If UsuarioActual.Empresa.CvePlataforma = 1 Then + CargaUsuariosPortalCliente() + End If + + UpGvUsuarios.Update() + UPPUsuarios.Update() + End If + End Sub + + Protected Sub LnkAgregarUsuario_Click(sender As Object, e As EventArgs) Handles LnkAgregarUsuario.Click + Dim ObjParametro As SisParametro = GlobalDTParametros(SisParametros.URL) + Dim ObjUsuario As New ClsSisUsuarios + + Dim Liga As String = ObjParametro.Cadena1 & "Login.aspx" + Dim CveUsuario = -1 + Dim CvePlataforma As Integer = 6 + Dim ErrorUsuario As Boolean = False + + If UsuarioActual.CveEmpresa = 43 Then + Liga = ObjParametro.Cadena1 & "AIMMGM/Portal.aspx" + End If + + Dim PermisoHistorialCompras As Boolean = ChkPermiso1.Checked + Dim PermisoCxP As Boolean = ChkPermiso2.Checked + Dim PermisoAnticipo As Boolean = ChkPermiso3.Checked + Dim PermisoRH As Boolean = ChkPermiso4.Checked + Dim PermisoOS As Boolean = ChkPermiso5.Checked + Dim PermisoCotiza As Boolean = ChkPermiso6.Checked + Dim PermisoSistema As Boolean = ChkPermiso7.Checked + + ObjUsuario.IniciaTransacSQL() + + CveUsuario = ObjUsuario.AddUsuarioPortal(TxtCorreoUsuarioPortal.Text, ContraseñaPredeterminadaEncriptada, TxtNombreUsuarioPortal.Text, TxtCorreoUsuarioPortal.Text, CveCliente, -1, CvePlataforma, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + If CveUsuario > 0 Then + If ObjUsuario.UpdateUsuariosModulos(CveUsuario, 1101, True, UsuarioActual.CveUsuario) Then + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 229, PermisoHistorialCompras, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 230, PermisoCxP, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 231, PermisoAnticipo, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 232, PermisoOS, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 233, PermisoRH, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 234, PermisoSistema, UsuarioActual.CveUsuario) Then ErrorUsuario = True + If Not ObjUsuario.UpdateUsuariosProcesos(CveUsuario, 235, PermisoCotiza, UsuarioActual.CveUsuario) Then ErrorUsuario = True + End If + End If + + If ErrorUsuario Then + ObjUsuario.RollBack() + Else + ObjUsuario.Commit() + + Dim LigaActivar As String = Liga & "?p=" & Encripta("CveU=" & CveUsuario & "&Clave=" & "-acceso-" & "&Opcion=Activar&Hora=" & DateTime.Now.Ticks& & "&CveE=" & UsuarioActual.CveEmpresa) + EnviaCorreo2(Liga, LigaActivar) + + LimpiaAgregarUsuarioPortal() + + Alert("Usuario Creado.
    El usuario accesará con la contraseña '" & ContraseñaPredeterminada & "'", TipoMensaje.MsgInformacion) + End If + + ObjUsuario.GetUsuariosPortal(-1, CveCliente, -1) + ViewState("DTUsuariosCliente") = ObjUsuario.DtResultados + + ObjUsuario.Dispose() + + If ViewState("OrdenUsuarios").ToString() <> String.Empty Then + CargaGrid(ViewState("OrdenUsuarios").ToString(), 1) + Else + CargaGrid("", 1) + End If + End Sub + + Protected Sub LimpiaAgregarUsuarioPortal() + TxtNombreUsuarioPortal.Text = "" + TxtCorreoUsuarioPortal.Text = "" + + ChkPermiso1.Checked = False + ChkPermiso2.Checked = False + ChkPermiso3.Checked = False + ChkPermiso4.Checked = False + ChkPermiso5.Checked = False + ChkPermiso6.Checked = False + ChkPermiso7.Checked = False + End Sub +#End Region + +#Region "E V E N T O - B I T A C O R A" + 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(175) + e.Row.Cells(1).Width = Unit.Pixel(175) + e.Row.Cells(2).Width = Unit.Pixel(100) + e.Row.Cells(4).Width = Unit.Pixel(30) + End If + + If e.Row.DBCampo("Archivo").ToString <> "" 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 + + 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) = Anexo.getfiles().Archivos + Dim filemove As String = "" + + For Each fileItem As Archivo In filesgral + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + filemove = fileItem.filename + Next + + If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, String.Format(".{0}", FileExtension), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, -1, -1, CveCliente, -1, -1, -1, -1, -1) Then + If filemove <> "" Then + filemove.FilesMove(String.Format("OI{0}", ObjEventoBitacora.CveEvento.ToString), String.Format("Empresas\{0}\OI", UsuarioActual.CveEmpresa)) + End If + + GvEB.DataSource = ObjEventoBitacora.DtResultados + TxtEventoDescripcion.Text = "" + Anexo.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 + Private Sub CargaEventoBitacora() + Dim ObjEventoBitacora As New ClsOIEventos() + If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=CveCliente) Then + GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2") + Else + GvEB.DataSource = Nothing + End If + ObjEventoBitacora.Dispose() + GvEB.DataBind() + 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 + + + Private Sub BtnCancelarSucursal_Click(sender As Object, e As EventArgs) Handles BtnCancelarSucursal.ServerClick + GvDatos_RowCancelingEdit(Nothing, Nothing) + End Sub + + Public Sub BtnAgregaCuentaContable(sender As Object, e As EventArgs) Handles BtnActivaRegistroClientes.Click, BtnActivaRegistroAnticipos.Click, BtnActivaRegistroIVA.Click, BtnActivaRegistroISR.Click + Dim CuentaContable = DirectCast(sender, Button).CommandArgument.ToString + Dim Button = DirectCast(sender, Button) + Select Case CuentaContable + Case "Clientes" + AgregarCuentaContable(Button, DdlCtaContableClientes) + Case "Anticipos" + AgregarCuentaContable(Button, DdlCtaContableAnticipos) + Case "RetIVA" + AgregarCuentaContable(Button, DdlCtaContableRetIVA) + Case "RetISR" + AgregarCuentaContable(Button, DdlCtaContableRetISR) + End Select + + End Sub + + Private Function AgregarCuentaContable(btn As Button, ddl As DropDownList) As Boolean + Dim IdCuentaContable As Integer = -1 + Dim CtaCodigo As String = "" + Dim TieneError = False + Dim IdCtaContableClientes As Integer = -1, IdCtaContableAnticipos As Integer = -1, IdCtaContableRetIVA As Integer = -1, IdCtaContableRetISR As Integer = -1 + Dim ProcesoCorrecto As Boolean + + Dim ObjContaAC As New ClsContPAQi(UsuarioActual.Empresa) + + ObjContaAC.IniciaTransacSQL() + + Dim CuentaPadre = -1 + + Select Case btn.CommandArgument.ToString + Case "Clientes" + CuentaPadre = UsuarioActual.Empresa.Funcionalidad(211).ToEntero + Case "Anticipos" + CuentaPadre = UsuarioActual.Empresa.Funcionalidad(212).ToEntero + Case "RetIVA" + CuentaPadre = UsuarioActual.Empresa.Funcionalidad(213).ToEntero + Case "RetISR" + CuentaPadre = UsuarioActual.Empresa.Funcionalidad(214).ToEntero + + End Select + + 'SI EL NOMBRE DEL PROVEEDOR ES MAYOR DE 50 LO CORTAMOS + Dim NombreCuenta = If(TxtNombreComercial.Text.Trim.Length > 50, TxtNombreComercial.Text.Trim.Substring(0, 50), TxtNombreComercial.Text.Trim) + + IdCuentaContable = ObjContaAC.AddSiguienteCuentaHijo(CuentaPadre, NombreCuenta, Tipo:="A", CuentaMayor:=2) + If IdCuentaContable > 0 Then + + ObjContaAC.GetCuentas(IdCuentaContable, "-1", -1) + Dim dt = ObjContaAC.DtResultados + + If dt.Rows.Count = 1 Then + + Dim row As DataRow = dt.Rows(0) + CtaCodigo = CStr(row("CtaCodigo")) + + Select Case btn.CommandArgument.ToString + Case "Clientes" + IdCtaContableClientes = IdCuentaContable + Case "Anticipos" + IdCtaContableAnticipos = IdCuentaContable + Case "RetIVA" + IdCtaContableRetIVA = IdCuentaContable + Case "RetISR" + IdCtaContableRetISR = IdCuentaContable + End Select + + + Dim ObjClientes As New ClsClientes + If Not ObjClientes.VincularCuentasContables(IdCtaContableClientes, IdCtaContableAnticipos, IdCtaContableRetIVA, IdCtaContableRetISR, CveCliente) Then + TieneError = True + End If + + ObjClientes.Dispose() + + Else + TieneError = True + End If + + Else + TieneError = True + End If + + If Not TieneError Then + ObjContaAC.Commit() + Alert(String.Format("Se registo la Cuenta Contable: {0}", CtaCodigo, TipoMensaje.MsgInformacion)) + ddl.Items.Add(New ListItem(CtaCodigo, IdCuentaContable.ToString)) : ddl.SelectedValueExist(IdCuentaContable.ToString) + btn.Visible = False + ddl.Width = 206 + ProcesoCorrecto = True + Else + ObjContaAC.RollBack() + Alert("error", TipoMensaje.MsgError) + ProcesoCorrecto = False + End If + + + ObjContaAC.Dispose() + UpFiscalContable.Update() + + + Return ProcesoCorrecto + End Function + + Private Sub ActivarRegistroAutomatico() + + 'Clientes + If DdlCtaContableClientes.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(211).ToEntero > 0 Then + BtnActivaRegistroClientes.Visible = True + End If + + 'Anticipos + If DdlCtaContableAnticipos.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(212).ToEntero > 0 Then + BtnActivaRegistroAnticipos.Visible = True + End If + + 'Ret IVA + If DdlCtaContableRetIVA.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(213).ToEntero > 0 Then + BtnActivaRegistroIVA.Visible = True + End If + + 'Ret ISR + If DdlCtaContableRetISR.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(214).ToEntero > 0 Then + BtnActivaRegistroISR.Visible = True + End If + + End Sub +#End Region + +#Region " I M P R I M I R P D F" + + Protected Sub ChkAntIXCNC_CheckedChanged(sender As Object, e As EventArgs) + DdlTipoDocto.ClearSelection() + If ChkAntIXCNC.Checked Then + DdlTipoDocto.SelectedValuesIfExistM("Ing,Rem,Ant,Egs,IxC") + Else + DdlTipoDocto.SelectedValuesIfExistM("Ing,Rem") + End If + End Sub + Protected Sub LnkGenerarReporteCxC_Click(sender As Object, e As EventArgs) Handles LnkGenerarReporteCxC.Click + GenerarPDFCrystal(RBLGenerarReporteCxC.SelectedValue) + End Sub + + Protected Sub GenerarReporte(sender As Object, e As EventArgs) + GenerarRepCrystal() + End Sub + Private Sub GenerarRepCrystal() + Dim Archivo As New FileInfo(Server.MapPath("~/Empresas/Grales/Formatos/EquiposGPS.rpt")) + Dim lista = New List(Of CrystalParametro) + lista.Add(New CrystalParametro("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + lista.Add(New CrystalParametro("NombreUsuario", UsuarioActual.Nombre)) + + Dim ObjGPS As New ClsGPS + Dim tablaReporte As DataTable + If ObjGPS.DispositivosGet(-1, Estatus, CveCliente) Then + tablaReporte = ObjGPS.DtResultados + Dim VistaFiltro As DataView = New DataView(tablaReporte) + Dim reporteDatos As DataTable = VistaFiltro.ToTable("Selected", False, "TipoDispositivoDisplay", "Display", "Modelo", "Serie", "IMEI", "NumeroTelefono", "FechaIng") + Dim file As Byte() = ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/EquiposGPS.rpt"), reporteDatos, lista) + ImprimirbytesPDF(file) + Else + Alert("No hay lista de dispositivos para imprimir") + End If + + End Sub + + Private Sub GenerarPDFCrystal(Optional Formato As String = "PDF") + Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/RepClientesCxC.rpt", UsuarioActual.Empresa.Ruta)) + 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) + 'OBTENEMOS LOS DATOS + + Dim DtCxCFact As DataTable = Nothing + + Dim FI = If(TxtFechaInicioCxP.Text = "" Or TxtFechaInicioCxP.Text = "__/__/____", "-1", TxtFechaInicioCxP.Text) + Dim FF = If(TxtFechaFinCxP.Text = "" Or TxtFechaFinCxP.Text = "__/__/____", "-1", TxtFechaFinCxP.Text) + + Dim SaldoIngDolares As Double = 0 + Dim SaldoIngPesos As Double = 0 + Dim SaldoIngDolaresPesos As Double = 0 + Dim TotalIng As Double = 0 + + Dim SaldoAntDolares As Double = 0 + Dim SaldoAntPesos As Double = 0 + Dim SaldoAntDolaresPesos As Double = 0 + Dim TotalAnt As Double = 0 + Dim ContaIng As Integer = 0 + Dim ContaAnt As Integer = 0 + Dim FechaCorte As Date = ("9999/01/01").ToDate + Dim TipoDocto As String = If(DdlTipoDocto.GetSelectedValuesM = "", "-1", DdlTipoDocto.GetSelectedValuesM) + Dim TipoDocto2 As String = If(DdlTipoDocto.GetSelectedValuesM = "", "-1", DdlTipoDocto.GetSelectedValuesM(True)) + Dim FechaVencimientoI As String = If(TxtFechaVICxP.Text = "", "-1", TxtFechaVICxP.Text).ToString + Dim FechaVencimientoF As String = If(TxtFechaVFCxP.Text = "", "-1", TxtFechaVFCxP.Text).ToString + + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetCxCClienteDetalle(CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, DdlSucursalCliente.SelectedValue.ToEntero) Then + DtCxCFact = If(DdlTipoCuentasCxC.SelectedValue = "-1", ObjMovtos.DtResultados.FiltraParametros("", "TipoDocto").Copy, ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act'", "TipoDocto")) + 'cargo los anticipos NC + DtCxCFact.Columns.Add("SaldoAnticipo", GetType(Decimal)) + + Dim dtt As DataTable = Nothing + If ObjMovtos.GetAnticiposNCIxCCliente(CveCliente, -1, -1) Then + dtt = If(DdlTipoCuentasCxC.SelectedValue = "-1", ObjMovtos.DtResultados.FiltraParametros("SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) OR (Tipo = 'NC' AND CveVenta > 0) OR (Tipo = 'Egs' AND CveVenta > 0) )"), ObjMovtos.DtResultados.FiltraParametros("Saldo > 0 AND SaldoVentaAnticipo = 0 AND ((Tipo = 'IxC' AND CveIE > 0) OR (Tipo = 'Ant' AND CveVenta > 0) OR (Tipo = 'NC' AND CveVenta > 0) OR (Tipo = 'Egs' AND CveVenta > 0) )")) ' que tenga saldo de anticipo y no de cliente + If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then + For Each drt As DataRow In dtt.Rows + Dim drr As DataRow = DtCxCFact.NewRow + + drr("TipoDocto") = drt("Tipo") + drr("SerieFolio") = drt("Folio") + drr("Original") = drt("Original") + drr("TipoCambio") = drt("TipoCambio") + drr("Saldo") = 0 + drr("SaldoAnticipo") = drt("Saldo") + drr("Fecha") = drt("Fecha") + drr("Moneda") = drt("Moneda") + drr("CveMoneda") = drt("CveMoneda") + DtCxCFact.Rows.Add(drr) + + Next + End If + + End If + + End If + ObjMovtos.Dispose() + + If DtCxCFact IsNot Nothing Then + For Each Row As DataRow In DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})").Rows + If Row("TipoDocto").ToString = "Ing" Or Row("TipoDocto").ToString = "Rem" Or (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble > 0) Then 'Ingresos + ContaIng = ContaIng + 1 + If Row("CveMoneda").ToString.ToEntero = 1 Then + SaldoIngPesos = SaldoIngPesos + Row("Saldo").ToString.ToDouble + ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then + SaldoIngDolares = SaldoIngDolares + Row("Saldo").ToString.ToDouble + SaldoIngDolaresPesos = SaldoIngDolaresPesos + (Row("Saldo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble) + End If + + ElseIf (Row("TipoDocto").ToString = "Ant" And Row("Saldo").ToString.ToDouble = 0) Or Row("TipoDocto").ToString = "IxC" Or Row("TipoDocto").ToString = "NC" Or Row("TipoDocto").ToString = "Dev" Then 'Anticipos, NC, IxC + ContaAnt = ContaAnt + 1 + If Row("CveMoneda").ToString.ToEntero = 1 Then + If Row("TipoDocto").ToString = "Dev" Then + SaldoAntPesos = SaldoAntPesos + Row("Saldo").ToString.ToDouble + Else + SaldoAntPesos = SaldoAntPesos + Row("SaldoAnticipo").ToString.ToDouble + End If + ElseIf Row("CveMoneda").ToString.ToEntero = 2 Then + SaldoAntDolares = SaldoAntDolares + Row("Saldo").ToString.ToDouble + SaldoAntDolaresPesos = SaldoAntDolaresPesos + (Row("SaldoAnticipo").ToString.ToDouble * Row("TipoCambio").ToString.ToDouble) + End If + End If + Next + End If + + TotalIng = SaldoIngPesos + SaldoIngDolaresPesos + TotalAnt = SaldoAntPesos + SaldoAntDolaresPesos + + Dim DtCxCFact2 As DataTable = DtCxCFact.FiltraParametros($"TipoDocto IN ({TipoDocto2})") + + 'INGRESOS + If SaldoIngPesos > 0 Then + Dim drr As DataRow = DtCxCFact2.NewRow + drr("SerieFolio") = "Total Ing Pesos" + drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") + drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") + drr("Saldo") = SaldoIngPesos + drr("CveMoneda") = 1 + DtCxCFact2.Rows.Add(drr) + End If + If SaldoIngDolares > 0 Then + Dim drr As DataRow = DtCxCFact2.NewRow + drr("SerieFolio") = "Total Ing Dólares" + drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") + drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") + drr("Saldo") = SaldoIngDolares + drr("CveMoneda") = 2 + DtCxCFact2.Rows.Add(drr) + End If + + 'ANTICIPOS + If SaldoAntPesos > 0 Then + Dim drr As DataRow = DtCxCFact2.NewRow + drr("SerieFolio") = "Total Pesos" + 'drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('IxC','Egs,'Dev') OR (TipoDocto = 'Ant' AND Saldo = 0)") + 'drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('IxC','Egs','Dev') OR (TipoDocto = 'Ant' AND Saldo = 0)") + drr("SaldoAnticipo") = SaldoAntPesos + drr("CveMoneda") = 1 + DtCxCFact2.Rows.Add(drr) + End If + If SaldoAntDolares > 0 Then + Dim drr As DataRow = DtCxCFact2.NewRow + drr("SerieFolio") = "Total Dólares" + ' drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Original", "TipoDocto IN ('IxC','Egs,'Dev') OR (TipoDocto = 'Ant' AND Saldo = 0)") + ' drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 2").SUM("Abonado", "TipoDocto IN ('IxC','Egs,'Dev') OR (TipoDocto = 'Ant' AND Saldo = 0)") + drr("SaldoAnticipo") = SaldoAntDolares + drr("CveMoneda") = 2 + DtCxCFact2.Rows.Add(drr) + End If + + If DtCxCFact2 IsNot Nothing AndAlso DtCxCFact2.Rows.Count > 0 Then + Dim dr As DataRow = DtCxCFact2.Rows(0) + Dim lista = New List(Of CrystalParametro) + lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa)) + lista.Add(New CrystalParametro("TipoCuentas", DdlTipoCuentasCxC.SelectedItem.Text)) + lista.Add(New CrystalParametro("NombreCliente", LtlCliente.Text)) + lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI))) + lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF))) + lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) + lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", TxtDireccion.Text, If(TxtNoExt.Text = "", "S/N", TxtNoExt.Text), TxtColonia.Text))) + lista.Add(New CrystalParametro("ClienteCP", TxtCP.Text)) + lista.Add(New CrystalParametro("ClienteCiudad", TxtCiudad.Text)) + lista.Add(New CrystalParametro("ClienteRFC", TxtRFC.Text)) + lista.Add(New CrystalParametro("ClienteTelefono", TxtTelefono.Text)) + lista.Add(New CrystalParametro("DiasCredito", TxtPlazoCobranza.Text)) + lista.Add(New CrystalParametro("LimiteCredito", TxtLimiteCredito.Text)) + lista.Add(New CrystalParametro("SaldoDisponible", (TxtLimiteCredito.Text.ToDouble - DtCxCFact2(0)("Saldo").ToString.ToDouble).FormatoNumero)) + + lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero)) + lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero)) + lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero)) + lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero)) + lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero)) + lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero)) + lista.Add(New CrystalParametro("ContaIng", ContaIng)) + lista.Add(New CrystalParametro("ContaAnt", ContaAnt)) + + + + If Imagen.Exists Then + lista.Add(New CrystalParametro("LogoPath", logouri)) + Else + lista.Add(New CrystalParametro("LogoPath", "")) + End If + + If ChkCobranzaEnviarCorreo.Checked Then + Try + Dim File As Byte() + If Archivo.Exists Then + File = ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato) + Else + File = ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato) + End If + + Try + Dim Cuerpo As String = String.Format("Estimado cliente {0}, al presente del correo se anexa su estado actual de cartera en {1}.
    +
    + Quedamos a sus ordenes para cualquier duda o aclaración con su agente de Ventas.
    +
    +
    + Gracias por la atención brindada al presente.
    Reciba un cordial saludo.
    +
    + ESTE CORREO SE GENERO EN FORMA AUTOMATICA.", TxtNombreComercial.Text, UsuarioActual.Empresa.Empresa) + Dim Hilo As New System.Threading.Thread(Sub() MandaCorreoEstadoCuenta(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Me.CveCliente, File, TxtCobranzaCorreo.Text, $"Estado Actual de Cartera {UsuarioActual.Empresa.Empresa}", Cuerpo, GuardarBitacora:=True)) + Hilo.Start() + Alert("El correo se envió con éxito", TipoMensaje.MsgInformacion) + Catch ex As Exception + Alert("Ocurrió un error al enviar el correo", TipoMensaje.MsgAdvertencia) + + End Try + + Catch ex As Exception + OnError("Ocurrió error al mandar MAIL de Orden de Compra", ex) + End Try + Else + If Archivo.Exists Then + ImprimirbytesPDF(ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) + Else + ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) + End If + + End If + Else + Dim lista = New List(Of CrystalParametro) + lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa)) + lista.Add(New CrystalParametro("TipoCuentas", DdlTipoCuentasCxC.SelectedItem.Text)) + lista.Add(New CrystalParametro("NombreCliente", LtlCliente.Text)) + lista.Add(New CrystalParametro("FechaInicio", If(FI = "-1", "-", FI))) + lista.Add(New CrystalParametro("FechaFin", If(FF = "-1", DateTime.Now.ToShortDateString, FF))) + lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) + lista.Add(New CrystalParametro("DireccionCliente", String.Format("Calle {0} #{1} Colonia {2}", TxtDireccion.Text, If(TxtNoExt.Text = "", "S/N", TxtNoExt.Text), TxtColonia.Text))) + lista.Add(New CrystalParametro("ClienteCP", TxtCP.Text)) + lista.Add(New CrystalParametro("ClienteCiudad", TxtCiudad.Text)) + lista.Add(New CrystalParametro("ClienteRFC", TxtRFC.Text)) + lista.Add(New CrystalParametro("ClienteTelefono", TxtTelefono.Text)) + lista.Add(New CrystalParametro("DiasCredito", TxtPlazoCobranza.Text)) + lista.Add(New CrystalParametro("LimiteCredito", TxtLimiteCredito.Text)) + lista.Add(New CrystalParametro("SaldoDisponible", (TxtLimiteCredito.Text.ToDouble).FormatoNumero)) + + lista.Add(New CrystalParametro("SaldoIngDolares", SaldoIngDolares.FormatoNumero)) + lista.Add(New CrystalParametro("SaldoIngPesos", SaldoIngPesos.FormatoNumero)) + lista.Add(New CrystalParametro("TotalIng", TotalIng.FormatoNumero)) + lista.Add(New CrystalParametro("SaldoAntDolares", SaldoAntDolares.FormatoNumero)) + lista.Add(New CrystalParametro("SaldoAntPesos", SaldoAntPesos.FormatoNumero)) + lista.Add(New CrystalParametro("TotalAnt", TotalAnt.FormatoNumero)) + lista.Add(New CrystalParametro("ContaIng", ContaIng)) + lista.Add(New CrystalParametro("ContaAnt", ContaAnt)) + + If Imagen.Exists Then + lista.Add(New CrystalParametro("LogoPath", logouri)) + Else + lista.Add(New CrystalParametro("LogoPath", "")) + End If + + Dim drr As DataRow = DtCxCFact2.NewRow + drr("SerieFolio") = "Total Ing Pesos" + drr("Original") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Original", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") + drr("Abonado") = DtCxCFact2.FiltraParametros("CveMoneda = 1").SUM("Abonado", "TipoDocto IN ('Ing','Rem') OR (TipoDocto = 'Ant' AND Saldo > 0)") + drr("Saldo") = 0 + drr("SaldoAnticipo") = 0 + drr("CveMoneda") = 1 + DtCxCFact2.Rows.Add(drr) + + If Archivo.Exists Then + ImprimirbytesPDF(ImprimirPDFCrystal($"{UsuarioActual.Empresa.Ruta}Formatos/RepClientesCxC.rpt", DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) + Else + ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/RepClientesCxC.rpt"), DtCxCFact2.FiltraParametros("", "CveMoneda,Fecha"), lista, "Estado de cuenta", Formato), "Estado de cuenta", Formato) + End If + End If + End Sub + Private Sub MandaCorreoEstadoCuenta(CveUsuario As Integer, CveEmpresa As Integer, CveCliente As Integer, File As Byte(), Para As String, Asunto As String, Body As String, Optional GuardarBitacora As Boolean = False) + + Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) + 'a.GuardaLog() + Dim Mail As New ClsSisMail() + + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.ArchivoBinario = File, .NombreArchivo = "EstadoDeCuenta.pdf"}) + Dim Envio As Boolean = Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body, Archivos:=LSRutasMail) If Envio AndAlso GuardarBitacora Then Using ObjBitacora As New ClsOIEventos ObjBitacora.AddEventoBitacora("Se envió correo con el estado de cuenta del cliente", "", CveUsuario, CveEmpresa, CveCliente:=CveCliente) End Using - End If - - End Sub -#End Region + End If -#Region "E N V I O C O R R E O" - Private Sub EnviaCorreo(Liga As String, LigaActivar As String) - - Try - Dim Para = TxtEmail.Text.Trim - Dim Asunto = "ACTIVACIÓN DEL PORTAL DE CLIENTE" - Dim Usuario = TxtEmail.Text.Trim - - Dim SBBody As New StringBuilder - 'Linia de estilos - SBBody.Append("") - 'incio Cuerpo del correo - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("ALTA DE CUENTA") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.AppendFormat(" Estimado {0}:
    ", TxtNombre.Text.ToUpper) - SBBody.AppendFormat("El presente correo es para informarle que se le han asignado los siguientes datos para el acceso al Portal del Cliente de: {0}

    ", UsuarioActual.Empresa.Empresa) - - SBBody.Append("
    ") - SBBody.Append("
    Datos de Usuario:
    ") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("
    Dirección de Acceso
    ") - SBBody.AppendFormat("", Liga) - SBBody.Append("
    ") - SBBody.Append("
    ") - - SBBody.Append("
    Usuario:
    ") - SBBody.AppendFormat("
    {0}
    ", Usuario) - SBBody.Append("
    ") - SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    Haga click para activar su cuenta
    ") - SBBody.AppendFormat("", LigaActivar) - SBBody.Append("
    ") - - - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("Para Activar su cuenta debera cambiar su contraseña.

    ") - SBBody.Append("
    ") - SBBody.Append("Nota Favor de NO responder este correo. ") - SBBody.Append("


    ") - SBBody.AppendFormat("", UrlSitio) - SBBody.Append("
    ") - SBBody.Append("") - 'Termino Cuerpo del correo - - Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Asunto, Para, SBBody.ToString)) - Hilo.Start() - Alert("El correo se ha enviado correctamente a: " + TxtEmail.Text + ".", TipoMensaje.MsgInformacion) - Catch ex As Exception - OnError("Ocurrió error al mandar MAIL", ex) - End Try - End Sub - - - Private Sub MandaCorreo(Asunto As String, Para As String, Body As String) - Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) - a.GuardaLog() - Dim Mail As New ClsSisMail() - Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body) - End Sub -#End Region - -#Region " COTIZACIONES " - - Protected Sub BtnVerMasCot_Click(sender As Object, e As EventArgs) - If BtnVerMasCot.Text = "Ver Más" Then - CargaCotizaciones(-1) - BtnVerMasCot.Text = "Ver Menos" - Else - CargaCotizaciones(21) - BtnVerMasCot.Text = "Ver Más" - End If - End Sub - Private Function CargaCotizaciones(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1) As Boolean - Dim Retorno As Boolean = False - Dim ObjClientes As New ClsClientes() - If ObjClientes.GetCotizaciones(CveCliente, SelectTop, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) Then - If ObjClientes.DtResultados.Rows.Count > 0 Then - 'Carga Generales - LtlCantidadCotizaciones.Text = ObjClientes.DtResultados.Rows(0)("CountTotal").ToString.FormatoNumero(2) - LtlFactorCotVentas.Text = If(LtlCantidad.Text.ToEntero > 0, (LtlCantidadCotizaciones.Text.ToEntero / LtlCantidad.Text.ToEntero).FormatoNumero, "0.00") - 'Carga Grid - GvCot.DataSource = ObjClientes.DtResultados - DtCotizaciones = ObjClientes.DtResultados - - If UsuarioActual.Empresa.UsaOS Then - GvCot.Columns(9).Visible = True - Else - GvCot.Columns(9).Visible = True - End If - - - Else - LtlCantidadCotizaciones.Text = "0" - LtlFactorCotVentas.Text = "0.00" - GvCot.DataSource = Nothing - DtCotizaciones = Nothing - End If - Else - GvCot.DataSource = Nothing - DtCotizaciones = Nothing - End If - ObjClientes.Dispose() - GvCot.DataBind() - Return Retorno - End Function - Protected Sub GVCotizaciones_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCot.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - Dim HLFacturar As HtmlAnchor = DirectCast(e.Row.FindControl("HLFacturarCot"), HtmlAnchor) - - - 'CABECERA - If e.Row.RowIndex = 0 Then - e.Row.BackColor = Drawing.Color.LightGray - DirectCast(e.Row.FindControl("HLSendMail2"), HtmlAnchor).Visible = False - e.Row.FindControl("HlOS").Visible = False - HLFacturar.Visible = False - End If - - e.Row.FCLiteral("LtlCotizacion").Text = String.Format("{1}", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("SerieFolio")) - e.Row.FCLiteral("LtlFolioVenta").Text = String.Format("{1}", e.Row.DBCampo("CveVentaPadre"), e.Row.DBCampo("FolioVenta")) - DirectCast(e.Row.FindControl("HLSendMail2"), HtmlAnchor).HRef = String.Format("javascript:$get('HdnTipoDocto2').value='Cot';$get('HdnCveVenta2').value='{0}';$get('HdnFolioVenta2').value='{1}';$get('TxtParaMail2').value='{2}';$get('HdnSerieFolio2').value='{2}';$get('HdnSubProyecto2').value='{2}'; $('#ModalDivMail2').modal();", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("Correo"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("SubProyecto")) - - - - 'FACTURAR COTIZACION - If e.Row.DBCampo("FolioVenta") <> "" Then - HLFacturar.Visible = False - Else - HLFacturar.HRef = $"/Ventas/Ventas.aspx?CveCotizacion={e.Row.DBCampo("CveVenta")}" - End If - End If - End Sub -#End Region - -#Region "D I R E C C I O N E N V I O " - Public Sub Edit_Click(sender As Object, e As EventArgs) - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - CveDireccionEnvio = GvRow.DataKey("CveDireccionEnvio").ToEntero - TxtEnvioDireccion.Text = GvRow.DataKey("EnvioDireccion") - TxtEnvioNoExt.Text = GvRow.DataKey("EnvioNoExt") - TxtEnvioNoInt.Text = GvRow.DataKey("EnvioNoInt") - TxtEnvioColonia.Text = GvRow.DataKey("EnvioColonia") - TxtEnvioCiudad.Text = GvRow.DataKey("EnvioCiudad") - TxtEnvioEstado.Text = GvRow.DataKey("EnvioEstado") - TxtEnvioContacto.Text = GvRow.DataKey("EnvioContacto") - 'TxtDepartamento.Text = GvRow.DataKey("EnvioDepartamento") - TxtEnvioCP.Text = GvRow.DataKey("EnvioCP") - TxtEnvioTel.Text = GvRow.DataKey("EnvioTel") - ChkEstatus.Checked = If(GvRow.DataKey("Estatus").ToString = "True", True, False) - If GvRow.DataKey("CveClienteSucursal").ToEntero > 0 Then DdlClienteSucursalEnvio.SelectedValueExist(GvRow.DataKey("CveClienteSucursal")) Else DdlClienteSucursalEnvio.SelectedValueExist("-1") - UpAddDireccion.Update() - RegistraScript("$('#divAddDireccionEnvio').modal();") - End Sub - Private Sub BtnAgregarDireccion_Click(sender As Object, e As EventArgs) Handles BtnAgregarDireccion.Click - Dim ObjClientes As New ClsClientes - Dim TieneError = False - Dim Estatus = If(ChkEstatus.Checked, 1, 0) - - If CveDireccionEnvio < 0 Then - CveDireccionEnvio = ObjClientes.DireccionEnvioAdd(CveCliente, TxtEnvioDireccion.Text.Trim, TxtEnvioNoExt.Text.Trim, TxtEnvioNoInt.Text.Trim, TxtEnvioColonia.Text.Trim, TxtEnvioCiudad.Text.Trim, TxtEnvioEstado.Text.Trim, TxtEnvioCP.Text.ToEntero, TxtEnvioContacto.Text.Trim, UsuarioActual.CveUsuario, Estatus, CveClienteSucursal:=DdlClienteSucursalEnvio.SelectedValue.ToEntero, EnvioTel:=TxtEnvioTel.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "")) - - If CveDireccionEnvio < 0 Then - TieneError = True - End If - Else - - If Not ObjClientes.DireccionEnvioUpdate(CveCliente, TxtEnvioDireccion.Text.Trim, TxtEnvioNoExt.Text.Trim, TxtEnvioNoInt.Text.Trim, TxtEnvioColonia.Text.Trim, TxtEnvioCiudad.Text.Trim, TxtEnvioEstado.Text.Trim, TxtEnvioCP.Text.ToEntero, TxtEnvioContacto.Text.Trim, UsuarioActual.CveUsuario, Estatus, CveDireccionEnvio, CveClienteSucursal:=DdlClienteSucursalEnvio.SelectedValue.ToEntero, EnvioTel:=TxtEnvioTel.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "")) Then - TieneError = True - End If - - End If - - If TieneError Then - Alert("Ocurrio un error al agregar/actualizar la dirección de envío", TipoMensaje.MsgError) - Else - RegistraScript("$('#divAddDireccionEnvio').modal('hide');") - CveDireccionEnvio = -1 - CargaDireccionesEnvio() - End If - End Sub - Private Sub BtnAgregarDireccionModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarDireccionModal.Click - TxtEnvioDireccion.Text = "" - TxtEnvioNoExt.Text = "" - TxtEnvioNoInt.Text = "" - TxtEnvioColonia.Text = "" - TxtEnvioCiudad.Text = "" - TxtEnvioEstado.Text = "" - TxtEnvioContacto.Text = "" - 'TxtDepartamento.Text = "" - TxtEnvioCP.Text = "" - TxtEnvioTel.Text = "" - DdlClienteSucursalEnvio.SelectedValue = "-1" - UpAddDireccion.Update() - RegistraScript("$('#divAddDireccionEnvio').modal();") - End Sub - Private Sub GvDireccionesEnvio_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDireccionesEnvio.RowDeleting - Dim ObjClientes As New ClsClientes - Dim TieneError = False - - Dim CveDireccionEnvio As Integer = GvDireccionesEnvio.Rows(e.RowIndex).DataKey("CveDireccionEnvio").ToEntero - - If Not ObjClientes.DireccionEnvioRemove(CveDireccionEnvio) Then - TieneError = True - End If - - If Not TieneError Then - GvDireccionesEnvio.EditIndex = -1 - Alert("Se eliminó correctamente la dirección de envío.", TipoMensaje.MsgInformacion) - Else - Alert("Ocurrió un error al eliminar la dirección de envío.", TipoMensaje.MsgAdvertencia) - End If - - CargaDireccionesEnvio() - End Sub - -#End Region - -#Region " IMPORTAR SALDOS " - - Private Sub HLImportarSaldos_Click(sender As Object, e As EventArgs) Handles HLImportarSaldos.Click - CargaClientesImportarSaldos() - RegistraScript(String.Format("$('#{0}').modal();", "DivImportarSaldos")) - End Sub - - Private Sub CargaClientesImportarSaldos() - DdlClienteImportarSaldos.setEsWebService(True) '(UsuarioActual.Empresa.Funcionalidad(105) = "1") - 'DdlClienteImportarSaldos.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) - 'DdlClienteImportarSaldos.DataBind() - UpImportarSaldos.Update() - 'DdlClienteImportarSaldos.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - Protected Sub BtnConsultarSaldoCliente_Click(sender As Object, e As EventArgs) - ConsultarAnticiposSaldosClientes() - End Sub - Private Sub ConsultarAnticiposSaldosClientes() - Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetAnticiposNCIxCCliente(DdlClienteImportarSaldos.SelectedValue.ToEntero) Then - GvImportarSaldos.DataSource = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0 AND Saldo > 0 AND CveIE > 0") - Else - GvImportarSaldos.DataSource = Nothing - End If - ObjMovtos.Dispose() - - TxtSaldoImportar.Text = "" - - GvImportarSaldos.DataBind() - UpImportarSaldos.Update() - End Sub - Protected Sub BtnGuardarTransferencias_Click(sender As Object, e As EventArgs) - Dim EsValida = False - - For Each Gvr As GridViewRow In GvImportarSaldos.Rows - If Gvr.FCCheckBox("Chk").Checked AndAlso Gvr.FCTextBox("TxtImporte").Text.ToDouble > 0 Then - EsValida = True - End If - Next - - If Not EsValida Then - Alert("El importe a importar de saldos debe ser mayor a cero. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim ObjConta As New ClsContabilidad - ObjConta.IniciaTransacSQL() - Dim TieneError = False - - - Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Clientes/ImportarSaldos", 53, TxtCantidad.Text.Trim.ToDouble, TxtCantidad.Text.Trim.ToDouble, 1, TxtFechaImportarSaldos.Text.ToDate, "Traspaso de saldos de anticipos", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - Dim IVA As Decimal = 0 - Dim Importe As Decimal = 0 - Dim ImporteAplicar As Decimal = 0 - If CvePrePoliza > 0 Then - For Each Gvr As GridViewRow In GvImportarSaldos.Rows - If Gvr.FCCheckBox("Chk").Checked AndAlso Gvr.FCTextBox("TxtImporte").Text.ToDouble > 0 Then - - Importe = Gvr.FCTextBox("TxtImporte").Text.ToDecimal - IVA = Importe / Gvr.DataKey("Original").ToString.ToDecimal * Gvr.DataKey("IVA").ToString.ToDecimal 'TOMA EN CUENTA EL IVA - CONCEPTO DIFERENTE - ImporteAplicar = -(Importe - IVA) - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteAplicar, "Traspaso de saldos de anticipos", 92, "Traspaso de saldos de anticipos.IVA", Now, 0, -1, CveCliente:=Gvr.DataKey("CveCliente").ToString.ToEntero, CveIE:=Gvr.DataKey("CveIE").ToString.ToEntero, ImporteMX:=ImporteAplicar) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAplicar, "Traspaso de saldos de anticipos", 66, "Traspaso de saldos de anticipos.IVA", Now, 0, -1, CveCliente:=CveCliente, CveIE:=Gvr.DataKey("CveIE").ToString.ToEntero, ImporteMX:=ImporteAplicar) Then - TieneError = True - End If - Else - TieneError = True - End If - - If Not TieneError Then - If IVA > 0 Then - If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -IVA, "Traspaso de saldos de anticipos.IVA", 61, "Traspaso de saldos de anticipos.IVA", Now, 0, -1, CveCliente:=Gvr.DataKey("CveCliente").ToString.ToEntero, CveIE:=Gvr.DataKey("CveIE").ToString.ToEntero, ImporteMX:=-IVA) Then - If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, "Traspaso de saldos de anticipos. IVA", 61, "Traspaso de saldos de anticipos.IVA", Now, 0, -1, CveCliente:=CveCliente, CveIE:=Gvr.DataKey("CveIE").ToString.ToEntero, ImporteMX:=IVA) Then - TieneError = True - End If - Else - TieneError = True - End If - End If - End If - - - End If - Next - Else - TieneError = True - End If - - - If Not TieneError Then - ObjConta.Commit() - Alert($"La importación de saldos se hizo correctamente.", TipoMensaje.MsgInformacion) - TxtSaldoImportar.Text = "" - ConsultarAnticiposSaldosClientes() - Else - ObjConta.RollBack() - Alert("Ocurrió un error al importar los saldos. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - - ObjConta.Dispose() - End Sub - - Protected Sub GvImportarSaldos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvImportarSaldos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ChkSaldo(this,{0},{1});", e.Row.FCTextBox("TxtImporte").ClientID, e.Row.DBCampo("Saldo"))) - e.Row.FCTextBox("TxtImporte").Attributes.Add("onKeyUp", String.Format("CambiaSaldo({0},this,{1});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"))) - End If - End Sub -#End Region - -#Region "Cuentas/Equipos" - Public Sub BtnAgregarCtaEquipo_Click(sender As Object, e As EventArgs) - HdnModalidad.Value = "I" - DivCicloComercial.Visible = False - TxtIdentificador.Text = "" - TxtNoSerie.Text = "" - DdlTipoCuentaDetalle.SelectedIndex = 0 - ChkAnticipo.Checked = False - PnlCicloComercial.Visible = False - CargaCuentasCaracteristicas() - UpBodyAgregarCuenta.Update() - UpDatos.Update() - RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarCuenta")) - End Sub - Private Sub BtnGuardarCuenta_Click(sender As Object, e As EventArgs) Handles BtnGuardarCuenta.Click - Dim objCuentasEquipos As New ClsGenerales() - Dim TieneError = False - objCuentasEquipos.IniciaTransacSQL() - - If HdnModalidad.Value = "I" Then - If Not objCuentasEquipos.AddCuentaEquipo(CveCliente, DdlTipoCuentaDetalle.SelectedValue.ToEntero, TxtIdentificador.Text.Trim, TxtNoSerie.Text.Trim, DdlClienteSucursal.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - TieneError = True - End If - - If Not GuardaCaracteristicas(HdnModalidad.Value.ToString, objCuentasEquipos.CveCuentaEquipo, objCuentasEquipos) Then - TieneError = True - End If - - ElseIf HdnModalidad.Value = "U" Then - - If Not objCuentasEquipos.UpdateCuentaEquipo(TxtIdentificador.Text, TxtNoSerie.Text, True, DdlClienteSucursal.SelectedValue.ToEntero, CveCuentaEquipo) Then - TieneError = True - End If - - If Not GuardaCaracteristicas(HdnModalidad.Value.ToString, CveCuentaEquipo, objCuentasEquipos) Then - TieneError = True - End If - - End If - - If Not TieneError Then - objCuentasEquipos.Commit() - CargaCuentasEquipos() - TxtIdentificador.Text = "" - TxtNoSerie.Text = "" - DdlTipoCuentaDetalle.SelectedIndex = 0 - ChkAnticipo.Checked = False - Alert("Se agregó/Actualizó correctamente la Cuenta/Equipo.", TipoMensaje.MsgInformacion) - UpBodyAgregarCuenta.Update() - Else - Alert("Ocurrió un erro al Agregar/Actualizar la Cuenta/Equipo.", TipoMensaje.MsgInformacion) - objCuentasEquipos.RollBack() - End If - - objCuentasEquipos.Dispose() - RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarCuenta")) - UpDatos.Update() - End Sub - Private Sub ChkCicloComercial_CheckedChanged(sender As Object, e As EventArgs) Handles ChkCicloComercial.CheckedChanged - If ChkCicloComercial.Checked = True Then - PnlCicloComercial.Visible = True - - DdlPS.Items.Clear() - DdlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - DdlPS.DataBind() - DdlPS.Items.Insert(0, New ListItem("Seleccione", "-1")) - - Else - PnlCicloComercial.Visible = False - End If - End Sub - Private Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) Handles BtnAgregarPS.Click - Dim Objeto As New ClsGenerales - If Objeto.AddCuentaEquipoPS(DdlPS.SelectedValue.ToEntero, CveCuentaEquipo) Then - Alert("Se ha agregado correctamente.", TipoMensaje.MsgInformacion) - CargaGridPS() - End If - Objeto.Dispose() - End Sub - Private Sub CargaGridPS() - Dim Objeto As New ClsGenerales() - If Objeto.GetCuentaEquipoPS(CveCuentaEquipo) Then - GvPS.DataSource = Objeto.DtResultados - GvPS.DataBind() - Objeto.Dispose() - End If - UpDatos.Update() - - End Sub - Public Sub imgE_Click(sender As Object, e As EventArgs) - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Dim Objeto As New ClsGenerales() - - HdnModalidad.Value = "U" - CveCuentaEquipo = GvRow.DataKey("CveCuentaEquipo").ToString.ToEntero - TxtIdentificador.Text = GvRow.DataKey("CuentaEquipo") - TxtNoSerie.Text = GvRow.DataKey("NoSerie") - DdlTipoCuentaDetalle.SelectedValueExist(GvRow.DataKey("CveTipoCuentaEquipo")) - BtnGuardarCuenta.Text = "Guardar" - DivCicloComercial.Visible = True - - If Objeto.GetCuentaEquipoPS(CveCuentaEquipo) Then - If Objeto.DtResultados.Rows.Count > 0 Then - GvPS.DataSource = Objeto.DtResultados - GvPS.DataBind() - ChkCicloComercial.Checked = True - PnlCicloComercial.Visible = True - DdlPS.Items.Clear() - DdlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - DdlPS.DataBind() - DdlPS.Items.Insert(0, New ListItem("Seleccione", "-1")) - Else - ChkCicloComercial.Checked = False - PnlCicloComercial.Visible = False - End If - End If - - If Objeto.GetCaracteristicasValores(-1, -1, -1, -1, CveCuentaEquipo, -1, 6, UsuarioActual.CveEmpresa) Then - GvCuentasCaracteristicas.DataSource = Objeto.DtResultados - Else - GvCuentasCaracteristicas.DataSource = Nothing - End If - GvCuentasCaracteristicas.DataBind() - GvCuentasCaracteristicas.Visible = True - GvAddCuentaCaracteristica.Visible = False - - UpDatos.Update() - UpBodyAgregarCuenta.Update() - UpAgregarCuenta.Update() - Objeto.Dispose() - RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarCuenta")) - End Sub - Protected Sub GvCuentasEquipos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvCuentasEquipos.RowDeleting - Dim Objeto As New ClsGenerales - Dim TieneError = False - If Objeto.RemoveCuentaEquipo(GvCuentasEquipos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then - Alert("La cuenta Equipo se eliminó correctamente.", TipoMensaje.MsgInformacion) - Else - TieneError = True - Alert("Error al eliminar la cuenta/equipo.", TipoMensaje.MsgError) - End If - Objeto.Dispose() - UpDatos.Update() - CargaCuentasEquipos() - - - End Sub - Public Sub GvPS_Delete(sender As Object, e As EventArgs) - Dim Objeto As New ClsGenerales - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - - Dim CveCtaEq As Integer = GvRow.DataKey("CveCuentaEquipo").ToString.ToEntero - Dim CvePS As Integer = GvRow.DataKey("CvePS").ToString.ToEntero - - If Objeto.RemoveCuentaEquipoPS(CvePS, CveCtaEq) Then - Alert("El PS se eliminó correctamente.", TipoMensaje.MsgInformacion) - Else - Alert("Error al eliminar el PS", TipoMensaje.MsgError) - End If - - CargaGridPS() - UpDatos.Update() - Objeto.Dispose() - End Sub - Private Sub CargaCuentasCaracteristicas() - Dim ObjCaracteristicas As New ClsGenerales - - - If ObjCaracteristicas.GetCaracteristicas(-1, 6, UsuarioActual.CveEmpresa) Then - GvAddCuentaCaracteristica.DataSource = ObjCaracteristicas.DtResultados - Else - GvAddCuentaCaracteristica.DataSource = Nothing - End If - GvAddCuentaCaracteristica.DataBind() - GvAddCuentaCaracteristica.Visible = True - GvCuentasCaracteristicas.Visible = False - - ObjCaracteristicas.Dispose() - End Sub - Private Sub GvCuentasCaracteristicas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCuentasCaracteristicas.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - Dim CveCaracteristicaTipo As Integer = e.Row.DataKey("CveCaracteristicaTipo").ToEntero - Dim dtTemp As New DataTable - Dim objCaracteristicas As New ClsGenerales - - Dim CveCaracteristica As Integer = e.Row.DataKey("CveCaracteristica").ToEntero - Dim CveCaracteristicaValor As Integer = e.Row.DataKey("CveCaracteristicaValor").ToEntero - Dim CveCaracteristicaOpcion As Integer = e.Row.DataKey("CveCaracteristicaOpcion").ToEntero - Dim CaracteristicaValor As String = e.Row.DataKey("CaracteristicaValor") - Dim Logitud As Integer = e.Row.DataKey("Longitud").ToString.ToEntero - - Dim DdlCarcateristicaOpcion As DropDownList = e.Row.FCDropDownList("DdlCarcateristicaOpcion") - Dim TxtCuentaValor As TextBox = e.Row.FCTextBox("TxtCuentaValor") - Dim RdlCarcateristicaOpcion As RadioButtonList = e.Row.FCRadioButtonList("RdlCarcateristicaOpcion") - Dim chkCaracteristicaValor As CheckBox = e.Row.FCCheckBox("chkCaracteristicaValor") - - Dim Requerido As Integer - If e.Row.DataKey("Requerido").ToString.ToUpper = "TRUE" Then - Requerido = 1 - Else - Requerido = 0 - End If - - TxtCuentaValor.Visible = False - Dim RFVCuentaValor1 As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("RFVCuentaValor1") - RFVCuentaValor1.Enabled = False - - DdlCarcateristicaOpcion.Visible = False - Dim rfvDdlCarcateristicaOpcion1 As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("rfvDdlCarcateristicaOpcion1") - rfvDdlCarcateristicaOpcion1.Enabled = False - - RdlCarcateristicaOpcion.Visible = False - Dim rfvRdlCarcateristicaOpcion = e.Row.FCRequiredFieldValidator("rfvRdlCarcateristicaOpcion") - rfvRdlCarcateristicaOpcion.Enabled = False - - Dim CalendarioCaractersiticas As AjaxControlToolkit.CalendarExtender = e.Row.FCCalendarExtender("CalendarioCaractersiticas") - CalendarioCaractersiticas.Enabled = False - - Dim _cvFechaF As CompareValidator = e.Row.FCCompareValidator("cvFechaF") - _cvFechaF.Enabled = False - - chkCaracteristicaValor.Visible = False - - If objCaracteristicas.GetCaracteriscasOpciones(-1, UsuarioActual.Empresa.CveEmpresa) Then - dtTemp = objCaracteristicas.DtResultados - End If - - If CaracteristicaValor.Length > 0 Then - TxtCuentaValor.Text = CaracteristicaValor - End If - - Select Case CveCaracteristicaTipo - Case 0 - 'txt - TxtCuentaValor.Visible = True - TxtCuentaValor.MaxLength = Logitud - If Requerido = 1 Then - RFVCuentaValor1.Enabled = True - End If - Exit Select - Case 1 - DdlCarcateristicaOpcion.Visible = True - dtTemp = dtTemp.FiltraParametros(" CveCaracteristica = " & CveCaracteristica) - DdlCarcateristicaOpcion.DataSource = dtTemp - DdlCarcateristicaOpcion.DataBind() - DdlCarcateristicaOpcion.Items.Insert(0, New ListItem("-", "-1")) - - If CveCaracteristicaValor <> -1 Then - DdlCarcateristicaOpcion.SelectedValueExist(CveCaracteristicaOpcion) - End If - - If Requerido = 1 Then - rfvDdlCarcateristicaOpcion1.Enabled = True - End If - Exit Select - Case 2 - 'radio - RdlCarcateristicaOpcion.Visible = True - dtTemp = dtTemp.FiltraParametros(" CveCaracteristica = " & CveCaracteristica) - RdlCarcateristicaOpcion.DataSource = dtTemp - RdlCarcateristicaOpcion.DataBind() - - If CveCaracteristicaValor <> -1 Then - RdlCarcateristicaOpcion.SelectedValuesIfExist(CveCaracteristicaOpcion.ToString) - End If - - If Requerido = 1 Then - rfvRdlCarcateristicaOpcion.Enabled = True - End If - Exit Select - Case 3 - 'Fecha txt Fecha - TxtCuentaValor.Visible = True - TxtCuentaValor.Width = 120 - cvFechaF.Enabled = True - CalendarioCaractersiticas.Enabled = True - RegistraScript(" $('#" & TxtCuentaValor.ClientID & "').mask('00/00/0000'); ") - If Requerido = 1 Then - RFVCuentaValor1.Enabled = True - End If - Exit Select - Case 4 - 'Multiline - TxtCuentaValor.Visible = True - TxtCuentaValor.MaxLength = Logitud - If Requerido = 1 Then - RFVCuentaValor1.Enabled = True - End If - Exit Select - Case 5 - 'CheckBox - chkCaracteristicaValor.Visible = True - If CaracteristicaValor = "1" Then - chkCaracteristicaValor.Checked = True - Else - chkCaracteristicaValor.Checked = False - End If - - Exit Select - Case 6 - TxtCuentaValor.Visible = True - TxtCuentaValor.TextMode = TextBoxMode.Number - - If Requerido = 1 Then - RFVCuentaValor1.Enabled = True - End If - Exit Select - End Select - - objCaracteristicas.Dispose() - End If - End Sub - Private Sub GvAddCuentaCaracteristica_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAddCuentaCaracteristica.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - Dim CveCaracteristicaTipo As Integer = e.Row.DataKey("CveCaracteristicaTipo").ToEntero - Dim dtTemp As New DataTable - Dim objCaracteristicas As New ClsGenerales - - Dim CveCaracteristica As Integer = e.Row.DataKey("CveCaracteristica").ToEntero - Dim Logitud As Integer = e.Row.DataKey("Longitud").ToString.ToEntero - - Dim DdlCarcateristicaOpcion As DropDownList = e.Row.FCDropDownList("DdlCarcateristicaOpcion") - Dim TxtCuentaValor As TextBox = e.Row.FCTextBox("TxtCuentaValor") - Dim RdlCarcateristicaOpcion2 As RadioButtonList = e.Row.FCRadioButtonList("RdlCarcateristicaOpcion2") - Dim chkCaracteristicaValor2 As CheckBox = e.Row.FCCheckBox("chkCaracteristicaValor2") - - If objCaracteristicas.GetCaracteriscasOpciones(-1, UsuarioActual.Empresa.CveEmpresa) Then - dtTemp = objCaracteristicas.DtResultados - End If - - Dim Requerido As Integer - If e.Row.DataKey("Requerido").ToString.ToUpper = "TRUE" Then - Requerido = 1 - Else - Requerido = 0 - End If - - TxtCuentaValor.Visible = False - Dim RFVCuentaValor2 As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("RFVCuentaValor2") - RFVCuentaValor2.Enabled = False - - DdlCarcateristicaOpcion.Visible = False - Dim rfvDdlCarcateristicaOpcion2 As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("rfvDdlCarcateristicaOpcion2") - rfvDdlCarcateristicaOpcion2.Enabled = False - - RdlCarcateristicaOpcion2.Visible = False - Dim rfvRdlCarcateristicaOpcion = e.Row.FCRequiredFieldValidator("rfvRdlCarcateristicaOpcion2") - rfvRdlCarcateristicaOpcion.Enabled = False - - Dim cvFechaF As CompareValidator = e.Row.FCCompareValidator("cvFechaF2") - cvFechaF.Enabled = False - - Dim CalendarioCaractersiticas As AjaxControlToolkit.CalendarExtender = e.Row.FCCalendarExtender("CalendarioCaractersiticas1") - CalendarioCaractersiticas.Enabled = False - - chkCaracteristicaValor2.Visible = False - - Select Case CveCaracteristicaTipo - Case 0 - TxtCuentaValor.Visible = True - Exit Select - Case 1 - DdlCarcateristicaOpcion.Visible = True - dtTemp = dtTemp.FiltraParametros(" CveCaracteristica = " & CveCaracteristica) - DdlCarcateristicaOpcion.DataSource = dtTemp - DdlCarcateristicaOpcion.DataBind() - DdlCarcateristicaOpcion.Items.Insert(0, New ListItem("-", "-1")) - - If Requerido = 1 Then - rfvDdlCarcateristicaOpcion2.Enabled = True - End If - - Exit Select - Case 2 - 'radio - RdlCarcateristicaOpcion2.Visible = True - dtTemp = dtTemp.FiltraParametros(" CveCaracteristica = " & CveCaracteristica) - RdlCarcateristicaOpcion2.DataSource = dtTemp - RdlCarcateristicaOpcion2.DataBind() - - If Requerido = 1 Then - rfvRdlCarcateristicaOpcion.Enabled = True - End If - Exit Select - Case 3 - 'Fecha txt Fecha - TxtCuentaValor.Visible = True - TxtCuentaValor.Width = 120 - cvFechaF.Enabled = True - CalendarioCaractersiticas.Enabled = True - RegistraScript(" $('#" & TxtCuentaValor.ClientID & "').mask('00/00/0000'); ") - - If Requerido = 1 Then - RFVCuentaValor2.Enabled = True - End If - Exit Select - Case 4 - 'Multiline - TxtCuentaValor.Visible = True - TxtCuentaValor.MaxLength = Logitud - - If Requerido = 1 Then - RFVCuentaValor2.Enabled = True - End If - Exit Select - Case 5 - 'CheckBox - chkCaracteristicaValor2.Visible = True - Exit Select - Case 6 - TxtCuentaValor.Visible = True - TxtCuentaValor.TextMode = TextBoxMode.Number - - If Requerido = 1 Then - RFVCuentaValor2.Enabled = True - End If - Exit Select - End Select - objCaracteristicas.Dispose() - End If - End Sub - Private Function GuardaCaracteristicas(Modalidad As String, CveCuentaEquipo As Integer, ByRef ObjCarac As ClsGenerales) As Boolean - Dim Retorno = False - - If Modalidad.ToString = "I" Then - For Each gvr As GridViewRow In GvAddCuentaCaracteristica.Rows - Dim CveCaracteristica As Integer = gvr.DataKey("CveCaracteristica").ToEntero - Dim CveCaracteristicaTipo As Integer = gvr.DataKey("CveCaracteristicaTipo").ToEntero - - Dim _DdlCarcateristicaOpcion As DropDownList = gvr.FCDropDownList("DdlCarcateristicaOpcion") - Dim _TxtCaracteristicaOpcion As TextBox = gvr.FCTextBox("TxtCuentaValor") - Dim _RdlCarcateristicaOpcion As RadioButtonList = gvr.FCRadioButtonList("RdlCarcateristicaOpcion2") - Dim _chkCaracteristicaValor As CheckBox = gvr.FCCheckBox("chkCaracteristicaValor2") - - Dim CveCaracteristicaOpcion As Integer = -1 - Dim CaracteristicaValor As String = "" - Dim CaracteristicaValorDate As Date = Now - Dim CaracteristicaValorInt As Integer = -1 - - Dim AgregaCaracteristica As Boolean = False - - Select Case CveCaracteristicaTipo - Case 0 - 'txt - CaracteristicaValor = _TxtCaracteristicaOpcion.Text - - If CaracteristicaValor.Trim.Length > 0 Then - AgregaCaracteristica = True - Else - AgregaCaracteristica = False - End If - Exit Select - Case 1 - 'drop - CveCaracteristicaOpcion = _DdlCarcateristicaOpcion.SelectedValue.ToEntero - - If CveCaracteristicaOpcion > 0 Then - AgregaCaracteristica = True - Else - AgregaCaracteristica = False - End If - Exit Select - Case 2 - 'radio - CveCaracteristicaOpcion = _RdlCarcateristicaOpcion.SelectedValue.ToEntero - - If CveCaracteristicaOpcion > 0 Then - AgregaCaracteristica = True - Else - AgregaCaracteristica = False - End If - Exit Select - Case 3 - 'Fecha txt Fecha - If _TxtCaracteristicaOpcion.Text.Trim.Length > 0 Then - CaracteristicaValorDate = _TxtCaracteristicaOpcion.Text.Trim.ToDate - CaracteristicaValor = CaracteristicaValorDate.ToString("dd/MM/yyyy") - - If CaracteristicaValor.Trim.ToDate.ToString("dd/MM/yyyy").ToString.Length > 0 Then - AgregaCaracteristica = True - Else - AgregaCaracteristica = False - End If - Else - AgregaCaracteristica = False - End If - Case 4 - 'txt - CaracteristicaValor = _TxtCaracteristicaOpcion.Text - - If CaracteristicaValor.Trim.Length > 0 Then - AgregaCaracteristica = True - Else - AgregaCaracteristica = False - End If - Exit Select - Case 5 - 'CheckBox - If _chkCaracteristicaValor.Checked Then - CaracteristicaValor = "1" - Else - CaracteristicaValor = "0" - End If - AgregaCaracteristica = True - Exit Select - Case 6 - 'txt numerico - 'txt - CaracteristicaValor = _TxtCaracteristicaOpcion.Text.ToEntero.ToString - - AgregaCaracteristica = True - Exit Select - End Select - - If AgregaCaracteristica Then - If ObjCarac.AddUpdateCaracteristicasValores(CveCaracteristica, CveCaracteristicaOpcion, CaracteristicaValor, UsuarioActual.CveUsuario, CveCuentaEquipo:=CveCuentaEquipo) Then - Retorno = True - Else - Exit For - End If - End If - Next - ElseIf Modalidad.ToString = "U" Then - For Each gvr As GridViewRow In GvCuentasCaracteristicas.Rows - Dim _CaracteristicaValor As Integer = gvr.DataKey("CaracteristicaValor").ToEntero - Dim _CveCaracteristica As Integer = gvr.DataKey("CveCaracteristica").ToEntero - Dim _CveCaracteristicaValor As Integer = gvr.DataKey("CveCaracteristicaValor").ToEntero - Dim _CveCaracteristicaTipo As Integer = gvr.DataKey("CveCaracteristicaTipo").ToEntero - - Dim _DdlCarcateristicaOpcion As DropDownList = gvr.FCDropDownList("DdlCarcateristicaOpcion") - Dim _TxtCaracteristicaOpcion As TextBox = gvr.FCTextBox("TxtCuentaValor") - Dim _RdlCarcateristicaOpcion As RadioButtonList = gvr.FCRadioButtonList("RdlCarcateristicaOpcion") - Dim _chkCaracteristicaValor As CheckBox = gvr.FCCheckBox("chkCaracteristicaValor") - - Dim CveCaracteristicaOpcion As Integer = -1 - Dim CaracteristicaValor As String = "" - Dim CaracteristicaValorDate As Date = Now - Dim CaracteristicaValorInt As Integer = -1 - - Select Case _CveCaracteristicaTipo - Case 0 - 'txt - CaracteristicaValor = _TxtCaracteristicaOpcion.Text - Exit Select - Case 1 - 'drop - CveCaracteristicaOpcion = _DdlCarcateristicaOpcion.SelectedValue.ToEntero - Exit Select - Case 2 - 'radio - CveCaracteristicaOpcion = _RdlCarcateristicaOpcion.SelectedValue.ToEntero - Exit Select - Case 3 - 'Fecha txt Fecha - If _TxtCaracteristicaOpcion.Text.Trim.Length > 0 Then - CaracteristicaValorDate = _TxtCaracteristicaOpcion.Text.Trim.ToDate - CaracteristicaValor = CaracteristicaValorDate.ToString("dd/MM/yyyy") - Exit Select - End If - Case 4 - 'txt - CaracteristicaValor = _TxtCaracteristicaOpcion.Text - Exit Select - Case 5 - 'CheckBox - If _chkCaracteristicaValor.Checked Then - CaracteristicaValor = "1" - Else - CaracteristicaValor = "0" - End If - Exit Select - Case 6 - 'txt numerico - 'txt - CaracteristicaValor = _TxtCaracteristicaOpcion.Text.ToEntero.ToString - Exit Select - End Select - - If ObjCarac.AddUpdateCaracteristicasValores(_CveCaracteristica, CveCaracteristicaOpcion, CaracteristicaValor, UsuarioActual.CveUsuario, CveCaracteristicaValor:=_CveCaracteristicaValor, CveCuentaEquipo:=CveCuentaEquipo) Then - Retorno = True - Else - Exit For - End If - Next - End If - - Return Retorno - End Function -#End Region - -#Region "GPS" - Protected Sub btnCargaArrayDisp_Click(sender As Object, e As EventArgs) Handles btnCargaArrayDisp.Click - If hdnArrayDispositivo.Value.Length > 0 Then - CargaDispositivos(DdlEstatusDispositivos.SelectedValue.ToEntero()) - End If - End Sub - Protected Sub DdlEstatusDispositivos_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaDispositivos(DdlEstatusDispositivos.SelectedValue.ToEntero()) - End Sub - Private Sub CargaDispositivos(Optional Estatus As Integer = 1) - Dim ObjGPS As New ClsGPS - If ObjGPS.DispositivosGet(-1, Estatus, CveCliente) Then - GvDatos.DataSource = ObjGPS.DtResultados - Else - GvDatos.DataSource = Nothing - End If - ObjGPS.Dispose() - GvDatos.DataBind() - UpDispositivos.Update() - End Sub - Private Sub CargaGlobalDispositos() - Dim ObjGPS As New ClsGPS - - If ObjGPS.DispositivosGet(-1, -1, -1, -1) Then - GlobalDTDispositivos(-1) = ObjGPS.DtResultados - End If - - If ObjGPS.DispositivosUsuariosGet(-1, -1, -1, -1, -1) Then - GlobalDTDispositivosUsuarios(-1, -1) = ObjGPS.DtResultados - End If - - ObjGPS.Dispose() - End Sub - Protected Sub GvDispositivos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.VerticalAlign = VerticalAlign.Middle - If e.Row.DBCampo("Estatus").ToString.ToEntero = 1 Then - e.Row.FCLabel("LblEstatus").Text = "Activo" - e.Row.FCLabel("LblEstatus").CssClass = "label label-success" - Else - e.Row.FCLabel("LblEstatus").Text = "Inactivo" - e.Row.FCLabel("LblEstatus").CssClass = "label label-danger" - End If - e.Row.FCLinkButton("imgE").Attributes.Add("onclick", $"javascript:AbrirVentana('/GPS/WizardDispositivos.aspx?CveDispositivo={e.Row.DBCampo("CveDispositivo").ToString}&CveCliente={CveCliente}&EsPopup=1', 801, 701);") - End If - End Sub - - Protected Sub GvDispositivos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting - Dim GPS As New ClsGPS - Dim CveDispositivo As Integer = GvDatos.Rows(e.RowIndex).DataKey("CveDispositivo").ToEntero - If GPS.DispositivosDelete(CveDispositivo) Then - Alert("El Dispositivo se eliminó correctamente", TipoMensaje.MsgInformacion) - End If - GPS.Dispose() - CargaDispositivos() - CargaGlobalDispositos() - UpDispositivos.Update() - End Sub - Private Sub CargaEmpresasUsuario(CveEmpresa As Integer) - Dim Dt As DataTable = GlobalDTUsuarios(UsuarioActual.CveUsuario) - - If Dt IsNot Nothing Then - If Dt.Rows.Count > 0 Then - DdlEmpresaDispositivo.DataSource = Dt.FiltraParametros("CvePlataforma = 1 OR (CvePlataforma = 3 AND CveCliente IS NULL)", "Empresa") - - If DdlEmpresaDispositivo.SelectedValue.ToEntero() <= 0 Then - DdlEmpresaDispositivo.SelectedValueExist(CveEmpresa) - End If - - DdlClienteDispositivo.DataSource = Dt.FiltraParametros($"CvePlataforma = 3 AND CveEmpresa = {CveEmpresa}", "Empresa") - - DdlEmpresaDispositivo.DataBind() - DdlClienteDispositivo.DataBind() - - DdlClienteDispositivo.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - End If - End Sub - Private Sub CargaClienteDispositivos(CveEmpresa As Integer) - Dim Dt As DataTable = GlobalDTUsuarios(UsuarioActual.CveUsuario) - +#End Region + +#Region "E N V I O C O R R E O" + Private Sub EnviaCorreo(Liga As String, LigaActivar As String) + + Try + Dim Para = TxtEmail.Text.Trim + Dim Asunto = "ACTIVACIÓN DEL PORTAL DE CLIENTE" + Dim Usuario = TxtEmail.Text.Trim + + Dim SBBody As New StringBuilder + 'Linia de estilos + SBBody.Append("") + 'incio Cuerpo del correo + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("ALTA DE CUENTA") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.AppendFormat(" Estimado {0}:
    ", TxtNombre.Text.ToUpper) + SBBody.AppendFormat("El presente correo es para informarle que se le han asignado los siguientes datos para el acceso al Portal del Cliente de: {0}

    ", UsuarioActual.Empresa.Empresa) + + SBBody.Append("
    ") + SBBody.Append("
    Datos de Usuario:
    ") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("
    Dirección de Acceso
    ") + SBBody.AppendFormat("", Liga) + SBBody.Append("
    ") + SBBody.Append("
    ") + + SBBody.Append("
    Usuario:
    ") + SBBody.AppendFormat("
    {0}
    ", Usuario) + SBBody.Append("
    ") + SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    Haga click para activar su cuenta
    ") + SBBody.AppendFormat("", LigaActivar) + SBBody.Append("
    ") + + + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("Para Activar su cuenta debera cambiar su contraseña.

    ") + SBBody.Append("
    ") + SBBody.Append("Nota Favor de NO responder este correo. ") + SBBody.Append("


    ") + SBBody.AppendFormat("", UrlSitio) + SBBody.Append("
    ") + SBBody.Append("") + 'Termino Cuerpo del correo + + Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Asunto, Para, SBBody.ToString)) + Hilo.Start() + Alert("El correo se ha enviado correctamente a: " + TxtEmail.Text + ".", TipoMensaje.MsgInformacion) + Catch ex As Exception + OnError("Ocurrió error al mandar MAIL", ex) + End Try + End Sub + + + Private Sub MandaCorreo(Asunto As String, Para As String, Body As String) + Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) + a.GuardaLog() + Dim Mail As New ClsSisMail() + Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body) + End Sub +#End Region + +#Region " COTIZACIONES " + + Protected Sub BtnVerMasCot_Click(sender As Object, e As EventArgs) + If BtnVerMasCot.Text = "Ver Más" Then + CargaCotizaciones(-1) + BtnVerMasCot.Text = "Ver Menos" + Else + CargaCotizaciones(21) + BtnVerMasCot.Text = "Ver Más" + End If + End Sub + Private Function CargaCotizaciones(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1) As Boolean + Dim Retorno As Boolean = False + Dim ObjClientes As New ClsClientes() + If ObjClientes.GetCotizaciones(CveCliente, SelectTop, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) Then + If ObjClientes.DtResultados.Rows.Count > 0 Then + 'Carga Generales + LtlCantidadCotizaciones.Text = ObjClientes.DtResultados.Rows(0)("CountTotal").ToString.FormatoNumero(2) + LtlFactorCotVentas.Text = If(LtlCantidad.Text.ToEntero > 0, (LtlCantidadCotizaciones.Text.ToEntero / LtlCantidad.Text.ToEntero).FormatoNumero, "0.00") + 'Carga Grid + GvCot.DataSource = ObjClientes.DtResultados + DtCotizaciones = ObjClientes.DtResultados + + If UsuarioActual.Empresa.UsaOS Then + GvCot.Columns(9).Visible = True + Else + GvCot.Columns(9).Visible = True + End If + + + Else + LtlCantidadCotizaciones.Text = "0" + LtlFactorCotVentas.Text = "0.00" + GvCot.DataSource = Nothing + DtCotizaciones = Nothing + End If + Else + GvCot.DataSource = Nothing + DtCotizaciones = Nothing + End If + ObjClientes.Dispose() + GvCot.DataBind() + Return Retorno + End Function + Protected Sub GVCotizaciones_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvCot.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + Dim HLFacturar As HtmlAnchor = DirectCast(e.Row.FindControl("HLFacturarCot"), HtmlAnchor) + + + 'CABECERA + If e.Row.RowIndex = 0 Then + e.Row.BackColor = Drawing.Color.LightGray + DirectCast(e.Row.FindControl("HLSendMail2"), HtmlAnchor).Visible = False + e.Row.FindControl("HlOS").Visible = False + HLFacturar.Visible = False + End If + + e.Row.FCLiteral("LtlCotizacion").Text = String.Format("{1}", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("SerieFolio")) + e.Row.FCLiteral("LtlFolioVenta").Text = String.Format("{1}", e.Row.DBCampo("CveVentaPadre"), e.Row.DBCampo("FolioVenta")) + DirectCast(e.Row.FindControl("HLSendMail2"), HtmlAnchor).HRef = String.Format("javascript:$get('HdnTipoDocto2').value='Cot';$get('HdnCveVenta2').value='{0}';$get('HdnFolioVenta2').value='{1}';$get('TxtParaMail2').value='{2}';$get('HdnSerieFolio2').value='{2}';$get('HdnSubProyecto2').value='{2}'; $('#ModalDivMail2').modal();", e.Row.DBCampo("CveVenta"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("Correo"), e.Row.DBCampo("SerieFolio"), e.Row.DBCampo("SubProyecto")) + + + + 'FACTURAR COTIZACION + If e.Row.DBCampo("FolioVenta") <> "" Then + HLFacturar.Visible = False + Else + HLFacturar.HRef = $"/Ventas/Ventas.aspx?CveCotizacion={e.Row.DBCampo("CveVenta")}" + End If + End If + End Sub +#End Region + +#Region "D I R E C C I O N E N V I O " + Public Sub Edit_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + CveDireccionEnvio = GvRow.DataKey("CveDireccionEnvio").ToEntero + TxtEnvioDireccion.Text = GvRow.DataKey("EnvioDireccion") + TxtEnvioNoExt.Text = GvRow.DataKey("EnvioNoExt") + TxtEnvioNoInt.Text = GvRow.DataKey("EnvioNoInt") + TxtEnvioColonia.Text = GvRow.DataKey("EnvioColonia") + TxtEnvioCiudad.Text = GvRow.DataKey("EnvioCiudad") + TxtEnvioEstado.Text = GvRow.DataKey("EnvioEstado") + TxtEnvioContacto.Text = GvRow.DataKey("EnvioContacto") + 'TxtDepartamento.Text = GvRow.DataKey("EnvioDepartamento") + TxtEnvioCP.Text = GvRow.DataKey("EnvioCP") + TxtEnvioTel.Text = GvRow.DataKey("EnvioTel") + ChkEstatus.Checked = If(GvRow.DataKey("Estatus").ToString = "True", True, False) + If GvRow.DataKey("CveClienteSucursal").ToEntero > 0 Then DdlClienteSucursalEnvio.SelectedValueExist(GvRow.DataKey("CveClienteSucursal")) Else DdlClienteSucursalEnvio.SelectedValueExist("-1") + UpAddDireccion.Update() + RegistraScript("$('#divAddDireccionEnvio').modal();") + End Sub + Private Sub BtnAgregarDireccion_Click(sender As Object, e As EventArgs) Handles BtnAgregarDireccion.Click + Dim ObjClientes As New ClsClientes + Dim TieneError = False + Dim Estatus = If(ChkEstatus.Checked, 1, 0) + + If CveDireccionEnvio < 0 Then + CveDireccionEnvio = ObjClientes.DireccionEnvioAdd(CveCliente, TxtEnvioDireccion.Text.Trim, TxtEnvioNoExt.Text.Trim, TxtEnvioNoInt.Text.Trim, TxtEnvioColonia.Text.Trim, TxtEnvioCiudad.Text.Trim, TxtEnvioEstado.Text.Trim, TxtEnvioCP.Text.ToEntero, TxtEnvioContacto.Text.Trim, UsuarioActual.CveUsuario, Estatus, CveClienteSucursal:=DdlClienteSucursalEnvio.SelectedValue.ToEntero, EnvioTel:=TxtEnvioTel.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "")) + + If CveDireccionEnvio < 0 Then + TieneError = True + End If + Else + + If Not ObjClientes.DireccionEnvioUpdate(CveCliente, TxtEnvioDireccion.Text.Trim, TxtEnvioNoExt.Text.Trim, TxtEnvioNoInt.Text.Trim, TxtEnvioColonia.Text.Trim, TxtEnvioCiudad.Text.Trim, TxtEnvioEstado.Text.Trim, TxtEnvioCP.Text.ToEntero, TxtEnvioContacto.Text.Trim, UsuarioActual.CveUsuario, Estatus, CveDireccionEnvio, CveClienteSucursal:=DdlClienteSucursalEnvio.SelectedValue.ToEntero, EnvioTel:=TxtEnvioTel.Text.Trim.Replace(" ", "").Replace("(", "").Replace(")", "").Replace("-", "").Replace("_", "")) Then + TieneError = True + End If + + End If + + If TieneError Then + Alert("Ocurrio un error al agregar/actualizar la dirección de envío", TipoMensaje.MsgError) + Else + RegistraScript("$('#divAddDireccionEnvio').modal('hide');") + CveDireccionEnvio = -1 + CargaDireccionesEnvio() + End If + End Sub + Private Sub BtnAgregarDireccionModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarDireccionModal.Click + TxtEnvioDireccion.Text = "" + TxtEnvioNoExt.Text = "" + TxtEnvioNoInt.Text = "" + TxtEnvioColonia.Text = "" + TxtEnvioCiudad.Text = "" + TxtEnvioEstado.Text = "" + TxtEnvioContacto.Text = "" + 'TxtDepartamento.Text = "" + TxtEnvioCP.Text = "" + TxtEnvioTel.Text = "" + DdlClienteSucursalEnvio.SelectedValue = "-1" + UpAddDireccion.Update() + RegistraScript("$('#divAddDireccionEnvio').modal();") + End Sub + Private Sub GvDireccionesEnvio_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvDireccionesEnvio.RowDeleting + Dim ObjClientes As New ClsClientes + Dim TieneError = False + + Dim CveDireccionEnvio As Integer = GvDireccionesEnvio.Rows(e.RowIndex).DataKey("CveDireccionEnvio").ToEntero + + If Not ObjClientes.DireccionEnvioRemove(CveDireccionEnvio) Then + TieneError = True + End If + + If Not TieneError Then + GvDireccionesEnvio.EditIndex = -1 + Alert("Se eliminó correctamente la dirección de envío.", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrió un error al eliminar la dirección de envío.", TipoMensaje.MsgAdvertencia) + End If + + CargaDireccionesEnvio() + End Sub + +#End Region + +#Region " IMPORTAR SALDOS " + + Private Sub HLImportarSaldos_Click(sender As Object, e As EventArgs) Handles HLImportarSaldos.Click + CargaClientesImportarSaldos() + RegistraScript(String.Format("$('#{0}').modal();", "DivImportarSaldos")) + End Sub + + Private Sub CargaClientesImportarSaldos() + DdlClienteImportarSaldos.setEsWebService(True) '(UsuarioActual.Empresa.Funcionalidad(105) = "1") + 'DdlClienteImportarSaldos.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa) + 'DdlClienteImportarSaldos.DataBind() + UpImportarSaldos.Update() + 'DdlClienteImportarSaldos.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + Protected Sub BtnConsultarSaldoCliente_Click(sender As Object, e As EventArgs) + ConsultarAnticiposSaldosClientes() + End Sub + Private Sub ConsultarAnticiposSaldosClientes() + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetAnticiposNCIxCCliente(DdlClienteImportarSaldos.SelectedValue.ToEntero) Then + GvImportarSaldos.DataSource = ObjMovtos.DtResultados.FiltraParametros("Saldo > 0 AND Saldo > 0 AND CveIE > 0") + Else + GvImportarSaldos.DataSource = Nothing + End If + ObjMovtos.Dispose() + + TxtSaldoImportar.Text = "" + + GvImportarSaldos.DataBind() + UpImportarSaldos.Update() + End Sub + Protected Sub BtnGuardarTransferencias_Click(sender As Object, e As EventArgs) + Dim EsValida = False + + For Each Gvr As GridViewRow In GvImportarSaldos.Rows + If Gvr.FCCheckBox("Chk").Checked AndAlso Gvr.FCTextBox("TxtImporte").Text.ToDouble > 0 Then + EsValida = True + End If + Next + + If Not EsValida Then + Alert("El importe a importar de saldos debe ser mayor a cero. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim ObjConta As New ClsContabilidad + ObjConta.IniciaTransacSQL() + Dim TieneError = False + + + Dim CvePrePoliza As Integer = ObjConta.AddPrePolizas("Clientes/ImportarSaldos", 53, TxtCantidad.Text.Trim.ToDouble, TxtCantidad.Text.Trim.ToDouble, 1, TxtFechaImportarSaldos.Text.ToDate, "Traspaso de saldos de anticipos", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + Dim IVA As Decimal = 0 + Dim Importe As Decimal = 0 + Dim ImporteAplicar As Decimal = 0 + If CvePrePoliza > 0 Then + For Each Gvr As GridViewRow In GvImportarSaldos.Rows + If Gvr.FCCheckBox("Chk").Checked AndAlso Gvr.FCTextBox("TxtImporte").Text.ToDouble > 0 Then + + Importe = Gvr.FCTextBox("TxtImporte").Text.ToDecimal + IVA = Importe / Gvr.DataKey("Original").ToString.ToDecimal * Gvr.DataKey("IVA").ToString.ToDecimal 'TOMA EN CUENTA EL IVA - CONCEPTO DIFERENTE + ImporteAplicar = -(Importe - IVA) + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, False, ImporteAplicar, "Traspaso de saldos de anticipos", 92, "Traspaso de saldos de anticipos.IVA", Now, 0, -1, CveCliente:=Gvr.DataKey("CveCliente").ToString.ToEntero, CveIE:=Gvr.DataKey("CveIE").ToString.ToEntero, ImporteMX:=ImporteAplicar) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, ImporteAplicar, "Traspaso de saldos de anticipos", 66, "Traspaso de saldos de anticipos.IVA", Now, 0, -1, CveCliente:=CveCliente, CveIE:=Gvr.DataKey("CveIE").ToString.ToEntero, ImporteMX:=ImporteAplicar) Then + TieneError = True + End If + Else + TieneError = True + End If + + If Not TieneError Then + If IVA > 0 Then + If ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, -IVA, "Traspaso de saldos de anticipos.IVA", 61, "Traspaso de saldos de anticipos.IVA", Now, 0, -1, CveCliente:=Gvr.DataKey("CveCliente").ToString.ToEntero, CveIE:=Gvr.DataKey("CveIE").ToString.ToEntero, ImporteMX:=-IVA) Then + If Not ObjConta.AddPrePolizasDetalle(CvePrePoliza, True, IVA, "Traspaso de saldos de anticipos. IVA", 61, "Traspaso de saldos de anticipos.IVA", Now, 0, -1, CveCliente:=CveCliente, CveIE:=Gvr.DataKey("CveIE").ToString.ToEntero, ImporteMX:=IVA) Then + TieneError = True + End If + Else + TieneError = True + End If + End If + End If + + + End If + Next + Else + TieneError = True + End If + + + If Not TieneError Then + ObjConta.Commit() + Alert($"La importación de saldos se hizo correctamente.", TipoMensaje.MsgInformacion) + TxtSaldoImportar.Text = "" + ConsultarAnticiposSaldosClientes() + Else + ObjConta.RollBack() + Alert("Ocurrió un error al importar los saldos. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + + ObjConta.Dispose() + End Sub + + Protected Sub GvImportarSaldos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvImportarSaldos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ChkSaldo(this,{0},{1});", e.Row.FCTextBox("TxtImporte").ClientID, e.Row.DBCampo("Saldo"))) + e.Row.FCTextBox("TxtImporte").Attributes.Add("onKeyUp", String.Format("CambiaSaldo({0},this,{1});", e.Row.FCCheckBox("Chk").ClientID, e.Row.DBCampo("Saldo"))) + End If + End Sub +#End Region + +#Region "Cuentas/Equipos" + Public Sub BtnAgregarCtaEquipo_Click(sender As Object, e As EventArgs) + HdnModalidad.Value = "I" + DivCicloComercial.Visible = False + TxtIdentificador.Text = "" + TxtNoSerie.Text = "" + DdlTipoCuentaDetalle.SelectedIndex = 0 + ChkAnticipo.Checked = False + PnlCicloComercial.Visible = False + CargaCuentasCaracteristicas() + UpBodyAgregarCuenta.Update() + UpDatos.Update() + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarCuenta")) + End Sub + Private Sub BtnGuardarCuenta_Click(sender As Object, e As EventArgs) Handles BtnGuardarCuenta.Click + Dim objCuentasEquipos As New ClsGenerales() + Dim TieneError = False + objCuentasEquipos.IniciaTransacSQL() + + If HdnModalidad.Value = "I" Then + If Not objCuentasEquipos.AddCuentaEquipo(CveCliente, DdlTipoCuentaDetalle.SelectedValue.ToEntero, TxtIdentificador.Text.Trim, TxtNoSerie.Text.Trim, DdlClienteSucursal.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + TieneError = True + End If + + If Not GuardaCaracteristicas(HdnModalidad.Value.ToString, objCuentasEquipos.CveCuentaEquipo, objCuentasEquipos) Then + TieneError = True + End If + + ElseIf HdnModalidad.Value = "U" Then + + If Not objCuentasEquipos.UpdateCuentaEquipo(TxtIdentificador.Text, TxtNoSerie.Text, True, DdlClienteSucursal.SelectedValue.ToEntero, CveCuentaEquipo) Then + TieneError = True + End If + + If Not GuardaCaracteristicas(HdnModalidad.Value.ToString, CveCuentaEquipo, objCuentasEquipos) Then + TieneError = True + End If + + End If + + If Not TieneError Then + objCuentasEquipos.Commit() + CargaCuentasEquipos() + TxtIdentificador.Text = "" + TxtNoSerie.Text = "" + DdlTipoCuentaDetalle.SelectedIndex = 0 + ChkAnticipo.Checked = False + Alert("Se agregó/Actualizó correctamente la Cuenta/Equipo.", TipoMensaje.MsgInformacion) + UpBodyAgregarCuenta.Update() + Else + Alert("Ocurrió un erro al Agregar/Actualizar la Cuenta/Equipo.", TipoMensaje.MsgInformacion) + objCuentasEquipos.RollBack() + End If + + objCuentasEquipos.Dispose() + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarCuenta")) + UpDatos.Update() + End Sub + Private Sub ChkCicloComercial_CheckedChanged(sender As Object, e As EventArgs) Handles ChkCicloComercial.CheckedChanged + If ChkCicloComercial.Checked = True Then + PnlCicloComercial.Visible = True + + DdlPS.Items.Clear() + DdlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlPS.DataBind() + DdlPS.Items.Insert(0, New ListItem("Seleccione", "-1")) + + Else + PnlCicloComercial.Visible = False + End If + End Sub + Private Sub BtnAgregarPS_Click(sender As Object, e As EventArgs) Handles BtnAgregarPS.Click + Dim Objeto As New ClsGenerales + If Objeto.AddCuentaEquipoPS(DdlPS.SelectedValue.ToEntero, CveCuentaEquipo) Then + Alert("Se ha agregado correctamente.", TipoMensaje.MsgInformacion) + CargaGridPS() + End If + Objeto.Dispose() + End Sub + Private Sub CargaGridPS() + Dim Objeto As New ClsGenerales() + If Objeto.GetCuentaEquipoPS(CveCuentaEquipo) Then + GvPS.DataSource = Objeto.DtResultados + GvPS.DataBind() + Objeto.Dispose() + End If + UpDatos.Update() + + End Sub + Public Sub imgE_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim Objeto As New ClsGenerales() + + HdnModalidad.Value = "U" + CveCuentaEquipo = GvRow.DataKey("CveCuentaEquipo").ToString.ToEntero + TxtIdentificador.Text = GvRow.DataKey("CuentaEquipo") + TxtNoSerie.Text = GvRow.DataKey("NoSerie") + DdlTipoCuentaDetalle.SelectedValueExist(GvRow.DataKey("CveTipoCuentaEquipo")) + BtnGuardarCuenta.Text = "Guardar" + DivCicloComercial.Visible = True + + If Objeto.GetCuentaEquipoPS(CveCuentaEquipo) Then + If Objeto.DtResultados.Rows.Count > 0 Then + GvPS.DataSource = Objeto.DtResultados + GvPS.DataBind() + ChkCicloComercial.Checked = True + PnlCicloComercial.Visible = True + DdlPS.Items.Clear() + DdlPS.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlPS.DataBind() + DdlPS.Items.Insert(0, New ListItem("Seleccione", "-1")) + Else + ChkCicloComercial.Checked = False + PnlCicloComercial.Visible = False + End If + End If + + If Objeto.GetCaracteristicasValores(-1, -1, -1, -1, CveCuentaEquipo, -1, 6, UsuarioActual.CveEmpresa) Then + GvCuentasCaracteristicas.DataSource = Objeto.DtResultados + Else + GvCuentasCaracteristicas.DataSource = Nothing + End If + GvCuentasCaracteristicas.DataBind() + GvCuentasCaracteristicas.Visible = True + GvAddCuentaCaracteristica.Visible = False + + UpDatos.Update() + UpBodyAgregarCuenta.Update() + UpAgregarCuenta.Update() + Objeto.Dispose() + RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarCuenta")) + End Sub + Protected Sub GvCuentasEquipos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvCuentasEquipos.RowDeleting + Dim Objeto As New ClsGenerales + Dim TieneError = False + If Objeto.RemoveCuentaEquipo(GvCuentasEquipos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then + Alert("La cuenta Equipo se eliminó correctamente.", TipoMensaje.MsgInformacion) + Else + TieneError = True + Alert("Error al eliminar la cuenta/equipo.", TipoMensaje.MsgError) + End If + Objeto.Dispose() + UpDatos.Update() + CargaCuentasEquipos() + + + End Sub + Public Sub GvPS_Delete(sender As Object, e As EventArgs) + Dim Objeto As New ClsGenerales + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + Dim CveCtaEq As Integer = GvRow.DataKey("CveCuentaEquipo").ToString.ToEntero + Dim CvePS As Integer = GvRow.DataKey("CvePS").ToString.ToEntero + + If Objeto.RemoveCuentaEquipoPS(CvePS, CveCtaEq) Then + Alert("El PS se eliminó correctamente.", TipoMensaje.MsgInformacion) + Else + Alert("Error al eliminar el PS", TipoMensaje.MsgError) + End If + + CargaGridPS() + UpDatos.Update() + Objeto.Dispose() + End Sub + Private Sub CargaCuentasCaracteristicas() + Dim ObjCaracteristicas As New ClsGenerales + + + If ObjCaracteristicas.GetCaracteristicas(-1, 6, UsuarioActual.CveEmpresa) Then + GvAddCuentaCaracteristica.DataSource = ObjCaracteristicas.DtResultados + Else + GvAddCuentaCaracteristica.DataSource = Nothing + End If + GvAddCuentaCaracteristica.DataBind() + GvAddCuentaCaracteristica.Visible = True + GvCuentasCaracteristicas.Visible = False + + ObjCaracteristicas.Dispose() + End Sub + Private Sub GvCuentasCaracteristicas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvCuentasCaracteristicas.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim CveCaracteristicaTipo As Integer = e.Row.DataKey("CveCaracteristicaTipo").ToEntero + Dim dtTemp As New DataTable + Dim objCaracteristicas As New ClsGenerales + + Dim CveCaracteristica As Integer = e.Row.DataKey("CveCaracteristica").ToEntero + Dim CveCaracteristicaValor As Integer = e.Row.DataKey("CveCaracteristicaValor").ToEntero + Dim CveCaracteristicaOpcion As Integer = e.Row.DataKey("CveCaracteristicaOpcion").ToEntero + Dim CaracteristicaValor As String = e.Row.DataKey("CaracteristicaValor") + Dim Logitud As Integer = e.Row.DataKey("Longitud").ToString.ToEntero + + Dim DdlCarcateristicaOpcion As DropDownList = e.Row.FCDropDownList("DdlCarcateristicaOpcion") + Dim TxtCuentaValor As TextBox = e.Row.FCTextBox("TxtCuentaValor") + Dim RdlCarcateristicaOpcion As RadioButtonList = e.Row.FCRadioButtonList("RdlCarcateristicaOpcion") + Dim chkCaracteristicaValor As CheckBox = e.Row.FCCheckBox("chkCaracteristicaValor") + + Dim Requerido As Integer + If e.Row.DataKey("Requerido").ToString.ToUpper = "TRUE" Then + Requerido = 1 + Else + Requerido = 0 + End If + + TxtCuentaValor.Visible = False + Dim RFVCuentaValor1 As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("RFVCuentaValor1") + RFVCuentaValor1.Enabled = False + + DdlCarcateristicaOpcion.Visible = False + Dim rfvDdlCarcateristicaOpcion1 As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("rfvDdlCarcateristicaOpcion1") + rfvDdlCarcateristicaOpcion1.Enabled = False + + RdlCarcateristicaOpcion.Visible = False + Dim rfvRdlCarcateristicaOpcion = e.Row.FCRequiredFieldValidator("rfvRdlCarcateristicaOpcion") + rfvRdlCarcateristicaOpcion.Enabled = False + + Dim CalendarioCaractersiticas As AjaxControlToolkit.CalendarExtender = e.Row.FCCalendarExtender("CalendarioCaractersiticas") + CalendarioCaractersiticas.Enabled = False + + Dim _cvFechaF As CompareValidator = e.Row.FCCompareValidator("cvFechaF") + _cvFechaF.Enabled = False + + chkCaracteristicaValor.Visible = False + + If objCaracteristicas.GetCaracteriscasOpciones(-1, UsuarioActual.Empresa.CveEmpresa) Then + dtTemp = objCaracteristicas.DtResultados + End If + + If CaracteristicaValor.Length > 0 Then + TxtCuentaValor.Text = CaracteristicaValor + End If + + Select Case CveCaracteristicaTipo + Case 0 + 'txt + TxtCuentaValor.Visible = True + TxtCuentaValor.MaxLength = Logitud + If Requerido = 1 Then + RFVCuentaValor1.Enabled = True + End If + Exit Select + Case 1 + DdlCarcateristicaOpcion.Visible = True + dtTemp = dtTemp.FiltraParametros(" CveCaracteristica = " & CveCaracteristica) + DdlCarcateristicaOpcion.DataSource = dtTemp + DdlCarcateristicaOpcion.DataBind() + DdlCarcateristicaOpcion.Items.Insert(0, New ListItem("-", "-1")) + + If CveCaracteristicaValor <> -1 Then + DdlCarcateristicaOpcion.SelectedValueExist(CveCaracteristicaOpcion) + End If + + If Requerido = 1 Then + rfvDdlCarcateristicaOpcion1.Enabled = True + End If + Exit Select + Case 2 + 'radio + RdlCarcateristicaOpcion.Visible = True + dtTemp = dtTemp.FiltraParametros(" CveCaracteristica = " & CveCaracteristica) + RdlCarcateristicaOpcion.DataSource = dtTemp + RdlCarcateristicaOpcion.DataBind() + + If CveCaracteristicaValor <> -1 Then + RdlCarcateristicaOpcion.SelectedValuesIfExist(CveCaracteristicaOpcion.ToString) + End If + + If Requerido = 1 Then + rfvRdlCarcateristicaOpcion.Enabled = True + End If + Exit Select + Case 3 + 'Fecha txt Fecha + TxtCuentaValor.Visible = True + TxtCuentaValor.Width = 120 + cvFechaF.Enabled = True + CalendarioCaractersiticas.Enabled = True + RegistraScript(" $('#" & TxtCuentaValor.ClientID & "').mask('00/00/0000'); ") + If Requerido = 1 Then + RFVCuentaValor1.Enabled = True + End If + Exit Select + Case 4 + 'Multiline + TxtCuentaValor.Visible = True + TxtCuentaValor.MaxLength = Logitud + If Requerido = 1 Then + RFVCuentaValor1.Enabled = True + End If + Exit Select + Case 5 + 'CheckBox + chkCaracteristicaValor.Visible = True + If CaracteristicaValor = "1" Then + chkCaracteristicaValor.Checked = True + Else + chkCaracteristicaValor.Checked = False + End If + + Exit Select + Case 6 + TxtCuentaValor.Visible = True + TxtCuentaValor.TextMode = TextBoxMode.Number + + If Requerido = 1 Then + RFVCuentaValor1.Enabled = True + End If + Exit Select + End Select + + objCaracteristicas.Dispose() + End If + End Sub + Private Sub GvAddCuentaCaracteristica_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAddCuentaCaracteristica.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + Dim CveCaracteristicaTipo As Integer = e.Row.DataKey("CveCaracteristicaTipo").ToEntero + Dim dtTemp As New DataTable + Dim objCaracteristicas As New ClsGenerales + + Dim CveCaracteristica As Integer = e.Row.DataKey("CveCaracteristica").ToEntero + Dim Logitud As Integer = e.Row.DataKey("Longitud").ToString.ToEntero + + Dim DdlCarcateristicaOpcion As DropDownList = e.Row.FCDropDownList("DdlCarcateristicaOpcion") + Dim TxtCuentaValor As TextBox = e.Row.FCTextBox("TxtCuentaValor") + Dim RdlCarcateristicaOpcion2 As RadioButtonList = e.Row.FCRadioButtonList("RdlCarcateristicaOpcion2") + Dim chkCaracteristicaValor2 As CheckBox = e.Row.FCCheckBox("chkCaracteristicaValor2") + + If objCaracteristicas.GetCaracteriscasOpciones(-1, UsuarioActual.Empresa.CveEmpresa) Then + dtTemp = objCaracteristicas.DtResultados + End If + + Dim Requerido As Integer + If e.Row.DataKey("Requerido").ToString.ToUpper = "TRUE" Then + Requerido = 1 + Else + Requerido = 0 + End If + + TxtCuentaValor.Visible = False + Dim RFVCuentaValor2 As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("RFVCuentaValor2") + RFVCuentaValor2.Enabled = False + + DdlCarcateristicaOpcion.Visible = False + Dim rfvDdlCarcateristicaOpcion2 As RequiredFieldValidator = e.Row.FCRequiredFieldValidator("rfvDdlCarcateristicaOpcion2") + rfvDdlCarcateristicaOpcion2.Enabled = False + + RdlCarcateristicaOpcion2.Visible = False + Dim rfvRdlCarcateristicaOpcion = e.Row.FCRequiredFieldValidator("rfvRdlCarcateristicaOpcion2") + rfvRdlCarcateristicaOpcion.Enabled = False + + Dim cvFechaF As CompareValidator = e.Row.FCCompareValidator("cvFechaF2") + cvFechaF.Enabled = False + + Dim CalendarioCaractersiticas As AjaxControlToolkit.CalendarExtender = e.Row.FCCalendarExtender("CalendarioCaractersiticas1") + CalendarioCaractersiticas.Enabled = False + + chkCaracteristicaValor2.Visible = False + + Select Case CveCaracteristicaTipo + Case 0 + TxtCuentaValor.Visible = True + Exit Select + Case 1 + DdlCarcateristicaOpcion.Visible = True + dtTemp = dtTemp.FiltraParametros(" CveCaracteristica = " & CveCaracteristica) + DdlCarcateristicaOpcion.DataSource = dtTemp + DdlCarcateristicaOpcion.DataBind() + DdlCarcateristicaOpcion.Items.Insert(0, New ListItem("-", "-1")) + + If Requerido = 1 Then + rfvDdlCarcateristicaOpcion2.Enabled = True + End If + + Exit Select + Case 2 + 'radio + RdlCarcateristicaOpcion2.Visible = True + dtTemp = dtTemp.FiltraParametros(" CveCaracteristica = " & CveCaracteristica) + RdlCarcateristicaOpcion2.DataSource = dtTemp + RdlCarcateristicaOpcion2.DataBind() + + If Requerido = 1 Then + rfvRdlCarcateristicaOpcion.Enabled = True + End If + Exit Select + Case 3 + 'Fecha txt Fecha + TxtCuentaValor.Visible = True + TxtCuentaValor.Width = 120 + cvFechaF.Enabled = True + CalendarioCaractersiticas.Enabled = True + RegistraScript(" $('#" & TxtCuentaValor.ClientID & "').mask('00/00/0000'); ") + + If Requerido = 1 Then + RFVCuentaValor2.Enabled = True + End If + Exit Select + Case 4 + 'Multiline + TxtCuentaValor.Visible = True + TxtCuentaValor.MaxLength = Logitud + + If Requerido = 1 Then + RFVCuentaValor2.Enabled = True + End If + Exit Select + Case 5 + 'CheckBox + chkCaracteristicaValor2.Visible = True + Exit Select + Case 6 + TxtCuentaValor.Visible = True + TxtCuentaValor.TextMode = TextBoxMode.Number + + If Requerido = 1 Then + RFVCuentaValor2.Enabled = True + End If + Exit Select + End Select + objCaracteristicas.Dispose() + End If + End Sub + Private Function GuardaCaracteristicas(Modalidad As String, CveCuentaEquipo As Integer, ByRef ObjCarac As ClsGenerales) As Boolean + Dim Retorno = False + + If Modalidad.ToString = "I" Then + For Each gvr As GridViewRow In GvAddCuentaCaracteristica.Rows + Dim CveCaracteristica As Integer = gvr.DataKey("CveCaracteristica").ToEntero + Dim CveCaracteristicaTipo As Integer = gvr.DataKey("CveCaracteristicaTipo").ToEntero + + Dim _DdlCarcateristicaOpcion As DropDownList = gvr.FCDropDownList("DdlCarcateristicaOpcion") + Dim _TxtCaracteristicaOpcion As TextBox = gvr.FCTextBox("TxtCuentaValor") + Dim _RdlCarcateristicaOpcion As RadioButtonList = gvr.FCRadioButtonList("RdlCarcateristicaOpcion2") + Dim _chkCaracteristicaValor As CheckBox = gvr.FCCheckBox("chkCaracteristicaValor2") + + Dim CveCaracteristicaOpcion As Integer = -1 + Dim CaracteristicaValor As String = "" + Dim CaracteristicaValorDate As Date = Now + Dim CaracteristicaValorInt As Integer = -1 + + Dim AgregaCaracteristica As Boolean = False + + Select Case CveCaracteristicaTipo + Case 0 + 'txt + CaracteristicaValor = _TxtCaracteristicaOpcion.Text + + If CaracteristicaValor.Trim.Length > 0 Then + AgregaCaracteristica = True + Else + AgregaCaracteristica = False + End If + Exit Select + Case 1 + 'drop + CveCaracteristicaOpcion = _DdlCarcateristicaOpcion.SelectedValue.ToEntero + + If CveCaracteristicaOpcion > 0 Then + AgregaCaracteristica = True + Else + AgregaCaracteristica = False + End If + Exit Select + Case 2 + 'radio + CveCaracteristicaOpcion = _RdlCarcateristicaOpcion.SelectedValue.ToEntero + + If CveCaracteristicaOpcion > 0 Then + AgregaCaracteristica = True + Else + AgregaCaracteristica = False + End If + Exit Select + Case 3 + 'Fecha txt Fecha + If _TxtCaracteristicaOpcion.Text.Trim.Length > 0 Then + CaracteristicaValorDate = _TxtCaracteristicaOpcion.Text.Trim.ToDate + CaracteristicaValor = CaracteristicaValorDate.ToString("dd/MM/yyyy") + + If CaracteristicaValor.Trim.ToDate.ToString("dd/MM/yyyy").ToString.Length > 0 Then + AgregaCaracteristica = True + Else + AgregaCaracteristica = False + End If + Else + AgregaCaracteristica = False + End If + Case 4 + 'txt + CaracteristicaValor = _TxtCaracteristicaOpcion.Text + + If CaracteristicaValor.Trim.Length > 0 Then + AgregaCaracteristica = True + Else + AgregaCaracteristica = False + End If + Exit Select + Case 5 + 'CheckBox + If _chkCaracteristicaValor.Checked Then + CaracteristicaValor = "1" + Else + CaracteristicaValor = "0" + End If + AgregaCaracteristica = True + Exit Select + Case 6 + 'txt numerico + 'txt + CaracteristicaValor = _TxtCaracteristicaOpcion.Text.ToEntero.ToString + + AgregaCaracteristica = True + Exit Select + End Select + + If AgregaCaracteristica Then + If ObjCarac.AddUpdateCaracteristicasValores(CveCaracteristica, CveCaracteristicaOpcion, CaracteristicaValor, UsuarioActual.CveUsuario, CveCuentaEquipo:=CveCuentaEquipo) Then + Retorno = True + Else + Exit For + End If + End If + Next + ElseIf Modalidad.ToString = "U" Then + For Each gvr As GridViewRow In GvCuentasCaracteristicas.Rows + Dim _CaracteristicaValor As Integer = gvr.DataKey("CaracteristicaValor").ToEntero + Dim _CveCaracteristica As Integer = gvr.DataKey("CveCaracteristica").ToEntero + Dim _CveCaracteristicaValor As Integer = gvr.DataKey("CveCaracteristicaValor").ToEntero + Dim _CveCaracteristicaTipo As Integer = gvr.DataKey("CveCaracteristicaTipo").ToEntero + + Dim _DdlCarcateristicaOpcion As DropDownList = gvr.FCDropDownList("DdlCarcateristicaOpcion") + Dim _TxtCaracteristicaOpcion As TextBox = gvr.FCTextBox("TxtCuentaValor") + Dim _RdlCarcateristicaOpcion As RadioButtonList = gvr.FCRadioButtonList("RdlCarcateristicaOpcion") + Dim _chkCaracteristicaValor As CheckBox = gvr.FCCheckBox("chkCaracteristicaValor") + + Dim CveCaracteristicaOpcion As Integer = -1 + Dim CaracteristicaValor As String = "" + Dim CaracteristicaValorDate As Date = Now + Dim CaracteristicaValorInt As Integer = -1 + + Select Case _CveCaracteristicaTipo + Case 0 + 'txt + CaracteristicaValor = _TxtCaracteristicaOpcion.Text + Exit Select + Case 1 + 'drop + CveCaracteristicaOpcion = _DdlCarcateristicaOpcion.SelectedValue.ToEntero + Exit Select + Case 2 + 'radio + CveCaracteristicaOpcion = _RdlCarcateristicaOpcion.SelectedValue.ToEntero + Exit Select + Case 3 + 'Fecha txt Fecha + If _TxtCaracteristicaOpcion.Text.Trim.Length > 0 Then + CaracteristicaValorDate = _TxtCaracteristicaOpcion.Text.Trim.ToDate + CaracteristicaValor = CaracteristicaValorDate.ToString("dd/MM/yyyy") + Exit Select + End If + Case 4 + 'txt + CaracteristicaValor = _TxtCaracteristicaOpcion.Text + Exit Select + Case 5 + 'CheckBox + If _chkCaracteristicaValor.Checked Then + CaracteristicaValor = "1" + Else + CaracteristicaValor = "0" + End If + Exit Select + Case 6 + 'txt numerico + 'txt + CaracteristicaValor = _TxtCaracteristicaOpcion.Text.ToEntero.ToString + Exit Select + End Select + + If ObjCarac.AddUpdateCaracteristicasValores(_CveCaracteristica, CveCaracteristicaOpcion, CaracteristicaValor, UsuarioActual.CveUsuario, CveCaracteristicaValor:=_CveCaracteristicaValor, CveCuentaEquipo:=CveCuentaEquipo) Then + Retorno = True + Else + Exit For + End If + Next + End If + + Return Retorno + End Function +#End Region + +#Region "GPS" + Protected Sub btnCargaArrayDisp_Click(sender As Object, e As EventArgs) Handles btnCargaArrayDisp.Click + If hdnArrayDispositivo.Value.Length > 0 Then + CargaDispositivos(DdlEstatusDispositivos.SelectedValue.ToEntero()) + End If + End Sub + Protected Sub DdlEstatusDispositivos_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaDispositivos(DdlEstatusDispositivos.SelectedValue.ToEntero()) + End Sub + Private Sub CargaDispositivos(Optional Estatus As Integer = 1) + Dim ObjGPS As New ClsGPS + If ObjGPS.DispositivosGet(-1, Estatus, CveCliente) Then + GvDatos.DataSource = ObjGPS.DtResultados + Else + GvDatos.DataSource = Nothing + End If + ObjGPS.Dispose() + GvDatos.DataBind() + UpDispositivos.Update() + End Sub + Private Sub CargaGlobalDispositos() + Dim ObjGPS As New ClsGPS + + If ObjGPS.DispositivosGet(-1, -1, -1, -1) Then + GlobalDTDispositivos(-1) = ObjGPS.DtResultados + End If + + If ObjGPS.DispositivosUsuariosGet(-1, -1, -1, -1, -1) Then + GlobalDTDispositivosUsuarios(-1, -1) = ObjGPS.DtResultados + End If + + ObjGPS.Dispose() + End Sub + Protected Sub GvDispositivos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.VerticalAlign = VerticalAlign.Middle + If e.Row.DBCampo("Estatus").ToString.ToEntero = 1 Then + e.Row.FCLabel("LblEstatus").Text = "Activo" + e.Row.FCLabel("LblEstatus").CssClass = "label label-success" + Else + e.Row.FCLabel("LblEstatus").Text = "Inactivo" + e.Row.FCLabel("LblEstatus").CssClass = "label label-danger" + End If + e.Row.FCLinkButton("imgE").Attributes.Add("onclick", $"javascript:AbrirVentana('/GPS/WizardDispositivos.aspx?CveDispositivo={e.Row.DBCampo("CveDispositivo").ToString}&CveCliente={CveCliente}&EsPopup=1', 801, 701);") + End If + End Sub + + Protected Sub GvDispositivos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting + Dim GPS As New ClsGPS + Dim CveDispositivo As Integer = GvDatos.Rows(e.RowIndex).DataKey("CveDispositivo").ToEntero + If GPS.DispositivosDelete(CveDispositivo) Then + Alert("El Dispositivo se eliminó correctamente", TipoMensaje.MsgInformacion) + End If + GPS.Dispose() + CargaDispositivos() + CargaGlobalDispositos() + UpDispositivos.Update() + End Sub + Private Sub CargaEmpresasUsuario(CveEmpresa As Integer) + Dim Dt As DataTable = GlobalDTUsuarios(UsuarioActual.CveUsuario) + + If Dt IsNot Nothing Then + If Dt.Rows.Count > 0 Then + DdlEmpresaDispositivo.DataSource = Dt.FiltraParametros("CvePlataforma = 1 OR (CvePlataforma = 3 AND CveCliente IS NULL)", "Empresa") + + If DdlEmpresaDispositivo.SelectedValue.ToEntero() <= 0 Then + DdlEmpresaDispositivo.SelectedValueExist(CveEmpresa) + End If + + DdlClienteDispositivo.DataSource = Dt.FiltraParametros($"CvePlataforma = 3 AND CveEmpresa = {CveEmpresa}", "Empresa") + + DdlEmpresaDispositivo.DataBind() + DdlClienteDispositivo.DataBind() + + DdlClienteDispositivo.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + End If + + End Sub + Private Sub CargaClienteDispositivos(CveEmpresa As Integer) + Dim Dt As DataTable = GlobalDTUsuarios(UsuarioActual.CveUsuario) + If Dt IsNot Nothing AndAlso Dt.Rows.Count > 0 Then DdlClienteDispositivo.DataSource = Dt.FiltraParametros($"CvePlataforma = 3 AND CveEmpresa = {CveEmpresa}", "Empresa") DdlClienteDispositivo.DataBind() - DdlClienteDispositivo.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - End Sub - Protected Sub DdlEmpresaDispositivo_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaClienteDispositivos(DdlEmpresaDispositivo.SelectedValue.ToEntero()) + DdlClienteDispositivo.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If End Sub - - - Protected Sub ImgMoverDispositivo_Click(sender As Object, e As EventArgs) - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Me.NombreDispositivo = GvRow.DataKey("Display") - HTituloDispostivo.InnerText = $"Mover Dispositivo: {NombreDispositivo}" - - UpMoverDispositivo.Update() - RegistraScript($"CargaModalMoverDispositivo({GvRow.DataKey("CveDispositivo")});") - - End Sub - -#End Region - -#Region "Sucursales" - Public Sub CreaDTSucursales() - - If Not CveCliente > 0 Then - - TempDTSucursales = New DataTable - TempDTSucursales.Columns.Add("CveClienteSucursal", Type.GetType("System.Int32")) - TempDTSucursales.Columns.Add("SucursalCliente", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("CiudadSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("ColoniaSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("CPSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("DireccionSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("LocalidadSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("EstadoSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("PaisSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("NumExtSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("NumIntSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("TelefonoSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("CorreoSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("CorreoCotiziacionSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("ContactoSucursal", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("NumCuenta", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("CveVendedorSucursal", Type.GetType("System.Int32")) - TempDTSucursales.Columns.Add("CveUsuario", Type.GetType("System.Int32")) - TempDTSucursales.Columns.Add("CveMetodoPago", Type.GetType("System.Int32")) - TempDTSucursales.Columns.Add("FechaIng", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("Usuario", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("LT", Type.GetType("System.String")) - TempDTSucursales.Columns.Add("LG", Type.GetType("System.String")) - TempDTSucursales.Columns.Add() - - End If - End Sub - - Private Sub AddSucursalTemp() - Dim RowSucursal As DataRow = TempDTSucursales.NewRow() - RowSucursal("CveClienteSucursal") = 1 - RowSucursal("SucursalCliente") = TxtNombreSucursal.Text.Trim - RowSucursal("CiudadSucursal") = TxtCiudadSucursal.Text.Trim - RowSucursal("ColoniaSucursal") = TxtColoniaSucursal.Text.Trim - RowSucursal("CPSucursal") = TxtCPSucursal.Text.Trim - RowSucursal("DireccionSucursal") = TxtDireccionSucursal.Text.Trim - RowSucursal("LocalidadSucursal") = TxtLocalidadSucursal.Text.Trim - RowSucursal("EstadoSucursal") = TxtEstadoSucursal.Text.Trim - RowSucursal("PaisSucursal") = TxtPaisSucursal.Text.Trim - RowSucursal("NumExtSucursal") = TxtNumExtSucursal.Text.Trim - RowSucursal("NumIntSucursal") = TxtNumIntSucursal.Text.Trim - RowSucursal("TelefonoSucursal") = TxtTelefonoSucursal.Text.Trim - RowSucursal("CorreoSucursal") = TxtCorreoSucursal.Text.Trim - RowSucursal("CorreoCotiziacionSucursal") = TxtCorreoSucursalCotizacion.Text.Trim - RowSucursal("ContactoSucursal") = TxtContactoSucursal.Text.Trim - RowSucursal("NumCuenta") = TxtNumeroCuenta.Text - RowSucursal("CveVendedorSucursal") = DdlVendedorSucursal.SelectedValue.ToEntero - RowSucursal("CveMetodoPago") = DdlMetodoPagoSucursal.SelectedValue.ToEntero - RowSucursal("CveUsuario") = UsuarioActual.CveUsuario - RowSucursal("FechaIng") = Now.ToShortDateString - RowSucursal("Usuario") = UsuarioActual.Usuario - - RowSucursal("CveUsoCFDI") = DdlSucursalUsoCFDI.SelectedValue.ToEntero - RowSucursal("CveFormaPago33") = DdlSucursalFormaPago33.SelectedValue.ToEntero - RowSucursal("CveMetodoPago33") = DdlSucursalMetodoPago33.SelectedValue.ToEntero - - RowSucursal("LT") = If(txtLt.Text.ToDouble <> 0, txtLt.Text, "0") - RowSucursal("LG") = If(txtLg.Text.ToDouble <> 0, txtLg.Text, "0") - - TempDTSucursales.Rows.Add(RowSucursal) - - GVSucursales.DataSource = TempDTSucursales - GVSucursales.DataBind() - UpDatos.Update() - End Sub - - Private Sub BtnSendMail2_Click(sender As Object, e As EventArgs) Handles BtnSendMail2.Click - Try - If HdnCveVenta2.Value <> "-1" AndAlso HdnFolioVenta2.Value <> "-1" Then - - Dim ObjMail As New ClsSisMail() - Dim Ruta As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\" - - Dim Cuerpo As String = TxtBody2.Text - Dim Asunto As String = "" - Dim TipoComprobante = "" - - If HdnTipoDocto2.Value.ToString = "Ing" Then TipoComprobante = "Factura" - If HdnTipoDocto2.Value.ToString = "Egs" Then TipoComprobante = "Nota de Crédito" - If HdnTipoDocto2.Value.ToString = "Dev" Then TipoComprobante = "Nota de Devolución" - If HdnTipoDocto2.Value.ToString = "Rem" Then TipoComprobante = "Remisión" - If HdnTipoDocto2.Value.ToString = "Cot" Then TipoComprobante = "Cotización" - If HdnTipoDocto2.Value.ToString = "Ant" Then TipoComprobante = "Anticipo" - - - Dim ObjVenta As New ClsVentas - Dim Dr As DataRow = Nothing - If ObjVenta.GetVenta(HdnCveVenta2.Value.ToEntero, UsuarioActual.CveEmpresa) Then - If ObjVenta.DtResultados.Rows.Count > 0 Then - Dr = ObjVenta.DtResultados.Rows(0) - End If - End If - ObjVenta.Dispose() - - If UsuarioActual.Empresa.PlantillaMailVenta.Trim.Length > 0 Then - Cuerpo = UsuarioActual.Empresa.PlantillaMailVenta - Cuerpo = Cuerpo.Replace("{""NombreEmpresa""}", UsuarioActual.Empresa.Empresa) - Cuerpo = Cuerpo.Replace("{""NombreCliente""}", LtlCliente.Text.Trim) - Cuerpo = Cuerpo.Replace("{""TipoDocumento""}", TipoComprobante) - Cuerpo = Cuerpo.Replace("{""SerieFolio""}", HdnSerieFolio2.Value.ToString) - If Dr IsNot Nothing Then - Cuerpo = Cuerpo.Replace("{""Fecha""}", Dr("Fecha").ToString.ToDate.ToShortDateString) - Cuerpo = Cuerpo.Replace("{""Total""}", Dr("Total").ToString.FormatoNumero) - Cuerpo = Cuerpo.Replace("{""FechaVencimiento""}", Dr("FechaVencimiento").ToString.ToDate.ToShortDateString) - End If - End If - - - If UsuarioActual.Empresa.AsuntoPlantillaMailVenta.Trim.Length > 0 Then - Asunto = UsuarioActual.Empresa.AsuntoPlantillaMailVenta - Asunto = Asunto.Replace("{""TipoDocumento""}", TipoComprobante) - Asunto = Asunto.Replace("{""Sucursal""}", HdnSubProyecto2.Value.ToString) - Asunto = Asunto.Replace("{""SerieFolio""}", HdnSerieFolio2.Value.ToString) - End If - - If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso HdnTipoDocto2.Value.Contiene("Ing", "Egs") Then - If File.Exists($"{Ruta}PDF\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.pdf") AndAlso File.Exists($"{Ruta}XML\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.xml") Then - Dim PDF As String = $"{Ruta}PDF\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.pdf" - Dim XML As String = $"{Ruta}XML\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.xml" - - - Dim ResultadoMail As Integer = 0 - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = XML}) - - - - 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then - If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail2.Text.Trim, Asunto, Cuerpo, TxtCC2.Text.Trim, LSRutasMail) Then - ResultadoMail = 1 - TxtCC2.Text = "" - TxtBody2.Text = "" - RegistraScript("$('#ModalDivMail2').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - CargaHistorial() - 'UpnHistorial.Update() - Else - Alert("Ocurrió un error al enviar el correo", TipoMensaje.MsgError) - ResultadoMail = 3 - End If - - Dim ObjVentas As New ClsVentas - ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta2.Value.ToEntero) - ObjVentas.Dispose() - Else - Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) - End If - ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" AndAlso HdnTipoDocto2.Value.Contiene("Ing", "Egs") Then - If File.Exists(Ruta & "PDF\" & HdnFolioVenta2.Value & ".pdf") Then - Dim PDF As String = Ruta & "PDF\" & HdnFolioVenta2.Value & ".pdf" - - Dim ResultadoMail As Integer = 0 - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) - - 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then - If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail2.Text.Trim, Asunto, Cuerpo, TxtCC2.Text.Trim, LSRutasMail) Then - ResultadoMail = 1 - TxtCC2.Text = "" - TxtBody2.Text = "" - RegistraScript("$('#ModalDivMail2').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - CargaHistorial() - UpnHistorial.Update() - Else - ResultadoMail = 3 - End If - - Dim ObjVentas As New ClsVentas - ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta2.Value.ToEntero) - ObjVentas.Dispose() - Else - Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) - End If - ElseIf HdnTipoDocto2.Value = "Cot" Then - If File.Exists($"{Ruta}PDF\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.pdf") Then - Dim PDF As String = $"{Ruta}PDF\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.pdf" - - Dim ResultadoMail As Integer = 0 - Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) - LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) - - 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then - If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail2.Text.Trim, Asunto, Cuerpo, TxtCC2.Text.Trim, LSRutasMail) Then - ResultadoMail = 1 - TxtCC2.Text = "" - TxtBody2.Text = "" - RegistraScript("$('#ModalDivMail2').modal('hide');") - Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) - CargaHistorial() - UpnHistorial.Update() - Else - ResultadoMail = 3 - End If - - Dim ObjVentas As New ClsVentas - ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta2.Value.ToEntero) - ObjVentas.Dispose() - Else - Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) - End If - End If - - 'End If - 'ObjEmprea.Dispose() - Else - Alert("No se seleccionó ninguna factura para envíar.", TipoMensaje.MsgAdvertencia) - End If - Catch ex As Exception - OnError("Ocurrió error al mandar MAIL", ex) - Dim ObjVentas As New ClsVentas - ObjVentas.UpdateVentaMail(3, HdnCveVenta2.Value.ToEntero) - ObjVentas.Dispose() - End Try - End Sub - - Protected Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) - If DdlSubProyecto.SelectedValue.ToEntero > 0 Then - Dim Dr As DataRow = GlobalDTSubProyectos(-1, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa).Rows(0) - If Dr IsNot Nothing Then - If Dr("CvePrecioLista").ToString.ToEntero > 0 Then - DdlPrecioLista.SelectedValueExist(Dr("CvePrecioLista").ToString) - End If - End If - End If - End Sub - -#End Region - -#Region "G P S" - - - - Private Sub EnviaCorreoGPS(Liga As String, LigaActivar As String) - - Try - Dim Para = TxtEmail.Text.Trim - Dim Asunto = "ACTIVACIÓN DEL PORTAL GPS" - Dim SBBody As New StringBuilder - 'Linia de estilos - SBBody.Append("") - 'incio Cuerpo del correo - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("ALTA DE CUENTA") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.AppendFormat(" Estimado {0}:
    ", TxtNombre.Text.ToUpper) - SBBody.AppendFormat("El presente correo es para informarle que se le han asignado los siguientes datos para el acceso al Portal GPS de: {0}

    ", UsuarioActual.Empresa.Empresa) - SBBody.Append("
    ") - SBBody.Append("
    Datos de usuario
    ") - SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    Dirección de Acceso
    ") - SBBody.AppendFormat("", Liga) - SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    Clave
    ") - SBBody.AppendFormat("
    {0}
    ", CveCliente) - SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    Usuario
    ") - SBBody.AppendFormat("
    {0}
    ", "Admin") - SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    Haga click para activar su cuenta
    ") - SBBody.AppendFormat("", LigaActivar) - SBBody.Append("
    ") - - - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("Para Activar su cuenta debera cambiar su contraseña.

    ") - SBBody.Append("
    ") - SBBody.Append("Nota Favor de NO responder este correo. ") - SBBody.Append("


    ") - SBBody.AppendFormat("", UrlSitio) - SBBody.Append("
    ") - SBBody.Append("
    ") - 'Termino Cuerpo del correo - - Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Asunto, Para, SBBody.ToString)) - Hilo.Start() - Alert("El correo de activación se ha enviado correctamente a: " + TxtEmail.Text + ".", TipoMensaje.MsgInformacion) - Catch ex As Exception - OnError("Ocurrió error al mandar MAIL", ex) - End Try - End Sub - - Private Sub BtnRegistrarCliente_Click(sender As Object, e As EventArgs) Handles BtnRegistrarCliente.Click - Dim ObjClientes As New ClsClientes - - If ObjClientes.RegistrarCliente(CveCliente) Then - RegistraScript("location.reload();") - End If - - ObjClientes.Dispose() - End Sub - - -#End Region - -#Region "C O N T R A T O S" - Private Sub CargaDatosContrato() - If CveCliente <= 0 Then - Exit Sub - End If - - Dim ObjContratos As New ClsContratos - If ObjContratos.GetReporteContratosAvancesCP(UsuarioActual.CveEmpresa, CveCliente, -1, -1, -1, -1, 1) 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 - - If ObjContratos.GetReporteContratosAvancesCP(UsuarioActual.CveEmpresa, CveCliente, -1, -1, -1, -1, -2) Then - GvContratosClienteInactivos.DataSource = ObjContratos.DtResultados - Else - Alert("Ocurrió un Error al obtener el Reporte de Avances Inactivos. Por favor vuelva a intentar", TipoMensaje.MsgError) - End If - - ObjContratos.Dispose() - GvDatosAvance.DataBind() - UpContratosInactivos.DataBind() - - - If GvDatosAvance.Rows.Count > 0 Or GvContratosClienteInactivos.Rows.Count > 0 Then - TabContratos.Visible = True - End If - End Sub - - Private Sub GvDatosAvance_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosAvance.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("CveContrato").ToString.ToEntero = 0 Then - e.Row.Cells(0).Text = "Total:" - e.Row.CssClass = "Totales white" - End If - End If - End Sub - - Private Sub GvContratosClienteInactivos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvContratosClienteInactivos.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("CveContrato").ToString.ToEntero = 0 Then - e.Row.Cells(0).Text = "Total:" - e.Row.CssClass = "Totales white" - End If - End If - End Sub - -#End Region - -#Region "M E T O D O S " - Protected Sub RblTipo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipo.SelectedIndexChanged - CargaHistorial(TipoDocto:=RblTipo.SelectedValue) - End Sub - Private Sub DdlSucursalCliente_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSucursalCliente.SelectedIndexChanged - CargaCotizaciones(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo - CargaHistorial(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo - CargaCxC(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo - CargaAnticipos(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo - CargaBancos(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo - - UpDatos.Update() - End Sub - Protected Sub LbDesactivaUsuario_Click(sender As Object, e As EventArgs) Handles LbDesactivaPortal.Click - 'Alert("Se Van a desativar todos o eliminar todos, junto con el Admin?") - Dim ObjUsuario As New ClsSisUsuarios - Dim ErrorUsuario As Boolean = False - - ObjUsuario.IniciaTransacSQL() - - For Each Dr As DataRow In DirectCast(ViewState("DTUsuariosCliente"), DataTable).Rows - 'se desactiva el usuario y se restablece la contraseña - If Not ObjUsuario.UpdateUsuarioPortal(Dr("Usuario").ToString, Dr("Nombre").ToString, Dr("Correo").ToString, False, ContraseñaPredeterminadaEncriptada, Dr("CveCliente").ToString.ToEntero, Dr("CveProveedor").ToString.ToEntero, Dr("CveUsuario").ToString.ToEntero, UsuarioActual.CveUsuario) Then - ErrorUsuario = True - End If - Next - - If ErrorUsuario Then - ObjUsuario.RollBack() - Else - LblUsuarioActivo.Text = "No" - HdnCveUsuarioPortalActivado.Value = "0" - trEnviarActivacion.Visible = True - trDesactivarUsuario.Visible = False - - 'DivPermisosPortal.Visible = False - - ObjUsuario.GetUsuariosPortal(-1, CveCliente, -1) - - ViewState("DTUsuariosCliente") = ObjUsuario.DtResultados - GvUsuariosPortal.DataSource = ViewState("DTUsuariosCliente") - GvUsuariosPortal.DataBind() - 'divUsuariosPortal.Visible = False - - ObjUsuario.Commit() - End If - - ObjUsuario.Dispose() - - If UsuarioActual.Empresa.CvePlataforma = 1 Then - CargaUsuariosPortalCliente() - End If - - UpGvUsuarios.Update() - UPPUsuarios.Update() - - End Sub - Private Sub AbonaaCuenta() - - 'si usa bancos, se va abrir el popupie para la recepci[on del pago - Dim MsgError As String = "" - - Dim ObjMov As New ClsContabilidad - ObjMov.IniciaTransacSQL() - Dim CvePrePoliza As Integer = ObjMov.AddPrePolizas("Cli", 2, TxtCantidad.Text.Trim.ToDouble, TxtCantidad.Text.Trim.ToDouble, 1, TxtFechaPago.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) - - If CvePrePoliza > 0 Then - If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtCantidad.Text.ToDecimal, TxtReferencia.Text, 2, TxtReferencia.Text, Now, 0, -1, -1, CveVenta:=HdnCveVentaAbono.Value.ToEntero, CveCliente:=CveCliente) Then - If ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtCantidad.Text.ToDecimal, TxtReferencia.Text, 4, TxtReferencia.Text, Now, 0, -1, -1, CveVenta:=HdnCveVentaAbono.Value.ToEntero, CveCliente:=CveCliente) Then - - Else - MsgError = "no se pudo insertar el detalle de la póliza2" - End If - Else - MsgError = "no se pudo insertar el detalle de la póliza" - End If - Else - MsgError = "No se pudo insertar la póliza" - End If - - If MsgError = "" Then - Alert("El Documento se guardó correctamente.", TipoMensaje.MsgInformacion, "window.opener.location.href = window.opener.location.href; window.close();") - ObjMov.Commit() - - UpDatos.Update() - - Else - ObjMov.RollBack() - End If - ObjMov.Dispose() - - - - End Sub - Private Sub ChecaPermiteCredito() - ' DivParametros.Disabled = Not ChkPermiteCredito.Checked - 'For Each Control As Control In UpParametros.Controls - ' Control.Visible = ChkPermiteCredito.Checked - 'Next - - DivPortal.Visible = UsuarioActual.TienePermisoProceso(162) - - TxtLimiteCredito.Enabled = UsuarioActual.TienePermisoProceso(162) - TxtPlazoCobranza.Enabled = UsuarioActual.TienePermisoProceso(162) - TxtPlazoCobranzaRemision.Enabled = UsuarioActual.TienePermisoProceso(162) - - DdlTipoPago.Enabled = UsuarioActual.TienePermisoProceso(162) - DdlResponsable.Enabled = UsuarioActual.TienePermisoProceso(162) - - ChkLunes.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkMartes.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkMiercoles.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkJueves.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkViernes.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkSabado.Enabled = UsuarioActual.TienePermisoProceso(162) - - ChkRevLunes.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkRevMartes.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkRevMiercoles.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkRevJueves.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkRevViernes.Enabled = UsuarioActual.TienePermisoProceso(162) - ChkRevSabado.Enabled = UsuarioActual.TienePermisoProceso(162) - - TxtDiasEspecifico.Enabled = UsuarioActual.TienePermisoProceso(162) - TxtDocumentacion.Enabled = UsuarioActual.TienePermisoProceso(162) - TxtCobranzaContacto.Enabled = UsuarioActual.TienePermisoProceso(162) - TxtCobranzaTelefono.Enabled = UsuarioActual.TienePermisoProceso(162) - TxtCobranzaExt.Enabled = UsuarioActual.TienePermisoProceso(162) - TxtCobranzaCorreo.Enabled = UsuarioActual.TienePermisoProceso(162) - TxtHorario.Enabled = UsuarioActual.TienePermisoProceso(162) - - TxtPortalFacturacion.Enabled = UsuarioActual.TienePermisoProceso(162) - TxtObsDiasRevision.Enabled = UsuarioActual.TienePermisoProceso(162) - - UpParametros.Update() - End Sub - Private Function NombreCuenta(Id As Integer) As String - Dim Retorno As String = "" - - If UsuarioActual.Empresa.ServerContPAQi = "" Then Return "" - Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) - If ObjContabilidad.GetCuentas(Id, "-1", -1) Then - Retorno = ObjContabilidad.DtResultados.FiltroPrimeroValor("CtaCodigo") - End If - - Return Retorno - End Function - Private Sub SetValues() - ViewState("Orden") = "" - ViewState("OrdenUsuarios") = "" - TxtFechaPago.Text = Now.ToShortDateString - txtFechaI.Text = Now.ToShortDateString - txtFechaF.Text = Now.ToShortDateString - TxtFechaImportarSaldos.Text = Now.ToShortDateString - TxtFechaIUsados.Text = Now.FirstDayOfMonth.ToShortDateString - TxtFechaFUsados.Text = Now.LastDayOfMonth.ToShortDateString - CobranzaTelefono = "" - CodigoCliente = "" - - End Sub - - Protected 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 csv o excel a la plataforma", TipoMensaje.MsgError) - End If - 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 "CSV" - Conexion = New Odbc.OdbcConnection("Driver={Microsoft Access Text Driver (*.txt, *.csv)};Dbq=" + Ruta + ";Extensions=asc,csv,tab,txt;") - Conexion.Open() - Dim cmd = Conexion.CreateCommand() - cmd.CommandType = CommandType.Text - cmd.CommandText = $"SELECT * FROM [{FileName}]" - Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) - DataAdapter.Fill(dt) - 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
    " & ex.Message, ex) - End Try - Conexion.Close() - If Not ErrorArchivo Then - If Not dt.Columns(0).ColumnName = "SerieFolio" Then - Alert("El nombre de la primera columna debe ser 'SerieFolio'.Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - If Not dt.Columns(1).ColumnName = "Fecha" Then - Alert("El nombre de la segunda columna debe ser 'Fecha'.Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - If Not dt.Columns(2).ColumnName = "Importe" Then - Alert("El nombre de la tercera columna debe ser 'Importe'.Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - If Not dt.Columns(3).ColumnName = "Saldo" Then - Alert("El nombre de la cuarta columna debe ser 'Saldo'.Favor de corregirlo", TipoMensaje.MsgError) - Exit Sub - End If - Dim XmlStream As New System.IO.MemoryStream - dt.TableName = "Datos" - Dim ObjClientes As New ClsClientes - Dim writer As New System.IO.StringWriter - dt.WriteXml(writer) - If ObjClientes.GetVentasConciliacion(CveCliente, DataTableToXml(writer)) Then - ObjClientes.DtResultados.ExportToExcel("Resultados") - End If - ObjClientes.Dispose() - End If - End Sub - Private Function DataTableToXml(ByVal stream As System.IO.TextWriter) As String - Return stream.ToString() - End Function - Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click - Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\FormatoClientes.csv" - Dim Archivo As New 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 - Private Sub EnviaCorreo2(Liga As String, LigaActivar As String) - - Try - Dim Para = TxtCorreoUsuarioPortal.Text.Trim - Dim Asunto = "ACTIVACIÓN DEL PORTAL DE CLIENTE" - Dim SBBody As New StringBuilder - 'Linia de estilos - SBBody.Append("") - 'incio Cuerpo del correo - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("ALTA DE CUENTA") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.AppendFormat(" Estimado {0}:
    ", TxtNombreUsuarioPortal.Text.ToUpper) - SBBody.AppendFormat("El presente correo es para informarle que se le han asignado los siguientes datos para el acceso al Portal del Cliente de: {0}

    ", UsuarioActual.Empresa.Empresa) - SBBody.Append("
    ") - SBBody.Append("
    Datos de usuario
    ") - SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    Dirección de Acceso
    ") - SBBody.AppendFormat("", Liga) - SBBody.Append("
    ") - - 'SBBody.Append("
    ") - 'SBBody.Append("
    Clave
    ") - 'SBBody.AppendFormat("
    {0}
    ", CveCliente) - 'SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    Usuario
    ") - SBBody.AppendFormat("
    {0}
    ", TxtCorreoUsuarioPortal.Text) - SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    Contraseña Predeterminada
    ") - SBBody.AppendFormat("
    {0}
    ", ContraseñaPredeterminada) - SBBody.Append("
    ") - - - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    Haga click para activar su cuenta
    ") - SBBody.AppendFormat("", LigaActivar) - SBBody.Append("
    ") - - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("
    ") - SBBody.Append("Para Activar su cuenta debera cambiar su contraseña.

    ") - SBBody.Append("
    ") - SBBody.Append("Nota Favor de NO responder este correo. ") - SBBody.Append("


    ") - - SBBody.AppendFormat("", UrlSitio) - SBBody.Append("") - SBBody.Append("") - 'Termino Cuerpo del correo - - Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo2(Asunto, Para, SBBody.ToString)) - Hilo.Start() - Alert("El correo se ha enviado correctamente a: " + TxtCorreoUsuarioPortal.Text + ".", TipoMensaje.MsgInformacion) - Catch ex As Exception - OnError("Ocurrió error al mandar MAIL", ex) - End Try - End Sub - Private Sub MandaCorreo2(Asunto As String, Para As String, Body As String) - Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) - a.GuardaLog() - Dim Mail As New ClsSisMail() + Protected Sub DdlEmpresaDispositivo_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaClienteDispositivos(DdlEmpresaDispositivo.SelectedValue.ToEntero()) + End Sub + + + Protected Sub ImgMoverDispositivo_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Me.NombreDispositivo = GvRow.DataKey("Display") + HTituloDispostivo.InnerText = $"Mover Dispositivo: {NombreDispositivo}" + + UpMoverDispositivo.Update() + RegistraScript($"CargaModalMoverDispositivo({GvRow.DataKey("CveDispositivo")});") + + End Sub + +#End Region + +#Region "Sucursales" + Public Sub CreaDTSucursales() + + If Not CveCliente > 0 Then + + TempDTSucursales = New DataTable + TempDTSucursales.Columns.Add("CveClienteSucursal", Type.GetType("System.Int32")) + TempDTSucursales.Columns.Add("SucursalCliente", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("CiudadSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("ColoniaSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("CPSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("DireccionSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("LocalidadSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("EstadoSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("PaisSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("NumExtSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("NumIntSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("TelefonoSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("CorreoSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("CorreoCotiziacionSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("ContactoSucursal", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("NumCuenta", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("CveVendedorSucursal", Type.GetType("System.Int32")) + TempDTSucursales.Columns.Add("CveUsuario", Type.GetType("System.Int32")) + TempDTSucursales.Columns.Add("CveMetodoPago", Type.GetType("System.Int32")) + TempDTSucursales.Columns.Add("FechaIng", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("Usuario", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("LT", Type.GetType("System.String")) + TempDTSucursales.Columns.Add("LG", Type.GetType("System.String")) + TempDTSucursales.Columns.Add() + + End If + End Sub + + Private Sub AddSucursalTemp() + Dim RowSucursal As DataRow = TempDTSucursales.NewRow() + RowSucursal("CveClienteSucursal") = 1 + RowSucursal("SucursalCliente") = TxtNombreSucursal.Text.Trim + RowSucursal("CiudadSucursal") = TxtCiudadSucursal.Text.Trim + RowSucursal("ColoniaSucursal") = TxtColoniaSucursal.Text.Trim + RowSucursal("CPSucursal") = TxtCPSucursal.Text.Trim + RowSucursal("DireccionSucursal") = TxtDireccionSucursal.Text.Trim + RowSucursal("LocalidadSucursal") = TxtLocalidadSucursal.Text.Trim + RowSucursal("EstadoSucursal") = TxtEstadoSucursal.Text.Trim + RowSucursal("PaisSucursal") = TxtPaisSucursal.Text.Trim + RowSucursal("NumExtSucursal") = TxtNumExtSucursal.Text.Trim + RowSucursal("NumIntSucursal") = TxtNumIntSucursal.Text.Trim + RowSucursal("TelefonoSucursal") = TxtTelefonoSucursal.Text.Trim + RowSucursal("CorreoSucursal") = TxtCorreoSucursal.Text.Trim + RowSucursal("CorreoCotiziacionSucursal") = TxtCorreoSucursalCotizacion.Text.Trim + RowSucursal("ContactoSucursal") = TxtContactoSucursal.Text.Trim + RowSucursal("NumCuenta") = TxtNumeroCuenta.Text + RowSucursal("CveVendedorSucursal") = DdlVendedorSucursal.SelectedValue.ToEntero + RowSucursal("CveMetodoPago") = DdlMetodoPagoSucursal.SelectedValue.ToEntero + RowSucursal("CveUsuario") = UsuarioActual.CveUsuario + RowSucursal("FechaIng") = Now.ToShortDateString + RowSucursal("Usuario") = UsuarioActual.Usuario + + RowSucursal("CveUsoCFDI") = DdlSucursalUsoCFDI.SelectedValue.ToEntero + RowSucursal("CveFormaPago33") = DdlSucursalFormaPago33.SelectedValue.ToEntero + RowSucursal("CveMetodoPago33") = DdlSucursalMetodoPago33.SelectedValue.ToEntero + + RowSucursal("LT") = If(txtLt.Text.ToDouble <> 0, txtLt.Text, "0") + RowSucursal("LG") = If(txtLg.Text.ToDouble <> 0, txtLg.Text, "0") + + TempDTSucursales.Rows.Add(RowSucursal) + + GVSucursales.DataSource = TempDTSucursales + GVSucursales.DataBind() + UpDatos.Update() + End Sub + + Private Sub BtnSendMail2_Click(sender As Object, e As EventArgs) Handles BtnSendMail2.Click + Try + If HdnCveVenta2.Value <> "-1" AndAlso HdnFolioVenta2.Value <> "-1" Then + + Dim ObjMail As New ClsSisMail() + Dim Ruta As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\" & UsuarioActual.CveEmpresa & "\" + + Dim Cuerpo As String = TxtBody2.Text + Dim Asunto As String = "" + Dim TipoComprobante = "" + + If HdnTipoDocto2.Value.ToString = "Ing" Then TipoComprobante = "Factura" + If HdnTipoDocto2.Value.ToString = "Egs" Then TipoComprobante = "Nota de Crédito" + If HdnTipoDocto2.Value.ToString = "Dev" Then TipoComprobante = "Nota de Devolución" + If HdnTipoDocto2.Value.ToString = "Rem" Then TipoComprobante = "Remisión" + If HdnTipoDocto2.Value.ToString = "Cot" Then TipoComprobante = "Cotización" + If HdnTipoDocto2.Value.ToString = "Ant" Then TipoComprobante = "Anticipo" + + + Dim ObjVenta As New ClsVentas + Dim Dr As DataRow = Nothing + If ObjVenta.GetVenta(HdnCveVenta2.Value.ToEntero, UsuarioActual.CveEmpresa) Then + If ObjVenta.DtResultados.Rows.Count > 0 Then + Dr = ObjVenta.DtResultados.Rows(0) + End If + End If + ObjVenta.Dispose() + + If UsuarioActual.Empresa.PlantillaMailVenta.Trim.Length > 0 Then + Cuerpo = UsuarioActual.Empresa.PlantillaMailVenta + Cuerpo = Cuerpo.Replace("{""NombreEmpresa""}", UsuarioActual.Empresa.Empresa) + Cuerpo = Cuerpo.Replace("{""NombreCliente""}", LtlCliente.Text.Trim) + Cuerpo = Cuerpo.Replace("{""TipoDocumento""}", TipoComprobante) + Cuerpo = Cuerpo.Replace("{""SerieFolio""}", HdnSerieFolio2.Value.ToString) + If Dr IsNot Nothing Then + Cuerpo = Cuerpo.Replace("{""Fecha""}", Dr("Fecha").ToString.ToDate.ToShortDateString) + Cuerpo = Cuerpo.Replace("{""Total""}", Dr("Total").ToString.FormatoNumero) + Cuerpo = Cuerpo.Replace("{""FechaVencimiento""}", Dr("FechaVencimiento").ToString.ToDate.ToShortDateString) + End If + End If + + + If UsuarioActual.Empresa.AsuntoPlantillaMailVenta.Trim.Length > 0 Then + Asunto = UsuarioActual.Empresa.AsuntoPlantillaMailVenta + Asunto = Asunto.Replace("{""TipoDocumento""}", TipoComprobante) + Asunto = Asunto.Replace("{""Sucursal""}", HdnSubProyecto2.Value.ToString) + Asunto = Asunto.Replace("{""SerieFolio""}", HdnSerieFolio2.Value.ToString) + End If + + If UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso HdnTipoDocto2.Value.Contiene("Ing", "Egs") Then + If File.Exists($"{Ruta}PDF\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.pdf") AndAlso File.Exists($"{Ruta}XML\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.xml") Then + Dim PDF As String = $"{Ruta}PDF\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.pdf" + Dim XML As String = $"{Ruta}XML\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.xml" + + + Dim ResultadoMail As Integer = 0 + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = XML}) + + + + 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then + If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail2.Text.Trim, Asunto, Cuerpo, TxtCC2.Text.Trim, LSRutasMail) Then + ResultadoMail = 1 + TxtCC2.Text = "" + TxtBody2.Text = "" + RegistraScript("$('#ModalDivMail2').modal('hide');") + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + CargaHistorial() + 'UpnHistorial.Update() + Else + Alert("Ocurrió un error al enviar el correo", TipoMensaje.MsgError) + ResultadoMail = 3 + End If + + Dim ObjVentas As New ClsVentas + ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta2.Value.ToEntero) + ObjVentas.Dispose() + Else + Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) + End If + ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" AndAlso HdnTipoDocto2.Value.Contiene("Ing", "Egs") Then + If File.Exists(Ruta & "PDF\" & HdnFolioVenta2.Value & ".pdf") Then + Dim PDF As String = Ruta & "PDF\" & HdnFolioVenta2.Value & ".pdf" + + Dim ResultadoMail As Integer = 0 + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) + + 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then + If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail2.Text.Trim, Asunto, Cuerpo, TxtCC2.Text.Trim, LSRutasMail) Then + ResultadoMail = 1 + TxtCC2.Text = "" + TxtBody2.Text = "" + RegistraScript("$('#ModalDivMail2').modal('hide');") + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + CargaHistorial() + UpnHistorial.Update() + Else + ResultadoMail = 3 + End If + + Dim ObjVentas As New ClsVentas + ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta2.Value.ToEntero) + ObjVentas.Dispose() + Else + Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) + End If + ElseIf HdnTipoDocto2.Value = "Cot" Then + If File.Exists($"{Ruta}PDF\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.pdf") Then + Dim PDF As String = $"{Ruta}PDF\{HdnTipoDocto2.Value}\{HdnFolioVenta2.Value}.pdf" + + Dim ResultadoMail As Integer = 0 + Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) + LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = PDF}) + + 'If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail.Text.Trim, "Entrega de Factura", PDF, XML, ArrayCC, TxtBody.Text.Trim) Then + If ObjMail.SendMail(UsuarioActual.Empresa, TxtParaMail2.Text.Trim, Asunto, Cuerpo, TxtCC2.Text.Trim, LSRutasMail) Then + ResultadoMail = 1 + TxtCC2.Text = "" + TxtBody2.Text = "" + RegistraScript("$('#ModalDivMail2').modal('hide');") + Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion) + CargaHistorial() + UpnHistorial.Update() + Else + ResultadoMail = 3 + End If + + Dim ObjVentas As New ClsVentas + ObjVentas.UpdateVentaMail(ResultadoMail, HdnCveVenta2.Value.ToEntero) + ObjVentas.Dispose() + Else + Alert("No se pudo adjuntar el correo electrónico.", TipoMensaje.MsgError) + End If + End If + + 'End If + 'ObjEmprea.Dispose() + Else + Alert("No se seleccionó ninguna factura para envíar.", TipoMensaje.MsgAdvertencia) + End If + Catch ex As Exception + OnError("Ocurrió error al mandar MAIL", ex) + Dim ObjVentas As New ClsVentas + ObjVentas.UpdateVentaMail(3, HdnCveVenta2.Value.ToEntero) + ObjVentas.Dispose() + End Try + End Sub + + Protected Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) + If DdlSubProyecto.SelectedValue.ToEntero > 0 Then + Dim Dr As DataRow = GlobalDTSubProyectos(-1, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa).Rows(0) + If Dr IsNot Nothing Then + If Dr("CvePrecioLista").ToString.ToEntero > 0 Then + DdlPrecioLista.SelectedValueExist(Dr("CvePrecioLista").ToString) + End If + End If + End If + End Sub + +#End Region + +#Region "G P S" + + + + Private Sub EnviaCorreoGPS(Liga As String, LigaActivar As String) + + Try + Dim Para = TxtEmail.Text.Trim + Dim Asunto = "ACTIVACIÓN DEL PORTAL GPS" + Dim SBBody As New StringBuilder + 'Linia de estilos + SBBody.Append("") + 'incio Cuerpo del correo + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("ALTA DE CUENTA") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.AppendFormat(" Estimado {0}:
    ", TxtNombre.Text.ToUpper) + SBBody.AppendFormat("El presente correo es para informarle que se le han asignado los siguientes datos para el acceso al Portal GPS de: {0}

    ", UsuarioActual.Empresa.Empresa) + SBBody.Append("
    ") + SBBody.Append("
    Datos de usuario
    ") + SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    Dirección de Acceso
    ") + SBBody.AppendFormat("", Liga) + SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    Clave
    ") + SBBody.AppendFormat("
    {0}
    ", CveCliente) + SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    Usuario
    ") + SBBody.AppendFormat("
    {0}
    ", "Admin") + SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    Haga click para activar su cuenta
    ") + SBBody.AppendFormat("", LigaActivar) + SBBody.Append("
    ") + + + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("Para Activar su cuenta debera cambiar su contraseña.

    ") + SBBody.Append("
    ") + SBBody.Append("Nota Favor de NO responder este correo. ") + SBBody.Append("


    ") + SBBody.AppendFormat("", UrlSitio) + SBBody.Append("
    ") + SBBody.Append("
    ") + 'Termino Cuerpo del correo + + Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo(Asunto, Para, SBBody.ToString)) + Hilo.Start() + Alert("El correo de activación se ha enviado correctamente a: " + TxtEmail.Text + ".", TipoMensaje.MsgInformacion) + Catch ex As Exception + OnError("Ocurrió error al mandar MAIL", ex) + End Try + End Sub + + Private Sub BtnRegistrarCliente_Click(sender As Object, e As EventArgs) Handles BtnRegistrarCliente.Click + Dim ObjClientes As New ClsClientes + + If ObjClientes.RegistrarCliente(CveCliente) Then + RegistraScript("location.reload();") + End If + + ObjClientes.Dispose() + End Sub + + +#End Region + +#Region "C O N T R A T O S" + Private Sub CargaDatosContrato() + If CveCliente <= 0 Then + Exit Sub + End If + + Dim ObjContratos As New ClsContratos + If ObjContratos.GetReporteContratosAvancesCP(UsuarioActual.CveEmpresa, CveCliente, -1, -1, -1, -1, 1) 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 + + If ObjContratos.GetReporteContratosAvancesCP(UsuarioActual.CveEmpresa, CveCliente, -1, -1, -1, -1, -2) Then + GvContratosClienteInactivos.DataSource = ObjContratos.DtResultados + Else + Alert("Ocurrió un Error al obtener el Reporte de Avances Inactivos. Por favor vuelva a intentar", TipoMensaje.MsgError) + End If + + ObjContratos.Dispose() + GvDatosAvance.DataBind() + UpContratosInactivos.DataBind() + + + If GvDatosAvance.Rows.Count > 0 Or GvContratosClienteInactivos.Rows.Count > 0 Then + TabContratos.Visible = True + End If + End Sub + + Private Sub GvDatosAvance_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatosAvance.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CveContrato").ToString.ToEntero = 0 Then + e.Row.Cells(0).Text = "Total:" + e.Row.CssClass = "Totales white" + End If + End If + End Sub + + Private Sub GvContratosClienteInactivos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvContratosClienteInactivos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CveContrato").ToString.ToEntero = 0 Then + e.Row.Cells(0).Text = "Total:" + e.Row.CssClass = "Totales white" + End If + End If + End Sub + +#End Region + +#Region "M E T O D O S " + Protected Sub RblTipo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipo.SelectedIndexChanged + CargaHistorial(TipoDocto:=RblTipo.SelectedValue) + End Sub + Private Sub DdlSucursalCliente_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSucursalCliente.SelectedIndexChanged + CargaCotizaciones(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo + CargaHistorial(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo + CargaCxC(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo + CargaAnticipos(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo + CargaBancos(CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero) 'listo + + UpDatos.Update() + End Sub + Protected Sub LbDesactivaUsuario_Click(sender As Object, e As EventArgs) Handles LbDesactivaPortal.Click + 'Alert("Se Van a desativar todos o eliminar todos, junto con el Admin?") + Dim ObjUsuario As New ClsSisUsuarios + Dim ErrorUsuario As Boolean = False + + ObjUsuario.IniciaTransacSQL() + + For Each Dr As DataRow In DirectCast(ViewState("DTUsuariosCliente"), DataTable).Rows + 'se desactiva el usuario y se restablece la contraseña + If Not ObjUsuario.UpdateUsuarioPortal(Dr("Usuario").ToString, Dr("Nombre").ToString, Dr("Correo").ToString, False, ContraseñaPredeterminadaEncriptada, Dr("CveCliente").ToString.ToEntero, Dr("CveProveedor").ToString.ToEntero, Dr("CveUsuario").ToString.ToEntero, UsuarioActual.CveUsuario) Then + ErrorUsuario = True + End If + Next + + If ErrorUsuario Then + ObjUsuario.RollBack() + Else + LblUsuarioActivo.Text = "No" + HdnCveUsuarioPortalActivado.Value = "0" + trEnviarActivacion.Visible = True + trDesactivarUsuario.Visible = False + + 'DivPermisosPortal.Visible = False + + ObjUsuario.GetUsuariosPortal(-1, CveCliente, -1) + + ViewState("DTUsuariosCliente") = ObjUsuario.DtResultados + GvUsuariosPortal.DataSource = ViewState("DTUsuariosCliente") + GvUsuariosPortal.DataBind() + 'divUsuariosPortal.Visible = False + + ObjUsuario.Commit() + End If + + ObjUsuario.Dispose() + + If UsuarioActual.Empresa.CvePlataforma = 1 Then + CargaUsuariosPortalCliente() + End If + + UpGvUsuarios.Update() + UPPUsuarios.Update() + + End Sub + Private Sub AbonaaCuenta() + + 'si usa bancos, se va abrir el popupie para la recepci[on del pago + Dim MsgError As String = "" + + Dim ObjMov As New ClsContabilidad + ObjMov.IniciaTransacSQL() + Dim CvePrePoliza As Integer = ObjMov.AddPrePolizas("Cli", 2, TxtCantidad.Text.Trim.ToDouble, TxtCantidad.Text.Trim.ToDouble, 1, TxtFechaPago.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) + + If CvePrePoliza > 0 Then + If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtCantidad.Text.ToDecimal, TxtReferencia.Text, 2, TxtReferencia.Text, Now, 0, -1, -1, CveVenta:=HdnCveVentaAbono.Value.ToEntero, CveCliente:=CveCliente) Then + If ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtCantidad.Text.ToDecimal, TxtReferencia.Text, 4, TxtReferencia.Text, Now, 0, -1, -1, CveVenta:=HdnCveVentaAbono.Value.ToEntero, CveCliente:=CveCliente) Then + + Else + MsgError = "no se pudo insertar el detalle de la póliza2" + End If + Else + MsgError = "no se pudo insertar el detalle de la póliza" + End If + Else + MsgError = "No se pudo insertar la póliza" + End If + + If MsgError = "" Then + Alert("El Documento se guardó correctamente.", TipoMensaje.MsgInformacion, "window.opener.location.href = window.opener.location.href; window.close();") + ObjMov.Commit() + + UpDatos.Update() + + Else + ObjMov.RollBack() + End If + ObjMov.Dispose() + + + + End Sub + Private Sub ChecaPermiteCredito() + ' DivParametros.Disabled = Not ChkPermiteCredito.Checked + 'For Each Control As Control In UpParametros.Controls + ' Control.Visible = ChkPermiteCredito.Checked + 'Next + + DivPortal.Visible = UsuarioActual.TienePermisoProceso(162) + + TxtLimiteCredito.Enabled = UsuarioActual.TienePermisoProceso(162) + TxtPlazoCobranza.Enabled = UsuarioActual.TienePermisoProceso(162) + TxtPlazoCobranzaRemision.Enabled = UsuarioActual.TienePermisoProceso(162) + + DdlTipoPago.Enabled = UsuarioActual.TienePermisoProceso(162) + DdlResponsable.Enabled = UsuarioActual.TienePermisoProceso(162) + + ChkLunes.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkMartes.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkMiercoles.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkJueves.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkViernes.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkSabado.Enabled = UsuarioActual.TienePermisoProceso(162) + + ChkRevLunes.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkRevMartes.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkRevMiercoles.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkRevJueves.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkRevViernes.Enabled = UsuarioActual.TienePermisoProceso(162) + ChkRevSabado.Enabled = UsuarioActual.TienePermisoProceso(162) + + TxtDiasEspecifico.Enabled = UsuarioActual.TienePermisoProceso(162) + TxtDocumentacion.Enabled = UsuarioActual.TienePermisoProceso(162) + TxtCobranzaContacto.Enabled = UsuarioActual.TienePermisoProceso(162) + TxtCobranzaTelefono.Enabled = UsuarioActual.TienePermisoProceso(162) + TxtCobranzaExt.Enabled = UsuarioActual.TienePermisoProceso(162) + TxtCobranzaCorreo.Enabled = UsuarioActual.TienePermisoProceso(162) + TxtHorario.Enabled = UsuarioActual.TienePermisoProceso(162) + + TxtPortalFacturacion.Enabled = UsuarioActual.TienePermisoProceso(162) + TxtObsDiasRevision.Enabled = UsuarioActual.TienePermisoProceso(162) + + UpParametros.Update() + End Sub + Private Function NombreCuenta(Id As Integer) As String + Dim Retorno As String = "" + + If UsuarioActual.Empresa.ServerContPAQi = "" Then Return "" + Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa) + If ObjContabilidad.GetCuentas(Id, "-1", -1) Then + Retorno = ObjContabilidad.DtResultados.FiltroPrimeroValor("CtaCodigo") + End If + + Return Retorno + End Function + Private Sub SetValues() + ViewState("Orden") = "" + ViewState("OrdenUsuarios") = "" + TxtFechaPago.Text = Now.ToShortDateString + txtFechaI.Text = Now.ToShortDateString + txtFechaF.Text = Now.ToShortDateString + TxtFechaImportarSaldos.Text = Now.ToShortDateString + TxtFechaIUsados.Text = Now.FirstDayOfMonth.ToShortDateString + TxtFechaFUsados.Text = Now.LastDayOfMonth.ToShortDateString + CobranzaTelefono = "" + CodigoCliente = "" + + End Sub + + Protected 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 csv o excel a la plataforma", TipoMensaje.MsgError) + End If + 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 "CSV" + Conexion = New Odbc.OdbcConnection("Driver={Microsoft Access Text Driver (*.txt, *.csv)};Dbq=" + Ruta + ";Extensions=asc,csv,tab,txt;") + Conexion.Open() + Dim cmd = Conexion.CreateCommand() + cmd.CommandType = CommandType.Text + cmd.CommandText = $"SELECT * FROM [{FileName}]" + Dim DataAdapter = New Odbc.OdbcDataAdapter(cmd) + DataAdapter.Fill(dt) + 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
    " & ex.Message, ex) + End Try + Conexion.Close() + If Not ErrorArchivo Then + If Not dt.Columns(0).ColumnName = "SerieFolio" Then + Alert("El nombre de la primera columna debe ser 'SerieFolio'.Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(1).ColumnName = "Fecha" Then + Alert("El nombre de la segunda columna debe ser 'Fecha'.Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(2).ColumnName = "Importe" Then + Alert("El nombre de la tercera columna debe ser 'Importe'.Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + If Not dt.Columns(3).ColumnName = "Saldo" Then + Alert("El nombre de la cuarta columna debe ser 'Saldo'.Favor de corregirlo", TipoMensaje.MsgError) + Exit Sub + End If + Dim XmlStream As New System.IO.MemoryStream + dt.TableName = "Datos" + Dim ObjClientes As New ClsClientes + Dim writer As New System.IO.StringWriter + dt.WriteXml(writer) + If ObjClientes.GetVentasConciliacion(CveCliente, DataTableToXml(writer)) Then + ObjClientes.DtResultados.ExportToExcel("Resultados") + End If + ObjClientes.Dispose() + End If + End Sub + Private Function DataTableToXml(ByVal stream As System.IO.TextWriter) As String + Return stream.ToString() + End Function + Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click + Dim Directorio As String = AppDomain.CurrentDomain.BaseDirectory & "Empresas\Grales\FormatoClientes.csv" + Dim Archivo As New 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 + Private Sub EnviaCorreo2(Liga As String, LigaActivar As String) + + Try + Dim Para = TxtCorreoUsuarioPortal.Text.Trim + Dim Asunto = "ACTIVACIÓN DEL PORTAL DE CLIENTE" + Dim SBBody As New StringBuilder + 'Linia de estilos + SBBody.Append("") + 'incio Cuerpo del correo + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("ALTA DE CUENTA") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.AppendFormat(" Estimado {0}:
    ", TxtNombreUsuarioPortal.Text.ToUpper) + SBBody.AppendFormat("El presente correo es para informarle que se le han asignado los siguientes datos para el acceso al Portal del Cliente de: {0}

    ", UsuarioActual.Empresa.Empresa) + SBBody.Append("
    ") + SBBody.Append("
    Datos de usuario
    ") + SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    Dirección de Acceso
    ") + SBBody.AppendFormat("", Liga) + SBBody.Append("
    ") + + 'SBBody.Append("
    ") + 'SBBody.Append("
    Clave
    ") + 'SBBody.AppendFormat("
    {0}
    ", CveCliente) + 'SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    Usuario
    ") + SBBody.AppendFormat("
    {0}
    ", TxtCorreoUsuarioPortal.Text) + SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    Contraseña Predeterminada
    ") + SBBody.AppendFormat("
    {0}
    ", ContraseñaPredeterminada) + SBBody.Append("
    ") + + + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    Haga click para activar su cuenta
    ") + SBBody.AppendFormat("", LigaActivar) + SBBody.Append("
    ") + + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("
    ") + SBBody.Append("Para Activar su cuenta debera cambiar su contraseña.

    ") + SBBody.Append("
    ") + SBBody.Append("Nota Favor de NO responder este correo. ") + SBBody.Append("


    ") + + SBBody.AppendFormat("", UrlSitio) + SBBody.Append("") + SBBody.Append("") + 'Termino Cuerpo del correo + + Dim Hilo As New System.Threading.Thread(Sub() MandaCorreo2(Asunto, Para, SBBody.ToString)) + Hilo.Start() + Alert("El correo se ha enviado correctamente a: " + TxtCorreoUsuarioPortal.Text + ".", TipoMensaje.MsgInformacion) + Catch ex As Exception + OnError("Ocurrió error al mandar MAIL", ex) + End Try + End Sub + Private Sub MandaCorreo2(Asunto As String, Para As String, Body As String) + Dim a As String = String.Format("{0} -- {1} ---- -->", Asunto, Para) + a.GuardaLog() + Dim Mail As New ClsSisMail() Dim Envio As Boolean = Mail.SendMail(ClsPaginas.EmpresaNotificaciones, Para, Asunto, Body) - - End Sub - Protected Sub BtnCobranzaSMS_Click(sender As Object, e As EventArgs) - Dim Telefono = CobranzaTelefono - If Telefono.Length <> 10 Then - Alert("El telefono de cobranza no tiene el formato correcto y es necesario.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim DtCxC As DataTable - Dim FI = If(TxtFechaInicioCxP.Text = "" Or TxtFechaInicioCxP.Text = "__/__/____", "-1", TxtFechaInicioCxP.Text) - Dim FF = If(TxtFechaFinCxP.Text = "" Or TxtFechaFinCxP.Text = "__/__/____", "-1", TxtFechaFinCxP.Text) - Dim StrSaldo As String = "" - - Dim ObjMovtos As New ClsMovimientos() - If ObjMovtos.GetCxCClienteDetalle(ViewState("CveCliente").ToString.ToEntero, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, -1) Then - DtCxC = If(DdlTipoCuentasCxC.SelectedValue = "-1", If(DdlTipoDocto.SelectedValue = "-1", ObjMovtos.DtResultados, ObjMovtos.DtResultados.FiltraParametros($"TipoDocto = '{DdlTipoDocto.SelectedValue}'")), - If(DdlTipoDocto.SelectedValue = "-1", ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act' ", "Moneda, OrdenVencimiento ,FechaVencimiento"), ObjMovtos.DtResultados.FiltraParametros($"Tipo = 'Act' AND TipoDocto = '{DdlTipoDocto.SelectedValue}'", "Moneda, OrdenVencimiento ,FechaVencimiento"))) - - Dim Pesos As Double = DtCxC.SUM("Saldo", "CveMoneda = 1 and CveVenta > 0") - Dim Dolares As Double = DtCxC.SUM("Saldo", "CveMoneda = 2 and CveVenta > 0") - If Pesos > 0 Then StrSaldo = $" $ {Pesos.FormatoNumero} pesos" - If Dolares > 0 Then StrSaldo = $"{StrSaldo} ${Dolares.FormatoNumero} dólares" - ObjMovtos.Dispose() - Else - DtCxC = Nothing - ObjMovtos.Dispose() - Exit Sub - End If - - If StrSaldo.Length > 0 Then - Dim Mensaje = "" - Select Case UsuarioActual.CveEmpresa - Case 4 - Mensaje = $"Cliente de VSH Seguridad su saldo pendiente es de $ {StrSaldo} fecha limite 25/{Now.ToString("MM/yyyy")} llamar al 6622106400 #REFERENCIA {CodigoCliente} " - End Select - - Dim ObjSMS As New ClsTecnoMovil - Dim ObjEventos As New ClsOIEventos - If ObjSMS.EnviarMensajeWS(Telefono, Mensaje) Then - If ObjEventos.AddEventoBitacora($"Estado de cuenta enviado al cliente via SMS. Telefono: {Telefono} Mensaje: {Mensaje}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=CveCliente) Then - Alert("El mensaje se envió correctamente", TipoMensaje.MsgInformacion) - Else - Alert("El mensaje se envió correctamente. Pero no se pudo guardar historial", TipoMensaje.MsgAdvertencia) - End If - End If - ObjEventos.Dispose() - CargaEventoBitacora() - UPEventoBitacora.Update() - Else - Alert("No hay saldo pendiente del cliente. Por lo cual no se envió el mensaje.", TipoMensaje.MsgInformacion) - End If - - - End Sub - -#End Region - -#Region "IMPRIMIR GVHistorial" - - - Protected Sub BtnExcelHistorial_Click(sender As Object, e As EventArgs) - Dim retorno As Byte() = Nothing - 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) - - - 'OBTENEMOS LOS DATOS - 'Dim DTHistorial As DataTable - 'If ObjClientes.GetHistorialVentas(UsuarioActual.CveCliente, TopRegistros) Then - ' DTHistorial = ObjClientes.DtResultados - 'Else - ' DTHistorial = Nothing - 'End If - - If DTHistorialVentas.Rows.Count > 0 Then - Dim dr As DataRow = DTHistorialVentas.Rows(0) - - Dim params As New List(Of ReportParameter) - params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) - params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion)) - params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono)) - params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario)) - If Imagen.Exists Then - params.Add(New ReportParameter("LogoPath", logouri)) - Else - params.Add(New ReportParameter("LogoPath", "")) - End If - - ImprimirPDF("Empresas/Grales/Formatos/ClienteHistorial.rdlc", DTHistorialVentas, params, "Reporte de Historial", "Excel") - Else - Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia) - End If - - End Sub - - - Protected Sub BtnPDFHistorial_Click(sender As Object, e As EventArgs) - Dim retorno As Byte() = ImprimirReporteHistorial() - If retorno IsNot Nothing Then - ImprimirbytesPDF(retorno, "Reporte de Historial", Descarga:=True) - End If - End Sub - - Protected Function ImprimirReporteHistorial() As Byte() - Dim retorno As Byte() = Nothing - 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 ObjClientes As New ClsClientes() - - 'OBTENEMOS LOS DATOS - 'Dim DTHistorial As DataTable - 'If ObjClientes.GetHistorialVentas(UsuarioActual.CveCliente, TopRegistros) Then - ' DTHistorial = ObjClientes.DtResultados - 'Else - ' DTHistorial = Nothing - 'End If - - If DTHistorialVentas.Rows.Count > 0 Then - Dim dr As DataRow = DTHistorialVentas.Rows(0) - - Dim params As New List(Of ReportParameter) - params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) - params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion)) - params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono)) - params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario)) - If Imagen.Exists Then - params.Add(New ReportParameter("LogoPath", logouri)) - Else - params.Add(New ReportParameter("LogoPath", "")) - End If - - retorno = StreamPDF("Empresas/Grales/Formatos/ClienteHistorial.rdlc", DTHistorialVentas, params, "Reporte de Historial") - Else - Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia) - End If - ObjClientes.Dispose() - - Return retorno - End Function - - -#End Region - -#Region "C O B R A N Z A" - Public Sub Visitas_Click(sender As Object, e As EventArgs) - RegistraScript(String.Format("$('#{0}').modal();", "DivVisitas")) - End Sub - -#End Region - -#Region "Usuarios" - Protected Sub GvUsuarios_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvUsuarios.RowDeleting - Dim CveUsuario As Integer = GvUsuarios.Rows(e.RowIndex).DataKey("CveUsuario").ToEntero - Dim ObjUsuarios As New ClsSisUsuarios - If ObjUsuarios.DeleteClienteUsuario(CveUsuario, CveCliente) Then - Alert("El Usuario se eliminó correctamente", TipoMensaje.MsgInformacion) - End If - ObjUsuarios.Dispose() - CargaGlobal() - CargaUsuarios() - UpDispositivos.Update() - End Sub - - Public Sub CargaGlobal() - Dim ObjUsuarios As New ClsSisUsuarios - If ObjUsuarios.GetUsuariosEmpresas(-1) Then - Application("GlobalDTUsuarios") = ObjUsuarios.DtResultados - End If - ObjUsuarios.Dispose() - End Sub - - Protected Sub GvUsuarios_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvUsuarios.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - e.Row.FCLinkButton("imgE").Attributes.Add("onclick", $"javascript:AbrirVentana('/Sistemas/PopUpAddUsuario.aspx?CveUsuario={e.Row.DBCampo("CveUsuario").ToString}&CveCliente={CveCliente}', 801, 701);") - If UsuarioActual.Empresa.CvePlataforma = 1 Then - e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center - e.Row.Cells(5).Visible = False - End If - End If - If e.Row.RowType = DataControlRowType.Header Then - If UsuarioActual.Empresa.CvePlataforma = 1 Then - e.Row.Cells(5).Visible = False - End If - End If - End Sub -#End Region - - -#Region "C U E N T A S - B A N C A R I A S" - - Private Sub CargaCuentasBancarias() - Dim ObjCuentasBancos As New ClsGenerales - ViewState("OrdenCuentasBancos") = "" - DTCuentasBancos = New DataTable - TempDTCuentasBancos = New DataTable - - If ObjCuentasBancos.GetCuentasDepositos(CveCliente:=CveCliente) Then - DTCuentasBancos.Merge(ObjCuentasBancos.DtResultados) - Else - Alert("No se pudieron cargar las cuentas bancarias. Por favor intente nuevamente.", TipoMensaje.MsgAdvertencia) - End If - - If CveCliente < 0 Then - TempDTCuentasBancos = DTCuentasBancos.Clone - - End If - - ObjCuentasBancos.Dispose() - CargaPSGridCuentasBancos() - - RecargaGlobalCuentasBancarias() - CargaMonedas() - End Sub - Protected Sub LbAgregarCuentaBanco_Click(sender As Object, e As EventArgs) - Dim EsBancomer = False - - If TxtNombreBanco.Text.ToUpper.Contains("BBVA") Or TxtNombreBanco.Text.ToUpper.Contains("BANCOMER") Or (TxtCLABE.Text.Length = 18 AndAlso TxtCLABE.Text.Substring(0, 3) = "012") Then - EsBancomer = True - End If - - - If TxtNumeroCuenta2.Text.Trim.Length = 0 AndAlso TxtCLABE.Text.Trim.Length = 0 AndAlso TxtSWIFT.Text.Trim.Length = 0 AndAlso TxtConvenioCIE.Text.Trim.Length = 0 Then - Alert("Debe especificar al menos un numero de cuenta.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'SI CLABE TIENE ALGO DEBE TENER UNA LOGITUD EXACTA DE 18 - If TxtCLABE.Text.Trim.Length <> 0 AndAlso TxtCLABE.Text.Trim.Length <> 18 Then - Alert("La CLABE debe tener una longitud de 18 dígitos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'RESTRICCIONES - GLUYAS - If UsuarioActual.CveEmpresa = 66 Then - - 'CLABE SIEMPRE OBLIGATORIA SI NO ES BANCOMER - If TxtCLABE.Text.Trim.Length <> 18 And TxtCLABE.Text.Trim.Length = 0 And Not EsBancomer And TxtSWIFT.Text.Trim.Length = 0 Then - Alert("La CLABE es obligatoria y debe tener una longitud de 18 dígitos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'SI CUENTA TIENE ALGO Y BANCO BANCOMER DEBE TENER UNA LOGITUD EXACTA DE 10 - If TxtNumeroCuenta2.Text.Trim.Length <> 0 AndAlso TxtNumeroCuenta2.Text.Trim.Length <> 10 AndAlso EsBancomer Then - Alert("El número de cuenta debe tener una longitud de 10 dígitos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'SI CIE TIENE ALGO REFERENCIA OBLIGATORIA - If TxtConvenioCIE2.Text.Trim.Length <> 0 And TxtReferencia2.Text.Trim.Length < 3 Then - Alert("Cuando se ingresa Convenio CIE se debe especificar una referencia. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - 'CUANDO SEA "BBVA" O "BANCOMER" DEBE TENER "CIE" O "CUENTA" - If EsBancomer AndAlso Not (TxtNumeroCuenta2.Text.Trim.Length = 10 Or TxtConvenioCIE2.Text.Trim.Length <> 0) Then - Alert("Para cuentas BBVA BANCOMER es obligatorio el Número de Cuenta o CIE.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Else - - 'SI CIE TIENE ALGO DEBE TENER UNA LOGITUD MINIMA DE 5 - If TxtConvenioCIE2.Text.Trim.Length <> 0 And TxtConvenioCIE2.Text.Trim.Length < 5 Then - Alert("El Convenio CIE debe tener una longitud de al menos 5 dígitos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - End If - Dim Estatus As Boolean - If ChkEstatus2.Checked = True Then Estatus = True Else Estatus = False - - AgregarCuentaBanco(TxtNombreBanco.Text.Trim, TxtNumeroSucursal.Text.Trim, TxtCLABE.Text.Trim, TxtSWIFT.Text.Trim, TxtPlaza.Text.Trim, TxtNumeroCuenta2.Text.Trim, TxtConvenioCIE2.Text.Trim, TxtReferencia2.Text.Trim, "", DdlMoneda.SelectedValue.ToEntero, DdlMoneda.SelectedItem.Text, Estatus) - End Sub - Private Sub AgregarCuentaBanco(NombreBanco As String, NumeroSucursal As String, CLABE As String, SWIFT As String, Plaza As String, NumeroCuenta As String, ConvenioCIE As String, Referencia As String, RefCrediProveedor As String, CveMoneda As Integer, Moneda As String, Estatus As Boolean) - Dim ObjCuentasBancos As New ClsGenerales - If Modalidad = "A" Then - - If CveCliente > 0 Then - - If ObjCuentasBancos.AddCuentasDepositos(NombreBanco, Plaza, NumeroSucursal, NumeroCuenta, CLABE, ConvenioCIE, SWIFT, Referencia, RefCrediProveedor, UsuarioActual.CveUsuario, CveMoneda, CveCliente:=CveCliente) Then - DTCuentasBancos.Clear() - DTCuentasBancos.Merge(ObjCuentasBancos.DtResultados.FiltraParametros(String.Format("CveCliente = {0}", CveCliente))) - Alert("Cuenta Bancaria agregada con éxito.", TipoMensaje.MsgInformacion) - RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddCuentasBancarias")) - Else - Alert("Error al registrar la cuenta bancaria. Por favor intente nuevamente", TipoMensaje.MsgError) - End If - - Else - Dim Row As DataRow - Row = TempDTCuentasBancos.NewRow - - Row("BancoNombre") = NombreBanco - Row("Sucursal") = NumeroSucursal - Row("CLABE") = CLABE - Row("SWIFT") = SWIFT - Row("Plaza") = Plaza - Row("Cuenta") = NumeroCuenta - Row("CIE") = ConvenioCIE - Row("Referencia") = Referencia - Row("RefCrediProveedor") = RefCrediProveedor - Row("CveMoneda") = CveMoneda - Row("Moneda") = Moneda - Row("EstatusPagoElectronico") = 0 - Row("Estatus") = "True" - TempDTCuentasBancos.Rows.Add(Row) - Alert("Cuenta Bancaria agregada con éxito.", TipoMensaje.MsgInformacion) - RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddCuentasBancarias")) - - End If - - Else - - - If CveCliente > 0 Then - - If ObjCuentasBancos.UpdateCuentasDepositos(GvBancosCuentas.DataKeys(CveCuentaBancaria)("CveCuentaDeposito").ToString.ToEntero, NombreBanco, Plaza, NumeroSucursal, NumeroCuenta, CLABE, ConvenioCIE, SWIFT, Referencia, "", False, Estatus, CveMoneda) Then - DTCuentasBancos.Clear() - DTCuentasBancos.Merge(ObjCuentasBancos.DtResultados.FiltraParametros(String.Format("CveCliente = {0}", CveCliente))) - Alert("Cuenta actualizada con éxito.", TipoMensaje.MsgInformacion) - RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddCuentasBancarias")) - Else - Alert("Error al actualizar la cuenta bancaria. Por favor intente nuevamente.", TipoMensaje.MsgError) - End If - - Else - - Dim index = CveCuentaBancaria - Dim Row As DataRow = TempDTCuentasBancos.Rows(index) - Row("BancoNombre") = NombreBanco - Row("Sucursal") = NumeroSucursal - Row("CLABE") = CLABE - Row("SWIFT") = SWIFT - Row("Plaza") = Plaza - Row("Cuenta") = NumeroCuenta - Row("CIE") = ConvenioCIE - Row("Referencia") = Referencia - Row("CveMoneda") = CveMoneda - Row("Moneda") = Moneda - Row("Estatus") = Estatus - TempDTCuentasBancos.AcceptChanges() - Alert("Cuenta actualizada con éxito.", TipoMensaje.MsgInformacion) - RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddCuentasBancarias")) - End If - - End If - ObjCuentasBancos.Dispose() - LimpiaCuentasBancarias() - CargaPSGridCuentasBancos() - RecargaGlobalCuentasBancarias() - End Sub - Private Sub LimpiaCuentasBancarias() - TxtNombreBanco.Text = "" - TxtNumeroSucursal.Text = "" - TxtCLABE.Text = "" - TxtSWIFT.Text = "" - TxtPlaza.Text = "" - TxtNumeroCuenta2.Text = "" - TxtConvenioCIE2.Text = "" - TxtReferencia2.Text = "" - End Sub - -#Region "GRIDVIEW - CUENTAS BANCARIAS" - Protected Sub GvBancosCuentas_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvBancosCuentas.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - If CveCliente < 0 Then - For index = 1 To TempDTCuentasBancos.Rows.Count - TempDTCuentasBancos.Rows(index - 1)("CveCuentaDeposito") = index - Next - TempDTCuentasBancos.AcceptChanges() - End If - - - If e.Row.DBCampo("Estatus") = "True" Then - e.Row.FCLabel("LlbEstatusTexto").Text = "Activo" - Else - e.Row.FCLabel("LlbEstatusTexto").Text = "Inactivo" - End If - - End If - End Sub - - - Public Sub Delete_Click(sender As Object, e As EventArgs) - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Dim ObjCuentasBancos As New ClsGenerales - - If CveCliente > 0 Then - If ObjCuentasBancos.RemoveCuentasDepositos(GvRow.DataKey("CveCuentaDeposito").ToEntero) Then - DTCuentasBancos.Clear() - DTCuentasBancos.Merge(ObjCuentasBancos.DtResultados.FiltraParametros(String.Format("CveCliente = {0}", CveCliente))) - - Alert("Cuenta Bancaria borrada con éxito.", TipoMensaje.MsgInformacion) - Else - Alert("No se pudo borrar la Cuenta Bancaria. Por favor intente nuevamente.", TipoMensaje.MsgError) - End If - Else - Dim index = GvRow.RowIndex - TempDTCuentasBancos.Rows.RemoveAt(index) - Alert("Cuenta Bancaria borrada con éxito.", TipoMensaje.MsgInformacion) - End If - - 'If ObjCuentasBancos.GetCuentasDepositos Then - ' GlobalDTProveedoresCuentas(CveCliente, True) = ObjCuentasBancos.DtResultados - 'End If - - CargaPSGridCuentasBancos() - ObjCuentasBancos.Dispose() - RecargaGlobalCuentasBancarias() - End Sub - Private Sub RecargaGlobalCuentasBancarias(Optional ByVal CveCuenta As Integer = -1) - If CveCliente > 0 Then - Dim ObjCuentasBancos As New ClsGenerales - - If ObjCuentasBancos.GetCuentasDepositos() Then - GlobalDTProveedoresCuentas(-1, True) = ObjCuentasBancos.DtResultados - End If - ObjCuentasBancos.Dispose() - End If - End Sub - -#End Region - - Private Sub CargaPSGridCuentasBancos() - If CveCliente > 0 Then - GvBancosCuentas.DataSource = DTCuentasBancos - Else - GvBancosCuentas.DataSource = TempDTCuentasBancos - End If - - GvBancosCuentas.DataBind() - UpCuentasBancos.Update() - End Sub - - - Private Sub CargaMonedas() - DdlMoneda.DataSource = GlobalDTMonedas - DdlMoneda.DataBind() - DdlMoneda.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - - - - - Private Sub LnkCuentasBancarias_Click(sender As Object, e As EventArgs) Handles LnkCuentasBancarias.Click - Modalidad = "A" - TxtNombreBanco.Text = "" - LbAgregarCuentaBanco.Text = "Agregar" - TxtNumeroSucursal.Text = "" - TxtNumeroCuenta2.Text = "" - TxtCLABE.Text = "" - TxtSWIFT.Text = "" - TxtPlaza.Text = "" - TxtConvenioCIE2.Text = "" - TxtReferencia2.Text = "" - DdlMoneda.SelectedIndex = 0 - ChkEstatus2.Checked = True - divestatus.Visible = False - UpAddBancos.Update() - RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddCuentasBancarias")) - End Sub - - Public Sub Edit_Click2(sender As Object, e As EventArgs) - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - TxtNombreBanco.Text = GvRow.DataKey("BancoNombre") - Modalidad = "U" - LbAgregarCuentaBanco.Text = "Actualizar" - CveCuentaBancaria = GvRow.RowIndex - TxtNumeroSucursal.Text = GvRow.DataKey("Sucursal") - TxtNumeroCuenta2.Text = GvRow.DataKey("Cuenta") - TxtCLABE.Text = GvRow.DataKey("CLABE") - TxtSWIFT.Text = GvRow.DataKey("SWIFT") - TxtPlaza.Text = GvRow.DataKey("Plaza") - TxtConvenioCIE2.Text = GvRow.DataKey("CIE") - TxtReferencia2.Text = GvRow.DataKey("Referencia") - DdlMoneda.SelectedValueExist(GvRow.DataKey("CveMoneda")) - ChkEstatus2.Checked = CBool(GvRow.DataKey("Estatus")) - divestatus.Visible = True - UpAddBancos.Update() - RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddCuentasBancarias")) - End Sub -#End Region - -#Region "C L I E N T E S P A G O S R E A L I Z A D O S I M P R I M I R P D F/Excel" - Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkPagosClientesBancosExcel.Click - GenerarPDF("Excel") - End Sub - Private Sub LinkPDF_Click(sender As Object, e As EventArgs) Handles LnkPagosClientesBancosPDF.Click - GenerarPDF() - End Sub - Private Sub GenerarPDF(Optional Formato As String = "PDF") - Dim params As New List(Of ReportParameter) - - 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) - params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) - params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) - params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) - - If Imagen.Exists Then - params.Add(New ReportParameter("LogoPath", logouri)) - Else - params.Add(New ReportParameter("LogoPath", "")) - End If - ImprimirPDF("Empresas\Grales\Formatos\RepClientesPagosBancos.rdlc", DTCobrosRealizados, params, "RepClientesPagosBancos_" & Now.ToString("yyyyMMddhhmmss"), Formato:=Formato) - - + End Sub -#End Region + Protected Sub BtnCobranzaSMS_Click(sender As Object, e As EventArgs) + Dim Telefono = CobranzaTelefono + If Telefono.Length <> 10 Then + Alert("El telefono de cobranza no tiene el formato correcto y es necesario.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If -#Region "VENTAS" + Dim DtCxC As DataTable + Dim FI = If(TxtFechaInicioCxP.Text = "" Or TxtFechaInicioCxP.Text = "__/__/____", "-1", TxtFechaInicioCxP.Text) + Dim FF = If(TxtFechaFinCxP.Text = "" Or TxtFechaFinCxP.Text = "__/__/____", "-1", TxtFechaFinCxP.Text) + Dim StrSaldo As String = "" - Public Function imprimirFacturaVenta(CveVenta As Integer) As Byte() - Dim ObjVentas As New ClsVentas - Dim Vta As Modelos.Factura = Nothing - - Dim TmpDTImpuestos = New DataTable - TmpDTImpuestos.Columns.Add("ImpuestoLocal", GetType(String)) - TmpDTImpuestos.Columns.Add("Importe", GetType(Double)) - TmpDTImpuestos.Columns.Add("Orden", GetType(Integer)) - - Dim TmpDTImpuestosIVAIEPS = New DataTable - TmpDTImpuestosIVAIEPS.Columns.Add("Impuesto", GetType(String)) - TmpDTImpuestosIVAIEPS.Columns.Add("tasa", GetType(String)) - TmpDTImpuestosIVAIEPS.Columns.Add("Importe", GetType(Double)) - TmpDTImpuestosIVAIEPS.Columns.Add("Orden", GetType(Integer)) - - If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then - Dim dtVentas As DataTable = ObjVentas.DtResultados - - ' se rellenan los campos de la factura - Vta = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.Factura) - - Vta.MonedaAbreviatura = dtVentas(0)("Abreviatura").ToString - 'se rellena la sucursal - 'Vta.Subproyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SucursalModel) - Vta.SubProyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SubProyectoModel) - Vta.Cliente = New Modelos.ClienteModel - Vta.Cliente.Nombre = dtVentas(0)("ClienteNombre").ToString - Vta.Cliente.Telefono = dtVentas(0)("Telefono").ToString - Vta.Cliente.Direccion = dtVentas(0)("ClienteDireccion").ToString - Vta.Cliente.CP = dtVentas(0)("CPCliente").ToString - Vta.Cliente.Ciudad = dtVentas(0)("ClienteCiudad").ToString - Vta.Cliente.Localidad = dtVentas(0)("ClienteLocalidad").ToString - Vta.Cliente.Estado = dtVentas(0)("ClienteEstado").ToString - Vta.Cliente.Pais = dtVentas(0)("ClientePais").ToString - Vta.Cliente.RFC = dtVentas(0)("ClienteRFC").ToString - Vta.Cliente.Colonia = dtVentas(0)("ColoniaCliente").ToString - Vta.AtencionA = dtVentas(0)("AtencionA").ToString - Vta.Cliente.NoExt = dtVentas(0)("ClienteNoExt").ToString - Vta.Cliente.NoInt = dtVentas(0)("ClienteNoInt").ToString - Vta.Cliente.Codigo = dtVentas(0)("ClienteCodigo").ToString - Vta.Cliente.Mail = dtVentas(0)("Mail").ToString - Vta.RefDocto = dtVentas(0)("Ref").ToString - Vta.CveVenta = dtVentas(0)("CveVenta").ToString.ToEntero - Vta.Version = dtVentas(0)("Version").ToString - - Vta.NumeroContrato = dtVentas(0)("NumeroContrato").ToString - Vta.DescripcionContrato = dtVentas(0)("DescripcionContrato").ToString - Vta.NumeroDescripcionContrato = If($"{dtVentas(0)("NumeroContrato").ToString} - {dtVentas(0)("NumeroLicitacion").ToString}" = " - ", "", $"{dtVentas(0)("NumeroContrato").ToString} {If(dtVentas(0)("NumeroLicitacion").ToString = "", "", $" - Licitación: {dtVentas(0)("NumeroLicitacion").ToString}")}") - - Vta.PedidoContrato = If(dtVentas(0)("PedidoContrato").ToString = "", Vta.NumeroDescripcionContrato, $"{dtVentas(0)("PedidoContrato").ToString} {If(Vta.NumeroDescripcionContrato = "", "", $" / {Vta.NumeroDescripcionContrato}") }") - 'Vta.PedidoContrato = dtVentas(0)("PedidoContrato").ToString - - Vta.ClienteSucursal = New Modelos.SucursalModel - Vta.ClienteSucursal.Direccion = dtVentas(0)("SucClienteDireccion").ToString - Vta.ClienteSucursal.NoExt = dtVentas(0)("SucClienteNoExt").ToString - Vta.ClienteSucursal.NoInt = dtVentas(0)("SucClienteNoInt").ToString - Vta.ClienteSucursal.Colonia = dtVentas(0)("SucClienteColonia").ToString - Vta.ClienteSucursal.CP = dtVentas(0)("SucClienteCP").ToString - Vta.ClienteSucursal.Municipio = dtVentas(0)("SucClienteCiudad").ToString - Vta.ClienteSucursal.Estado = dtVentas(0)("SucClienteEstado").ToString - Vta.ClienteSucursal.Pais = dtVentas(0)("SucClientePais").ToString - Vta.ClienteSucursal.Localidad = dtVentas(0)("SucClienteLocalidad").ToString - Vta.ClienteSucursal.CorreoSucursal = dtVentas(0)("SucClienteCorreo").ToString - Vta.ClienteSucursal.TelefonoSucursal = dtVentas(0)("SucClienteTelefono").ToString - Vta.ClienteSucursal.Sucursal = dtVentas(0)("SucursalCliente").ToString - Vta.ClienteSucursal.ImprimeNombreSucursal = dtVentas(0)("ImprimeNombreSucursal").ToString - - Vta.EnviarA = New Modelos.EnviarAModel - Vta.EnviarA.CveDireccionEnvio = dtVentas(0)("CveDireccionEnvio").ToString.ToEntero - Vta.EnviarA.EnvioDireccion = dtVentas(0)("EnvioDireccion").ToString - Vta.EnviarA.EnvioColonia = dtVentas(0)("EnvioColonia").ToString - Vta.EnviarA.EnvioCiudad = dtVentas(0)("EnvioCiudad").ToString - Vta.EnviarA.EnvioEstado = dtVentas(0)("EnvioEstado").ToString - Vta.EnviarA.EnvioCP = dtVentas(0)("EnvioCP").ToString - - Vta.EnviarA.EnvioNoExt = dtVentas(0)("EnvioNoExt").ToString - Vta.EnviarA.EnvioNoInt = dtVentas(0)("EnvioNoInt").ToString - Vta.EnviarA.EnvioContacto = dtVentas(0)("EnvioContacto").ToString - 'Vta.EnviarA.EnvioPedidoContrato = dtVentas(0)("EnvioPedidoContrato").ToString - - 'INE COMPLEMENTO - If dtVentas(0)("TipoComite").ToString <> "" Then - Dim INE As New Modelos.ComplementoINE - INE.INETipoComite = dtVentas(0)("TipoComite").ToString - INE.INETipoProceso = dtVentas(0)("TipoProceso").ToString - INE.INEIdContabilidad = dtVentas(0)("IdContabilidad").ToString.ToEntero - Vta.ComplementoINE = INE - End If - - - Dim DR As DataRow = TmpDTImpuestos.NewRow() - If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("IVA").ToString.ToDouble >= 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR) - - 'solo para eclipse, que muesre un subtotal debajo de IVA - If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - - If dtVentas(0)("IEPS").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IEPS" : DR("Importe") = dtVentas(0)("IEPS").ToString.ToDouble : DR("Orden") = 80 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - - If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 100 : TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - - If ObjVentas.GetVentaDetalle(CveVenta) Then 'Obtenemos el Detalle de la Oorden de Compra - Vta.DtDetalle = ObjVentas.DtResultados - End If - - If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then - - Dim dtImpuesto As DataTable = ObjVentas.DtResultados - If dtImpuesto.Rows.Count > 0 Then - For Each Row As DataRow In dtImpuesto.Rows - Dim Orden = 80 - If Row("Importe").ToString.ToDouble <> 0 Then - DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString - DR("Importe") = Row("Importe").ToString.ToDouble - DR("Orden") = Orden - TmpDTImpuestos.Rows.Add(DR) - DR = TmpDTImpuestos.NewRow() - Orden = Orden + 1 - End If - Next - End If - Vta.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC") - - End If - - 'TmpDT DESGLOSE DE IMPUESTOS 3.3 - For Each dr1 As DataRow In Vta.DtDetalle.Rows - Dim DrIVA As DataRow = Nothing - Dim DrIEPS As DataRow = Nothing - - Try - DrIVA = TmpDTImpuestosIVAIEPS.Select("Impuesto = 'IVA'")(0) - Catch ex As Exception - DrIVA = Nothing - End Try - - If DrIVA IsNot Nothing Then - DrIVA("Importe") = DrIVA("Importe").ToString.ToDouble + dr1("ImporteIVA").ToString.ToDouble - TmpDTImpuestosIVAIEPS.AcceptChanges() - Else - Dim DR2 As DataRow = TmpDTImpuestosIVAIEPS.NewRow() - If dr1("PorcentajeIVA").ToString.ToDouble >= 0 Then - DR2("Impuesto") = "IVA" : DR2("tasa") = "16 %" : DR2("Importe") = dr1("ImporteIVA").ToString.ToDouble : DR2("Orden") = "1" - TmpDTImpuestosIVAIEPS.Rows.Add(DR2) - TmpDTImpuestosIVAIEPS.AcceptChanges() - End If - End If - - Try - DrIEPS = TmpDTImpuestosIVAIEPS.Select($"Impuesto = 'IEPS' AND tasa = '{dr1("PorcentajeIEPS").ToString.ToDouble * 100} %'")(0) - Catch ex As Exception - DrIEPS = Nothing - End Try - - If DrIEPS IsNot Nothing Then - DrIEPS("Importe") = DrIEPS("Importe").ToString.ToDouble + dr1("ImporteIEPS").ToString.ToDouble - TmpDTImpuestosIVAIEPS.AcceptChanges() - Else - Dim DR2 As DataRow = TmpDTImpuestosIVAIEPS.NewRow() - If dr1("PorcentajeIEPS").ToString.ToDouble > 0 Then - DR2("Impuesto") = "IEPS" : DR2("tasa") = String.Format("{0} {1}", dr1("PorcentajeIEPS").ToString.ToDouble * 100, "%") : DR2("Importe") = dr1("ImporteIEPS").ToString.ToDouble : DR2("Orden") = If(dr1("PorcentajeIEPS").ToString = "0.03", "2", If(dr1("PorcentajeIEPS").ToString = "0.06", "3", If(dr1("PorcentajeIEPS").ToString = "0.07", "4", If(dr1("PorcentajeIEPS").ToString = "0.09", "5", "")))) - TmpDTImpuestosIVAIEPS.Rows.Add(DR2) - TmpDTImpuestosIVAIEPS.AcceptChanges() - End If - End If - - Next - Vta.DtDesgloseImpuestos = TmpDTImpuestosIVAIEPS.FiltraParametros("", Orderby:="Orden ASC") - - If ObjVentas.GetVentasFirmas(CveVenta) Then - Vta.DtFirmas = ObjVentas.DtResultados - End If - - If UsuarioActual.CveEmpresa.Contiene(119) Then - If dtVentas(0)("TipoDocto").ToString.Contiene("Ing", "Ant", "Rem") Then - 'carga as notas de credito vinculadas - If ObjVentas.GetVentasAntNC(CveVenta, -1) Then - Vta.DtDocumentosRelacionados = ObjVentas.DtResultados - - End If - End If - - If dtVentas(0)("TipoDocto").ToString.Contiene("Egs", "Dev", "Ant") Then - If ObjVentas.GetVentasAntNC(-1, CveVenta) Then - Vta.DtDocumentosRelacionados = ObjVentas.DtResultados - End If - End If - End If - - - 'CFDI RELACIONADO - If dtVentas(0)("CveTipoRelacion").ToString.ToEntero > 0 Then - Vta.Timbre.Comprobante.TipoComprobante = If(Vta.TipoDocto.Contiene("Ing", "Ant"), "I", If(Vta.TipoDocto.Contiene("Egs", "Dev"), "E", "")) - If Vta.Timbre.Comprobante.TipoComprobante = "E" Then - If Vta.TipoDocto.Contiene("Egs") Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "01" - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" - End If - If Vta.TipoDocto.Contiene("Dev") Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" - End If - Vta.Timbre.CFDIRelacionados.UUID.Add(dtVentas(0)("FolioFiscalPadre").ToString) - End If - ' cuando es refacturacoin es cfdirelacionado, con relacion 04 - If Vta.Timbre.Comprobante.TipoComprobante = "I" AndAlso (dtVentas(0)("Total").ToString.ToDouble = dtVentas(0)("TotalPadre").ToString.ToDouble) Then - Vta.Timbre.CFDIRelacionados.TipoRelacion = "04" - Vta.Timbre.CFDIRelacionados.UUID.Add(dtVentas(0)("FolioFiscalPadre").ToString) - Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Refacturación de Ingreso" - End If - End If - - End If - ObjVentas.Dispose() - - Return PdfFactura(Vta) - End Function - -#End Region - -#Region "COMERCIO EXTERIOR" - Public Sub CargaCombosComercioExterior() - - DdlTipoOperacion.Items.Clear() - DdlTipoOperacion.DataSource = GlobalDTTipoOperacion() - DdlTipoOperacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlTipoOperacion.DataBind() - - DdlIncoterm.Items.Clear() - DdlIncoterm.DataSource = GlobalDTIncoterm() - DdlIncoterm.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlIncoterm.DataBind() - - DdlClavePedimento.Items.Clear() - DdlClavePedimento.DataSource = GlobalDTClavePedimento() - DdlClavePedimento.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlClavePedimento.DataBind() - - DdlMotivoTraslado.Items.Clear() - DdlMotivoTraslado.DataSource = GlobalDTSATMotivoTraslado() - DdlMotivoTraslado.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlMotivoTraslado.DataBind() - - CargaPais() - CargaEstado() - CargaMunicipio() - CargaColonia() - - End Sub - - - Private Sub CargaPais() - DdlPais.Items.Clear() - DdlPais.DataSource = GlobalDTPais() - DdlPais.DataBind() - DdlPais.SelectedValueExist("151") - End Sub - - Private Sub CargaEstado() - DdlEstado.Items.Clear() - If DdlPais.SelectedValue.ToEntero > 0 Then - DdlEstado.DataSource = GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString) - End If - DdlEstado.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlEstado.DataBind() - End Sub - - Private Sub CargaMunicipio() - DdlMunicipio.Items.Clear() - If DdlEstado.SelectedValue.ToEntero > 0 Then - DdlMunicipio.DataSource = GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString).FiltraParametros($"CveEstado = {DdlEstado.SelectedValue.ToEntero}")(0)("ClaveSATEstado").ToString) - End If - DdlMunicipio.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlMunicipio.DataBind() - End Sub - - Private Sub CargaColonia() - DdlColonia.Items.Clear() - If DdlMunicipio.SelectedValue.ToEntero > 0 Then - DdlColonia.DataSource = GlobalDTColonia(GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString).FiltraParametros($"CveEstado = {DdlEstado.SelectedValue.ToEntero}")(0)("ClaveSATEstado").ToString).FiltraParametros($"CveMunicipio = {DdlMunicipio.SelectedValue.ToEntero}")(0)("ClaveSATMunicipio").ToString) - End If - DdlColonia.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlColonia.DataBind() - End Sub - - Protected Sub DdlPais_SelectedIndexChanged(sender As Object, e As EventArgs) - 'si contiene MX, USA o CANADA carga ddls, si no carga txt - CargaEstado() - - If DdlPais.SelectedValue.Contiene("151", "66", "40") Then - DdlEstado.Visible = True - DdlMunicipio.Visible = True - DdlColonia.Visible = True - - TxtComExtEstado.Visible = False - TxtComExtMunicipio.Visible = False - TxtComExtColonia.Visible = False - - TxtComExtEstado.Text = "" - TxtComExtMunicipio.Text = "" - TxtComExtColonia.Text = "" - - If DdlPais.SelectedValue.Contiene("66", "40") Then - DdlMunicipio.Visible = False - DdlColonia.Visible = False - - DdlMunicipio.SelectedValue = "-1" - DdlColonia.SelectedValue = "-1" - - TxtComExtMunicipio.Visible = True - TxtComExtColonia.Visible = True - End If - - Else - 'Limpia los DDLs - CargaMunicipio() - CargaColonia() - - DdlEstado.Visible = False - DdlMunicipio.Visible = False - DdlColonia.Visible = False - - TxtComExtEstado.Visible = True - TxtComExtMunicipio.Visible = True - TxtComExtColonia.Visible = True - End If - End Sub - Protected Sub DdlEstado_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaMunicipio() - CargaColonia() - End Sub - Protected Sub DdlMunicipio_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaColonia() - End Sub - -#End Region - -#Region "D O C U M E N T A C I O N " - - Private Sub CargaDocumentacionCliente() - Dim objRH As New ClsEdocumentacion() - - If objRH.DocumentacionElectronicaGet(-1, If(CveCliente = -1, 0, CveCliente), -1, UsuarioActual.Empresa.CveEmpresa, -1, Modulo:=2) Then - DTDocumentacion = objRH.DtResultados - GvDocumentosCliente.DataSource = objRH.DtResultados - End If - objRH.Dispose() - 'If DTDocumentacion.FiltraParametros(" CveDocumentacionTipo = 7 ").Rows.Count > 0 Then - ' GvDocumentosCliente.DataSource = DTDocumentacion.FiltraParametros(" CveDocumentacionTipo = 7 ") - 'Else - ' GvDocumentosCliente.DataSource = Nothing - 'End If - GvDocumentosCliente.DataBind() - - UPGvDocumentosCliente.Update() - 'UpGvDocumentosFirma2.Update() - End Sub - Public Sub UploadModal_ClickDocumentacionFirmaContrato(sender As Object, e As EventArgs) - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - - Dim chkEstatus As CheckBox - CveDocumentacionElectronica = GvRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero - CveDocumentacion = GvRow.DataKey("CveDocumentacion").ToString.ToEntero - Documentacion = GvRow.DataKey("Documentacion") - AdjuntoDocumentacion = GvRow.DataKey("Adjunto").ToString - - chkEstatus = GvRow.FCCheckBox("chkEstatus") - - - - ObservacionDocumentacion = GvRow.FCTextBox("TxtObservaciones").Text.Trim.ToUpper - FechaLimite = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate - - AdjuntoDocumentacion = GvRow.DataKey("Adjunto") - - LtlTitulofirmaContrato.Text = "Subir " & Documentacion - - UpTituloFirma.Update() - - RegistraScript("$('#ModalUploadFirmaContratoDocumento').modal({ backdrop: 'static', keyboard: false});") - End Sub - Private Sub GuardarDocumentosClientes(Optional _CveDocumentacionExcluir As Integer = -1) - - Dim hasError As Boolean = True - Dim objDocumentos As New ClsEdocumentacion - - For Each dRow As GridViewRow In GvDocumentosCliente.Rows - - Dim _CveDocumentacion As Integer = dRow.DataKey("CveDocumentacion").ToString.ToEntero - Dim _Adjunto As String = dRow.DataKey("Adjunto") - 'Dim _Documentacion As String = dRow.DataKey("Documentacion") - Dim _CveDocumentacionElectronica As Integer = dRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero - Dim _txtObservaciones As TextBox = dRow.FCTextBox("TxtObservaciones") - Dim _TxtFechaLimite As TextBox = dRow.FCTextBox("TxtFechaLimite") - Dim _TxtFechaVigencia As TextBox = dRow.FCTextBox("TxtFechaVigencia") - Dim chkEstatus As CheckBox = dRow.FCCheckBox("chkEstatus") - Dim _estatus As Integer - - _estatus = If(dRow.FCCheckBox("chkEstatus").Checked, 1, 0) - - Dim _FechaVigencia As Date - Dim _FechaLimite As Date - - Dim DiasLimite As Integer = dRow.DataKey("DiasLimite").ToString.ToEntero - Dim AplicaDiasLimite As Boolean = If(dRow.DataKey("AplicaDiasLimite").ToString = "1", True, False) - Dim AplicaFechaVencimiento As Boolean = If(dRow.DataKey("AplicaFechaVencimiento").ToString = "1", True, False) - - If _TxtFechaVigencia.Text.Length = 10 Then - _FechaVigencia = _TxtFechaVigencia.Text.ToDate - Else - _FechaVigencia = Nothing - End If - - If Not AplicaDiasLimite Then - _FechaLimite = MinFecha - Else - _FechaLimite = _TxtFechaLimite.Text.ToDate - End If - - If Not AplicaFechaVencimiento Then - _FechaVigencia = MinFecha - End If - - - If Not _CveDocumentacionExcluir = _CveDocumentacion Then - Try - If _CveDocumentacionElectronica = -1 Then - - If objDocumentos.DocumentacionElectronicaAdd(_CveDocumentacion, -1, CveCliente, -1, _estatus, _txtObservaciones.Text.Trim, _Adjunto, UsuarioActual.CveUsuario, _FechaLimite, _FechaVigencia) > 0 Then - Else - hasError = True - Exit For - End If - - Else - If objDocumentos.DocumentacionElectronicaUpdate(_CveDocumentacionElectronica, _CveDocumentacion, -1, CveCliente, -1, _estatus, _txtObservaciones.Text.Trim, _Adjunto, UsuarioActual.CveUsuario, _FechaLimite, _FechaVigencia) Then - Else - hasError = True - Exit For - End If - End If - - - hasError = False - Catch ex As Exception - hasError = True - Exit For - End Try - End If - Next - - 'refrescar grid datos investigacion - CargaDocumentacionCliente() - End Sub - - Protected Sub chkEstatus_CheckedChanged(sender As Object, e As EventArgs) - GuardarDocumentosClientes() - End Sub - - Protected Sub TxtObservaciones_TextChanged(sender As Object, e As EventArgs) - GuardarDocumentosClientes() - End Sub - Protected Sub BtnModalFirmaContratoDocumentoUpload_Click(sender As Object, e As EventArgs) Handles BtnModalFirmaContratoDocumentoUpload.Click - - Dim FileExtension As String = "-1" - Dim Filesgral As List(Of Archivo) = TxtFileFirmaContrato.getfiles().Archivos - Dim Filename As String = "" - - - For Each fileItem As Archivo In Filesgral - Try - - FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") - Dim tempArray() As String - tempArray = fileItem.filename.ToString().Split("-".ToCharArray()) - - Dim rutaDestino As String = UsuarioActual.Empresa.Ruta & "\DocElectronica\Clientes\" & CveCliente & "\" & Documentacion & "." & FileExtension - Dim rutaAdjuntoAnterior As String = UsuarioActual.Empresa.Ruta & "DocElectronica\Clientes\" & CveCliente & "\" & AdjuntoDocumentacion - - If Not System.IO.Directory.Exists(UsuarioActual.Empresa.Ruta & "DocElectronica\Clientes\" & CveCliente & "\") Then - System.IO.Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "DocElectronica\Clientes\" & CveCliente & "\") - End If - - If File.Exists(rutaAdjuntoAnterior) And AdjuntoDocumentacion.Trim.Length > 0 Then - File.Delete(rutaAdjuntoAnterior) - End If - - If System.IO.File.Exists(rutaDestino) Then - System.IO.File.Delete(rutaDestino) - End If - - System.IO.File.Move(fileItem.FileUrl, rutaDestino) - - Dim objRH As New ClsEdocumentacion - - - If CveDocumentacionElectronica = -1 Then - If objRH.DocumentacionElectronicaAdd(CveDocumentacion, -1, CveCliente, -1, 1, ObservacionDocumentacion, Documentacion & "." & FileExtension, UsuarioActual.CveUsuario, FechaLimite) > 0 Then - - End If - Else - If objRH.DocumentacionElectronicaUpdate(CveDocumentacionElectronica, CveDocumentacion, -1, CveCliente, -1, 1, ObservacionDocumentacion, Documentacion & "." & FileExtension, UsuarioActual.CveUsuario, FechaLimite) Then - - End If - End If - - objRH.Dispose() - - GuardarDocumentosClientes(CveDocumentacion) - CargaDocumentacionCliente() - - - TxtFileFirmaContrato.Text = "" - UpModalFirmaContratoDocumento.Update() - - Catch ex As Exception - OnError("Error al cargar archivo", ex) - End Try - - Next - RegistraScript("$('#ModalUploadFirmaContratoDocumento').modal('hide')", "hidemodal7") - - End Sub - - Public Sub Update_ClickDocumentacionFirmaContrato(sender As Object, e As EventArgs) - - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Dim activo As Boolean = False - - Dim _CveDocumentacionElectronica As Integer = GvRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero - Dim _CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToString.ToEntero - Dim _Adjunto As String = GvRow.DataKey("Adjunto").ToString - Dim _fechaLimite As Date = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate - - Dim obserbaciones As String = DirectCast(GvRow.FindControl("TxtObservaciones"), TextBox).Text - 'Dim DDLEstatus As DropDownList = DirectCast(GvRow.FindControl("DDLEstatus"), DropDownList) - Dim chkCompleto As CheckBox = DirectCast(GvRow.FindControl("chkEstatus"), CheckBox) - - If chkCompleto.Checked Then - Estatus = 1 - Else - Estatus = 0 - End If - - Dim ObjEdoc As New ClsEdocumentacion - - If Not _CveDocumentacionElectronica = -1 Then - If ObjEdoc.DocumentacionElectronicaUpdate(_CveDocumentacionElectronica, _CveDocumentacion, -1, CveCliente, -1, 1, obserbaciones, _Adjunto, UsuarioActual.CveUsuario, _fechaLimite) Then - Alert("Documento actualizado correctamente.", TipoMensaje.MsgInformacion) - End If - Else - If ObjEdoc.DocumentacionElectronicaAdd(_CveDocumentacion, -1, CveCliente, -1, 1, obserbaciones, _Adjunto, UsuarioActual.CveUsuario, _fechaLimite) > 0 Then - Alert("Documento actualizado correctamente.", TipoMensaje.MsgInformacion) - End If - End If - - CargaDocumentacionCliente() - ObjEdoc.Dispose() - - End Sub - - - Public Sub Update_ClickDocumentacionRemove(sender As Object, e As EventArgs) - - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Dim activo As Boolean = False - - Dim _CveDocumentacionElectronica As Integer = GvRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero - Dim _CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToString.ToEntero - Dim _Adjunto As String = GvRow.DataKey("Adjunto").ToString - Dim _fechaLimite As Date = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate - Dim obserbaciones As String = DirectCast(GvRow.FindControl("TxtObservaciones"), TextBox).Text - 'Dim DDLEstatus As DropDownList = DirectCast(GvRow.FindControl("DDLEstatus"), DropDownList) - Dim chkCompleto As CheckBox = DirectCast(GvRow.FindControl("chkEstatus"), CheckBox) - - Dim UrlArchivo = UsuarioActual.Empresa.Ruta & "\DocElectronica\Clientes\" & CveCliente & "/" & _Adjunto - - If File.Exists(UrlArchivo) Then - Try - File.Delete(UrlArchivo) - Catch ex As Exception - End Try - - End If - - Dim ObjEdoc As New ClsEdocumentacion - - If Not _CveDocumentacionElectronica = -1 Then - - If ObjEdoc.DocumentacionElectronicaUpdate(_CveDocumentacionElectronica, _CveDocumentacion, -1, CveCliente, -1, 0, "", "", UsuarioActual.CveUsuario, _fechaLimite) Then - Alert("Documento Eliminado Correctamente.", TipoMensaje.MsgInformacion) - End If - - End If - - CargaDocumentacionCliente() - ObjEdoc.Dispose() - - End Sub + Dim ObjMovtos As New ClsMovimientos() + If ObjMovtos.GetCxCClienteDetalle(ViewState("CveCliente").ToString.ToEntero, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, -1) Then + DtCxC = If(DdlTipoCuentasCxC.SelectedValue = "-1", If(DdlTipoDocto.SelectedValue = "-1", ObjMovtos.DtResultados, ObjMovtos.DtResultados.FiltraParametros($"TipoDocto = '{DdlTipoDocto.SelectedValue}'")), + If(DdlTipoDocto.SelectedValue = "-1", ObjMovtos.DtResultados.FiltraParametros("Tipo = 'Act' ", "Moneda, OrdenVencimiento ,FechaVencimiento"), ObjMovtos.DtResultados.FiltraParametros($"Tipo = 'Act' AND TipoDocto = '{DdlTipoDocto.SelectedValue}'", "Moneda, OrdenVencimiento ,FechaVencimiento"))) + + Dim Pesos As Double = DtCxC.SUM("Saldo", "CveMoneda = 1 and CveVenta > 0") + Dim Dolares As Double = DtCxC.SUM("Saldo", "CveMoneda = 2 and CveVenta > 0") + If Pesos > 0 Then StrSaldo = $" $ {Pesos.FormatoNumero} pesos" + If Dolares > 0 Then StrSaldo = $"{StrSaldo} ${Dolares.FormatoNumero} dólares" + ObjMovtos.Dispose() + Else + DtCxC = Nothing + ObjMovtos.Dispose() + Exit Sub + End If + + If StrSaldo.Length > 0 Then + Dim Mensaje = "" + Select Case UsuarioActual.CveEmpresa + Case 4 + Mensaje = $"Cliente de VSH Seguridad su saldo pendiente es de $ {StrSaldo} fecha limite 25/{Now.ToString("MM/yyyy")} llamar al 6622106400 #REFERENCIA {CodigoCliente} " + End Select + + Dim ObjSMS As New ClsTecnoMovil + Dim ObjEventos As New ClsOIEventos + If ObjSMS.EnviarMensajeWS(Telefono, Mensaje) Then + If ObjEventos.AddEventoBitacora($"Estado de cuenta enviado al cliente via SMS. Telefono: {Telefono} Mensaje: {Mensaje}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=CveCliente) Then + Alert("El mensaje se envió correctamente", TipoMensaje.MsgInformacion) + Else + Alert("El mensaje se envió correctamente. Pero no se pudo guardar historial", TipoMensaje.MsgAdvertencia) + End If + End If + ObjEventos.Dispose() + CargaEventoBitacora() + UPEventoBitacora.Update() + Else + Alert("No hay saldo pendiente del cliente. Por lo cual no se envió el mensaje.", TipoMensaje.MsgInformacion) + End If + + + End Sub + +#End Region + +#Region "IMPRIMIR GVHistorial" + + + Protected Sub BtnExcelHistorial_Click(sender As Object, e As EventArgs) + Dim retorno As Byte() = Nothing + 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) + + + 'OBTENEMOS LOS DATOS + 'Dim DTHistorial As DataTable + 'If ObjClientes.GetHistorialVentas(UsuarioActual.CveCliente, TopRegistros) Then + ' DTHistorial = ObjClientes.DtResultados + 'Else + ' DTHistorial = Nothing + 'End If + + If DTHistorialVentas.Rows.Count > 0 Then + Dim dr As DataRow = DTHistorialVentas.Rows(0) + + Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion)) + params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario)) + If Imagen.Exists Then + params.Add(New ReportParameter("LogoPath", logouri)) + Else + params.Add(New ReportParameter("LogoPath", "")) + End If + + ImprimirPDF("Empresas/Grales/Formatos/ClienteHistorial.rdlc", DTHistorialVentas, params, "Reporte de Historial", "Excel") + Else + Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia) + End If + + End Sub + + + Protected Sub BtnPDFHistorial_Click(sender As Object, e As EventArgs) + Dim retorno As Byte() = ImprimirReporteHistorial() + If retorno IsNot Nothing Then + ImprimirbytesPDF(retorno, "Reporte de Historial", Descarga:=True) + End If + End Sub + + Protected Function ImprimirReporteHistorial() As Byte() + Dim retorno As Byte() = Nothing + 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 ObjClientes As New ClsClientes() + + 'OBTENEMOS LOS DATOS + 'Dim DTHistorial As DataTable + 'If ObjClientes.GetHistorialVentas(UsuarioActual.CveCliente, TopRegistros) Then + ' DTHistorial = ObjClientes.DtResultados + 'Else + ' DTHistorial = Nothing + 'End If + + If DTHistorialVentas.Rows.Count > 0 Then + Dim dr As DataRow = DTHistorialVentas.Rows(0) + + Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("DireccionEmpresa", UsuarioActual.Empresa.Direccion)) + params.Add(New ReportParameter("TelefonoEmpresa", UsuarioActual.Empresa.Telefono)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario)) + If Imagen.Exists Then + params.Add(New ReportParameter("LogoPath", logouri)) + Else + params.Add(New ReportParameter("LogoPath", "")) + End If + + retorno = StreamPDF("Empresas/Grales/Formatos/ClienteHistorial.rdlc", DTHistorialVentas, params, "Reporte de Historial") + Else + Alert("Ocurrió un error.", TipoMensaje.MsgAdvertencia) + End If + ObjClientes.Dispose() + + Return retorno + End Function + + +#End Region + +#Region "C O B R A N Z A" + Public Sub Visitas_Click(sender As Object, e As EventArgs) + RegistraScript(String.Format("$('#{0}').modal();", "DivVisitas")) + End Sub + +#End Region + +#Region "Usuarios" + Protected Sub GvUsuarios_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvUsuarios.RowDeleting + Dim CveUsuario As Integer = GvUsuarios.Rows(e.RowIndex).DataKey("CveUsuario").ToEntero + Dim ObjUsuarios As New ClsSisUsuarios + If ObjUsuarios.DeleteClienteUsuario(CveUsuario, CveCliente) Then + Alert("El Usuario se eliminó correctamente", TipoMensaje.MsgInformacion) + End If + ObjUsuarios.Dispose() + CargaGlobal() + CargaUsuarios() + UpDispositivos.Update() + End Sub + + Public Sub CargaGlobal() + Dim ObjUsuarios As New ClsSisUsuarios + If ObjUsuarios.GetUsuariosEmpresas(-1) Then + Application("GlobalDTUsuarios") = ObjUsuarios.DtResultados + End If + ObjUsuarios.Dispose() + End Sub + + Protected Sub GvUsuarios_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvUsuarios.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + e.Row.FCLinkButton("imgE").Attributes.Add("onclick", $"javascript:AbrirVentana('/Sistemas/PopUpAddUsuario.aspx?CveUsuario={e.Row.DBCampo("CveUsuario").ToString}&CveCliente={CveCliente}', 801, 701);") + If UsuarioActual.Empresa.CvePlataforma = 1 Then + e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center + e.Row.Cells(5).Visible = False + End If + End If + If e.Row.RowType = DataControlRowType.Header Then + If UsuarioActual.Empresa.CvePlataforma = 1 Then + e.Row.Cells(5).Visible = False + End If + End If + End Sub +#End Region + + +#Region "C U E N T A S - B A N C A R I A S" + + Private Sub CargaCuentasBancarias() + Dim ObjCuentasBancos As New ClsGenerales + ViewState("OrdenCuentasBancos") = "" + DTCuentasBancos = New DataTable + TempDTCuentasBancos = New DataTable + + If ObjCuentasBancos.GetCuentasDepositos(CveCliente:=CveCliente) Then + DTCuentasBancos.Merge(ObjCuentasBancos.DtResultados) + Else + Alert("No se pudieron cargar las cuentas bancarias. Por favor intente nuevamente.", TipoMensaje.MsgAdvertencia) + End If + + If CveCliente < 0 Then + TempDTCuentasBancos = DTCuentasBancos.Clone + + End If + + ObjCuentasBancos.Dispose() + CargaPSGridCuentasBancos() + + RecargaGlobalCuentasBancarias() + CargaMonedas() + End Sub + Protected Sub LbAgregarCuentaBanco_Click(sender As Object, e As EventArgs) + Dim EsBancomer = False + + If TxtNombreBanco.Text.ToUpper.Contains("BBVA") Or TxtNombreBanco.Text.ToUpper.Contains("BANCOMER") Or (TxtCLABE.Text.Length = 18 AndAlso TxtCLABE.Text.Substring(0, 3) = "012") Then + EsBancomer = True + End If + + + If TxtNumeroCuenta2.Text.Trim.Length = 0 AndAlso TxtCLABE.Text.Trim.Length = 0 AndAlso TxtSWIFT.Text.Trim.Length = 0 AndAlso TxtConvenioCIE.Text.Trim.Length = 0 Then + Alert("Debe especificar al menos un numero de cuenta.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'SI CLABE TIENE ALGO DEBE TENER UNA LOGITUD EXACTA DE 18 + If TxtCLABE.Text.Trim.Length <> 0 AndAlso TxtCLABE.Text.Trim.Length <> 18 Then + Alert("La CLABE debe tener una longitud de 18 dígitos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'RESTRICCIONES - GLUYAS + If UsuarioActual.CveEmpresa = 66 Then + + 'CLABE SIEMPRE OBLIGATORIA SI NO ES BANCOMER + If TxtCLABE.Text.Trim.Length <> 18 And TxtCLABE.Text.Trim.Length = 0 And Not EsBancomer And TxtSWIFT.Text.Trim.Length = 0 Then + Alert("La CLABE es obligatoria y debe tener una longitud de 18 dígitos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'SI CUENTA TIENE ALGO Y BANCO BANCOMER DEBE TENER UNA LOGITUD EXACTA DE 10 + If TxtNumeroCuenta2.Text.Trim.Length <> 0 AndAlso TxtNumeroCuenta2.Text.Trim.Length <> 10 AndAlso EsBancomer Then + Alert("El número de cuenta debe tener una longitud de 10 dígitos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'SI CIE TIENE ALGO REFERENCIA OBLIGATORIA + If TxtConvenioCIE2.Text.Trim.Length <> 0 And TxtReferencia2.Text.Trim.Length < 3 Then + Alert("Cuando se ingresa Convenio CIE se debe especificar una referencia. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + 'CUANDO SEA "BBVA" O "BANCOMER" DEBE TENER "CIE" O "CUENTA" + If EsBancomer AndAlso Not (TxtNumeroCuenta2.Text.Trim.Length = 10 Or TxtConvenioCIE2.Text.Trim.Length <> 0) Then + Alert("Para cuentas BBVA BANCOMER es obligatorio el Número de Cuenta o CIE.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Else + + 'SI CIE TIENE ALGO DEBE TENER UNA LOGITUD MINIMA DE 5 + If TxtConvenioCIE2.Text.Trim.Length <> 0 And TxtConvenioCIE2.Text.Trim.Length < 5 Then + Alert("El Convenio CIE debe tener una longitud de al menos 5 dígitos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + End If + Dim Estatus As Boolean + If ChkEstatus2.Checked = True Then Estatus = True Else Estatus = False + + AgregarCuentaBanco(TxtNombreBanco.Text.Trim, TxtNumeroSucursal.Text.Trim, TxtCLABE.Text.Trim, TxtSWIFT.Text.Trim, TxtPlaza.Text.Trim, TxtNumeroCuenta2.Text.Trim, TxtConvenioCIE2.Text.Trim, TxtReferencia2.Text.Trim, "", DdlMoneda.SelectedValue.ToEntero, DdlMoneda.SelectedItem.Text, Estatus) + End Sub + Private Sub AgregarCuentaBanco(NombreBanco As String, NumeroSucursal As String, CLABE As String, SWIFT As String, Plaza As String, NumeroCuenta As String, ConvenioCIE As String, Referencia As String, RefCrediProveedor As String, CveMoneda As Integer, Moneda As String, Estatus As Boolean) + Dim ObjCuentasBancos As New ClsGenerales + If Modalidad = "A" Then + + If CveCliente > 0 Then + + If ObjCuentasBancos.AddCuentasDepositos(NombreBanco, Plaza, NumeroSucursal, NumeroCuenta, CLABE, ConvenioCIE, SWIFT, Referencia, RefCrediProveedor, UsuarioActual.CveUsuario, CveMoneda, CveCliente:=CveCliente) Then + DTCuentasBancos.Clear() + DTCuentasBancos.Merge(ObjCuentasBancos.DtResultados.FiltraParametros(String.Format("CveCliente = {0}", CveCliente))) + Alert("Cuenta Bancaria agregada con éxito.", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddCuentasBancarias")) + Else + Alert("Error al registrar la cuenta bancaria. Por favor intente nuevamente", TipoMensaje.MsgError) + End If + + Else + Dim Row As DataRow + Row = TempDTCuentasBancos.NewRow + + Row("BancoNombre") = NombreBanco + Row("Sucursal") = NumeroSucursal + Row("CLABE") = CLABE + Row("SWIFT") = SWIFT + Row("Plaza") = Plaza + Row("Cuenta") = NumeroCuenta + Row("CIE") = ConvenioCIE + Row("Referencia") = Referencia + Row("RefCrediProveedor") = RefCrediProveedor + Row("CveMoneda") = CveMoneda + Row("Moneda") = Moneda + Row("EstatusPagoElectronico") = 0 + Row("Estatus") = "True" + TempDTCuentasBancos.Rows.Add(Row) + Alert("Cuenta Bancaria agregada con éxito.", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddCuentasBancarias")) + + End If + + Else + + + If CveCliente > 0 Then + + If ObjCuentasBancos.UpdateCuentasDepositos(GvBancosCuentas.DataKeys(CveCuentaBancaria)("CveCuentaDeposito").ToString.ToEntero, NombreBanco, Plaza, NumeroSucursal, NumeroCuenta, CLABE, ConvenioCIE, SWIFT, Referencia, "", False, Estatus, CveMoneda) Then + DTCuentasBancos.Clear() + DTCuentasBancos.Merge(ObjCuentasBancos.DtResultados.FiltraParametros(String.Format("CveCliente = {0}", CveCliente))) + Alert("Cuenta actualizada con éxito.", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddCuentasBancarias")) + Else + Alert("Error al actualizar la cuenta bancaria. Por favor intente nuevamente.", TipoMensaje.MsgError) + End If + + Else + + Dim index = CveCuentaBancaria + Dim Row As DataRow = TempDTCuentasBancos.Rows(index) + Row("BancoNombre") = NombreBanco + Row("Sucursal") = NumeroSucursal + Row("CLABE") = CLABE + Row("SWIFT") = SWIFT + Row("Plaza") = Plaza + Row("Cuenta") = NumeroCuenta + Row("CIE") = ConvenioCIE + Row("Referencia") = Referencia + Row("CveMoneda") = CveMoneda + Row("Moneda") = Moneda + Row("Estatus") = Estatus + TempDTCuentasBancos.AcceptChanges() + Alert("Cuenta actualizada con éxito.", TipoMensaje.MsgInformacion) + RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAddCuentasBancarias")) + End If + + End If + ObjCuentasBancos.Dispose() + LimpiaCuentasBancarias() + CargaPSGridCuentasBancos() + RecargaGlobalCuentasBancarias() + End Sub + Private Sub LimpiaCuentasBancarias() + TxtNombreBanco.Text = "" + TxtNumeroSucursal.Text = "" + TxtCLABE.Text = "" + TxtSWIFT.Text = "" + TxtPlaza.Text = "" + TxtNumeroCuenta2.Text = "" + TxtConvenioCIE2.Text = "" + TxtReferencia2.Text = "" + End Sub + +#Region "GRIDVIEW - CUENTAS BANCARIAS" + Protected Sub GvBancosCuentas_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvBancosCuentas.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If CveCliente < 0 Then + For index = 1 To TempDTCuentasBancos.Rows.Count + TempDTCuentasBancos.Rows(index - 1)("CveCuentaDeposito") = index + Next + TempDTCuentasBancos.AcceptChanges() + End If + + + If e.Row.DBCampo("Estatus") = "True" Then + e.Row.FCLabel("LlbEstatusTexto").Text = "Activo" + Else + e.Row.FCLabel("LlbEstatusTexto").Text = "Inactivo" + End If + + End If + End Sub + + + Public Sub Delete_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim ObjCuentasBancos As New ClsGenerales + + If CveCliente > 0 Then + If ObjCuentasBancos.RemoveCuentasDepositos(GvRow.DataKey("CveCuentaDeposito").ToEntero) Then + DTCuentasBancos.Clear() + DTCuentasBancos.Merge(ObjCuentasBancos.DtResultados.FiltraParametros(String.Format("CveCliente = {0}", CveCliente))) + + Alert("Cuenta Bancaria borrada con éxito.", TipoMensaje.MsgInformacion) + Else + Alert("No se pudo borrar la Cuenta Bancaria. Por favor intente nuevamente.", TipoMensaje.MsgError) + End If + Else + Dim index = GvRow.RowIndex + TempDTCuentasBancos.Rows.RemoveAt(index) + Alert("Cuenta Bancaria borrada con éxito.", TipoMensaje.MsgInformacion) + End If + + 'If ObjCuentasBancos.GetCuentasDepositos Then + ' GlobalDTProveedoresCuentas(CveCliente, True) = ObjCuentasBancos.DtResultados + 'End If + + CargaPSGridCuentasBancos() + ObjCuentasBancos.Dispose() + RecargaGlobalCuentasBancarias() + End Sub + Private Sub RecargaGlobalCuentasBancarias(Optional ByVal CveCuenta As Integer = -1) + If CveCliente > 0 Then + Dim ObjCuentasBancos As New ClsGenerales + + If ObjCuentasBancos.GetCuentasDepositos() Then + GlobalDTProveedoresCuentas(-1, True) = ObjCuentasBancos.DtResultados + End If + ObjCuentasBancos.Dispose() + End If + End Sub + +#End Region + + Private Sub CargaPSGridCuentasBancos() + If CveCliente > 0 Then + GvBancosCuentas.DataSource = DTCuentasBancos + Else + GvBancosCuentas.DataSource = TempDTCuentasBancos + End If + + GvBancosCuentas.DataBind() + UpCuentasBancos.Update() + End Sub + + + Private Sub CargaMonedas() + DdlMoneda.DataSource = GlobalDTMonedas + DdlMoneda.DataBind() + DdlMoneda.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + + + + + Private Sub LnkCuentasBancarias_Click(sender As Object, e As EventArgs) Handles LnkCuentasBancarias.Click + Modalidad = "A" + TxtNombreBanco.Text = "" + LbAgregarCuentaBanco.Text = "Agregar" + TxtNumeroSucursal.Text = "" + TxtNumeroCuenta2.Text = "" + TxtCLABE.Text = "" + TxtSWIFT.Text = "" + TxtPlaza.Text = "" + TxtConvenioCIE2.Text = "" + TxtReferencia2.Text = "" + DdlMoneda.SelectedIndex = 0 + ChkEstatus2.Checked = True + divestatus.Visible = False + UpAddBancos.Update() + RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddCuentasBancarias")) + End Sub + + Public Sub Edit_Click2(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + TxtNombreBanco.Text = GvRow.DataKey("BancoNombre") + Modalidad = "U" + LbAgregarCuentaBanco.Text = "Actualizar" + CveCuentaBancaria = GvRow.RowIndex + TxtNumeroSucursal.Text = GvRow.DataKey("Sucursal") + TxtNumeroCuenta2.Text = GvRow.DataKey("Cuenta") + TxtCLABE.Text = GvRow.DataKey("CLABE") + TxtSWIFT.Text = GvRow.DataKey("SWIFT") + TxtPlaza.Text = GvRow.DataKey("Plaza") + TxtConvenioCIE2.Text = GvRow.DataKey("CIE") + TxtReferencia2.Text = GvRow.DataKey("Referencia") + DdlMoneda.SelectedValueExist(GvRow.DataKey("CveMoneda")) + ChkEstatus2.Checked = CBool(GvRow.DataKey("Estatus")) + divestatus.Visible = True + UpAddBancos.Update() + RegistraScript(String.Format("$('#{0}').modal('show');", "DivAddCuentasBancarias")) + End Sub +#End Region + +#Region "C L I E N T E S P A G O S R E A L I Z A D O S I M P R I M I R P D F/Excel" + Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkPagosClientesBancosExcel.Click + GenerarPDF("Excel") + End Sub + Private Sub LinkPDF_Click(sender As Object, e As EventArgs) Handles LnkPagosClientesBancosPDF.Click + GenerarPDF() + End Sub + Private Sub GenerarPDF(Optional Formato As String = "PDF") + Dim params As New List(Of ReportParameter) + + 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) + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("FechaImpresion", Now.ToDateTime.ToShortDateString)) + + If Imagen.Exists Then + params.Add(New ReportParameter("LogoPath", logouri)) + Else + params.Add(New ReportParameter("LogoPath", "")) + End If + ImprimirPDF("Empresas\Grales\Formatos\RepClientesPagosBancos.rdlc", DTCobrosRealizados, params, "RepClientesPagosBancos_" & Now.ToString("yyyyMMddhhmmss"), Formato:=Formato) + + + End Sub +#End Region + +#Region "VENTAS" + + Public Function imprimirFacturaVenta(CveVenta As Integer) As Byte() + Dim ObjVentas As New ClsVentas + Dim Vta As Modelos.Factura = Nothing + + Dim TmpDTImpuestos = New DataTable + TmpDTImpuestos.Columns.Add("ImpuestoLocal", GetType(String)) + TmpDTImpuestos.Columns.Add("Importe", GetType(Double)) + TmpDTImpuestos.Columns.Add("Orden", GetType(Integer)) + + Dim TmpDTImpuestosIVAIEPS = New DataTable + TmpDTImpuestosIVAIEPS.Columns.Add("Impuesto", GetType(String)) + TmpDTImpuestosIVAIEPS.Columns.Add("tasa", GetType(String)) + TmpDTImpuestosIVAIEPS.Columns.Add("Importe", GetType(Double)) + TmpDTImpuestosIVAIEPS.Columns.Add("Orden", GetType(Integer)) + + If ObjVentas.GetVenta(CveVenta, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then + Dim dtVentas As DataTable = ObjVentas.DtResultados + + ' se rellenan los campos de la factura + Vta = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.Factura) + + Vta.MonedaAbreviatura = dtVentas(0)("Abreviatura").ToString + 'se rellena la sucursal + 'Vta.Subproyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SucursalModel) + Vta.SubProyecto = ObjVentas.DtResultados.Rows(0).DataRowToObject(Of Modelos.SubProyectoModel) + Vta.Cliente = New Modelos.ClienteModel + Vta.Cliente.Nombre = dtVentas(0)("ClienteNombre").ToString + Vta.Cliente.Telefono = dtVentas(0)("Telefono").ToString + Vta.Cliente.Direccion = dtVentas(0)("ClienteDireccion").ToString + Vta.Cliente.CP = dtVentas(0)("CPCliente").ToString + Vta.Cliente.Ciudad = dtVentas(0)("ClienteCiudad").ToString + Vta.Cliente.Localidad = dtVentas(0)("ClienteLocalidad").ToString + Vta.Cliente.Estado = dtVentas(0)("ClienteEstado").ToString + Vta.Cliente.Pais = dtVentas(0)("ClientePais").ToString + Vta.Cliente.RFC = dtVentas(0)("ClienteRFC").ToString + Vta.Cliente.Colonia = dtVentas(0)("ColoniaCliente").ToString + Vta.AtencionA = dtVentas(0)("AtencionA").ToString + Vta.Cliente.NoExt = dtVentas(0)("ClienteNoExt").ToString + Vta.Cliente.NoInt = dtVentas(0)("ClienteNoInt").ToString + Vta.Cliente.Codigo = dtVentas(0)("ClienteCodigo").ToString + Vta.Cliente.Mail = dtVentas(0)("Mail").ToString + Vta.RefDocto = dtVentas(0)("Ref").ToString + Vta.CveVenta = dtVentas(0)("CveVenta").ToString.ToEntero + Vta.Version = dtVentas(0)("Version").ToString + + Vta.NumeroContrato = dtVentas(0)("NumeroContrato").ToString + Vta.DescripcionContrato = dtVentas(0)("DescripcionContrato").ToString + Vta.NumeroDescripcionContrato = If($"{dtVentas(0)("NumeroContrato").ToString} - {dtVentas(0)("NumeroLicitacion").ToString}" = " - ", "", $"{dtVentas(0)("NumeroContrato").ToString} {If(dtVentas(0)("NumeroLicitacion").ToString = "", "", $" - Licitación: {dtVentas(0)("NumeroLicitacion").ToString}")}") + + Vta.PedidoContrato = If(dtVentas(0)("PedidoContrato").ToString = "", Vta.NumeroDescripcionContrato, $"{dtVentas(0)("PedidoContrato").ToString} {If(Vta.NumeroDescripcionContrato = "", "", $" / {Vta.NumeroDescripcionContrato}") }") + 'Vta.PedidoContrato = dtVentas(0)("PedidoContrato").ToString + + Vta.ClienteSucursal = New Modelos.SucursalModel + Vta.ClienteSucursal.Direccion = dtVentas(0)("SucClienteDireccion").ToString + Vta.ClienteSucursal.NoExt = dtVentas(0)("SucClienteNoExt").ToString + Vta.ClienteSucursal.NoInt = dtVentas(0)("SucClienteNoInt").ToString + Vta.ClienteSucursal.Colonia = dtVentas(0)("SucClienteColonia").ToString + Vta.ClienteSucursal.CP = dtVentas(0)("SucClienteCP").ToString + Vta.ClienteSucursal.Municipio = dtVentas(0)("SucClienteCiudad").ToString + Vta.ClienteSucursal.Estado = dtVentas(0)("SucClienteEstado").ToString + Vta.ClienteSucursal.Pais = dtVentas(0)("SucClientePais").ToString + Vta.ClienteSucursal.Localidad = dtVentas(0)("SucClienteLocalidad").ToString + Vta.ClienteSucursal.CorreoSucursal = dtVentas(0)("SucClienteCorreo").ToString + Vta.ClienteSucursal.TelefonoSucursal = dtVentas(0)("SucClienteTelefono").ToString + Vta.ClienteSucursal.Sucursal = dtVentas(0)("SucursalCliente").ToString + Vta.ClienteSucursal.ImprimeNombreSucursal = dtVentas(0)("ImprimeNombreSucursal").ToString + + Vta.EnviarA = New Modelos.EnviarAModel + Vta.EnviarA.CveDireccionEnvio = dtVentas(0)("CveDireccionEnvio").ToString.ToEntero + Vta.EnviarA.EnvioDireccion = dtVentas(0)("EnvioDireccion").ToString + Vta.EnviarA.EnvioColonia = dtVentas(0)("EnvioColonia").ToString + Vta.EnviarA.EnvioCiudad = dtVentas(0)("EnvioCiudad").ToString + Vta.EnviarA.EnvioEstado = dtVentas(0)("EnvioEstado").ToString + Vta.EnviarA.EnvioCP = dtVentas(0)("EnvioCP").ToString + + Vta.EnviarA.EnvioNoExt = dtVentas(0)("EnvioNoExt").ToString + Vta.EnviarA.EnvioNoInt = dtVentas(0)("EnvioNoInt").ToString + Vta.EnviarA.EnvioContacto = dtVentas(0)("EnvioContacto").ToString + 'Vta.EnviarA.EnvioPedidoContrato = dtVentas(0)("EnvioPedidoContrato").ToString + + 'INE COMPLEMENTO + If dtVentas(0)("TipoComite").ToString <> "" Then + Dim INE As New Modelos.ComplementoINE + INE.INETipoComite = dtVentas(0)("TipoComite").ToString + INE.INETipoProceso = dtVentas(0)("TipoProceso").ToString + INE.INEIdContabilidad = dtVentas(0)("IdContabilidad").ToString.ToEntero + Vta.ComplementoINE = INE + End If + + + Dim DR As DataRow = TmpDTImpuestos.NewRow() + If dtVentas(0)("SubTotal").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Subtotal" : DR("Importe") = dtVentas(0)("SubTotal").ToString.ToDouble : DR("Orden") = 10 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("Descuento").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Descuentos" : DR("Importe") = dtVentas(0)("Descuento").ToString.ToDouble : DR("Orden") = 20 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("Amortizacion").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Amort.Ant" : DR("Importe") = dtVentas(0)("Amortizacion").ToString.ToDouble : DR("Orden") = 30 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("SubTotal").ToString.ToDouble <> (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) Then DR("ImpuestoLocal") = "SubTotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) : DR("Orden") = 40 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("IVA").ToString.ToDouble >= 0 Then DR("ImpuestoLocal") = "IVA" : DR("Importe") = dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 50 : TmpDTImpuestos.Rows.Add(DR) + + 'solo para eclipse, que muesre un subtotal debajo de IVA + If UsuarioActual.CveEmpresa = 15 Then DR = TmpDTImpuestos.NewRow() : DR("ImpuestoLocal") = "Subtotal2" : DR("Importe") = (dtVentas(0)("SubTotal").ToString.ToDouble - dtVentas(0)("Descuento").ToString.ToDouble - dtVentas(0)("Amortizacion").ToString.ToDouble) + dtVentas(0)("IVA").ToString.ToDouble : DR("Orden") = 51 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("RetIVA").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.IVA" : DR("Importe") = dtVentas(0)("RetIVA").ToString.ToDouble : DR("Orden") = 60 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + If dtVentas(0)("RetISR").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Ret.ISR" : DR("Importe") = dtVentas(0)("RetISR").ToString.ToDouble : DR("Orden") = 70 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + + If dtVentas(0)("IEPS").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "IEPS" : DR("Importe") = dtVentas(0)("IEPS").ToString.ToDouble : DR("Orden") = 80 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + + If dtVentas(0)("Total").ToString.ToDouble <> 0 Then DR("ImpuestoLocal") = "Total" : DR("Importe") = dtVentas(0)("Total").ToString.ToDouble : DR("Orden") = 100 : TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + + If ObjVentas.GetVentaDetalle(CveVenta) Then 'Obtenemos el Detalle de la Oorden de Compra + Vta.DtDetalle = ObjVentas.DtResultados + End If + + If ObjVentas.GetVentaImpuestosLocales(CveVenta) Then + + Dim dtImpuesto As DataTable = ObjVentas.DtResultados + If dtImpuesto.Rows.Count > 0 Then + For Each Row As DataRow In dtImpuesto.Rows + Dim Orden = 80 + If Row("Importe").ToString.ToDouble <> 0 Then + DR("ImpuestoLocal") = Row("ImpuestoLocal").ToString + DR("Importe") = Row("Importe").ToString.ToDouble + DR("Orden") = Orden + TmpDTImpuestos.Rows.Add(DR) + DR = TmpDTImpuestos.NewRow() + Orden = Orden + 1 + End If + Next + End If + Vta.DtDeduccion = TmpDTImpuestos.FiltraParametros("", Orderby:="Orden ASC") + + End If + + 'TmpDT DESGLOSE DE IMPUESTOS 3.3 + For Each dr1 As DataRow In Vta.DtDetalle.Rows + Dim DrIVA As DataRow = Nothing + Dim DrIEPS As DataRow = Nothing + + Try + DrIVA = TmpDTImpuestosIVAIEPS.Select("Impuesto = 'IVA'")(0) + Catch ex As Exception + DrIVA = Nothing + End Try + + If DrIVA IsNot Nothing Then + DrIVA("Importe") = DrIVA("Importe").ToString.ToDouble + dr1("ImporteIVA").ToString.ToDouble + TmpDTImpuestosIVAIEPS.AcceptChanges() + Else + Dim DR2 As DataRow = TmpDTImpuestosIVAIEPS.NewRow() + If dr1("PorcentajeIVA").ToString.ToDouble >= 0 Then + DR2("Impuesto") = "IVA" : DR2("tasa") = "16 %" : DR2("Importe") = dr1("ImporteIVA").ToString.ToDouble : DR2("Orden") = "1" + TmpDTImpuestosIVAIEPS.Rows.Add(DR2) + TmpDTImpuestosIVAIEPS.AcceptChanges() + End If + End If + + Try + DrIEPS = TmpDTImpuestosIVAIEPS.Select($"Impuesto = 'IEPS' AND tasa = '{dr1("PorcentajeIEPS").ToString.ToDouble * 100} %'")(0) + Catch ex As Exception + DrIEPS = Nothing + End Try + + If DrIEPS IsNot Nothing Then + DrIEPS("Importe") = DrIEPS("Importe").ToString.ToDouble + dr1("ImporteIEPS").ToString.ToDouble + TmpDTImpuestosIVAIEPS.AcceptChanges() + Else + Dim DR2 As DataRow = TmpDTImpuestosIVAIEPS.NewRow() + If dr1("PorcentajeIEPS").ToString.ToDouble > 0 Then + DR2("Impuesto") = "IEPS" : DR2("tasa") = String.Format("{0} {1}", dr1("PorcentajeIEPS").ToString.ToDouble * 100, "%") : DR2("Importe") = dr1("ImporteIEPS").ToString.ToDouble : DR2("Orden") = If(dr1("PorcentajeIEPS").ToString = "0.03", "2", If(dr1("PorcentajeIEPS").ToString = "0.06", "3", If(dr1("PorcentajeIEPS").ToString = "0.07", "4", If(dr1("PorcentajeIEPS").ToString = "0.09", "5", "")))) + TmpDTImpuestosIVAIEPS.Rows.Add(DR2) + TmpDTImpuestosIVAIEPS.AcceptChanges() + End If + End If + + Next + Vta.DtDesgloseImpuestos = TmpDTImpuestosIVAIEPS.FiltraParametros("", Orderby:="Orden ASC") + + If ObjVentas.GetVentasFirmas(CveVenta) Then + Vta.DtFirmas = ObjVentas.DtResultados + End If + + If UsuarioActual.CveEmpresa.Contiene(119) Then + If dtVentas(0)("TipoDocto").ToString.Contiene("Ing", "Ant", "Rem") Then + 'carga as notas de credito vinculadas + If ObjVentas.GetVentasAntNC(CveVenta, -1) Then + Vta.DtDocumentosRelacionados = ObjVentas.DtResultados + + End If + End If + + If dtVentas(0)("TipoDocto").ToString.Contiene("Egs", "Dev", "Ant") Then + If ObjVentas.GetVentasAntNC(-1, CveVenta) Then + Vta.DtDocumentosRelacionados = ObjVentas.DtResultados + End If + End If + End If + + + 'CFDI RELACIONADO + If dtVentas(0)("CveTipoRelacion").ToString.ToEntero > 0 Then + Vta.Timbre.Comprobante.TipoComprobante = If(Vta.TipoDocto.Contiene("Ing", "Ant"), "I", If(Vta.TipoDocto.Contiene("Egs", "Dev"), "E", "")) + If Vta.Timbre.Comprobante.TipoComprobante = "E" Then + If Vta.TipoDocto.Contiene("Egs") Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "01" + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" + End If + If Vta.TipoDocto.Contiene("Dev") Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "03" + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" + End If + Vta.Timbre.CFDIRelacionados.UUID.Add(dtVentas(0)("FolioFiscalPadre").ToString) + End If + ' cuando es refacturacoin es cfdirelacionado, con relacion 04 + If Vta.Timbre.Comprobante.TipoComprobante = "I" AndAlso (dtVentas(0)("Total").ToString.ToDouble = dtVentas(0)("TotalPadre").ToString.ToDouble) Then + Vta.Timbre.CFDIRelacionados.TipoRelacion = "04" + Vta.Timbre.CFDIRelacionados.UUID.Add(dtVentas(0)("FolioFiscalPadre").ToString) + Vta.Timbre.CFDIRelacionados.TipoRelacionTexto = "Refacturación de Ingreso" + End If + End If + + End If + ObjVentas.Dispose() + + Return PdfFactura(Vta) + End Function + +#End Region + +#Region "COMERCIO EXTERIOR" + Public Sub CargaCombosComercioExterior() + + DdlTipoOperacion.Items.Clear() + DdlTipoOperacion.DataSource = GlobalDTTipoOperacion() + DdlTipoOperacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlTipoOperacion.DataBind() + + DdlIncoterm.Items.Clear() + DdlIncoterm.DataSource = GlobalDTIncoterm() + DdlIncoterm.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlIncoterm.DataBind() + + DdlClavePedimento.Items.Clear() + DdlClavePedimento.DataSource = GlobalDTClavePedimento() + DdlClavePedimento.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlClavePedimento.DataBind() + + DdlMotivoTraslado.Items.Clear() + DdlMotivoTraslado.DataSource = GlobalDTSATMotivoTraslado() + DdlMotivoTraslado.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlMotivoTraslado.DataBind() + + CargaPais() + CargaEstado() + CargaMunicipio() + CargaColonia() + + End Sub + + + Private Sub CargaPais() + DdlPais.Items.Clear() + DdlPais.DataSource = GlobalDTPais() + DdlPais.DataBind() + DdlPais.SelectedValueExist("151") + End Sub + + Private Sub CargaEstado() + DdlEstado.Items.Clear() + If DdlPais.SelectedValue.ToEntero > 0 Then + DdlEstado.DataSource = GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString) + End If + DdlEstado.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlEstado.DataBind() + End Sub + + Private Sub CargaMunicipio() + DdlMunicipio.Items.Clear() + If DdlEstado.SelectedValue.ToEntero > 0 Then + DdlMunicipio.DataSource = GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString).FiltraParametros($"CveEstado = {DdlEstado.SelectedValue.ToEntero}")(0)("ClaveSATEstado").ToString) + End If + DdlMunicipio.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlMunicipio.DataBind() + End Sub + + Private Sub CargaColonia() + DdlColonia.Items.Clear() + If DdlMunicipio.SelectedValue.ToEntero > 0 Then + DdlColonia.DataSource = GlobalDTColonia(GlobalDTMunicipio(GlobalDTEstado(GlobalDTPais.FiltraParametros($"CvePais = {DdlPais.SelectedValue.ToEntero}")(0)("ClaveSATPais").ToString).FiltraParametros($"CveEstado = {DdlEstado.SelectedValue.ToEntero}")(0)("ClaveSATEstado").ToString).FiltraParametros($"CveMunicipio = {DdlMunicipio.SelectedValue.ToEntero}")(0)("ClaveSATMunicipio").ToString) + End If + DdlColonia.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlColonia.DataBind() + End Sub + + Protected Sub DdlPais_SelectedIndexChanged(sender As Object, e As EventArgs) + 'si contiene MX, USA o CANADA carga ddls, si no carga txt + CargaEstado() + + If DdlPais.SelectedValue.Contiene("151", "66", "40") Then + DdlEstado.Visible = True + DdlMunicipio.Visible = True + DdlColonia.Visible = True + + TxtComExtEstado.Visible = False + TxtComExtMunicipio.Visible = False + TxtComExtColonia.Visible = False + + TxtComExtEstado.Text = "" + TxtComExtMunicipio.Text = "" + TxtComExtColonia.Text = "" + + If DdlPais.SelectedValue.Contiene("66", "40") Then + DdlMunicipio.Visible = False + DdlColonia.Visible = False + + DdlMunicipio.SelectedValue = "-1" + DdlColonia.SelectedValue = "-1" + + TxtComExtMunicipio.Visible = True + TxtComExtColonia.Visible = True + End If + + Else + 'Limpia los DDLs + CargaMunicipio() + CargaColonia() + + DdlEstado.Visible = False + DdlMunicipio.Visible = False + DdlColonia.Visible = False + + TxtComExtEstado.Visible = True + TxtComExtMunicipio.Visible = True + TxtComExtColonia.Visible = True + End If + End Sub + Protected Sub DdlEstado_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaMunicipio() + CargaColonia() + End Sub + Protected Sub DdlMunicipio_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaColonia() + End Sub + +#End Region + +#Region "D O C U M E N T A C I O N " + + Private Sub CargaDocumentacionCliente() + Dim objRH As New ClsEdocumentacion() + + If objRH.DocumentacionElectronicaGet(-1, If(CveCliente = -1, 0, CveCliente), -1, UsuarioActual.Empresa.CveEmpresa, -1, Modulo:=2) Then + DTDocumentacion = objRH.DtResultados + GvDocumentosCliente.DataSource = objRH.DtResultados + End If + objRH.Dispose() + 'If DTDocumentacion.FiltraParametros(" CveDocumentacionTipo = 7 ").Rows.Count > 0 Then + ' GvDocumentosCliente.DataSource = DTDocumentacion.FiltraParametros(" CveDocumentacionTipo = 7 ") + 'Else + ' GvDocumentosCliente.DataSource = Nothing + 'End If + GvDocumentosCliente.DataBind() + + UPGvDocumentosCliente.Update() + 'UpGvDocumentosFirma2.Update() + End Sub + Public Sub UploadModal_ClickDocumentacionFirmaContrato(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + Dim chkEstatus As CheckBox + CveDocumentacionElectronica = GvRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero + CveDocumentacion = GvRow.DataKey("CveDocumentacion").ToString.ToEntero + Documentacion = GvRow.DataKey("Documentacion") + AdjuntoDocumentacion = GvRow.DataKey("Adjunto").ToString + + chkEstatus = GvRow.FCCheckBox("chkEstatus") + + + + ObservacionDocumentacion = GvRow.FCTextBox("TxtObservaciones").Text.Trim.ToUpper + FechaLimite = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate + + AdjuntoDocumentacion = GvRow.DataKey("Adjunto") + + LtlTitulofirmaContrato.Text = "Subir " & Documentacion + + UpTituloFirma.Update() + + RegistraScript("$('#ModalUploadFirmaContratoDocumento').modal({ backdrop: 'static', keyboard: false});") + End Sub + Private Sub GuardarDocumentosClientes(Optional _CveDocumentacionExcluir As Integer = -1) + + Dim hasError As Boolean = True + Dim objDocumentos As New ClsEdocumentacion + + For Each dRow As GridViewRow In GvDocumentosCliente.Rows + + Dim _CveDocumentacion As Integer = dRow.DataKey("CveDocumentacion").ToString.ToEntero + Dim _Adjunto As String = dRow.DataKey("Adjunto") + 'Dim _Documentacion As String = dRow.DataKey("Documentacion") + Dim _CveDocumentacionElectronica As Integer = dRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero + Dim _txtObservaciones As TextBox = dRow.FCTextBox("TxtObservaciones") + Dim _TxtFechaLimite As TextBox = dRow.FCTextBox("TxtFechaLimite") + Dim _TxtFechaVigencia As TextBox = dRow.FCTextBox("TxtFechaVigencia") + Dim chkEstatus As CheckBox = dRow.FCCheckBox("chkEstatus") + Dim _estatus As Integer + + _estatus = If(dRow.FCCheckBox("chkEstatus").Checked, 1, 0) + + Dim _FechaVigencia As Date + Dim _FechaLimite As Date + + Dim DiasLimite As Integer = dRow.DataKey("DiasLimite").ToString.ToEntero + Dim AplicaDiasLimite As Boolean = If(dRow.DataKey("AplicaDiasLimite").ToString = "1", True, False) + Dim AplicaFechaVencimiento As Boolean = If(dRow.DataKey("AplicaFechaVencimiento").ToString = "1", True, False) + + If _TxtFechaVigencia.Text.Length = 10 Then + _FechaVigencia = _TxtFechaVigencia.Text.ToDate + Else + _FechaVigencia = Nothing + End If + + If Not AplicaDiasLimite Then + _FechaLimite = MinFecha + Else + _FechaLimite = _TxtFechaLimite.Text.ToDate + End If + + If Not AplicaFechaVencimiento Then + _FechaVigencia = MinFecha + End If + + + If Not _CveDocumentacionExcluir = _CveDocumentacion Then + Try + If _CveDocumentacionElectronica = -1 Then + + If objDocumentos.DocumentacionElectronicaAdd(_CveDocumentacion, -1, CveCliente, -1, _estatus, _txtObservaciones.Text.Trim, _Adjunto, UsuarioActual.CveUsuario, _FechaLimite, _FechaVigencia) > 0 Then + Else + hasError = True + Exit For + End If + + Else + If objDocumentos.DocumentacionElectronicaUpdate(_CveDocumentacionElectronica, _CveDocumentacion, -1, CveCliente, -1, _estatus, _txtObservaciones.Text.Trim, _Adjunto, UsuarioActual.CveUsuario, _FechaLimite, _FechaVigencia) Then + Else + hasError = True + Exit For + End If + End If + + + hasError = False + Catch ex As Exception + hasError = True + Exit For + End Try + End If + Next + + 'refrescar grid datos investigacion + CargaDocumentacionCliente() + End Sub + + Protected Sub chkEstatus_CheckedChanged(sender As Object, e As EventArgs) + GuardarDocumentosClientes() + End Sub + + Protected Sub TxtObservaciones_TextChanged(sender As Object, e As EventArgs) + GuardarDocumentosClientes() + End Sub + Protected Sub BtnModalFirmaContratoDocumentoUpload_Click(sender As Object, e As EventArgs) Handles BtnModalFirmaContratoDocumentoUpload.Click + + Dim FileExtension As String = "-1" + Dim Filesgral As List(Of Archivo) = TxtFileFirmaContrato.getfiles().Archivos + Dim Filename As String = "" + + + For Each fileItem As Archivo In Filesgral + Try + + FileExtension = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + Dim tempArray() As String + tempArray = fileItem.filename.ToString().Split("-".ToCharArray()) + + Dim rutaDestino As String = UsuarioActual.Empresa.Ruta & "\DocElectronica\Clientes\" & CveCliente & "\" & Documentacion & "." & FileExtension + Dim rutaAdjuntoAnterior As String = UsuarioActual.Empresa.Ruta & "DocElectronica\Clientes\" & CveCliente & "\" & AdjuntoDocumentacion + + If Not System.IO.Directory.Exists(UsuarioActual.Empresa.Ruta & "DocElectronica\Clientes\" & CveCliente & "\") Then + System.IO.Directory.CreateDirectory(UsuarioActual.Empresa.Ruta & "DocElectronica\Clientes\" & CveCliente & "\") + End If + + If File.Exists(rutaAdjuntoAnterior) And AdjuntoDocumentacion.Trim.Length > 0 Then + File.Delete(rutaAdjuntoAnterior) + End If + + If System.IO.File.Exists(rutaDestino) Then + System.IO.File.Delete(rutaDestino) + End If + + System.IO.File.Move(fileItem.FileUrl, rutaDestino) + + Dim objRH As New ClsEdocumentacion + + + If CveDocumentacionElectronica = -1 Then + If objRH.DocumentacionElectronicaAdd(CveDocumentacion, -1, CveCliente, -1, 1, ObservacionDocumentacion, Documentacion & "." & FileExtension, UsuarioActual.CveUsuario, FechaLimite) > 0 Then + + End If + Else + If objRH.DocumentacionElectronicaUpdate(CveDocumentacionElectronica, CveDocumentacion, -1, CveCliente, -1, 1, ObservacionDocumentacion, Documentacion & "." & FileExtension, UsuarioActual.CveUsuario, FechaLimite) Then + + End If + End If + + objRH.Dispose() + + GuardarDocumentosClientes(CveDocumentacion) + CargaDocumentacionCliente() + + + TxtFileFirmaContrato.Text = "" + UpModalFirmaContratoDocumento.Update() + + Catch ex As Exception + OnError("Error al cargar archivo", ex) + End Try + + Next + RegistraScript("$('#ModalUploadFirmaContratoDocumento').modal('hide')", "hidemodal7") + + End Sub + + Public Sub Update_ClickDocumentacionFirmaContrato(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim activo As Boolean = False + + Dim _CveDocumentacionElectronica As Integer = GvRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero + Dim _CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToString.ToEntero + Dim _Adjunto As String = GvRow.DataKey("Adjunto").ToString + Dim _fechaLimite As Date = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate + + Dim obserbaciones As String = DirectCast(GvRow.FindControl("TxtObservaciones"), TextBox).Text + 'Dim DDLEstatus As DropDownList = DirectCast(GvRow.FindControl("DDLEstatus"), DropDownList) + Dim chkCompleto As CheckBox = DirectCast(GvRow.FindControl("chkEstatus"), CheckBox) + + If chkCompleto.Checked Then + Estatus = 1 + Else + Estatus = 0 + End If + + Dim ObjEdoc As New ClsEdocumentacion + + If Not _CveDocumentacionElectronica = -1 Then + If ObjEdoc.DocumentacionElectronicaUpdate(_CveDocumentacionElectronica, _CveDocumentacion, -1, CveCliente, -1, 1, obserbaciones, _Adjunto, UsuarioActual.CveUsuario, _fechaLimite) Then + Alert("Documento actualizado correctamente.", TipoMensaje.MsgInformacion) + End If + Else + If ObjEdoc.DocumentacionElectronicaAdd(_CveDocumentacion, -1, CveCliente, -1, 1, obserbaciones, _Adjunto, UsuarioActual.CveUsuario, _fechaLimite) > 0 Then + Alert("Documento actualizado correctamente.", TipoMensaje.MsgInformacion) + End If + End If + + CargaDocumentacionCliente() + ObjEdoc.Dispose() + + End Sub + + + Public Sub Update_ClickDocumentacionRemove(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim activo As Boolean = False + + Dim _CveDocumentacionElectronica As Integer = GvRow.DataKey("CveDocumentacionElectronica").ToString.ToEntero + Dim _CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToString.ToEntero + Dim _Adjunto As String = GvRow.DataKey("Adjunto").ToString + Dim _fechaLimite As Date = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate + Dim obserbaciones As String = DirectCast(GvRow.FindControl("TxtObservaciones"), TextBox).Text + 'Dim DDLEstatus As DropDownList = DirectCast(GvRow.FindControl("DDLEstatus"), DropDownList) + Dim chkCompleto As CheckBox = DirectCast(GvRow.FindControl("chkEstatus"), CheckBox) + + Dim UrlArchivo = UsuarioActual.Empresa.Ruta & "\DocElectronica\Clientes\" & CveCliente & "/" & _Adjunto + + If File.Exists(UrlArchivo) Then + Try + File.Delete(UrlArchivo) + Catch ex As Exception + End Try + + End If + + Dim ObjEdoc As New ClsEdocumentacion + + If Not _CveDocumentacionElectronica = -1 Then + + If ObjEdoc.DocumentacionElectronicaUpdate(_CveDocumentacionElectronica, _CveDocumentacion, -1, CveCliente, -1, 0, "", "", UsuarioActual.CveUsuario, _fechaLimite) Then + Alert("Documento Eliminado Correctamente.", TipoMensaje.MsgInformacion) + End If + + End If + + CargaDocumentacionCliente() + ObjEdoc.Dispose() + + End Sub Public Sub DownLoad_ClickDocumentacion(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim Adjunto As String = GvRow.DataKey("Adjunto") @@ -6883,8 +6883,8 @@ Partial Class Clientes TxtAval.Text = "" RegistraScript("$('#ModalDivPagare').modal('show')") - End Sub - + End Sub + Protected Sub ImprimirPagare(sender As Object, e As EventArgs) Handles BtnAgregarPagare.Click Dim memoryStreamDoc As New System.IO.MemoryStream Dim objGemBoxDocument As New clsGemBoxDocument(linkDescargaPagare) @@ -6942,2514 +6942,2514 @@ Partial Class Clientes memoryStream.WriteTo(Response.OutputStream) Response.End() - End Sub - - Protected Sub GvDocumentosFirma_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocumentosCliente.RowDataBound - - - If e.Row.RowType = DataControlRowType.DataRow Then - - Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString - Dim ImgDownLoadFormato As LinkButton = e.Row.FCLinkButton("ImgDownLoadFormato") - 'Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad") - Dim LnkDownLoadDoc As LinkButton = e.Row.FCLinkButton("LnkDownLoadDoc") - Dim ImgRequired As Literal = e.Row.FCLiteral("ImgRequired") - Dim txtFechaLimite As TextBox = e.Row.FCTextBox("TxtFechaLimite") - Dim requerido As Boolean = If(e.Row.DBCampo("Requerido").ToUpper = "TRUE", True, False) - Dim chkEstatus As CheckBox = e.Row.FCCheckBox("chkEstatus") - Dim documentacionFormato As String = e.Row.DBCampo("DocumentacionFormato").ToString - Dim Documentacion As String = e.Row.DBCampo("Documentacion").ToString - Dim _CveDocumentacion As Integer = e.Row.DBCampo("CveDocumentacion").ToString.ToEntero - Dim separado As Char() = ".".ToString.ToCharArray - Dim array() As String = Adjunto.Split(separado) - Dim extencion As String = "" - Dim existeAdjunto As Boolean = False - Dim TxtFechaVigencia As TextBox = e.Row.FCTextBox("TxtFechaVigencia") - - Dim imgCalendario As LinkButton = e.Row.FCLinkButton("imgCalendario") - - - - - - - ' FechaVigencia - - Dim DiasLimite As Integer = e.Row.DataKey("DiasLimite").ToString.ToEntero - Dim AplicaDiasLimite As Boolean = If(e.Row.DataKey("AplicaDiasLimite").ToString = "1", True, False) - Dim AplicaFechaVencimiento As Boolean = If(e.Row.DataKey("AplicaFechaVencimiento").ToString = "1", True, False) - - txtFechaLimite.Visible = If(AplicaDiasLimite, True, False) - TxtFechaVigencia.Visible = If(AplicaFechaVencimiento, True, False) - imgCalendario.Visible = If(AplicaFechaVencimiento, True, False) - - - 'Dim scripMascara = " $('#" & TxtFechaVigencia.ClientID & "').mask('00/00/0000');" - ' RegistraScript(scripMascara) - - If TxtFechaVigencia.Text.Length = 10 Then - TxtFechaVigencia.Text = TxtFechaVigencia.Text.ToDate.ToString("dd/MM/yyyy") - End If - - If array.Length > 0 Then - extencion = array(array.Length - 1) - End If - - If e.Row.DBCampo("Estatus").ToString.ToEntero = 1 Then - chkEstatus.Checked = True - Else - chkEstatus.Checked = False - End If - - If documentacionFormato = "" Then - 'ImgDownLoadFormato.Visible = False - LnkDownLoadDoc.Visible = False - Else - Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "/Formatos/" & CveDocumentacion & "" & documentacionFormato - LnkDownLoadDoc.Visible = True - End If - - txtFechaLimite.Text = e.Row.DBCampo("FechaLimite").ToString.ToDate.ToString("dd/MM/yyyy") - - If Adjunto.Trim.Length > 0 Then - - Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "\DocElectronica\Clientes\" & CveCliente & "/" & Adjunto - Dim linkDescargaArchivo = UsuarioActual.Empresa.Ruta & "\DocElectronica\Clientes\" & CveCliente & "/" & Adjunto - - If File.Exists(linkDescargaArchivo) Then - - LnkDownLoadDoc.Visible = True - ScriptManager.GetCurrent(Me).RegisterPostBackControl(LnkDownLoadDoc) - 'If extencion.Length > 0 Then - ' ImgDownLoad.Text = String.Format(" ", linkDescarga, CveCliente & Documentacion & "." & extencion) - 'Else - ' ImgDownLoad.Text = String.Format(" ", linkDescarga, CveCliente & Documentacion) - 'End If - Else - LnkDownLoadDoc.Visible = False - End If - Else - LnkDownLoadDoc.Visible = False - End If - - If requerido Then - ImgRequired.Text = " " - Else - ' ImgRequired.Text = " " - End If - - If UsuarioActual.TienePermisoProceso(248) And e.Row.DBCampo("Estatus").ToString.ToEntero = 1 And LnkDownLoadDoc.Visible Then - e.Row.FCLinkButton("LnkGvDocumentosEliminar").Visible = True - End If - - End If - - End Sub - Public Sub DownLoadFormato_ClickDocumentacion(sender As Object, e As EventArgs) - - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - - Dim CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToString.ToEntero - Dim DocumentacionFormato As String = CveDocumentacion & "_" & GvRow.DataKey("DocumentacionFormato") - - DescarFormato(DocumentacionFormato) - - End Sub - 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\" & documento - pathDesti = PathRoot & "Temp\" & CveCliente & documento - - If File.Exists(pathDesti) Then - File.Delete(pathDesti) - End If - - File.Copy(PathSource, pathDesti) - - Dim objDoc As New clsGemBoxDocument(pathDesti) - Dim objRH As New ClsRH - Dim FechaActual As String = Now.Day.ToString("0#") & " de " & CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1).ToString & " del " & Now.Year.ToString() - - - objDoc.SustituirTags(objRH.GetDatosTagsDocumentos(-1, UsuarioActual.CveEmpresa)) ' Pendiente - objRH.Dispose() - - - - objDoc.Guardar(pathDesti) - - Dim fileinfo As New FileInfo(pathDesti) - - Dim baseUrl As String = Request.Url.GetLeftPart(UriPartial.Authority) - baseUrl = baseUrl & "/temp/" & fileinfo.Name - - RegistraDescargaJavaScript(baseUrl) - - End Sub - - - - 'Private Function GetDatosTagsDocumentos() As List(Of TagsDocumentos) - ' Dim ListaTagsDocumentost = New List(Of TagsDocumentos) - - ' If CvePersonal <> -1 Then - ' Dim objRH As New ClsRH - - - - ' If objRH.PersonalReclutamientoGet(CvePersonal, UsuarioActual.Empresa.CveEmpresa) Then - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Nombres}", objRH.DtResultados(0)("Nombres").ToString)) - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{APaterno}", objRH.DtResultados(0)("APaterno").ToString)) - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{AMaterno}", objRH.DtResultados(0)("AMaterno").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{RFC}", objRH.DtResultados(0)("RFC").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{NombreCompleto}", Cliente)) - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Estatura}", objRH.DtResultados(0)("Estatura").ToString)) - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Peso}", objRH.DtResultados(0)("Peso").ToString)) - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{LugarNacimiento}", objRH.DtResultados(0)("LugarNacimiento").ToString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Edad}", objRH.DtResultados(0)("Edad").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{NombreTelEmergencia}", objRH.DtResultados(0)("NombreTelEmergencia").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{TipoSangre}", objRH.DtResultados(0)("TipoSangre").ToString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Vivienda}", objRH.DtResultados(0)("Vivienda").ToString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{ViviendaDueno}", objRH.DtResultados(0)("ViviendaDueno").ToString)) - - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{CreditoInfonavit}", objRH.DtResultados(0)("CreditoInfonavit").ToString)) - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{RentaMensual}", objRH.DtResultados(0)("RentaMensual").ToString.ToDecimal.ToString("###,###,###.00"))) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{TransportePublico}", objRH.DtResultados(0)("TransportePublico").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{TrabajadoAnteriormente}", objRH.DtResultados(0)("TrabajadoAnteriormente").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{TrabajadoAnteriormenteObservaciones}", objRH.DtResultados(0)("TrabajadoAnteriormenteObservaciones").ToString)) - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{ParientesEmpresa}", objRH.DtResultados(0)("ParientesEmpresa").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{AcusadoDelito}", objRH.DtResultados(0)("AcusadoDelito").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{AcusadoDelitoObservaciones}", objRH.DtResultados(0)("AcusadoDelitoObservaciones").ToString)) - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Direccion}", objRH.DtResultados(0)("Direccion").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Calle}", objRH.DtResultados(0)("Calle").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Colonia}", objRH.DtResultados(0)("Colonia").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{CP}", objRH.DtResultados(0)("CP").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Telefono}", objRH.DtResultados(0)("Telefono").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Celular}", objRH.DtResultados(0)("Celular").ToString)) - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Correo}", objRH.DtResultados(0)("Correo").ToString)) - - - ' 'If Not IsDBNull(objRH.DtResultados(0)("CveSucursal")) Then - - ' ' ListaTagsDocumentost.Add(New TagsDocumentos("{CveSucursal}", DDLSucursal4.Text)) - ' 'End If - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{NumeroSS}", objRH.DtResultados(0)("NumeroSS").ToString)) - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Licencia}", objRH.DtResultados(0)("Licencia").ToString)) - - - - - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{CartillaMilitar}", objRH.DtResultados(0)("CartillaMilitar").ToString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{CURP}", objRH.DtResultados(0)("CURP").ToString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{AutorizaAntidoping}", objRH.DtResultados(0)("AutorizaAntidoping").ToString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Observaciones}", objRH.DtResultados(0)("Observaciones").ToString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Direccion}", objRH.DtResultados(0)("Direccion").ToString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaIngreso}", objRH.DtResultados(0)("FechaIngreso").ToString.ToDate.ToShortDateString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Direccion}", objRH.DtResultados(0)("Direccion").ToString.ToDate.ToShortDateString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Puesto}", objRH.DtResultados(0)("Puesto").ToString)) - - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{CUIP}", "")) - ' ListaTagsDocumentost.Add(New TagsDocumentos("{Denominacion}", "")) - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaNacimiento}", objRH.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("dd/MM/yyyy"))) - - - ' Dim fechaActual As String = " " & Now.Day & " del mes " & Now.Month & " del año " & Now.Year - - ' Dim FechaActualDF As String = Now.ToString("dd/MM/yyyy") - - ' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaActual}", fechaActual)) - ' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaActualDF}", FechaActualDF)) - ' End If - - - ' objRH.Dispose() - ' End If - - ' Return ListaTagsDocumentost - 'End Function - - - - - - - - ''Private Function GetDatosTagsDocumentos() As List(Of TagsDocumentos) - '' Dim ListaTagsDocumentost = New List(Of TagsDocumentos) - - '' If CvePersonal <> -1 Then - '' Dim objRH As New ClsRH - - - - '' If objRH.PersonalReclutamientoGet(CvePersonal, UsuarioActual.Empresa.CveEmpresa) Then - - '' If Not IsDBNull(objRH.DtResultados(0)("Nombres")) Then - '' ListaTagsDocumentost.Add(New TagsDocumentos("{Nombres}", objRH.DtResultados(0)("Nombres").ToString)) - '' End If - - '' If Not objRH.DtResultados(0)("APaterno") Is Nothing Then - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{APaterno}", objRH.DtResultados(0)("APaterno").ToString)) - '' End If - - '' If Not objRH.DtResultados(0)("AMaterno") Is Nothing Then - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{AMaterno}", objRH.DtResultados(0)("AMaterno").ToString)) - '' End If - - '' If Not objRH.DtResultados(0)("NombreCompleto") Is Nothing Then - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{NombreCompleto}", objRH.DtResultados(0)("NombreCompleto").ToString)) - '' End If - - '' If Not IsDBNull(objRH.DtResultados(0)("Estatura")) Then - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{Estatura}", objRH.DtResultados(0)("Estatura").ToString)) - '' End If - - '' If Not IsDBNull(objRH.DtResultados(0)("Peso")) Then - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{Peso}", objRH.DtResultados(0)("Peso").ToString)) - '' End If - - '' If Not IsDBNull(objRH.DtResultados(0)("LugarNacimiento")) Then - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{LugarNacimiento}", objRH.DtResultados(0)("LugarNacimiento").ToString)) - '' End If - - '' If Not IsDBNull(objRH.DtResultados(0)("Edad")) Then - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{Edad}", objRH.DtResultados(0)("Edad").ToString)) - '' End If - - '' If Not IsDBNull(objRH.DtResultados(0)("NombreTelEmergencia")) Then - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{NombreTelEmergencia}", objRH.DtResultados(0)("NombreTelEmergencia").ToString)) - '' End If - - '' If Not IsDBNull(objRH.DtResultados(0)("TipoSangre")) Then - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{TipoSangre}", objRH.DtResultados(0)("TipoSangre").ToString)) - '' End If - - '' If Not IsDBNull(objRH.DtResultados(0)("Vivienda")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Vivienda}", objRH.DtResultados(0)("Vivienda").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("ViviendaDueno")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{ViviendaDueno}", objRH.DtResultados(0)("ViviendaDueno").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("CreditoInfonavit")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CreditoInfonavit}", objRH.DtResultados(0)("CreditoInfonavit").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("RentaMensual")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{RentaMensual}", objRH.DtResultados(0)("RentaMensual").ToString.ToDecimal.ToString("###,###,###.00"))) - - '' If Not IsDBNull(objRH.DtResultados(0)("TransportePublico")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{TransportePublico}", objRH.DtResultados(0)("TransportePublico").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("TrabajadoAnteriormente")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{TrabajadoAnteriormente}", objRH.DtResultados(0)("TrabajadoAnteriormente").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("TrabajadoAnteriormenteObservaciones")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{TrabajadoAnteriormenteObservaciones}", objRH.DtResultados(0)("TrabajadoAnteriormenteObservaciones").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("ParientesEmpresa")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{ParientesEmpresa}", objRH.DtResultados(0)("ParientesEmpresa").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("AcusadoDelito")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{AcusadoDelito}", objRH.DtResultados(0)("AcusadoDelito").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("AcusadoDelitoObservaciones")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{AcusadoDelitoObservaciones}", objRH.DtResultados(0)("AcusadoDelitoObservaciones").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Direccion")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Direccion}", objRH.DtResultados(0)("Direccion").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Calle")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Calle}", objRH.DtResultados(0)("Calle").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Colonia")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Colonia}", objRH.DtResultados(0)("Colonia").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("CP")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CP}", objRH.DtResultados(0)("CP").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Telefono")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Telefono}", objRH.DtResultados(0)("Telefono").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Celular")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Celular}", objRH.DtResultados(0)("Celular").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Correo")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Correo}", objRH.DtResultados(0)("Correo").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("CveSucursal")) Then - - '' ' ListaTagsDocumentost.Add(New TagsDocumentos("{CveSucursal}", DDLSucursal4.Text)) - '' End If - - '' If Not IsDBNull(objRH.DtResultados(0)("NumeroSS")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{NumeroSS}", objRH.DtResultados(0)("NumeroSS").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Licencia")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Licencia}", objRH.DtResultados(0)("Licencia").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("CartillaMilitar")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CartillaMilitar}", objRH.DtResultados(0)("CartillaMilitar").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("CURP")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CURP}", objRH.DtResultados(0)("CURP").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("AutorizaAntidoping")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{AutorizaAntidoping}", objRH.DtResultados(0)("AutorizaAntidoping").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Observaciones")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Observaciones}", objRH.DtResultados(0)("Observaciones").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("CredencialElector")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CredencialElector}", objRH.DtResultados(0)("CredencialElector").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Sucursal")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Sucursal}", objRH.DtResultados(0)("Sucursal").ToString)) - - '' If Not IsDBNull(objRH.DtResultados(0)("Puesto")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Puesto}", objRH.DtResultados(0)("Puesto").ToString)) - - '' 'If Not IsDBNull(objRH.DtResultados(0)("InformacionFidedigno")) Then chkFidedigna4.Checked = objRH.DtResultados(0)("InformacionFidedigno") - '' ListaTagsDocumentost.Add(New TagsDocumentos("{InformacionFidedigno}", objRH.DtResultados(0)("InformacionFidedigno").ToString)) - '' End If - - '' If Not IsDBNull(objRH.DtResultados(0)("FechaNacimiento")) Then - '' ListaTagsDocumentost.Add(New TagsDocumentos("{InformacionFidedigno}", objRH.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("dd/MM/yyyy"))) - '' End If - - - '' Dim fechaActual As String = " " & Now.Day & " del mes " & Now.Month & " del año " & Now.Year - '' Dim FechaActualDF As String = Now.ToString("dd/MM/yyyy") - - '' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaActual}", fechaActual)) - '' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaActualDF}", FechaActualDF)) - - - '' objRH.Dispose() - '' End If - - '' Return ListaTagsDocumentost - ''End Function - Private Sub RegistraDescargaJavaScript(baseUrl As String) - - RegistraScript("Download('" & baseUrl & "')") - - End Sub - -#End Region - -#Region "D O C U M E N T O S V E N T A S" - - Private Sub CargaDocumentosVenta(tCveCliente As Integer) - Dim objInv As New ClsEdocumentacion - - If objInv.DocumentacionElectronicaGet(-1, tCveCliente, -1, UsuarioActual.CveEmpresa, 14) Then - GvDocsVentas.DataSource = objInv.DtResultados - If objInv.DtResultados.Rows.Count > 0 Then BtnGuardarDocumentacion.Visible = True - Else - GvDocsVentas.DataSource = Nothing - End If - - objInv.Dispose() - GvDocsVentas.DataBind() - UpDocumentacion.Update() - - End Sub - - Private Sub BtnGuardarDocumentación_Click(sender As Object, e As EventArgs) Handles BtnGuardarDocumentacion.Click - Dim objDoc As New ClsEdocumentacion() - objDoc.IniciaTransacSQL() - Dim HuboError As Boolean = False - - If CveCliente <= 0 Then - For Each gvr As GridViewRow In GvDocsVentas.Rows - If gvr.FCCheckBox("ChkDoc").Checked Then - - If objDoc.DocumentacionElectronicaAdd(gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, Now, Observacion2:=gvr.FCTextBox("TxtObs2").Text) <= 0 Then HuboError = True - - End If - - Next - - Else - For Each gvr As GridViewRow In GvDocsVentas.Rows - 'sino está registrada y se selecciona, se va a insertar - If gvr.DataKey("CveDocumentacionElectronica").ToEntero <= 0 AndAlso gvr.FCCheckBox("ChkDoc").Checked Then - If objDoc.DocumentacionElectronicaAdd(gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, Now, Observacion2:=gvr.FCTextBox("TxtObs2").Text) <= 0 Then HuboError = True - Else - ', Observacion2:=gvr.FCTextBox("TxtObs2").Text - If Not objDoc.DocumentacionElectronicaUpdate(gvr.DataKey("CveDocumentacionElectronica").ToEntero, gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, gvr.DataKey("FechaLimite").ToDate, Observacion2:=gvr.FCTextBox("TxtObs2").Text) Then HuboError = True - End If - - 'si ya estaba registrada y no se selecciona, se va a insertar - If gvr.DataKey("CveDocumentacionElectronica").ToEntero > 0 AndAlso Not gvr.FCCheckBox("ChkDoc").Checked Then - If Not objDoc.DocumentacionElectronicaRemove(gvr.DataKey("CveDocumentacionElectronica").ToEntero, -1) Then HuboError = True - End If - - Next - - End If - - - If Not HuboError Then - Alert("Documentación guardada", TipoMensaje.MsgInformacion) - objDoc.Commit() - Else - objDoc.RollBack() - End If - objDoc.Dispose() - - End Sub - - Public Sub Upload_ClickDocumentacion(sender As Object, e As EventArgs) - RegistraScript("$('#ModalCXCDocumento').modal({ backdrop: 'static', keyboard: false});") - End Sub - - Protected Sub BtnModalCXCDocumentoClienteUpload_Click(sender As Object, e As EventArgs) Handles BtnModalCXCDocumentoClienteUpload.Click - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Dim _CveDocumentacionElectronica As Integer = GvRow.DataKey("CveDocumentacion").ToEntero - Dim _CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToEntero - Dim _Obserbaciones As String = GvRow.FCTextBox("TxtObservaciones").Text.Trim - Dim _FechaLimite As Date = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate - - SubirComprobante(_CveDocumentacionElectronica, _CveDocumentacion, _Obserbaciones, _FechaLimite) - 'CargaDocs() - - End Sub - - Private Function SubirComprobante(_CveDocumentacionElecronica As Integer, _CveDocumentacion As Integer, _Obserbaciones As String, _FechaLimite As Date) As Boolean - - Dim Respuesta As Boolean = False - Dim RutaDirectorio As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, "Clientes\") - - Dim filesgral As List(Of Archivo) = TxtCXCDocumentoCliente.getfiles().Archivos - Dim filemove As String = "" - Dim Comprobante As String = "" - Dim ShortFileName As String = "" - - - If filesgral.Count > 0 Then - - Dim RutaArchivo As String - - For Each fileItem As Archivo In filesgral - - Dim edoc As New ClsEdocumentacion - - Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") - filemove = fileItem.FileUrl - RutaArchivo = String.Format("{0}{1}_{2}", RutaDirectorio, CveCliente, _CveDocumentacion) - RutaArchivo = String.Format("{0}.{1}", RutaArchivo, fileItem.Extencion) - - Try - If Not Directory.Exists(RutaDirectorio) Then - Directory.CreateDirectory(RutaDirectorio) - End If - - If File.Exists(RutaArchivo) Then - File.Delete(RutaArchivo) - End If - - File.Move(filemove, RutaArchivo) - Respuesta = True - ShortFileName = System.IO.Path.GetFileName(RutaArchivo) - - If edoc.DocumentacionElectronicaUpdate(_CveDocumentacionElecronica, _CveDocumentacion, -1, CveCliente, -1, 1, _Obserbaciones, ShortFileName, UsuarioActual.CveEmpresa, _FechaLimite) Then - - - End If - - Catch ex As Exception - - OnError("Error al intentar guardar archivo ", ex) - Respuesta = False - RutaArchivo = "-1" - End Try - Anexo.Text = "" - - edoc.Dispose() - Next - Else - Respuesta = True - End If - - - - UpModalCXCClienteDocumento.Update() - Return Respuesta - - End Function - - Public Sub Update_ClickDocumentacion(sender As Object, e As EventArgs) - - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - Dim activo As Boolean = False - - Dim _CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToEntero - Dim _Adjunto As String = GvRow.DataKey("Adjunto").ToString - Dim _fechaLimite As Date = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate - - Dim observaciones As String = GvRow.FCTextBox("TxtObservaciones").Text ' DirectCast(GvRow.FindControl("TxtObservaciones"), TextBox).Text - 'Dim DDLEstatus As DropDownList = DirectCast(GvRow.FindControl("DDLEstatus"), DropDownList) - Dim chkCompleto As CheckBox = GvRow.FCCheckBox("chkEstatus") - Dim _Estatus As Integer - If chkCompleto.Checked Then _Estatus = 1 Else _Estatus = 0 - - - Dim objRH As New ClsEdocumentacion - - If Not GvRow.DataKey("CveDocumentacionElectronica").ToEntero = -1 Then - If objRH.DocumentacionElectronicaUpdate(GvRow.DataKey("CveDocumentacionElectronica").ToEntero, _CveDocumentacion, -1, CveCliente, -1, _Estatus, observaciones, _Adjunto, UsuarioActual.CveUsuario, GvRow.FCTextBox("TxtFechaLimite").Text.ToDate) Then - Alert("Documento actualizado correctamente.", TipoMensaje.MsgInformacion) - End If - Else - If objRH.DocumentacionElectronicaAdd(_CveDocumentacion, -1, CveCliente, -1, _Estatus, observaciones, _Adjunto, UsuarioActual.CveUsuario, GvRow.FCTextBox("TxtFechaLimite").Text.ToDate) > 0 Then - Alert("Documento actualizado correctamente.", TipoMensaje.MsgInformacion) - End If - End If - - objRH.Dispose() - - End Sub - - -#End Region - -#Region "PERSONA FISICA" - Protected Sub LnkPersonaFisica_Click(sender As Object, e As EventArgs) - RegistraScript("$('#DivModalPersonaFisica').modal();") - End Sub - Protected Sub LnkActualizarPersonaFisica_Click(sender As Object, e As EventArgs) - Dim ObjCliente As New ClsClientes - - If ObjCliente.UpdateClientePersonaFisica(CveCliente, TxtApellidoPaternoPF.Text, TxtApellidoMaternoPF.Text, TxtNombrePF.Text) Then - Alert("El Cliente se ha actualizado correctamente.", TipoMensaje.MsgInformacion) - - TxtNombre.Text = $"{TxtNombrePF.Text} {TxtApellidoPaternoPF.Text} {TxtApellidoMaternoPF.Text}" - - TxtApellidoPaterno.Text = TxtApellidoPaternoPF.Text - TxtApellidoMaterno.Text = TxtApellidoMaternoPF.Text - TxtNombres.Text = TxtNombrePF.Text - - DivRazonSocial.Visible = False - DivPersonaFisica.Visible = True - - RegistraScript("$('#DivModalPersonaFisica').modal('hide');") - End If - - ObjCliente.Dispose() - UpDatos.Update() - End Sub -#End Region - -#Region "USUARIOS PLATAFORMA CLIENTE - 6 " - Protected Sub CargaUsuariosPortalCliente() - Dim objUsuario As ClsSisUsuarios = New ClsSisUsuarios - If objUsuario.GetUsuariosPortal(-1, CveCliente, -1) Then - GvUsuarios.DataSource = objUsuario.DtResultados.FiltraParametros($"CveEmpresa={UsuarioActual.CveEmpresa}") - GvUsuarios.DataBind() - End If - objUsuario.Dispose() - End Sub -#End Region - -#Region " DEVOLVER DINERO ANT/NC " - Private Sub InicializaDevolverDinero() - If UsuarioActual.TienePermisoProceso(247) Then - GVAnticipos.Columns(6).Visible = True - End If - End Sub -#End Region - -#Region "MODAL GRAFICA/PEDIDOS" - - Protected Sub LnkVerGrafica_Click(sender As Object, e As EventArgs) - If CargaDatatables() Then - RegistraScript("$('#DivModalGrafica').modal('show')") - CargaGrafica() - End If - End Sub - - Protected Sub LnkCancelar_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - Dim ObjCliente As New ClsClientes - If ObjCliente.UpdateEstatusPedido(gvRow.DataKey("CveVenta").ToEntero, 17, -1, UsuarioActual.CveUsuario) Then - Alert("Cancelado correctamente.") - CargaPedido() - End If - ObjCliente.Dispose() - End Sub - - - Private Sub CargaPedido() - Dim ObjCliente As New ClsClientes - If ObjCliente.GetClienteVentasPedido(CveCliente, UsuarioActual.CveEmpresa) Then - GvPedidos.DataSource = ObjCliente.DtResultados - End If - ObjCliente.Dispose() - GvPedidos.DataBind() - UpPedido.Update() - End Sub - - Protected Sub LnkAutorizar_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - Dim ObjCliente As New ClsClientes - ObjCliente.IniciaTransacSQL() - Dim ErrorTrans As Boolean = False - Dim CveU As Integer = 0 - Dim MsgAut As String = "" - - If ObjCliente.UpdateEstatusPedido(gvRow.DataKey("CveVenta").ToEntero, 16, gvRow.FCTextBox("TxtDiasCredito").Text.ToEntero, UsuarioActual.CveUsuario) Then - CveU = gvRow.DataKey("CveUsuario").ToEntero - MsgAut = String.Format(" Solicitud Autorizada {0} ", gvRow.DataKey("SerieFolio")) - 'If Not ObjCliente.UpdateFechaPedido(gvRow.DataKey("CveVenta").ToEntero, gvRow.FCTextBox("TxtDiasCredito").Text.ToEntero) Then - ' ErrorTrans = True - 'End If - Else - ErrorTrans = True - End If - If Not ErrorTrans Then - ObjCliente.Commit() - Alert("Autorizado correctamente.") - - If CveU > 0 Then ClsSisNotificaciones.SendNotificacionERP(CveU, MsgAut, MsgAut, 1) - - CargaPedido() - Else - ObjCliente.RollBack() - End If - ObjCliente.Dispose() - End Sub - Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) - If CargaDatatables() Then - CargaGrafica() - End If - End Sub - - Private Function CargaDatatables() As Boolean - Dim ObjClientes As New ClsClientes - If ObjClientes.GetClienteVencido(CveCliente, UsuarioActual.CveEmpresa, TxtFechaICredito.Text.ToDate, TxtFechaFCredito.Text.ToDate) Then - DtVencido = ObjClientes.DtResultados - End If - - If ObjClientes.GetRotacionCartera(CveCliente, UsuarioActual.CveEmpresa, TxtFechaICredito.Text.ToDate, TxtFechaFCredito.Text.ToDate) Then - DtRotacion = ObjClientes.DtResultados - End If - - If ObjClientes.GetClienteSaldoMensual(CveCliente, UsuarioActual.CveEmpresa, TxtFechaICredito.Text.ToDate, TxtFechaFCredito.Text.ToDate) Then - DtSaldoMensual = ObjClientes.DtResultados - End If - - If ObjClientes.GetClienteComportamientoVentaMensual(CveCliente, UsuarioActual.CveEmpresa, TxtFechaICredito.Text.ToDate, TxtFechaFCredito.Text.ToDate) Then - DtComportamientoVentas = ObjClientes.DtResultados - End If - - If ObjClientes.GetClienteVentasPedido(CveCliente, UsuarioActual.CveEmpresa) Then - GvPedidos.DataSource = ObjClientes.DtResultados - End If - - ObjClientes.Dispose() - GvPedidos.DataBind() - UpPedido.Update() - - Return True - End Function - - Private Sub CargaGrafica() - Dim FactVencida As Boolean = False - Dim Saldo As Double = 0 - Dim LimiteCredito As Double = 0 - If DtVencido.Rows.Count > 0 Then - Saldo = DtVencido.SUM("Saldo") - LimiteCredito = DtVencido.Rows(0)("LimiteCredito").ToString.ToDouble - LblVencido.Text = DtVencido.SUM("Total", "DiasVencidos > 0").FormatoNumero - LblPorVencer.Text = DtVencido.SUM("Total", "DiasVencidos <= 0").FormatoNumero - Else - LimiteCredito = TxtLimiteCredito.Text.ToDouble - LblVencido.Text = "0" - LblPorVencer.Text = "0" - End If - - Dim Dt As New DataTable() - Dt.Columns.Add("value") - For Each Dr As DataRow In DtVencido.Rows - Dim Row As DataRow = Nothing - Row = Dt.NewRow() - Row("value") = Dr("DiasVencidos").ToString - Dt.Rows.Add(Row) - If Dr("DiasVencidos").ToString.ToEntero > 0 And Dr("Saldo").ToString.ToDouble > 0 Then - FactVencida = True - End If - Next - - - Dim query = From s In Dt.AsEnumerable() Select New With {.date = "", .value = s("value").ToString()} - Dim json = Newtonsoft.Json.JsonConvert.SerializeObject(query) - RegistraScript($"CargaGraficaVencido({json})", "22") - - Dim Dt2 As New DataTable() - Dt2.Columns.Add("limite") - Dt2.Columns.Add("saldo") - Dim Row2 As DataRow = Nothing - Row2 = Dt2.NewRow() - LtlLimiteCreditoModal.Text = LimiteCredito.FormatoNumero - Row2("limite") = LimiteCredito - Saldo - Row2("saldo") = Saldo - Dt2.Rows.Add(Row2) - Dim query2 = From s In Dt2.AsEnumerable() Select New With {.year = "", .limite = s("limite").ToString(), .saldo = s("saldo").ToString()} - Dim json2 = Newtonsoft.Json.JsonConvert.SerializeObject(query2) - - RegistraScript($"CargaGraficaLimiteCredito({json2})", "33") - - If DtRotacion.Rows.Count > 0 Then - LblVentasModal.Text = DtRotacion.Rows(0)("Ventas").ToString.FormatoNumero - LblPagadoModal.Text = DtRotacion.Rows(0)("Pagado").ToString.FormatoNumero - LblRotacionModal.Text = DtRotacion.Rows(0)("Rotacion").ToString.FormatoNumero - LblDiasModal.Text = DtRotacion.Rows(0)("Dias").ToString.FormatoNumero - LblDiasCreditoModal.Text = DtRotacion.Rows(0)("DiasCredito").ToString.FormatoNumero - Else - LblVentasModal.Text = "0" - LblPagadoModal.Text = "0" - LblRotacionModal.Text = "0" - LblDiasModal.Text = "0" - LblDiasCreditoModal.Text = "0" - End If - - If FactVencida Or (Saldo > LimiteCredito) Then - LblEstatusModal.Text = "Vencido" - LblEstatusModal.ForeColor = Drawing.Color.Red - Else - LblEstatusModal.Text = "Al Corriente" - LblEstatusModal.ForeColor = Drawing.Color.Green - End If - - Dim Dt3 As New DataTable() - Dt3.Columns.Add("mes") - - Dim Dt4 As New DataTable() - Dt4.Columns.Add("balloonText") - Dt4.Columns.Add("bullet") - Dt4.Columns.Add("title") - Dt4.Columns.Add("valueField") - Dt4.Columns.Add("fillAlphas") - Dt4.Columns.Add("hidden") - - - Dim Cont As Integer = 1 - For Each Dr As DataRow In DtComportamientoVentas.Rows - Dt3.Columns.Add(Dr("Ano").ToString) - Dim Row4 As DataRow = Nothing - Row4 = Dt4.NewRow() - Row4("balloonText") = "Ventas [[category]]: [[value]]" - Row4("bullet") = "round" - Row4("title") = Dr("Ano").ToString - Row4("valueField") = Dr("Ano").ToString - Row4("fillAlphas") = 0 - Row4("hidden") = If(Cont > DtComportamientoVentas.Rows.Count - 3, False, True) - Dt4.Rows.Add(Row4) - Cont += 1 - Next - - Dim RowEnero As DataRow = Nothing - RowEnero = Dt3.NewRow() - Dim RowFebrero As DataRow = Nothing - RowFebrero = Dt3.NewRow() - Dim RowMarzo As DataRow = Nothing - RowMarzo = Dt3.NewRow() - Dim RowAbril As DataRow = Nothing - RowAbril = Dt3.NewRow() - Dim RowMayo As DataRow = Nothing - RowMayo = Dt3.NewRow() - Dim RowJunio As DataRow = Nothing - RowJunio = Dt3.NewRow() - Dim RowJulio As DataRow = Nothing - RowJulio = Dt3.NewRow() - Dim RowAgosto As DataRow = Nothing - RowAgosto = Dt3.NewRow() - Dim RowSeptiembre As DataRow = Nothing - RowSeptiembre = Dt3.NewRow() - Dim RowOctubre As DataRow = Nothing - RowOctubre = Dt3.NewRow() - Dim RowNoviembre As DataRow = Nothing - RowNoviembre = Dt3.NewRow() - Dim RowDiciembre As DataRow = Nothing - RowDiciembre = Dt3.NewRow() - For Each Dr As DataRow In DtComportamientoVentas.Rows - RowEnero(Dr("Ano").ToString) = Dr("Enero").ToString - RowEnero("mes") = "Enero" - RowFebrero(Dr("Ano").ToString) = Dr("Febrero").ToString - RowFebrero("mes") = "Febrero" - RowMarzo(Dr("Ano").ToString) = Dr("Marzo").ToString - RowMarzo("mes") = "Marzo" - RowAbril(Dr("Ano").ToString) = Dr("Abril").ToString - RowAbril("mes") = "Abril" - RowMayo(Dr("Ano").ToString) = Dr("Mayo").ToString - RowMayo("mes") = "Mayo" - RowJunio(Dr("Ano").ToString) = Dr("Junio").ToString - RowJunio("mes") = "Junio" - RowJulio(Dr("Ano").ToString) = Dr("Julio").ToString - RowJulio("mes") = "Julio" - RowAgosto(Dr("Ano").ToString) = Dr("Agosto").ToString - RowAgosto("mes") = "Agosto" - RowSeptiembre(Dr("Ano").ToString) = Dr("Septiembre").ToString - RowSeptiembre("mes") = "Septiembre" - RowOctubre(Dr("Ano").ToString) = Dr("Octubre").ToString - RowOctubre("mes") = "Octubre" - RowNoviembre(Dr("Ano").ToString) = Dr("Noviembre").ToString - RowNoviembre("mes") = "Noviembre" - RowDiciembre(Dr("Ano").ToString) = Dr("Diciembre").ToString - RowDiciembre("mes") = "Diciembre" - Next - Dt3.Rows.Add(RowEnero) - Dt3.Rows.Add(RowFebrero) - Dt3.Rows.Add(RowMarzo) - Dt3.Rows.Add(RowAbril) - Dt3.Rows.Add(RowMayo) - Dt3.Rows.Add(RowJunio) - Dt3.Rows.Add(RowJulio) - Dt3.Rows.Add(RowAgosto) - Dt3.Rows.Add(RowSeptiembre) - Dt3.Rows.Add(RowOctubre) - Dt3.Rows.Add(RowNoviembre) - Dt3.Rows.Add(RowDiciembre) - - RegistraScript($"CargaGraficaComportamientoVentas({Dt3.ToJson},{Dt4.ToJson.Replace($"{Chr(34)}True{Chr(34)}", "true").Replace($"{Chr(34)}False{Chr(34)}", "false")})", "44") - - Dim Dt5 As New DataTable() - Dt5.Columns.Add("mes") - - Dim Dt6 As New DataTable() - Dt6.Columns.Add("balloonText") - Dt6.Columns.Add("bullet") - Dt6.Columns.Add("title") - Dt6.Columns.Add("valueField") - Dt6.Columns.Add("fillAlphas") - Dt6.Columns.Add("hidden") - - Cont = 1 - For Each Dr As DataRow In DtSaldoMensual.Rows - Dt5.Columns.Add(Dr("Ano").ToString) - Dim Row6 As DataRow = Nothing - Row6 = Dt6.NewRow() - Row6("balloonText") = "Saldo [[category]]: [[value]]" - Row6("bullet") = "round" - Row6("title") = Dr("Ano").ToString - Row6("valueField") = Dr("Ano").ToString - Row6("fillAlphas") = 0 - Row6("hidden") = If(Cont > DtSaldoMensual.Rows.Count - 3, False, True) - Dt6.Rows.Add(Row6) - Cont += 1 - Next - RowEnero = Dt5.NewRow() - RowFebrero = Dt5.NewRow() - RowMarzo = Dt5.NewRow() - RowAbril = Dt5.NewRow() - RowMayo = Dt5.NewRow() - RowJunio = Dt5.NewRow() - RowJulio = Dt5.NewRow() - RowAgosto = Dt5.NewRow() - RowSeptiembre = Dt5.NewRow() - RowOctubre = Dt5.NewRow() - RowNoviembre = Dt5.NewRow() - RowDiciembre = Dt5.NewRow() - For Each Dr As DataRow In DtSaldoMensual.Rows - RowEnero(Dr("Ano").ToString) = Dr("Enero").ToString - RowEnero("mes") = "Enero" - RowFebrero(Dr("Ano").ToString) = Dr("Febrero").ToString - RowFebrero("mes") = "Febrero" - RowMarzo(Dr("Ano").ToString) = Dr("Marzo").ToString - RowMarzo("mes") = "Marzo" - RowAbril(Dr("Ano").ToString) = Dr("Abril").ToString - RowAbril("mes") = "Abril" - RowMayo(Dr("Ano").ToString) = Dr("Mayo").ToString - RowMayo("mes") = "Mayo" - RowJunio(Dr("Ano").ToString) = Dr("Junio").ToString - RowJunio("mes") = "Junio" - RowJulio(Dr("Ano").ToString) = Dr("Julio").ToString - RowJulio("mes") = "Julio" - RowAgosto(Dr("Ano").ToString) = Dr("Agosto").ToString - RowAgosto("mes") = "Agosto" - RowSeptiembre(Dr("Ano").ToString) = Dr("Septiembre").ToString - RowSeptiembre("mes") = "Septiembre" - RowOctubre(Dr("Ano").ToString) = Dr("Octubre").ToString - RowOctubre("mes") = "Octubre" - RowNoviembre(Dr("Ano").ToString) = Dr("Noviembre").ToString - RowNoviembre("mes") = "Noviembre" - RowDiciembre(Dr("Ano").ToString) = Dr("Diciembre").ToString - RowDiciembre("mes") = "Diciembre" - Next - Dt5.Rows.Add(RowEnero) - Dt5.Rows.Add(RowFebrero) - Dt5.Rows.Add(RowMarzo) - Dt5.Rows.Add(RowAbril) - Dt5.Rows.Add(RowMayo) - Dt5.Rows.Add(RowJunio) - Dt5.Rows.Add(RowJulio) - Dt5.Rows.Add(RowAgosto) - Dt5.Rows.Add(RowSeptiembre) - Dt5.Rows.Add(RowOctubre) - Dt5.Rows.Add(RowNoviembre) - Dt5.Rows.Add(RowDiciembre) - - - RegistraScript($"CargaGraficaCompratamientoSaldoMensual({Dt5.ToJson},{Dt6.ToJson.Replace($"{Chr(34)}True{Chr(34)}", "true").Replace($"{Chr(34)}False{Chr(34)}", "false")})", "55") - - UPModalProd.Update() - End Sub - - -#End Region - -#Region "TAB - COMPORTAMIENTO DE VENTAS" - - Private Sub CargaGrupo() - DdlGrupo.Items.Insert(0, New ListItem("Categoria", "3")) - DdlGrupo.Items.Insert(1, New ListItem("Clasificacion", "4")) - DdlGrupo.Items.Insert(2, New ListItem("Productos-Servicios", "5")) - DdlGrupo.Items.Insert(3, New ListItem("Año", "6")) - DdlGrupo.Items.Insert(4, New ListItem("Mes", "7")) - DdlGrupo.Items.Insert(5, New ListItem("Año/Mes", "8")) - DdlGrupo.Items.Insert(6, New ListItem("Fecha", "9")) - DdlGrupo.Items.Insert(7, New ListItem("Cliente", "10")) - DdlGrupo.Items.Insert(8, New ListItem("Vendedor", "12")) - DdlGrupo.Items.Insert(9, New ListItem("Usuario", "13")) - DdlGrupo.Items.Insert(10, New ListItem("Estatus Fact.", "14")) - DdlGrupo.Items.Insert(11, New ListItem("Año Ejec.", "15")) - DdlGrupo.Items.Insert(12, New ListItem("Mes Ejec.", "16")) - DdlGrupo.Items.Insert(13, New ListItem("Año/Mes Ejec.", "17")) - DdlGrupo.Items.Insert(14, New ListItem("Fecha Ejec.", "18")) - DdlGrupo.Items.Insert(15, New ListItem("Cliente - PS", "20")) - DdlGrupo.DataBind() - DdlGrupo.SelectedValueExist("8") - End Sub - - Private Sub CargaTipoCentroCosto() - - If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then - DdlSubProyectoFiltro.Items.Clear() - DivProyecto.Visible = False - LblProyecto.Visible = False - LblSubProyecto.InnerText = "Sucursal:" - DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) - DdlSubProyectoFiltro.Items.Insert(0, New ListItem("Todos", "-1")) - DdlSubProyectoFiltro.DataBind() - - DdlGrupo.Items.Insert(0, New ListItem("Sucursal", "2")) - DdlGrupo.Items.Insert(16, New ListItem("Sucursal Ejec.", "19")) - DdlGrupo.DataBind() - - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then - DdlSubProyectoFiltro.Items.Clear() - DivProyecto.Visible = False - LblProyecto.Visible = False - LblSubProyecto.InnerText = "Proyecto:" - DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) - DdlSubProyectoFiltro.Items.Insert(0, New ListItem("Todos", "-1")) - DdlSubProyectoFiltro.DataBind() - - DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "2")) - DdlGrupo.Items.Insert(16, New ListItem("Proyecto Ejec.", "19")) - DdlGrupo.DataBind() - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 3 Then - DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "1")) - DdlGrupo.Items.Insert(1, New ListItem("SubProyecto", "2")) - DdlGrupo.Items.Insert(17, New ListItem("SubProyecto Ejec.", "19")) - DdlGrupo.DataBind() - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then - LblProyecto.InnerText = "Sucursal:" - LblSubProyecto.InnerText = "Proyecto:" - - - DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "1")) - DdlGrupo.Items.Insert(1, New ListItem("SubProyecto", "2")) - DdlGrupo.Items.Insert(17, New ListItem("SubProyecto Ejec.", "19")) - DdlGrupo.DataBind() - - ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then - LblProyecto.InnerText = "Proyecto:" - LblSubProyecto.InnerText = "Sucursal:" - - DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "1")) - DdlGrupo.Items.Insert(1, New ListItem("SubProyecto", "2")) - DdlGrupo.Items.Insert(17, New ListItem("SubProyecto Ejec.", "19")) - DdlGrupo.DataBind() - End If - End Sub - - Private Sub CargaFiltros() - 'Cargo Proyectos - DdlProyecto.DataSource = GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1) - DdlProyecto.DataBind() - - 'Cargo Clasificaciones - DdlClasificacionFilto.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) - DdlClasificacionFilto.DataBind() - - 'CargaSubProyectos - DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) - DdlSubProyectoFiltro.DataBind() - - 'Vendedor - DdlVendedorFiltro.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa) - DdlVendedorFiltro.DataBind() - - 'CargaUsuarios - DdlUsuario.DataSource = GlobalDTUsuarios.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - DdlUsuario.DataBind() - - 'Carga Productos - DdlPSFiltro.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then - DdlPSFiltro.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacionFilto.SelectedValue) - DdlPSFiltro.SelectedText = "" - DdlPSFiltro.SelectedValue = "-1" - Else - DdlPSFiltro.ddl.Items.Clear() - DdlPSFiltro.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacionFilto.SelectedValue.ToEntero) - DdlPSFiltro.ddl.DataBind() - DdlPSFiltro.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) - End If - - CargaGrupo() - CargaTipoCentroCosto() - - End Sub - - Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged - CargaSubProyecto() - End Sub - - Private Sub CargaSubProyecto() - DdlSubProyectoFiltro.Items.Clear() - If DdlProyecto.SelectedValue <> "-1" Then - DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, DdlProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1, 1) - DdlSubProyectoFiltro.DataBind() - End If - DdlSubProyectoFiltro.Items.Insert(0, New ListItem("Todos", "-1")) - End Sub - - Protected Sub DdlClasificacionFilto_SelectedIndexChanged(sender As Object, e As EventArgs) - If UsuarioActual.Empresa.Funcionalidad(105) = "" Then - DdlPSFiltro.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacionFilto.SelectedValue.ToEntero) - DdlPSFiltro.DataBind() - DdlPSFiltro.ddl.Items.Insert(0, New ListItem("Todos", "-1")) - Else - DdlPSFiltro.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacionFilto.SelectedValue) - DdlPSFiltro.SelectedText = "Todos" - DdlPSFiltro.SelectedValue = "-1" - End If - End Sub - - Protected Sub GvComportamientoVenta_RowDataBound(sender As Object, e As GridViewRowEventArgs) - If e.Row.RowType = DataControlRowType.DataRow Then - - If DdlGrupo.SelectedValue.ToEntero = 20 Then - - If e.Row.DBCampo("PS").ToString = "" Then - e.Row.CssClass = "Totales" - End If - Else - If Not e.Row.DBCampo("CveVenta").ToEntero > 0 Then - e.Row.Cells(5).Text = e.Row.DBCampo("Gpo").ToString - e.Row.CssClass = "Totales" - - End If - End If - End If - End Sub - - Protected Sub BtnConsultarComportamiento_Click(sender As Object, e As EventArgs) - CargaGvComportamientoVenta() - End Sub - - Private Sub CargaGvComportamientoVenta() - Dim ObjVentas As New ClsVentas() - Dim FechaI, FechaF As Date - FechaI = If(IsDate(TxtFechaIFiltro.Text.Trim()), TxtFechaIFiltro.Text.ToDate, MinFecha) - FechaF = If(IsDate(TxtFechaFFiltro.Text.Trim()), TxtFechaFFiltro.Text.ToDate, MaxFecha) - - If ObjVentas.GetRepProductosServiciosDetalle(DdlProyecto.SelectedValue.ToEntero, DdlSubProyectoFiltro.SelectedValue.ToEntero, -1, DdlClasificacionFilto.SelectedValue.ToEntero, - DdlPSFiltro.SelectedValue.ToEntero, FechaI, FechaF, -1, MinFecha, MaxFecha, -1, - CveCliente, -1, DdlVendedorFiltro.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero, -1, - UsuarioActual.CveEmpresa, CveUsuarioConsulta:=UsuarioActual.CveUsuario, TipoDocto:="Ing", GPO:=DdlGrupo.SelectedValue.ToEntero) Then - GvComportamientoVenta.DataSource = ObjVentas.DtResultados - Else - GvComportamientoVenta.DataSource = Nothing - End If - - ObjVentas.Dispose() - GvComportamientoVenta.DataBind() - UpDatosComportamientoVenta.Update() - End Sub - -#End Region - -#Region "DISPOSITIVOS" - - Protected Sub LnkMoverDispositivo_Click(sender As Object, e As EventArgs) - Dim CveDispositivo As Integer = HdnCveDispositivoMover.Value.ToEntero() - Dim CveCliente As Integer = DdlClienteDispositivo.SelectedValue.ToEntero() - - If CveDispositivo <= 0 Then - Alert("Se debe seleccionar un dispositivo.", TipoMensaje.MsgAdvertencia) - Return - End If - If CveCliente <= 0 Then - Alert("Se debe seleccionar un cliente.", TipoMensaje.MsgAdvertencia) - Return - End If - Dim TieneError As Boolean = False - Dim ObjGPS = New ClsGPS() - Dim ObjEventos As New ClsOIEventos(ObjGPS.IniciaTransacSQL()) - - If ObjGPS.UpdateClienteDispositivo(CveDispositivo, CveCliente) Then - TieneError = Not ObjEventos.AddEventoBitacora($"Se movió el dispositivo: {NombreDispositivo} de cliente. Valor Anterior:{UsuarioActual.Empresa.Empresa}, {LtlCliente.Text} Valor Actual:{DdlEmpresaDispositivo.SelectedItem.Text}, {DdlClienteDispositivo.SelectedItem.Text}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=CveCliente) - Else - TieneError = True - End If - - If TieneError Then - ObjGPS.RollBack() - Alert($"Ocurrió un error al mover el dispostivo.", TipoMensaje.MsgError) - Else - ObjGPS.Commit() - Alert($"El dispositivo '{NombreDispositivo}' se movió correctamente.") - End If - - ObjGPS.Dispose() - ObjEventos.Dispose() - - CargaDispositivos(DdlEstatusDispositivos.SelectedValue.ToEntero()) - CargaEventoBitacora() - NombreDispositivo = "" - RegistraScript("$('#DivMoverDispositivo').modal('hide');") - End Sub - -#End Region - -#Region "CRM" - Protected Sub CargaDatosCRM() - Dim ObjCRM = New ClsCRM() - - If ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa, CveEmpresaCRM) And ObjCRM.DtResultados.Rows.Count > 0 Then - TxtNombre.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Empresa").ToString - TxtNombreComercial.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Empresa").ToString - TxtRFC.Text = ObjCRM.DtResultados.FiltroPrimeroValor("RFC").ToString - - TxtEmail.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Correo").ToString - TxtEmailCotizacion.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Correo").ToString - - DdlVendedor.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveVendedorAsignado").ToString) - DdlSubProyecto.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveSubProyecto").ToString) - Else - Alert("La empresa CRM solicitada no existe, porfavor verifique", TipoMensaje.MsgAdvertencia) - CveEmpresaCRM = -1 - End If - ObjCRM.Dispose() - End Sub - - Protected Sub VerificaVinculacion() - Dim ObjCRM = New ClsCRM() - - If ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa, -1) And ObjCRM.DtResultados.Rows.Count > 0 Then - If ObjCRM.DtResultados.FiltraParametros(String.Format("CveCliente = {0}", CveCliente)).Rows.Count > 0 Then - LiLnkUnificarCRM.Visible = False - Else - LiLnkUnificarCRM.Visible = True - End If - End If - ObjCRM.Dispose() - End Sub - - Protected Function VincularEmpresaCRM() As Boolean - Dim Ok As Boolean = False - Dim ObjCRM = New ClsCRM() - Dim ObjBitacora = New ClsOIEventos(ObjCRM.IniciaTransacSQL()) - If (CveCliente > 0) Then - - Dim CveEmpresaCRMVincular As Integer = If(CveEmpresaCRM > 0, CveEmpresaCRM, If(CveEmpresaCRMUnificar > 0, CveEmpresaCRMUnificar, -1)) - - If ObjCRM.UpdateEmpresCRM("-2", "-2", -2, CveEmpresaCRMVincular, -2, UsuarioActual.CveUsuario, CveCliente, -1, "-1") Then - If CveEmpresaCRM > 0 Then - ObjBitacora.AddEventoBitacora(String.Format("Se Creó el Cliente: {0} a partir de la Empresa CRM", TxtNombre.Text), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM:=CveEmpresaCRM) - End If - If CveEmpresaCRMUnificar > 0 Then - ObjBitacora.AddEventoBitacora(String.Format("Se Unificó el Cliente: {0} con la Empresa CRM", TxtNombre.Text), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM:=CveEmpresaCRMUnificar) - End If - Ok = True - End If - End If - - If (Ok) Then - ObjCRM.Commit() - Else - ObjCRM.RollBack() - End If - ObjCRM.Dispose() - ObjBitacora.Dispose() - - Return Ok - End Function - - Protected Sub CargaModalEmpresasCRM() - Dim ObjCRM = New ClsCRM() - - If (ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa) And ObjCRM.DtResultados.Rows.Count > 0) Then - DtEmpresasCRM = ObjCRM.DtResultados.FiltraParametros(String.Format("CveCliente IS NULL")) - GvEmpresasCRM.DataSource = DtEmpresasCRM - End If - ObjCRM.Dispose() - GvEmpresasCRM.DataBind() - UpEmpresasCRM.Update() - End Sub - - Protected Sub LnkUnificarCRM_Click(sender As Object, e As EventArgs) - CveEmpresaCRMUnificar = -1 - CargaModalEmpresasCRM() - RegistraScript("$('#DivModalUnificarCRM').modal();") - End Sub - - Protected Sub BtnUnificarCRM_Click(sender As Object, e As EventArgs) - For Each row As GridViewRow In GvEmpresasCRM.Rows - Dim chkSeleccionado As RadioButton = CType(row.FindControl("RBSeleccion"), RadioButton) - If chkSeleccionado.Checked Then - CveEmpresaCRMUnificar = row.DataKey("CveEmpresaCRM").ToEntero - End If - Next - - If CveEmpresaCRMUnificar > 0 Then - If (VincularEmpresaCRM()) Then - LiLnkUnificarCRM.Visible = False - UpAccionesCRM.Update() - - RegistraScript("$('#DivModalUnificarCRM').modal('hide');") - Alert("Se Unificó correctamente al Cliente con la Empresa CRM.") - End If - End If - End Sub -#End Region - -#Region "PORCENTAJE PRECIO DE MARCAS" - Private Sub LnkPorcentajeMarcas_Click(sender As Object, e As EventArgs) Handles LnkPorcentajeMarcas.Click - RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajeMarcas")) - - CreaDT() - - CargaMarcas() - LimpiaModalPorcentaje() - End Sub - Private Sub CreaDT() - Dim DTPorcentajeTemp As New DataTable - - Dim column As DataColumn = New DataColumn("No") - column.DataType = Type.GetType("System.Int32") - With column - .AutoIncrement = True - .AutoIncrementSeed = 1 - .AutoIncrementStep = 1 - End With - - DTPorcentajeTemp.Columns.Add(column) - DTPorcentajeTemp.Columns.Add("CveMarca", GetType(Integer)) - DTPorcentajeTemp.Columns.Add("Marca", GetType(String)) - DTPorcentajeTemp.Columns.Add("PorcentajeProducto", GetType(Decimal)) - DTPorcentajeTemp.Columns.Add("PorcentajeProducto2", GetType(Decimal)) - DTPorcentajeTemp.Columns.Add("PorcentajeProducto3", GetType(Decimal)) - DTPorcentajeTemp.Columns.Add("ProntoPago", GetType(Decimal)) - DTPorcentajeTemp.Columns.Add("Plazo", GetType(Integer)) - DTPorcentajeTemp.Columns.Add("Estatus", GetType(String)) - DTPorcentajePrecios = DTPorcentajeTemp.Clone - End Sub - Private Sub CargaMarcas() - Dim ObjMarcas As New ClsProductosServicios - ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa) - DdlMarcaPS.DataSource = ObjMarcas.DtResultados - ObjMarcas.Dispose() - DdlMarcaPS.DataBind() - DdlMarcaPS.Items.Insert(0, New ListItem("Seleccione", "-1")) - - CargaGridPorcentajes() - UpPorcentaje.Update() - End Sub - - Private Sub CargaGridPorcentajes() - Dim ObjPS As New ClsProductosServicios - - If ObjPS.GetPorcentajeMarcas(CveCliente) Then - DTPorcentajePrecios = ObjPS.DtResultados - GvM.DataSource = DTPorcentajePrecios - End If - ObjPS.Dispose() - - GvM.DataBind() - UppGrid.Update() - - End Sub - Private Sub CargaDTPorcentajePrecios(DtTemp As DataTable) - GvM.DataSource = DtTemp - GvM.DataBind() - - UppGrid.Update() - End Sub - - Private Sub LimpiaModalPorcentaje() - txtPorcentaje.Text = "" - txtPorcentaje2.Text = "" - txtPorcentaje3.Text = "" - txtProntoPago.Text = "" - txtPlazo.Text = "" - DdlMarcaPS.SelectedValue = "-1" - End Sub - - Protected Sub LbAgregarMarca_Click(sender As Object, e As EventArgs) Handles LbAgregarMarca.Click - If txtPorcentaje.Text.ToDecimal > 0 And txtPorcentaje.Text.ToDecimal <= 100 And txtPorcentaje2.Text.ToDecimal >= 0 And txtPorcentaje2.Text.ToDecimal <= 100 And txtPorcentaje3.Text.ToDecimal >= 0 And txtPorcentaje3.Text.ToDecimal <= 100 Then - - Dim registro As DataRow = DTPorcentajePrecios.NewRow - - registro.Item("No") = DTPorcentajePrecios.Rows.Count + 1 - registro.Item("CveMarca") = DdlMarcaPS.SelectedValue.ToEntero - registro.Item("Marca") = DdlMarcaPS.SelectedItem.Text - registro.Item("PorcentajeProducto") = txtPorcentaje.Text.ToDecimal - registro.Item("PorcentajeProducto2") = txtPorcentaje2.Text.ToDecimal - registro.Item("PorcentajeProducto3") = txtPorcentaje3.Text.ToDecimal - registro.Item("ProntoPago") = txtProntoPago.Text.ToDecimal - registro.Item("Plazo") = txtPlazo.Text.ToEntero - registro.Item("Estatus") = "I" - DTPorcentajePrecios.Rows.Add(registro) - CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - Else - Alert("El Porcentaje debe estar en un rango mayor a 0 y menor o igual a 100", TipoMensaje.MsgAdvertencia) - End If - - LimpiaModalPorcentaje() - End Sub - - Protected Sub DeleteRowMarca(sender As Object, e As EventArgs) - - Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) - - - If DTPorcentajePrecios.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then - Dim i As Integer - i = lnkRemove.CommandArgument.ToString.ToEntero - Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", i)) - If Drs.Count > 0 Then - If CveCliente > 0 AndAlso Drs(0)("CveMarca").ToString.ToEntero > 0 Then - Drs(0)("Estatus") = "D" - Else - Drs(0).Delete() - End If - - End If - DTPorcentajePrecios.AcceptChanges() - End If - - GvM.EditIndex = -1 - - CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - - End Sub - - Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvM.RowEditing - GvM.EditIndex = e.NewEditIndex - - CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - End Sub - Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvM.RowCancelingEdit - GvM.EditIndex = -1 - - CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - End Sub - Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvM.RowUpdating - - Dim PorcentajeProducto As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP").Text.ToDouble - Dim PorcentajeProducto2 As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP2").Text.ToDouble - Dim PorcentajeProducto3 As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP3").Text.ToDouble - Dim ProntoPago As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtProntoPagoP").Text.ToDouble - Dim Plazo As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPlazoP").Text.ToDouble - - If PorcentajeProducto > 0 And PorcentajeProducto <= 100 And PorcentajeProducto2 >= 0 And PorcentajeProducto2 <= 100 And PorcentajeProducto3 >= 0 And PorcentajeProducto3 <= 100 Then - Dim No As Integer = GvM.Rows(e.RowIndex).DataKey("No").ToEntero - - Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", No)) - - If Drs.Count > 0 Then - Drs(0)("PorcentajeProducto") = PorcentajeProducto - Drs(0)("PorcentajeProducto2") = PorcentajeProducto2 - Drs(0)("PorcentajeProducto3") = PorcentajeProducto3 - Drs(0)("ProntoPago") = ProntoPago - Drs(0)("Plazo") = Plazo - If Drs(0)("Estatus").ToString <> "I" Then - Drs(0)("Estatus") = "U" - End If - End If - - DTPorcentajePrecios.AcceptChanges() - GvM.EditIndex = -1 - - CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - Else - Alert("El Porcentaje debe estar en un rango mayor a 0 y menor o igual a 100", TipoMensaje.MsgAdvertencia) - End If - - End Sub - - Protected Sub BtnGuardarPorcentajesMarca_Click(sender As Object, e As EventArgs) Handles BtnGuardarPorcentajesMarca.Click - - Dim TieneError As Boolean = False - - Dim ObjPS As New ClsProductosServicios - ObjPS.IniciaTransacSQL() - - For Each Dr As DataRow In DTPorcentajePrecios.Rows - - If Dr("Estatus").ToString <> "" Then - - If Dr("Estatus").ToString = "I" Then - If Not ObjPS.AddPorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal, Dr("PorcentajeProducto2").ToString.ToDecimal, Dr("PorcentajeProducto3").ToString.ToDecimal, UsuarioActual.CveUsuario, Dr("ProntoPago").ToString.ToDecimal, Dr("Plazo").ToString.ToEntero) Then - TieneError = True - End If - ElseIf Dr("Estatus").ToString = "U" Then - If Not ObjPS.UpdatePorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal, Dr("PorcentajeProducto2").ToString.ToDecimal, Dr("PorcentajeProducto3").ToString.ToDecimal, Dr("ProntoPago").ToString.ToDecimal, Dr("Plazo").ToString.ToEntero) Then - TieneError = True - End If - ElseIf Dr("Estatus").ToString = "D" Then - If Not ObjPS.RemovePorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero) Then - TieneError = True - End If - End If - - End If - Next - - If TieneError Then - ObjPS.RollBack() - Else - ObjPS.Commit() - Alert("Los Porcentajes se guardaron correctamente.", TipoMensaje.MsgInformacion) - RegistraScript("$('#DivPorcentajeMarcas').modal('hide')", "hidemodal") - End If - - ObjPS.Dispose() - - End Sub -#End Region - -#Region "PORCENTAJE PRECIO DE PRODUCTOS" - Private Sub LnkPorcentajePrecios_Click(sender As Object, e As EventArgs) Handles LnkPorcentajePrecios.Click - RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajePrecios")) - - CreaDT2() - - TxtPorcentajePS.Attributes.Add("onchange", String.Format("FnCambiaPorcentaje({0});", "5")) - CargaPorcentajesProductos() - LimpiaModalPorcentaje2() - End Sub - Private Sub CreaDT2() - Dim DTPorcentajeTemp As New DataTable - - Dim column As DataColumn = New DataColumn("No") - column.DataType = Type.GetType("System.Int32") - With column - .AutoIncrement = True - .AutoIncrementSeed = 1 - .AutoIncrementStep = 1 - End With - - DTPorcentajeTemp.Columns.Add(column) - DTPorcentajeTemp.Columns.Add("CvePS", GetType(Integer)) - DTPorcentajeTemp.Columns.Add("Producto", GetType(String)) - DTPorcentajeTemp.Columns.Add("PrecioG", GetType(Decimal)) - DTPorcentajeTemp.Columns.Add("PorcentajeProducto", GetType(Decimal)) - DTPorcentajeTemp.Columns.Add("PrecioA", GetType(Decimal)) - DTPorcentajeTemp.Columns.Add("Estatus", GetType(String)) - DTPorcentajePrecios = DTPorcentajeTemp.Clone - End Sub - Private Sub CargaPorcentajesProductos() - 'Llenar el dropdownlist de Secciones - If UsuarioActual.CveEmpresa = 66 Then - DdlClasificacion2.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") - Else - Dim ObjClasificaciones As New ClsClasificaciones - If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then - DdlClasificacion2.DataSource = ObjClasificaciones.DtResultados - End If - ObjClasificaciones.Dispose() - End If - DdlClasificacion2.DataBind() - - CargaPS() - CargaGridPorcentajes2() - - UpPorcentajeP.Update() - End Sub - Private Sub CargaPS() - DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - - If UsuarioActual.CveEmpresa = 66 Then - DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios") - End If - - If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then - DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2") - - DdlProducto2.DataBind() - - DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - - End Sub - - Protected Sub DdlProducto2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlProducto2.selectedindexchange - DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2) - End Sub - Private Sub DdlProducto2IndexChange(CvePSParametro As Integer, Ddl As ADServerControl.Dropdownlost) - Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("") - - If drPS IsNot Nothing Then - Dim Precio = drPS("Precio").ToString.ToDouble - LbPrecioG.Text = Precio.FormatoNumero() - LbPrecioA.Text = ((Precio * TxtPorcentajePS.Text.ToDecimal) / 100).FormatoNumero - End If - End Sub - - Private Sub CargaGridPorcentajes2() - Dim ObjPS As New ClsProductosServicios - - If ObjPS.GetPorcentajeProductos(CveCliente) Then - DTPorcentajePrecios = ObjPS.DtResultados - GvP.DataSource = DTPorcentajePrecios - End If - ObjPS.Dispose() - - GvP.DataBind() - UpPorcentajePS.Update() - - End Sub - Private Sub CargaDTPorcentajePrecios2(DtTemp As DataTable) - GvP.DataSource = DtTemp - GvP.DataBind() - - UpPorcentajePS.Update() - End Sub - - Private Sub LimpiaModalPorcentaje2() - TxtPorcentajePS.Text = "" - DdlClasificacion2.SelectedValue = "-1" - DdlProducto2.SelectedText = "" - End Sub - - Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click - - If DdlProducto2.SelectedText <> "" Then - If TxtPorcentajePS.Text.ToDecimal >= 0 And TxtPorcentajePS.Text.ToDecimal <= 100 Then - - Dim registro As DataRow = DTPorcentajePrecios.NewRow - - registro.Item("No") = DTPorcentajePrecios.Rows.Count + 1 - registro.Item("CvePS") = DdlProducto2.SelectedValue.ToEntero - registro.Item("Producto") = DdlProducto2.SelectedText - registro.Item("PrecioG") = LbPrecioG.Text.ToDecimal - registro.Item("PrecioA") = LbPrecioG.Text.ToDecimal * TxtPorcentajePS.Text.ToDecimal / 100 - registro.Item("PorcentajeProducto") = TxtPorcentajePS.Text.ToDecimal - registro.Item("Estatus") = "I" - DTPorcentajePrecios.Rows.Add(registro) - CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - Else - Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia) - End If - Else - Alert("El campo ''Producto'' es necesario, por favor ingréselo.", TipoMensaje.MsgAdvertencia) - End If - - LimpiaModalPorcentaje() - End Sub - - Protected Sub DeleteRow(sender As Object, e As EventArgs) - - Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) - - - If DTPorcentajePrecios.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then - Dim i As Integer - i = lnkRemove.CommandArgument.ToString.ToEntero - Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", i)) - If Drs.Count > 0 Then - If CveCliente > 0 AndAlso Drs(0)("CvePS").ToString.ToEntero > 0 Then - Drs(0)("Estatus") = "D" - Else - Drs(0).Delete() - End If - - End If - DTPorcentajePrecios.AcceptChanges() - End If - - GvP.EditIndex = -1 - - CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - - End Sub - - Protected Sub GvP_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvP.RowEditing - GvP.EditIndex = e.NewEditIndex - - CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - End Sub - Protected Sub GvP_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvP.RowCancelingEdit - GvP.EditIndex = -1 - - CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - End Sub - Protected Sub GvP_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvP.RowUpdating - - Dim PorcentajeProducto As Double = GvP.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP").Text.ToDouble - - If PorcentajeProducto >= 0 And PorcentajeProducto <= 100 Then - Dim No As Integer = GvP.Rows(e.RowIndex).DataKey("No").ToEntero - - Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", No)) - - If Drs.Count > 0 Then - Drs(0)("PorcentajeProducto") = PorcentajeProducto - Drs(0)("PrecioA") = Drs(0)("PrecioG").ToString.ToDouble * PorcentajeProducto / 100 - If Drs(0)("Estatus").ToString <> "I" Then - Drs(0)("Estatus") = "U" - End If - End If - - DTPorcentajePrecios.AcceptChanges() - GvP.EditIndex = -1 - - CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) - Else - Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia) - End If - - End Sub - - Protected Sub BtnGuardarPorcentajes_Click(sender As Object, e As EventArgs) Handles BtnGuardarPorcentajes.Click - - Dim TieneError As Boolean = False - - Dim ObjPS As New ClsProductosServicios - ObjPS.IniciaTransacSQL() - - For Each Dr As DataRow In DTPorcentajePrecios.Rows - - If Dr("Estatus").ToString <> "" Then - - If Dr("Estatus").ToString = "I" Then - If Not ObjPS.AddPorcentajeProductos(CveCliente, Dr("CvePS").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal, UsuarioActual.CveUsuario) Then - TieneError = True - End If - ElseIf Dr("Estatus").ToString = "U" Then - If Not ObjPS.UpdatePorcentajeProductos(CveCliente, Dr("CvePS").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal) Then - TieneError = True - End If - ElseIf Dr("Estatus").ToString = "D" Then - If Not ObjPS.RemovePorcentajeProductos(CveCliente, Dr("CvePS").ToString.ToEntero) Then - TieneError = True - End If - End If - - End If - Next - - If TieneError Then - ObjPS.RollBack() - Else - ObjPS.Commit() - Alert("Los Porcentajes se guardaron correctamente.", TipoMensaje.MsgInformacion) - RegistraScript("$('#DivPorcentajePrecios').modal('hide')", "hidemodal") - End If - - ObjPS.Dispose() - - End Sub - - Protected Sub BtnCambiaPorcentaje_Click(sender As Object, e As EventArgs) - DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2) - End Sub -#End Region - -#Region " A C U M U L A D O R E S" - - - Protected Sub LnkFacturaUsadosCargos_Click(sender As Object, e As EventArgs) - 'CveVentaNota = 0 - - 'Dim Cargos As Decimal = 0D - 'Dim Iva As Decimal = 0D - - 'For Each GvRow As GridViewRow In GvAcum.Rows - - ' If GvRow.DataKey("CveConcepto").ToEntero = 1 And GvRow.FCCheckBox("ChkCargo").Checked Then - ' Cargos = Cargos + GvRow.DataKey("ImporteCargo").ToDecimal - ' End If - 'Next - - 'Dim CvePS As Integer = UsuarioActual.Empresa.Funcionalidad(534).ToEntero 'CvePS Distruibuidor Cargo Nota - 'Dim CveUnidadMedida As Integer - 'Dim CveClasificacion As Integer - - 'If CvePS > 0 Then - - ' If Cargos > 0 Then - - ' CveUnidadMedida = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveUnidadMedida").ToString.ToEntero - ' CveClasificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveClasificacion").ToString.ToEntero - ' Iva = Cargos * 0.16D - - ' If GenerarNotaCredito(CvePS, 1, CveUnidadMedida, Cargos, Iva, "Clientes/Usados", CveClasificacion) Then - ' Alert($"LA nota de crédito fue generada correctamente {SerieNotaAcumulador}-{FolioNotaAcumulador}") - ' Else - ' Alert("Se presento un error al generar la nota de creédito", TipoMensaje.MsgError) - ' End If - ' End If - - 'Else - ' Alert("No esta asignada la funcionalidad CvePS Distruibuidor Cargo Nota") - 'End If - - CreaObjetosVenta(1) - - 'If ObjFactura.CveCliente > 0 Then - ' If TmpDT.Rows.Count > 0 Then - ' Dim Retorno = ObjFactura.EmitirFactura(false) - ' For Each Mensaje In Retorno.Mensajes - ' Alert(Mensaje, If(Retorno.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion)) - ' Next - ' End If - 'End If - - CargaUsados() - - End Sub - Protected Sub LnkFacturaUsadosBonificacion_Click(sender As Object, e As EventArgs) - - 'CveVentaNota = 0 - 'Dim Bonificacion As Decimal = 0D - 'Dim Iva As Decimal = 0D - - 'For Each GvRow As GridViewRow In GvAcum.Rows - ' If GvRow.DataKey("CveConcepto").ToEntero = 1 And GvRow.FCCheckBox("ChkBonificacion").Checked Then - ' Bonificacion = Bonificacion + GvRow.DataKey("ImporteBonificacion").ToDecimal - ' End If - 'Next - - - 'Dim CvePS As Integer = UsuarioActual.Empresa.Funcionalidad(534).ToEntero 'CvePS Distruibuidor Bonificación Nota - 'Dim CveUnidadMedida As Integer - 'Dim CveClasificacion As Integer - 'If CvePS > 0 Then - ' If Bonificacion > 0 Then - - ' CveUnidadMedida = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveUnidadMedida").ToString.ToEntero - ' CveClasificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveClasificacion").ToString.ToEntero - ' Iva = Bonificacion * 0.16D - - ' If GenerarNotaCredito(CvePS, 2, CveUnidadMedida, Bonificacion, Iva, "Clientes/Usados", CveClasificacion) Then - ' Alert($"LA nota de crédito fue generada correctamente {SerieNotaAcumulador}-{FolioNotaAcumulador}") - ' Else - ' Alert("Se presento un error al generar la nota de creédito", TipoMensaje.MsgError) - ' End If - - ' End If - - 'Else - ' Alert("No esta asignada la funcionalidad CvePS Distruibuidor Bonificación Nota") - 'End If - - CreaObjetosVenta(2) - - If ObjFactura.CveCliente > 0 Then - If TmpDT.Rows.Count > 0 Then - Dim Retorno = ObjFactura.EmitirFactura(False) - For Each Mensaje In Retorno.Mensajes - Alert(Mensaje, If(Retorno.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion)) - Next - End If - End If - - Alert("Listo") - - CargaUsados() - - - End Sub - - - Function FolioNotaCredito(Tipo As Integer) As Boolean - - FolioNotaAcumulador = 0 - SerieNotaAcumulador = "" - Dim Respuesta As Boolean = False - - Dim ObjFolios As New ClsGralFolios() - - Dim DTSucursales As DataTable = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ") - - If DTSucursales.Rows.Count > 0 Then - - If ObjFolios.GetFolios("RNC", UsuarioActual.CveEmpresa) Then - Dim CveSubProyecto As Integer = DTSucursales.FiltroPrimeroValor("CveSubProyecto", "").ToEntero - Dim DT As DataTable - If CveSubProyecto > 0 Then - DT = ObjFolios.DtResultados.FiltraParametros(" Estado = 'Activo' AND LEN(Serie) > 0 AND CveSubProyecto = " & CveSubProyecto) - Else - DT = ObjFolios.DtResultados.FiltraParametros(" Estado = 'Activo' AND LEN(Serie) > 0 ") - End If - - If DT.Rows.Count > 0 Then - FolioNotaAcumulador = DT.Rows(0)("FActual").ToString.ToEntero - SerieNotaAcumulador = DT.Rows(0)("Serie").ToString - Respuesta = True - End If - - End If - End If - - ObjFolios.Dispose() - - Return Respuesta - - End Function - - Private Sub GvAcum_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAcum.RowDataBound - - If e.Row.RowType = DataControlRowType.DataRow Then - - If e.Row.DataKey("CveConcepto").ToEntero = 1 Then - - Dim FacturadoCargo As Boolean = Boolean.Parse(e.Row.DataKey("FacturadoCargo")) - Dim FacturadoBonificacion As Boolean = Boolean.Parse(e.Row.DataKey("FacturadoBonificacion")) - - If FacturadoCargo Then - e.Row.FCCheckBox("ChkCargo").Checked = False - e.Row.FCCheckBox("ChkCargo").Visible = False - Else - e.Row.FCCheckBox("ChkCargo").Checked = False + End Sub + + Protected Sub GvDocumentosFirma_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDocumentosCliente.RowDataBound + + + If e.Row.RowType = DataControlRowType.DataRow Then + + Dim Adjunto As String = e.Row.DBCampo("Adjunto").ToString + Dim ImgDownLoadFormato As LinkButton = e.Row.FCLinkButton("ImgDownLoadFormato") + 'Dim ImgDownLoad As Literal = e.Row.FCLiteral("ImgDownLoad") + Dim LnkDownLoadDoc As LinkButton = e.Row.FCLinkButton("LnkDownLoadDoc") + Dim ImgRequired As Literal = e.Row.FCLiteral("ImgRequired") + Dim txtFechaLimite As TextBox = e.Row.FCTextBox("TxtFechaLimite") + Dim requerido As Boolean = If(e.Row.DBCampo("Requerido").ToUpper = "TRUE", True, False) + Dim chkEstatus As CheckBox = e.Row.FCCheckBox("chkEstatus") + Dim documentacionFormato As String = e.Row.DBCampo("DocumentacionFormato").ToString + Dim Documentacion As String = e.Row.DBCampo("Documentacion").ToString + Dim _CveDocumentacion As Integer = e.Row.DBCampo("CveDocumentacion").ToString.ToEntero + Dim separado As Char() = ".".ToString.ToCharArray + Dim array() As String = Adjunto.Split(separado) + Dim extencion As String = "" + Dim existeAdjunto As Boolean = False + Dim TxtFechaVigencia As TextBox = e.Row.FCTextBox("TxtFechaVigencia") + + Dim imgCalendario As LinkButton = e.Row.FCLinkButton("imgCalendario") + + + + + + + ' FechaVigencia + + Dim DiasLimite As Integer = e.Row.DataKey("DiasLimite").ToString.ToEntero + Dim AplicaDiasLimite As Boolean = If(e.Row.DataKey("AplicaDiasLimite").ToString = "1", True, False) + Dim AplicaFechaVencimiento As Boolean = If(e.Row.DataKey("AplicaFechaVencimiento").ToString = "1", True, False) + + txtFechaLimite.Visible = If(AplicaDiasLimite, True, False) + TxtFechaVigencia.Visible = If(AplicaFechaVencimiento, True, False) + imgCalendario.Visible = If(AplicaFechaVencimiento, True, False) + + + 'Dim scripMascara = " $('#" & TxtFechaVigencia.ClientID & "').mask('00/00/0000');" + ' RegistraScript(scripMascara) + + If TxtFechaVigencia.Text.Length = 10 Then + TxtFechaVigencia.Text = TxtFechaVigencia.Text.ToDate.ToString("dd/MM/yyyy") + End If + + If array.Length > 0 Then + extencion = array(array.Length - 1) + End If + + If e.Row.DBCampo("Estatus").ToString.ToEntero = 1 Then + chkEstatus.Checked = True + Else + chkEstatus.Checked = False + End If + + If documentacionFormato = "" Then + 'ImgDownLoadFormato.Visible = False + LnkDownLoadDoc.Visible = False + Else + Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "/Formatos/" & CveDocumentacion & "" & documentacionFormato + LnkDownLoadDoc.Visible = True + End If + + txtFechaLimite.Text = e.Row.DBCampo("FechaLimite").ToString.ToDate.ToString("dd/MM/yyyy") + + If Adjunto.Trim.Length > 0 Then + + Dim linkDescarga = "/Empresas/" & UsuarioActual.Empresa.CveEmpresa & "\DocElectronica\Clientes\" & CveCliente & "/" & Adjunto + Dim linkDescargaArchivo = UsuarioActual.Empresa.Ruta & "\DocElectronica\Clientes\" & CveCliente & "/" & Adjunto + + If File.Exists(linkDescargaArchivo) Then + + LnkDownLoadDoc.Visible = True + ScriptManager.GetCurrent(Me).RegisterPostBackControl(LnkDownLoadDoc) + 'If extencion.Length > 0 Then + ' ImgDownLoad.Text = String.Format(" ", linkDescarga, CveCliente & Documentacion & "." & extencion) + 'Else + ' ImgDownLoad.Text = String.Format(" ", linkDescarga, CveCliente & Documentacion) + 'End If + Else + LnkDownLoadDoc.Visible = False + End If + Else + LnkDownLoadDoc.Visible = False + End If + + If requerido Then + ImgRequired.Text = " " + Else + ' ImgRequired.Text = " " + End If + + If UsuarioActual.TienePermisoProceso(248) And e.Row.DBCampo("Estatus").ToString.ToEntero = 1 And LnkDownLoadDoc.Visible Then + e.Row.FCLinkButton("LnkGvDocumentosEliminar").Visible = True + End If + + End If + + End Sub + Public Sub DownLoadFormato_ClickDocumentacion(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + + Dim CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToString.ToEntero + Dim DocumentacionFormato As String = CveDocumentacion & "_" & GvRow.DataKey("DocumentacionFormato") + + DescarFormato(DocumentacionFormato) + + End Sub + 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\" & documento + pathDesti = PathRoot & "Temp\" & CveCliente & documento + + If File.Exists(pathDesti) Then + File.Delete(pathDesti) + End If + + File.Copy(PathSource, pathDesti) + + Dim objDoc As New clsGemBoxDocument(pathDesti) + Dim objRH As New ClsRH + Dim FechaActual As String = Now.Day.ToString("0#") & " de " & CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1).ToString & " del " & Now.Year.ToString() + + + objDoc.SustituirTags(objRH.GetDatosTagsDocumentos(-1, UsuarioActual.CveEmpresa)) ' Pendiente + objRH.Dispose() + + + + objDoc.Guardar(pathDesti) + + Dim fileinfo As New FileInfo(pathDesti) + + Dim baseUrl As String = Request.Url.GetLeftPart(UriPartial.Authority) + baseUrl = baseUrl & "/temp/" & fileinfo.Name + + RegistraDescargaJavaScript(baseUrl) + + End Sub + + + + 'Private Function GetDatosTagsDocumentos() As List(Of TagsDocumentos) + ' Dim ListaTagsDocumentost = New List(Of TagsDocumentos) + + ' If CvePersonal <> -1 Then + ' Dim objRH As New ClsRH + + + + ' If objRH.PersonalReclutamientoGet(CvePersonal, UsuarioActual.Empresa.CveEmpresa) Then + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Nombres}", objRH.DtResultados(0)("Nombres").ToString)) + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{APaterno}", objRH.DtResultados(0)("APaterno").ToString)) + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{AMaterno}", objRH.DtResultados(0)("AMaterno").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{RFC}", objRH.DtResultados(0)("RFC").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{NombreCompleto}", Cliente)) + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Estatura}", objRH.DtResultados(0)("Estatura").ToString)) + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Peso}", objRH.DtResultados(0)("Peso").ToString)) + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{LugarNacimiento}", objRH.DtResultados(0)("LugarNacimiento").ToString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Edad}", objRH.DtResultados(0)("Edad").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{NombreTelEmergencia}", objRH.DtResultados(0)("NombreTelEmergencia").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{TipoSangre}", objRH.DtResultados(0)("TipoSangre").ToString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Vivienda}", objRH.DtResultados(0)("Vivienda").ToString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{ViviendaDueno}", objRH.DtResultados(0)("ViviendaDueno").ToString)) + + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{CreditoInfonavit}", objRH.DtResultados(0)("CreditoInfonavit").ToString)) + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{RentaMensual}", objRH.DtResultados(0)("RentaMensual").ToString.ToDecimal.ToString("###,###,###.00"))) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{TransportePublico}", objRH.DtResultados(0)("TransportePublico").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{TrabajadoAnteriormente}", objRH.DtResultados(0)("TrabajadoAnteriormente").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{TrabajadoAnteriormenteObservaciones}", objRH.DtResultados(0)("TrabajadoAnteriormenteObservaciones").ToString)) + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{ParientesEmpresa}", objRH.DtResultados(0)("ParientesEmpresa").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{AcusadoDelito}", objRH.DtResultados(0)("AcusadoDelito").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{AcusadoDelitoObservaciones}", objRH.DtResultados(0)("AcusadoDelitoObservaciones").ToString)) + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Direccion}", objRH.DtResultados(0)("Direccion").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Calle}", objRH.DtResultados(0)("Calle").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Colonia}", objRH.DtResultados(0)("Colonia").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{CP}", objRH.DtResultados(0)("CP").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Telefono}", objRH.DtResultados(0)("Telefono").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Celular}", objRH.DtResultados(0)("Celular").ToString)) + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Correo}", objRH.DtResultados(0)("Correo").ToString)) + + + ' 'If Not IsDBNull(objRH.DtResultados(0)("CveSucursal")) Then + + ' ' ListaTagsDocumentost.Add(New TagsDocumentos("{CveSucursal}", DDLSucursal4.Text)) + ' 'End If + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{NumeroSS}", objRH.DtResultados(0)("NumeroSS").ToString)) + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Licencia}", objRH.DtResultados(0)("Licencia").ToString)) + + + + + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{CartillaMilitar}", objRH.DtResultados(0)("CartillaMilitar").ToString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{CURP}", objRH.DtResultados(0)("CURP").ToString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{AutorizaAntidoping}", objRH.DtResultados(0)("AutorizaAntidoping").ToString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Observaciones}", objRH.DtResultados(0)("Observaciones").ToString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Direccion}", objRH.DtResultados(0)("Direccion").ToString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaIngreso}", objRH.DtResultados(0)("FechaIngreso").ToString.ToDate.ToShortDateString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Direccion}", objRH.DtResultados(0)("Direccion").ToString.ToDate.ToShortDateString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Puesto}", objRH.DtResultados(0)("Puesto").ToString)) + + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{CUIP}", "")) + ' ListaTagsDocumentost.Add(New TagsDocumentos("{Denominacion}", "")) + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaNacimiento}", objRH.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("dd/MM/yyyy"))) + + + ' Dim fechaActual As String = " " & Now.Day & " del mes " & Now.Month & " del año " & Now.Year + + ' Dim FechaActualDF As String = Now.ToString("dd/MM/yyyy") + + ' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaActual}", fechaActual)) + ' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaActualDF}", FechaActualDF)) + ' End If + + + ' objRH.Dispose() + ' End If + + ' Return ListaTagsDocumentost + 'End Function + + + + + + + + ''Private Function GetDatosTagsDocumentos() As List(Of TagsDocumentos) + '' Dim ListaTagsDocumentost = New List(Of TagsDocumentos) + + '' If CvePersonal <> -1 Then + '' Dim objRH As New ClsRH + + + + '' If objRH.PersonalReclutamientoGet(CvePersonal, UsuarioActual.Empresa.CveEmpresa) Then + + '' If Not IsDBNull(objRH.DtResultados(0)("Nombres")) Then + '' ListaTagsDocumentost.Add(New TagsDocumentos("{Nombres}", objRH.DtResultados(0)("Nombres").ToString)) + '' End If + + '' If Not objRH.DtResultados(0)("APaterno") Is Nothing Then + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{APaterno}", objRH.DtResultados(0)("APaterno").ToString)) + '' End If + + '' If Not objRH.DtResultados(0)("AMaterno") Is Nothing Then + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{AMaterno}", objRH.DtResultados(0)("AMaterno").ToString)) + '' End If + + '' If Not objRH.DtResultados(0)("NombreCompleto") Is Nothing Then + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{NombreCompleto}", objRH.DtResultados(0)("NombreCompleto").ToString)) + '' End If + + '' If Not IsDBNull(objRH.DtResultados(0)("Estatura")) Then + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{Estatura}", objRH.DtResultados(0)("Estatura").ToString)) + '' End If + + '' If Not IsDBNull(objRH.DtResultados(0)("Peso")) Then + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{Peso}", objRH.DtResultados(0)("Peso").ToString)) + '' End If + + '' If Not IsDBNull(objRH.DtResultados(0)("LugarNacimiento")) Then + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{LugarNacimiento}", objRH.DtResultados(0)("LugarNacimiento").ToString)) + '' End If + + '' If Not IsDBNull(objRH.DtResultados(0)("Edad")) Then + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{Edad}", objRH.DtResultados(0)("Edad").ToString)) + '' End If + + '' If Not IsDBNull(objRH.DtResultados(0)("NombreTelEmergencia")) Then + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{NombreTelEmergencia}", objRH.DtResultados(0)("NombreTelEmergencia").ToString)) + '' End If + + '' If Not IsDBNull(objRH.DtResultados(0)("TipoSangre")) Then + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{TipoSangre}", objRH.DtResultados(0)("TipoSangre").ToString)) + '' End If + + '' If Not IsDBNull(objRH.DtResultados(0)("Vivienda")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Vivienda}", objRH.DtResultados(0)("Vivienda").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("ViviendaDueno")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{ViviendaDueno}", objRH.DtResultados(0)("ViviendaDueno").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("CreditoInfonavit")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CreditoInfonavit}", objRH.DtResultados(0)("CreditoInfonavit").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("RentaMensual")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{RentaMensual}", objRH.DtResultados(0)("RentaMensual").ToString.ToDecimal.ToString("###,###,###.00"))) + + '' If Not IsDBNull(objRH.DtResultados(0)("TransportePublico")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{TransportePublico}", objRH.DtResultados(0)("TransportePublico").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("TrabajadoAnteriormente")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{TrabajadoAnteriormente}", objRH.DtResultados(0)("TrabajadoAnteriormente").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("TrabajadoAnteriormenteObservaciones")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{TrabajadoAnteriormenteObservaciones}", objRH.DtResultados(0)("TrabajadoAnteriormenteObservaciones").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("ParientesEmpresa")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{ParientesEmpresa}", objRH.DtResultados(0)("ParientesEmpresa").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("AcusadoDelito")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{AcusadoDelito}", objRH.DtResultados(0)("AcusadoDelito").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("AcusadoDelitoObservaciones")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{AcusadoDelitoObservaciones}", objRH.DtResultados(0)("AcusadoDelitoObservaciones").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Direccion")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Direccion}", objRH.DtResultados(0)("Direccion").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Calle")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Calle}", objRH.DtResultados(0)("Calle").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Colonia")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Colonia}", objRH.DtResultados(0)("Colonia").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("CP")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CP}", objRH.DtResultados(0)("CP").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Telefono")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Telefono}", objRH.DtResultados(0)("Telefono").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Celular")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Celular}", objRH.DtResultados(0)("Celular").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Correo")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Correo}", objRH.DtResultados(0)("Correo").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("CveSucursal")) Then + + '' ' ListaTagsDocumentost.Add(New TagsDocumentos("{CveSucursal}", DDLSucursal4.Text)) + '' End If + + '' If Not IsDBNull(objRH.DtResultados(0)("NumeroSS")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{NumeroSS}", objRH.DtResultados(0)("NumeroSS").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Licencia")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Licencia}", objRH.DtResultados(0)("Licencia").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("CartillaMilitar")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CartillaMilitar}", objRH.DtResultados(0)("CartillaMilitar").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("CURP")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CURP}", objRH.DtResultados(0)("CURP").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("AutorizaAntidoping")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{AutorizaAntidoping}", objRH.DtResultados(0)("AutorizaAntidoping").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Observaciones")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Observaciones}", objRH.DtResultados(0)("Observaciones").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("CredencialElector")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{CredencialElector}", objRH.DtResultados(0)("CredencialElector").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Sucursal")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Sucursal}", objRH.DtResultados(0)("Sucursal").ToString)) + + '' If Not IsDBNull(objRH.DtResultados(0)("Puesto")) Then ListaTagsDocumentost.Add(New TagsDocumentos("{Puesto}", objRH.DtResultados(0)("Puesto").ToString)) + + '' 'If Not IsDBNull(objRH.DtResultados(0)("InformacionFidedigno")) Then chkFidedigna4.Checked = objRH.DtResultados(0)("InformacionFidedigno") + '' ListaTagsDocumentost.Add(New TagsDocumentos("{InformacionFidedigno}", objRH.DtResultados(0)("InformacionFidedigno").ToString)) + '' End If + + '' If Not IsDBNull(objRH.DtResultados(0)("FechaNacimiento")) Then + '' ListaTagsDocumentost.Add(New TagsDocumentos("{InformacionFidedigno}", objRH.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("dd/MM/yyyy"))) + '' End If + + + '' Dim fechaActual As String = " " & Now.Day & " del mes " & Now.Month & " del año " & Now.Year + '' Dim FechaActualDF As String = Now.ToString("dd/MM/yyyy") + + '' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaActual}", fechaActual)) + '' ListaTagsDocumentost.Add(New TagsDocumentos("{FechaActualDF}", FechaActualDF)) + + + '' objRH.Dispose() + '' End If + + '' Return ListaTagsDocumentost + ''End Function + Private Sub RegistraDescargaJavaScript(baseUrl As String) + + RegistraScript("Download('" & baseUrl & "')") + + End Sub + +#End Region + +#Region "D O C U M E N T O S V E N T A S" + + Private Sub CargaDocumentosVenta(tCveCliente As Integer) + Dim objInv As New ClsEdocumentacion + + If objInv.DocumentacionElectronicaGet(-1, tCveCliente, -1, UsuarioActual.CveEmpresa, 14) Then + GvDocsVentas.DataSource = objInv.DtResultados + If objInv.DtResultados.Rows.Count > 0 Then BtnGuardarDocumentacion.Visible = True + Else + GvDocsVentas.DataSource = Nothing + End If + + objInv.Dispose() + GvDocsVentas.DataBind() + UpDocumentacion.Update() + + End Sub + + Private Sub BtnGuardarDocumentación_Click(sender As Object, e As EventArgs) Handles BtnGuardarDocumentacion.Click + Dim objDoc As New ClsEdocumentacion() + objDoc.IniciaTransacSQL() + Dim HuboError As Boolean = False + + If CveCliente <= 0 Then + For Each gvr As GridViewRow In GvDocsVentas.Rows + If gvr.FCCheckBox("ChkDoc").Checked Then + + If objDoc.DocumentacionElectronicaAdd(gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, Now, Observacion2:=gvr.FCTextBox("TxtObs2").Text) <= 0 Then HuboError = True + + End If + + Next + + Else + For Each gvr As GridViewRow In GvDocsVentas.Rows + 'sino está registrada y se selecciona, se va a insertar + If gvr.DataKey("CveDocumentacionElectronica").ToEntero <= 0 AndAlso gvr.FCCheckBox("ChkDoc").Checked Then + If objDoc.DocumentacionElectronicaAdd(gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, Now, Observacion2:=gvr.FCTextBox("TxtObs2").Text) <= 0 Then HuboError = True + Else + ', Observacion2:=gvr.FCTextBox("TxtObs2").Text + If Not objDoc.DocumentacionElectronicaUpdate(gvr.DataKey("CveDocumentacionElectronica").ToEntero, gvr.DataKey("CveDocumentacion").ToEntero, -1, CveCliente, -1, 1, gvr.FCTextBox("TxtObs").Text, "", UsuarioActual.CveUsuario, gvr.DataKey("FechaLimite").ToDate, Observacion2:=gvr.FCTextBox("TxtObs2").Text) Then HuboError = True + End If + + 'si ya estaba registrada y no se selecciona, se va a insertar + If gvr.DataKey("CveDocumentacionElectronica").ToEntero > 0 AndAlso Not gvr.FCCheckBox("ChkDoc").Checked Then + If Not objDoc.DocumentacionElectronicaRemove(gvr.DataKey("CveDocumentacionElectronica").ToEntero, -1) Then HuboError = True + End If + + Next + + End If + + + If Not HuboError Then + Alert("Documentación guardada", TipoMensaje.MsgInformacion) + objDoc.Commit() + Else + objDoc.RollBack() + End If + objDoc.Dispose() + + End Sub + + Public Sub Upload_ClickDocumentacion(sender As Object, e As EventArgs) + RegistraScript("$('#ModalCXCDocumento').modal({ backdrop: 'static', keyboard: false});") + End Sub + + Protected Sub BtnModalCXCDocumentoClienteUpload_Click(sender As Object, e As EventArgs) Handles BtnModalCXCDocumentoClienteUpload.Click + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim _CveDocumentacionElectronica As Integer = GvRow.DataKey("CveDocumentacion").ToEntero + Dim _CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToEntero + Dim _Obserbaciones As String = GvRow.FCTextBox("TxtObservaciones").Text.Trim + Dim _FechaLimite As Date = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate + + SubirComprobante(_CveDocumentacionElectronica, _CveDocumentacion, _Obserbaciones, _FechaLimite) + 'CargaDocs() + + End Sub + + Private Function SubirComprobante(_CveDocumentacionElecronica As Integer, _CveDocumentacion As Integer, _Obserbaciones As String, _FechaLimite As Date) As Boolean + + Dim Respuesta As Boolean = False + Dim RutaDirectorio As String = String.Format("{0}{1}", UsuarioActual.Empresa.Ruta, "Clientes\") + + Dim filesgral As List(Of Archivo) = TxtCXCDocumentoCliente.getfiles().Archivos + Dim filemove As String = "" + Dim Comprobante As String = "" + Dim ShortFileName As String = "" + + + If filesgral.Count > 0 Then + + Dim RutaArchivo As String + + For Each fileItem As Archivo In filesgral + + Dim edoc As New ClsEdocumentacion + + Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "") + filemove = fileItem.FileUrl + RutaArchivo = String.Format("{0}{1}_{2}", RutaDirectorio, CveCliente, _CveDocumentacion) + RutaArchivo = String.Format("{0}.{1}", RutaArchivo, fileItem.Extencion) + + Try + If Not Directory.Exists(RutaDirectorio) Then + Directory.CreateDirectory(RutaDirectorio) + End If + + If File.Exists(RutaArchivo) Then + File.Delete(RutaArchivo) + End If + + File.Move(filemove, RutaArchivo) + Respuesta = True + ShortFileName = System.IO.Path.GetFileName(RutaArchivo) + + If edoc.DocumentacionElectronicaUpdate(_CveDocumentacionElecronica, _CveDocumentacion, -1, CveCliente, -1, 1, _Obserbaciones, ShortFileName, UsuarioActual.CveEmpresa, _FechaLimite) Then + + + End If + + Catch ex As Exception + + OnError("Error al intentar guardar archivo ", ex) + Respuesta = False + RutaArchivo = "-1" + End Try + Anexo.Text = "" + + edoc.Dispose() + Next + Else + Respuesta = True + End If + + + + UpModalCXCClienteDocumento.Update() + Return Respuesta + + End Function + + Public Sub Update_ClickDocumentacion(sender As Object, e As EventArgs) + + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + Dim activo As Boolean = False + + Dim _CveDocumentacion As Integer = GvRow.DataKey("CveDocumentacion").ToEntero + Dim _Adjunto As String = GvRow.DataKey("Adjunto").ToString + Dim _fechaLimite As Date = GvRow.FCTextBox("TxtFechaLimite").Text.ToDate + + Dim observaciones As String = GvRow.FCTextBox("TxtObservaciones").Text ' DirectCast(GvRow.FindControl("TxtObservaciones"), TextBox).Text + 'Dim DDLEstatus As DropDownList = DirectCast(GvRow.FindControl("DDLEstatus"), DropDownList) + Dim chkCompleto As CheckBox = GvRow.FCCheckBox("chkEstatus") + Dim _Estatus As Integer + If chkCompleto.Checked Then _Estatus = 1 Else _Estatus = 0 + + + Dim objRH As New ClsEdocumentacion + + If Not GvRow.DataKey("CveDocumentacionElectronica").ToEntero = -1 Then + If objRH.DocumentacionElectronicaUpdate(GvRow.DataKey("CveDocumentacionElectronica").ToEntero, _CveDocumentacion, -1, CveCliente, -1, _Estatus, observaciones, _Adjunto, UsuarioActual.CveUsuario, GvRow.FCTextBox("TxtFechaLimite").Text.ToDate) Then + Alert("Documento actualizado correctamente.", TipoMensaje.MsgInformacion) + End If + Else + If objRH.DocumentacionElectronicaAdd(_CveDocumentacion, -1, CveCliente, -1, _Estatus, observaciones, _Adjunto, UsuarioActual.CveUsuario, GvRow.FCTextBox("TxtFechaLimite").Text.ToDate) > 0 Then + Alert("Documento actualizado correctamente.", TipoMensaje.MsgInformacion) + End If + End If + + objRH.Dispose() + + End Sub + + +#End Region + +#Region "PERSONA FISICA" + Protected Sub LnkPersonaFisica_Click(sender As Object, e As EventArgs) + RegistraScript("$('#DivModalPersonaFisica').modal();") + End Sub + Protected Sub LnkActualizarPersonaFisica_Click(sender As Object, e As EventArgs) + Dim ObjCliente As New ClsClientes + + If ObjCliente.UpdateClientePersonaFisica(CveCliente, TxtApellidoPaternoPF.Text, TxtApellidoMaternoPF.Text, TxtNombrePF.Text) Then + Alert("El Cliente se ha actualizado correctamente.", TipoMensaje.MsgInformacion) + + TxtNombre.Text = $"{TxtNombrePF.Text} {TxtApellidoPaternoPF.Text} {TxtApellidoMaternoPF.Text}" + + TxtApellidoPaterno.Text = TxtApellidoPaternoPF.Text + TxtApellidoMaterno.Text = TxtApellidoMaternoPF.Text + TxtNombres.Text = TxtNombrePF.Text + + DivRazonSocial.Visible = False + DivPersonaFisica.Visible = True + + RegistraScript("$('#DivModalPersonaFisica').modal('hide');") + End If + + ObjCliente.Dispose() + UpDatos.Update() + End Sub +#End Region + +#Region "USUARIOS PLATAFORMA CLIENTE - 6 " + Protected Sub CargaUsuariosPortalCliente() + Dim objUsuario As ClsSisUsuarios = New ClsSisUsuarios + If objUsuario.GetUsuariosPortal(-1, CveCliente, -1) Then + GvUsuarios.DataSource = objUsuario.DtResultados.FiltraParametros($"CveEmpresa={UsuarioActual.CveEmpresa}") + GvUsuarios.DataBind() + End If + objUsuario.Dispose() + End Sub +#End Region + +#Region " DEVOLVER DINERO ANT/NC " + Private Sub InicializaDevolverDinero() + If UsuarioActual.TienePermisoProceso(247) Then + GVAnticipos.Columns(6).Visible = True + End If + End Sub +#End Region + +#Region "MODAL GRAFICA/PEDIDOS" + + Protected Sub LnkVerGrafica_Click(sender As Object, e As EventArgs) + If CargaDatatables() Then + RegistraScript("$('#DivModalGrafica').modal('show')") + CargaGrafica() + End If + End Sub + + Protected Sub LnkCancelar_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + Dim ObjCliente As New ClsClientes + If ObjCliente.UpdateEstatusPedido(gvRow.DataKey("CveVenta").ToEntero, 17, -1, UsuarioActual.CveUsuario) Then + Alert("Cancelado correctamente.") + CargaPedido() + End If + ObjCliente.Dispose() + End Sub + + + Private Sub CargaPedido() + Dim ObjCliente As New ClsClientes + If ObjCliente.GetClienteVentasPedido(CveCliente, UsuarioActual.CveEmpresa) Then + GvPedidos.DataSource = ObjCliente.DtResultados + End If + ObjCliente.Dispose() + GvPedidos.DataBind() + UpPedido.Update() + End Sub + + Protected Sub LnkAutorizar_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + Dim ObjCliente As New ClsClientes + ObjCliente.IniciaTransacSQL() + Dim ErrorTrans As Boolean = False + Dim CveU As Integer = 0 + Dim MsgAut As String = "" + + If ObjCliente.UpdateEstatusPedido(gvRow.DataKey("CveVenta").ToEntero, 16, gvRow.FCTextBox("TxtDiasCredito").Text.ToEntero, UsuarioActual.CveUsuario) Then + CveU = gvRow.DataKey("CveUsuario").ToEntero + MsgAut = String.Format(" Solicitud Autorizada {0} ", gvRow.DataKey("SerieFolio")) + 'If Not ObjCliente.UpdateFechaPedido(gvRow.DataKey("CveVenta").ToEntero, gvRow.FCTextBox("TxtDiasCredito").Text.ToEntero) Then + ' ErrorTrans = True + 'End If + Else + ErrorTrans = True + End If + If Not ErrorTrans Then + ObjCliente.Commit() + Alert("Autorizado correctamente.") + + If CveU > 0 Then ClsSisNotificaciones.SendNotificacionERP(CveU, MsgAut, MsgAut, 1) + + CargaPedido() + Else + ObjCliente.RollBack() + End If + ObjCliente.Dispose() + End Sub + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + If CargaDatatables() Then + CargaGrafica() + End If + End Sub + + Private Function CargaDatatables() As Boolean + Dim ObjClientes As New ClsClientes + If ObjClientes.GetClienteVencido(CveCliente, UsuarioActual.CveEmpresa, TxtFechaICredito.Text.ToDate, TxtFechaFCredito.Text.ToDate) Then + DtVencido = ObjClientes.DtResultados + End If + + If ObjClientes.GetRotacionCartera(CveCliente, UsuarioActual.CveEmpresa, TxtFechaICredito.Text.ToDate, TxtFechaFCredito.Text.ToDate) Then + DtRotacion = ObjClientes.DtResultados + End If + + If ObjClientes.GetClienteSaldoMensual(CveCliente, UsuarioActual.CveEmpresa, TxtFechaICredito.Text.ToDate, TxtFechaFCredito.Text.ToDate) Then + DtSaldoMensual = ObjClientes.DtResultados + End If + + If ObjClientes.GetClienteComportamientoVentaMensual(CveCliente, UsuarioActual.CveEmpresa, TxtFechaICredito.Text.ToDate, TxtFechaFCredito.Text.ToDate) Then + DtComportamientoVentas = ObjClientes.DtResultados + End If + + If ObjClientes.GetClienteVentasPedido(CveCliente, UsuarioActual.CveEmpresa) Then + GvPedidos.DataSource = ObjClientes.DtResultados + End If + + ObjClientes.Dispose() + GvPedidos.DataBind() + UpPedido.Update() + + Return True + End Function + + Private Sub CargaGrafica() + Dim FactVencida As Boolean = False + Dim Saldo As Double = 0 + Dim LimiteCredito As Double = 0 + If DtVencido.Rows.Count > 0 Then + Saldo = DtVencido.SUM("Saldo") + LimiteCredito = DtVencido.Rows(0)("LimiteCredito").ToString.ToDouble + LblVencido.Text = DtVencido.SUM("Total", "DiasVencidos > 0").FormatoNumero + LblPorVencer.Text = DtVencido.SUM("Total", "DiasVencidos <= 0").FormatoNumero + Else + LimiteCredito = TxtLimiteCredito.Text.ToDouble + LblVencido.Text = "0" + LblPorVencer.Text = "0" + End If + + Dim Dt As New DataTable() + Dt.Columns.Add("value") + For Each Dr As DataRow In DtVencido.Rows + Dim Row As DataRow = Nothing + Row = Dt.NewRow() + Row("value") = Dr("DiasVencidos").ToString + Dt.Rows.Add(Row) + If Dr("DiasVencidos").ToString.ToEntero > 0 And Dr("Saldo").ToString.ToDouble > 0 Then + FactVencida = True + End If + Next + + + Dim query = From s In Dt.AsEnumerable() Select New With {.date = "", .value = s("value").ToString()} + Dim json = Newtonsoft.Json.JsonConvert.SerializeObject(query) + RegistraScript($"CargaGraficaVencido({json})", "22") + + Dim Dt2 As New DataTable() + Dt2.Columns.Add("limite") + Dt2.Columns.Add("saldo") + Dim Row2 As DataRow = Nothing + Row2 = Dt2.NewRow() + LtlLimiteCreditoModal.Text = LimiteCredito.FormatoNumero + Row2("limite") = LimiteCredito - Saldo + Row2("saldo") = Saldo + Dt2.Rows.Add(Row2) + Dim query2 = From s In Dt2.AsEnumerable() Select New With {.year = "", .limite = s("limite").ToString(), .saldo = s("saldo").ToString()} + Dim json2 = Newtonsoft.Json.JsonConvert.SerializeObject(query2) + + RegistraScript($"CargaGraficaLimiteCredito({json2})", "33") + + If DtRotacion.Rows.Count > 0 Then + LblVentasModal.Text = DtRotacion.Rows(0)("Ventas").ToString.FormatoNumero + LblPagadoModal.Text = DtRotacion.Rows(0)("Pagado").ToString.FormatoNumero + LblRotacionModal.Text = DtRotacion.Rows(0)("Rotacion").ToString.FormatoNumero + LblDiasModal.Text = DtRotacion.Rows(0)("Dias").ToString.FormatoNumero + LblDiasCreditoModal.Text = DtRotacion.Rows(0)("DiasCredito").ToString.FormatoNumero + Else + LblVentasModal.Text = "0" + LblPagadoModal.Text = "0" + LblRotacionModal.Text = "0" + LblDiasModal.Text = "0" + LblDiasCreditoModal.Text = "0" + End If + + If FactVencida Or (Saldo > LimiteCredito) Then + LblEstatusModal.Text = "Vencido" + LblEstatusModal.ForeColor = Drawing.Color.Red + Else + LblEstatusModal.Text = "Al Corriente" + LblEstatusModal.ForeColor = Drawing.Color.Green + End If + + Dim Dt3 As New DataTable() + Dt3.Columns.Add("mes") + + Dim Dt4 As New DataTable() + Dt4.Columns.Add("balloonText") + Dt4.Columns.Add("bullet") + Dt4.Columns.Add("title") + Dt4.Columns.Add("valueField") + Dt4.Columns.Add("fillAlphas") + Dt4.Columns.Add("hidden") + + + Dim Cont As Integer = 1 + For Each Dr As DataRow In DtComportamientoVentas.Rows + Dt3.Columns.Add(Dr("Ano").ToString) + Dim Row4 As DataRow = Nothing + Row4 = Dt4.NewRow() + Row4("balloonText") = "Ventas [[category]]: [[value]]" + Row4("bullet") = "round" + Row4("title") = Dr("Ano").ToString + Row4("valueField") = Dr("Ano").ToString + Row4("fillAlphas") = 0 + Row4("hidden") = If(Cont > DtComportamientoVentas.Rows.Count - 3, False, True) + Dt4.Rows.Add(Row4) + Cont += 1 + Next + + Dim RowEnero As DataRow = Nothing + RowEnero = Dt3.NewRow() + Dim RowFebrero As DataRow = Nothing + RowFebrero = Dt3.NewRow() + Dim RowMarzo As DataRow = Nothing + RowMarzo = Dt3.NewRow() + Dim RowAbril As DataRow = Nothing + RowAbril = Dt3.NewRow() + Dim RowMayo As DataRow = Nothing + RowMayo = Dt3.NewRow() + Dim RowJunio As DataRow = Nothing + RowJunio = Dt3.NewRow() + Dim RowJulio As DataRow = Nothing + RowJulio = Dt3.NewRow() + Dim RowAgosto As DataRow = Nothing + RowAgosto = Dt3.NewRow() + Dim RowSeptiembre As DataRow = Nothing + RowSeptiembre = Dt3.NewRow() + Dim RowOctubre As DataRow = Nothing + RowOctubre = Dt3.NewRow() + Dim RowNoviembre As DataRow = Nothing + RowNoviembre = Dt3.NewRow() + Dim RowDiciembre As DataRow = Nothing + RowDiciembre = Dt3.NewRow() + For Each Dr As DataRow In DtComportamientoVentas.Rows + RowEnero(Dr("Ano").ToString) = Dr("Enero").ToString + RowEnero("mes") = "Enero" + RowFebrero(Dr("Ano").ToString) = Dr("Febrero").ToString + RowFebrero("mes") = "Febrero" + RowMarzo(Dr("Ano").ToString) = Dr("Marzo").ToString + RowMarzo("mes") = "Marzo" + RowAbril(Dr("Ano").ToString) = Dr("Abril").ToString + RowAbril("mes") = "Abril" + RowMayo(Dr("Ano").ToString) = Dr("Mayo").ToString + RowMayo("mes") = "Mayo" + RowJunio(Dr("Ano").ToString) = Dr("Junio").ToString + RowJunio("mes") = "Junio" + RowJulio(Dr("Ano").ToString) = Dr("Julio").ToString + RowJulio("mes") = "Julio" + RowAgosto(Dr("Ano").ToString) = Dr("Agosto").ToString + RowAgosto("mes") = "Agosto" + RowSeptiembre(Dr("Ano").ToString) = Dr("Septiembre").ToString + RowSeptiembre("mes") = "Septiembre" + RowOctubre(Dr("Ano").ToString) = Dr("Octubre").ToString + RowOctubre("mes") = "Octubre" + RowNoviembre(Dr("Ano").ToString) = Dr("Noviembre").ToString + RowNoviembre("mes") = "Noviembre" + RowDiciembre(Dr("Ano").ToString) = Dr("Diciembre").ToString + RowDiciembre("mes") = "Diciembre" + Next + Dt3.Rows.Add(RowEnero) + Dt3.Rows.Add(RowFebrero) + Dt3.Rows.Add(RowMarzo) + Dt3.Rows.Add(RowAbril) + Dt3.Rows.Add(RowMayo) + Dt3.Rows.Add(RowJunio) + Dt3.Rows.Add(RowJulio) + Dt3.Rows.Add(RowAgosto) + Dt3.Rows.Add(RowSeptiembre) + Dt3.Rows.Add(RowOctubre) + Dt3.Rows.Add(RowNoviembre) + Dt3.Rows.Add(RowDiciembre) + + RegistraScript($"CargaGraficaComportamientoVentas({Dt3.ToJson},{Dt4.ToJson.Replace($"{Chr(34)}True{Chr(34)}", "true").Replace($"{Chr(34)}False{Chr(34)}", "false")})", "44") + + Dim Dt5 As New DataTable() + Dt5.Columns.Add("mes") + + Dim Dt6 As New DataTable() + Dt6.Columns.Add("balloonText") + Dt6.Columns.Add("bullet") + Dt6.Columns.Add("title") + Dt6.Columns.Add("valueField") + Dt6.Columns.Add("fillAlphas") + Dt6.Columns.Add("hidden") + + Cont = 1 + For Each Dr As DataRow In DtSaldoMensual.Rows + Dt5.Columns.Add(Dr("Ano").ToString) + Dim Row6 As DataRow = Nothing + Row6 = Dt6.NewRow() + Row6("balloonText") = "Saldo [[category]]: [[value]]" + Row6("bullet") = "round" + Row6("title") = Dr("Ano").ToString + Row6("valueField") = Dr("Ano").ToString + Row6("fillAlphas") = 0 + Row6("hidden") = If(Cont > DtSaldoMensual.Rows.Count - 3, False, True) + Dt6.Rows.Add(Row6) + Cont += 1 + Next + RowEnero = Dt5.NewRow() + RowFebrero = Dt5.NewRow() + RowMarzo = Dt5.NewRow() + RowAbril = Dt5.NewRow() + RowMayo = Dt5.NewRow() + RowJunio = Dt5.NewRow() + RowJulio = Dt5.NewRow() + RowAgosto = Dt5.NewRow() + RowSeptiembre = Dt5.NewRow() + RowOctubre = Dt5.NewRow() + RowNoviembre = Dt5.NewRow() + RowDiciembre = Dt5.NewRow() + For Each Dr As DataRow In DtSaldoMensual.Rows + RowEnero(Dr("Ano").ToString) = Dr("Enero").ToString + RowEnero("mes") = "Enero" + RowFebrero(Dr("Ano").ToString) = Dr("Febrero").ToString + RowFebrero("mes") = "Febrero" + RowMarzo(Dr("Ano").ToString) = Dr("Marzo").ToString + RowMarzo("mes") = "Marzo" + RowAbril(Dr("Ano").ToString) = Dr("Abril").ToString + RowAbril("mes") = "Abril" + RowMayo(Dr("Ano").ToString) = Dr("Mayo").ToString + RowMayo("mes") = "Mayo" + RowJunio(Dr("Ano").ToString) = Dr("Junio").ToString + RowJunio("mes") = "Junio" + RowJulio(Dr("Ano").ToString) = Dr("Julio").ToString + RowJulio("mes") = "Julio" + RowAgosto(Dr("Ano").ToString) = Dr("Agosto").ToString + RowAgosto("mes") = "Agosto" + RowSeptiembre(Dr("Ano").ToString) = Dr("Septiembre").ToString + RowSeptiembre("mes") = "Septiembre" + RowOctubre(Dr("Ano").ToString) = Dr("Octubre").ToString + RowOctubre("mes") = "Octubre" + RowNoviembre(Dr("Ano").ToString) = Dr("Noviembre").ToString + RowNoviembre("mes") = "Noviembre" + RowDiciembre(Dr("Ano").ToString) = Dr("Diciembre").ToString + RowDiciembre("mes") = "Diciembre" + Next + Dt5.Rows.Add(RowEnero) + Dt5.Rows.Add(RowFebrero) + Dt5.Rows.Add(RowMarzo) + Dt5.Rows.Add(RowAbril) + Dt5.Rows.Add(RowMayo) + Dt5.Rows.Add(RowJunio) + Dt5.Rows.Add(RowJulio) + Dt5.Rows.Add(RowAgosto) + Dt5.Rows.Add(RowSeptiembre) + Dt5.Rows.Add(RowOctubre) + Dt5.Rows.Add(RowNoviembre) + Dt5.Rows.Add(RowDiciembre) + + + RegistraScript($"CargaGraficaCompratamientoSaldoMensual({Dt5.ToJson},{Dt6.ToJson.Replace($"{Chr(34)}True{Chr(34)}", "true").Replace($"{Chr(34)}False{Chr(34)}", "false")})", "55") + + UPModalProd.Update() + End Sub + + +#End Region + +#Region "TAB - COMPORTAMIENTO DE VENTAS" + + Private Sub CargaGrupo() + DdlGrupo.Items.Insert(0, New ListItem("Categoria", "3")) + DdlGrupo.Items.Insert(1, New ListItem("Clasificacion", "4")) + DdlGrupo.Items.Insert(2, New ListItem("Productos-Servicios", "5")) + DdlGrupo.Items.Insert(3, New ListItem("Año", "6")) + DdlGrupo.Items.Insert(4, New ListItem("Mes", "7")) + DdlGrupo.Items.Insert(5, New ListItem("Año/Mes", "8")) + DdlGrupo.Items.Insert(6, New ListItem("Fecha", "9")) + DdlGrupo.Items.Insert(7, New ListItem("Cliente", "10")) + DdlGrupo.Items.Insert(8, New ListItem("Vendedor", "12")) + DdlGrupo.Items.Insert(9, New ListItem("Usuario", "13")) + DdlGrupo.Items.Insert(10, New ListItem("Estatus Fact.", "14")) + DdlGrupo.Items.Insert(11, New ListItem("Año Ejec.", "15")) + DdlGrupo.Items.Insert(12, New ListItem("Mes Ejec.", "16")) + DdlGrupo.Items.Insert(13, New ListItem("Año/Mes Ejec.", "17")) + DdlGrupo.Items.Insert(14, New ListItem("Fecha Ejec.", "18")) + DdlGrupo.Items.Insert(15, New ListItem("Cliente - PS", "20")) + DdlGrupo.DataBind() + DdlGrupo.SelectedValueExist("8") + End Sub + + Private Sub CargaTipoCentroCosto() + + If UsuarioActual.Empresa.Tipo_CentroCosto = 1 Then + DdlSubProyectoFiltro.Items.Clear() + DivProyecto.Visible = False + LblProyecto.Visible = False + LblSubProyecto.InnerText = "Sucursal:" + DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoFiltro.Items.Insert(0, New ListItem("Todos", "-1")) + DdlSubProyectoFiltro.DataBind() + + DdlGrupo.Items.Insert(0, New ListItem("Sucursal", "2")) + DdlGrupo.Items.Insert(16, New ListItem("Sucursal Ejec.", "19")) + DdlGrupo.DataBind() + + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 2 Then + DdlSubProyectoFiltro.Items.Clear() + DivProyecto.Visible = False + LblProyecto.Visible = False + LblSubProyecto.InnerText = "Proyecto:" + DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoFiltro.Items.Insert(0, New ListItem("Todos", "-1")) + DdlSubProyectoFiltro.DataBind() + + DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "2")) + DdlGrupo.Items.Insert(16, New ListItem("Proyecto Ejec.", "19")) + DdlGrupo.DataBind() + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 3 Then + DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "1")) + DdlGrupo.Items.Insert(1, New ListItem("SubProyecto", "2")) + DdlGrupo.Items.Insert(17, New ListItem("SubProyecto Ejec.", "19")) + DdlGrupo.DataBind() + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 4 Then + LblProyecto.InnerText = "Sucursal:" + LblSubProyecto.InnerText = "Proyecto:" + + + DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "1")) + DdlGrupo.Items.Insert(1, New ListItem("SubProyecto", "2")) + DdlGrupo.Items.Insert(17, New ListItem("SubProyecto Ejec.", "19")) + DdlGrupo.DataBind() + + ElseIf UsuarioActual.Empresa.Tipo_CentroCosto = 5 Then + LblProyecto.InnerText = "Proyecto:" + LblSubProyecto.InnerText = "Sucursal:" + + DdlGrupo.Items.Insert(0, New ListItem("Proyecto", "1")) + DdlGrupo.Items.Insert(1, New ListItem("SubProyecto", "2")) + DdlGrupo.Items.Insert(17, New ListItem("SubProyecto Ejec.", "19")) + DdlGrupo.DataBind() + End If + End Sub + + Private Sub CargaFiltros() + 'Cargo Proyectos + DdlProyecto.DataSource = GlobalDTProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1) + DdlProyecto.DataBind() + + 'Cargo Clasificaciones + DdlClasificacionFilto.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) + DdlClasificacionFilto.DataBind() + + 'CargaSubProyectos + DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoFiltro.DataBind() + + 'Vendedor + DdlVendedorFiltro.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa) + DdlVendedorFiltro.DataBind() + + 'CargaUsuarios + DdlUsuario.DataSource = GlobalDTUsuarios.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + DdlUsuario.DataBind() + + 'Carga Productos + DdlPSFiltro.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.Empresa.Funcionalidad(105) = "1" Then + DdlPSFiltro.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacionFilto.SelectedValue) + DdlPSFiltro.SelectedText = "" + DdlPSFiltro.SelectedValue = "-1" + Else + DdlPSFiltro.ddl.Items.Clear() + DdlPSFiltro.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacionFilto.SelectedValue.ToEntero) + DdlPSFiltro.ddl.DataBind() + DdlPSFiltro.ddl.Items.Insert(0, New ListItem("Seleccione el Producto", "-1")) + End If + + CargaGrupo() + CargaTipoCentroCosto() + + End Sub + + Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged + CargaSubProyecto() + End Sub + + Private Sub CargaSubProyecto() + DdlSubProyectoFiltro.Items.Clear() + If DdlProyecto.SelectedValue <> "-1" Then + DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, DdlProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1, 1) + DdlSubProyectoFiltro.DataBind() + End If + DdlSubProyectoFiltro.Items.Insert(0, New ListItem("Todos", "-1")) + End Sub + + Protected Sub DdlClasificacionFilto_SelectedIndexChanged(sender As Object, e As EventArgs) + If UsuarioActual.Empresa.Funcionalidad(105) = "" Then + DdlPSFiltro.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacionFilto.SelectedValue.ToEntero) + DdlPSFiltro.DataBind() + DdlPSFiltro.ddl.Items.Insert(0, New ListItem("Todos", "-1")) + Else + DdlPSFiltro.ddlWS.Attributes.Add("data-cveclasificacion", DdlClasificacionFilto.SelectedValue) + DdlPSFiltro.SelectedText = "Todos" + DdlPSFiltro.SelectedValue = "-1" + End If + End Sub + + Protected Sub GvComportamientoVenta_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + + If DdlGrupo.SelectedValue.ToEntero = 20 Then + + If e.Row.DBCampo("PS").ToString = "" Then + e.Row.CssClass = "Totales" + End If + Else + If Not e.Row.DBCampo("CveVenta").ToEntero > 0 Then + e.Row.Cells(5).Text = e.Row.DBCampo("Gpo").ToString + e.Row.CssClass = "Totales" + + End If + End If + End If + End Sub + + Protected Sub BtnConsultarComportamiento_Click(sender As Object, e As EventArgs) + CargaGvComportamientoVenta() + End Sub + + Private Sub CargaGvComportamientoVenta() + Dim ObjVentas As New ClsVentas() + Dim FechaI, FechaF As Date + FechaI = If(IsDate(TxtFechaIFiltro.Text.Trim()), TxtFechaIFiltro.Text.ToDate, MinFecha) + FechaF = If(IsDate(TxtFechaFFiltro.Text.Trim()), TxtFechaFFiltro.Text.ToDate, MaxFecha) + + If ObjVentas.GetRepProductosServiciosDetalle(DdlProyecto.SelectedValue.ToEntero, DdlSubProyectoFiltro.SelectedValue.ToEntero, -1, DdlClasificacionFilto.SelectedValue.ToEntero, + DdlPSFiltro.SelectedValue.ToEntero, FechaI, FechaF, -1, MinFecha, MaxFecha, -1, + CveCliente, -1, DdlVendedorFiltro.SelectedValue.ToEntero, DdlUsuario.SelectedValue.ToEntero, -1, + UsuarioActual.CveEmpresa, CveUsuarioConsulta:=UsuarioActual.CveUsuario, TipoDocto:="Ing", GPO:=DdlGrupo.SelectedValue.ToEntero) Then + GvComportamientoVenta.DataSource = ObjVentas.DtResultados + Else + GvComportamientoVenta.DataSource = Nothing + End If + + ObjVentas.Dispose() + GvComportamientoVenta.DataBind() + UpDatosComportamientoVenta.Update() + End Sub + +#End Region + +#Region "DISPOSITIVOS" + + Protected Sub LnkMoverDispositivo_Click(sender As Object, e As EventArgs) + Dim CveDispositivo As Integer = HdnCveDispositivoMover.Value.ToEntero() + Dim CveCliente As Integer = DdlClienteDispositivo.SelectedValue.ToEntero() + + If CveDispositivo <= 0 Then + Alert("Se debe seleccionar un dispositivo.", TipoMensaje.MsgAdvertencia) + Return + End If + If CveCliente <= 0 Then + Alert("Se debe seleccionar un cliente.", TipoMensaje.MsgAdvertencia) + Return + End If + Dim TieneError As Boolean = False + Dim ObjGPS = New ClsGPS() + Dim ObjEventos As New ClsOIEventos(ObjGPS.IniciaTransacSQL()) + + If ObjGPS.UpdateClienteDispositivo(CveDispositivo, CveCliente) Then + TieneError = Not ObjEventos.AddEventoBitacora($"Se movió el dispositivo: {NombreDispositivo} de cliente. Valor Anterior:{UsuarioActual.Empresa.Empresa}, {LtlCliente.Text} Valor Actual:{DdlEmpresaDispositivo.SelectedItem.Text}, {DdlClienteDispositivo.SelectedItem.Text}", "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCliente:=CveCliente) + Else + TieneError = True + End If + + If TieneError Then + ObjGPS.RollBack() + Alert($"Ocurrió un error al mover el dispostivo.", TipoMensaje.MsgError) + Else + ObjGPS.Commit() + Alert($"El dispositivo '{NombreDispositivo}' se movió correctamente.") + End If + + ObjGPS.Dispose() + ObjEventos.Dispose() + + CargaDispositivos(DdlEstatusDispositivos.SelectedValue.ToEntero()) + CargaEventoBitacora() + NombreDispositivo = "" + RegistraScript("$('#DivMoverDispositivo').modal('hide');") + End Sub + +#End Region + +#Region "CRM" + Protected Sub CargaDatosCRM() + Dim ObjCRM = New ClsCRM() + + If ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa, CveEmpresaCRM) And ObjCRM.DtResultados.Rows.Count > 0 Then + TxtNombre.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Empresa").ToString + TxtNombreComercial.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Empresa").ToString + TxtRFC.Text = ObjCRM.DtResultados.FiltroPrimeroValor("RFC").ToString + + TxtEmail.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Correo").ToString + TxtEmailCotizacion.Text = ObjCRM.DtResultados.FiltroPrimeroValor("Correo").ToString + + DdlVendedor.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveVendedorAsignado").ToString) + DdlSubProyecto.SelectedValueExist(ObjCRM.DtResultados.FiltroPrimeroValor("CveSubProyecto").ToString) + Else + Alert("La empresa CRM solicitada no existe, porfavor verifique", TipoMensaje.MsgAdvertencia) + CveEmpresaCRM = -1 + End If + ObjCRM.Dispose() + End Sub + + Protected Sub VerificaVinculacion() + Dim ObjCRM = New ClsCRM() + + If ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa, -1) And ObjCRM.DtResultados.Rows.Count > 0 Then + If ObjCRM.DtResultados.FiltraParametros(String.Format("CveCliente = {0}", CveCliente)).Rows.Count > 0 Then + LiLnkUnificarCRM.Visible = False + Else + LiLnkUnificarCRM.Visible = True + End If + End If + ObjCRM.Dispose() + End Sub + + Protected Function VincularEmpresaCRM() As Boolean + Dim Ok As Boolean = False + Dim ObjCRM = New ClsCRM() + Dim ObjBitacora = New ClsOIEventos(ObjCRM.IniciaTransacSQL()) + If (CveCliente > 0) Then + + Dim CveEmpresaCRMVincular As Integer = If(CveEmpresaCRM > 0, CveEmpresaCRM, If(CveEmpresaCRMUnificar > 0, CveEmpresaCRMUnificar, -1)) + + If ObjCRM.UpdateEmpresCRM("-2", "-2", -2, CveEmpresaCRMVincular, -2, UsuarioActual.CveUsuario, CveCliente, -1, "-1") Then + If CveEmpresaCRM > 0 Then + ObjBitacora.AddEventoBitacora(String.Format("Se Creó el Cliente: {0} a partir de la Empresa CRM", TxtNombre.Text), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM:=CveEmpresaCRM) + End If + If CveEmpresaCRMUnificar > 0 Then + ObjBitacora.AddEventoBitacora(String.Format("Se Unificó el Cliente: {0} con la Empresa CRM", TxtNombre.Text), "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveEmpresaCRM:=CveEmpresaCRMUnificar) + End If + Ok = True + End If + End If + + If (Ok) Then + ObjCRM.Commit() + Else + ObjCRM.RollBack() + End If + ObjCRM.Dispose() + ObjBitacora.Dispose() + + Return Ok + End Function + + Protected Sub CargaModalEmpresasCRM() + Dim ObjCRM = New ClsCRM() + + If (ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa) And ObjCRM.DtResultados.Rows.Count > 0) Then + DtEmpresasCRM = ObjCRM.DtResultados.FiltraParametros(String.Format("CveCliente IS NULL")) + GvEmpresasCRM.DataSource = DtEmpresasCRM + End If + ObjCRM.Dispose() + GvEmpresasCRM.DataBind() + UpEmpresasCRM.Update() + End Sub + + Protected Sub LnkUnificarCRM_Click(sender As Object, e As EventArgs) + CveEmpresaCRMUnificar = -1 + CargaModalEmpresasCRM() + RegistraScript("$('#DivModalUnificarCRM').modal();") + End Sub + + Protected Sub BtnUnificarCRM_Click(sender As Object, e As EventArgs) + For Each row As GridViewRow In GvEmpresasCRM.Rows + Dim chkSeleccionado As RadioButton = CType(row.FindControl("RBSeleccion"), RadioButton) + If chkSeleccionado.Checked Then + CveEmpresaCRMUnificar = row.DataKey("CveEmpresaCRM").ToEntero + End If + Next + + If CveEmpresaCRMUnificar > 0 Then + If (VincularEmpresaCRM()) Then + LiLnkUnificarCRM.Visible = False + UpAccionesCRM.Update() + + RegistraScript("$('#DivModalUnificarCRM').modal('hide');") + Alert("Se Unificó correctamente al Cliente con la Empresa CRM.") + End If + End If + End Sub +#End Region + +#Region "PORCENTAJE PRECIO DE MARCAS" + Private Sub LnkPorcentajeMarcas_Click(sender As Object, e As EventArgs) Handles LnkPorcentajeMarcas.Click + RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajeMarcas")) + + CreaDT() + + CargaMarcas() + LimpiaModalPorcentaje() + End Sub + Private Sub CreaDT() + Dim DTPorcentajeTemp As New DataTable + + Dim column As DataColumn = New DataColumn("No") + column.DataType = Type.GetType("System.Int32") + With column + .AutoIncrement = True + .AutoIncrementSeed = 1 + .AutoIncrementStep = 1 + End With + + DTPorcentajeTemp.Columns.Add(column) + DTPorcentajeTemp.Columns.Add("CveMarca", GetType(Integer)) + DTPorcentajeTemp.Columns.Add("Marca", GetType(String)) + DTPorcentajeTemp.Columns.Add("PorcentajeProducto", GetType(Decimal)) + DTPorcentajeTemp.Columns.Add("PorcentajeProducto2", GetType(Decimal)) + DTPorcentajeTemp.Columns.Add("PorcentajeProducto3", GetType(Decimal)) + DTPorcentajeTemp.Columns.Add("ProntoPago", GetType(Decimal)) + DTPorcentajeTemp.Columns.Add("Plazo", GetType(Integer)) + DTPorcentajeTemp.Columns.Add("Estatus", GetType(String)) + DTPorcentajePrecios = DTPorcentajeTemp.Clone + End Sub + Private Sub CargaMarcas() + Dim ObjMarcas As New ClsProductosServicios + ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa) + DdlMarcaPS.DataSource = ObjMarcas.DtResultados + ObjMarcas.Dispose() + DdlMarcaPS.DataBind() + DdlMarcaPS.Items.Insert(0, New ListItem("Seleccione", "-1")) + + CargaGridPorcentajes() + UpPorcentaje.Update() + End Sub + + Private Sub CargaGridPorcentajes() + Dim ObjPS As New ClsProductosServicios + + If ObjPS.GetPorcentajeMarcas(CveCliente) Then + DTPorcentajePrecios = ObjPS.DtResultados + GvM.DataSource = DTPorcentajePrecios + End If + ObjPS.Dispose() + + GvM.DataBind() + UppGrid.Update() + + End Sub + Private Sub CargaDTPorcentajePrecios(DtTemp As DataTable) + GvM.DataSource = DtTemp + GvM.DataBind() + + UppGrid.Update() + End Sub + + Private Sub LimpiaModalPorcentaje() + txtPorcentaje.Text = "" + txtPorcentaje2.Text = "" + txtPorcentaje3.Text = "" + txtProntoPago.Text = "" + txtPlazo.Text = "" + DdlMarcaPS.SelectedValue = "-1" + End Sub + + Protected Sub LbAgregarMarca_Click(sender As Object, e As EventArgs) Handles LbAgregarMarca.Click + If txtPorcentaje.Text.ToDecimal > 0 And txtPorcentaje.Text.ToDecimal <= 100 And txtPorcentaje2.Text.ToDecimal >= 0 And txtPorcentaje2.Text.ToDecimal <= 100 And txtPorcentaje3.Text.ToDecimal >= 0 And txtPorcentaje3.Text.ToDecimal <= 100 Then + + Dim registro As DataRow = DTPorcentajePrecios.NewRow + + registro.Item("No") = DTPorcentajePrecios.Rows.Count + 1 + registro.Item("CveMarca") = DdlMarcaPS.SelectedValue.ToEntero + registro.Item("Marca") = DdlMarcaPS.SelectedItem.Text + registro.Item("PorcentajeProducto") = txtPorcentaje.Text.ToDecimal + registro.Item("PorcentajeProducto2") = txtPorcentaje2.Text.ToDecimal + registro.Item("PorcentajeProducto3") = txtPorcentaje3.Text.ToDecimal + registro.Item("ProntoPago") = txtProntoPago.Text.ToDecimal + registro.Item("Plazo") = txtPlazo.Text.ToEntero + registro.Item("Estatus") = "I" + DTPorcentajePrecios.Rows.Add(registro) + CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + Else + Alert("El Porcentaje debe estar en un rango mayor a 0 y menor o igual a 100", TipoMensaje.MsgAdvertencia) + End If + + LimpiaModalPorcentaje() + End Sub + + Protected Sub DeleteRowMarca(sender As Object, e As EventArgs) + + Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) + + + If DTPorcentajePrecios.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then + Dim i As Integer + i = lnkRemove.CommandArgument.ToString.ToEntero + Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", i)) + If Drs.Count > 0 Then + If CveCliente > 0 AndAlso Drs(0)("CveMarca").ToString.ToEntero > 0 Then + Drs(0)("Estatus") = "D" + Else + Drs(0).Delete() + End If + + End If + DTPorcentajePrecios.AcceptChanges() + End If + + GvM.EditIndex = -1 + + CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + + End Sub + + Protected Sub GvM_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvM.RowEditing + GvM.EditIndex = e.NewEditIndex + + CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + End Sub + Protected Sub GvM_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvM.RowCancelingEdit + GvM.EditIndex = -1 + + CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + End Sub + Protected Sub GvM_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvM.RowUpdating + + Dim PorcentajeProducto As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP").Text.ToDouble + Dim PorcentajeProducto2 As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP2").Text.ToDouble + Dim PorcentajeProducto3 As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP3").Text.ToDouble + Dim ProntoPago As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtProntoPagoP").Text.ToDouble + Dim Plazo As Double = GvM.Rows(e.RowIndex).FCTextBox("TxtPlazoP").Text.ToDouble + + If PorcentajeProducto > 0 And PorcentajeProducto <= 100 And PorcentajeProducto2 >= 0 And PorcentajeProducto2 <= 100 And PorcentajeProducto3 >= 0 And PorcentajeProducto3 <= 100 Then + Dim No As Integer = GvM.Rows(e.RowIndex).DataKey("No").ToEntero + + Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", No)) + + If Drs.Count > 0 Then + Drs(0)("PorcentajeProducto") = PorcentajeProducto + Drs(0)("PorcentajeProducto2") = PorcentajeProducto2 + Drs(0)("PorcentajeProducto3") = PorcentajeProducto3 + Drs(0)("ProntoPago") = ProntoPago + Drs(0)("Plazo") = Plazo + If Drs(0)("Estatus").ToString <> "I" Then + Drs(0)("Estatus") = "U" + End If + End If + + DTPorcentajePrecios.AcceptChanges() + GvM.EditIndex = -1 + + CargaDTPorcentajePrecios(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + Else + Alert("El Porcentaje debe estar en un rango mayor a 0 y menor o igual a 100", TipoMensaje.MsgAdvertencia) + End If + + End Sub + + Protected Sub BtnGuardarPorcentajesMarca_Click(sender As Object, e As EventArgs) Handles BtnGuardarPorcentajesMarca.Click + + Dim TieneError As Boolean = False + + Dim ObjPS As New ClsProductosServicios + ObjPS.IniciaTransacSQL() + + For Each Dr As DataRow In DTPorcentajePrecios.Rows + + If Dr("Estatus").ToString <> "" Then + + If Dr("Estatus").ToString = "I" Then + If Not ObjPS.AddPorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal, Dr("PorcentajeProducto2").ToString.ToDecimal, Dr("PorcentajeProducto3").ToString.ToDecimal, UsuarioActual.CveUsuario, Dr("ProntoPago").ToString.ToDecimal, Dr("Plazo").ToString.ToEntero) Then + TieneError = True + End If + ElseIf Dr("Estatus").ToString = "U" Then + If Not ObjPS.UpdatePorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal, Dr("PorcentajeProducto2").ToString.ToDecimal, Dr("PorcentajeProducto3").ToString.ToDecimal, Dr("ProntoPago").ToString.ToDecimal, Dr("Plazo").ToString.ToEntero) Then + TieneError = True + End If + ElseIf Dr("Estatus").ToString = "D" Then + If Not ObjPS.RemovePorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero) Then + TieneError = True + End If + End If + + End If + Next + + If TieneError Then + ObjPS.RollBack() + Else + ObjPS.Commit() + Alert("Los Porcentajes se guardaron correctamente.", TipoMensaje.MsgInformacion) + RegistraScript("$('#DivPorcentajeMarcas').modal('hide')", "hidemodal") + End If + + ObjPS.Dispose() + + End Sub +#End Region + +#Region "PORCENTAJE PRECIO DE PRODUCTOS" + Private Sub LnkPorcentajePrecios_Click(sender As Object, e As EventArgs) Handles LnkPorcentajePrecios.Click + RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajePrecios")) + + CreaDT2() + + TxtPorcentajePS.Attributes.Add("onchange", String.Format("FnCambiaPorcentaje({0});", "5")) + CargaPorcentajesProductos() + LimpiaModalPorcentaje2() + End Sub + Private Sub CreaDT2() + Dim DTPorcentajeTemp As New DataTable + + Dim column As DataColumn = New DataColumn("No") + column.DataType = Type.GetType("System.Int32") + With column + .AutoIncrement = True + .AutoIncrementSeed = 1 + .AutoIncrementStep = 1 + End With + + DTPorcentajeTemp.Columns.Add(column) + DTPorcentajeTemp.Columns.Add("CvePS", GetType(Integer)) + DTPorcentajeTemp.Columns.Add("Producto", GetType(String)) + DTPorcentajeTemp.Columns.Add("PrecioG", GetType(Decimal)) + DTPorcentajeTemp.Columns.Add("PorcentajeProducto", GetType(Decimal)) + DTPorcentajeTemp.Columns.Add("PrecioA", GetType(Decimal)) + DTPorcentajeTemp.Columns.Add("Estatus", GetType(String)) + DTPorcentajePrecios = DTPorcentajeTemp.Clone + End Sub + Private Sub CargaPorcentajesProductos() + 'Llenar el dropdownlist de Secciones + If UsuarioActual.CveEmpresa = 66 Then + DdlClasificacion2.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") + Else + Dim ObjClasificaciones As New ClsClasificaciones + If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then + DdlClasificacion2.DataSource = ObjClasificaciones.DtResultados + End If + ObjClasificaciones.Dispose() + End If + DdlClasificacion2.DataBind() + + CargaPS() + CargaGridPorcentajes2() + + UpPorcentajeP.Update() + End Sub + Private Sub CargaPS() + DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + + If UsuarioActual.CveEmpresa = 66 Then + DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios") + End If + + If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then + DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2") + + DdlProducto2.DataBind() + + DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + + End Sub + + Protected Sub DdlProducto2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlProducto2.selectedindexchange + DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2) + End Sub + Private Sub DdlProducto2IndexChange(CvePSParametro As Integer, Ddl As ADServerControl.Dropdownlost) + Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("") + + If drPS IsNot Nothing Then + Dim Precio = drPS("Precio").ToString.ToDouble + LbPrecioG.Text = Precio.FormatoNumero() + LbPrecioA.Text = ((Precio * TxtPorcentajePS.Text.ToDecimal) / 100).FormatoNumero + End If + End Sub + + Private Sub CargaGridPorcentajes2() + Dim ObjPS As New ClsProductosServicios + + If ObjPS.GetPorcentajeProductos(CveCliente) Then + DTPorcentajePrecios = ObjPS.DtResultados + GvP.DataSource = DTPorcentajePrecios + End If + ObjPS.Dispose() + + GvP.DataBind() + UpPorcentajePS.Update() + + End Sub + Private Sub CargaDTPorcentajePrecios2(DtTemp As DataTable) + GvP.DataSource = DtTemp + GvP.DataBind() + + UpPorcentajePS.Update() + End Sub + + Private Sub LimpiaModalPorcentaje2() + TxtPorcentajePS.Text = "" + DdlClasificacion2.SelectedValue = "-1" + DdlProducto2.SelectedText = "" + End Sub + + Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click + + If DdlProducto2.SelectedText <> "" Then + If TxtPorcentajePS.Text.ToDecimal >= 0 And TxtPorcentajePS.Text.ToDecimal <= 100 Then + + Dim registro As DataRow = DTPorcentajePrecios.NewRow + + registro.Item("No") = DTPorcentajePrecios.Rows.Count + 1 + registro.Item("CvePS") = DdlProducto2.SelectedValue.ToEntero + registro.Item("Producto") = DdlProducto2.SelectedText + registro.Item("PrecioG") = LbPrecioG.Text.ToDecimal + registro.Item("PrecioA") = LbPrecioG.Text.ToDecimal * TxtPorcentajePS.Text.ToDecimal / 100 + registro.Item("PorcentajeProducto") = TxtPorcentajePS.Text.ToDecimal + registro.Item("Estatus") = "I" + DTPorcentajePrecios.Rows.Add(registro) + CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + Else + Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia) + End If + Else + Alert("El campo ''Producto'' es necesario, por favor ingréselo.", TipoMensaje.MsgAdvertencia) + End If + + LimpiaModalPorcentaje() + End Sub + + Protected Sub DeleteRow(sender As Object, e As EventArgs) + + Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton) + + + If DTPorcentajePrecios.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then + Dim i As Integer + i = lnkRemove.CommandArgument.ToString.ToEntero + Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", i)) + If Drs.Count > 0 Then + If CveCliente > 0 AndAlso Drs(0)("CvePS").ToString.ToEntero > 0 Then + Drs(0)("Estatus") = "D" + Else + Drs(0).Delete() + End If + + End If + DTPorcentajePrecios.AcceptChanges() + End If + + GvP.EditIndex = -1 + + CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + + End Sub + + Protected Sub GvP_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvP.RowEditing + GvP.EditIndex = e.NewEditIndex + + CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + End Sub + Protected Sub GvP_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvP.RowCancelingEdit + GvP.EditIndex = -1 + + CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + End Sub + Protected Sub GvP_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvP.RowUpdating + + Dim PorcentajeProducto As Double = GvP.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP").Text.ToDouble + + If PorcentajeProducto >= 0 And PorcentajeProducto <= 100 Then + Dim No As Integer = GvP.Rows(e.RowIndex).DataKey("No").ToEntero + + Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", No)) + + If Drs.Count > 0 Then + Drs(0)("PorcentajeProducto") = PorcentajeProducto + Drs(0)("PrecioA") = Drs(0)("PrecioG").ToString.ToDouble * PorcentajeProducto / 100 + If Drs(0)("Estatus").ToString <> "I" Then + Drs(0)("Estatus") = "U" + End If + End If + + DTPorcentajePrecios.AcceptChanges() + GvP.EditIndex = -1 + + CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' ")) + Else + Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia) + End If + + End Sub + + Protected Sub BtnGuardarPorcentajes_Click(sender As Object, e As EventArgs) Handles BtnGuardarPorcentajes.Click + + Dim TieneError As Boolean = False + + Dim ObjPS As New ClsProductosServicios + ObjPS.IniciaTransacSQL() + + For Each Dr As DataRow In DTPorcentajePrecios.Rows + + If Dr("Estatus").ToString <> "" Then + + If Dr("Estatus").ToString = "I" Then + If Not ObjPS.AddPorcentajeProductos(CveCliente, Dr("CvePS").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal, UsuarioActual.CveUsuario) Then + TieneError = True + End If + ElseIf Dr("Estatus").ToString = "U" Then + If Not ObjPS.UpdatePorcentajeProductos(CveCliente, Dr("CvePS").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal) Then + TieneError = True + End If + ElseIf Dr("Estatus").ToString = "D" Then + If Not ObjPS.RemovePorcentajeProductos(CveCliente, Dr("CvePS").ToString.ToEntero) Then + TieneError = True + End If + End If + + End If + Next + + If TieneError Then + ObjPS.RollBack() + Else + ObjPS.Commit() + Alert("Los Porcentajes se guardaron correctamente.", TipoMensaje.MsgInformacion) + RegistraScript("$('#DivPorcentajePrecios').modal('hide')", "hidemodal") + End If + + ObjPS.Dispose() + + End Sub + + Protected Sub BtnCambiaPorcentaje_Click(sender As Object, e As EventArgs) + DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2) + End Sub +#End Region + +#Region " A C U M U L A D O R E S" + + + Protected Sub LnkFacturaUsadosCargos_Click(sender As Object, e As EventArgs) + 'CveVentaNota = 0 + + 'Dim Cargos As Decimal = 0D + 'Dim Iva As Decimal = 0D + + 'For Each GvRow As GridViewRow In GvAcum.Rows + + ' If GvRow.DataKey("CveConcepto").ToEntero = 1 And GvRow.FCCheckBox("ChkCargo").Checked Then + ' Cargos = Cargos + GvRow.DataKey("ImporteCargo").ToDecimal + ' End If + 'Next + + 'Dim CvePS As Integer = UsuarioActual.Empresa.Funcionalidad(534).ToEntero 'CvePS Distruibuidor Cargo Nota + 'Dim CveUnidadMedida As Integer + 'Dim CveClasificacion As Integer + + 'If CvePS > 0 Then + + ' If Cargos > 0 Then + + ' CveUnidadMedida = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveUnidadMedida").ToString.ToEntero + ' CveClasificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveClasificacion").ToString.ToEntero + ' Iva = Cargos * 0.16D + + ' If GenerarNotaCredito(CvePS, 1, CveUnidadMedida, Cargos, Iva, "Clientes/Usados", CveClasificacion) Then + ' Alert($"LA nota de crédito fue generada correctamente {SerieNotaAcumulador}-{FolioNotaAcumulador}") + ' Else + ' Alert("Se presento un error al generar la nota de creédito", TipoMensaje.MsgError) + ' End If + ' End If + + 'Else + ' Alert("No esta asignada la funcionalidad CvePS Distruibuidor Cargo Nota") + 'End If + + CreaObjetosVenta(1) + + 'If ObjFactura.CveCliente > 0 Then + ' If TmpDT.Rows.Count > 0 Then + ' Dim Retorno = ObjFactura.EmitirFactura(false) + ' For Each Mensaje In Retorno.Mensajes + ' Alert(Mensaje, If(Retorno.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion)) + ' Next + ' End If + 'End If + + CargaUsados() + + End Sub + Protected Sub LnkFacturaUsadosBonificacion_Click(sender As Object, e As EventArgs) + + 'CveVentaNota = 0 + 'Dim Bonificacion As Decimal = 0D + 'Dim Iva As Decimal = 0D + + 'For Each GvRow As GridViewRow In GvAcum.Rows + ' If GvRow.DataKey("CveConcepto").ToEntero = 1 And GvRow.FCCheckBox("ChkBonificacion").Checked Then + ' Bonificacion = Bonificacion + GvRow.DataKey("ImporteBonificacion").ToDecimal + ' End If + 'Next + + + 'Dim CvePS As Integer = UsuarioActual.Empresa.Funcionalidad(534).ToEntero 'CvePS Distruibuidor Bonificación Nota + 'Dim CveUnidadMedida As Integer + 'Dim CveClasificacion As Integer + 'If CvePS > 0 Then + ' If Bonificacion > 0 Then + + ' CveUnidadMedida = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveUnidadMedida").ToString.ToEntero + ' CveClasificacion = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).FiltroPrimeroValor("CveClasificacion").ToString.ToEntero + ' Iva = Bonificacion * 0.16D + + ' If GenerarNotaCredito(CvePS, 2, CveUnidadMedida, Bonificacion, Iva, "Clientes/Usados", CveClasificacion) Then + ' Alert($"LA nota de crédito fue generada correctamente {SerieNotaAcumulador}-{FolioNotaAcumulador}") + ' Else + ' Alert("Se presento un error al generar la nota de creédito", TipoMensaje.MsgError) + ' End If + + ' End If + + 'Else + ' Alert("No esta asignada la funcionalidad CvePS Distruibuidor Bonificación Nota") + 'End If + + CreaObjetosVenta(2) + + If ObjFactura.CveCliente > 0 Then + If TmpDT.Rows.Count > 0 Then + Dim Retorno = ObjFactura.EmitirFactura(False) + For Each Mensaje In Retorno.Mensajes + Alert(Mensaje, If(Retorno.TieneError, TipoMensaje.MsgError, TipoMensaje.MsgInformacion)) + Next + End If + End If + + Alert("Listo") + + CargaUsados() + + + End Sub + + + Function FolioNotaCredito(Tipo As Integer) As Boolean + + FolioNotaAcumulador = 0 + SerieNotaAcumulador = "" + Dim Respuesta As Boolean = False + + Dim ObjFolios As New ClsGralFolios() + + Dim DTSucursales As DataTable = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1).FiltraParametros("EsSucursal = True ") + + If DTSucursales.Rows.Count > 0 Then + + If ObjFolios.GetFolios("RNC", UsuarioActual.CveEmpresa) Then + Dim CveSubProyecto As Integer = DTSucursales.FiltroPrimeroValor("CveSubProyecto", "").ToEntero + Dim DT As DataTable + If CveSubProyecto > 0 Then + DT = ObjFolios.DtResultados.FiltraParametros(" Estado = 'Activo' AND LEN(Serie) > 0 AND CveSubProyecto = " & CveSubProyecto) + Else + DT = ObjFolios.DtResultados.FiltraParametros(" Estado = 'Activo' AND LEN(Serie) > 0 ") + End If + + If DT.Rows.Count > 0 Then + FolioNotaAcumulador = DT.Rows(0)("FActual").ToString.ToEntero + SerieNotaAcumulador = DT.Rows(0)("Serie").ToString + Respuesta = True + End If + + End If + End If + + ObjFolios.Dispose() + + Return Respuesta + + End Function + + Private Sub GvAcum_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAcum.RowDataBound + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DataKey("CveConcepto").ToEntero = 1 Then + + Dim FacturadoCargo As Boolean = Boolean.Parse(e.Row.DataKey("FacturadoCargo")) + Dim FacturadoBonificacion As Boolean = Boolean.Parse(e.Row.DataKey("FacturadoBonificacion")) + + If FacturadoCargo Then + e.Row.FCCheckBox("ChkCargo").Checked = False + e.Row.FCCheckBox("ChkCargo").Visible = False + Else + e.Row.FCCheckBox("ChkCargo").Checked = False e.Row.FCCheckBox("ChkCargo").Visible = False 'True - End If - - If FacturadoBonificacion Then - e.Row.FCCheckBox("ChkBonificacion").Checked = False - e.Row.FCCheckBox("ChkBonificacion").Visible = False - Else - e.Row.FCCheckBox("ChkBonificacion").Checked = False - e.Row.FCCheckBox("ChkBonificacion").Visible = True - End If - - Else - e.Row.FCCheckBox("ChkCargo").Checked = False - e.Row.FCCheckBox("ChkCargo").Visible = False - - e.Row.FCCheckBox("ChkBonificacion").Checked = False - e.Row.FCCheckBox("ChkBonificacion").Visible = False - End If - - End If - - End Sub - - Protected Sub BtnConsultaUsados_Click(sender As Object, e As EventArgs) - CargaUsados() - End Sub - - Private Sub CargaUsados() - - If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then ' Funcionalidad Es Distribuidor - - DivEsDistribuidor.Visible = True - TabUsados.Visible = True - - Dim ObjAcum As New ClsAcumuladores - Dim ImporteCargo As Decimal = 0D - Dim ImporteBonificacion As Decimal = 0D - - If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, TxtFechaIUsados.Text.ToDate, TxtFechaFUsados.Text.ToDate) Then - - GvAcum.DataSource = ObjAcum.DtResultados - - LblUsadosPuntos.Text = (ObjAcum.DtResultados.SUM("Puntos", " CveConcepto = 2 ") - ObjAcum.DtResultados.SUM("Puntos", " CveConcepto IN (1,3) ")).ToDecimal.FormatoNumero(2) - - ImporteCargo = ObjAcum.DtResultados.SUM("ImporteCargo", "(FacturadoCargo = 0 OR FacturadoCargo IS NULL) AND CveConcepto = 1 ").ToDecimal - ImporteBonificacion = ObjAcum.DtResultados.SUM("ImporteBonificacion", "(FacturadoBonificacion = 0 OR FacturadoBonificacion IS NULL) AND CveConcepto = 1 ").ToDecimal - - LblUsadosImpCargo.Text = ImporteCargo.FormatoNumero(2) - LblusadosImpBonificacion.Text = ImporteBonificacion.FormatoNumero(2) - - Else - GvAcum.DataSource = Nothing - - ImporteCargo = 0D - ImporteBonificacion = 0D - - LblUsadosImpCargo.Text = "" - LblusadosImpBonificacion.Text = "" - LblUsadosPuntos.Text = "" - - End If - - 'LnkFacturaUsadosCargos.Visible = If(ImporteCargo > 0, True, False) - LnkFacturaUsadosBonificacion.Visible = If(ImporteBonificacion > 0, True, False) - - ObjAcum.Dispose() - GvAcum.DataBind() - - UpAcciones.Update() - UpUsadosResumen.Update() - UpAcum.Update() - - End If - - End Sub - - Private Sub CreaDTVentas() - TmpDT = New DataTable - TmpDT.Columns.Add("CveVenta", GetType(Integer)) - TmpDT.Columns.Add("Consec", GetType(Integer)) - TmpDT.Columns.Add("Cantidad", GetType(Decimal)) - TmpDT.Columns.Add("Codigo", GetType(String)) - TmpDT.Columns.Add("CveUM", GetType(Integer)) - TmpDT.Columns.Add("UM", GetType(String)) - TmpDT.Columns.Add("SATClaveUM", 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("SATClaveProdServ", GetType(String)) - TmpDT.Columns.Add("NoIdentificacion", GetType(String)) - TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) - TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) - TmpDT.Columns.Add("SerieLote", GetType(String)) - TmpDT.Columns.Add("CuentaPredial", GetType(String)) - TmpDT.Columns.Add("Obs", GetType(String)) - TmpDT.Columns.Add("TiempoEntrega", GetType(String)) - TmpDT.Columns.Add("PU", GetType(Decimal)) - TmpDT.Columns.Add("IVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal)) - TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal)) - TmpDT.Columns.Add("IEPS", GetType(Decimal)) - TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal)) - TmpDT.Columns.Add("Descuento", GetType(Decimal)) - TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) - TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) - TmpDT.Columns.Add("Total", GetType(Decimal)) - 'Para uso del módulo contable - TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer)) - TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer)) - TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean)) - TmpDT.Columns.Add("CveProyecto", GetType(Integer)) - TmpDT.Columns.Add("Proyecto", GetType(String)) - TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) - TmpDT.Columns.Add("SubProyecto", GetType(String)) - TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer)) - - 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto - TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer)) - TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer)) - 'Contratos - TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) - 'Remisiones a Facturas - TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer)) - TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) - - 'Pedido2 a Facturas - TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer)) - - TmpDT.Columns.Add("Origen", GetType(Integer)) - 'Ordenes Servicio - TmpDT.Columns.Add("CveOS", GetType(Integer)) - TmpDT.Columns.Add("CveOSDetalle", GetType(Integer)) - TmpDT.Columns.Add("SeFacturara", GetType(Integer)) - TmpDT.Columns.Add("Folio", GetType(Integer)) - TmpDT.Columns.Add("Estatus", GetType(String)) - 'Ordenamiento - TmpDT.Columns.Add("Orden", GetType(Integer)) - TmpDT.Columns.Add("TipoDocto", GetType(String)) - 'OC - TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) - TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) - - TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) - TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal)) - TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal)) - TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal)) - TmpDT.Columns.Add("CantidadInventario", GetType(Decimal)) - - TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String)) - TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) - TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) - - TmpDT.Columns.Add("CveTamaño", GetType(Integer)) - TmpDT.Columns.Add("EsCargo", GetType(Boolean)) - - End Sub - Private Function AgregarProductoServicio(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String, - PU As Decimal, Descuento As Decimal, - CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, - Optional SerieLote As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0, - Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0, - Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, - Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional EsCargo As Boolean = False, Optional PorcentajeIVA As Decimal = 0D) As Boolean - - Dim Retorno As Boolean = False - If Not CvePS > 0 Then - Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Return False - End If - - If (Obs.Length + PS.Length > 1000) Then - Alert(String.Format("El Nombre y observación del producto tiene longitud de {0} caracteres y excede los 1000 caracteres permitidos.", Obs.Length + PS.Length), TipoMensaje.MsgAdvertencia) - Return False - End If - - - Dim Row As DataRow = Nothing - Dim TotalCalculableImpuestos As Decimal = 0 - PU = Math.Round(PU, 6) ' el precio unitario puede llevar hasta 6 decimales permitidos - - Row = TmpDT.NewRow() - Row("CveProyecto") = CveProyecto - Row("Proyecto") = Proyecto - Row("CveSubProyecto") = CveSubProyecto - Row("SubProyecto") = SubProyecto - Row("SerieLote") = SerieLote - Row("TiempoEntrega") = TiempoEntrega - Row("Orden") = TmpDT.Rows.Count + 1 - Row("Cantidad") = Cantidad - Row("CveUM") = CveUM - Row("UM") = UM - Row("CveClasificacion") = CveClasificacion - Row("Clasificacion") = Clasificacion - Row("CvePS") = CvePS - Row("Obs") = Obs - - - - Dim DrPS As DataRow = Nothing - - DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1 - - If DrPS Is Nothing Then - Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Return False - End If - - - DrPS("IEPSPorcentaje") = 0 - - 'verifica si tiene ventaminima - If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then - 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15... - If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then - Alert(String.Format("El producto se vende solo en cantidades de {0}", DrPS("VentaMinima").ToString)) - Return False - End If - End If - - TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento - - Row("PU") = PU - Row("Codigo") = DrPS("Codigo") - Row("NoIdentificacion") = DrPS("Codigo") - Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria") - Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana") - Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion") - Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion") - Row("Consec") = TmpDT.Rows.Count + 1 - - Row("PS") = DrPS("PS") - Row("CodigoPS") = DrPS("PSCodigo").ToString - Row("CveTipoPS") = DrPS("CveTipoPS") - Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario") - Row("CveTamaño") = DrPS("CveTamaño") - - If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion") - If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion") - - Row("PorcentajeIVA") = PorcentajeIVA - - Row("IVA") = Row("PorcentajeIVA") - Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) - - - Row("ImporteRetIVA") = 0 - Row("ImporteRetISR") = 0 - Row("PorcentajeRetIVA") = 0 - Row("PorcentajeRetISR") = 0 - Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje") - Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) - Row("IEPS") = Row("ImporteIEPS") - Row("Descuento") = Math.Round(Descuento, NumeroDecimales) - Row("TipoDescuento") = 0 - Row("Total") = (Cantidad * PU) - Row("TotalImporte") = Math.Round(Cantidad * PU, NumeroDecimales) - 'Row("AsientoContableVentas") = DrPS("AsientoContableVentas") - ' Row("IdCtaContVentas") = IdCtaContable - ' Row("AplicaParaConcepto") = AplicaParaConcepto - - Row("SATClaveProdServ") = DrPS("SATClavePS") - Row("SATClaveUM") = DrPS("SATClaveUnidadMedida") - - - Row("EntregaDirecta") = EntregaDirecta - 'Contratos - Row("CveContratoDetalle") = CveContratoDetalle - Row("CveVentaDetalle") = CveVentaDetalle - Row("CveMovimientoDetallePedido") = CveVentaDetalle - Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle - Row("CveVentaDetalleRemision") = CveVentaDetalleRemision - Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion - Row("CveVentaDetallePedido2") = CveVentaDetallePedido2 - Row("CuentaPredial") = CuentaPredial - Row("EsCargo") = EsCargo - - 'RECARGAR GV - TmpDT.Rows.Add(Row) - TmpDT.AcceptChanges() - Retorno = True - Return Retorno - - End Function - Private Sub CreaObjetosVenta(Tipo As Integer) - - Dim SubTotal As Decimal = 0D - Dim IVA As Decimal = 0D - - For Each GvRow As GridViewRow In GvAcum.Rows - If Tipo = 1 Then - If GvRow.DataKey("CveConcepto").ToEntero = 1 And GvRow.FCCheckBox("ChkCargo").Checked Then - SubTotal = SubTotal + GvRow.DataKey("ImporteCargo").ToDecimal - End If - ElseIf Tipo = 2 Then - If GvRow.DataKey("CveConcepto").ToEntero = 1 And GvRow.FCCheckBox("ChkBonificacion").Checked Then - SubTotal = SubTotal + GvRow.DataKey("ImporteBonificacion").ToDecimal - End If - End If - Next - - Dim CvePS As Integer = UsuarioActual.Empresa.Funcionalidad(534).ToEntero 'CvePS Distruibuidor Bonificación Nota - Dim CveUnidadMedida As Integer = 0 - Dim CveClasificacion As Integer = 0 - Dim UnidadMedida As String = "" - Dim Clasificacion As String = "" - Dim PS As String = "" - Dim PorcentajeIVA As Decimal = 0D - If CvePS > 0 Then - If SubTotal > 0 Then - Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).Rows(0) - If Dr IsNot Nothing Then - CveUnidadMedida = Dr("CveUnidadMedida").ToString.ToEntero - CveClasificacion = Dr("CveClasificacion").ToString.ToEntero - PS = Dr("PSCodigo").ToString - UnidadMedida = Dr("UnidadMedida").ToString - Clasificacion = Dr("Clasificacion").ToString - End If - PorcentajeIVA = 0.16D - IVA = SubTotal * PorcentajeIVA - End If - End If - - TmpDT.Rows.Clear() - TmpDT.AcceptChanges() - AgregarProductoServicio(1, CveUnidadMedida, UnidadMedida, CveClasificacion, Clasificacion, CvePS, PS, "Clientes/Usados", SubTotal, 0, -1, "", DdlSubProyecto.SelectedValue.ToEntero, - DdlSubProyecto.SelectedItem.Text, PorcentajeIVA:=PorcentajeIVA) - - Dim Folio As Integer = -1 - Dim Serie As String = "" - - 'If FolioNotaCredito(Tipo) Then - ' Folio = FolioNotaAcumulador - ' Serie = SerieNotaAcumulador - 'End If - + End If + + If FacturadoBonificacion Then + e.Row.FCCheckBox("ChkBonificacion").Checked = False + e.Row.FCCheckBox("ChkBonificacion").Visible = False + Else + e.Row.FCCheckBox("ChkBonificacion").Checked = False + e.Row.FCCheckBox("ChkBonificacion").Visible = True + End If + + Else + e.Row.FCCheckBox("ChkCargo").Checked = False + e.Row.FCCheckBox("ChkCargo").Visible = False + + e.Row.FCCheckBox("ChkBonificacion").Checked = False + e.Row.FCCheckBox("ChkBonificacion").Visible = False + End If + + End If + + End Sub + + Protected Sub BtnConsultaUsados_Click(sender As Object, e As EventArgs) + CargaUsados() + End Sub + + Private Sub CargaUsados() + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then ' Funcionalidad Es Distribuidor + + DivEsDistribuidor.Visible = True + TabUsados.Visible = True + + Dim ObjAcum As New ClsAcumuladores + Dim ImporteCargo As Decimal = 0D + Dim ImporteBonificacion As Decimal = 0D + + If ObjAcum.DistribuidorMovtosGet(CveCliente, UsuarioActual.CveEmpresa, TxtFechaIUsados.Text.ToDate, TxtFechaFUsados.Text.ToDate) Then + + GvAcum.DataSource = ObjAcum.DtResultados + + LblUsadosPuntos.Text = (ObjAcum.DtResultados.SUM("Puntos", " CveConcepto = 2 ") - ObjAcum.DtResultados.SUM("Puntos", " CveConcepto IN (1,3) ")).ToDecimal.FormatoNumero(2) + + ImporteCargo = ObjAcum.DtResultados.SUM("ImporteCargo", "(FacturadoCargo = 0 OR FacturadoCargo IS NULL) AND CveConcepto = 1 ").ToDecimal + ImporteBonificacion = ObjAcum.DtResultados.SUM("ImporteBonificacion", "(FacturadoBonificacion = 0 OR FacturadoBonificacion IS NULL) AND CveConcepto = 1 ").ToDecimal + + LblUsadosImpCargo.Text = ImporteCargo.FormatoNumero(2) + LblusadosImpBonificacion.Text = ImporteBonificacion.FormatoNumero(2) + + Else + GvAcum.DataSource = Nothing + + ImporteCargo = 0D + ImporteBonificacion = 0D + + LblUsadosImpCargo.Text = "" + LblusadosImpBonificacion.Text = "" + LblUsadosPuntos.Text = "" + + End If + + 'LnkFacturaUsadosCargos.Visible = If(ImporteCargo > 0, True, False) + LnkFacturaUsadosBonificacion.Visible = If(ImporteBonificacion > 0, True, False) + + ObjAcum.Dispose() + GvAcum.DataBind() + + UpAcciones.Update() + UpUsadosResumen.Update() + UpAcum.Update() + + End If + + End Sub + + Private Sub CreaDTVentas() + TmpDT = New DataTable + TmpDT.Columns.Add("CveVenta", GetType(Integer)) + TmpDT.Columns.Add("Consec", GetType(Integer)) + TmpDT.Columns.Add("Cantidad", GetType(Decimal)) + TmpDT.Columns.Add("Codigo", GetType(String)) + TmpDT.Columns.Add("CveUM", GetType(Integer)) + TmpDT.Columns.Add("UM", GetType(String)) + TmpDT.Columns.Add("SATClaveUM", 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("SATClaveProdServ", GetType(String)) + TmpDT.Columns.Add("NoIdentificacion", GetType(String)) + TmpDT.Columns.Add("CveTipoPS", GetType(Integer)) + TmpDT.Columns.Add("CveTipoInvPS", GetType(Integer)) + TmpDT.Columns.Add("SerieLote", GetType(String)) + TmpDT.Columns.Add("CuentaPredial", GetType(String)) + TmpDT.Columns.Add("Obs", GetType(String)) + TmpDT.Columns.Add("TiempoEntrega", GetType(String)) + TmpDT.Columns.Add("PU", GetType(Decimal)) + TmpDT.Columns.Add("IVA", GetType(Decimal)) + TmpDT.Columns.Add("ImporteIVA", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeIVA", GetType(Decimal)) + TmpDT.Columns.Add("ImporteRetIVA", GetType(Decimal)) + TmpDT.Columns.Add("ImporteRetISR", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeRetIVA", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeRetISR", GetType(Decimal)) + TmpDT.Columns.Add("ImporteIEPS", GetType(Decimal)) + TmpDT.Columns.Add("IEPS", GetType(Decimal)) + TmpDT.Columns.Add("PorcentajeIEPS", GetType(Decimal)) + TmpDT.Columns.Add("Descuento", GetType(Decimal)) + TmpDT.Columns.Add("TipoDescuento", GetType(Integer)) + TmpDT.Columns.Add("TotalImporte", GetType(Decimal)) + TmpDT.Columns.Add("Total", GetType(Decimal)) + 'Para uso del módulo contable + TmpDT.Columns.Add("AsientoContableVentas", GetType(Integer)) + TmpDT.Columns.Add("IdCtaContVentas", GetType(Integer)) + TmpDT.Columns.Add("AplicaParaConcepto", GetType(Boolean)) + TmpDT.Columns.Add("CveProyecto", GetType(Integer)) + TmpDT.Columns.Add("Proyecto", GetType(String)) + TmpDT.Columns.Add("CveSubProyecto", GetType(Integer)) + TmpDT.Columns.Add("SubProyecto", GetType(String)) + TmpDT.Columns.Add("CveVentaDetallePadre", GetType(Integer)) + + 'TipoDescuento: 1 = Descuento * PU; 2 = Descuento por Total del concepto + TmpDT.Columns.Add("CvePresupuestoIngreso", GetType(Integer)) + TmpDT.Columns.Add("CveFuenteRecaudacion", GetType(Integer)) + 'Contratos + TmpDT.Columns.Add("CveContratoDetalle", GetType(Integer)) + 'Remisiones a Facturas + TmpDT.Columns.Add("CveVentaDetalle", GetType(Integer)) + TmpDT.Columns.Add("CveVentaDetalleRemision", GetType(Integer)) + TmpDT.Columns.Add("CveVentaDetalleCotizacion", GetType(Integer)) + + 'Pedido2 a Facturas + TmpDT.Columns.Add("CveVentaDetallePedido2", GetType(Integer)) + + TmpDT.Columns.Add("Origen", GetType(Integer)) + 'Ordenes Servicio + TmpDT.Columns.Add("CveOS", GetType(Integer)) + TmpDT.Columns.Add("CveOSDetalle", GetType(Integer)) + TmpDT.Columns.Add("SeFacturara", GetType(Integer)) + TmpDT.Columns.Add("Folio", GetType(Integer)) + TmpDT.Columns.Add("Estatus", GetType(String)) + 'Ordenamiento + TmpDT.Columns.Add("Orden", GetType(Integer)) + TmpDT.Columns.Add("TipoDocto", GetType(String)) + 'OC + TmpDT.Columns.Add("CveOrdenCompraDetalle", GetType(Integer)) + TmpDT.Columns.Add("EntregaDirecta", GetType(Integer)) + + TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer)) + TmpDT.Columns.Add("CantidadFacturadaRem", GetType(Decimal)) + TmpDT.Columns.Add("CantidadFacturadaCot", GetType(Decimal)) + TmpDT.Columns.Add("CantidadFacturadaPed2", GetType(Decimal)) + TmpDT.Columns.Add("CantidadInventario", GetType(Decimal)) + + TmpDT.Columns.Add("ClaveSATFraccionArancelaria", GetType(String)) + TmpDT.Columns.Add("ClaveSATUnidadAduana", GetType(String)) + TmpDT.Columns.Add("ClaveSATFraccionArancelariaDescripcion", GetType(String)) + TmpDT.Columns.Add("ClaveSATUnidadAduanaDescripcion", GetType(String)) + + TmpDT.Columns.Add("CveTamaño", GetType(Integer)) + TmpDT.Columns.Add("EsCargo", GetType(Boolean)) + + End Sub + Private Function AgregarProductoServicio(Cantidad As Decimal, CveUM As Integer, UM As String, CveClasificacion As Integer, Clasificacion As String, CvePS As Integer, PS As String, Obs As String, + PU As Decimal, Descuento As Decimal, + CveProyecto As Integer, Proyecto As String, CveSubProyecto As Integer, SubProyecto As String, + Optional SerieLote As String = "", Optional TiempoEntrega As String = "", Optional EntregaDirecta As Integer = 0, + Optional CveContratoDetalle As Integer = 0, Optional CveVentaDetalle As Integer = 0, Optional CveMovimientoDetallePedido As Integer = 0, + Optional CveOrdenCompraDetalle As Integer = 0, Optional CveVentaDetalleRemision As Integer = 0, Optional CveVentaDetalleCotizacion As Integer = 0, + Optional CuentaPredial As String = "", Optional RegeneraIEPS As Boolean = True, Optional CveVentaDetallePedido2 As Integer = 0, Optional EsCargo As Boolean = False, Optional PorcentajeIVA As Decimal = 0D) As Boolean + + Dim Retorno As Boolean = False + If Not CvePS > 0 Then + Alert("Ocurrió un error al cargar la información del producto a agregar. Por favor verifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Return False + End If + + If (Obs.Length + PS.Length > 1000) Then + Alert(String.Format("El Nombre y observación del producto tiene longitud de {0} caracteres y excede los 1000 caracteres permitidos.", Obs.Length + PS.Length), TipoMensaje.MsgAdvertencia) + Return False + End If + + + Dim Row As DataRow = Nothing + Dim TotalCalculableImpuestos As Decimal = 0 + PU = Math.Round(PU, 6) ' el precio unitario puede llevar hasta 6 decimales permitidos + + Row = TmpDT.NewRow() + Row("CveProyecto") = CveProyecto + Row("Proyecto") = Proyecto + Row("CveSubProyecto") = CveSubProyecto + Row("SubProyecto") = SubProyecto + Row("SerieLote") = SerieLote + Row("TiempoEntrega") = TiempoEntrega + Row("Orden") = TmpDT.Rows.Count + 1 + Row("Cantidad") = Cantidad + Row("CveUM") = CveUM + Row("UM") = UM + Row("CveClasificacion") = CveClasificacion + Row("Clasificacion") = Clasificacion + Row("CvePS") = CvePS + Row("Obs") = Obs + + + + Dim DrPS As DataRow = Nothing + + DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimero("") ' Estado = -1 + + If DrPS Is Nothing Then + Alert("Ocurrió un error al cargar la información del Producto. Por favor vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Return False + End If + + + DrPS("IEPSPorcentaje") = 0 + + 'verifica si tiene ventaminima + If Cantidad > 0 AndAlso DrPS("VentaMinima").ToString.ToDecimal > 0 Then + 'verifico que la cantidad sea multiplo de venta minima, es decir ventaminima =5, solo puede vender 5,10,15... + If Cantidad Mod DrPS("VentaMinima").ToString.ToDecimal <> 0 Then + Alert(String.Format("El producto se vende solo en cantidades de {0}", DrPS("VentaMinima").ToString)) + Return False + End If + End If + + TotalCalculableImpuestos = (Cantidad * (PU)) - Descuento + + Row("PU") = PU + Row("Codigo") = DrPS("Codigo") + Row("NoIdentificacion") = DrPS("Codigo") + Row("ClaveSATFraccionArancelaria") = DrPS("ClaveSATFraccionArancelaria") + Row("ClaveSATUnidadAduana") = DrPS("ClaveSATUnidadAduana") + Row("ClaveSATFraccionArancelariaDescripcion") = DrPS("ClaveSATFraccionArancelariaDescripcion") + Row("ClaveSATUnidadAduanaDescripcion") = DrPS("ClaveSATUnidadAduanaDescripcion") + Row("Consec") = TmpDT.Rows.Count + 1 + + Row("PS") = DrPS("PS") + Row("CodigoPS") = DrPS("PSCodigo").ToString + Row("CveTipoPS") = DrPS("CveTipoPS") + Row("CveTipoInvPS") = DrPS("Inv_CveMetodoInventario") + Row("CveTamaño") = DrPS("CveTamaño") + + If CveClasificacion <= 0 Then Row("CveClasificacion") = DrPS("CveClasificacion") + If Clasificacion = "" Then Row("Clasificacion") = DrPS("Clasificacion") + + Row("PorcentajeIVA") = PorcentajeIVA + + Row("IVA") = Row("PorcentajeIVA") + Row("ImporteIVA") = Math.Round(Row("PorcentajeIVA").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + + + Row("ImporteRetIVA") = 0 + Row("ImporteRetISR") = 0 + Row("PorcentajeRetIVA") = 0 + Row("PorcentajeRetISR") = 0 + Row("PorcentajeIEPS") = DrPS("IEPSPorcentaje") + Row("ImporteIEPS") = Math.Round(DrPS("IEPSPorcentaje").ToString.ToDecimal * TotalCalculableImpuestos, NumeroDecimales) + Row("IEPS") = Row("ImporteIEPS") + Row("Descuento") = Math.Round(Descuento, NumeroDecimales) + Row("TipoDescuento") = 0 + Row("Total") = (Cantidad * PU) + Row("TotalImporte") = Math.Round(Cantidad * PU, NumeroDecimales) + 'Row("AsientoContableVentas") = DrPS("AsientoContableVentas") + ' Row("IdCtaContVentas") = IdCtaContable + ' Row("AplicaParaConcepto") = AplicaParaConcepto + + Row("SATClaveProdServ") = DrPS("SATClavePS") + Row("SATClaveUM") = DrPS("SATClaveUnidadMedida") + + + Row("EntregaDirecta") = EntregaDirecta + 'Contratos + Row("CveContratoDetalle") = CveContratoDetalle + Row("CveVentaDetalle") = CveVentaDetalle + Row("CveMovimientoDetallePedido") = CveVentaDetalle + Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle + Row("CveVentaDetalleRemision") = CveVentaDetalleRemision + Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion + Row("CveVentaDetallePedido2") = CveVentaDetallePedido2 + Row("CuentaPredial") = CuentaPredial + Row("EsCargo") = EsCargo + + 'RECARGAR GV + TmpDT.Rows.Add(Row) + TmpDT.AcceptChanges() + Retorno = True + Return Retorno + + End Function + Private Sub CreaObjetosVenta(Tipo As Integer) + + Dim SubTotal As Decimal = 0D + Dim IVA As Decimal = 0D + + For Each GvRow As GridViewRow In GvAcum.Rows + If Tipo = 1 Then + If GvRow.DataKey("CveConcepto").ToEntero = 1 And GvRow.FCCheckBox("ChkCargo").Checked Then + SubTotal = SubTotal + GvRow.DataKey("ImporteCargo").ToDecimal + End If + ElseIf Tipo = 2 Then + If GvRow.DataKey("CveConcepto").ToEntero = 1 And GvRow.FCCheckBox("ChkBonificacion").Checked Then + SubTotal = SubTotal + GvRow.DataKey("ImporteBonificacion").ToDecimal + End If + End If + Next + + Dim CvePS As Integer = UsuarioActual.Empresa.Funcionalidad(534).ToEntero 'CvePS Distruibuidor Bonificación Nota + Dim CveUnidadMedida As Integer = 0 + Dim CveClasificacion As Integer = 0 + Dim UnidadMedida As String = "" + Dim Clasificacion As String = "" + Dim PS As String = "" + Dim PorcentajeIVA As Decimal = 0D + If CvePS > 0 Then + If SubTotal > 0 Then + Dim Dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS).Rows(0) + If Dr IsNot Nothing Then + CveUnidadMedida = Dr("CveUnidadMedida").ToString.ToEntero + CveClasificacion = Dr("CveClasificacion").ToString.ToEntero + PS = Dr("PSCodigo").ToString + UnidadMedida = Dr("UnidadMedida").ToString + Clasificacion = Dr("Clasificacion").ToString + End If + PorcentajeIVA = 0.16D + IVA = SubTotal * PorcentajeIVA + End If + End If + + TmpDT.Rows.Clear() + TmpDT.AcceptChanges() + AgregarProductoServicio(1, CveUnidadMedida, UnidadMedida, CveClasificacion, Clasificacion, CvePS, PS, "Clientes/Usados", SubTotal, 0, -1, "", DdlSubProyecto.SelectedValue.ToEntero, + DdlSubProyecto.SelectedItem.Text, PorcentajeIVA:=PorcentajeIVA) + + Dim Folio As Integer = -1 + Dim Serie As String = "" + + 'If FolioNotaCredito(Tipo) Then + ' Folio = FolioNotaAcumulador + ' Serie = SerieNotaAcumulador + 'End If + If ObjFactura IsNot Nothing Then ObjFactura.Dispose() ObjFactura = Nothing - End If - - ObjFactura = New Modelos.Factura(UsuarioActual) - ObjFactura.CveUsuario = UsuarioActual.CveUsuario - ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa - ObjFactura.CveVenta = -1 - ObjFactura.Version = "3.3" - ObjFactura.TipoCambio = 1 - ObjFactura.TipoCambioDolares = 0 - ObjFactura.ConvertirPesos = False - ObjFactura.ConvertirDolares = False - ObjFactura.CveMoneda = 1 - ObjFactura.Moneda = "Pesos" - ObjFactura.MonedaSAT = "MXN" - ObjFactura.TipoDocto = "RNC" - - ObjFactura.Folio = Folio - ObjFactura.Serie = Serie - - ObjFactura.Fecha = Now - ObjFactura.CvePrePoliza = -1 - ObjFactura.CveMetodoPago = DdlMetodoPago.SelectedValue.ToEntero - ObjFactura.MetodoPago = DdlMetodoPago.SelectedItem.Text - ObjFactura.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {DdlMetodoPago.SelectedValue}") - ObjFactura.FechaVencimiento = TxtFechaPago.Text.ToDate - - ObjFactura.CveMetodoPago33 = DdlMetodoPago33.SelectedValue.ToEntero - ObjFactura.MetodoPago33 = If(DdlMetodoPago33.SelectedValue.ToEntero > 0, DdlMetodoPago33.SelectedItem.Text, "") - ObjFactura.ClaveMetodoPagoSAT = GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", $"CveMetodoPago = {DdlMetodoPago33.SelectedValue}") - - ObjFactura.CveFormaPago33 = DdlFormaPago33.SelectedValue.ToEntero - ObjFactura.FormaPago33 = If(DdlFormaPago33.SelectedValue.ToEntero > 0, DdlFormaPago33.SelectedItem.Text, "") - ObjFactura.FormaPagoSAT33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", $"CveFormaPago = {DdlFormaPago33.SelectedValue}") - - ObjFactura.CveUsoCFDI = DdlUsoCFDI.SelectedValue.ToEntero - ObjFactura.UsoCFDI = If(DdlUsoCFDI.SelectedValue.ToEntero > 0, DdlUsoCFDI.SelectedItem.Text, "") - ObjFactura.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {DdlUsoCFDI.SelectedValue}") - - ObjFactura.UsuarioCreo = UsuarioActual.Nombre - ObjFactura.CveCondicionEntrega = -1 - ObjFactura.CondicionEntrega = "" - - ObjFactura.CondicionesPago = 0 ' 0 - Contado, 1 - Credito, 2 - termianl - ObjFactura.FormaPago = 0 - - ObjFactura.AtnA = "" - ObjFactura.FordGSDB = "" - - ObjFactura.NumeroContrato = "" - ObjFactura.DescripcionContrato = "" - ObjFactura.NumeroDescripcionContrato = "" - ObjFactura.PedidoContrato = "" - ObjFactura.OrdenCompra = "" - - Select Case ObjFactura.TipoDocto - Case "Ing" - ObjFactura.TipoDocumento = "Factura" - Case "Rem" - ObjFactura.TipoDocumento = "Remision" - Case "Cot" - ObjFactura.TipoDocumento = "Cotizacion" - Case "Egs" - ObjFactura.TipoDocumento = "Nota de Crédito" - Case "Dev" - ObjFactura.TipoDocumento = "Nota de Devolución" - Case "DPe" - ObjFactura.TipoDocumento = "Devolución de pedido" - Case "PeC" - ObjFactura.TipoDocumento = "Consignación de Pedido" - Case Else - ObjFactura.TipoDocumento = "" - End Select - - ObjFactura.Fech1 = Now - ObjFactura.Fech2 = Now - ObjFactura.Fech3 = Now - - ObjFactura.Alfa1 = "" - ObjFactura.Alfa2 = "" - ObjFactura.Alfa3 = "" - - ObjFactura.Num1 = 0 - ObjFactura.Num2 = 0 - - ObjFactura.Num3 = 0 - ObjFactura.FechaPago = Now - - ObjFactura.CveCorte = -1 - ObjFactura.CveMesa = -1 - ObjFactura.NumeroPersonas = 0 - ObjFactura.CveContrato = -1 - - ObjFactura.CveClienteSucursal = DdlSucursalCliente.SelectedValue.ToEntero - ObjFactura.Entrega = "" - ObjFactura.Vigencia = Now - - ObjFactura.CveVentaPadre = -1 - - ObjFactura.CveVendedor = DdlVendedor.SelectedValue.ToEntero - If DdlVendedor.SelectedValue.ToEntero > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then - DdlVendedor.Enabled = False - End If - - ObjFactura.FechaEjecucion = Now - ObjFactura.CveSubProyecto = UsuarioActual.CveSubProyecto - ObjFactura.CveSubProyectoCobranza = UsuarioActual.CveSubProyecto - ObjFactura.CveSubProyectoEjecucion = UsuarioActual.CveSubProyecto - ObjFactura.AtencionA = "-1" - ObjFactura.MotivoDescuento = "" - ObjFactura.Observaciones = "" - ObjFactura.Det_OrdenCompra = "" - ObjFactura.Det_FechaOrdenCompra = "" - ObjFactura.MonedaAbreviatura = "" - - ObjFactura.SubTotal = SubTotal - ObjFactura.Descuento = 0 - ObjFactura.Amortizacion = 0 - ObjFactura.IVA = IVA - ObjFactura.RetIVA = 0 - ObjFactura.RetISR = 0 - ObjFactura.IEPS = 0 - ObjFactura.Total = SubTotal + IVA - ObjFactura.DtDetalle = TmpDT - ObjFactura.DtPagos = DtPagos - ObjFactura.DtPromociones = DtPromociones - - '' CLIENTE - ObjFactura.CveCliente = CveCliente - ObjFactura.SetCliente() - - ''SUCURSAL - - ObjFactura.SetSubProyectoMatriz(Me) - ObjFactura.SetSubProyecto(Me) - ObjFactura.ClienteSucursal = New Modelos.SucursalModel - - If ObjFactura.Timbre.Comprobante.TipoComprobante = "E" Then - If ObjFactura.TipoDocumento.Contiene("Nota de Crédito") Then - ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "01" - ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" - End If - If ObjFactura.TipoDocumento.Contiene("Nota de Devolución") Then - ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "03" - ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" - End If - - End If - - If ObjFactura.TipoDocto.Contiene("Egs", "RNC") Then - ObjFactura.CveTipoRelacion = -1 - End If - - Dim UsadosBonificacion As List(Of Integer) = New List(Of Integer) - For Each GvRow As GridViewRow In GvAcum.Rows - Dim CveMovto As Integer = GvRow.DataKey("CveMovto").ToEntero - If (Tipo = 1 And GvRow.FCCheckBox("ChkCargo").Checked) Or (Tipo = 2 And GvRow.FCCheckBox("ChkBonificacion").Checked) Then - UsadosBonificacion.Add(CveMovto) - End If - Next - - ObjFactura.UsadosBonificacion = UsadosBonificacion - ObjFactura.TipoBonificacion = Tipo - - Dim FM As New Modelos.FemsaFactura - Dim TmpDT7Eleven As New DataTable - Dim TmpDTComplementosTimbrado As New DataTable - - 'PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado) - + End If + + ObjFactura = New Modelos.Factura(UsuarioActual) + ObjFactura.CveUsuario = UsuarioActual.CveUsuario + ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa + ObjFactura.CveVenta = -1 + ObjFactura.Version = "3.3" + ObjFactura.TipoCambio = 1 + ObjFactura.TipoCambioDolares = 0 + ObjFactura.ConvertirPesos = False + ObjFactura.ConvertirDolares = False + ObjFactura.CveMoneda = 1 + ObjFactura.Moneda = "Pesos" + ObjFactura.MonedaSAT = "MXN" + ObjFactura.TipoDocto = "RNC" + + ObjFactura.Folio = Folio + ObjFactura.Serie = Serie + + ObjFactura.Fecha = Now + ObjFactura.CvePrePoliza = -1 + ObjFactura.CveMetodoPago = DdlMetodoPago.SelectedValue.ToEntero + ObjFactura.MetodoPago = DdlMetodoPago.SelectedItem.Text + ObjFactura.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {DdlMetodoPago.SelectedValue}") + ObjFactura.FechaVencimiento = TxtFechaPago.Text.ToDate + + ObjFactura.CveMetodoPago33 = DdlMetodoPago33.SelectedValue.ToEntero + ObjFactura.MetodoPago33 = If(DdlMetodoPago33.SelectedValue.ToEntero > 0, DdlMetodoPago33.SelectedItem.Text, "") + ObjFactura.ClaveMetodoPagoSAT = GlobalDTVtaMetodoPago.FiltroPrimeroValor("ClaveMetodoPagoSAT", $"CveMetodoPago = {DdlMetodoPago33.SelectedValue}") + + ObjFactura.CveFormaPago33 = DdlFormaPago33.SelectedValue.ToEntero + ObjFactura.FormaPago33 = If(DdlFormaPago33.SelectedValue.ToEntero > 0, DdlFormaPago33.SelectedItem.Text, "") + ObjFactura.FormaPagoSAT33 = GlobalDTVtaFormaPago.FiltroPrimeroValor("ClaveFormaPagoSAT", $"CveFormaPago = {DdlFormaPago33.SelectedValue}") + + ObjFactura.CveUsoCFDI = DdlUsoCFDI.SelectedValue.ToEntero + ObjFactura.UsoCFDI = If(DdlUsoCFDI.SelectedValue.ToEntero > 0, DdlUsoCFDI.SelectedItem.Text, "") + ObjFactura.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", $"CveUsoCFDI = {DdlUsoCFDI.SelectedValue}") + + ObjFactura.UsuarioCreo = UsuarioActual.Nombre + ObjFactura.CveCondicionEntrega = -1 + ObjFactura.CondicionEntrega = "" + + ObjFactura.CondicionesPago = 0 ' 0 - Contado, 1 - Credito, 2 - termianl + ObjFactura.FormaPago = 0 + + ObjFactura.AtnA = "" + ObjFactura.FordGSDB = "" + + ObjFactura.NumeroContrato = "" + ObjFactura.DescripcionContrato = "" + ObjFactura.NumeroDescripcionContrato = "" + ObjFactura.PedidoContrato = "" + ObjFactura.OrdenCompra = "" + + Select Case ObjFactura.TipoDocto + Case "Ing" + ObjFactura.TipoDocumento = "Factura" + Case "Rem" + ObjFactura.TipoDocumento = "Remision" + Case "Cot" + ObjFactura.TipoDocumento = "Cotizacion" + Case "Egs" + ObjFactura.TipoDocumento = "Nota de Crédito" + Case "Dev" + ObjFactura.TipoDocumento = "Nota de Devolución" + Case "DPe" + ObjFactura.TipoDocumento = "Devolución de pedido" + Case "PeC" + ObjFactura.TipoDocumento = "Consignación de Pedido" + Case Else + ObjFactura.TipoDocumento = "" + End Select + + ObjFactura.Fech1 = Now + ObjFactura.Fech2 = Now + ObjFactura.Fech3 = Now + + ObjFactura.Alfa1 = "" + ObjFactura.Alfa2 = "" + ObjFactura.Alfa3 = "" + + ObjFactura.Num1 = 0 + ObjFactura.Num2 = 0 + + ObjFactura.Num3 = 0 + ObjFactura.FechaPago = Now + + ObjFactura.CveCorte = -1 + ObjFactura.CveMesa = -1 + ObjFactura.NumeroPersonas = 0 + ObjFactura.CveContrato = -1 + + ObjFactura.CveClienteSucursal = DdlSucursalCliente.SelectedValue.ToEntero + ObjFactura.Entrega = "" + ObjFactura.Vigencia = Now + + ObjFactura.CveVentaPadre = -1 + + ObjFactura.CveVendedor = DdlVendedor.SelectedValue.ToEntero + If DdlVendedor.SelectedValue.ToEntero > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then + DdlVendedor.Enabled = False + End If + + ObjFactura.FechaEjecucion = Now + ObjFactura.CveSubProyecto = UsuarioActual.CveSubProyecto + ObjFactura.CveSubProyectoCobranza = UsuarioActual.CveSubProyecto + ObjFactura.CveSubProyectoEjecucion = UsuarioActual.CveSubProyecto + ObjFactura.AtencionA = "-1" + ObjFactura.MotivoDescuento = "" + ObjFactura.Observaciones = "" + ObjFactura.Det_OrdenCompra = "" + ObjFactura.Det_FechaOrdenCompra = "" + ObjFactura.MonedaAbreviatura = "" + + ObjFactura.SubTotal = SubTotal + ObjFactura.Descuento = 0 + ObjFactura.Amortizacion = 0 + ObjFactura.IVA = IVA + ObjFactura.RetIVA = 0 + ObjFactura.RetISR = 0 + ObjFactura.IEPS = 0 + ObjFactura.Total = SubTotal + IVA + ObjFactura.DtDetalle = TmpDT + ObjFactura.DtPagos = DtPagos + ObjFactura.DtPromociones = DtPromociones + + '' CLIENTE + ObjFactura.CveCliente = CveCliente + ObjFactura.SetCliente() + + ''SUCURSAL + + ObjFactura.SetSubProyectoMatriz(Me) + ObjFactura.SetSubProyecto(Me) + ObjFactura.ClienteSucursal = New Modelos.SucursalModel + + If ObjFactura.Timbre.Comprobante.TipoComprobante = "E" Then + If ObjFactura.TipoDocumento.Contiene("Nota de Crédito") Then + ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "01" + ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "Nota de Crédito aplicada a Ingreso" + End If + If ObjFactura.TipoDocumento.Contiene("Nota de Devolución") Then + ObjFactura.Timbre.CFDIRelacionados.TipoRelacion = "03" + ObjFactura.Timbre.CFDIRelacionados.TipoRelacionTexto = "Devolución aplicada a Ingreso" + End If + + End If + + If ObjFactura.TipoDocto.Contiene("Egs", "RNC") Then + ObjFactura.CveTipoRelacion = -1 + End If + + Dim UsadosBonificacion As List(Of Integer) = New List(Of Integer) + For Each GvRow As GridViewRow In GvAcum.Rows + Dim CveMovto As Integer = GvRow.DataKey("CveMovto").ToEntero + If (Tipo = 1 And GvRow.FCCheckBox("ChkCargo").Checked) Or (Tipo = 2 And GvRow.FCCheckBox("ChkBonificacion").Checked) Then + UsadosBonificacion.Add(CveMovto) + End If + Next + + ObjFactura.UsadosBonificacion = UsadosBonificacion + ObjFactura.TipoBonificacion = Tipo + + Dim FM As New Modelos.FemsaFactura + Dim TmpDT7Eleven As New DataTable + Dim TmpDTComplementosTimbrado As New DataTable + + 'PrepararTimbrado(FM, TmpDT7Eleven, TmpDTComplementosTimbrado) + ObjFactura.FemsaFactura = FM ' ObjFactura.Timbre = PreParaTimbre(ObjFactura) @@ -9942,52 +9942,52 @@ Partial Class Clientes ' Return Timbre 'End Function -#End Region +#End Region -#Region "C L I E N T E S G R I D S I M P R I M I R P D F/Excel" - Private Sub LnkCotizacionesPDF_Click(sender As Object, e As EventArgs) Handles LnkCotizacionesPDF.Click - ImprimeGridsProveedores("PDF", DtCotizaciones, "RepClientesCotizaciones") +#Region "C L I E N T E S G R I D S I M P R I M I R P D F/Excel" + Private Sub LnkCotizacionesPDF_Click(sender As Object, e As EventArgs) Handles LnkCotizacionesPDF.Click + ImprimeGridsProveedores("PDF", DtCotizaciones, "RepClientesCotizaciones") End Sub - Private Sub LnkCotizacionesExcel_Click(sender As Object, e As EventArgs) Handles LnkCotizacionesExcel.Click - ImprimeGridsProveedores("Excel", DtCotizaciones, "RepClientesCotizaciones") + Private Sub LnkCotizacionesExcel_Click(sender As Object, e As EventArgs) Handles LnkCotizacionesExcel.Click + ImprimeGridsProveedores("Excel", DtCotizaciones, "RepClientesCotizaciones") End Sub - Private Sub LnkCxCActivasPDF_Click(sender As Object, e As EventArgs) Handles LnkCxCActivasPDF.Click - ImprimeGridsProveedores("PDF", DtCxCActivas, "RepClientesCxCActivas") + Private Sub LnkCxCActivasPDF_Click(sender As Object, e As EventArgs) Handles LnkCxCActivasPDF.Click + ImprimeGridsProveedores("PDF", DtCxCActivas, "RepClientesCxCActivas") End Sub - Private Sub LnkCxCActivasExcel_Click(sender As Object, e As EventArgs) Handles LnkCxCActivasExcel.Click - ImprimeGridsProveedores("Excel", DtCxCActivas, "RepClientesCxCActivas") + Private Sub LnkCxCActivasExcel_Click(sender As Object, e As EventArgs) Handles LnkCxCActivasExcel.Click + ImprimeGridsProveedores("Excel", DtCxCActivas, "RepClientesCxCActivas") End Sub - Private Sub LnkHistorialCxCPDF_Click(sender As Object, e As EventArgs) Handles LnkHistorialCxCPDF.Click - ImprimeGridsProveedores("PDF", DtHistorialCxC, "RepClientesHistorialCxC") + Private Sub LnkHistorialCxCPDF_Click(sender As Object, e As EventArgs) Handles LnkHistorialCxCPDF.Click + ImprimeGridsProveedores("PDF", DtHistorialCxC, "RepClientesHistorialCxC") End Sub - Private Sub LnkHistorialCxCExcel_Click(sender As Object, e As EventArgs) Handles LnkHistorialCxCExcel.Click - ImprimeGridsProveedores("Excel", DtHistorialCxC, "RepClientesHistorialCxC") + Private Sub LnkHistorialCxCExcel_Click(sender As Object, e As EventArgs) Handles LnkHistorialCxCExcel.Click + ImprimeGridsProveedores("Excel", DtHistorialCxC, "RepClientesHistorialCxC") End Sub - Private Sub LnkAnticipoClientePDF_Click(sender As Object, e As EventArgs) Handles LnkAnticipoClientePDF.Click - ImprimeGridsProveedores("PDF", DtClientesAnticipo, "RepClientesAnticipos") + Private Sub LnkAnticipoClientePDF_Click(sender As Object, e As EventArgs) Handles LnkAnticipoClientePDF.Click + ImprimeGridsProveedores("PDF", DtClientesAnticipo, "RepClientesAnticipos") End Sub - Private Sub LnkAnticipoClienteExcel_Click(sender As Object, e As EventArgs) Handles LnkAnticipoClienteExcel.Click - ImprimeGridsProveedores("Excel", DtClientesAnticipo, "RepClientesAnticipos") + Private Sub LnkAnticipoClienteExcel_Click(sender As Object, e As EventArgs) Handles LnkAnticipoClienteExcel.Click + ImprimeGridsProveedores("Excel", DtClientesAnticipo, "RepClientesAnticipos") End Sub - Private Sub LnkAnticipoHistorialPDF_Click(sender As Object, e As EventArgs) Handles LnkAnticipoHistorialPDF.Click - ImprimeGridsProveedores("PDF", DtAnticipoHistorial, "RepClientesAnticipoHistorial") + Private Sub LnkAnticipoHistorialPDF_Click(sender As Object, e As EventArgs) Handles LnkAnticipoHistorialPDF.Click + ImprimeGridsProveedores("PDF", DtAnticipoHistorial, "RepClientesAnticipoHistorial") End Sub - Private Sub LnkAnticipoHistorialExcel_Click(sender As Object, e As EventArgs) Handles LnkAnticipoHistorialExcel.Click - ImprimeGridsProveedores("Excel", DtAnticipoHistorial, "RepClientesAnticipoHistorial") + Private Sub LnkAnticipoHistorialExcel_Click(sender As Object, e As EventArgs) Handles LnkAnticipoHistorialExcel.Click + ImprimeGridsProveedores("Excel", DtAnticipoHistorial, "RepClientesAnticipoHistorial") End Sub - Private Sub LnkCuentasBancariasPDF_Click(sender As Object, e As EventArgs) Handles LnkCuentasBancariasPDF.Click - ImprimeGridsProveedores("PDF", DTCuentasBancos, "RepClientesCuentasBancarias") + Private Sub LnkCuentasBancariasPDF_Click(sender As Object, e As EventArgs) Handles LnkCuentasBancariasPDF.Click + ImprimeGridsProveedores("PDF", DTCuentasBancos, "RepClientesCuentasBancarias") End Sub - Private Sub LnkCuentasBancariasExcel_Click(sender As Object, e As EventArgs) Handles LnkCuentasBancariasExcel.Click - ImprimeGridsProveedores("Excel", DTCuentasBancos, "RepClientesCuentasBancarias") + Private Sub LnkCuentasBancariasExcel_Click(sender As Object, e As EventArgs) Handles LnkCuentasBancariasExcel.Click + ImprimeGridsProveedores("Excel", DTCuentasBancos, "RepClientesCuentasBancarias") End Sub - Private Sub ImprimeGridsProveedores(Formato As String, DtTemp As DataTable, NombreFormato As String) + Private Sub ImprimeGridsProveedores(Formato As String, DtTemp As DataTable, NombreFormato As String) If DtTemp IsNot Nothing And DtTemp.Rows.Count > 0 Then Dim params As New List(Of ReportParameter) @@ -10006,7 +10006,7 @@ Partial Class Clientes ImprimirPDF("Empresas\Grales\Formatos\" & NombreFormato & ".rdlc", DtTemp, params, NombreFormato & "_" & Now.ToString("yyyyMMddhhmmss"), Formato:=Formato) Else Alert("No se encontró información.", TipoMensaje.MsgAdvertencia) - End If + End If End Sub Private Sub LnkUsadosReset_Click(sender As Object, e As EventArgs) Handles LnkUsadosReset.Click @@ -10038,5 +10038,5 @@ Partial Class Clientes End If End Sub -End Class - +End Class +