This commit is contained in:
Antonio Gonzalez
2020-01-21 13:22:09 -07:00
15 changed files with 2579 additions and 882 deletions

View File

@@ -4750,7 +4750,7 @@ Public Class ClsGPS
#End Region
#Region "T R A Y E C T O S"
Public Function AddTrayecto(Trayecto As String, Fecha As DateTime, Folio As String, CveDispositivo As Integer, CveCliente As Integer) As Integer
Public Function AddTrayecto(Trayecto As String, Fecha As DateTime, Folio As String, CveDispositivo As Integer, CveCliente As Integer, Optional EnviarNotificacion As Boolean = False, Optional CorreosNotificacion As String = "", Optional Intervalo As Integer = 0, Optional EnviarLiga As Boolean = False) As Integer
Dim retorno As Integer = 0
DataAdapter("PA_GPS_TrayectosAdd", CommandType.StoredProcedure)
With SqlAdapter.SelectCommand.Parameters
@@ -4759,6 +4759,10 @@ Public Class ClsGPS
.Add("@Folio", SqlDbType.VarChar).Value = Folio
.Add("@CveDispositivo", SqlDbType.Int).Value = CveDispositivo
.Add("@CveCliente", SqlDbType.Int).Value = CveCliente
.Add("@EnviarNotificacion", SqlDbType.Bit).Value = EnviarNotificacion
.Add("@CorreosNotificacion", SqlDbType.VarChar).Value = CorreosNotificacion
.Add("@Intervalo", SqlDbType.Int).Value = Intervalo
.Add("@EnviarLiga", SqlDbType.Bit).Value = EnviarLiga
.Add("@CveTrayecto", SqlDbType.Int).Direction = ParameterDirection.Output
End With

View File

@@ -541,7 +541,7 @@ Namespace Modelos
End Class
Public Function EmitirFactura(Optional Timbrar As Boolean = True) As MMensajeFactura
Public Function EmitirFactura(Optional Timbrar As Boolean = True, Optional Trasac As SqlClient.SqlTransaction = Nothing, Optional ObjContPaqTransac As ClsContPAQi = Nothing) As MMensajeFactura
Dim Retorno As New MMensajeFactura()
If Me.Version = "3.3" AndAlso Not Me.TipoDocto.Contiene("Ped", "PeC") Then
@@ -586,9 +586,16 @@ Namespace Modelos
End If
If Me.CveCliente > 0 Or Me.CveEmpresaCRM > 0 Then
If DtDetalle.Rows.Count > 0 Then
If DtDetalle.Rows.Count > 0 Then
Dim ObjVentas As ClsVentas = Nothing
If Trasac IsNot Nothing Then
ObjVentas = New ClsVentas(Trasac)
Else
ObjVentas = New ClsVentas()
ObjVentas.IniciaTransacSQL()
End If
Dim ObjVentas As New ClsVentas()
Dim ObjConta As New ClsContabilidad(ObjVentas.IniciaTransacSQL())
Dim ObjInventario As New ClsInventarios(ObjVentas.IniciaTransacSQL())
Dim ObjContr As New ClsContratos(ObjVentas.IniciaTransacSQL())
@@ -604,10 +611,15 @@ Namespace Modelos
Try
'CONTABILIDAD AUTOMATICA Y AC
If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
If ObjContPaqTransac IsNot Nothing Then
ObjContPaq = ObjContPaqTransac
Else
If UsuarioActual.Empresa.UsaAC OrElse UsuarioActual.Empresa.Funcionalidad(200) = "1" Then
ObjContPaq = New ClsContPAQi(UsuarioActual.Empresa)
End If
End If
'GUARDA VENTA
Dim TieneAnticipo As Boolean = False
Dim CveAnticipoPadre As Integer = 0 ' vinculación con anticipo
@@ -787,9 +799,15 @@ Namespace Modelos
End If
End If
If Me.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or Me.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then
ObjVentas.Commit()
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
If Me.CveVenta > 0 AndAlso ErrorList.Count = 0 AndAlso (SeGuardoPrePoliza Or Me.TipoDocto.Contiene("Ped", "Cot", "DPe", "PeC", "PA", "Pd2")) Then
If Trasac Is Nothing Then
ObjVentas.Commit()
End If
If ObjContPaqTransac Is Nothing Then
If ObjContPaq IsNot Nothing Then ObjContPaq.Commit()
End If
Try
If Not String.IsNullOrEmpty(DirectorioServidor) Then
Dim DirectoriArchivoXML As String = System.IO.Path.Combine(DirectorioServidor, "Empresas", UsuarioActual.CveEmpresa.ToString, Me.TipoDocto)
@@ -986,42 +1004,61 @@ Namespace Modelos
Retorno.Mensajes = ListaMensajes
End Try
Else
ObjVentas.RollBack()
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
If Trasac Is Nothing Then
ObjVentas.RollBack()
End If
If ObjContPaqTransac Is Nothing Then
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
End If
Retorno.Mensajes = ErrorList
Retorno.TieneError = True
End If
Else
ObjVentas.RollBack()
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
If Trasac Is Nothing Then
ObjVentas.RollBack()
End If
If ObjContPaqTransac Is Nothing Then
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
End If
ErrorList.Add("Ocurrió un error al procesar los datos. Por favor rectifique y vuelta a intentar.")
Retorno.Mensajes = ErrorList
Retorno.TieneError = True
End If
Catch ex As Exception
Me.ErrorList.Add(ex.ToString())
ObjVentas.RollBack()
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
If Trasac Is Nothing Then
ObjVentas.RollBack()
End If
If ObjContPaqTransac Is Nothing Then
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
End If
Retorno.Mensajes = ErrorList
Retorno.TieneError = True
Finally
ObjVentas.Dispose()
ObjConta.Dispose()
ObjInventario.Dispose()
ObjCGame.Dispose()
ObjContr.Dispose()
ObjDocCliente.Dispose()
ObjClientes.Dispose()
ObjAcum.Dispose()
If ObjContPaq IsNot Nothing Then ObjContPaq.Dispose()
If Trasac Is Nothing Then
ObjVentas.Dispose()
ObjConta.Dispose()
ObjInventario.Dispose()
ObjCGame.Dispose()
ObjContr.Dispose()
ObjDocCliente.Dispose()
ObjClientes.Dispose()
ObjAcum.Dispose()
End If
If ObjContPaqTransac Is Nothing Then
If ObjContPaq IsNot Nothing Then ObjContPaq.RollBack()
End If
End Try
Else
Retorno.Mensajes.Add("No se han agregado productos/servicios")
End If
End If
Return Retorno
End Function
@@ -5086,7 +5123,8 @@ Namespace Modelos
Public Property CveAlmacenRecepcionUsados As Integer = -1
Public Property CveDireccionEnvio As Integer
Public Property RefacturacionGeneroNC As Boolean = False
Public Property Pagado As Decimal
Public Property Pagado As Decimal
Public Property DescuentoProntoPago As Decimal
'Public Property Sucursal As SucursalModel
Public Property SubProyecto As Modelos.SubProyectoModel

View File

@@ -13647,19 +13647,32 @@ Partial Class Compras_Compras
End Sub
Private Sub VinculaDevolucion()
'Borramos el TmpDT
TmpDT.Clear()
'LIMPIAR PARTIDAS DE LA COMPRA PARA AGREGAR NUEVAS
TmpDT.Clear()
Dim SubTotalCompra As Decimal = TxtSubTotal.Text.ToDecimal()
Dim TotalCompra As Decimal = TxtTotal.Text.ToDecimal()
Dim IVACompra As Decimal = TxtIVA.Text.ToDecimal()
Dim IEPSCompra As Decimal = TxtIEPS.Text.ToDecimal()
Dim RetIVACompra As Decimal = TxtRetIVA.Text.ToDecimal()
Dim RetISRCompra As Decimal = TxtRetISR.Text.ToDecimal()
'Dim TotalCalculable As Decimal = TotalCompra - IEPSCompra + RetIVACompra + RetISRCompra
Dim IVAPorcentajeCompra As Decimal = Math.Round((IVACompra / SubTotalCompra), 2)
'Iteramos el GridView de la OC
For Each gvr As GridViewRow In GVDevolucion.Rows
If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then
If gvr.FCTextBox("TxtCantidad").Text.ToDecimal > 0 Then
Dim CvePS As Integer = gvr.DataKey("CvePS").ToString.ToEntero
Dim DrPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).Rows(0)
Dim Cantidad As Decimal = gvr.FCTextBox("TxtCantidad").Text.ToDecimal
Dim CveUM As Integer = gvr.DataKey("CveUM").ToString.ToEntero
Dim UM As String = gvr.DataKey("UM").ToString
Dim CveClasificacion As Integer = gvr.DataKey("CveClasificacion").ToString.ToEntero
Dim Clasificacion As String = gvr.DataKey("Clasificacion").ToString
Dim CvePS As Integer = gvr.DataKey("CvePS").ToString.ToEntero
Dim PS As String = gvr.DataKey("PS").ToString
Dim CveTipoPS As Integer = gvr.DataKey("CveTipoPS").ToString.ToEntero
Dim CveSubProyectoContrato As String = "-1"
@@ -13669,7 +13682,7 @@ Partial Class Compras_Compras
Dim Obs As String = ""
Dim PU As Decimal = gvr.DataKey("PU").ToString.ToDecimal
Dim Total As Decimal = gvr.FCTextBox("TxtTotalDevolucion").Text.ToDecimal
Dim IVA As Decimal = 0
Dim IVA As Decimal = IVAPorcentajeCompra 'Math.Round(Total * IVAPorcentajeCompra, 2)
Dim Descuento As Decimal = 0
AddPS(Cantidad, CveUM, UM, CveClasificacion, Clasificacion, CvePS, PS, CveTipoPS, CveSubProyectoContrato, SubProyecto, Proyecto, CveProyecto, Obs, PU, Total, IVA, 0, 0, 0, 0, Descuento, -1, False)
@@ -17540,15 +17553,17 @@ Partial Class Compras_Compras
TmpDT.Rows(HdnAliasInd.Value.ToEntero)("Obs") = TxtPSAlias.Text.Trim
'busco si el producto está en otros renglones QUE NO LO TENGAN ASIGNADO, LO VINCULE
For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0")
drt("CvePS") = CvePS
drt("PS") = tPS
drt("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero
drt("UM") = DdlUnidadAlias.SelectedItem.Text
drt("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero
drt("Clasificacion") = HdnPSAliasClasificacion.Value
drt("Obs") = TxtPSAlias.Text.Trim
Next
If UsuarioActual.CveEmpresa <> 141 Then
For Each drt As DataRow In TmpDT.Select($"PS ='{TxtPSAlias.Text.Trim}' and ISNULL(CvePS,0) = 0")
drt("CvePS") = CvePS
drt("PS") = tPS
drt("CveUM") = DdlUnidadAlias.SelectedValue.ToEntero
drt("UM") = DdlUnidadAlias.SelectedItem.Text
drt("CveClasificacion") = HdnPSAliasCveClasificacion.Value.ToEntero
drt("Clasificacion") = HdnPSAliasClasificacion.Value
drt("Obs") = TxtPSAlias.Text.Trim
Next
End If
TmpDT.AcceptChanges()

View File

@@ -2621,7 +2621,7 @@
<Paragraph>
<TextRuns>
<TextRun>
<Value>IVA (16%):</Value>
<Value>IVA</Value>
<Style>
<FontFamily>calibri</FontFamily>
<FontSize>9pt</FontSize>

View File

@@ -316,67 +316,7 @@
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<%-- <asp:UpdatePanel ID="UpBodyTipoEquipo" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 15px;">
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnApagarMotor" CssClass="btn btn-danger" Text="Apagar Motor" />
</div>
<div class="col-md-4" style="padding-right: 0px">
<asp:TextBox ID="TxtTelefonoPanico" runat="server" Style="width: 150px; height: 100%; float: right;" Type="number" MaxLength="10" />
<asp:RequiredFieldValidator ID="RFVTelefonoPanico" runat="server" ControlToValidate="TxtTelefonoPanico" Display="None" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Telefono''</b> es necesario, por favor ingréselo." ValidationGroup="GrpBotonPanico"></asp:RequiredFieldValidator>
<ajax:ValidatorCalloutExtender ID="VCETelefonoPanico" runat="server" HighlightCssClass="vco" TargetControlID="RFVTelefonoPanico" Width="350px"></ajax:ValidatorCalloutExtender>
</div>
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnTelefonoPanico" CssClass="btn btn-danger" Text="Telefono Panico" ValidationGroup="GrpBotonPanico" />
</div>
</div>
<div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 15px;">
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnEncenderMotor" CssClass="btn btn-success" Text="Encender Motor" />
</div>
<div class="col-md-4" style="padding-right: 0px">
<asp:DropDownList CssClass="form-control input-sm" Style="float: right; height: 100%;" ID="DdlTipoBateria" runat="server" Width="150px">
<asp:ListItem Value="0" Text="ST Solo en Movimiento"></asp:ListItem>
<asp:ListItem Value="1" Text="Intervalos de Tiempo" Selected="True"></asp:ListItem>
</asp:DropDownList>
</div>
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnAhorroBateria" CssClass="btn btn-success" Text="Ahorro Bateria" />
</div>
</div>
<div class="row" style="margin-left: 0px; margin-top: 5px; margin-bottom: 15px;">
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnProbarEncendido" CssClass="btn btn-primary" Text="Abrir Compuerta" />
</div>
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnInfoDispositivo" CssClass="btn btn-primary" Text="Cerrar Compuerta" />
</div>
<div class="col-md-4">
<asp:LinkButton runat="server" Style="width: 150px; text-align: center" ID="BtnReinicio" CssClass="btn btn-primary" Text="Reiniciar" />
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>--%>
</div>
<%--<div class="modal-footer">
<asp:UpdatePanel ID="UpFooter" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton ID="BtnBuscarEquipoC" runat="server" CssClass="btn btn-primary" ValidationGroup="GrpObligatorio"> <i class='fa fa-search '></i> Buscar</asp:LinkButton>
<button id="btnCancelar" class="btn btn-default" data-dismiss="modal">Cancelar</button>
</ContentTemplate>
</asp:UpdatePanel>
</div>--%>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
@@ -1063,6 +1003,7 @@
CalculaDireccionHistorica(coord, j, ejecutar)
}
}
function CalculaDireccionHistorica(coord, j, ejecutar) {
setTimeout(function () {
var url = '<%= ClsPaginas.UrlDirecciones%>' + 'nominatim/reverse.php?format=jsonv2&lat=' + coord.lat + '&lon=' + coord.lng;
@@ -1077,7 +1018,8 @@
}
});
}, timeout + (j));
}
}
function CalculaRutaHistorica(coordenadasRuta, lastCoord) {
if (coordenadasRuta.length > 0) {
var flag = 1;

679
GPS/RastreoTrayectos.aspx Normal file
View File

@@ -0,0 +1,679 @@
<%@ Page Title="" Language="VB" MasterPageFile="~/SiteGPS.master" AutoEventWireup="false" CodeFile="RastreoTrayectos.aspx.vb" Inherits="GPS_RastreoTrayectos" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CP" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Css" runat="Server">
<style type="text/css">
.ADScroller-body {
max-height: 400px;
}
.dataTables_scrollHeadInner > table {
background: lightgray;
}
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
table.dataTable th.focus, table.dataTable td.focus {
outline: 3px solid #3366ff00;
outline-offset: -1px;
}
.CustomSpinner {
position: fixed;
background-image: url(/Imagenes/Loading.gif);
background-repeat: no-repeat, repeat;
background-size: contain;
top: 60px;
right: 25px;
z-index: 500000;
height: 40px;
width: 40px;
}
/*.page-head {
display: none;
}
.page-breadcrumb .breadcrumb {
display: none;
}
#barradenavegacion {
display:none;
}*/
#showdiv1 {
left: 0 !important;
width: 100% !important;
}
#ShowDiv3:hover {
line-height: 34px !important;
-webkit-transition: line-height ease 1s;
-moz-transition: line-height ease 1s;
-o-transition: line-height ease 1s;
transition: line-height ease 1s;
}
#map {
position: fixed !important;
}
.pac-container.pac-logo {
z-index: 100000;
}
#iw-container {
margin-bottom: 10px;
}
#iw-container .iw-title {
font-family: 'Open Sans Condensed', sans-serif;
font-size: 22px;
font-weight: 400;
padding: 10px;
background-color: #48b5e9;
color: white;
margin: 0;
border-radius: 2px 2px 0 0;
}
#iw-container .iw-content {
font-size: 13px;
line-height: 18px;
font-weight: 400;
margin-right: 1px;
padding: 15px 5px 20px 15px;
max-height: 140px;
overflow-y: auto;
overflow-x: hidden;
}
.iw-content img {
float: right;
margin: 0 5px 5px 10px;
}
.iw-subTitle {
font-size: 16px;
font-weight: 700;
padding: 5px 0;
}
.iw-bottom-gradient {
position: absolute;
width: 326px;
height: 25px;
bottom: 10px;
right: 18px;
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
}
.modal.fade:not(.in).left .modal-dialog {
-webkit-transform: translate3d(-25%, 0, 0);
transform: translate3d(-25%, 0, 0);
}
.modal.fade:not(.in).right .modal-dialog {
-webkit-transform: translate3d(25%, 0, 0);
transform: translate3d(25%, 0, 0);
}
.modal.fade:not(.in).bottom .modal-dialog {
-webkit-transform: translate3d(0, 25%, 0);
transform: translate3d(0, 25%, 0);
}
/* Alternative Angles */
.modal.fade:not(.in).top-left .modal-dialog {
-webkit-transform: translate3d(-25%, -25%, 0);
transform: translate3d(-25%, -25%, 0);
}
.modal.fade:not(.in).top-right .modal-dialog {
-webkit-transform: translate3d(25%, -25%, 0);
transform: translate3d(25%, -25%, 0);
}
.modal.fade:not(.in).bottom-left .modal-dialog {
-webkit-transform: translate3d(-25%, 25%, 0);
transform: translate3d(-25%, 25%, 0);
}
.modal.fade:not(.in).bottom-right .modal-dialog {
-webkit-transform: translate3d(25%, 25%, 0);
transform: translate3d(25%, 25%, 0);
}
.minicolors {
position: relative;
MARGIN-TOP: 10PX;
WIDTH: 20%;
}
table.dataTable,
table.dataTable th,
table.dataTable td {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.dataTables_scrollBody > .dataTable > thead {
display: none !important;
}
tr td:nth-child(4) {
text-align: center;
}
.form-horizontal .control-label {
text-align: left;
}
</style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="C" runat="Server">
<asp:UpdatePanel ID="UpFiltros" runat="server" UpdateMode="conditional">
<ContentTemplate>
<asp:Timer runat="server" ID="TimmerRefresh" Enabled="false" Interval="30000" OnTick="TimmerRefresh_Tick"></asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
<div id="map"></div>
<div class="modal fade bottom in" style="bottom: unset; z-index: 539" id="h">
<div class="modal-dialog" style="position: fixed; bottom: 0; margin: 0px,0px,0px,0px; width: 100%; padding: 0px, 0px, 0px, 0px; border-style: solid; border-color: rgb(68, 77, 88); z-index: 539;">
<div class="modal-content">
<div class="modal-body" style="padding: 5px;">
<asp:UpdatePanel runat="server" ID="UPGV" UpdateMode="Conditional">
<ContentTemplate>
<div id="DvPaginacion" runat="server" class="row" visible="false">
<div class="col-md-11">
<asp:Label ID="LblRegistros" runat="server" Style="display: inline-block;"></asp:Label>
</div>
<div class="col-md-1" style="display: inline-block; position: relative">
<asp:HiddenField ID="HdnIndexPage" runat="server" ClientIDMode="Static" Value="0" />
<asp:LinkButton ID="btnPagePrev" runat="server" Style="vertical-align: top;" Text="<i class='fa fa-angle-left' style='font-size:24px' aria-hidden='true'></i> Anterior" OnClick="btnPagePrev_Click" Enabled="false" />
<asp:LinkButton ID="btnPageNext" runat="server" Style="vertical-align: top;" Text="Siguiente <i class='fa fa-angle-right' aria-hidden='true' style='font-size:24px'></i>" OnClick="btnPageNext_Click" />
</div>
</div>
<asp:GridView ID="GvBarra" runat="server" GridLines="None" PageSize="1000" AllowPaging="true" AllowCustomPaging="true" DataKeyNames="Vehiculo, Posicion,Fecha,Velocidad, CveDispositivo" CssClass="table table-striped table-advance table-hover Widthall ADScrollPaginator2" data-sort="true" data-height="150px;" BorderWidth="1" BorderColor="#D3D3D3" CellSpacing="0" Width="100%" AutoGenerateColumns="False" EmptyDataText="No se encontraron registros">
<Columns>
<asp:BoundField DataField="Vehiculo" ItemStyle-Width="15%" HeaderText="Vehículo" ItemStyle-HorizontalAlign="center" />
<asp:BoundField DataField="Fecha" ItemStyle-Width="15%" HeaderText="Fecha Reporte" ItemStyle-HorizontalAlign="center" />
<asp:TemplateField ItemStyle-Width="30%" HeaderText="Dirección" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:Literal runat="server" Text="Haga click para ver Dirección" ID="ltlDireccion"></asp:Literal>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TiempoDetenido" ItemStyle-Width="25%" DataFormatString="{0} Minutos" HeaderText="Tiempo Detenido" ItemStyle-HorizontalAlign="center" />
<asp:BoundField DataField="Evento" ItemStyle-Width="25%" HeaderText="Eventos" ItemStyle-HorizontalAlign="center" />
<asp:BoundField DataField="Velocidad" ItemStyle-Width="10%" DataFormatString="{0:N2} KM/H" HeaderText="Velocidad" ItemStyle-HorizontalAlign="center" />
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="HdnDireccionRow" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="NextPrevious" Visible="true" Position="Top" />
</asp:GridView>
<asp:HiddenField ID="HdnIndexGvBarra" runat="server" ClientIDMode="Static" Value="-1" />
<asp:HiddenField ID="HdnTextFilter" runat="server" ClientIDMode="Static" Value="" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="H" runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="JS" runat="Server">
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAF7s8wwhzCVXDUYopc9mXxqaWB33cDro4&libraries=places"></script>
<script src="../Metronic/assets/global/plugins/datatables2/datatables.min.js"></script>
<script src="../Metronic/assets/global/plugins/datatables2/extensions/Scroller/js/dataTables.scroller.js"></script>
<script src="../Metronic/assets/global/plugins/datatables2/extensions/KeyTable/js/dataTables.keyTable.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
initMap();
});
var image = '/Imagenes/rsz_11rsz_car.png';
var geocoder;
var map;
var directionsService;
var directionsDisplay;
var polylinesRoute = [];
var directionsDisplayArray = [];
var lastOpenedInfoWindow;
var retorno;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 24.6345, lng: -102.5528 },
zoom: 6
});
var ShowDiv1 = document.createElement('div');
var ShowDivControl = new ShowDiv(ShowDiv1, map);
ShowDiv1.index = 1;
ShowDiv1.id = "showdiv1"
map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(ShowDiv1);
geocoder = new google.maps.Geocoder();
google.maps.event.addListener(map, "click", function (event) {
closeLastOpenedInfoWindow();
});
directionsService = new google.maps.DirectionsService;
directionsDisplay = new google.maps.DirectionsRenderer;
directionsDisplay.setOptions({ suppressMarkers: true });
directionsDisplay.setMap(map);
}
var polylines = [];
var coordspoly = [];
var geoRutasHistoricas = [];
function creaPolyline(coords, color, info, lastcoord, nomequipo, Imagen, valueEquipo, Continuo) {
var lineSymbol = {
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
strokeWeight: 1,
strokeOpacity: 1,
scale: 3,
fillOpacity: 0.6
};
var polyline = new google.maps.Polyline({
path: coords,
strokeColor: color,
strokeOpacity: 0.6,
strokeWeight: 6,
fillOpacity: 0.35,
icons: [{
icon: lineSymbol,
offset: '0',
repeat: '80px'
}]
});
polyline.setMap(map);
polylines.push(polyline);
if (coordspoly.length <= 0 && typeof (Continuo) === "undefined") {
FitBoundsToCoords(coords);
} else {
coordspoly.push(coords[coords.length - 1]);
}
if (lastcoord != "") {
var geo = {
NombreEquipo: nomequipo,
ValueEquipo: valueEquipo,
UltimaPos: lastcoord,
Cordenadas: coords
};
geoRutasHistoricas.push(geo);
CreaMarcador(lastcoord, nomequipo, info, Imagen);
ConsultaDireccionesRutasHistoricas(geo);
}
}
function closeLastOpenedInfoWindow() {
if (lastOpenedInfoWindow) {
lastOpenedInfoWindow.close();
}
}
function fitBoundsToVisibleMarkers() {
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
if (markers[i].getVisible()) {
bounds.extend(markers[i].getPosition());
}
}
map.fitBounds(bounds);
}
function ShowDiv(controlDiv, map) {
// Set CSS for the control border.
var controlUI = document.createElement('div');
controlUI.style.backgroundColor = '#444d58';
controlUI.style.border = '2px solid #444d58';
controlUI.style.borderRadius = '3px';
controlUI.style.width = '100%'
controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
controlUI.style.cursor = 'pointer';
controlUI.style.marginRight = '5px';
controlUI.style.marginTop = '5px';
controlUI.style.marginBottom = '0px';
controlUI.style.textAlign = 'center';
// controlUI.title = 'Click para borrar el último punto dibujado';
controlDiv.appendChild(controlUI);
// Set CSS for the control interior.
var controlText = document.createElement('div');
controlText.style.color = '#ebebeb';
controlText.id = "ShowDiv3"
controlText.style.fontFamily = ' "Open Sans", sans-serif; ';
controlText.style.fontSize = '14px';
controlText.style.lineHeight = '20px';
controlText.style.paddingLeft = '5px';
controlText.style.paddingRight = '5px';
controlText.innerHTML = '<i class="fa fa-angle-up" aria-hidden="true"></i>';
controlUI.appendChild(controlText);
// Setup the click event listeners: simply set the map to Chicago.
controlUI.addEventListener('click', function () {
FNShowDiv();
});
}
function FNShowDiv() {
if (open === false) {
//$("#ChkSeguimiento").appendTo("#DivSeguimiento");
//$("#ChkSeguimiento").appendTo("#DivSeguimiento");
$("#h").modal()
$("#ShowDiv3").css("line-height", "34px")
open = true
$("#ShowDiv3").html('<i class="fa fa-angle-down" aria-hidden="true"></i>')
setTimeout(function () {
$('.table.ADScrollPaginator2').DataTable().draw();
}, 150);
if ($("#HdnOpcion").val() === 'All' || $("#HdnOpcion").val() === 'Idle' || $("#HdnOpcion").val() === 'Ralenti') {
$('#btnPlay').css('display', '');
$('#btnPrintExcel').css('display', '');
$('#btnPrintPDF').css('display', '');
$("#btnPlay").click(function () {
pause = !pause;
if (pause) {
stopTimeout();
} else {
if (startPlay) {
startPlay = false;
Play();
} else {
Play();
}
}
if ($('#btnPlay > i').hasClass("fa-pause")) {
$('#btnPlay > i').removeClass("fa-pause").addClass("fa-play");
} else if ($('#btnPlay > i').hasClass("fa-play")) {
$('#btnPlay > i').removeClass("fa-play").addClass("fa-pause");
}
});
$("#btnPrintExcel").click(function () {
var s;
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_BtnImprimirEX")
});
$("#btnPrintPDF").click(function () {
var s = "";
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_btnImprimir")
});
} else if ($("#HdnOpcion").val() === 'Speed') {
$('#btnPrintExcel').css('display', '');
$('#btnPrintPDF').css('display', '');
$("#btnPrintExcel").click(function () {
var s;
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_BtnImprimirEX")
});
$("#btnPrintPDF").click(function () {
var s = "";
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_btnImprimir")
});
} else if ($("#HdnOpcion").val() === 'Last') {
$('#btnPrintExcel').css('display', '');
$("#btnPrintExcel").click(function () {
var s;
for (var i = 0; i < $("#C_GvBarra").DataTable().rows().nodes().length; i++) {
s = s + $("#C_GvBarra").DataTable().row(i).node().cells[2].title.trim() + ';';
}
$("#HdnDirecciones").val(s);
doScaledCLick("#C_BtnImprimirEX");
});
}
} else {
$("#h").modal('hide')
$("#ShowDiv3").css("line-height", "20px")
open = false
$("#ShowDiv3").html('<i class="fa fa-angle-up" aria-hidden="true"></i>')
}
}
function GvBarraPaginator() {
$('.table.PaginarGV').each(function () {
var Tthis = $(this);
if (!$.fn.DataTable.isDataTable(Tthis) && Tthis.find("th").length > 0) {
Tthis.prepend(("<thead></thead>"));
Tthis.find('thead').append($("#C_GvBarra").find("tr:first"));
var table = Tthis.DataTable({
deferRender: true,
deferLoading: 100,
scrollY: 130,
scrollCollapse: true,
scroller: {
displayBuffer: 20
},
ordering: true
});
var tkeys = new $.fn.dataTable.KeyTable(table, {
// options
});
var parent = Tthis.parent().parent().parent();
$('.dataTables_scrollHeadInner > .table.ADScrollPaginator2').find('th').addClass('importantth');
parent.find(".dataTables_paginate").css("display", "none");
parent.find(".dataTables_length").css("display", "none");
}
});
}
$(document).ready(function () {
GvBarraPaginator();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
$("#C_GvBarra_filter > div > input").on("keypress", function (e) {
HdnTextFilter.value = $(this).val() + String.fromCharCode(e.which);
});
}
});
var markers = [];
function CreaMarcador(coords, nomEquipo, ContentString, imagen) {
if (typeof imagen === 'undefined') { imagen = image; }
var markerIcon = {
url: imagen,
labelOrigin: new google.maps.Point(26, 43)
};
var marker = new google.maps.Marker({
position: coords,
title: nomEquipo,
map: map,
icon: markerIcon
});
var infowindow = new google.maps.InfoWindow({
content: ContentString
});
marker.addListener('click', function () {
closeLastOpenedInfoWindow();
GetDirecciones(coords, infowindow, marker)
infowindow.open(map, marker);
lastOpenedInfoWindow = infowindow;
});
marker.Nombre = nomEquipo
markers.push(marker);
if (markers.length > 1 && coordspoly.length < 1) {
fitBoundsToVisibleMarkers()
} else if (markers.length === 1 && coordspoly.length < 1) {
map.setZoom(15);
map.setCenter(coords);
}
}
function DeleteMarkers() {
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(null);
}
markers = [];
for (var i = 0; i < polylines.length; i++) {
polylines[i].setMap(null);
}
polylines = [];
coordspoly = [];
}
var timeout = 1500;
function GetDireccionesGV(posicion, indice, multiplicador) {
setTimeout(function () {
var columnaSeleccionada = 2 + indice;
var tr = $("#C_GvBarra").DataTable().row(indice).node();
var lat = posicion.lat;
var lng = posicion.lng;
var largo;
var url = '<%= ClsPaginas.UrlDirecciones%>' + 'nominatim/reverse.php?format=jsonv2&lat=' + lat + '&lon=' + lng;
if ($("#HdnOpcion").val() === 'All' || $("#HdnOpcion").val() === 'TPS') { largo = 37 } else { largo = 74 }
if ($())
$.getJSON(url, function (data) {
if (typeof (data.error) === 'undefined') {
if (multiplicador > 0) {
if (typeof (markers[indice]) !== 'undefined') {
markers[indice].formatted_addressrow = data.display_name
}
}
if (data.display_name.length > largo) {
tr.cells[2].innerHTML = data.display_name.substring(0, largo) + '...';
} else {
tr.cells[2].innerHTML = data.display_name;
}
tr.cells[2].title = data.display_name;
$("#C_GvBarra_HdnDireccionRow_" + indice).val(data.display_name);
} else {
tr.cells[2].innerHTML = "No se encontró la dirección";
$("#C_GvBarra_HdnDireccionRow_" + indice).val("No se encontró la dirección;");
}
});
}, timeout + (indice));
}
var countdown = 1;
var countup = 1;
var pixels = 0;
function GetDireccionesGVClick(posicion, indice) {
if (typeof (markers[indice].formatted_addressrow) === 'undefined') {
setTimeout(function () {
var columnaSeleccionada = 2 + indice;
var tr = $("#C_GvBarra").DataTable().row(indice).node()
geocoder.geocode({ 'location': posicion }, function (results, status) {
if (status === 'OK') {
if (results[0]) {
if (typeof (markers[indice]) !== 'undefined') {
markers[indice].formatted_addressrow = results[0].formatted_address
if (typeof (tr) !== 'undefined') {
tr.cells[2].innerHTML = results[0].formatted_address;
}
} else {
console.log("Ocurrio un error al obtener la direccion del punto: " + posicion + "en el indice: " + indice)
}
} else {
markers[indice].formatted_addressrow = "Direccion no encontrada"
tr.cells[2].innerHTML = "Direccion no encontrada;"
}
} else {
markers[indice].formatted_addressrow = "Cargando..."
tr.cells[2].innerHTML = "Cargando..."
}
});
}, timeout);
}
}
function GetDirecciones(posicion, infowindow, marker, indice) {
var lat = posicion.lat
var lng = posicion.lng
var url = '<%= ClsPaginas.UrlDirecciones%>' + 'nominatim/reverse.php?format=jsonv2&lat=' + lat + '&lon=' + lng;
$.getJSON(url, function (data) {
if (typeof (data.error) === 'undefined') {
marker.formatted_address = data.display_name;
var contenido = infowindow.getContent();
if (contenido.indexOf("direccion") >= 0) {
var html = $($.parseHTML(contenido));
var dir = html.filter(".direccion");;
dir.text("Dirección: " + data.display_name);
var htmlstring = "";
for (var i = 0; i < html.length; i++) {
htmlstring = htmlstring.concat(html[i].outerHTML);
}
infowindow.setContent(htmlstring);
} else {
infowindow.setContent(contenido + "<div class='direccion' style='margin-left:5px'>" + "Dirección: " + data.display_name + "</div>");
}
if (indice > -1) {
if (data.display_name.length > 74) {
if (typeof (tr) !== 'undefined') {
tr.cells[2].innerHTML = data.display_name.substring(0, 74) + '...'
}
} else {
if (typeof (tr) !== 'undefined') {
tr.cells[2].innerHTML = data.display_name
}
}
}
} else {
marker.formatted_address = "Dirección no encontrada";
if (contenido.indexOf("direccion") >= 0) {
var html = $($.parseHTML(contenido));
var dir = html.filter(".direccion");;
dir.text("Dirección no encontrada");
var htmlstring = "";
for (var i = 0; i < html.length; i++) {
htmlstring = htmlstring.concat(html[i].outerHTML);
}
infowindow.setContent(htmlstring);
} else {
infowindow.setContent(infowindow.getContent() + "<div style='margin-left:5px'> Dirección: No Encontrada </div>");
}
if (indice) {
var col = indice + 1
var tr = $('#C_GvBarra tr').filter(':nth-child(' + col + ')')
tr.find("td").filter(':nth-child(3)').html(results[0].formatted_address);
}
}
});
}
</script>
</asp:Content>

View File

@@ -0,0 +1,343 @@
Option Strict On
Option Explicit On
Imports System.Data
Imports System.IO
Imports System.Net
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports Newtonsoft.Json.Linq
Imports System.Linq
Partial Class GPS_RastreoTrayectos
Inherits Page
#Region "P R O P I E D A D E S"
Private Property TrazarLineaContinuo As Boolean
Get
Return CType(ViewState("TrazarLineaContinuo"), Boolean)
End Get
Set(value As Boolean)
ViewState("TrazarLineaContinuo") = value
End Set
End Property
Private Property CveTrayecto As Integer
Get
Return IfNull(ViewState("CveTrayecto"), -1, ViewState("CveTrayecto").ToString().ToEntero()).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveTrayecto") = value
End Set
End Property
Private Property CveDispositivo As Integer
Get
Return IfNull(ViewState("CveDispositivo"), -1, ViewState("CveDispositivo").ToString().ToEntero()).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveDispositivo") = value
End Set
End Property
Private Property CveCliente As Integer
Get
Return IfNull(ViewState("CveCliente"), -1, ViewState("CveCliente").ToString().ToEntero()).ToString().ToEntero()
End Get
Set(value As Integer)
ViewState("CveCliente") = value
End Set
End Property
Private Property DtCoordenadasContinuas As DataTable
Get
Return CType(ViewState("DtCoordenadasContinuas"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtCoordenadasContinuas") = value
End Set
End Property
Private Property DtPosiciones As DataTable
Get
Return CType(ViewState("DtPosiciones"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtPosiciones") = value
End Set
End Property
Property GlobalDTDispositivos(CveCliente As Integer) As DataTable
Get
Dim Str As StringBuilder = New StringBuilder()
If CveCliente <> -1 Then Str.AppendFormat(" {0} CveCliente = {1}", If(Str.Length > 0, "AND", ""), CveCliente)
If CveCliente <> -1 Then
Dim Dv As New DataView(DirectCast(HttpContext.Current.Application("GlobalDTDispositivos"), DataTable), Str.ToString, "", DataViewRowState.CurrentRows)
GlobalDTDispositivos = Dv.ToTable
Dv.Dispose()
Else
GlobalDTDispositivos = DirectCast(HttpContext.Current.Application("GlobalDTDispositivos"), DataTable)
End If
End Get
Set(value As DataTable)
HttpContext.Current.Application("GlobalDTDispositivos") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
RegistraScript("$('#SideNav').click();initMap();")
Me.CveTrayecto = 97
CreaDTPosiciones()
CargaDatos()
RastrearEquipos()
CargaTabla()
End If
End Sub
Private Sub CreaDTPosiciones()
DtPosiciones = Nothing
Dim dt As New DataTable
dt.Columns.Add("CveDispositivo", Type.GetType("System.Int32"))
dt.Columns.Add("Vehiculo", Type.GetType("System.String"))
dt.Columns.Add("Fecha", Type.GetType("System.String"))
dt.Columns.Add("Evento", Type.GetType("System.String"))
dt.Columns.Add("TiempoDetenido", Type.GetType("System.Double"))
dt.Columns.Add("Velocidad", Type.GetType("System.Double"))
dt.Columns.Add("Posicion", Type.GetType("System.String"))
dt.Columns.Add("KMRecorridos", Type.GetType("System.Double"))
dt.Columns.Add("Icono", Type.GetType("System.String"))
DtPosiciones = dt
End Sub
Private Sub CreaDTCoordenadas()
Dim dt As New DataTable
dt.Columns.Add("CveDispositivo", Type.GetType("System.Int32"))
dt.Columns.Add("Coord", Type.GetType("System.String"))
DtCoordenadasContinuas = dt
End Sub
Private Sub CargaDatos()
Using ObjGPS As New ClsGPS
If ObjGPS.GetTrayectos(CveTrayecto, -1, -1) AndAlso ObjGPS.DtResultados.Rows.Count > 0 Then
Dim Row As DataRow = ObjGPS.DtResultados.Rows(0)
Me.CveDispositivo = Row("CveDispositivo").ToString().ToEntero()
Me.CveCliente = Row("CveCliente").ToString().ToEntero()
End If
End Using
TrazarLineaContinuo = True
CreaDTCoordenadas()
End Sub
Protected Sub TimmerRefresh_Tick(sender As Object, e As EventArgs)
DtPosiciones.Rows.Clear()
RegistraScript("DeleteMarkers();")
Dim LastCoord As String = ""
Dim TmpDT As New DataTable
Dim Info = ""
Dim Direccion = ""
Dim SBBody As New StringBuilder
Dim Icono As String = "/Imagenes/rsz_11rsz_car.png"
Dim Fecha, Vehiculo As String
Dim ObjGPS As New ClsGPS
Try
Dim RowVehiculo As DataRow = GlobalDTDispositivos(CveCliente).FiltroPrimero($"CveDispositivo = {CveDispositivo}")
If ObjGPS.UltimaPosicionEquipoGet(CveDispositivo, MinFecha, MaxFecha) Then
If ObjGPS.DtResultados.Rows.Count > 0 Then
Dim Coord As String = SQLToGmaps(ObjGPS.DtResultados.Rows(0)("Posicion").ToString, "POINT")
Fecha = ObjGPS.DtResultados.Rows(0)("FechaTrama").ToString
Vehiculo = ObjGPS.DtResultados.Rows(0)("Vehiculo").ToString
Info = InfoWindowCombustible($" Vehículo: {Vehiculo}", "-1", CveDispositivo, ObjGPS.DtResultados.Rows(0), False)
If ObjGPS.DtResultados.Rows(0)("SPD").ToString.ToDouble > 1 Then
Icono = $"/Imagenes/{RowVehiculo("Icono")}green.png"
Else
Icono = $"/Imagenes/{RowVehiculo("Icono")}.png"
End If
AddRowCoordenadasContinuas(Coord, CveDispositivo)
Dim POLYPATH As String = "["
For Each RCC As DataRow In DtCoordenadasContinuas.FiltraParametros($"CveDispositivo = {CveDispositivo}", DistinctColumns:={"CveDispositivo", "Coord"}).Rows
POLYPATH = $"{POLYPATH}{RCC("Coord").ToString},"
Next
POLYPATH = $"{POLYPATH.Substring(0, POLYPATH.Length - 1)}]"
RegistraScript($"creaPolyline({POLYPATH}, '{RowVehiculo("ColorTrazo")}', '{Info}', {Coord}, '{RowVehiculo("NombreVehiculo")}', '{Icono}',{CveDispositivo}, 1)", $"{CveDispositivo}{DtCoordenadasContinuas.Rows.Count}")
RegistraScript($"setTimeout(function(){{ CreaMarcador({Coord},'{RowVehiculo("NombreVehiculo").ToString()}', '{Info}', '{Icono}');}}, 1000);", CveDispositivo.ToString())
AddRowPosiciones(Vehiculo, Coord, ObjGPS.DtResultados.Rows(0)("SPD").ToString.ToDouble, Fecha, CveDispositivo, ObjGPS.DtResultados(0)("TiempoDetenido").ToString.ToDouble)
End If
End If
TimmerRefresh.Enabled = True
Catch ex As Exception
OnError("Ocurrió un error al rastrear equipo", ex)
End Try
End Sub
Private Sub RastrearEquipos()
Dim LastCoord As String = ""
Dim TmpDT As New DataTable
Dim Info = ""
Dim Direccion = ""
Dim SBBody As New StringBuilder
Dim Icono As String = "/Imagenes/rsz_11rsz_car.png"
Dim Fecha, Vehiculo As String
Dim ObjGPS As New ClsGPS
Try
Dim RowVehiculo As DataRow = GlobalDTDispositivos(CveCliente).FiltroPrimero($"CveDispositivo = {CveDispositivo}")
If ObjGPS.UltimaPosicionEquipoGet(CveDispositivo, MinFecha, MaxFecha) Then
If ObjGPS.DtResultados.Rows.Count > 0 Then
Dim Coord As String = SQLToGmaps(ObjGPS.DtResultados.Rows(0)("Posicion").ToString, "POINT")
Fecha = ObjGPS.DtResultados.Rows(0)("FechaTrama").ToString
Vehiculo = ObjGPS.DtResultados.Rows(0)("Vehiculo").ToString
Info = InfoWindowCombustible($" Vehículo: {Vehiculo}", "-1", CveDispositivo, ObjGPS.DtResultados.Rows(0), False)
If ObjGPS.DtResultados.Rows(0)("SPD").ToString.ToDouble > 1 Then
Icono = $"/Imagenes/{RowVehiculo("Icono")}green.png"
Else
Icono = $"/Imagenes/{RowVehiculo("Icono")}.png"
End If
AddRowCoordenadasContinuas(Coord, CveDispositivo)
RegistraScript($"setTimeout(function(){{ CreaMarcador({Coord},'{RowVehiculo("NombreVehiculo").ToString()}', '{Info}', '{Icono}');}}, 1000);", CveDispositivo.ToString())
AddRowPosiciones(Vehiculo, Coord, ObjGPS.DtResultados.Rows(0)("SPD").ToString.ToDouble, Fecha, CveDispositivo, ObjGPS.DtResultados(0)("TiempoDetenido").ToString.ToDouble)
End If
End If
TimmerRefresh.Enabled = True
Catch ex As Exception
OnError("Ocurrió un error al rastrear equipo", ex)
End Try
ObjGPS.Dispose()
End Sub
Private Sub CargaTabla()
If DtPosiciones IsNot Nothing Then
GvBarra.DataSource = DtPosiciones
GvBarra.DataBind()
End If
If GvBarra.HeaderRow IsNot Nothing Then
GvBarra.HeaderRow.Cells(3).Style.Add("display", "")
GvBarra.HeaderRow.Cells(4).Style.Add("display", "none !important")
End If
End Sub
Private Sub AddRowCoordenadasContinuas(Coord As String, CveDispositivo As Integer)
Dim dr As DataRow = DtCoordenadasContinuas.NewRow()
dr("CveDispositivo") = CveDispositivo
dr("Coord") = Coord
DtCoordenadasContinuas.Rows.Add(dr)
End Sub
Private Sub AddRowPosiciones(Vehiculo As String, Posicion As String, Velocidad As Double, Fecha As String, CveDispositivo As Integer, Optional TiempoDetenido As Double = 0, Optional Evento As String = "", Optional KMRecorridos As Double = 0, Optional Icono As String = "/Imagenes/rsz_11rsz_car.png")
Dim dr As DataRow = DtPosiciones.NewRow()
dr("Vehiculo") = Vehiculo
dr("Fecha") = Fecha
dr("TiempoDetenido") = TiempoDetenido
dr("Velocidad") = Velocidad
dr("Posicion") = Posicion
dr("CveDispositivo") = CveDispositivo
dr("Evento") = Evento
dr("KMRecorridos") = KMRecorridos
dr("Icono") = Icono
DtPosiciones.Rows.Add(dr)
End Sub
Public Function InfoWindowCombustible(Header As String, ExtraBody As String, CveDispositivo As Integer, row As DataRow, Optional PermisoComandos As Boolean = True) As String
Dim SBuilder As New StringBuilder
SBuilder.Clear()
SBuilder.Append($"<div>")
SBuilder.Append($"<div><h5><a target=\'_blank\' href=\'\'><b>{Header}</b></a></h5></div>")
SBuilder.Append($"<div><table>")
Try
SBuilder.Append($"<tr><td>Fecha : {row("FechaTrama")} </td></tr>")
SBuilder.Append($"<tr><td>Conductor : {row("Conductor").ToString}</td></tr>")
If row.Table.Columns.Contains("Combustible") Then
SBuilder.Append($"<tr><td>Combustible : {IfNull(row("Combustible"), "NO DISPONIBLE", $"{row("Combustible").ToString.FormatoNumero} lts").ToString}</td></tr>")
End If
If row("SPD").ToString <> "-1" Then
SBuilder.Append($"<tr><td>Velocidad : {row("SPD").ToString} KM/H </td></tr>")
End If
If ExtraBody <> "" AndAlso ExtraBody <> "-1" Then
SBuilder.Append(ExtraBody)
End If
SBuilder.AppendFormat("<tr><td><a target=\'_blank\' href=\'https://www.google.com/maps/search/{0},{1}/\'>Ver en google maps</a></td></tr>", row("Lat").ToString, row("Lng").ToString)
Catch ex As Exception
OnError("Ocurrió un error al consultar", ex)
End Try
SBuilder.Append($"</table></div><div></div></div>")
Return SBuilder.ToString
End Function
Protected Sub btnPagePrev_Click(sender As Object, e As EventArgs)
Dim TotalRegistros As Integer = DtPosiciones.Rows.Count
Dim TotalRowsPage As Integer = GvBarra.PageSize
Dim PrevIndex As Integer = HdnIndexPage.Value.ToEntero - 1
Dim CurrentIndex As Integer = PrevIndex + 1
Dim PrevIndexDT As Integer = (TotalRowsPage) * PrevIndex
Dim CurrentIndexDT As Integer = (TotalRowsPage) * CurrentIndex
HdnIndexPage.Value = PrevIndex.ToString
If Not btnPageNext.Enabled Then
btnPageNext.Enabled = True
End If
If PrevIndexDT <= 0 Then
btnPagePrev.Enabled = False
GvBarra.DataSource = DtPosiciones.FiltraPorIndices(0, CurrentIndexDT)
LblRegistros.Text = $"Distribución de datos desde 0 hasta {CurrentIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}"
Else
LblRegistros.Text = $"Distribución de datos desde {PrevIndexDT.ToString.FormatoNumero(0)} hasta {CurrentIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}"
GvBarra.DataSource = DtPosiciones.FiltraPorIndices(PrevIndexDT, CurrentIndexDT)
End If
GvBarra.DataBind()
UPGV.Update()
RegistraScript("setTimeout(function(){OpcionesHistorico();},500);")
End Sub
Protected Sub btnPageNext_Click(sender As Object, e As EventArgs)
Dim TotalRegistros As Integer = DtPosiciones.Rows.Count
Dim TotalRowsPage As Integer = GvBarra.PageSize
Dim Index As Integer = HdnIndexPage.Value.ToEntero + 1
Dim NextIndex As Integer = Index + 1
Dim CurrentIndexDT As Integer = (TotalRowsPage) * Index
Dim NextIndexDT As Integer = (TotalRowsPage) * NextIndex
HdnIndexPage.Value = Index.ToString
If Not btnPagePrev.Enabled Then
btnPagePrev.Enabled = True
End If
If NextIndexDT >= TotalRegistros Then
btnPageNext.Enabled = False
GvBarra.DataSource = DtPosiciones.FiltraPorIndices(CurrentIndexDT, TotalRegistros - 1)
LblRegistros.Text = $"Distribución de datos desde {CurrentIndexDT.ToString.FormatoNumero(0)} hasta {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}. Total de registros: {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}"
Else
GvBarra.DataSource = DtPosiciones.FiltraPorIndices(CurrentIndexDT, NextIndexDT)
LblRegistros.Text = $"Distribución de datos desde {CurrentIndexDT.ToString.FormatoNumero(0)} hasta {NextIndexDT.ToString.FormatoNumero(0)}. Total de registros: {DtPosiciones.Rows.Count.ToString.FormatoNumero(0)}"
End If
GvBarra.DataBind()
UPGV.Update()
RegistraScript("setTimeout(function(){OpcionesHistorico();},500);")
End Sub
Public Sub RegistraScript(Script As String, Optional valuetick As String = "")
Dim Rdm As Random = New Random()
ScriptManager.RegisterStartupScript(Page, Me.GetType(), String.Format("{0}{1}{2}", (DateTime.Now.Ticks + 1), Rdm.Next(), valuetick), String.Format("<script type='text/javascript' language='javascript'>{0}</script>", Script), False)
End Sub
End Class

File diff suppressed because it is too large Load Diff

View File

@@ -183,7 +183,9 @@ Partial Class GPS_Trayectos
ObjGPS.IniciaTransacSQL()
Try
Dim CveTrayecto As Integer = ObjGPS.AddTrayecto(Nombre, DateTime.Now, "", CveDispositivo, UsuarioActual.CveCliente)
Dim CveTrayecto As Integer = ObjGPS.AddTrayecto(Nombre, DateTime.Now, "", CveDispositivo, UsuarioActual.CveCliente, EnviarNotificacion:=ChkNotificacion.Checked,
CorreosNotificacion:=TxtCorreoNot.Text, Intervalo:=If(ChkNotificacion.Checked, 0, DdlIntervalo.SelectedValue.ToEntero()),
EnviarLiga:=ChkEnviarLiga.Checked)
If CveTrayecto > 0 Then
For Each Row As GridViewRow In GvEstatus.Rows
@@ -401,6 +403,115 @@ Partial Class GPS_Trayectos
ObjGPS.Dispose()
End If
Return Retorno
End Function
End Function
Protected Sub ChkNotificacion_CheckedChanged(sender As Object, e As EventArgs)
DivNotificaciones.Visible = ChkNotificacion.Checked
UpAgregar.Update()
End Sub
Protected Sub LnkEnviar_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
Dim CveTrayecto As Integer = GvRow.DataKey("CveTrayecto").ToEntero()
Dim EnviarLiga As Boolean = CBool(GvRow.DataKey("EnviarLiga"))
If CveTrayecto > 0 Then
Dim DtInfoTrayecto As DataTable = Nothing
Using ObjGPS As New ClsGPS
If ObjGPS.GetTrayectosDatos(CveTrayecto) Then
DtInfoTrayecto = ObjGPS.DtSetResultados.Tables(0).Copy()
End If
End Using
If DtInfoTrayecto IsNot Nothing AndAlso DtInfoTrayecto.Rows.Count > 0 Then
Dim Row As DataRow = DtInfoTrayecto.Rows(0)
GeneraCorreo(CveTrayecto, EnviarLiga, Row)
End If
End If
End Sub
Protected Function GeneraCorreo(CveTrayecto As Integer, EnviarLiga As Boolean, Row As DataRow) As String
Dim strBody As New StringBuilder
Try
strBody.Append("<html xmlns=""http://www.w3.org/1999/xhtml""> ")
strBody.Append("<head> ")
strBody.Append(" <style type=""text/css""> ")
strBody.Append(" body ")
strBody.Append(" { ")
strBody.Append(" margin:0px; ")
strBody.Append(" padding:0px 0px 0px 0px; ")
strBody.Append(" font-family: Verdana, Arial, Helvetica, sans-serif; ")
strBody.Append(" font-size: 10px; ")
strBody.Append(" background-color:#F0F0F0; ")
strBody.Append(" } ")
strBody.Append(" a.Texto ")
strBody.Append(" { ")
strBody.Append(" font-size:11px; ")
strBody.Append(" background-color:#F7F6F3; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" } ")
strBody.Append(" .Texto ")
strBody.Append(" { ")
strBody.Append(" background-color:#F7F6F3; color:Black; font-family:Verdana; font-size:10px; text-align:center; vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .TextoAlterno ")
strBody.Append(" { ")
strBody.Append(" background-color:White; color:Black; font-family:Verdana; font-size:10px; text-align:center; ")
strBody.Append(" vertical-align:middle; height:20px;")
strBody.Append(" } ")
strBody.Append(" .BarraIdentidad ")
strBody.Append(" { ")
strBody.Append(" color:#FFFFFF; ")
strBody.Append(" background:#F0F0F0; ")
strBody.Append(" font-weight:bold; ")
strBody.Append(" font-size:19px; ")
strBody.Append(" font-style:oblique; ")
strBody.Append(" } ")
strBody.Append(" .Titulos ")
strBody.Append(" { ")
strBody.Append(" background-color: Gray;")
strBody.Append(" color:White; ")
strBody.Append(" font-family:Verdana; font-size:12px; text-align:center; ")
strBody.Append(" vertical-align:middle; font-weight:bold; height:30px; ")
strBody.Append(" text-decoration:none; ")
strBody.Append(" } ")
strBody.Append(" .Verde {color: #00CC00;} ")
strBody.Append(" .Negro {color: #000000;} ")
strBody.Append(" .Rojo {color: #FF0000;} ")
strBody.Append(" </style> ")
strBody.Append("</head> ")
strBody.Append("<body> ")
strBody.Append(" <h5> ")
strBody.Append(" ")
strBody.Append(" </h5> ")
strBody.Append(" <div id=""C_divOC"" > <fieldset> <legend><b> Datos del Trayecto</b></legend> ")
strBody.Append(" <table border=""0"" cellpadding=""0"" cellspacing=""0"" width=""550px""> ")
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td> Trayecto:</td><td colspan=""3""><b>{0}</b></td> ", Row("Trayecto"))
strBody.Append(" </tr> ")
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td> Vehículo:</td><td colspan=""3""><b>{0}</b></td> ", Row("Vehiculo"))
strBody.Append(" </tr> ")
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td>Estatus:</td><td colspan='3'><b>{0}</b></td> ", Row("Estatus"))
strBody.Append(" </tr> ")
If EnviarLiga Then
strBody.Append(" <tr style=""height: 22px""> ")
strBody.AppendFormat(" <td>Rastrea Equipo:</td><td colspan='3'><b>{0}</b></td> ", String.Format("http://gps.signalsgps.com/GPS/RastreoTrayectos.aspx?P={0}", Encripta($"CveTrayecto={CveTrayecto}")))
strBody.Append(" </tr> ")
End If
strBody.Append(" <tr > ")
strBody.AppendFormat(" <td>Posición:</td><td colspan='3'><img src=""{0}""></td> ", Row("LigaImagen"))
strBody.Append(" </tr> ")
strBody.Append(" </table> ")
strBody.Append(" </fieldset> ")
strBody.Append(" <h5> ")
strBody.Append(" ")
strBody.Append(" </h5> ")
strBody.Append(" </div> ")
strBody.Append("</body></html>")
Catch ex As Exception
OnError("Ocurrio un error al general el correo.", ex)
End Try
Return strBody.ToString()
End Function
End Class

View File

@@ -843,7 +843,7 @@
var request = {
Metodo: "UpdateNotificacion",
Params: {
Cve: <%= UsuarioActual.CveUsuario %>,
Cve: <%= If(UsuarioActual IsNot Nothing, UsuarioActual.CveUsuario, -1) %>,
CveBitacora: -1
}
}
@@ -864,8 +864,6 @@
setTimeout(startTimer, 60000); // callback
}
startTimer();
//
function ShowToast(text, header, type, footer, sound,persistencia,coords) {
@@ -919,7 +917,7 @@
var request = {
Metodo: "UpdateNotificacion",
Params: {
Cve: <%= UsuarioActual.CveUsuario %>,
Cve: <%= If(UsuarioActual IsNot Nothing, UsuarioActual.CveUsuario, -1) %>,
CveBitacora: CveNotificacionBitacora
}
}

View File

@@ -127,19 +127,22 @@ Partial Class SiteGPS
End If
End If
CargarNotificaciones()
CargarNotificaciones()
RegistraScript($"IniciarNotificaciones();startTimer();")
Else
Dim thisURL As String = Request.Url.Segments(Request.Url.Segments.Count - 1)
If thisURL.Equals("WizardRegistro.aspx") OrElse thisURL.Equals("Registro.aspx") Then
LitTit.Text = "<span style='color:white; font-size:x-large'>AD</span>&nbsp;<span style='color: #32A1CF; font-size:x-large'> Soluciones en TI</span> "
ElseIf thisURL.Equals("RastreoTrayectos.aspx") Then
LitTit.Text = "<span style='color:white; font-size:x-large'>Rastreo</span>&nbsp;<span style='color: #32A1CF; font-size:x-large'> Trayectos</span> "
End If
'Response.Redirect("/PortalGPS/LoginPortal.aspx")
End If
End If
RegistraScript($"IniciarNotificaciones();")
Else
'VALIDACION DE SEGURIDAD, EN LA QUE SE VALIDA QUE LA EMPRESA EN LA QUE SE GENERO LA PAGINA SEA LA MISMA A LA DE LA SESION,

View File

@@ -837,19 +837,22 @@
<i></i>
</div>
<div id="DivRetenciones" runat="server">
<div id="DivTipoRetenciones" runat="server" visible="false" class="form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlTipoRetencion" AutoPostBack="true" OnSelectedIndexChanged="DdlTipoRetencion_SelectedIndexChanged" CssClass="form-control select2me" runat="server" AppendDataBoundItems="true" CausesValidation="true">
<asp:ListItem Selected="True" Text="Sin Retención" Value="0"></asp:ListItem>
<asp:ListItem Text="Arrendamiento" Value="1"></asp:ListItem>
<asp:ListItem Text="Servicios Profesionales" Value="2"></asp:ListItem>
<asp:ListItem Text="Fletes" Value="3"></asp:ListItem>
<asp:ListItem Text="Servicios" Value="4"></asp:ListItem>
</asp:DropDownList>
<label for="<%= DdlTipoRetencion.ClientID.ToString()%>">Tipo de Retención de IVA:</label>
<asp:RequiredFieldValidator ID="RFVTipoRetencion" runat="server" ControlToValidate="DdlTipoRetencion" CssClass="help-block" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Tipo de Retención''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<i></i>
</div>
<div class="row">
<div class="col-md-6">
<div id="DivTipoRetenciones" runat="server" visible="false" class="form-group form-md-line-input input-iconright">
<asp:DropDownList ID="DdlTipoRetencion" ToolTip="Al establecer la retención de servicios, deberá especificarse el producto, como outsourcing para que se aplique la retención."
AutoPostBack="true" OnSelectedIndexChanged="DdlTipoRetencion_SelectedIndexChanged" CssClass="form-control select2me" runat="server" AppendDataBoundItems="true" CausesValidation="true">
<asp:ListItem Selected="True" Text="Sin Retención" Value="0"></asp:ListItem>
<asp:ListItem Text="Arrendamiento" Value="1"></asp:ListItem>
<asp:ListItem Text="Servicios Profesionales" Value="2"></asp:ListItem>
<asp:ListItem Text="Fletes" Value="3"></asp:ListItem>
<asp:ListItem Text="Servicios" Value="4"></asp:ListItem>
</asp:DropDownList>
<label for="<%= DdlTipoRetencion.ClientID.ToString()%>" >Tipo de Retención de IVA:</label>
<asp:RequiredFieldValidator ID="RFVTipoRetencion" runat="server" ControlToValidate="DdlTipoRetencion" CssClass="help-block" ErrorMessage="<b><span style='text-decoration: underline'>ERROR:</span></b><br />El campo <b>''Tipo de Retención''</b> es necesario, por favor seleccione uno." InitialValue="-1" ValidationGroup="GrpGuardar"></asp:RequiredFieldValidator>
<i></i>
</div>
</div>
<div class="col-md-6">
<div id="DivRetIVA" runat="server" class="form-group form-md-line-input input-iconright">
<asp:TextBox ID="TxtRetIVA" CssClass="form-control" runat="server" MaxLength="9" Text="0"></asp:TextBox>
@@ -859,6 +862,8 @@
<i style="font-weight: bold;">%</i>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group form-md-line-input input-iconright">
<asp:TextBox ID="TxtRetISR" CssClass="form-control" runat="server" MaxLength="9" Text="0"></asp:TextBox>
@@ -868,6 +873,8 @@
<i style="font-weight: bold;">%</i>
</div>
</div>
<div class="col-md-6">
</div>
</div>
</div>
<div class="form-group form-md-line-input" id="DivRetFletes" runat="server" visible="false">

View File

@@ -344,6 +344,11 @@
<asp:Literal ID="LtlDescuentoProntoPago" runat="server" Text='<%# Eval("DescuentoProntoPago", "{0:N2}") %>'></asp:Literal>&nbsp;
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Generar NC" Visible="false" >
<ItemTemplate>
<asp:CheckBox ID="ChkGenerarNC" CssClass="chkgv" runat="server" Visible="false"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="300px">
<HeaderTemplate>Auxiliar</HeaderTemplate>
<ItemTemplate>
@@ -506,6 +511,11 @@
} else {
txt.value = "";
}
//if (typeof t2 === "undefined") {
//} else {
//}
if (chkPesosBancos) {

View File

@@ -1,5 +1,7 @@
Imports System.Data
Imports Extensiones
Imports Extensiones
Imports System.Data
Imports System.Linq
Partial Class Ventas_ClientesAbonar
Inherits ClsPaginas
@@ -459,7 +461,10 @@ Partial Class Ventas_ClientesAbonar
TxtImporte.Text = ""
TxtObservaciones.Text = ""
If SumDescuentoProntoPago > 0.0 Then
GvCxC.Columns(14).Visible = True
GvCxC.Columns(14).Visible = True 'MOSTRAR DESCUENTO PRONTO PAGO
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
GvCxC.Columns(15).Visible = True 'HABILITAR NC
End If
End If
Mov.Dispose()
@@ -635,6 +640,11 @@ Partial Class Ventas_ClientesAbonar
e.Row.FCRangeValidator("RVComision").MinimumValue = 0.00
e.Row.FCRangeValidator("RVComision").MaximumValue = e.Row.DBCampo("Saldo")
End If
If e.Row.DBCampo("DescuentoProntoPago").ToDecimal() >= 0 Then
e.Row.FCCheckBox("ChkGenerarNC").Visible = True
End If
Else
e.Row.FCTextBox("TxtAbonar").Visible = False
e.Row.FCTextBox("TxtComision").Visible = False
@@ -680,6 +690,8 @@ Partial Class Ventas_ClientesAbonar
Next
Dim MsgError As String = ""
Dim NCGeneradas As New List(Of Modelos.Factura.MMensajeFactura)
Dim ListaFacturasGenerarNC As New List(Of Modelos.Factura)
'comentada RMF 2018.09.28
'Dim Dep As New ClsGenerales
@@ -1362,43 +1374,43 @@ Partial Class Ventas_ClientesAbonar
If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
End If
'Case 92
' If RblTipoPago.SelectedValue = "3" Then ' cuando es ingreso por comprobar
' ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
' importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2)
' CveSubProyectoContabilizar = CveSubProyecto
' If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
' 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe
' If gvr.DataKey("CveMoneda").ToEntero <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then
' importeMX = ImporteMovimiento
' IdCtaContable = IdCtaContMonedaExtranjera
' Else
' IdCtaContable = IdCuentaCliente
' CveCuenta = CveCuentaCliente
' End If
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=importeMX, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then
' MsgError = "No se pudo insertar la póliza"
' End If
' If gvr.DataKey("CveMoneda").ToEntero = 2 Then
' IdCtaContable = IdCtaContComplementaria
' CveCuenta = CveCuentaComplementaria
' If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 227, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, CveCuenta:=CveCuenta, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then
' MsgError = "No se pudo insertar la póliza"
' End If
' importeMX = ImporteMovimiento
' IdCtaContable = IdCtaContMonedaExtranjera
' CveCuenta = CveCuentaMonedaExtranjera
' End If
' End If
' End If
' ImporteMovimiento = 0
End If
'Case 92
' If RblTipoPago.SelectedValue = "3" Then ' cuando es ingreso por comprobar
' ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal
' importeMX = Math.Round(ImporteMovimiento * tipoCambioPago, 2)
' CveSubProyectoContabilizar = CveSubProyecto
' If tipoCambioVenta > 1 Then ConceptoMovimiento += $" TC:{tipoCambioVenta} ${ImporteMovimiento.FormatoNumero(2)}"
' 'si la factura es en dólares y trae complementaria, el importemn debe ser igual al importe
' If gvr.DataKey("CveMoneda").ToEntero <> 1 AndAlso (IdCtaContComplementaria > 0 Or UsuarioActual.CveEmpresa = 119) Then
' importeMX = ImporteMovimiento
' IdCtaContable = IdCtaContMonedaExtranjera
' Else
' IdCtaContable = IdCuentaCliente
' CveCuenta = CveCuentaCliente
' End If
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, ImporteMovimiento, Referencia, ConceptoContable, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=importeMX, CveCuenta:=CveCuenta, CveSubProyecto:=CveSubProyectoContabilizar) Then
' MsgError = "No se pudo insertar la póliza"
' End If
' If gvr.DataKey("CveMoneda").ToEntero = 2 Then
' IdCtaContable = IdCtaContComplementaria
' CveCuenta = CveCuentaComplementaria
' If ImporteMovimiento <> 0 AndAlso (IdCtaContable > 0 Or UsuarioActual.CveEmpresa = 119) Then
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, 0, TxtObservaciones.Text, 227, ConceptoMovimiento, FechaMovimiento, IdCtaContable, -1, CveIE:=DdlIngreso.SelectedValue.ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCliente:=CveCliente, ImporteMX:=ImporteMovimiento * tipoCambioPago - ImporteMovimiento, CveCuenta:=CveCuenta, ImporteME:=ImporteMovimiento, TipoCambio:=tipoCambioPago) Then
' MsgError = "No se pudo insertar la póliza"
' End If
' importeMX = ImporteMovimiento
' IdCtaContable = IdCtaContMonedaExtranjera
' CveCuenta = CveCuentaMonedaExtranjera
' End If
' End If
' End If
' ImporteMovimiento = 0
Case 134 'Pago Intermediario
If RblTipoPago.SelectedValue = "2" Then
ImporteMovimiento = gvr.FCTextBox("TxtAbonar").Text.ToDecimal - gvr.FCTextBox("TxtComision").Text.ToDecimal
@@ -1438,6 +1450,10 @@ Partial Class Ventas_ClientesAbonar
End If
Next
End If
If gvr.FCCheckBox("ChkGenerarNC").Checked Then
ListaFacturasGenerarNC.Add(New Modelos.Factura(UsuarioActual, gvr.DataKey("CveVenta").ToEntero(), UsuarioActual.CveEmpresa) With {.DescuentoProntoPago = gvr.DataKey("DescuentoProntoPago").ToDecimal()})
End If
End If
Next
@@ -1565,7 +1581,16 @@ Partial Class Ventas_ClientesAbonar
MsgError = "No se insertó el encabezado"
End If
If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then
If MsgError = "" Then
Dim Resp = GenerarNC(ObjIE.IniciaTransacSQL(), ObjConta, ListaFacturasGenerarNC)
If Resp.CveVenta > 0 Then
NCGeneradas.Add(Resp)
Else
MsgError = "No se pudo generar la nota de credito"
End If
End If
End If
If MsgError = "" Then
'se agregan las pólizas de Armonización Contable
@@ -1649,8 +1674,17 @@ Partial Class Ventas_ClientesAbonar
Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
Dim SbMensaje As New StringBuilder
SbMensaje.Append(String.Format("Abono Registrado Correctamente.<br/><br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a><br/><br/>{2}", IDPoliza, FolioPoliza, TextoComplementoPago))
For Each NC In NCGeneradas
For Each msg In NC.Mensajes
SbMensaje.Append(msg)
Next
SbMensaje.Append("</br>")
Next
Alert(String.Format("Abono Registrado Correctamente.<br/><br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a><br/><br/>{2}", IDPoliza, FolioPoliza, TextoComplementoPago), TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx"""))
Alert(SbMensaje.ToString())
Else
ObjIE.RollBack()
If ObjConta IsNot Nothing Then ObjConta.RollBack()
@@ -1671,7 +1705,17 @@ Partial Class Ventas_ClientesAbonar
If IDPoliza > 0 Then StrMsg.AppendFormat("<br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a>", IDPoliza, FolioPoliza)
Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
Dim TextoComplementoPago = EmitirComplementoPago(CveIE, CveVentasPago, SeriesPago)
Dim SbMensaje As New StringBuilder
SbMensaje.Append(String.Format("Abono Registrado Correctamente.<br/><br/> Poliza: <a href='/Contabilidad/RegPoliza.aspx?IdPoliza={0}' target='_blank' class='Texto'>{1}</a><br/><br/>{2}", IDPoliza, FolioPoliza, TextoComplementoPago))
For Each NC In NCGeneradas
For Each msg In NC.Mensajes
StrMsg.Append(msg)
Next
StrMsg.Append("</br>")
Next
Alert($"{StrMsg.ToString}<br/><br/>{TextoComplementoPago}", TipoMensaje.MsgInformacion, If(ChkSeguirRegistrando.Checked, "location.href =""#""", "location.href =""/Bancos/RepCxCCliente.aspx"""))
End If
@@ -1703,8 +1747,463 @@ Partial Class Ventas_ClientesAbonar
ObjEvento.Dispose()
LimpiaCampos()
End Sub
End Sub
#Region " N O T A - D E - C R E D I T O"
Private Function GenerarNC(Trasac As SqlClient.SqlTransaction, ObjConta As ClsContPAQi, ListaVentasGenerarNC As List(Of Modelos.Factura)) As Modelos.Factura.MMensajeFactura
Dim ObjFacturaDevolucion = New Modelos.Factura(UsuarioActual)
ObjFacturaDevolucion.TipoMensajeRespuesta = Modelos.TipoMensajeRespuesta.HTML
ObjFacturaDevolucion.CveUsuario = UsuarioActual.CveUsuario
ObjFacturaDevolucion.UsuarioCreo = UsuarioActual.Usuario
'If CveVentaPadre > 0 Then
' ObjFacturaDevolucion.CveVentaPadre = CveVentaPadre
' ObjFacturaDevolucion.CveVentaRelacion = CveVentaPadre
'End If
Dim Folio As String = ""
Dim Serie As String = ""
Dim ObjFolios As New ClsGralFolios()
If ObjFolios.GetFolios("Egs", UsuarioActual.CveEmpresa) Then
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" Estado = 'Activo' AND CveSubProyecto = {0}", Me.CveSubProyecto))
If DT.Rows.Count > 0 Then
Serie = DT.Rows(0)("Serie").ToString()
Folio = DT.Rows(0)("FActual").ToString()
End If
DT.Dispose()
End If
ObjFolios.Dispose()
ObjFacturaDevolucion.CveEmpresa = UsuarioActual.CveEmpresa
ObjFacturaDevolucion.TipoCambio = If(Me.CveMoneda = 1, 1, GlobalTipoCambio(Now).FormatoNumero(4).ToDecimal())
ObjFacturaDevolucion.ConvertirPesos = False
ObjFacturaDevolucion.CveMoneda = Me.CveMoneda
ObjFacturaDevolucion.Moneda = GlobalDTMonedas.FiltroPrimeroValor("Moneda", $"CveMoneda = {Me.CveMoneda}")
ObjFacturaDevolucion.MonedaSAT = GlobalDTMonedas.FiltroPrimeroValor("AbreviaturaSAT", $"CveMoneda = {Me.CveMoneda}")
ObjFacturaDevolucion.Serie = Serie
ObjFacturaDevolucion.Folio = Folio
ObjFacturaDevolucion.Fecha = Now
ObjFacturaDevolucion.CvePrePoliza = -1
ObjFacturaDevolucion.CveMetodoPago = 0
ObjFacturaDevolucion.CondicionesPago = 0 ' 0 - Contado, 1 - Credito (CHECAR)
ObjFacturaDevolucion.FormaPago = 0
ObjFacturaDevolucion.TipoDocto = "Egs"
ObjFacturaDevolucion.Fecha = Now
ObjFacturaDevolucion.Version = "3.3"
ObjFacturaDevolucion.CveMetodoPago33 = 1
ObjFacturaDevolucion.MetodoPago33 = "Pago en una sola exhibición"
ObjFacturaDevolucion.ClaveMetodoPagoSAT = "PUE"
ObjFacturaDevolucion.CveFormaPago33 = 21
ObjFacturaDevolucion.FormaPago33 = "Aplicación de anticipos"
ObjFacturaDevolucion.FormaPagoSAT33 = "30"
ObjFacturaDevolucion.MetodoPago = ""
ObjFacturaDevolucion.ClaveMetodoPagoSAT = GlobalDTMetodosPago.FiltroPrimeroValor("ClaveSAT", $"CveMetodoPago = {ObjFacturaDevolucion.CveMetodoPago33}")
ObjFacturaDevolucion.CveSubProyecto = Me.CveSubProyecto
ObjFacturaDevolucion.SetSubProyecto()
ObjFacturaDevolucion.CveCliente = Me.CveCliente
ObjFacturaDevolucion.SetCliente()
Dim ObjCliente As New ClsClientes
If ObjCliente.GetClientes(ObjFacturaDevolucion.CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1, TipoCliente:=-1) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
ObjFacturaDevolucion.CveUsoCFDI = ObjCliente.CveUsoCFDI
ObjFacturaDevolucion.UsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("Descripcion", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
ObjFacturaDevolucion.ClaveUsoCFDI = GlobalDTSATUsosCFDI.FiltroPrimeroValor("UsoCFDI", String.Format("CveUsoCFDI = {0}", ObjCliente.CveUsoCFDI))
ObjFacturaDevolucion.DtDetalle = CreaDTDetalleNC()
CargaImpuestos(ObjFacturaDevolucion, ListaVentasGenerarNC, ObjCliente.DesglosaIEPS, ObjCliente.RetIVA, ObjCliente.RetISR)
End If
End If
If ObjCliente.GetSucursales(CveCliente) Then
If ObjCliente.DtResultados.Rows.Count > 0 Then
ObjFacturaDevolucion.CveClienteSucursal = If(String.IsNullOrEmpty(ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'")), -1, ObjCliente.DtResultados.FiltroPrimeroValor("CveClienteSucursal", "Estatus = 'Activo'").ToEntero())
Else
ObjFacturaDevolucion.CveClienteSucursal = -1
End If
End If
ObjCliente.Dispose()
ObjFacturaDevolucion.CveTipoRelacion = 7
ObjFacturaDevolucion.TipoRelacion = "07"
Dim Fol As New List(Of String)
For Each Fac In ListaVentasGenerarNC
Fol.Add(Fac.FolioFiscal)
Next
ObjFacturaDevolucion.UUIDRelacionados = Fol
Select Case ObjFacturaDevolucion.TipoDocto
Case "Ing"
ObjFacturaDevolucion.TipoDocumento = "Factura"
Case "REM"
ObjFacturaDevolucion.TipoDocumento = "Remision"
Case "Cot"
ObjFacturaDevolucion.TipoDocumento = "Cotizacion"
Case "Egs"
ObjFacturaDevolucion.TipoDocumento = "Nota de Crédito"
Case "Dev"
ObjFacturaDevolucion.TipoDocumento = "Nota de Devolución"
Case Else
ObjFacturaDevolucion.TipoDocumento = ""
End Select
If ObjFacturaDevolucion.TipoDocto IsNot Nothing Then
ViewState("TipoDoctoDevolucion") = ObjFacturaDevolucion.TipoDocto
End If
ObjFacturaDevolucion.FechaPago = Now
ObjFacturaDevolucion.CveCorte = -1
ObjFacturaDevolucion.CveMesa = -1
ObjFacturaDevolucion.NumeroPersonas = 0
ObjFacturaDevolucion.CveContrato = -1
ObjFacturaDevolucion.DescripcionContrato = ""
ObjFacturaDevolucion.CveClienteSucursal = -1
ObjFacturaDevolucion.Entrega = ""
ObjFacturaDevolucion.CveAlmacen = -1
Dim DtVentasNC = InicializaDTVentasNC()
Dim TotalImporte As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("TotalImporte").ToDecimal()
Dim ImporteIVA As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIVA").ToDecimal()
Dim ImporteRetIVA As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetIVA").ToDecimal()
Dim ImporteRetISR As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteRetISR").ToDecimal()
Dim ImporteIEPS As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("ImporteIEPS").ToDecimal()
Dim Descuento As Decimal = ObjFacturaDevolucion.DtDetalle.SUM("Descuento").ToDecimal()
Dim Amortizacion As Decimal = 0
Dim Total As Decimal = (TotalImporte + ImporteIVA + ImporteIEPS) - (ImporteRetIVA + ImporteRetISR + Descuento + Amortizacion)
'DETALLES
ObjFacturaDevolucion.SubTotal = TotalImporte
ObjFacturaDevolucion.Descuento = Descuento
ObjFacturaDevolucion.Amortizacion = Amortizacion
ObjFacturaDevolucion.IVA = ImporteIVA
ObjFacturaDevolucion.RetIVA = ImporteRetIVA
ObjFacturaDevolucion.RetISR = ImporteRetISR
ObjFacturaDevolucion.IEPS = ImporteIEPS
ObjFacturaDevolucion.Total = Total
ObjFacturaDevolucion.TotalOtrosConceptos = 0
For Each Fac In ListaVentasGenerarNC
Dim Drt = DtVentasNC.NewRow
Drt("CveVenta") = Fac.CveVenta
Drt("Importe") = Fac.DescuentoProntoPago
Drt("FolioFiscal") = Fac.FolioFiscal
DtVentasNC.Rows.Add(Drt)
Next
DtVentasNC.AcceptChanges()
ObjFacturaDevolucion.DtVentasNC = DtVentasNC
Dim Resp = ObjFacturaDevolucion.EmitirFactura(False, Trasac:=Trasac, ObjContPaqTransac:=ObjConta)
Return Resp
End Function
Private Sub AgregaTempDTNC(ByRef TmpDT As DataTable, CvePS As Integer, PS As String, Codigo As String, CodigoPS As String, CveTipoPS As Integer, CveTipoInvPS As Integer, CveUM As Integer, UM As String,
CveClasificacion As Integer, Clasificacion As String, CveProyecto As Integer, CveSubProyecto As Integer,
Obs As String, Cantidad As Double, PU As Double, PorcentajeIVA As Double, ImporteIVA As Double, PorcentajeRetIVA As Double, ImporteRetIVA As Double,
PorcentajeRetISR As Double, ImporteRetISR As Double, PorcentajeIEPS As Double, ImporteIEPS As Double, TipoDescuento As Integer, Descuento As Double,
Total As Double, SerieLote As String, TiempoEntrega As String, CvePresupuestoIngreso As Integer, EntregaDirecta As Integer, SATClaveProdServ As String,
SATClaveUM As String, CveContratoDetalle As Integer, CveVentaDetalle As Integer, CveMovimientoDetallePedido As Integer, CveOrdenCompraDetalle As Integer,
CveVentaDetalleRemision As Integer, CveVentaDetalleCotizacion As Integer)
Dim Row As DataRow = Nothing
Row = TmpDT.NewRow()
Row("Consec") = TmpDT.Rows.Count + 1
Row("Orden") = TmpDT.Rows.Count + 1
Row("CvePS") = CvePS
Row("PS") = PS
Row("Codigo") = Codigo
Row("CodigoPS") = CodigoPS
Row("CveTipoPS") = CveTipoPS
Row("CveTipoInvPS") = CveTipoInvPS
Row("CveUM") = CveUM
Row("UM") = UM
Row("CveClasificacion") = CveClasificacion
Row("Clasificacion") = Clasificacion
Row("CveProyecto") = CveProyecto
Row("Proyecto") = ""
Row("CveSubProyecto") = CveSubProyecto
Row("SubProyecto") = ""
Row("Obs") = Obs
Row("Cantidad") = Cantidad
Row("PU") = Math.Round(PU, 6)
Row("PorcentajeIVA") = PorcentajeIVA
Row("IVA") = PorcentajeIVA
Row("ImporteIVA") = Math.Round(ImporteIVA, 2)
Row("PorcentajeRetIVA") = PorcentajeRetIVA
Row("ImporteRetIVA") = Math.Round(ImporteRetIVA, 2)
Row("PorcentajeRetISR") = PorcentajeRetISR
Row("ImporteRetISR") = Math.Round(ImporteRetISR, 2)
Row("PorcentajeIEPS") = PorcentajeIEPS
Row("ImporteIEPS") = Math.Round(ImporteIEPS, 2)
Row("IEPS") = Math.Round(ImporteIEPS, 2)
Row("TipoDescuento") = TipoDescuento
Row("Descuento") = Math.Round(Descuento, 2)
Row("Total") = Math.Round(Total, 2)
Row("TotalImporte") = Math.Round(Total, 2)
Row("SerieLote") = SerieLote
Row("TiempoEntrega") = TiempoEntrega
Row("CvePresupuestoIngreso") = CvePresupuestoIngreso
Row("EntregaDirecta") = EntregaDirecta
Row("SATClaveProdServ") = SATClaveProdServ
Row("SATClaveUM") = SATClaveUM
'Contratos
Row("CveContratoDetalle") = CveContratoDetalle
Row("CveVentaDetalle") = CveVentaDetalle
Row("CveMovimientoDetallePedido") = CveMovimientoDetallePedido
Row("CveOrdenCompraDetalle") = CveOrdenCompraDetalle
Row("CveVentaDetalleRemision") = CveVentaDetalleRemision
Row("CveVentaDetalleCotizacion") = CveVentaDetalleCotizacion
TmpDT.Rows.Add(Row)
End Sub
Private Sub CargaImpuestos(ByRef ObjFacturaDevolucion As Modelos.Factura, ListaVentasGenerarNC As List(Of Modelos.Factura), ClienteDesglosaIEPS As Boolean, ClienteRetIVA As Decimal, ClienteRetISR As Decimal)
Dim DtImpuestos As New DataTable
DtImpuestos.Columns.Add("ImportePU", GetType(Decimal))
DtImpuestos.Columns.Add("ImporteTotal", GetType(Decimal))
DtImpuestos.Columns.Add("PorcentajeIVA", GetType(Decimal))
DtImpuestos.Columns.Add("ImporteIVA", GetType(Decimal))
DtImpuestos.Columns.Add("PorcentajeRetIVA", GetType(Decimal))
DtImpuestos.Columns.Add("ImporteRetIVA", GetType(Decimal))
DtImpuestos.Columns.Add("PorcentajeRetISR", GetType(Decimal))
DtImpuestos.Columns.Add("ImporteRetISR", GetType(Decimal))
DtImpuestos.Columns.Add("PorcentajeIEPS", GetType(Decimal))
DtImpuestos.Columns.Add("ImporteIEPS", GetType(Decimal))
DtImpuestos.Columns.Add("CveSubProyecto", GetType(Integer))
DtImpuestos.AcceptChanges()
Dim AcumuladoNC As Decimal = 0
For Each Fac In ListaVentasGenerarNC
DtImpuestos.Merge(CargaDtImpuestosNC(Fac.CveVenta, Fac.DescuentoProntoPago), True, MissingSchemaAction.Ignore)
Next
DtImpuestos = CargaTotalesImpuestos(DtImpuestos)
Dim DrSubProyecto As DataRow = GlobalDTSubProyectos(-1, ObjFacturaDevolucion.CveSubProyecto).Rows(0)
Dim Cantidad As Decimal = 1
Dim CveProyecto As Integer = DrSubProyecto("CveProyecto").ToString().ToEntero()
Dim CveSubProyecto = DrSubProyecto("CveSubProyecto").ToString.ToEntero
Dim SubProyecto = DrSubProyecto("SubProyecto").ToString
Dim Proyecto = DrSubProyecto("Proyecto").ToString
Dim CveSATNC = "84111506"
Dim DrPS = GlobalDTPS(UsuarioActual.CveEmpresa, SATClavePS:=CveSATNC, AplicaParaVenta:=1).FiltroPrimero("")
For Each Dr As DataRow In DtImpuestos.Rows
AgregaTempDTNC(ObjFacturaDevolucion.DtDetalle, DrPS("CvePS").ToString.ToEntero, DrPS("PS").ToString, DrPS("Codigo").ToString, DrPS("PSCodigo").ToString, DrPS("CveTipoPS").ToString.ToEntero, DrPS("Inv_CveMetodoInventario").ToString.ToEntero,
DrPS("CveUM").ToString.ToEntero, DrPS("UnidadMedida").ToString, DrPS("CveClasificacion").ToString.ToEntero, DrPS("Clasificacion").ToString, CveProyecto, CveSubProyecto,
"", Cantidad, Dr("ImportePU").ToString.ToDecimal, Dr("PorcentajeIVA").ToString.ToDecimal, Dr("ImporteIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("ImporteRetIVA").ToString.ToDecimal,
Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("ImporteRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("ImporteIEPS").ToString.ToDecimal, -1, 0.0, Dr("ImporteTotal").ToString.ToDecimal, "", "", -1, -1,
DrPS("SATClavePS").ToString, DrPS("SATClaveUnidadMedida").ToString, -1, -1, -1, -1, -1, -1)
Next
End Sub
Private Function CargaDtImpuestosNC(CveVentaNC As Integer, Importe As Decimal) As DataTable
Dim Total As Decimal = 0, SubTotal As Decimal = 0, Saldo As Decimal = 0
Dim TmpDT As DataTable = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVentaDetalle(CveVentaNC) Then
TmpDT = ObjVentas.DtResultados
TmpDT.Columns.Add("EntregaDirecta", GetType(Integer))
TmpDT.Columns.Add("CveMovimientoDetallePedido", GetType(Integer))
End If
If ObjVentas.GetVenta(CveVentaNC, UsuarioActual.CveEmpresa) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
Total = ObjVentas.DtResultados()(0)("Total").ToString.ToDecimal
SubTotal = ObjVentas.DtResultados()(0)("SubTotal").ToString.ToDecimal
End If
End If
ObjVentas.Dispose()
Dim DtImpuestosLocal = TmpDT.FiltraParametros("", "", {"PorcentajeIVA", "PorcentajeRetIVA", "PorcentajeRetISR", "PorcentajeIEPS", "CveSubProyecto"}).Copy
DtImpuestosLocal.Columns.Add("ImportePU", GetType(Decimal))
DtImpuestosLocal.Columns.Add("ImporteTotal", GetType(Decimal))
DtImpuestosLocal.Columns.Add("ImporteIVA", GetType(Decimal))
DtImpuestosLocal.Columns.Add("ImporteRetIVA", GetType(Decimal))
DtImpuestosLocal.Columns.Add("ImporteRetISR", GetType(Decimal))
DtImpuestosLocal.Columns.Add("ImporteIEPS", GetType(Decimal))
Dim ImporteReferencia As Decimal = Total
Dim Porcentaje As Decimal = ((Importe * 100) / ImporteReferencia) / 100
Dim FiltroStr As String = ""
For Each Dr As DataRow In DtImpuestosLocal.Rows
FiltroStr = String.Format("ISNULL(PorcentajeIVA,0) = {0} AND ISNULL(PorcentajeRetIVA,0) = {1} AND ISNULL(PorcentajeRetISR,0) = {2} AND ISNULL(PorcentajeIEPS,0) = {3} AND ISNULL(CveSubProyecto,0) = {4} ", Dr("PorcentajeIVA").ToString.ToDecimal, Dr("PorcentajeRetIVA").ToString.ToDecimal, Dr("PorcentajeRetISR").ToString.ToDecimal, Dr("PorcentajeIEPS").ToString.ToDecimal, Dr("CveSubProyecto"))
Dr("ImporteTotal") = Math.Round(Porcentaje * (TmpDT.SUM("TotalImporte", FiltroStr) - TmpDT.SUM("Descuento", FiltroStr)), 2)
Dr("ImporteIVA") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeIVA").ToString().ToDecimal()).RoundSQL(2)
Dr("ImporteRetIVA") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeRetIVA").ToString().ToDecimal()).RoundSQL(2)
Dr("ImporteRetISR") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeRetISR").ToString().ToDecimal()).RoundSQL(2)
Dr("ImporteIEPS") = (Dr("ImporteTotal").ToString().ToDecimal() * Dr("PorcentajeIEPS").ToString().ToDecimal()).RoundSQL(2)
'Dr("ImporteIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIVA", FiltroStr), 2)
'Dr("ImporteRetIVA") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetIVA", FiltroStr), 2)
'Dr("ImporteRetISR") = Math.Round(Porcentaje * TmpDT.SUM("ImporteRetISR", FiltroStr), 2)
'Dr("ImporteIEPS") = Math.Round(Porcentaje * TmpDT.SUM("ImporteIEPS", FiltroStr), 2)
Dr("ImportePU") = Dr("ImporteTotal").ToString.ToDecimal '(Dr("ImporteTotal").ToString.ToDecimal - Dr("ImporteIVA").ToString.ToDecimal - Dr("ImporteRetIVA").ToString.ToDecimal - Dr("ImporteRetISR").ToString.ToDecimal - Dr("ImporteIEPS").ToString.ToDecimal)
Next
'codigo para ajuste de centavo, si el importe total no cuadra con los totales
Dim difTmp As Decimal = Importe - (DtImpuestosLocal.SUMD("ImporteTotal") + DtImpuestosLocal.SUMD("ImporteIVA") + DtImpuestosLocal.SUMD("ImporteIEPS") - DtImpuestosLocal.SUMD("ImporteRetIVA") - DtImpuestosLocal.SUMD("ImporteRetISR"))
If Math.Abs(difTmp) >= 0.01 Then
'asusto la diferencia en el último concepto
Dim ImporteAjustado As Decimal = DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal").ToString.ToDecimal + difTmp
DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImporteTotal") = ImporteAjustado
DtImpuestosLocal.Rows(DtImpuestosLocal.Rows.Count - 1)("ImportePU") = ImporteAjustado
End If
'CARGA FACTURA A LA CUAL SE APLICA LA NC
'CargaNCDT(CveVentaNC, Importe.ToDecimal)
Return DtImpuestosLocal
End Function
Private Function CargaTotalesImpuestos(DtImpuestos As DataTable) As DataTable
Dim query = From dr In DtImpuestos
Group By PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal,
PorcentajeRetIVA = dr("PorcentajeRetIVA").ToString.ToDecimal,
PorcentajeRetISR = dr("PorcentajeRetISR").ToString.ToDecimal,
PorcentajeIEPS = dr("PorcentajeIEPS").ToString.ToDecimal
Into x = Group
Select ImportePU = x.Sum(Function(s) s("ImportePU").ToString.ToDecimal),
ImporteTotal = x.Sum(Function(s) s("ImporteTotal").ToString.ToDecimal),
ImporteIVA = x.Sum(Function(s) Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)), ' Math.Round(s("ImporteIVA").ToString.ToDecimal, 2)) * (1 + PorcentajeIEPS) * PorcentajeIVA,
ImporteRetIVA = x.Sum(Function(s) Math.Round(s("ImporteRetIVA").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetIVA,
ImporteRetISR = x.Sum(Function(s) Math.Round(s("ImporteRetISR").ToString.ToDecimal, 2)),' Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeRetISR,
ImporteIEPS = x.Sum(Function(s) Math.Round(s("ImporteIEPS").ToString.ToDecimal, 2)), 'Math.Round(s("ImportePU").ToString.ToDecimal, 2)) * PorcentajeIEPS,
PorcentajeIVA = PorcentajeIVA,
PorcentajeRetIVA = PorcentajeRetIVA,
PorcentajeRetISR = PorcentajeRetISR,
PorcentajeIEPS = PorcentajeIEPS
Return query.QueryToDataTable(False)
End Function
Protected Function CreaDTDetalleNC() As DataTable
Dim 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))
Return TmpDT
End Function
Private Function InicializaDTVentasNC() As DataTable
Dim DtVentasNC = New DataTable
DtVentasNC.Columns.Add("CveVenta", GetType(Integer))
DtVentasNC.Columns.Add("Importe", GetType(Decimal))
DtVentasNC.Columns.Add("FolioFiscal", GetType(String))
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TC", .DataType = GetType(Decimal), .DefaultValue = 1})
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "TCCambioValuacion", .DataType = GetType(Decimal), .DefaultValue = 1})
DtVentasNC.Columns.Add(New DataColumn With {.ColumnName = "CveEstatusFactura", .DataType = GetType(Integer), .DefaultValue = -1})
Return DtVentasNC
End Function
#End Region
Private Sub LimpiaCampos()
TxtFolio.Text = ""
TxtObservaciones.Text = ""

View File

@@ -6494,7 +6494,7 @@ Partial Class Ventas
'Valida si en caso de que el detalle tenga llantas o polizas se agreguén kilometraje/serie en la parte de observaciones(solo para el caso de empresas llanteras)
If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then
If txtkilometraje.text.toentero = 0 Then
If TxtKilometraje.Text.ToEntero = 0 Then
'cuando es la clasificacion de llantas
Dim FaltaObservacion As Integer = TmpDT.FiltroPrimeroValor("CveClasificacion", "CveClasificacion = 20342").ToEntero
If FaltaObservacion = 20342 Then
@@ -6913,8 +6913,7 @@ Partial Class Ventas
'ENVIAR POLIZA VIRTUAL
If ErrorList.Count = 0 Then
If UsuarioActual.Empresa.Funcionalidad(576) = "1" Then
Dim TipoPoliza As Integer = 1
GeneraPolizaVentaWS(ObjFactura, TipoPoliza)
GeneraPolizaVentaWS(ObjFactura)
End If
End If
@@ -9167,7 +9166,7 @@ Partial Class Ventas
CveVentaRelacion:=(If(factura.CveVentaRelacion.ToEntero > 0, factura.CveVentaRelacion, -1)), ImporteRelacion:=(If(factura.ImporteRelacion <> Nothing, factura.ImporteRelacion, -1)),
CveTipoAmortizacionAnticipo:=factura.CveTipoAmortizacionAnticipo, CveEmpresaCRM:=CveEmpresaCRM, EsInterno:=EsInterno, CveAcercamientoCRM:=CveAcercamientoCRM,
DiasCredito:=factura.DiasCredito, EsDiasCreditoFijo:=factura.EsDiasCreditoFijo, AnticipoEspecial:=If(TrAntEspecial.Visible, ChkAntEspecial.Checked, False),
Kilometraje:=TxtKilometraje.Text.todouble) Then
Kilometraje:=TxtKilometraje.Text.ToDouble) Then
ErrorList.Add("Ocurrió un error al Generar la Venta.<br />Revise su factura y cualquier detalle comuníquese a Soporte Técnico")
@@ -10773,7 +10772,7 @@ Partial Class Ventas
Exit For
End If
If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing") Then
If UsuarioActual.CveEmpresa.Contiene({72, 80, 119}) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ing") AndAlso Dr("EntregaDirecta").ToString.ToEntero < 1 Then
Existencia = ObjInventario.GetExistenciasPS(CveProducto, CveUnidad, UsuarioActual.CveEmpresa, CveAlmacen, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), CveSubProyecto:=DdlSubProyectoDatos.SelectedValue.ToEntero, CveVendedor:=DdlVendedor.SelectedValue.ToEntero, CveCliente:=If(UsuarioActual.Empresa.Funcionalidad(146) = "1", -1, CveCliente), ExcluyeAdelantado:=1, RestringirAlmacenes:=1, ExcluyeApartados:=1)
If Existencia < Cantidad Then
OcurrioError = True
@@ -15478,7 +15477,7 @@ Partial Class Ventas
If ConSalida AndAlso Not OcurrioError Then
If UsuarioActual.Empresa.Funcionalidad(573) = "1" Then
OcurrioError = GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura)
OcurrioError = Not GenerarMovimientoAlmacenVirtual(CveRemision, ObjInventario, ObjFactura)
End If
If Not OcurrioError Then
@@ -15803,7 +15802,7 @@ Partial Class Ventas
OcurrioError = True
End Try
Return OcurrioError
Return Not OcurrioError
End Function
Private Function SalidaAlmacenMateriales(ByRef ObjInventario As ClsInventarios, CveOS As Integer, ByRef ObjConta As ClsContabilidad, ConSalida As Boolean, ConceptoMovimiento As Integer) As Boolean
@@ -23937,23 +23936,22 @@ Partial Class Ventas
GvCodigosUnicos.DataBind()
End If
End Sub
Protected Sub GeneraPolizaVentaWS(ObjFactura As Modelos.Factura, TipoPoliza As Integer)
'TipoPoliza: 01 Venta, 02 Ajuste, 03 Garantía
Protected Sub GeneraPolizaVentaWS(ObjFactura As Modelos.Factura)
Try
For Each Row As GridViewRow In GvCodigosUnicos.Rows
If Row.RowType = DataControlRowType.DataRow Then
Dim obj As New Modelos.MPolizaVentaWS
'DATOS DEL CLIENTE
obj.customer_name = ObjFactura.Cliente.Nombre
obj.customer_last_name1 = "."
obj.customer_last_name1 = ""
obj.customer_last_name2 = ""
obj.customer_birthday = Nothing
obj.customer_phone = ObjFactura.Cliente.Telefono
obj.customer_email = ObjFactura.Cliente.Mail
obj.customer_gender = "03" 'OTRO GENERO
obj.customer_advertising = False
obj.customer_car_brand = "01"
obj.customer_car_model = "01"
obj.customer_car_brand = "00"
obj.customer_car_model = "00"
obj.customer_car_year = ObjFactura.Fecha.Year
'DATOS DE VENTA
@@ -23963,12 +23961,12 @@ Partial Class Ventas
obj.sale_type_service = "02" 'COMERCIAL
obj.sale_total = ObjFactura.Total
obj.sale_discount = ObjFactura.Descuento
obj.sale_id = ObjFactura.CveVenta.ToString
obj.sale_id = String.Format("{0}{1}{2}", ObjFactura.Serie, ObjFactura.Folio, ObjFactura.CveVenta)
'DATOS DEL PRODUCTO
obj.product_code = Row.DataKey("IdProductoPolizaVirtual").ToString()
obj.product_unique_code = Row.FCTextBox("TxtCodigoUnico").Text 'se indique el código único de la batería. (SERIE LOTE)
obj.product_sale_type = "0" & TipoPoliza 'VENTA
obj.product_sale_type = "01 " 'VENTA
Dim FechaUsado As DateTime = Row.DataKey("FechaAjuste").ToString().ToDateTime()