This commit is contained in:
2024-04-25 15:34:42 -07:00
3 changed files with 113 additions and 655 deletions

View File

@@ -240,576 +240,6 @@ Partial Class PopUpVerFactura
End If End If
End Sub End Sub
'temporal
Protected Sub ImprimeFormatoCartaPorteTimbrado(CveTimbre As Integer)
Dim resp As Modelos.MSubReportData = PreParaImpresionCartaPorte(CveTimbre)
If resp.DataSources.Count > 0 AndAlso resp.Parametros.Count > 0 Then
ImprimirPDF("Empresas/Grales/Formatos/CartaPorteTimbrado.rdlc", resp.DataSources, resp.Parametros, resp.SerieFolio)
End If
End Sub
Private Function PreParaImpresionCartaPorte(CveTimbre As Integer, Optional AplicaSubReporte As Boolean = False) As Modelos.MSubReportData
Dim retorno As New Modelos.MSubReportData
retorno.Nombre = "CartaPorte"
Try
If CveTimbre > 0 Then
Dim params As New List(Of ReportParameter)
'01 Autotransporte Federal
'02 Transporte Marítimo
'03 Transporte Aéreo
'04 Transporte Ferroviario
'05 Ducto
Dim HtTransporte As New Hashtable()
HtTransporte.Add("01", "Autotransporte Federal")
HtTransporte.Add("02", "Transporte Marítimo")
HtTransporte.Add("03", "Transporte Aéreo")
HtTransporte.Add("04", "Transporte Ferroviario")
HtTransporte.Add("05", "Ducto")
'EMISOR
Dim LugarExpedicion As String = ""
Dim ImgCBB As String = ""
Dim ImgCCP As String = ""
'COMPROBANTE
Dim SerieFolio As String = ""
Dim Telefono As String = ""
Dim SubTotal As Decimal = 0
Dim Descuentos As Decimal = 0
Dim Total As Decimal = 0
'DATOS DEL CLIENTE
Dim ClienteRFC As String = ""
Dim ClienteNombre As String = ""
Dim ClienteUsoCFDi As String = ""
'TRANSPORTE
Dim MedioTransporte As String = ""
Dim TransporteInternacional As String = ""
Dim PermisoSTCC As String = ""
Dim NumPermiso As String = ""
Dim AseguradoraRespCivil As String = ""
Dim NumPolizaSeguroRespCivil As String = ""
Dim NombreAseguradoraMedioAmbiente As String = ""
Dim NumPolizaSeguroMedioAmbiente As String = ""
Dim NombreAseguradoraCarga As String = ""
Dim NumPolizaSeguroCarga As String = ""
Dim RemolquePlaca1 As String = ""
Dim RemolquePlaca2 As String = ""
Dim RemolqueSubtimo1 As String = ""
Dim RemolqueSubtimo2 As String = ""
Dim PlacaVM As String = ""
Dim AnioModeloVM As String = ""
Dim PesoBrutoVehicular As String = ""
'TIMBRADO
Dim FolioFiscal As String = ""
Dim NoCertificadoSAT As String = ""
Dim CadenaOriginal As String = ""
Dim NoSerieCertificado As String = ""
Dim FechaCertificacion As DateTime = Nothing
Dim SelloCFDi As String = ""
Dim SelloSAT As String = ""
Dim TipoDocto As String = ""
Dim PermisoSCTR1 As String = ""
Dim PermisoSCTR2 As String = ""
Dim ConfATR1 As String = ""
Dim ConfATR2 As String = ""
Dim ObjInv As New ClsGenerales
If ObjInv.GetGralTimbre(CveTimbre, "-1", MinFecha, MaxFecha, -1, UsuarioActual.CveEmpresa, -1) Then
If ObjInv.DtResultados.Rows.Count > 0 Then
Dim Dr As DataRow = ObjInv.DtResultados.Rows(0)
If Dr IsNot Nothing Then
SerieFolio = Dr("SerieFolio").ToString
Telefono = Dr("FiguraTelefono").ToString
TipoDocto = Dr("TipoDocto").ToString
If UsuarioActual.CveEmpresa = 13 Then
PermisoSCTR1 = Dr("PermisoSCTR1").ToString
PermisoSCTR2 = Dr("PermisoSCTR2").ToString
ConfATR1 = Dr("ConfATR1").ToString
ConfATR2 = Dr("ConfATR2").ToString
End If
End If
End If
End If
ObjInv.Dispose()
retorno.SerieFolio = SerieFolio
Dim DtConceptos As New DataTable()
DtConceptos.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
DtConceptos.Columns.Add(New DataColumn("Unidad", GetType(String)))
DtConceptos.Columns.Add(New DataColumn("Descripcion", GetType(String)))
DtConceptos.Columns.Add(New DataColumn("ValorUnitario", GetType(Decimal)))
DtConceptos.Columns.Add(New DataColumn("Importe", GetType(Decimal)))
Dim DtUbicaciones As New DataTable()
DtUbicaciones.Columns.Add(New DataColumn("Distancia", GetType(String)))
DtUbicaciones.Columns.Add(New DataColumn("TipoUbicacion", GetType(String)))
DtUbicaciones.Columns.Add(New DataColumn("RFC", GetType(String)))
DtUbicaciones.Columns.Add(New DataColumn("Nombre", GetType(String)))
DtUbicaciones.Columns.Add(New DataColumn("FechaHoraSalida", GetType(DateTime)))
DtUbicaciones.Columns.Add(New DataColumn("Direccion", GetType(String)))
Dim DtMercancias As New DataTable()
DtMercancias.Columns.Add(New DataColumn("Cantidad", GetType(Decimal)))
DtMercancias.Columns.Add(New DataColumn("UnidadMedida", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("Descripcion", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("PesoEnKg", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("CveMaterialPeligroso", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("Embalaje", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("SectorCOFEPRIS", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("NombreIngredienteActivo", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("NomQuimico", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("DenominacionGenerica", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("DenominacionDistintiva", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("Fabricante", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("FormaFarmaceutica", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("CondicionesTransporte", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("RegistroSanitarioAutorizacion", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("PermisoImportacion", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("FolioImportacionVUCEM", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("NumCAS", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("RazonSocialEmpImportacion", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("NumRegistroPlagCOFEPRIS", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("DatosFabricante", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("DatosFormulador", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("DatosMaquilador", GetType(String)))
DtMercancias.Columns.Add(New DataColumn("UsoAutorizado", GetType(String)))
Dim DtOperadores As New DataTable()
DtOperadores.Columns.Add(New DataColumn("RFC", GetType(String)))
DtOperadores.Columns.Add(New DataColumn("NumLicencia", GetType(String)))
DtOperadores.Columns.Add(New DataColumn("NombreOperador", GetType(String)))
Dim DTRelacionados As New DataTable()
DTRelacionados.Columns.Add(New DataColumn("Relacion", GetType(String)))
DTRelacionados.Columns.Add(New DataColumn("UUID", GetType(String)))
Dim XMLDoc As New XmlDocument
Dim Path As String = String.Format("{0}\{1}\{2}\{3}.{4}", UsuarioActual.Empresa.Ruta, "XML", TipoDocto, String.Format("{0}", SerieFolio), "xml")
Dim Archivo As New System.IO.FileInfo(Path)
If Archivo.Exists Then
Try
XMLDoc.Load(Path)
Catch ex As Exception
Try
Dim oReader As New StreamReader(Path, Encoding.GetEncoding("ISO-8859-1"))
XMLDoc.Load(oReader)
oReader.Dispose()
Catch ex2 As Exception
GuardaLog("Error al intentar leer el XML del SAT. Error:" & ex2.ToString())
End Try
End Try
End If
If XMLDoc IsNot Nothing AndAlso Archivo.Exists Then
Dim RutaCBB As String = String.Format("{0}\CBB\{1}.jpg", UsuarioActual.Empresa.Ruta, SerieFolio)
Dim ImagenCBB As New System.IO.FileInfo(RutaCBB)
Dim RutaCCP As String = String.Format("{0}\CBB\{1}_CCP.jpg", UsuarioActual.Empresa.Ruta, SerieFolio)
Dim ImagenCCP As New System.IO.FileInfo(RutaCCP)
Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix)
Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3"
Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable)
Dim Version As String = ValorXML(XMLDoc.DocumentElement, "version")
Dim VersionCCP As String = ""
Dim PrefijoCCP As String = ""
If Version = "3.3" Then
cfdVer = "http://www.sat.gob.mx/cfd/3"
Else ' se considera que es la version 4.0
cfdVer = "http://www.sat.gob.mx/cfd/4"
End If
params.Add(New ReportParameter("CFDIVersion", Version))
namespaces.AddNamespace(Prefijo, cfdVer)
namespaces.AddNamespace("tfd", "http://www.sat.gob.mx/TimbreFiscalDigital")
namespaces.AddNamespace("implocal", "http://www.sat.gob.mx/implocal")
namespaces.AddNamespace("registrofiscal", "http://www.sat.gob.mx/registrofiscal")
namespaces.AddNamespace("cartaporte", "http://www.sat.gob.mx/CartaPorte")
namespaces.AddNamespace("cartaporte20", "http://www.sat.gob.mx/CartaPorte20")
namespaces.AddNamespace("cartaporte30", "http://www.sat.gob.mx/CartaPorte30")
Dim Nodos30 As XmlNode = XMLDoc.SelectSingleNode("//cartaporte30:CartaPorte", namespaces)
Dim Nodos20 As XmlNode = XMLDoc.SelectSingleNode("//cartaporte20:CartaPorte", namespaces)
If Nodos30 IsNot Nothing Then
VersionCCP = "3.0"
PrefijoCCP = "cartaporte30"
End If
If Nodos20 IsNot Nothing Then
VersionCCP = "2.0"
PrefijoCCP = "cartaporte20"
End If
params.Add(New ReportParameter("CartaPorteVersion", VersionCCP))
Dim nodeComprobante As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Comprobante", Prefijo), namespaces)
If nodeComprobante IsNot Nothing Then
LugarExpedicion = ValorXML(nodeComprobante, "LugarExpedicion")
SubTotal = ValorXML(nodeComprobante, "SubTotal").ToDecimal()
Total = ValorXML(nodeComprobante, "Total").ToDecimal()
End If
Dim nodeCliente As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Receptor", Prefijo), namespaces)
If nodeCliente IsNot Nothing Then
ClienteRFC = ValorXML(nodeCliente, "RFC")
ClienteNombre = ValorXML(nodeCliente, "Nombre")
Dim UsoCFDI As String = ValorXML(nodeCliente, "UsoCFDI")
ClienteUsoCFDi = String.Format("{0} - {1}", UsoCFDI, GlobalDTSATUsosCFDI().FiltroPrimeroValor("Descripcion", String.Format("UsoCFDI = '{0}'", UsoCFDI)))
End If
Dim nodeConceptos As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Conceptos", Prefijo), namespaces)
If nodeConceptos IsNot Nothing Then
For Each node As XmlNode In nodeConceptos.ChildNodes
Dim Row As DataRow = DtConceptos.NewRow
Row("Cantidad") = ValorXML(node, "Cantidad", "")
Row("Unidad") = ValorXML(node, "Unidad", "")
Row("Descripcion") = ValorXML(node, "Descripcion", "")
Row("ValorUnitario") = ValorXML(node, "ValorUnitario", "")
Row("Importe") = ValorXML(node, "Importe", "")
DtConceptos.Rows.Add(Row)
Next
End If
Dim nodeComp As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Comprobante/{0}:Complemento", Prefijo), namespaces)
Dim nodeCartaPorte As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:CartaPorte", PrefijoCCP), namespaces)
If nodeCartaPorte IsNot Nothing Then
TransporteInternacional = ValorXML(nodeCartaPorte, "TranspInternac", "")
Dim CveTransporte As String = ValorXML(nodeCartaPorte, "ViaEntradaSalida", "")
'Dim nodeFiguraTransporte As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:FiguraTransporte", "cartaporte20"), namespaces)
If CveTransporte <> "" Then MedioTransporte = String.Format("{0} - {1}", CveTransporte, HtTransporte(CveTransporte).ToString())
End If
Dim nodeAutotransporteFederal As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Autotransporte", PrefijoCCP), namespaces)
If nodeAutotransporteFederal IsNot Nothing Then
PermisoSTCC = ValorXML(nodeAutotransporteFederal, "PermSCT", "")
NumPermiso = ValorXML(nodeAutotransporteFederal, "NumPermisoSCT", "")
End If
Dim nodeIdentificacionVehicular As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:IdentificacionVehicular", PrefijoCCP), namespaces)
If nodeIdentificacionVehicular IsNot Nothing Then
PlacaVM = ValorXML(nodeIdentificacionVehicular, "PlacaVM", "")
AnioModeloVM = ValorXML(nodeIdentificacionVehicular, "AnioModeloVM", "")
PesoBrutoVehicular = ValorXML(nodeIdentificacionVehicular, "PesoBrutoVehicular", "")
End If
Dim nodeSeguros As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Seguros", PrefijoCCP), namespaces)
If nodeIdentificacionVehicular IsNot Nothing Then
AseguradoraRespCivil = ValorXML(nodeSeguros, "AseguraRespCivil", "")
NumPolizaSeguroRespCivil = ValorXML(nodeSeguros, "PolizaRespCivil", "")
'Por Definir de donde sale
NombreAseguradoraMedioAmbiente = ValorXML(nodeSeguros, "AseguraMedAmbiente", "")
NumPolizaSeguroMedioAmbiente = ValorXML(nodeSeguros, "PolizaMedAmbiente", "")
NombreAseguradoraCarga = ValorXML(nodeSeguros, "AseguraCarga", "")
NumPolizaSeguroCarga = ValorXML(nodeSeguros, "PolizaCarga", "")
End If
Dim nodeRemolques As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:Remolques", PrefijoCCP), namespaces)
If nodeRemolques IsNot Nothing Then
If nodeRemolques.ChildNodes.Count = 1 Then
RemolquePlaca1 = ValorXML(nodeRemolques.ChildNodes(0), "Placa", "")
RemolqueSubtimo1 = ValorXML(nodeRemolques.ChildNodes(0), "SubTipoRem", "")
ElseIf nodeRemolques.ChildNodes.Count > 1 Then
RemolquePlaca1 = ValorXML(nodeRemolques.ChildNodes(0), "Placa", "")
RemolqueSubtimo1 = ValorXML(nodeRemolques.ChildNodes(0), "SubTipoRem", "")
RemolquePlaca2 = ValorXML(nodeRemolques.ChildNodes(1), "Placa", "")
RemolqueSubtimo2 = ValorXML(nodeRemolques.ChildNodes(1), "SubTipoRem", "")
End If
End If
Dim nodeMercancias As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Mercancia", PrefijoCCP), namespaces)
For Each node As XmlNode In nodeMercancias
Dim Row As DataRow = DtMercancias.NewRow
Row("Cantidad") = ValorXML(node, "Cantidad", "")
Row("UnidadMedida") = ValorXML(node, "Unidad", "")
Row("Descripcion") = ValorXML(node, "Descripcion", "")
Row("PesoEnKg") = ValorXML(node, "PesoEnKg", "")
Row("CveMaterialPeligroso") = ValorXML(node, "CveMaterialPeligroso", "")
Row("Embalaje") = ValorXML(node, "Embalaje", "")
Row("SectorCOFEPRIS") = ValorXML(node, "SectorCOFEPRIS", "")
Row("NombreIngredienteActivo") = ValorXML(node, "NombreIngredienteActivo", "")
Row("NomQuimico") = ValorXML(node, "NomQuimico", "")
Row("DenominacionGenerica") = ValorXML(node, "DenominacionGenerica", "")
Row("DenominacionDistintiva") = ValorXML(node, "DenominacionDistintiva", "")
Row("Fabricante") = ValorXML(node, "Fabricante", "")
Row("FormaFarmaceutica") = ValorXML(node, "FormaFarmaceutica", "")
Row("CondicionesTransporte") = ValorXML(node, "CondicionesTransporte", "")
Row("RegistroSanitarioAutorizacion") = ValorXML(node, "RegistroSanitarioAutorizacion", "")
Row("PermisoImportacion") = ValorXML(node, "PermisoImportacion", "")
Row("FolioImportacionVUCEM") = ValorXML(node, "FolioImportacionVUCEM", "")
Row("NumCAS") = ValorXML(node, "NumCAS", "")
Row("RazonSocialEmpImportacion") = ValorXML(node, "RazonSocialEmpImportacion", "")
Row("NumRegistroPlagCOFEPRIS") = ValorXML(node, "NumRegistroPlagCOFEPRIS", "")
Row("DatosFabricante") = ValorXML(node, "DatosFabricante", "")
Row("DatosFormulador") = ValorXML(node, "DatosFormulador", "")
Row("DatosMaquilador") = ValorXML(node, "DatosMaquilador", "")
Row("UsoAutorizado") = ValorXML(node, "UsoAutorizado", "")
DtMercancias.Rows.Add(Row)
Next
Dim nodeMercanciaPadre As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Mercancias", PrefijoCCP), namespaces)
If UsuarioActual.CveEmpresa = 13 AndAlso nodeMercanciaPadre IsNot Nothing Then
Dim PesoNetoTotal As String = ValorXML(nodeMercanciaPadre(0), "PesoNetoTotal", "")
Dim UnidadPeso As String = ValorXML(nodeMercanciaPadre(0), "UnidadPeso", "")
Dim NumTotalMercancias As String = ValorXML(nodeMercanciaPadre(0), "NumTotalMercancias", "")
params.Add(New ReportParameter("PesoNetoTotal", PesoNetoTotal))
params.Add(New ReportParameter("UnidadPeso", UnidadPeso))
params.Add(New ReportParameter("NumTotalMercancias", NumTotalMercancias))
End If
Dim nodeOperadores As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:TiposFigura", PrefijoCCP), namespaces)
For Each node As XmlNode In nodeOperadores
Dim Row As DataRow = DtOperadores.NewRow
Row("RFC") = ValorXML(node, "RFCFigura", "")
Row("NumLicencia") = ValorXML(node, "NumLicencia", "")
Row("NombreOperador") = ValorXML(node, "NombreFigura", "")
DtOperadores.Rows.Add(Row)
Next
Dim DistanciaTotal As Decimal = 0
Dim nodeUbicaciones As XmlNodeList = nodeComp.SelectNodes(String.Format("//{0}:Ubicacion", PrefijoCCP), namespaces)
For Each node As XmlNode In nodeUbicaciones
Dim Row As DataRow = DtUbicaciones.NewRow
Row("Distancia") = ValorXML(node, "DistanciaRecorrida", "")
DistanciaTotal += Row("Distancia").ToString().ToDecimal()
Row("TipoUbicacion") = ValorXML(node, "TipoUbicacion", "")
Row("FechaHoraSalida") = ValorXML(node, "FechaHoraSalidaLlegada", "")
Row("RFC") = ValorXML(node, "RFCRemitenteDestinatario", "")
Row("Nombre") = ValorXML(node, "NombreRemitenteDestinatario", "")
Dim nodeDomicilio As XmlNode = node.ChildNodes.Cast(Of XmlNode).FirstOrDefault(Function(x) x.Name = $"{PrefijoCCP}:Domicilio") 'node.SelectSingleNode(String.Format("//{0}:Domicilio", "cartaporte"), namespaces)
If nodeDomicilio IsNot Nothing Then
Dim Estado As String = ""
Dim Municipio As String = ""
Dim Colonia As String = ""
Dim calle As String = ValorXML(nodeDomicilio, "Calle", "")
Dim CP As String = ValorXML(nodeDomicilio, "CodigoPostal", "")
Dim dr As DataRow = GlobalDTGralColonias(ValorXML(nodeDomicilio, "Estado", ""), ValorXML(nodeDomicilio, "Municipio", ""), ValorXML(nodeDomicilio, "Colonia", "")).FiltroPrimero("")
If dr IsNot Nothing Then
Estado = dr("NombreEstado").ToString
Municipio = dr("NombreMunicipio").ToString
Colonia = dr("NombreAsentamiento").ToString
End If
Row("Direccion") = String.Format("{0} Col.{1},{2},{3}. CP {4}", calle, Colonia, Municipio, Estado, CP)
End If
DtUbicaciones.Rows.Add(Row)
Next
If UsuarioActual.CveEmpresa = 13 Then
params.Add(New ReportParameter("DistanciaTotal", DistanciaTotal.ToString()))
End If
Dim nodeRelacion As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces)
If nodeRelacion IsNot Nothing Then
Dim RelacionCodigo As String = ValorXML(nodeRelacion, "TipoRelacion")
Dim Relacion As String = ""
Select Case RelacionCodigo
Case "01"
Relacion = "01 - Nota de crédito de los documentos relacionados"
Case "02"
Relacion = "02 - Nota de débito de los documentos relacionados"
Case "03"
Relacion = "03 - Devolución de mercancía sobre facturas o traslados previos"
Case "04"
Relacion = "04 - Sustitución de los CFDI previos"
Case "05"
Relacion = "05 - Traslados de mercancias facturados previamente"
Case "06"
Relacion = "06 - Factura generada por los traslados previos"
Case "07"
Relacion = "07 - CFDI por aplicación de anticipo"
Case "08"
Relacion = "08 - Factura generada por pagos en parcialidades"
Case "09"
Relacion = "09 - Factura generada por pagos diferidos"
End Select
Dim nodoDocumentosRelacionados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:CfdiRelacionados", Prefijo), namespaces)
For Each node As XmlNode In nodoDocumentosRelacionados
Dim nRow As DataRow = DTRelacionados.NewRow
nRow("Relacion") = Relacion
Try
Dim nodoUUID As XmlNode = node.ChildNodes.Cast(Of XmlNode).FirstOrDefault(Function(x) x.Name = "cfdi:CfdiRelacionado")
nRow("UUID") = ValorXML(nodoUUID, "UUID", "")
Catch ex As Exception
nRow("UUID") = ""
End Try
DTRelacionados.Rows.Add(nRow)
Next
End If
Dim nodeTFD As XmlNode = nodeComp.SelectSingleNode(String.Format("//{0}:TimbreFiscalDigital", "tfd"), namespaces)
If nodeTFD IsNot Nothing Then
FolioFiscal = ValorXML(nodeTFD, "UUID", "")
NoSerieCertificado = ValorXML(nodeTFD, "NoCertificadoSAT", "")
FechaCertificacion = ValorXML(nodeTFD, "FechaTimbrado", "").ToDateTime
SelloCFDi = ValorXML(nodeTFD, "SelloCFD", "")
SelloSAT = ValorXML(nodeTFD, "SelloSAT", "")
NoCertificadoSAT = ValorXML(nodeTFD, "NoCertificadoSAT", "")
CadenaOriginal = "||1.0|" + FolioFiscal + "|" + FechaCertificacion.ToString("yyyy-MM-dd") + "T" + FechaCertificacion.ToString("HH:mm:ss") + "|" + SelloCFDi + "|" + NoSerieCertificado + "||"
End If
If Not ImagenCBB.Exists Then GeneraQRSAT(UsuarioActual.Empresa.RFC, ClienteRFC, Total, FolioFiscal, RutaGuardado:=RutaCBB)
ImagenCBB = New System.IO.FileInfo(RutaCBB)
If ImagenCBB.Exists Then
ImgCBB = String.Format("file://{0}", ImagenCBB.FullName)
Else
ImgCBB = ""
End If
ImagenCCP = New System.IO.FileInfo(RutaCCP)
If ImagenCCP.Exists Then
ImgCCP = String.Format("file://{0}", ImagenCCP.FullName)
Else
ImgCCP = ""
End If
End If
If DtConceptos.Rows.Count > 0 Then
params.Add(New ReportParameter("LogoPath", RutaImagenLogo))
'EMPRESA
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("RegimenFiscal", UsuarioActual.Empresa.Regimen))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString))
params.Add(New ReportParameter("DomicilioFiscal", $"{UsuarioActual.Empresa.Direccion}, {UsuarioActual.Empresa.Colonia}, {UsuarioActual.Empresa.Localidad}, {UsuarioActual.Empresa.Estado}, Tel. {Telefono}"))
params.Add(New ReportParameter("SerieFolio", SerieFolio))
params.Add(New ReportParameter("RFC", UsuarioActual.Empresa.RFC))
params.Add(New ReportParameter("DomicilioExpedicion", LugarExpedicion))
'CLIENTE
params.Add(New ReportParameter("ClienteNombre", ClienteNombre))
params.Add(New ReportParameter("ClienteRFC", ClienteRFC))
params.Add(New ReportParameter("UsoCFDi", ClienteUsoCFDi))
'TRANSPORTE
params.Add(New ReportParameter("MedioTransporte", MedioTransporte))
params.Add(New ReportParameter("TransporteInternacional", TransporteInternacional))
params.Add(New ReportParameter("PermisoSTCC", PermisoSTCC))
params.Add(New ReportParameter("NumPermiso", NumPermiso))
params.Add(New ReportParameter("Aseguradora", AseguradoraRespCivil))
params.Add(New ReportParameter("NumPoliza", NumPolizaSeguroRespCivil))
params.Add(New ReportParameter("NombreAseguradoraMedioAmbiente", NombreAseguradoraMedioAmbiente))
params.Add(New ReportParameter("NumPolizaSeguroMedioAmbiente", NumPolizaSeguroMedioAmbiente))
params.Add(New ReportParameter("NombreAseguradoraCarga", NombreAseguradoraCarga))
params.Add(New ReportParameter("NumPolizaSeguroCarga", NumPolizaSeguroCarga))
params.Add(New ReportParameter("PlacaVM", PlacaVM))
params.Add(New ReportParameter("AnioVM", AnioModeloVM))
params.Add(New ReportParameter("PesoBrutoVehicular", PesoBrutoVehicular))
'TIMBRADO
params.Add(New ReportParameter("FolioFiscal", FolioFiscal))
params.Add(New ReportParameter("QR", ImgCBB))
params.Add(New ReportParameter("QRCCP", ImgCCP))
params.Add(New ReportParameter("SelloCFDI", SelloCFDi))
params.Add(New ReportParameter("CertificadoContribuyente", NoCertificadoSAT))
params.Add(New ReportParameter("CadenaOriginal", CadenaOriginal))
params.Add(New ReportParameter("SerieCertificadoSAT", NoSerieCertificado))
params.Add(New ReportParameter("FechaCertificacion", FechaCertificacion.ToString("dd/MM/yyyy HH:mm:ss")))
params.Add(New ReportParameter("SelloSAT", SelloSAT))
'TOTALES
params.Add(New ReportParameter("SubTotal", SubTotal.ToString()))
params.Add(New ReportParameter("Descuentos", Descuentos.ToString()))
params.Add(New ReportParameter("Total", Total.ToString()))
params.Add(New ReportParameter("RemolquePlaca1", RemolquePlaca1))
params.Add(New ReportParameter("RemolqueSubtimo1", RemolqueSubtimo1))
params.Add(New ReportParameter("RemolquePlaca2", RemolquePlaca2))
params.Add(New ReportParameter("RemolqueSubtimo2", RemolqueSubtimo2))
If UsuarioActual.CveEmpresa = 13 Then
params.Add(New ReportParameter("PermisoSCTRemolque1", PermisoSCTR1))
params.Add(New ReportParameter("PermisoSCTRemolque2", PermisoSCTR2))
params.Add(New ReportParameter("ConfATR1", ConfATR1))
params.Add(New ReportParameter("ConfATR2", ConfATR2))
End If
Dim lrds As New List(Of ReportDataSource)
Dim rds As New ReportDataSource
rds.Name = "DataSet1"
rds.Value = DtConceptos
lrds.Add(rds)
Dim rds2 As New ReportDataSource
rds2.Name = "DataSet2"
rds2.Value = DtUbicaciones
lrds.Add(rds2)
Dim rds3 As New ReportDataSource
rds3.Name = "DataSet3"
rds3.Value = DtMercancias
lrds.Add(rds3)
Dim rds4 As New ReportDataSource
rds4.Name = "DataSet4"
rds4.Value = DtOperadores
lrds.Add(rds4)
Dim rds5 As New ReportDataSource
rds5.Name = "DataSet5"
rds5.Value = DTRelacionados
lrds.Add(rds5)
If AplicaSubReporte Then
For Each parametro As ReportParameter In params
retorno.Parametros.Add(New ReportParameter($"SRP_{parametro.Name}", parametro.Values.Item(0)))
Next
retorno.Parametros.Add(New ReportParameter($"TieneCartaPorte", "True"))
Else
retorno.Parametros.AddRange(params)
End If
retorno.DataSources.AddRange(lrds)
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al generar el pdf de la carta porte", ex)
End Try
Return retorno
End Function
Private Sub DescargaArchivoDirecto(RutaArchivo As String) Private Sub DescargaArchivoDirecto(RutaArchivo As String)
If RutaArchivo <> "" Then If RutaArchivo <> "" Then
@@ -1088,7 +518,6 @@ Partial Class PopUpVerFactura
params.Add(New ReportParameter("CAAT", CAAT)) params.Add(New ReportParameter("CAAT", CAAT))
params.Add(New ReportParameter("NumeroTrailer", NumeroTrailer)) params.Add(New ReportParameter("NumeroTrailer", NumeroTrailer))
params.Add(New ReportParameter("NoFactura", NoFactura)) params.Add(New ReportParameter("NoFactura", NoFactura))
params.Add(New ReportParameter("Mercado", Mercado)) params.Add(New ReportParameter("Mercado", Mercado))
params.Add(New ReportParameter("NoBultos", NoBultos)) params.Add(New ReportParameter("NoBultos", NoBultos))
@@ -1096,11 +525,6 @@ Partial Class PopUpVerFactura
params.Add(New ReportParameter("NoKgManifiesto", NoKgManifiesto)) params.Add(New ReportParameter("NoKgManifiesto", NoKgManifiesto))
Dim lrds As New List(Of ReportDataSource) Dim lrds As New List(Of ReportDataSource)
Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = tablaReporte} Dim rds As New ReportDataSource With {.Name = "DataSet1", .Value = tablaReporte}
lrds.Add(rds) lrds.Add(rds)
@@ -1164,15 +588,15 @@ Partial Class PopUpVerFactura
NoEmbarque = row("NoEmbarque").ToString() NoEmbarque = row("NoEmbarque").ToString()
Cliente = row("Cliente").ToString() Cliente = row("Cliente").ToString()
Direccion = row("Direccion").ToString() Direccion = row("Direccion").ToString()
Fecha = String.Format("{0dd/MM/yyyy}", row("Fecha")) Fecha = String.Format("{0:dd/MM/yyyy}", row("Fecha"))
DivisoresdeCarton = String.Format("{0N0}", row("DivisoresdeCarton")) DivisoresdeCarton = String.Format("{0:N0}", row("DivisoresdeCarton"))
BolsasdePlastico = String.Format("{0N0}", row("BolsasdePlastico")) BolsasdePlastico = String.Format("{0:N0}", row("BolsasdePlastico"))
TapaderasdeCarton = String.Format("{0N0}", row("TapaderasdeCarton")) TapaderasdeCarton = String.Format("{0:N0}", row("TapaderasdeCarton"))
CAJASDECARTON = String.Format("{0N0}", row("CAJASDECARTON")) CAJASDECARTON = String.Format("{0:N0}", row("CAJASDECARTON"))
RPC = String.Format("{0N0}", row("RPC")) RPC = String.Format("{0:N0}", row("RPC"))
BINSDECARTON = String.Format("{0N0}", row("BINSDECARTON")) BINSDECARTON = String.Format("{0:N0}", row("BINSDECARTON"))
BinsPrecio = String.Format("{0N0}", row("BINSDECARTON").ToString().ToDecimal() * 5) BinsPrecio = String.Format("{0:N0}", row("BINSDECARTON").ToString().ToDecimal() * 5)
TotalDlls = String.Format("{0N0}", row("TotalDlls")) TotalDlls = String.Format("{0:N0}", row("TotalDlls"))
@@ -1180,7 +604,7 @@ Partial Class PopUpVerFactura
AgenciaAduanalUSA = row("AgenciaAduanalUSA").ToString() AgenciaAduanalUSA = row("AgenciaAduanalUSA").ToString()
AgenciaAduanalMEX = row("AgenciaAduanalMEX").ToString() AgenciaAduanalMEX = row("AgenciaAduanalMEX").ToString()
Temperatura = row("Temperatura").ToString() Temperatura = row("Temperatura").ToString()
Hora = String.Format("{0hh }:{0:mm }:{0:ss tt}:", row("FechaIng")) Hora = String.Format("{0:hh }:{0:mm }:{0:ss tt}:", row("FechaIng"))
Chofer = row("Chofer").ToString() Chofer = row("Chofer").ToString()
CamPlaca = row("CamPlaca").ToString() CamPlaca = row("CamPlaca").ToString()
Camion = String.Format("{0} {1}", row("CamEspecificacion"), row("CamAnio")) Camion = String.Format("{0} {1}", row("CamEspecificacion"), row("CamAnio"))
@@ -1320,13 +744,13 @@ Partial Class PopUpVerFactura
Direccion = row("Direccion").ToString() Direccion = row("Direccion").ToString()
Correo = row("Correo").ToString() Correo = row("Correo").ToString()
Fecha = String.Format("{0dd/MM/yyyy}", row("Fecha")) Fecha = String.Format("{0dd/MM/yyyy}", row("Fecha"))
DivisoresdeCarton = String.Format("{0N0}", row("DivisoresdeCarton")) DivisoresdeCarton = String.Format("{0:N0}", row("DivisoresdeCarton"))
BolsasdePlastico = String.Format("{0N0}", row("BolsasdePlastico")) BolsasdePlastico = String.Format("{0:N0}", row("BolsasdePlastico"))
TapaderasdeCarton = String.Format("{0N0}", row("TapaderasdeCarton")) TapaderasdeCarton = String.Format("{0:N0}", row("TapaderasdeCarton"))
CAJASDECARTON = String.Format("{0N0}", row("CAJASDECARTON")) CAJASDECARTON = String.Format("{0:N0}", row("CAJASDECARTON"))
RPC = String.Format("{0N0}", row("RPC")) RPC = String.Format("{0:N0}", row("RPC"))
BINSDECARTON = String.Format("{0N0}", row("BINSDECARTON")) BINSDECARTON = String.Format("{0:N0}", row("BINSDECARTON"))
TotalDlls = String.Format("{0N0}", row("TotalDlls")) TotalDlls = String.Format("{0:N0}", row("TotalDlls"))
@@ -1456,7 +880,7 @@ Partial Class PopUpVerFactura
Cultivo = row("Cultivo").ToString() Cultivo = row("Cultivo").ToString()
noPallet = row("Codigo").ToString() noPallet = row("Codigo").ToString()
Variedad = row("CultivoVariedad").ToString() Variedad = row("CultivoVariedad").ToString()
NoCajas = String.Format("{0N0}", row("NoCajas")) NoCajas = String.Format("{0:N0}", row("NoCajas"))
End If End If
@@ -1537,7 +961,7 @@ Partial Class PopUpVerFactura
NoCajas = row("NoCajas").ToString() NoCajas = row("NoCajas").ToString()
Fecha = String.Format("{0:MMM dd}", row("Fecha")).Replace(".", "").ToUpper() Fecha = String.Format("{0:MMM dd}", row("Fecha")).Replace(".", "").ToUpper()
CvetypeImpresion = row("CvetypeImpresion").ToString().ToEntero() CvetypeImpresion = row("CvetypeImpresion").ToString().ToEntero()
NumberOfCode = String.Format("(00)00000000000000(00){1ddMMyy}(00){0}00", Right(String.Format("0{0}", Regex.Match(row("Cuadro").ToString(), "\d+")), 2), row("Fecha")) NumberOfCode = String.Format("(00)00000000000000(00){1:ddMMyy}(00){0}00", Right(String.Format("0{0}", Regex.Match(row("Cuadro").ToString(), "\d+")), 2), row("Fecha"))
'NumberSmall = String.Format("{000}", noPallet.ToEntero()) 'NumberSmall = String.Format("{000}", noPallet.ToEntero())
'NumberBig = String.Format("{000}", row("Consecutivo").ToString().ToEntero()) ' String.Format("{0:dd}", row("Fecha")) 'NumberBig = String.Format("{000}", row("Consecutivo").ToString().ToEntero()) ' String.Format("{0:dd}", row("Fecha"))
@@ -1662,7 +1086,7 @@ Partial Class PopUpVerFactura
NoCajas = row("NoCajas").ToString() NoCajas = row("NoCajas").ToString()
Fecha = String.Format("{0:MMM dd}", row("Fecha")).Replace(".", "").ToUpper() Fecha = String.Format("{0:MMM dd}", row("Fecha")).Replace(".", "").ToUpper()
CvetypeImpresion = row("CvetypeImpresion").ToString().ToEntero() CvetypeImpresion = row("CvetypeImpresion").ToString().ToEntero()
NumberOfCode = String.Format("(00)00000000000000(00){1ddMMyy}(00){0}00", Right(String.Format("0{0}", Regex.Match(row("Cuadro").ToString(), "\d+")), 2), row("Fecha")) NumberOfCode = String.Format("(00)00000000000000(00){1:ddMMyy}(00){0}00", Right(String.Format("0{0}", Regex.Match(row("Cuadro").ToString(), "\d+")), 2), row("Fecha"))
NumberSmall = String.Format("{000}", noPallet.ToEntero()) NumberSmall = String.Format("{000}", noPallet.ToEntero())
NumberBig = String.Format("{000}", row("Consecutivo").ToString().ToEntero()) ' String.Format("{0:dd}", row("Fecha")) NumberBig = String.Format("{000}", row("Consecutivo").ToString().ToEntero()) ' String.Format("{0:dd}", row("Fecha"))
End If End If

View File

@@ -2991,19 +2991,14 @@ Partial Class OS_OrdenesServicios
Select Case DdlTipoVenta.SelectedValue.ToEntero Select Case DdlTipoVenta.SelectedValue.ToEntero
Case 1, 2 ' *Fuera de liena *pago directo Case 1, 2 ' *Fuera de liena *pago directo
Opcion = 1 Opcion = 1
Exit Select
Case 3 ' por el momento ya no se usa Case 3 ' por el momento ya no se usa
Opcion = 2 Opcion = 2
Exit Select
Case 5 ' consignacion uso Case 5 ' consignacion uso
Opcion = 3 Opcion = 3
Exit Select
Case 6 ' a vista uso de material Case 6 ' a vista uso de material
Opcion = 4 Opcion = 4
Exit Select
Case Else Case Else
Opcion = 1 Opcion = 1
Exit Select
End Select End Select
Dim ObjOS As New ClsOS Dim ObjOS As New ClsOS
@@ -3080,7 +3075,7 @@ Partial Class OS_OrdenesServicios
TotalSeleccionado = TotalSeleccionado + GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal TotalSeleccionado = TotalSeleccionado + GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal
Next Next
If TotalSeleccionado = 0 Then If TotalSeleccionado = 0 Then
Alert("No se selecciono ningun material", TipoMensaje.MsgAdvertencia) Alert("No se seleccionó ningun material", TipoMensaje.MsgAdvertencia)
Exit Sub Exit Sub
End If End If
Else Else
@@ -3096,38 +3091,45 @@ Partial Class OS_OrdenesServicios
Dim ObjOS As New ClsOS(ObjV.IniciaTransacSQL()) Dim ObjOS As New ClsOS(ObjV.IniciaTransacSQL())
Dim ObjInventario As New ClsInventarios(ObjV.IniciaTransacSQL()) Dim ObjInventario As New ClsInventarios(ObjV.IniciaTransacSQL())
Dim ObjConta As New ClsContabilidad(ObjV.IniciaTransacSQL()) Dim ObjConta As New ClsContabilidad(ObjV.IniciaTransacSQL())
Dim GenrarRemisionMovimientos As Boolean = False Dim GenerarRemisionMovimientos As Boolean = False
If DdlTipoVenta.SelectedValue.ToEntero = 5 Then If DdlTipoVenta.SelectedValue = "5" Then 'Consignación - Uso Material
'genera una salida de almacen.
Dim CveMovimientoSalida As Integer = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, ClsPaginas.NowADS(), -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="OS/MatUtilConsig")
Dim Folio As Integer = ObjInventario.Folio
For Each GVRow As GridViewRow In GvMU.Rows If CveMovimientoSalida > 0 Then
Dim CantidadRegistro As Decimal = GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal For Each GVRow As GridViewRow In GvMU.Rows
Dim CvePS As Integer = GVRow.DataKey("CvePS").ToEntero Dim CantidadRegistro As Decimal = GVRow.FCTextBox("TxtUtilizado").Text.ToDecimal
Dim CvePS As Integer = GVRow.DataKey("CvePS").ToEntero
If CantidadRegistro > 0 Then If CantidadRegistro > 0 Then
Dim Serie As String = If(GVRow.DataKey("Serie") = "", "-1", GVRow.DataKey("Serie")) Dim Serie As String = GVRow.DataKey("Serie")
Dim Lote As String = If(GVRow.DataKey("Lote") = "", "-1", GVRow.DataKey("Lote")) Dim Lote As String = GVRow.DataKey("Lote")
Dim FechaCaducidad As DateTime = If(GVRow.DataKey("FechaCaducidad") = "", MinFecha, GVRow.DataKey("FechaCaducidad").ToDate) Dim CveUM As Integer = GVRow.DataKey("CveUM").ToEntero
If Not ObjOS.AddOrdenesServicioMateriales(CveOS, CvePS, CantidadRegistro, Serie, Lote, FechaCaducidad, UsuarioActual.CveUsuario) Then Dim FechaCaducidad As DateTime = GVRow.DataKey("FechaCaducidad").ToDate
Alert("Ocurrió un error al guardar el material.", TipoMensaje.MsgAdvertencia) If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadRegistro, CveUM, CvePS, 0, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then
ProcesoOK = False Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia)
Exit For ProcesoOK = False
Exit For
End If
End If End If
End If Next
Next If ProcesoOK Then
If ProcesoOK Then Dim CveOSEstatusFinalizada As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 4").ToEntero
Dim CveOSEstatusFinalizada As Integer = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveEstatusOrdenServicio", "TipoEstatus = 4").ToEntero If CveOSEstatusFinalizada > 0 Then
If CveOSEstatusFinalizada > 0 Then If Not ObjOS.UpdateOrdenesServiciosEstatus(CveOSEstatusFinalizada, UsuarioActual.CveUsuario, CveOS) Then
If Not ObjOS.UpdateOrdenesServiciosEstatus(CveOSEstatusFinalizada, UsuarioActual.CveUsuario, CveOS) Then ProcesoOK = False
End If
Else
Alert("No se pudo obtener el estado para finalizar la orden de servicio.")
ProcesoOK = False ProcesoOK = False
End If End If
Else
Alert("No se pudo obtener el estado para finalizar la orden de servicio.")
ProcesoOK = False
End If End If
Else
ProcesoOK = False
End If End If
Else Else
If ProcesoOK Then If ProcesoOK Then
Dim AplicaDevolucion As Boolean = False Dim AplicaDevolucion As Boolean = False
@@ -3135,20 +3137,19 @@ Partial Class OS_OrdenesServicios
Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero Dim CveVentaDetalle As Integer = GvRow.DataKey("CveVentaDetalle").ToEntero
Dim CantidadDev As Decimal = GvRow.DataKey("Cantidad").ToDecimal - GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal Dim CantidadDev As Decimal = GvRow.DataKey("Cantidad").ToDecimal - GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal
If CantidadDev > 0 Then If CantidadDev > 0 AndAlso CveVentaDetalle > 0 Then
AplicaDevolucion = True AplicaDevolucion = True
If Not ObjV.UpdateVentasDetalleCantidadDevolucion(CveVentaDetalle, CantidadDev) Then If Not ObjV.UpdateVentasDetalleCantidadDevolucion(CveVentaDetalle, CantidadDev) Then
ProcesoOK = False ProcesoOK = False
GenrarRemisionMovimientos = False GenerarRemisionMovimientos = False
AplicaDevolucion = False AplicaDevolucion = False
Exit For Exit For
End If End If
End If End If
If GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal > 0 Then If GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal > 0 Then
GenrarRemisionMovimientos = True GenerarRemisionMovimientos = True
End If End If
Next Next
If AplicaDevolucion Then If AplicaDevolucion Then
If Not ObjV.UpdateVentasDevolucionAlmacen(1, CveVentaPedido) Then If Not ObjV.UpdateVentasDevolucionAlmacen(1, CveVentaPedido) Then
@@ -3162,29 +3163,36 @@ Partial Class OS_OrdenesServicios
Dim ImporteAlmacen As Decimal Dim ImporteAlmacen As Decimal
Dim Fecha As DateTime = ClsPaginas.NowADS() Dim Fecha As DateTime = ClsPaginas.NowADS()
If GenrarRemisionMovimientos AndAlso ProcesoOK Then If GenerarRemisionMovimientos AndAlso ProcesoOK Then
If Not TxtFolioRemisionModal.Text.Trim.Length > 0 Then If Not TxtFolioRemisionModal.Text.Trim.Length > 0 Then
Alert("El campo Folio es requerido por favor ingreselo.", TipoMensaje.MsgAdvertencia) Alert("El campo Folio es requerido por favor ingréselo.", TipoMensaje.MsgAdvertencia)
ProcesoOK = False ProcesoOK = False
GenrarRemisionMovimientos = False GenerarRemisionMovimientos = False
End If End If
End If End If
If GenrarRemisionMovimientos AndAlso ProcesoOK Then If GenerarRemisionMovimientos AndAlso ProcesoOK Then
Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL()) Respuesta = GeneraRemision(CveVentaPedido, ObjV.IniciaTransacSQL())
If Respuesta.CveVenta > 0 Then If Respuesta.CveVenta > 0 Then
If ObjV.GetVentaDetalle(Respuesta.CveVenta) Then If ObjV.GetVentaDetalle(Respuesta.CveVenta) Then
Dim dtClon As DataTable = ObjV.DtResultados.Copy Dim dtClon As DataTable = ObjV.DtResultados.Copy
dtClon.DefaultView.Sort = "CveVentaDetalle ASC" dtClon.DefaultView.Sort = "CveVentaDetalle ASC"
DtVentaDetalle = dtClon.DefaultView.ToTable() Dim dtmat As DataTable = dtClon.DefaultView.ToTable()
'una vez registrada, asocia los lotes/cad con el cveventadetalle para que se surta así
DtVentaDetalle = Respuesta.dtdetalle
For i = 0 To dtmat.Rows.Count - 1
If DtVentaDetalle.Rows(i)("CvePS").ToString = dtmat.Rows(i)("CvePS").ToString Then
DtVentaDetalle.Rows(i)("CveVentaDetalle") = dtmat.Rows(i)("CveVentaDetalle")
End If
Next
End If End If
Else Else
ProcesoOK = False ProcesoOK = False
End If End If
End If End If
If GenrarRemisionMovimientos AndAlso ProcesoOK Then If GenerarRemisionMovimientos AndAlso ProcesoOK Then
CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="OS/MatUtil") CveMovimientoSalida = ObjInventario.AddMovimiento(CveAlmacenActual, 8, CveMoneda, Fecha, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, Respuesta.CveVenta, CveSubProyectoPedido, -1, CveOS:=CveOS, CveAlmacenDestino:=CveAlmacenDestino, Modulo:="OS/MatUtil")
Dim Folio As Integer = ObjInventario.Folio Dim Folio As Integer = ObjInventario.Folio
@@ -3192,17 +3200,17 @@ Partial Class OS_OrdenesServicios
If CveMovimientoSalida > 0 Then If CveMovimientoSalida > 0 Then
Dim IndexMov1 As Integer = 0 Dim IndexMov1 As Integer = 0
For Each GvRow As GridViewRow In GvMU.Rows For Each drr As DataRow In DtVentaDetalle.Rows
Dim Cantidad As Decimal = GvRow.DataKey("Cantidad").ToDecimal Dim Cantidad As Decimal = drr("Cantidad").ToString.ToDecimal
Dim CantidadRegistro As Decimal = GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal 'Dim CantidadRegistro As Decimal = GvRow.FCTextBox("TxtUtilizado").Text.ToDecimal
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero Dim CvePS As Integer = drr("CvePS").ToString.ToEntero
Dim CveUM As Integer = GvRow.DataKey("CveUM").ToEntero Dim CveUM As Integer = drr("CveUM").ToString.ToEntero
Dim PU As Decimal = GvRow.DataKey("PU").ToDecimal Dim PU As Decimal = drr("PU").ToString.ToDecimal
If CantidadRegistro > 0 Then If Cantidad > 0 Then
Dim CveVentaDetalle As Integer = DtVentaDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePadre = {GvRow.DataKey("CveVentaDetalle")}").ToEntero Dim CveVentaDetalle As Integer = drr("CveVentaDetalle").ToString.ToEntero 'DtVentaDetalle.FiltroPrimeroValor("CveVentaDetalle", $"CveVentaDetallePadre = {GvRow.DataKey("CveVentaDetalle")}").ToEntero
Dim CveMovimientoDetalle As Integer = GvRow.DataKey("CveMovimientoDetalle").ToEntero Dim CveMovimientoDetalle As Integer = -1 'GvRow.DataKey("CveMovimientoDetalle").ToEntero
If CveVentaDetalle <= 0 Then If CveVentaDetalle <= 0 Then
Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia) Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia)
@@ -3210,10 +3218,10 @@ Partial Class OS_OrdenesServicios
Exit For Exit For
End If End If
Dim Serie As String = GvRow.DataKey("Serie") Dim Serie As String = "" 'GvRow.DataKey("Serie")
Dim Lote As String = GvRow.DataKey("Lote") Dim Lote As String = drr("Lote").ToString
Dim FechaCaducidad As DateTime = GvRow.DataKey("FechaCaducidad").ToDate Dim FechaCaducidad As DateTime = drr("FechaCaducidad").ToString.ToDate
If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, CantidadRegistro, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then If Not ObjInventario.AddMovimientoDetalle(CveMovimientoSalida, Cantidad, CveUM, CvePS, PU, CveVentaDetalle:=CveVentaDetalle, CveMovimientoDetalleEntrada:=CveMovimientoDetalle, Lote:=Lote, Serie:=Serie, FechaCaducidad:=FechaCaducidad) Then
Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia) Alert("Error al agregar detalle de movimiento.", TipoMensaje.MsgAdvertencia)
ProcesoOK = False ProcesoOK = False
Exit For Exit For
@@ -3312,7 +3320,7 @@ Partial Class OS_OrdenesServicios
Dim Liga As String = $" document.location.href=""/OS/OrdenesServicios.aspx?CveOS={CveOS}""; " Dim Liga As String = $" document.location.href=""/OS/OrdenesServicios.aspx?CveOS={CveOS}""; "
Alert("El material utilizado se guardó correctamente", TipoMensaje.MsgInformacion, Liga) Alert("El material utilizado se guardó correctamente", TipoMensaje.MsgInformacion, Liga)
Else Else
If GenrarRemisionMovimientos = False Then If GenerarRemisionMovimientos = False Then
Alert("El material sera recibido en almacén.") Alert("El material sera recibido en almacén.")
Else Else
Alert("El material utilizado se guardó correctamente") Alert("El material utilizado se guardó correctamente")
@@ -3401,6 +3409,16 @@ Partial Class OS_OrdenesServicios
ObjFactura.Episodio = TxtEpisodioModal.Text.Trim ObjFactura.Episodio = TxtEpisodioModal.Text.Trim
ObjFactura.Alfa1 = TxtFolioRemisionModal.Text.Trim ObjFactura.Alfa1 = TxtFolioRemisionModal.Text.Trim
Dim TmpDTMat As New DataTable
TmpDTMat.Columns.Add("Consec", GetType(Integer))
TmpDTMat.Columns.Add("CvePS", GetType(Integer))
TmpDTMat.Columns.Add("CveUM", GetType(Integer))
TmpDTMat.Columns.Add("Cantidad", GetType(Integer))
TmpDTMat.Columns.Add("PU", GetType(Decimal))
TmpDTMat.Columns.Add("Lote", GetType(String))
TmpDTMat.Columns.Add("FechaCaducidad", GetType(Date))
TmpDTMat.Columns.Add("CveVentaDetalle", GetType(Integer))
For Each GvRow As GridViewRow In GvMU.Rows For Each GvRow As GridViewRow In GvMU.Rows
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
@@ -3409,8 +3427,17 @@ Partial Class OS_OrdenesServicios
Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal Dim Descuento As Decimal = GvRow.DataKey("Descuento").ToDecimal
Dim Obs As String = GvRow.DataKey("Observaciones") Dim Obs As String = GvRow.DataKey("Observaciones")
If CantidadRegistro > 0 Then If CantidadRegistro > 0 Then
If Not ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=GvRow.DataKey("CveVentaDetalle").ToEntero) Then If ObjFactura.AgregarPS(CvePS, CantidadRegistro, PU, Descuento, Obs, CveSubProyecto:=CveSubProyectoPedido, CveVentaDetallePadre:=GvRow.DataKey("CveVentaDetalle").ToEntero) Then
Dim drp As DataRow = TmpDTMat.NewRow
drp("CvePS") = CvePS
drp("Cantidad") = CantidadRegistro
drp("PU") = PU
drp("Lote") = GvRow.DataKey("Lote")
drp("FechaCaducidad") = GvRow.DataKey("FechaCaducidad").ToDate
TmpDTMat.Rows.Add(drp)
Else
Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia) Alert("Error al agregar producto", TipoMensaje.MsgAdvertencia)
ProcesoOK = False ProcesoOK = False
Exit For Exit For
@@ -3426,6 +3453,7 @@ Partial Class OS_OrdenesServicios
If Resp.CveVenta > 0 Then If Resp.CveVenta > 0 Then
Respuesta.CveVenta = Resp.CveVenta Respuesta.CveVenta = Resp.CveVenta
Respuesta.SerieFolio = Resp.SerieFolio Respuesta.SerieFolio = Resp.SerieFolio
Respuesta.dtdetalle = TmpDTMat
Else Else
ProcesoOK = False ProcesoOK = False
End If End If
@@ -3442,6 +3470,7 @@ Partial Class OS_OrdenesServicios
Friend Class RespuestaFacturacion Friend Class RespuestaFacturacion
Public Property CveVenta As Integer = -1 Public Property CveVenta As Integer = -1
Public Property SerieFolio As String = "-1" Public Property SerieFolio As String = "-1"
Public Property dtdetalle As DataTable = Nothing
Public Sub New() Public Sub New()
End Sub End Sub

View File

@@ -13690,19 +13690,21 @@ Partial Class Ventas
If DdlSucursalCliente.SelectedValue.ToEntero > 0 Then If DdlSucursalCliente.SelectedValue.ToEntero > 0 Then
Dim drr As DataRow = GlobalDTClientesSucursales(UsuarioActual.CveEmpresa, CveCliente).FiltroPrimero($" CveClienteSucursal = {DdlSucursalCliente.SelectedValue.ToEntero}") Dim drr As DataRow = GlobalDTClientesSucursales(UsuarioActual.CveEmpresa, CveCliente).FiltroPrimero($" CveClienteSucursal = {DdlSucursalCliente.SelectedValue.ToEntero}")
If drr IsNot Nothing Then If drr IsNot Nothing Then
If RBLTipoVenta.SelectedValue.Contiene("3", "6") Then 'cuando es A-vista If RBLTipoVenta.SelectedValue.Contiene("3") Then 'cuando es A-vista
CveAlmacenTraspasoDestino = drr("CveAlmacenAlterno").ToString.ToEntero CveAlmacenTraspasoDestino = drr("CveAlmacenAlterno").ToString.ToEntero
ElseIf RBLTipoVenta.SelectedValue.Contiene("4") Then 'cuando es Consignación
CveAlmacenTraspasoDestino = drr("CveAlmacenConsignacion").ToString.ToEntero
Else Else
CveAlmacenTraspasoDestino = drr("CveAlmacenAsignado").ToString.ToEntero CveAlmacenTraspasoDestino = drr("CveAlmacenAsignado").ToString.ToEntero '' cuando Fuera de Línea
End If End If
End If End If
End If End If
If Not CveAlmacenTraspasoDestino > 0 Then If Not CveAlmacenTraspasoDestino > 0 Then ' para consignación es salida directa
CveAlmacenTraspasoDestino = CveAlmacenAsignado CveAlmacenTraspasoDestino = CveAlmacenAsignado
End If End If
If RBLTipoVenta.SelectedValue.ToEntero = 2 Then If RBLTipoVenta.SelectedValue = "2" Then
If Not ChkRequiereTecnico.Checked Then If Not ChkRequiereTecnico.Checked Then
CveAlmacenTraspasoDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 10 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString().ToEntero() CveAlmacenTraspasoDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveAlmacen", $"CveTipoAlmacen = 10 AND CveSubProyecto = {DdlSubProyectoDatos.SelectedValue}").ToString().ToEntero()
End If End If
@@ -13716,6 +13718,7 @@ Partial Class Ventas
ErrorList.Add("Ocurrió un error al seleccionar el almacen de resguardo del cliente.") ErrorList.Add("Ocurrió un error al seleccionar el almacen de resguardo del cliente.")
End If End If
End If End If
End If End If
Dim TotalImpuestoLocal As Double = 0 Dim TotalImpuestoLocal As Double = 0
@@ -37815,6 +37818,8 @@ Partial Class Ventas
If drr IsNot Nothing Then If drr IsNot Nothing Then
If RBLTipoVenta.SelectedValue.Contiene("6") Then If RBLTipoVenta.SelectedValue.Contiene("6") Then
tCveAlmacenExistencia = drr("CveAlmacenAlterno").ToString.ToEntero tCveAlmacenExistencia = drr("CveAlmacenAlterno").ToString.ToEntero
ElseIf RBLTipoVenta.SelectedValue.Contiene("5") Then
tCveAlmacenExistencia = drr("CveAlmacenConsignacion").ToString.ToEntero
Else Else
tCveAlmacenExistencia = drr("CveAlmacenAsignado").ToString.ToEntero tCveAlmacenExistencia = drr("CveAlmacenAsignado").ToString.ToEntero
End If End If