diff --git a/App_Code/ClsBancos.vb b/App_Code/ClsBancos.vb index 9e1e30aa8..d01135057 100644 --- a/App_Code/ClsBancos.vb +++ b/App_Code/ClsBancos.vb @@ -1099,7 +1099,7 @@ Public Class ClsBancos Dim Timbrado As New Timbrado Dim CFDIVersion As String = "4.0" - If GetComplementoPagosImpuestos(CveIE, UsuarioActual.CveEmpresa) Then + If GetComplementoPagosImpuestos(CveIE, UsuarioActual.CveEmpresa, CvePrePoliza:=CvePrePoliza) Then dttpagosimpuestos = DtResultados End If @@ -1386,7 +1386,7 @@ Public Class ClsBancos Return Retorno End Function - Public Function GetComplementoPagosImpuestos(CveIE As Integer, CveEmpresa As Integer) As Boolean + Public Function GetComplementoPagosImpuestos(CveIE As Integer, CveEmpresa As Integer, Optional CvePrePoliza As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_Banc_ComplementoPagoImpuestosGet") @@ -1394,6 +1394,7 @@ Public Class ClsBancos With SqlAdapter.SelectCommand.Parameters .Add("@CveIE", SqlDbType.Int).Value = CveIE .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + .Add("@CvePrePoliza", SqlDbType.Int).Value = CvePrePoliza End With Try SqlAdapter.Fill(Data) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index ae4459a62..ac9d061bb 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -8831,7 +8831,7 @@ Public Class ClsPaginas If File.Exists($"{UsuarioActual.Empresa.Ruta}Formatos\ReciboDePago.rdlc") Then rutaArchivo = $"{UsuarioActual.Empresa.Ruta}Formatos\ReciboDePago.rdlc" Else - rutaArchivo = " \Empresas\Grales\Formatos\ReciboDePago.rdlc" + rutaArchivo = "\Empresas\Grales\Formatos\ReciboDePago.rdlc" End If If Not Directory.Exists($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\") Then Directory.CreateDirectory($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\") Dim ArchivoPDF As New System.IO.FileInfo($"{Ruta}PDF\Pag\{Serie}-{Folio}.pdf") @@ -8843,7 +8843,7 @@ Public Class ClsPaginas Alert("Ocurrió un error al generar el PDF", TipoMensaje.MsgAdvertencia) End Try Else - File.WriteAllBytes($"{UsuarioActual.Empresa.Ruta}\PDF\Pag\{SerieFolio}.pdf", StreamPDF(rutaArchivo, lrds, params, "Pago", "PDF")) + File.WriteAllBytes($"{UsuarioActual.Empresa.Ruta}PDF\Pag\{SerieFolio}.pdf", StreamPDF(rutaArchivo, lrds, params, "Pago", "PDF")) End If If imprimir Then ImprimirPDF(rutaArchivo, lrds, params, SerieFolio, "PDF") diff --git a/App_Code/ClsRH.vb b/App_Code/ClsRH.vb index c9290bf53..5c4a50311 100644 --- a/App_Code/ClsRH.vb +++ b/App_Code/ClsRH.vb @@ -2054,11 +2054,9 @@ Public Class ClsRH .Add("@NetoPeriodo", SqlDbType.Money).Value = NetoPeriodo .Add("@TipoSangre", SqlDbType.VarChar).Value = TipoSangre .Add("@AreaGeografica", SqlDbType.VarChar).Value = AreaGeografica - .Add("@CveSubTipoPeriodo", SqlDbType.Int).Value = CveSubTipoPeriodo - .Add("@ErrorMostrarADS", SqlDbType.VarChar).Direction = ParameterDirection.Output - + '.Add("@ErrorMostrarADS", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output .Add("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.Output End With diff --git a/Ashx/E119.ashx b/Ashx/E119.ashx index a774331de..a14a437ef 100644 --- a/Ashx/E119.ashx +++ b/Ashx/E119.ashx @@ -9,7 +9,7 @@ Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Imports Extensiones -Public Class E119 : Implements IHttpHandler +Public Class E119 : Implements IHttpHandler, System.Web.SessionState.IRequiresSessionState Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get @@ -59,6 +59,7 @@ Public Class E119 : Implements IHttpHandler Dim Contrasenia As String = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, CveEmpresa:=CveEmpresa) UsuarioActual.CveEmpresa = CveEmpresa + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual CreaObjetoEmpresa(UsuarioActual) End If End If @@ -79,7 +80,7 @@ Public Class E119 : Implements IHttpHandler End If UsuarioActual.Empresa = ObjEmpresa.Empresa - If UsuarioActual.Empresa.RutaDB = "" Then UsuarioActual.Empresa.RutaDB = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString + End If ObjEmpresa.Dispose() End Sub @@ -267,7 +268,7 @@ Public Class E119 : Implements IHttpHandler End If Dim Productos As JArray = Nothing - + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Using ObjInventario As New ClsInventarios If ObjInventario.GetJAM_APIs(1, CveClasificacion:=CveClasificacion.ToEntero()) AndAlso ObjInventario.DtResultados IsNot Nothing Then Productos = JArray.Parse(ObjInventario.DtResultados.FiltroPrimeroValor("JsonTexto")) @@ -302,6 +303,7 @@ Public Class E119 : Implements IHttpHandler Dim TieneError As Boolean = False Dim Clasificaciones As JArray = Nothing + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Try 'Clasificaciones = JArray.Parse(ClsPaginas.GlobalDTClasificaciones(CveEmpresa).FiltraParametros("", DistinctColumns:={"CveClasificacion", "Clasificacion"}).DataTableToJSONIPP()) diff --git a/Ashx/E141.ashx b/Ashx/E141.ashx index d173221f0..07ca0b86d 100644 --- a/Ashx/E141.ashx +++ b/Ashx/E141.ashx @@ -10,7 +10,7 @@ Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Imports Extensiones -Public Class E141 : Implements IHttpHandler +Public Class E141 : Implements IHttpHandler, System.Web.SessionState.IRequiresSessionState Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get @@ -69,6 +69,7 @@ Public Class E141 : Implements IHttpHandler Dim Contrasenia = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, CveEmpresa:=CveEmpresa) UsuarioActual.CveEmpresa = CveEmpresa + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual CreaObjetoEmpresa(UsuarioActual) End If End If @@ -1671,6 +1672,21 @@ Public Class E141 : Implements IHttpHandler Return JsonConvert.SerializeObject(respuesta) End If + + Dim UsuarioActual As Usuario = Nothing + Dim ObjUsuarios As New ClsSisUsuarios + If ObjUsuarios.GetUsuarios(100) Then + If ObjUsuarios.DtResultados.Rows.Count > 0 Then + Dim Usuario As String = ObjUsuarios.DtResultados.Rows(0)("Usuario").ToString() + Dim Contrasenia As String = ObjUsuarios.DtResultados.Rows(0)("Contraseña").ToString() + UsuarioActual = ObjUsuarios.ValidaUsuario(Usuario, Contrasenia, CveEmpresa:=CveEmpresa) + UsuarioActual.CveEmpresa = CveEmpresa + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual + CreaObjetoEmpresa(UsuarioActual) + End If + End If + ObjUsuarios.Dispose() + Using ObjPS As New ClsProductosServicios() If ObjPS.GetExistenciasEmpresa(Codigo, CveEmpresa) Then Dim ArrayPS As New JArray @@ -1964,6 +1980,7 @@ Public Class E141 : Implements IHttpHandler Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios 'OBTERNER PRECIOS DE PUBLICO GENERAL @@ -2054,6 +2071,7 @@ Public Class E141 : Implements IHttpHandler Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios 'OBTERNER PRECIOS DE PUBLICO GENERAL @@ -2101,7 +2119,7 @@ Public Class E141 : Implements IHttpHandler Retorno = True Return Retorno End If - + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios 'OBTERNER PRECIOS DE PUBLICO GENERAL @@ -2191,7 +2209,7 @@ Public Class E141 : Implements IHttpHandler Dim payload = New JObject() Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 - + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios If ObjPS.GetExistenciasEmpresa("-1", CveEmpresa) Then @@ -2231,6 +2249,7 @@ Public Class E141 : Implements IHttpHandler Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 Dim DtVendedores As DataTable = Nothing + Dim Usuario As Usuario = ValidaUsuarioSistema(100, CveEmpresa) Using ObjPS As New ClsProductosServicios 'OBTERNER PRECIOS DE PUBLICO GENERAL If ObjPS.GetVendedoresModificados(CveEmpresa, If(Todos, -1, 1)) Then diff --git a/Compras/Compras.aspx.vb b/Compras/Compras.aspx.vb index ace5f8509..eb8f9e463 100644 --- a/Compras/Compras.aspx.vb +++ b/Compras/Compras.aspx.vb @@ -10,10 +10,8 @@ Imports System.Threading.Tasks Imports Newtonsoft.Json Imports Extensiones Imports MoreLinq -Imports ClsPaginas Imports System.Data.SqlClient - - +Imports ClsPaginas Partial Class Compras_Compras Inherits ClsPaginas @@ -3148,7 +3146,6 @@ Partial Class Compras_Compras LtlGvAnticiposSel.Visible = True End If - '' VALIDA ELIMINAR COMPRA, QUE NO TENGA PAGOS CONCILIADOS If (UsuarioActual.TienePermisoProceso(77) OrElse UsuarioActual.TienePermisoProceso(135)) AndAlso dr("NumPagosConciliados").ToString.ToEntero = 0 Then ' Eliminar compra @@ -3168,7 +3165,6 @@ Partial Class Compras_Compras End If End If - Dim StrInventario As String = "" If dr("Inventario").ToString = "1" Then StrInventario = "los Movimientos de Inventario relacionados" @@ -6296,13 +6292,13 @@ Partial Class Compras_Compras If RBLPago.SelectedValue.ToEntero = 4 Then Exit Select 'Es credito el concepto 6 se agrega en CASE 17 End If - Dim DifSubTotatles As Decimal = 0D + Dim DifSubTotales As Decimal = 0D If CveCompraRefacturacion > 0 Then - DifSubTotatles = Math.Abs(SubTotalRefacturacion - TxtSubTotal2.Text.ToDecimal) + DifSubTotales = Math.Abs(SubTotalRefacturacion - TxtSubTotal2.Text.ToDecimal) End If - If DifSubTotatles > 0 Or (Not CveCompraRefacturacion > 0 OrElse (ChkRefacNC.Checked)) Then + If DifSubTotales > 0 Or (Not CveCompraRefacturacion > 0 OrElse (ChkRefacNC.Checked)) Then 'AF TipoAF 2 Es para las compras DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2 And ISNULL(AplicaCostoIndirecto,0) <> 1 ") If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then @@ -6347,8 +6343,6 @@ Partial Class Compras_Compras DT = DT.FiltraParametros("ISNULL(CveAlmacen,0) > 0") If DT.Rows.Count > 0 AndAlso Not DdlTipoComprobante.SelectedValue.Contiene("NC", "DEV", "Ant") Then - - 'SI ES GASTO CON ALMACEN If DdlTipoCompra.SelectedValue = "10" Then For Each RowDetalle As DataRow In TmpDT.FiltraParametros("ISNULL(TipoAF,0) <> 2 And ISNULL(CveAlmacen,0) > 0", "", {"CveAlmacen", "CveClasificacion", "CveSubProyecto"}).Rows @@ -6449,6 +6443,9 @@ Partial Class Compras_Compras ConceptoContabilizacion = 6 End If + If UsuarioActual.CveEmpresa.Contiene(7, 11, 12, 122, 145, 13, 83) AndAlso ConceptoContabilizacion = 205 Then + ConceptoContabilizacion = 6 + End If Select Case ConceptoContabilizacion Case 6 @@ -9316,6 +9313,10 @@ Partial Class Compras_Compras End If End If + If UsuarioActual.CveEmpresa.Contiene(7, 11, 12, 122, 145, 13, 83) AndAlso CveConceptoContableAlmacen = 205 Then + CveConceptoContableAlmacen = 6 + End If + 'AF DT = TmpDT.FiltraParametros("ISNULL(TipoAF,0) = 2") If DT.Rows.Count > 0 AndAlso DdlTipoComprobante.SelectedValue <> "NC" Then @@ -21131,9 +21132,9 @@ Public Class ClsCompraManagerCompras Public Property CveRetISRConcepto As Integer = -1 Public Property CveSubProyecto As Integer = -1 Public Property UsuarioActual As Usuario - Public ReadOnly Property ConceptoPrePolizaIVA As ConceptosRetenciones + Public ReadOnly Property ConceptoPrePolizaIVA As ClsPaginas.ConceptosRetenciones Get - Dim Ret As New ConceptosRetenciones + Dim Ret As New ClsPaginas.ConceptosRetenciones If EsImportacion Then Ret.CveConceptoAcreditable = 288 Ret.CveConceptoxAcreditar = 287 @@ -21144,9 +21145,9 @@ Public Class ClsCompraManagerCompras Return Ret End Get End Property - Public ReadOnly Property ConceptoPrePolizaRetIVA As ConceptosRetenciones + Public ReadOnly Property ConceptoPrePolizaRetIVA As ClsPaginas.ConceptosRetenciones Get - Dim Ret As New ConceptosRetenciones + Dim Ret As New ClsPaginas.ConceptosRetenciones Dim Funcionalidad, FuncionalidadxAcred As Integer If CveRetIVAConcepto = 1 Then Funcionalidad = 308 : FuncionalidadxAcred = 307 @@ -21176,9 +21177,9 @@ Public Class ClsCompraManagerCompras Return Ret End Get End Property - Public ReadOnly Property ConceptoPrePolizaRetISR As ConceptosRetenciones + Public ReadOnly Property ConceptoPrePolizaRetISR As ClsPaginas.ConceptosRetenciones Get - Dim Ret As New ConceptosRetenciones + Dim Ret As New ClsPaginas.ConceptosRetenciones Dim Funcionalidad, FuncionalidadxAcred As Integer If CveRetISRConcepto = 1 Then Funcionalidad = 316 : FuncionalidadxAcred = 315 @@ -21376,7 +21377,7 @@ Public Class ClsCompraManagerCompras Descuento = ValorXML(nodo, "descuento").ToDecimal Moneda = ValorXML(nodo, "Moneda") - CveMoneda = GlobalDTMonedas().FiltroPrimeroValor("CveMoneda", $" AbreviaturaSAT = '{Moneda}' ").ToEntero + CveMoneda = ClsPaginas.GlobalDTMonedas().FiltroPrimeroValor("CveMoneda", $" AbreviaturaSAT = '{Moneda}' ").ToEntero If Not CveMoneda > 0 Then GuardaLog($"Moneda {Moneda} no se obtuvo la clabe") Errores.AppendLine($"Moneda {Moneda} no se obtuvo la clabe") @@ -21388,7 +21389,7 @@ Public Class ClsCompraManagerCompras TipoCambio = ValorXML(nodo, "TipoCambio", "1").ToDecimal If CFDIVersion = EnumCFDIVersion.v33 Or CFDIVersion = EnumCFDIVersion.v40 Then - Dim drm As DataRow = GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago"))) + Dim drm As DataRow = ClsPaginas.GlobalDTVtaMetodoPago.FiltroPrimero(String.Format("ClaveMetodoPagoSAT = '{0}'", ValorXML(nodo, "MetodoPago"))) If drm IsNot Nothing Then CveMetodoPago = drm("CveMetodoPago").ToString.ToEntero MetodoPago = drm("MetodoPagoSAT").ToString diff --git a/Nomina/CalculoISRAnual.aspx b/Nomina/CalculoISRAnual.aspx index 64c1e0fed..85ad28de4 100644 --- a/Nomina/CalculoISRAnual.aspx +++ b/Nomina/CalculoISRAnual.aspx @@ -26,19 +26,19 @@ -
  • - Excel -
  • - Autoriza + Autorizar
  • +
  • + Descargar XLS +
  • - Formato Anual +  Constancia 37
  • diff --git a/Nomina/Nomina.aspx b/Nomina/Nomina.aspx index ed55de56d..6723242a6 100644 --- a/Nomina/Nomina.aspx +++ b/Nomina/Nomina.aspx @@ -215,10 +215,7 @@ - -
  • - Ordenar -
  • +
  • Autorizar
  • @@ -5049,8 +5046,7 @@
    diff --git a/Nomina/Nomina.aspx.cs b/Nomina/Nomina.aspx.cs index c32e3a437..c57915175 100644 --- a/Nomina/Nomina.aspx.cs +++ b/Nomina/Nomina.aspx.cs @@ -10994,12 +10994,7 @@ public partial class Nomina_Nomina2 : ClsPaginas Alert("Se cargo satisfactoriamente."); RegistraScript(string.Format("$('#divCargaMasiva').modal('hide');")); - if (ChkCargaMasivaRecalcularNomina.Checked) - { - cargaDatos(true); - - } - // + cargaPeriodos(); } } } diff --git a/RH/CatPersonal.aspx.vb b/RH/CatPersonal.aspx.vb index 05de5de9c..5ecad4271 100644 --- a/RH/CatPersonal.aspx.vb +++ b/RH/CatPersonal.aspx.vb @@ -134,7 +134,10 @@ Partial Class RH_CatPersonal FechaFIngreso = "-1" End If - If ObjPersonal.GetPersonal(-1, "-1", "-1", "-1", "-1", CveTurno, CvePuesto, CveDepartamento, CveRuta, CveEscolaridad, CveEstadoCivil, CveGenero, CveEstatusPersonal, CveSubProyecto, CveClienteAsignado, HorarioTrabajo, CveSupervisor, CveTipoPeriodo, CveMetodoPago, CveTipoContrato, CveMotivoBaja, CveProyecto, FechaIFinContrato, FechaFFinContrato, FechaIIngreso, FechaFIngreso, UsuarioActual.CveEmpresa, ddlclasificacion.SelectedValue.ToEntero()) Then + If ObjPersonal.GetPersonal(-1, "-1", "-1", "-1", "-1", CveTurno, CvePuesto, CveDepartamento, CveRuta, CveEscolaridad, CveEstadoCivil, CveGenero, + CveEstatusPersonal, CveSubProyecto, CveClienteAsignado, HorarioTrabajo, CveSupervisor, CveTipoPeriodo, CveMetodoPago, + CveTipoContrato, CveMotivoBaja, CveProyecto, FechaIFinContrato, FechaFFinContrato, FechaIIngreso, FechaFIngreso, + UsuarioActual.CveEmpresa, ddlclasificacion.SelectedValue.ToEntero()) Then DTDatos = ObjPersonal.DtResultados 'filtro por usuario subproyecto/sucursal vsh diff --git a/Transportes/RepContratoDetalle.aspx b/Transportes/RepContratoDetalle.aspx index fd736a498..0aee4aa8d 100644 --- a/Transportes/RepContratoDetalle.aspx +++ b/Transportes/RepContratoDetalle.aspx @@ -102,7 +102,7 @@
    <%-- Datos del Contrato --%>
    -
    +
    <%-- Contrato Digitalizado --%>
    -
    +
    <%-- Bitácora --%>
    -
    +
    "" Then - BtnArchivoAdjunto.Text = Adjunto - BtnArchivoAdjunto.Visible = True - BtnEliminarAdjunto.Visible = False - BtnAdjuntar.Visible = False - End If - - ViewState("CveSubProyectoVenta") = DbRowVenta("CveSubProyecto").ToString().ToEntero() - - If DbRowVenta("CveCondicionEntrega").ToString().ToEntero() > 0 Then - DdlFormaEntrega.SelectedValueExist(DbRowVenta("CveCondicionEntrega").ToString()) - DdlFormaEntrega.Enabled = False - End If - - Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString().ToEntero() - - If UsuarioActual.Empresa.Funcionalidad(705) = "1" Then - Me.CveLineaAdicionalVenta = DbRowVenta("CveLineaAdicional").ToString().ToEntero() - End If - TxtDescripcionVenta.Text = DbRowVenta("DescripcionVenta").ToString() - - 'CargaEncabezado - If Not (CveRemision > 0 Or CveCotizacion > 0) Then - DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString() - - If UsuarioActual.TienePermisoProceso(274) Then - TrAntEspecial.Visible = DdlTipoComprobante.SelectedValue = "Ant" - End If - - If TrAntEspecial.Visible Then - ChkAntEspecial.Enabled = False - ChkAntEspecial.Checked = If(DbRowVenta("AnticipoEspecial").ToString() = "True", True, False) - End If - CargaEstatusFactura(DdlTipoComprobante.SelectedValue) - CveEstatus = DbRowVenta("CveEstatusFactura").ToString().ToEntero() - LbEstatus.Text = DbRowVenta("EstatusFactura").ToString() - ViewState("SaldoVenta") = DbRowVenta("Saldo").ToString() - AplicaCancelarRemision = CBool(DbRowVenta("AplicaCancelarRemision").ToString()) - If AplicaCancelarRemision AndAlso CveEstatus.Contiene(2, 3) AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then DivCanRem.Visible = True - - - If CveEstatus = 5 Then LbCancelarDocumento.Enabled = False - 'If CveEstatus = 20 Then - ' LbCancelarDocumentoManual.Visible = True - 'End If - - - If (Not CveEstatus.Contiene(4, 5, 12, 13, 20, 23) OrElse (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4)) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Ant") AndAlso UsuarioActual.TienePermisoProceso(159) Then - Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) - If TienePermiso <> "" Then - LkRefacturacion.Visible = True - If (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4) Then - RefacturarCancelada = True - End If + RFCReceptorVenta = DbRowVenta("RFCReceptor").ToString() + 'Adjuntar archivo + Adjunto = DbRowVenta("Adjunto").ToString() + If Adjunto <> "" Then + BtnArchivoAdjunto.Text = Adjunto + BtnArchivoAdjunto.Visible = True + BtnEliminarAdjunto.Visible = False + BtnAdjuntar.Visible = False End If - End If - If DbRowVenta("CveVentaRelacionada").ToString().ToEntero() > 0 Then - TrRefacturadaa.Visible = True - HplRefacturadaEn.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", DbRowVenta("CveVentaRelacionada")) - HplRefacturadaEn.Text = DbRowVenta("SerieFolioRelacionada").ToString() - LblAlertRefacInv.Visible = True - End If - - If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev", "Rem", "DPe", "RNC", "Ped", "Cot") AndAlso Not CveEstatus.Contiene(4, 5, 10, 12, 13, 20, 23) Then - If UsuarioActual.TienePermisoProceso(159) Then - Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) - If TienePermiso <> "" Then - LbCancelarDocumento.Visible = True - 'If UsuarioActual.CveEmpresa = 119 And Not UsuarioActual.CveUsuario.Contiene(100, 1703) Then '[IPP] AD y Jesus de JAM - ' 'si es del mes anterior no permita cancelar - ' If Not DdlTipoComprobante.SelectedValue.Contiene("Rem") Then - ' If DbRowVenta("Fecha").ToString().ToDate <= NowADS().AddMonths(-1).LastDayOfMonth Then - ' LbCancelarDocumento.Visible = False - ' End If - ' End If - 'End If - End If + ViewState("CveSubProyectoVenta") = DbRowVenta("CveSubProyecto").ToString().ToEntero() + If DbRowVenta("CveCondicionEntrega").ToString().ToEntero() > 0 Then + DdlFormaEntrega.SelectedValueExist(DbRowVenta("CveCondicionEntrega").ToString()) + DdlFormaEntrega.Enabled = False End If - End If - Dim TipoEstatus As Integer = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero() + Me.CveEstatusFacturaPadre = DbRowVenta("CveEstatusFacturaPadre").ToString().ToEntero() - If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") Then - If UsuarioActual.TienePermisoProceso(116) Then - LbCancelarDocumento.Visible = True - If TipoEstatus = 2 Then - LbCancelarDocumento.Visible = False - ElseIf TipoEstatus = 5 Then - LbCancelarDocumento.Visible = False - End If + If UsuarioActual.Empresa.Funcionalidad(705) = "1" Then + Me.CveLineaAdicionalVenta = DbRowVenta("CveLineaAdicional").ToString().ToEntero() End If - End If + TxtDescripcionVenta.Text = DbRowVenta("DescripcionVenta").ToString() - If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CBool(DbRowVenta("ServicioDomicilio")) Then - TrServicioDomicilio.Visible = True - End If + 'CargaEncabezado + If Not (CveRemision > 0 Or CveCotizacion > 0) Then + DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString() - If UsuarioActual.TienePermisoProceso(318) Then - If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso String.IsNullOrEmpty(DbRowVenta("FolioFiscal").ToString.Trim) Then HplFolioFiscalModal.Visible = True - End If - - Select Case DbRowVenta("TipoDocto").ToString() - Case "Ing" - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then - HLPagar.Visible = True - HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" - HlCuentaTerminal.Visible = True + If UsuarioActual.TienePermisoProceso(274) Then + TrAntEspecial.Visible = DdlTipoComprobante.SelectedValue = "Ant" End If - TabAuxiliarConta.Visible = UsuarioActual.TienePermisoProceso(306) - Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) - If TienePermiso <> "" Then ' si tiene acceso en el subproyecto - 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) - If UsuarioActual.TienePermisoProceso(264) Then - InicializaAplicaDevolucion(TmpDT) - End If + If TrAntEspecial.Visible Then + ChkAntEspecial.Enabled = False + ChkAntEspecial.Checked = If(DbRowVenta("AnticipoEspecial").ToString() = "True", True, False) End If + CargaEstatusFactura(DdlTipoComprobante.SelectedValue) + CveEstatus = DbRowVenta("CveEstatusFactura").ToString().ToEntero() + LbEstatus.Text = DbRowVenta("EstatusFactura").ToString() + ViewState("SaldoVenta") = DbRowVenta("Saldo").ToString() + AplicaCancelarRemision = CBool(DbRowVenta("AplicaCancelarRemision").ToString()) + If AplicaCancelarRemision AndAlso CveEstatus.Contiene(2, 3) AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then DivCanRem.Visible = True - If UsuarioActual.Empresa.Funcionalidad(163) = "1" Then - TrDescripcionVenta.Visible = True - End If - HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) - Case "Egs" - HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) - HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + If CveEstatus = 5 Then LbCancelarDocumento.Enabled = False + 'If CveEstatus = 20 Then + ' LbCancelarDocumentoManual.Visible = True + 'End If - 'SI NO TIENE INGRESOS RELACIONADOS, SE TOMARA COMO DEVOLUCION DE EFECTIVO - If DtVentasRelacionadas IsNot Nothing AndAlso DtVentasRelacionadas.Rows.Count = 0 Then - EsNCDevolucionEfectivo = True - End If - Case "Rem" - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then - HLPagar.Visible = True - HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" - HlCuentaTerminal.Visible = True - End If - - If UsuarioActual.CveEmpresa = 80 Then - LtlImprimir.Text = String.Format("
  • Imprimir
  • ", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta))) - End If - DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() - EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) - If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + If (Not CveEstatus.Contiene(4, 5, 12, 13, 20, 23) OrElse (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4)) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Egs", "Ant") AndAlso UsuarioActual.TienePermisoProceso(159) Then Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) - If TienePermiso <> "" Then ' si tiene acceso en el subproyecto - 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) - If UsuarioActual.TienePermisoProceso(264) Then - InicializaAplicaRNCDevolucion(TmpDT) + If TienePermiso <> "" Then + LkRefacturacion.Visible = True + If (CveEstatus = 5 AndAlso DbRowVenta("CveEstatusRefacturacion").ToString().ToEntero() = 4) Then + RefacturarCancelada = True End If End If End If - Case "RNC" - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - If DdlTipoComprobante.Items.FindByValue("RNC") Is Nothing Then - DdlTipoComprobante.Items.Add(New ListItem("Remisión de nota de crédito", "RNC")) - End If - DdlTipoComprobante.SelectedValueExist("RNC") - Case "OP" - TdOrdenPago.Visible = True - DdlOrdenPago.SelectedValue = DbRowVenta("Num3").ToString() - DdlOrdenPago.Enabled = False - Case "Cot" - TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() - TxtFechaVencimientoCotizacion.Text = DbRowVenta("Vigencia").ToString() - PnlImprimir.Visible = True - HLOrdendeCompra.Visible = True - HLOrdendeCompra.NavigateUrl = String.Format("/OC/OC.aspx?Tipo=Req&CveCotizacion={0}", CveVenta) - Dim ObjOS As New ClsOS() - If ObjOS.GetCotizacionOS(CveVenta) Then - If ObjOS.DtResultados.Rows.Count > 0 Then - Dim DbRowOS As DataRow = ObjOS.DtResultados.Rows(0) - ViewState("CveOS") = DbRowOS("CveOS").ToString().ToEntero() - CargaOS(CveOS) - End If - - Else - HLOrdenServicio.Visible = True - HLOrdenServicio.NavigateUrl = String.Format("/OS/OrdenesServicios.aspx?CveCotizacion={0}", CveVenta) - End If - ObjOS.Dispose() - - If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 145) Then PnlImprimir.Visible = True : LnkImprimir.OnClientClick = "javascript:ImprimirCotizacion();return false;" - 'Deshabilitar impresión cuando no esté supervisada - If DbRowVenta("TipoEstatus").ToString().ToEntero() = 2 Or UsuarioActual.Empresa.Funcionalidad(113) = "1" Then - PnlImprimir.Visible = True - Else - HplDownPDF.Visible = False - PnlImprimir.Visible = False + If DbRowVenta("CveVentaRelacionada").ToString().ToEntero() > 0 Then + TrRefacturadaa.Visible = True + HplRefacturadaEn.NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", DbRowVenta("CveVentaRelacionada")) + HplRefacturadaEn.Text = DbRowVenta("SerieFolioRelacionada").ToString() + LblAlertRefacInv.Visible = True End If - - 'SI LA AUTORIZACION ES POR SUPERVISOR, BUSCA EL SUPERVISOR QUE TIENE EL VENDEDOR - If UsuarioActual.Empresa.Funcionalidad(135) = "1" Then - 'Reviso cuales son los supervisores - Dim Objeto As New ClsVtaVendedores - - If Objeto.GetVendedores(UsuarioActual.CveEmpresa) Then - Dim DTVendedores As New DataTable - If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then - DTVendedores = Objeto.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor)) + If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev", "Rem", "DPe", "RNC", "Ped", "Cot") AndAlso Not CveEstatus.Contiene(4, 5, 10, 12, 13, 20, 23) Then + If UsuarioActual.TienePermisoProceso(159) Then + Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) + If TienePermiso <> "" Then + LbCancelarDocumento.Visible = True + 'If UsuarioActual.CveEmpresa = 119 And Not UsuarioActual.CveUsuario.Contiene(100, 1703) Then '[IPP] AD y Jesus de JAM + ' 'si es del mes anterior no permita cancelar + ' If Not DdlTipoComprobante.SelectedValue.Contiene("Rem") Then + ' If DbRowVenta("Fecha").ToString().ToDate <= NowADS().AddMonths(-1).LastDayOfMonth Then + ' LbCancelarDocumento.Visible = False + ' End If + ' End If + 'End If End If - 'Verifico si es su supervisor asignado - If DTVendedores.Rows.Count > 0 Then - LkCotizacionAutorizar.Visible = True + End If + End If - If TipoEstatus = 2 Then - LkCotizacionAutorizar.Visible = False - ElseIf TipoEstatus = 5 Then - LkCotizacionAutorizar.Visible = False + Dim TipoEstatus As Integer = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero() + + If UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") AndAlso DdlTipoComprobante.SelectedValue.Contiene("Cot") Then + If UsuarioActual.TienePermisoProceso(116) Then + LbCancelarDocumento.Visible = True + If TipoEstatus = 2 Then + LbCancelarDocumento.Visible = False + ElseIf TipoEstatus = 5 Then + LbCancelarDocumento.Visible = False + End If + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso CBool(DbRowVenta("ServicioDomicilio")) Then + TrServicioDomicilio.Visible = True + End If + + If UsuarioActual.TienePermisoProceso(318) Then + If DdlTipoComprobante.SelectedValue.Contiene("Egs", "Ing", "Ant", "Dev") AndAlso String.IsNullOrEmpty(DbRowVenta("FolioFiscal").ToString.Trim) Then HplFolioFiscalModal.Visible = True + End If + + Select Case DbRowVenta("TipoDocto").ToString() + Case "Ing" + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then + HLPagar.Visible = True + HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" + HlCuentaTerminal.Visible = True + End If + + TabAuxiliarConta.Visible = UsuarioActual.TienePermisoProceso(306) + Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) + If TienePermiso <> "" Then ' si tiene acceso en el subproyecto + 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) + If UsuarioActual.TienePermisoProceso(264) Then + InicializaAplicaDevolucion(TmpDT) End If End If - DTVendedores.Dispose() - End If - Objeto.Dispose() - End If - 'SI LA AUTORIZACION ES POR PERMISO, BUSCA QUE EL USUARIO TENGA EL PERMISO PARA AUTORIZAR - If UsuarioActual.Empresa.Funcionalidad(135) = "2" Then - 'Reviso cuales son los supervisores - If UsuarioActual.TienePermisoProceso(116) Then - LkCotizacionAutorizar.Visible = True - If TipoEstatus = 2 Then - LkCotizacionAutorizar.Visible = False - ElseIf TipoEstatus = 5 Then - LkCotizacionAutorizar.Visible = False + If UsuarioActual.Empresa.Funcionalidad(163) = "1" Then + TrDescripcionVenta.Visible = True End If - End If - End If - Case "Ant" - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - 'LkNotaCredito.Visible = True - HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) - 'visualizo el saldo de anticipos, para cuando se aplique una Nota de crédito, decida si afecta anticipos o a DSV - LblNCSaldoAnticipo.Visible = True - ChkAplicaNCAnticipo.Visible = True - ChkAplicaNCAnticipo.Checked = True - If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then - HLPagar.Visible = True - HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" - HlCuentaTerminal.Visible = True - End If - Me.SaldoAnticipo = DbRowVenta("SaldoAnticipo").ToString().ToDecimal - If SaldoAnticipo > 0 Then - InicializaDTAnticiposAmortizacion() - ChkAplicaNCAnticipo.Enabled = False - Else - ChkAplicaNCAnticipo.Enabled = False - ChkAplicaNCAnticipo.Checked = False - End If - 'If DbRowVenta("SaldoAnticipo").ToString().ToDouble <= 0 Then ChkAplicaNCAnticipo.Checked = False : ChkAplicaNCAnticipo.Enabled = False - LblNCSaldoAnticipo.Text = String.Format("Saldo Anticipo: $ {0}", DbRowVenta("SaldoAnticipo").ToString().ToDouble.FormatoNumero) - Case "Dev" - DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev")) - HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) - HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - 'ViewState("CveDevolucion") = DbRowVenta("CveVentaPadre").ToString().ToEntero() - Trsaldo.Visible = True - HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) - Case "Ped" - DdlTipoComprobante.Items.Insert(0, New ListItem("Pedido", "Ped")) - CvePedido = CveVenta - If UsuarioActual.Empresa.Funcionalidad(595) = "1" Then - If DdlTipoComprobante.Items.FindByValue("PA") Is Nothing Then - BtnGeneraAutorizacion.Visible = If(CveEstatus <> 21, True, False) - End If - End If + HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) + Case "Egs" + HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) + HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + + 'SI NO TIENE INGRESOS RELACIONADOS, SE TOMARA COMO DEVOLUCION DE EFECTIVO + If DtVentasRelacionadas IsNot Nothing AndAlso DtVentasRelacionadas.Rows.Count = 0 Then + EsNCDevolucionEfectivo = True + End If + + Case "Rem" + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then + HLPagar.Visible = True + HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" + HlCuentaTerminal.Visible = True + End If + + If UsuarioActual.CveEmpresa = 80 Then + LtlImprimir.Text = String.Format("
  • Imprimir
  • ", Encripta(String.Format("OP=VTA&CVEVENTA={0}&PAG=0", CveVenta))) + End If + DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() + EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + Dim TienePermiso As String = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, -1).FiltroPrimeroValor("CveSubProyecto", String.Format("CveSubProyecto = {0}", DbRowVenta("CveSubProyecto"))) + If TienePermiso <> "" Then ' si tiene acceso en el subproyecto + 'LkNotaCredito.Visible = UsuarioActual.TienePermisoProceso(175) + If UsuarioActual.TienePermisoProceso(264) Then + InicializaAplicaRNCDevolucion(TmpDT) + End If + End If + End If + Case "RNC" + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + If DdlTipoComprobante.Items.FindByValue("RNC") Is Nothing Then + DdlTipoComprobante.Items.Add(New ListItem("Remisión de nota de crédito", "RNC")) + End If + DdlTipoComprobante.SelectedValueExist("RNC") + Case "OP" + TdOrdenPago.Visible = True + DdlOrdenPago.SelectedValue = DbRowVenta("Num3").ToString() + DdlOrdenPago.Enabled = False + Case "Cot" + TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() + TxtFechaVencimientoCotizacion.Text = DbRowVenta("Vigencia").ToString() + PnlImprimir.Visible = True + HLOrdendeCompra.Visible = True + HLOrdendeCompra.NavigateUrl = String.Format("/OC/OC.aspx?Tipo=Req&CveCotizacion={0}", CveVenta) + + Dim ObjOS As New ClsOS() + If ObjOS.GetCotizacionOS(CveVenta) Then + If ObjOS.DtResultados.Rows.Count > 0 Then + Dim DbRowOS As DataRow = ObjOS.DtResultados.Rows(0) + ViewState("CveOS") = DbRowOS("CveOS").ToString().ToEntero() + CargaOS(CveOS) + End If + + Else + HLOrdenServicio.Visible = True + HLOrdenServicio.NavigateUrl = String.Format("/OS/OrdenesServicios.aspx?CveCotizacion={0}", CveVenta) + End If + ObjOS.Dispose() + + If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 145) Then PnlImprimir.Visible = True : LnkImprimir.OnClientClick = "javascript:ImprimirCotizacion();return false;" + 'Deshabilitar impresión cuando no esté supervisada + If DbRowVenta("TipoEstatus").ToString().ToEntero() = 2 Or UsuarioActual.Empresa.Funcionalidad(113) = "1" Then + PnlImprimir.Visible = True + Else + HplDownPDF.Visible = False + PnlImprimir.Visible = False + End If + + + 'SI LA AUTORIZACION ES POR SUPERVISOR, BUSCA EL SUPERVISOR QUE TIENE EL VENDEDOR + If UsuarioActual.Empresa.Funcionalidad(135) = "1" Then + 'Reviso cuales son los supervisores + Dim Objeto As New ClsVtaVendedores + + If Objeto.GetVendedores(UsuarioActual.CveEmpresa) Then + Dim DTVendedores As New DataTable + If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then + DTVendedores = Objeto.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor)) + End If + + 'Verifico si es su supervisor asignado + If DTVendedores.Rows.Count > 0 Then + LkCotizacionAutorizar.Visible = True + + If TipoEstatus = 2 Then + LkCotizacionAutorizar.Visible = False + ElseIf TipoEstatus = 5 Then + LkCotizacionAutorizar.Visible = False + End If + End If + DTVendedores.Dispose() + End If + Objeto.Dispose() + End If + + 'SI LA AUTORIZACION ES POR PERMISO, BUSCA QUE EL USUARIO TENGA EL PERMISO PARA AUTORIZAR + If UsuarioActual.Empresa.Funcionalidad(135) = "2" Then + 'Reviso cuales son los supervisores + If UsuarioActual.TienePermisoProceso(116) Then + LkCotizacionAutorizar.Visible = True + If TipoEstatus = 2 Then + LkCotizacionAutorizar.Visible = False + ElseIf TipoEstatus = 5 Then + LkCotizacionAutorizar.Visible = False + End If + End If + End If + + Case "Ant" + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + 'LkNotaCredito.Visible = True + HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) + 'visualizo el saldo de anticipos, para cuando se aplique una Nota de crédito, decida si afecta anticipos o a DSV + LblNCSaldoAnticipo.Visible = True + ChkAplicaNCAnticipo.Visible = True + ChkAplicaNCAnticipo.Checked = True + If SaldoVenta > 0 And UsuarioActual.TienePermisoProceso(100) Then + HLPagar.Visible = True + HLPagar.NavigateUrl = $"/Bancos/PopIEVentas.aspx?CveVenta={CveVenta}&TB_iframe=true&height=500&width=675" + HlCuentaTerminal.Visible = True + End If + Me.SaldoAnticipo = DbRowVenta("SaldoAnticipo").ToString().ToDecimal + If SaldoAnticipo > 0 Then + InicializaDTAnticiposAmortizacion() + ChkAplicaNCAnticipo.Enabled = False + Else + ChkAplicaNCAnticipo.Enabled = False + ChkAplicaNCAnticipo.Checked = False + End If + 'If DbRowVenta("SaldoAnticipo").ToString().ToDouble <= 0 Then ChkAplicaNCAnticipo.Checked = False : ChkAplicaNCAnticipo.Enabled = False + LblNCSaldoAnticipo.Text = String.Format("Saldo Anticipo: $ {0}", DbRowVenta("SaldoAnticipo").ToString().ToDouble.FormatoNumero) + Case "Dev" + DdlTipoComprobante.Items.Insert(0, New ListItem("Devolucion", "Dev")) + HplDownXML.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=FactVta&CVEVENTA={0}&EXT={1}&SERIEFOLIO={2}&TIPODOCTO={3}", CveVenta, "XML", DbRowVenta("SerieFolio"), DbRowVenta("TipoDocto")))) + HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() + 'ViewState("CveDevolucion") = DbRowVenta("CveVentaPadre").ToString().ToEntero() + Trsaldo.Visible = True + HplSaldoAuxiliar.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + HplPagado.NavigateUrl = String.Format("/Contabilidad/PopUpAuxiliar.aspx?Tipo=CxCClientes&CveCliente={0}&CveVenta={1}&TB_iframe=true&height=550&width=920", DbRowVenta("CveCliente"), DbRowVenta("CveVenta")) + Case "Ped" + DdlTipoComprobante.Items.Insert(0, New ListItem("Pedido", "Ped")) + CvePedido = CveVenta + If UsuarioActual.Empresa.Funcionalidad(595) = "1" Then + If DdlTipoComprobante.Items.FindByValue("PA") Is Nothing Then + BtnGeneraAutorizacion.Visible = If(CveEstatus <> 21, True, False) + End If + End If 'If UsuarioActual.TienePermisoProceso(199) Then ' BtnGenerarRemision.Visible = If(CveEstatus <> 21, True, False) 'Else ' BtnGenerarRemision.Visible = False 'End If - Case "DPe" - DdlTipoComprobante.Items.Insert(5, New ListItem("Devolución de perdido", "DPe")) - Case "PeC" - DdlTipoComprobante.Items.Insert(5, New ListItem("Pedido de Consignación", "PeC")) - Case "PA" - If UsuarioActual.TienePermisoProceso(199) Then - BtnGenerarRemision.Visible = If(CveEstatus = 16, True, False) - Else - BtnGenerarRemision.Visible = False - End If - CvePedidoA = CveVenta - DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() - EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) - End Select + Case "DPe" + DdlTipoComprobante.Items.Insert(5, New ListItem("Devolución de perdido", "DPe")) + Case "PeC" + DdlTipoComprobante.Items.Insert(5, New ListItem("Pedido de Consignación", "PeC")) + Case "PA" + If UsuarioActual.TienePermisoProceso(199) Then + BtnGenerarRemision.Visible = If(CveEstatus = 16, True, False) + Else + BtnGenerarRemision.Visible = False + End If + CvePedidoA = CveVenta + DiasCredito = DbRowVenta("DiasCredito").ToString().ToEntero() + EsDiasCreditoFijo = CBool(DbRowVenta("EsDiasCreditoFijo").ToString()) + End Select + + DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString() - DdlTipoComprobante.SelectedValue = DbRowVenta("TipoDocto").ToString() - - End If - - If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then - TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() - End If - - DdlTipoRelacionARelacionar.SelectedValueExist(DbRowVenta("CveTipoRelacion").ToString()) - - 'contado 0, credito 1, terminal 2 - If DbRowVenta("CondicionesPago").ToString().ToEntero() = 1 Then - RBLPago.SelectedValue = "1" - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - ElseIf DbRowVenta("CondicionesPago").ToString().ToEntero() = 0 Then - RBLPago.SelectedValue = "2" - RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - Else - DdlCuentasTerminal.SelectedValue = DbRowVenta("CveCuentaTerminal").ToString() - RBLPago.SelectedValue = "3" - RBLPago.Items(0).Enabled = False - RBLPago_SelectedIndexChanged(Nothing, Nothing) - UPCondicionesPago.Update() - End If - - - 'ESCONDE ACCIONES - LnkRemisiones.Visible = False - LnkPedido2SinFacturar.Visible = False - LnkCotizaciones.Visible = False - LnkOCs.Visible = False - UpnTools.Update() - - DivEstatusFac.Visible = True - HdnCveCliente.Value = CveCliente.ToString() - ViewState("CveCliente") = CveCliente - ViewState("CveEmpresaCRM") = DbRowVenta("CveEmpresaCRM").ToString().ToEntero() - ViewState("CveAcercamientoCRM") = DbRowVenta("CveAcercamientoCRM").ToString().ToEntero() - Entrega = DbRowVenta("Entrega").ToString() - Vigencia = DbRowVenta("Vigencia").ToString().ToDate.ToShortDateString - HplSaldoAuxiliar.Text = DbRowVenta("Saldo").ToString().FormatoNumero(2) - If Not HplSaldoAuxiliar.Text.ToDouble > 0 Then - HplSaldoAuxiliar.Visible = False - HplPagado.Visible = True - Dim EsCancelado As Boolean = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero() = 5 - If EsCancelado Then - HplPagado.Text = "CANCELADO" - End If - If ViewState("CveCotizacion") IsNot Nothing AndAlso ViewState("CveCotizacion").ToString().ToEntero() > 0 AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then - ImgAntiPend.Visible = True - Else - ImgAntiPend.Visible = False - End If - - End If - HdnPagado.Value = DbRowVenta("Pagado").ToString() - TxtTotal.Text = DbRowVenta("Total").ToString().FormatoNumero(2) - HdnVentaSaldo.Value = (SaldoVenta).ToString() - CvePrePoliza = DbRowVenta("CvePrePoliza").ToString().ToEntero() - CveVentaFacturada = DbRowVenta("CveVentaFacturada").ToString().ToEntero() - - CveVentaRelacion = DbRowVenta("CveVentaRelacion").ToString().ToEntero() - ImporteRelacion = DbRowVenta("ImporteRelacion").ToString().ToDouble - - DdlMoneda.SelectedValue = DbRowVenta("CveMoneda").ToString() - CambiaMoneda() - - If DbRowVenta("TipoDocto").ToString() = "Ped" Then - 'CANTIDAD FACTURADA - If TmpDT.SUM("CantidadFacturadaPed2") > 0 Then - GvPS.Columns(7).Visible = True - ThCantidadFacturada.Visible = True - ThCantidadFacturada2.Visible = True - Else - GvPS.Columns(7).Visible = False - ThCantidadFacturada.Visible = False - ThCantidadFacturada2.Visible = False - End If - - ''ACTIVA EDITAR - ''SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA - 'If (UsuarioActual.CveUsuario = DbRowVenta("CveUsuario").ToString().ToEntero() Or UsuarioActual.CveVendedor = DdlVendedor.SelectedValue.ToEntero()) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") - ' BtnPermisoEditarCotizacion.Visible = True - 'End If - - 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - 'If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then - ' BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) - ' BtnsFacturar.Visible = True - 'End If - ElseIf DbRowVenta("TipoDocto").ToString() = "Cot" AndAlso CveCotizacion > 0 Then - CveEstatusCotizacion = DbRowVenta("CveEstatusFactura").ToString().ToEntero() - End If - - - If CveEmpresaCRM > 0 And Not CveCliente > 0 Then - CargaEmpresaCRM(CveEmpresaCRM) - Else - CveEmpresaCRM = IIf(CveEmpresaCRM > 0, CveEmpresaCRM, 0).ToString().ToEntero() - CargaCliente(CveCliente, -1) 'Estatus activo, se requiere para cargar una factura en la que el cliente a sido eliminado - End If - - ViewState("CveAlmacenTransitorio") = DbRowVenta("CveAlmacenTraspasoDestino").ToString().ToEntero() - DevolucionAlmacen = DbRowVenta("EsDevolucionVenta").ToString().ToEntero() - - 'sino esta cargada la información del metodo de pago que le corresponde, la recarga para que se le pueda asignar - If DdlMetodoPago33.SelectedValue <> DbRowVenta("CveMetodoPago33").ToString() Then - CargaFormaPago(DbRowVenta("CveMetodoPago33").ToString().ToEntero()) - End If - DdlMetodoPago33.SelectedValueExist(DbRowVenta("CveMetodoPago33").ToString()) - DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString().ToEntero()) - - Me.CveMetodoPago33Venta = DbRowVenta("CveMetodoPago33").ToString().ToEntero() - Me.CveFormaPago33Venta = DbRowVenta("CveFormaPago33").ToString().ToEntero() - Me.CveVendedorVenta = DbRowVenta("CveVendedor").ToString().ToEntero() - - 'SI YA TIENE UN VALOR ASIGNADO SELECCIONA EL GUARDADO - 'If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Me.CveVenta > 0 AndAlso Me.CveVendedorVenta > 0 Then - ' Dim Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=1).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta)) - ' 'SI NO ENCUENTRA BUSCA EN LOS VENDEDORES DEL PV - ' If String.IsNullOrEmpty(Vendedor) Then - ' Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=4).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta)) - ' End If - ' DdlVendedor.SelectedValueExistInsert(Me.CveVendedorVenta, Vendedor) - 'End If - - If DdlFormaPago33.SelectedValue <> DbRowVenta("CveFormaPago33").ToString() And DbRowVenta("CveFormaPago33").ToString() <> "" Then - 'sino está seleccionada la asginada la debe de cargar - Dim Nombre As String = GlobalDTVtaFormaPago().FiltroPrimeroValor("FormaPagoSAT", String.Format("CveFormaPago={0}", DbRowVenta("CveFormaPago33"))) - DdlFormaPago33.Items.Add(New ListItem(Nombre, DbRowVenta("CveFormaPago33").ToString())) - DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString().ToEntero()) - End If - - If DbRowVenta("CveUsoCFDI").ToString().ToEntero() > 0 Then - Dim UsoCFDI As String = GlobalDTSATUsosCFDI().FiltroPrimeroValor("UsoCFDIDescripcion", $"CveUsoCFDI={DbRowVenta("CveUsoCFDI").ToString()}") - DdlUsoCFDI.SelectedValueExistInsert(DbRowVenta("CveUsoCFDI").ToString(), UsoCFDI) - End If - - - If UsuarioActual.CveEmpresa = 126 Then CargaOrdenProduccion(2, CveVenta) - - If DbRowVenta("CveTipoRelacion").ToString().ToEntero() > 0 Then - TrTipoRelacion.Visible = True - DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion").ToString().ToEntero()) - - 'RELACIONAR ANTICIPOS APLICADOS - If DbRowVenta("CveTipoRelacion").ToString().ToEntero() = 7 AndAlso DtAntRelacionados IsNot Nothing AndAlso DtAntRelacionados.Rows.Count > 0 Then - DdlTipoRelacionAnticipo.SelectedValueExist(7) - ListaAnticiposAplicados = New List(Of Modelos.MAnticipoRelacionado)() - For Each RowAnt As DataRow In DtAntRelacionados.Rows - ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = RowAnt("CveVentaRelacionada").ToString().ToEntero(), .FolioFiscal = RowAnt("FolioFiscal").ToString()}) - Next - Else - HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - End If - End If - - If DbRowVenta("Saldo").ToString().ToDouble < 0.01 Then - If ViewState("CveCotizacion") IsNot Nothing AndAlso ViewState("CveCotizacion").ToString().ToEntero() > 0 AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then - ImgAntiPend.Visible = True - Else - ImgAntiPend.Visible = False - End If - ElseIf Opcion <> "Op" Then - ImgAntiPend.Visible = True - End If - If UsuarioActual.CveRol.Contiene(1, 1155) Then LiLnkGuias.Visible = True - - LiComplementoPago.Visible = True - - - ViewState("FolioFiscal") = DbRowVenta("FolioFiscal").ToString() - - SerieVenta = DbRowVenta("Serie").ToString() - LblSerie.Text = SerieVenta - ViewState("Serie") = DbRowVenta("Serie").ToString() - ViewState("Folio") = DbRowVenta("Folio").ToString().ToEntero() - TxtFolio.Text = DbRowVenta("Folio").ToString() - 'TxtDocto.Text = DbRowVenta("Ref").ToString() - 'TxtNumCtaPago.Text = DbRowVenta("NumeroCuenta").ToString() - LblFolioFiscal.Text = DbRowVenta("FolioFiscal").ToString() - TxtFecha.Text = DbRowVenta("Fecha").ToString() - TxtSubTotal.Text = DbRowVenta("SubTotal").ToString().FormatoNumero(2) - LblDescuentos.Text = DbRowVenta("Descuento").ToString().FormatoNumero(2) - LblAmortizacion.Text = DbRowVenta("Amortizacion").ToString().FormatoNumero(2) - TxtSubTotal2.Text = (TxtSubTotal.Text.Replace(",", "").Trim.Trim.ToDouble - LblDescuentos.Text.Replace(",", "").Trim.Trim.ToDouble - LblAmortizacion.Text.Replace(",", "").Trim.Trim.ToDouble).FormatoNumero(2) - TxtIVA.Text = DbRowVenta("IVA").ToString().FormatoNumero(2) - TxtRetIVA.Text = DbRowVenta("RetIVA").ToString().FormatoNumero(2) - TxtCorreoNotificaciones.Text = DbRowVenta("CorreoNotificacion").ToString() - - If TxtRetIVA.Text.ToDecimal() > 0 Then - TrRetIVA.Style.Add("display", "") - UsuarioActual.Empresa.MostrarRetIVA = True - If DdlTipoRetencion.SelectedValue.ToEntero() > 0 Then - DdlTipoRetencion.Visible = True - End If - If TmpDT IsNot Nothing Then - Dim PorcentajeRetIVA As Decimal = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100) - LblRetIVA.Text = PorcentajeRetIVA.FormatoNumero(2) - End If - - End If - TxtRetISR.Text = DbRowVenta("RetISR").ToString().FormatoNumero(2) - TxtIEPS.Text = DbRowVenta("IEPS").ToString().FormatoNumero(2) - TrIEPS.Visible = TxtIEPS.Text.ToDouble > 0 - TxtTotal.Text = DbRowVenta("Total").ToString().FormatoNumero(2) - HdnTotalVenta.Value = DbRowVenta("Total").ToString().FormatoNumero(2) - TxtMotivoDescuento.Text = DbRowVenta("MotivoDescuento").ToString() - TxtObsFact.Text = DbRowVenta("Observaciones").ToString() - LblUsuario.Text = DbRowVenta("Nombre").ToString().SubStringADS(30) - LblFechaRegistro.Text = DbRowVenta("FechaIng").ToString().ToDate.ToShortDateString - LblSeTimbro.Text = DbRowVenta("SeTimbro").ToString() - LblMail.Text = DbRowVenta("EnvioMail").ToString() - TxtFechaPago.Text = DbRowVenta("FechaVencimiento").ToString() - TxtFechaVencimientoCotizacion.Text = Vigencia - TxtDet_OrdenCompra.Text = DbRowVenta("Det_OrdenCompra").ToString() - TxtDet_FechaOrdenCompra.Text = DbRowVenta("Det_FechaOrdenCompra").ToString() - HdnIVAOriginal.Value = TxtIVA.Text - TxtPedidoContrato.Text = DbRowVenta("PedidoContrato").ToString() - TxtPedidoContrato.Enabled = False - TxtKilometraje.Text = DbRowVenta("Kilometraje").ToString().PadLeft(6, "0"c) - - - VentaActual = New Venta(UsuarioActual) - VentaActual.CveVenta = CveVenta - VentaActual.Fecha = DbRowVenta("Fecha").ToString.ToDate - VentaActual.CveCliente = DbRowVenta("CveCliente").ToString.ToEntero - VentaActual.CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero - VentaActual.SerieFolio = DbRowVenta("SerieFolio").ToString - VentaActual.ClienteNombre = DbRowVenta("ClienteNombre").ToString - VentaActual.TC = DbRowVenta("TipoCambio").ToString.ToDecimal - VentaActual.Total = DbRowVenta("Total").ToString.ToDecimal - VentaActual.IVA = DbRowVenta("IVA").ToString.ToDecimal - VentaActual.IEPS = DbRowVenta("IEPS").ToString.ToDecimal - VentaActual.RetIVA = DbRowVenta("RetIVA").ToString.ToDecimal - VentaActual.RetISR = DbRowVenta("RetISR").ToString.ToDecimal - - VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal - VentaActual.UsuarioActual = UsuarioActual - VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero - - HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString() - HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2) - 'DdlAmortizacionConceptos.SelectedValue = DbRowVenta("AnticipoPosicion").ToString() - 'ChkAnticipoEnSubTotal.Checked = DbRowVenta("AnticipoEnSubTotal").ToString() = "True" - DdlTipoAmortizacionAnticipo.SelectedValueExist(DbRowVenta("CveTipoAmortizacionAnticipo")) - DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion")) - - 'Si es AMORTIZACIÓN ANTICIPO SOBRE FACTURA EN CERO no debe timbrar - If DbRowVenta("CveTipoAmortizacionAnticipo").ToString().ToEntero() = 3 Then - BtnEmitir.Visible = False - End If - - 'HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString() - 'HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2) - 'DdlAmortizacionConceptos.SelectedValue = DbRowVenta("AnticipoPosicion").ToString() - 'ChkAnticipoEnSubTotal.Checked = DbRowVenta("AnticipoEnSubTotal").ToString() = "True" - - - If DbRowVenta("CveTipoRelacion").ToString().ToEntero() > 0 Then - TrTipoRelacion2.Visible = True - LblTipoRelacion.Text = DbRowVenta("TipoRelacion").ToString() - HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() - End If - - - TxtOrdenCompra.Text = DbRowVenta("OrdenCompra").ToString() - TxtOrdenCompra.Enabled = False - - TxtObsAlmacen.Text = DbRowVenta("ObservacionesAlmacen").ToString() - CvePAC = DbRowVenta("CvePAC").ToString().ToEntero() - - If DbRowVenta("Saldo").ToString().ToDecimal > 0 AndAlso UsuarioActual.TienePermisoProceso(204) AndAlso Not UsuarioActual.CveEmpresa.Contiene(119) Then - TxtFechaSaldarVenta.Text = TxtFecha.Text - CEFechaSaldarVenta.StartDate = TxtFecha.Text.ToDate - HLSaldarVenta.Visible = True - End If - - - If (UsuarioActual.TienePermisoProceso(166) Or UsuarioActual.CveRol = 1) AndAlso (LblFolioFiscal.Text = "" Or LblFolioFiscal.Text = "test") Then - LkEliminarFactura.Visible = True - End If - If (UsuarioActual.CveRol = 1) AndAlso (LblFolioFiscal.Text <> "") Then - LnkUUIDRelacionados.Visible = True - End If - - 'Envio Direccion - If DbRowVenta("CveDireccionEnvio").ToString().ToEntero() > 0 AndAlso DbRowVenta("CveDireccionEnvio").ToString() IsNot Nothing Then - ChkDireccionEnvio.Checked = True - DdlDireccionEnvio.SelectedValueExist(DbRowVenta("CveDireccionEnvio").ToString().ToEntero()) - 'DdlDireccionEnvio_SelectedIndexChanged(DdlDireccionEnvio, EventArgs.Empty) - DdlDireccionEnvio.Enabled = False - ChkDireccionEnvio.Enabled = False - DdlDireccionEnvio.Visible = True - trDireccionEnvio.Visible = True - End If - If UsuarioActual.TienePermisoProceso(333) Then LnkEditarDir.Visible = True - - 'ESTATUS FACTURA - If Not (CveRemision > 0 Or CveCotizacion > 0) Then - CveEstatus = DbRowVenta("CveEstatusFactura").ToString().ToEntero() - End If - - TxtTipoCambio.Text = DbRowVenta("TipoCambio").ToString() - If DbRowVenta("UltimasFluctuaciones").ToString() <> "" Then - LblTCValuacion.Text = String.Format("Ult. Val:{0}", DbRowVenta("UltimasFluctuaciones").ToString()) - LblTCValuacion.Visible = True - End If - - ViewState("SelloCancelacion") = DbRowVenta("SelloCancelacion").ToString() - ViewState("FechaCancelacion") = DbRowVenta("FechaCancelacion").ToString().ToDateTime - TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() - TxtTelefonoGenerico.Text = DbRowVenta("TelefonoGenerico").ToString() - CveVentaPadre = DbRowVenta("CveVentaPadre").ToString().ToEntero() - SerieFolioPadre = DbRowVenta("SerieFolioPadre").ToString() - - If DdlVendedor.SelectedValue.ToEntero() > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then - DdlVendedor.Enabled = False - End If - - 'PERMITIR EDITAR EL VENDEDOR ANTES DE FACTURAR - If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso TmpDT IsNot Nothing AndAlso TmpDT.SUM("CantidadFacturadaCot") = 0) Then - DdlVendedor.Enabled = True - End If - - If CveVentaPadre > 0 Then - If IsNothing(Request("CveDevolucion")) AndAlso IsNumeric(Request("CveDevolucion")) Then - DdlNCFactura.Visible = True - Else - DdlNCFactura.Visible = False - End If - trNCFactura.Visible = True - LblSerieFolioPadre.Visible = True - LblSerieFolioPadre.Text = String.Format("{1}", CveVentaPadre, SerieFolioPadre) - - End If - - If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso DbRowVenta("CveProcedimiento").ToString.ToEntero > 0 Then - TxtFechaEjecucion.Text = DbRowVenta("FechaEjecucion").ToString().ToDateTime.ToString("dd/MM/yyyy HH:mm") - DVMEEFechaEje.Visible = False - Else - TxtFechaEjecucion.Text = DbRowVenta("FechaEjecucion").ToString().ToDateTime.ToString("dd/MM/yyyy") - End If - - 'DdlSucursalEjecucion.SelectedValueExist(DbRowVenta("CveSucursalEjecucion").ToString()) - 'DdlSucursalCobranza.SelectedValueExist(DbRowVenta("CveSucursalCobranza").ToString()) - DdlSucursalCliente.SelectedValueExist(DbRowVenta("CveClienteSucursal").ToString()) - 'DdlSucursal.SelectedValueExist(DbRowVenta("CveSucursal").ToString()) - 'DdlSubProyectoDatos.SelectedValueExist(DbRowVenta("CveSubProyecto").ToString()) - - If DdlSubProyectoDatos.Items.Count = 0 Then - DdlSubProyectoDatos.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - DdlSubProyectoDatos.SelectedValueExistInsert(DbRowVenta("CveSubProyecto").ToString(), DbRowVenta("SubProyecto").ToString()) - DdlSubProyecto.SelectedValueExist(DbRowVenta("CveSubProyecto").ToString()) - - CargarAlmacenes() - - If DdlSubProyectoCobranza.Items.Count = 0 Then - DdlSubProyectoCobranza.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - DdlSubProyectoCobranza.SelectedValueExistInsert(DbRowVenta("CveSubProyectoCobranza").ToString(), GlobalDTSubProyectos(-1, DbRowVenta("CveSubProyectoCobranza").ToString().ToEntero()).FiltroPrimeroValor("SubProyecto").ToString()) - - If DdlSubProyectoEjecucion.Items.Count = 0 Then - DdlSubProyectoEjecucion.Items.Insert(0, New ListItem("Seleccione", "-1")) - End If - DdlSubProyectoEjecucion.SelectedValueExistInsert(DbRowVenta("CveSubProyectoEjecucion").ToString(), GlobalDTSubProyectos(-1, DbRowVenta("CveSubProyectoEjecucion").ToString().ToEntero()).FiltroPrimeroValor("SubProyecto").ToString()) - - CargaClienteSucursal(DbRowVenta("CveClienteSucursal").ToString().ToEntero()) - - If DbRowVenta("CveContrato").ToString().ToEntero() > 0 Then - CveContrato = DbRowVenta("CveContrato").ToString().ToEntero() - NumeroContrato = DbRowVenta("NumeroContrato").ToString() - DescripcionContrato = DbRowVenta("DescripcionContrato").ToString() - DdlContrato.Visible = False - HLContrato.Text = $"{DbRowVenta("NumeroContrato")} - {DbRowVenta("DescripcionContrato")}" - HLContrato.NavigateUrl = $"/Contratos/Contrato.aspx?CveContrato={CveContrato}" - 'trPresupuesto.Visible = True - 'HplPresupuesto.NavigateUrl = String.Format(" / Presupuestos / Presupuesto.aspx?CvePresupuesto={0}", DbRowVenta("CveContrato").ToString()) - Else - NumeroContrato = "" - DescripcionContrato = "" - End If - - 'DdlEstatus.Items.Remove(DdlEstatus.Items.FindByText("Cotización")) - - If DbRowVenta("SeTimbro").ToString() <> "No" Then - HplDownXML.Visible = True - 'If HLImprimir.Visible = False Then - HplDownPDF.Visible = True - 'End If - ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" OrElse DdlTipoComprobante.SelectedValue = "Cot" Then - 'If drv("TipoEstatus").ToString().ToEntero() = 2 AndAlso drv("TipoDocto").ToString() = "Cot" Then - ' ImgDownPDF.Visible = True - 'Else - HplDownPDF.Visible = False - 'End If - ElseIf UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso DbRowVenta("SeTimbro").ToString() = "No" AndAlso DbRowVenta("CveEstatusFactura").ToString() = "2" AndAlso DbRowVenta("TipoDocto").ToString().Contiene("Ing", "Egs", "Dev", "Ant") Then - TrEmitir.Visible = True - If TxtFecha.Text.ToDate < NowADS().AddDays(-3) Then - TxtFecha.Enabled = True - End If - End If - - 'NO DEBE IMPRIMIR PDF DE COTIZACION - If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DbRowVenta("TipoDocto").ToString() = "Cot" Then - HplDownPDF.Visible = False - End If - - If DbRowVenta("SeTimbro").ToString() = "Si" Then - TrEmitir.Visible = False - End If - - 'CargaAcuseCancelacion - If DbRowVenta("CveEstatusFactura").ToString().Contiene("5", "20") Then - ImgDownCancelacion.Visible = True - ImgDownCancelacion.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CAN&CVEVTA={0}", CveVenta))) - End If - IdPoliza = DbRowVenta("IdPoliza").ToString().ToEntero() - - 'Carga si es Contabilizada - If IdPoliza > 0 Then - HLContabilizada.Text = "Si" - HLContabilizada.NavigateUrl = $"/Contabilidad/RegPoliza.aspx?IdPoliza={DbRowVenta("IdPoliza")}" - trContabilizada.Visible = True - If UsuarioActual.TienePermisoProceso(107) Then BtnDescontabilizar.Visible = True - - Else - 'cuando no este contabilizada y usa AC, habilita el boton para generar la poliza - If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC AndAlso UsuarioActual.CveRol = 1 Then - BtnGenerarPoliza.Visible = True - End If - If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then - BtnContabilizar.Visible = True - End If - End If - - If DbRowVenta("IdPolizaCancelacion").ToString().ToEntero() > 0 Then - HPLContaCancelacion.Text = "Cancelación" - HPLContaCancelacion.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", DbRowVenta("IdPolizaCancelacion")) - trContabilizada.Visible = True - End If - - - If UsuarioActual.Empresa.UsaOS AndAlso DbRowVenta("CveOS").ToString().ToEntero() = 0 Then - BtnGenerarOS.Visible = True - BtnGenerarOS.OnClientClick = String.Format("javascriptwindow.location.href = '/OS/OrdenesServicios.aspx?CveVenta={0}'; return false;", CveVenta) - ' BtnGenerarOS.OnClientClick = String.Format("/OS/OrdenesServicios.aspx?CveVenta={0}", CveVenta) - End If - - - '[IPP] COMENTADO 12/MARZO/2018 -SABRA QUE SE QUERIA ESCONDER - 'If DbRowVenta("TipoDocto").ToString() = "Rem" Then - ' GvPS.Columns(11).Visible = False - ' GvPS.Columns(12).Visible = False - 'End If - - - 'Ocultamos los botones Clonar y Ordenar - GvPS.Columns(19).Visible = False - GvPS.Columns(20).Visible = False - - GvFirmas.DataSource = DTmpF - GvFirmas.DataBind() - - If TmpDTImpuestos IsNot Nothing AndAlso TmpDTImpuestos.Rows.Count > 0 Then - TrOtros.Visible = True - GvImpuestosLocales2.DataSource = TmpDTImpuestos - GvImpuestosLocales2.DataBind() - - GvImpuestosLocales2.Enabled = False - GvImpuestosLocales2.Visible = True - End If - - DdlVendedor.SelectedValue = If(DbRowVenta("CveVendedor").ToString = "", "0", DbRowVenta("CveVendedor").ToString) 'si viene dbnull, que ponga cero. - DdlTipoComprobante.Enabled = False - 'TxtDocto.Enabled = False - - 'PORLET CLIENTE - 'DESACTIVA CAMBIO DE CLIENTE - HlCliente.Attributes.Remove("class") - HlCliente.Attributes.Add("class", "Texto disabled") - TxtCodigo.ReadOnly = True - ChkEnviarFactura.Enabled = False - ChkDireccionEnvio.Enabled = False - TxtAtencionA.Enabled = False - TxtFechaVencimientoCotizacion.Enabled = False - - TxtCantidad.Enabled = False - DdlClasificacion.Enabled = False - - DdlPS.Enabled = False - TxtObsPS.Enabled = False - DdlProyecto.Enabled = False - DdlSubProyecto.Enabled = False - TxtPrecio.Enabled = False - ImgDescPU.Attributes.Clear() - ImgDescTotal.Attributes.Clear() - ImgDescConcepto.Attributes.Clear() - LbAgregar.Enabled = False - DdlCuentasTerminal.Enabled = False - - For Each Row As GridViewRow In GvPS.Rows - Row.FCLiteral("LtlConsecutivo").Text = (Row.RowIndex + 1).ToString() - Next - GvPS.Columns(ColumnaEditar).HeaderText = "" - GvPS.Columns(ColumnaEliminar).HeaderText = "" - 'GvPS.Columns(ColumnaEliminar).Visible = False - - TxtObsFact.Enabled = False - TxtObsAlmacen.Enabled = False - TxtMotivoDescuento.Enabled = False - 'GvLeyendasFiscales.Enabled = False - TxtSubTotal.ReadOnly = True - TxtIVA.ReadOnly = True - TxtRetIVA.ReadOnly = True - TxtRetISR.ReadOnly = True - TxtIEPS.ReadOnly = True - TxtTotal.ReadOnly = True - - 'Sección Detalle - DdlMoneda.Enabled = False - DdlTipoRetencion.Enabled = False - TxtFechaEjecucion.ReadOnly = True - ImgCalendarFechaEje.Enabled = False - 'DdlSucursalEjecucion.Enabled = False - 'DdlSucursalCobranza.Enabled = False - DdlVendedor.Enabled = False - 'PERMITIR EDITAR EL VENDEDOR ANTES DE FACTURAR - If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso TmpDT IsNot Nothing AndAlso TmpDT.SUM("CantidadFacturadaCot") = 0) Then - DdlVendedor.Enabled = True - End If - DdlSucursalCliente.Enabled = False - TxtTiempoEntrega.Enabled = False - TxtAlfa1.ReadOnly = True - TxtAlfa2.ReadOnly = True - TxtAlfa3.ReadOnly = True - TxtNum1.ReadOnly = True - TxtNum2.ReadOnly = True - TxtNum3.ReadOnly = True - TxtFech1.ReadOnly = True : ImgFech1.Enabled = False - TxtFech2.ReadOnly = True : ImgFech2.Enabled = False - TxtFech3.ReadOnly = True : ImgFech3.Enabled = False - ChkConvertirDoctoPesos.Enabled = False - ChkConvertirDolares.Enabled = False - - TxtTipoCambio.Enabled = UsuarioActual.CveEmpresa.Contiene(13, 83) - TxtTipoCambioDlls.Enabled = UsuarioActual.CveEmpresa.Contiene(13, 83) - TxtTipoCambio.ReadOnly = Not UsuarioActual.CveEmpresa.Contiene(13, 83) - TxtTipoCambioDlls.ReadOnly = Not UsuarioActual.CveEmpresa.Contiene(13, 83) - - 'Condiciones de Pago - RBLPago.Enabled = False - DdlFormaPago33.Enabled = False - DdlUsoCFDI.Enabled = False - DdlMetodoPago33.Enabled = False - 'TxtNumCtaPago.Enabled = False - If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") Then - TxtFechaPago.ReadOnly = Not UsuarioActual.TienePermisoProceso(260) - LnkUpdateFechaVencimiento.Visible = UsuarioActual.TienePermisoProceso(260) - Else - TxtFechaPago.ReadOnly = False - End If - - imgCalendario.Enabled = False - DdlFuenteRecaudacion.Enabled = False - - TrVistaPrevia.Visible = False - BtnEmitirImprimir.Visible = False - 'CargaLeyendasFiscales - ViewState("VentaFolio") = If(LblSerie.Text.Trim.Length = 0, TxtFolio.Text.Trim, LblSerie.Text.Trim & "-" & TxtFolio.Text.Trim) - - CalculaTotalesVenta(False) - - 'JJMQ 20160506: Se agrego para la validacion de pago de contado. - 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") - - tdVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") - tdFechaVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") - - If DbRowVenta("TipoDocto").ToString() = "Rem" Then - 'CANTIDAD FACTURADA - If TmpDT.SUM("CantidadFacturadaRem") > 0 Then - GvPS.Columns(6).Visible = True - ThCantidadFacturadaRem.Visible = True - ThCantidadFacturadaRem2.Visible = True - Else - GvPS.Columns(6).Visible = False - ThCantidadFacturadaRem.Visible = False - ThCantidadFacturadaRem2.Visible = False - End If - - 'ACTIVA EDITAR - 'SOLO LA PUEDE EDITAR CON PROCESO | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - If UsuarioActual.TienePermisoProceso(202) And TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad") Then - BtnPermisoEditarRemision.Visible = True - End If - - 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - If TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad") Then - BtnsFacturar.Visible = True - - 'E119, bloquear la facturación de remisiones que no estén surtidas - If UsuarioActual.CveEmpresa = 119 Then - If TmpDT.SUM("Cantidad") <> TmpDT.SUM("CantidadInventario") Then 'que ya esté surtida totalmente - BtnsFacturar.Visible = False - End If End If - LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) - 'ACTIVA CONVERSION DE MONEDA - If DdlMoneda.SelectedValue.ToEntero() = 1 Then - TrConversionDolares.Visible = True - ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) - TxtTipoCambioDlls.Enabled = True + If UsuarioActual.Empresa.Funcionalidad(109) = "1" Then + TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() + End If + + DdlTipoRelacionARelacionar.SelectedValueExist(DbRowVenta("CveTipoRelacion").ToString()) + + 'contado 0, credito 1, terminal 2 + If DbRowVenta("CondicionesPago").ToString().ToEntero() = 1 Then + RBLPago.SelectedValue = "1" + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() + ElseIf DbRowVenta("CondicionesPago").ToString().ToEntero() = 0 Then + RBLPago.SelectedValue = "2" + RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() Else - TrConversionTipoCambio.Visible = True - ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) - TxtTipoCambio.Enabled = True + DdlCuentasTerminal.SelectedValue = DbRowVenta("CveCuentaTerminal").ToString() + RBLPago.SelectedValue = "3" + RBLPago.Items(0).Enabled = False + RBLPago_SelectedIndexChanged(Nothing, Nothing) + UPCondicionesPago.Update() End If - If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then - TrVistaPrevia.Visible = True + + 'ESCONDE ACCIONES + LnkRemisiones.Visible = False + LnkPedido2SinFacturar.Visible = False + LnkCotizaciones.Visible = False + LnkOCs.Visible = False + UpnTools.Update() + + DivEstatusFac.Visible = True + HdnCveCliente.Value = CveCliente.ToString() + ViewState("CveCliente") = CveCliente + ViewState("CveEmpresaCRM") = DbRowVenta("CveEmpresaCRM").ToString().ToEntero() + ViewState("CveAcercamientoCRM") = DbRowVenta("CveAcercamientoCRM").ToString().ToEntero() + Entrega = DbRowVenta("Entrega").ToString() + Vigencia = DbRowVenta("Vigencia").ToString().ToDate.ToShortDateString + HplSaldoAuxiliar.Text = DbRowVenta("Saldo").ToString().FormatoNumero(2) + If Not HplSaldoAuxiliar.Text.ToDouble > 0 Then + HplSaldoAuxiliar.Visible = False + HplPagado.Visible = True + Dim EsCancelado As Boolean = GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {CveEstatus}").ToEntero() = 5 + If EsCancelado Then + HplPagado.Text = "CANCELADO" + End If + If ViewState("CveCotizacion") IsNot Nothing AndAlso ViewState("CveCotizacion").ToString().ToEntero() > 0 AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then + ImgAntiPend.Visible = True + Else + ImgAntiPend.Visible = False + End If + End If - End If + HdnPagado.Value = DbRowVenta("Pagado").ToString() + TxtTotal.Text = DbRowVenta("Total").ToString().FormatoNumero(2) + HdnVentaSaldo.Value = (SaldoVenta).ToString() + CvePrePoliza = DbRowVenta("CvePrePoliza").ToString().ToEntero() + CveVentaFacturada = DbRowVenta("CveVentaFacturada").ToString().ToEntero() - 'Si es Empresa de Acumuladores - If CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DbRowVenta("TipoDocto").ToString() = "Rem" AndAlso (GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() <> 5) Then + CveVentaRelacion = DbRowVenta("CveVentaRelacion").ToString().ToEntero() + ImporteRelacion = DbRowVenta("ImporteRelacion").ToString().ToDouble - BtnsFacturar.Visible = False + DdlMoneda.SelectedValue = DbRowVenta("CveMoneda").ToString() + CambiaMoneda() - Dim DtUsadosPendientes As DataTable = Nothing - Dim DtGarantiasPendientes As DataTable = Nothing + If DbRowVenta("TipoDocto").ToString() = "Ped" Then + 'CANTIDAD FACTURADA + If TmpDT.SUM("CantidadFacturadaPed2") > 0 Then + GvPS.Columns(7).Visible = True + ThCantidadFacturada.Visible = True + ThCantidadFacturada2.Visible = True + Else + GvPS.Columns(7).Visible = False + ThCantidadFacturada.Visible = False + ThCantidadFacturada2.Visible = False + End If - Dim ObjUsados As New ClsVentas + ''ACTIVA EDITAR + ''SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA + 'If (UsuarioActual.CveUsuario = DbRowVenta("CveUsuario").ToString().ToEntero() Or UsuarioActual.CveVendedor = DdlVendedor.SelectedValue.ToEntero()) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") + ' BtnPermisoEditarCotizacion.Visible = True + 'End If - If ObjUsados.GetVentasUsados(CveVenta, -1, DbRowVenta("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then - DtUsadosPendientes = ObjUsados.DtResultados.Copy() + 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + 'If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then + ' BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) + ' BtnsFacturar.Visible = True + 'End If + ElseIf DbRowVenta("TipoDocto").ToString() = "Cot" AndAlso CveCotizacion > 0 Then + CveEstatusCotizacion = DbRowVenta("CveEstatusFactura").ToString().ToEntero() End If - If ObjUsados.GetVentasGarantiaPendiente(CveVenta, NowADS(), UsuarioActual.CveEmpresa) Then - DtGarantiasPendientes = ObjUsados.DtResultados.Copy() + + If CveEmpresaCRM > 0 And Not CveCliente > 0 Then + CargaEmpresaCRM(CveEmpresaCRM) + Else + CveEmpresaCRM = IIf(CveEmpresaCRM > 0, CveEmpresaCRM, 0).ToString().ToEntero() + CargaCliente(CveCliente, -1) 'Estatus activo, se requiere para cargar una factura en la que el cliente a sido eliminado End If - 'If ObjUsados.GetVentasGarantiaPendiente(CveVenta, -1, NowADS(), UsuarioActual.CveEmpresa) Then - ' DtGarantiasPendientes = ObjUsados.DtResultados.Copy() + ViewState("CveAlmacenTransitorio") = DbRowVenta("CveAlmacenTraspasoDestino").ToString().ToEntero() + DevolucionAlmacen = DbRowVenta("EsDevolucionVenta").ToString().ToEntero() + + 'sino esta cargada la información del metodo de pago que le corresponde, la recarga para que se le pueda asignar + If DdlMetodoPago33.SelectedValue <> DbRowVenta("CveMetodoPago33").ToString() Then + CargaFormaPago(DbRowVenta("CveMetodoPago33").ToString().ToEntero()) + End If + DdlMetodoPago33.SelectedValueExist(DbRowVenta("CveMetodoPago33").ToString()) + DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString().ToEntero()) + + Me.CveMetodoPago33Venta = DbRowVenta("CveMetodoPago33").ToString().ToEntero() + Me.CveFormaPago33Venta = DbRowVenta("CveFormaPago33").ToString().ToEntero() + Me.CveVendedorVenta = DbRowVenta("CveVendedor").ToString().ToEntero() + + 'SI YA TIENE UN VALOR ASIGNADO SELECCIONA EL GUARDADO + 'If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Me.CveVenta > 0 AndAlso Me.CveVendedorVenta > 0 Then + ' Dim Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=1).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta)) + ' 'SI NO ENCUENTRA BUSCA EN LOS VENDEDORES DEL PV + ' If String.IsNullOrEmpty(Vendedor) Then + ' Vendedor = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=4).FiltroPrimeroValor("Vendedor", String.Format("CveVendedor = {0}", Me.CveVendedorVenta)) + ' End If + ' DdlVendedor.SelectedValueExistInsert(Me.CveVendedorVenta, Vendedor) 'End If - ObjUsados.Dispose() - - BtnsFacturar.Visible = True - - 'VERIFICA SI YA SE FACTURO COMPLETAMENTE - If TmpDT.SUM("CantidadFacturadaRem") = TmpDT.SUM("Cantidad") Then - BtnsFacturar.Visible = False + If DdlFormaPago33.SelectedValue <> DbRowVenta("CveFormaPago33").ToString() And DbRowVenta("CveFormaPago33").ToString() <> "" Then + 'sino está seleccionada la asginada la debe de cargar + Dim Nombre As String = GlobalDTVtaFormaPago().FiltroPrimeroValor("FormaPagoSAT", String.Format("CveFormaPago={0}", DbRowVenta("CveFormaPago33"))) + DdlFormaPago33.Items.Add(New ListItem(Nombre, DbRowVenta("CveFormaPago33").ToString())) + DdlFormaPago33.SelectedValueExist(DbRowVenta("CveFormaPago33").ToString().ToEntero()) End If - 'VERIFICA SI TIENE USADOS O GARANTIAS PENDIENTES - If BtnsFacturar.Visible Then - If (Not EsGarantia AndAlso (DtUsadosPendientes IsNot Nothing AndAlso DtUsadosPendientes.Rows.Count > 0)) Then - BtnsFacturar.Visible = False - Alert("Tiene usados pendiente de recibir", TipoMensaje.MsgAdvertencia) - End If + If DbRowVenta("CveUsoCFDI").ToString().ToEntero() > 0 Then + Dim UsoCFDI As String = GlobalDTSATUsosCFDI().FiltroPrimeroValor("UsoCFDIDescripcion", $"CveUsoCFDI={DbRowVenta("CveUsoCFDI").ToString()}") + DdlUsoCFDI.SelectedValueExistInsert(DbRowVenta("CveUsoCFDI").ToString(), UsoCFDI) + End If - If (EsGarantia AndAlso (DtGarantiasPendientes IsNot Nothing AndAlso DtGarantiasPendientes.Rows.Count > 0)) Then - Alert("Tiene garantías pendientes de recibir", TipoMensaje.MsgAdvertencia) - BtnsFacturar.Visible = False + + If UsuarioActual.CveEmpresa = 126 Then CargaOrdenProduccion(2, CveVenta) + + If DbRowVenta("CveTipoRelacion").ToString().ToEntero() > 0 Then + TrTipoRelacion.Visible = True + DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion").ToString().ToEntero()) + + 'RELACIONAR ANTICIPOS APLICADOS + If DbRowVenta("CveTipoRelacion").ToString().ToEntero() = 7 AndAlso DtAntRelacionados IsNot Nothing AndAlso DtAntRelacionados.Rows.Count > 0 Then + DdlTipoRelacionAnticipo.SelectedValueExist(7) + ListaAnticiposAplicados = New List(Of Modelos.MAnticipoRelacionado)() + For Each RowAnt As DataRow In DtAntRelacionados.Rows + ListaAnticiposAplicados.Add(New Modelos.MAnticipoRelacionado() With {.CveVenta = RowAnt("CveVentaRelacionada").ToString().ToEntero(), .FolioFiscal = RowAnt("FolioFiscal").ToString()}) + Next + Else + HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() End If End If - - LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) - End If - - 'SI ES COMPLEMENTARIA, NO DEBE PERMITIR FACTURAR - If UsuarioActual.Empresa.Funcionalidad(706) = "1" AndAlso DbRowVenta("TipoContable").ToString() <> "-1" Then - If DbRowVenta("TipoContable").ToString() = "0" Then - BtnsFacturar.Visible = False - End If - - TrTipoContable.Visible = True - DdlTipoContable.SelectedValueExist(DbRowVenta("TipoContable").ToString()) - DdlTipoContable.Enabled = False - End If - - End If - - If DbRowVenta("TipoDocto").ToString().Contiene("Cot") Then - 'CANTIDAD FACTURADA - If TmpDT.SUM("CantidadFacturadaCot") > 0 Then - GvPS.Columns(7).Visible = True - ThCantidadFacturada.Visible = True - ThCantidadFacturada2.Visible = True - Else - GvPS.Columns(7).Visible = False - ThCantidadFacturada.Visible = False - ThCantidadFacturada2.Visible = False - End If - - 'ACTIVA EDITAR - 'SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA - If (UsuarioActual.CveUsuario = DbRowVenta("CveUsuario").ToString().ToEntero() Or UsuarioActual.CveVendedor = DdlVendedor.SelectedValue.ToEntero()) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") - BtnPermisoEditarCotizacion.Visible = True - End If - - 'SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA - If UsuarioActual.TienePermisoProceso(281) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") - BtnPermisoEditarCotizacion.Visible = True - End If - - 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - VerificarBtnFacturarCotizacion(DbRowVenta("CveVendedor").ToString().ToEntero()) - End If - - - If DbRowVenta("TipoDocto").ToString().Contiene("Ped") Then - 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR - If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then - BtnsFacturar.Visible = True - - 'bloquear la facturación de remisiones que no estén surtidas - If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then - If TmpDT.SUM("Cantidad") <> TmpDT.SUM("CantidadInventario") Then 'que ya esté surtida totalmente - BtnsFacturar.Visible = False + If DbRowVenta("Saldo").ToString().ToDouble < 0.01 Then + If ViewState("CveCotizacion") IsNot Nothing AndAlso ViewState("CveCotizacion").ToString().ToEntero() > 0 AndAlso DdlTipoComprobante.SelectedValue = "Ing" Then + ImgAntiPend.Visible = True + Else + ImgAntiPend.Visible = False End If + ElseIf Opcion <> "Op" Then + ImgAntiPend.Visible = True + End If + If UsuarioActual.CveRol.Contiene(1, 1155) Then LiLnkGuias.Visible = True + + LiComplementoPago.Visible = True + + + ViewState("FolioFiscal") = DbRowVenta("FolioFiscal").ToString() + + SerieVenta = DbRowVenta("Serie").ToString() + LblSerie.Text = SerieVenta + ViewState("Serie") = DbRowVenta("Serie").ToString() + ViewState("Folio") = DbRowVenta("Folio").ToString().ToEntero() + TxtFolio.Text = DbRowVenta("Folio").ToString() + 'TxtDocto.Text = DbRowVenta("Ref").ToString() + 'TxtNumCtaPago.Text = DbRowVenta("NumeroCuenta").ToString() + LblFolioFiscal.Text = DbRowVenta("FolioFiscal").ToString() + TxtFecha.Text = DbRowVenta("Fecha").ToString() + TxtSubTotal.Text = DbRowVenta("SubTotal").ToString().FormatoNumero(2) + LblDescuentos.Text = DbRowVenta("Descuento").ToString().FormatoNumero(2) + LblAmortizacion.Text = DbRowVenta("Amortizacion").ToString().FormatoNumero(2) + TxtSubTotal2.Text = (TxtSubTotal.Text.Replace(",", "").Trim.Trim.ToDouble - LblDescuentos.Text.Replace(",", "").Trim.Trim.ToDouble - LblAmortizacion.Text.Replace(",", "").Trim.Trim.ToDouble).FormatoNumero(2) + TxtIVA.Text = DbRowVenta("IVA").ToString().FormatoNumero(2) + TxtRetIVA.Text = DbRowVenta("RetIVA").ToString().FormatoNumero(2) + TxtCorreoNotificaciones.Text = DbRowVenta("CorreoNotificacion").ToString() + + If TxtRetIVA.Text.ToDecimal() > 0 Then + TrRetIVA.Style.Add("display", "") + UsuarioActual.Empresa.MostrarRetIVA = True + If DdlTipoRetencion.SelectedValue.ToEntero() > 0 Then + DdlTipoRetencion.Visible = True + End If + If TmpDT IsNot Nothing Then + Dim PorcentajeRetIVA As Decimal = (TmpDT.MAX("PorcentajeRetIVA").ToDecimal() * 100) + LblRetIVA.Text = PorcentajeRetIVA.FormatoNumero(2) + End If + + End If + TxtRetISR.Text = DbRowVenta("RetISR").ToString().FormatoNumero(2) + TxtIEPS.Text = DbRowVenta("IEPS").ToString().FormatoNumero(2) + TrIEPS.Visible = TxtIEPS.Text.ToDouble > 0 + TxtTotal.Text = DbRowVenta("Total").ToString().FormatoNumero(2) + HdnTotalVenta.Value = DbRowVenta("Total").ToString().FormatoNumero(2) + TxtMotivoDescuento.Text = DbRowVenta("MotivoDescuento").ToString() + TxtObsFact.Text = DbRowVenta("Observaciones").ToString() + LblUsuario.Text = DbRowVenta("Nombre").ToString().SubStringADS(30) + LblFechaRegistro.Text = DbRowVenta("FechaIng").ToString().ToDate.ToShortDateString + LblSeTimbro.Text = DbRowVenta("SeTimbro").ToString() + LblMail.Text = DbRowVenta("EnvioMail").ToString() + TxtFechaPago.Text = DbRowVenta("FechaVencimiento").ToString() + TxtFechaVencimientoCotizacion.Text = Vigencia + TxtDet_OrdenCompra.Text = DbRowVenta("Det_OrdenCompra").ToString() + TxtDet_FechaOrdenCompra.Text = DbRowVenta("Det_FechaOrdenCompra").ToString() + HdnIVAOriginal.Value = TxtIVA.Text + TxtPedidoContrato.Text = DbRowVenta("PedidoContrato").ToString() + TxtPedidoContrato.Enabled = False + TxtKilometraje.Text = DbRowVenta("Kilometraje").ToString().PadLeft(6, "0"c) + + + VentaActual = New Venta(UsuarioActual) + VentaActual.CveVenta = CveVenta + VentaActual.Fecha = DbRowVenta("Fecha").ToString.ToDate + VentaActual.CveCliente = DbRowVenta("CveCliente").ToString.ToEntero + VentaActual.CveMoneda = DbRowVenta("CveMoneda").ToString.ToEntero + VentaActual.SerieFolio = DbRowVenta("SerieFolio").ToString + VentaActual.ClienteNombre = DbRowVenta("ClienteNombre").ToString + VentaActual.TC = DbRowVenta("TipoCambio").ToString.ToDecimal + VentaActual.Total = DbRowVenta("Total").ToString.ToDecimal + VentaActual.IVA = DbRowVenta("IVA").ToString.ToDecimal + VentaActual.IEPS = DbRowVenta("IEPS").ToString.ToDecimal + VentaActual.RetIVA = DbRowVenta("RetIVA").ToString.ToDecimal + VentaActual.RetISR = DbRowVenta("RetISR").ToString.ToDecimal + + VentaActual.PorcentajeIVA = DbRowVenta("PorcentajeIVA").ToString.ToDecimal + VentaActual.UsuarioActual = UsuarioActual + VentaActual.CveSubProyecto = DbRowVenta("CveSubProyecto").ToString.ToEntero + + HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString() + HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2) + 'DdlAmortizacionConceptos.SelectedValue = DbRowVenta("AnticipoPosicion").ToString() + 'ChkAnticipoEnSubTotal.Checked = DbRowVenta("AnticipoEnSubTotal").ToString() = "True" + DdlTipoAmortizacionAnticipo.SelectedValueExist(DbRowVenta("CveTipoAmortizacionAnticipo")) + DdlTiposRelacion.SelectedValueExist(DbRowVenta("CveTipoRelacion")) + + 'Si es AMORTIZACIÓN ANTICIPO SOBRE FACTURA EN CERO no debe timbrar + If DbRowVenta("CveTipoAmortizacionAnticipo").ToString().ToEntero() = 3 Then + BtnEmitir.Visible = False End If - LBFacturarAnticipo.Visible = False + 'HdnAmortizacion.Value = LblAmort.Text.ToDouble.ToString() + 'HdnSubTotalDescuestos.Value = (TxtSubTotal.Text.Replace(",", "").ToDouble - LblDescuentos.Text.Replace(",", "").ToDouble - LblAmortizacion.Text.Trim.Replace(",", "").ToDouble - TxtRetISR.Text.Replace(",", "").ToDouble).FormatoNumero(2) + 'DdlAmortizacionConceptos.SelectedValue = DbRowVenta("AnticipoPosicion").ToString() + 'ChkAnticipoEnSubTotal.Checked = DbRowVenta("AnticipoEnSubTotal").ToString() = "True" - 'ACTIVA CONVERSION DE MONEDA - If DdlMoneda.SelectedValue.ToEntero() = 1 Then - TrConversionDolares.Visible = True - ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) - TxtTipoCambioDlls.Enabled = True + + If DbRowVenta("CveTipoRelacion").ToString().ToEntero() > 0 Then + TrTipoRelacion2.Visible = True + LblTipoRelacion.Text = DbRowVenta("TipoRelacion").ToString() + HdnFolioFiscalNC.Value = DbRowVenta("FolioFiscalPadre").ToString() + End If + + + TxtOrdenCompra.Text = DbRowVenta("OrdenCompra").ToString() + TxtOrdenCompra.Enabled = False + + TxtObsAlmacen.Text = DbRowVenta("ObservacionesAlmacen").ToString() + CvePAC = DbRowVenta("CvePAC").ToString().ToEntero() + + If DbRowVenta("Saldo").ToString().ToDecimal > 0 AndAlso UsuarioActual.TienePermisoProceso(204) AndAlso Not UsuarioActual.CveEmpresa.Contiene(119) Then + TxtFechaSaldarVenta.Text = TxtFecha.Text + CEFechaSaldarVenta.StartDate = TxtFecha.Text.ToDate + HLSaldarVenta.Visible = True + End If + + + If (UsuarioActual.TienePermisoProceso(166) Or UsuarioActual.CveRol = 1) AndAlso (LblFolioFiscal.Text = "" Or LblFolioFiscal.Text = "test") Then + LkEliminarFactura.Visible = True + End If + If (UsuarioActual.CveRol = 1) AndAlso (LblFolioFiscal.Text <> "") Then + LnkUUIDRelacionados.Visible = True + End If + + 'Envio Direccion + If DbRowVenta("CveDireccionEnvio").ToString().ToEntero() > 0 AndAlso DbRowVenta("CveDireccionEnvio").ToString() IsNot Nothing Then + ChkDireccionEnvio.Checked = True + DdlDireccionEnvio.SelectedValueExist(DbRowVenta("CveDireccionEnvio").ToString().ToEntero()) + 'DdlDireccionEnvio_SelectedIndexChanged(DdlDireccionEnvio, EventArgs.Empty) + DdlDireccionEnvio.Enabled = False + ChkDireccionEnvio.Enabled = False + DdlDireccionEnvio.Visible = True + trDireccionEnvio.Visible = True + End If + If UsuarioActual.TienePermisoProceso(333) Then LnkEditarDir.Visible = True + + 'ESTATUS FACTURA + If Not (CveRemision > 0 Or CveCotizacion > 0) Then + CveEstatus = DbRowVenta("CveEstatusFactura").ToString().ToEntero() + End If + + TxtTipoCambio.Text = DbRowVenta("TipoCambio").ToString() + If DbRowVenta("UltimasFluctuaciones").ToString() <> "" Then + LblTCValuacion.Text = String.Format("Ult. Val:{0}", DbRowVenta("UltimasFluctuaciones").ToString()) + LblTCValuacion.Visible = True + End If + + ViewState("SelloCancelacion") = DbRowVenta("SelloCancelacion").ToString() + ViewState("FechaCancelacion") = DbRowVenta("FechaCancelacion").ToString().ToDateTime + TxtAtencionA.Text = DbRowVenta("AtencionA").ToString() + TxtTelefonoGenerico.Text = DbRowVenta("TelefonoGenerico").ToString() + CveVentaPadre = DbRowVenta("CveVentaPadre").ToString().ToEntero() + SerieFolioPadre = DbRowVenta("SerieFolioPadre").ToString() + + If DdlVendedor.SelectedValue.ToEntero() > 0 AndAlso Not UsuarioActual.TienePermisoProceso(161) Then + DdlVendedor.Enabled = False + End If + + 'PERMITIR EDITAR EL VENDEDOR ANTES DE FACTURAR + If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso TmpDT IsNot Nothing AndAlso TmpDT.SUM("CantidadFacturadaCot") = 0) Then + DdlVendedor.Enabled = True + End If + + If CveVentaPadre > 0 Then + If IsNothing(Request("CveDevolucion")) AndAlso IsNumeric(Request("CveDevolucion")) Then + DdlNCFactura.Visible = True + Else + DdlNCFactura.Visible = False + End If + trNCFactura.Visible = True + LblSerieFolioPadre.Visible = True + LblSerieFolioPadre.Text = String.Format("{1}", CveVentaPadre, SerieFolioPadre) + + End If + + If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso DbRowVenta("CveProcedimiento").ToString.ToEntero > 0 Then + TxtFechaEjecucion.Text = DbRowVenta("FechaEjecucion").ToString().ToDateTime.ToString("dd/MM/yyyy HH:mm") + DVMEEFechaEje.Visible = False Else - TrConversionTipoCambio.Visible = True - ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) - TxtTipoCambio.Enabled = True + TxtFechaEjecucion.Text = DbRowVenta("FechaEjecucion").ToString().ToDateTime.ToString("dd/MM/yyyy") End If - End If - End If - If UsuarioActual.Empresa.Funcionalidad(280) = "1" Then - RblPaqueteria.SelectedValue = If(DbRowVenta("FormaPaqueteria").ToString = "", "1", DbRowVenta("FormaPaqueteria").ToString) - RblPaqueteria.Enabled = False - End If + 'DdlSucursalEjecucion.SelectedValueExist(DbRowVenta("CveSucursalEjecucion").ToString()) + 'DdlSucursalCobranza.SelectedValueExist(DbRowVenta("CveSucursalCobranza").ToString()) + DdlSucursalCliente.SelectedValueExist(DbRowVenta("CveClienteSucursal").ToString()) + 'DdlSucursal.SelectedValueExist(DbRowVenta("CveSucursal").ToString()) + 'DdlSubProyectoDatos.SelectedValueExist(DbRowVenta("CveSubProyecto").ToString()) - If UsuarioActual.CveEmpresa = 48 Then - TxtFecha.AutoPostBack = True - End If + If DdlSubProyectoDatos.Items.Count = 0 Then + DdlSubProyectoDatos.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + DdlSubProyectoDatos.SelectedValueExistInsert(DbRowVenta("CveSubProyecto").ToString(), DbRowVenta("SubProyecto").ToString()) + DdlSubProyecto.SelectedValueExist(DbRowVenta("CveSubProyecto").ToString()) - CargaCodigoUnico() + CargarAlmacenes() - DdlTipoRetencion.SelectedValueExist(DbRowVenta("CveTipoRetencion").ToString()) + If DdlSubProyectoCobranza.Items.Count = 0 Then + DdlSubProyectoCobranza.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + DdlSubProyectoCobranza.SelectedValueExistInsert(DbRowVenta("CveSubProyectoCobranza").ToString(), GlobalDTSubProyectos(-1, DbRowVenta("CveSubProyectoCobranza").ToString().ToEntero()).FiltroPrimeroValor("SubProyecto").ToString()) - Me.FacturarSucursal = CBool(DbRowVenta("FacturarSucursal").ToString()) + If DdlSubProyectoEjecucion.Items.Count = 0 Then + DdlSubProyectoEjecucion.Items.Insert(0, New ListItem("Seleccione", "-1")) + End If + DdlSubProyectoEjecucion.SelectedValueExistInsert(DbRowVenta("CveSubProyectoEjecucion").ToString(), GlobalDTSubProyectos(-1, DbRowVenta("CveSubProyectoEjecucion").ToString().ToEntero()).FiltroPrimeroValor("SubProyecto").ToString()) - If Me.FacturarSucursal Then - HabilitarFacturacionSucursal() - End If + CargaClienteSucursal(DbRowVenta("CveClienteSucursal").ToString().ToEntero()) - CargaPS(-1, DdlPS) + If DbRowVenta("CveContrato").ToString().ToEntero() > 0 Then + CveContrato = DbRowVenta("CveContrato").ToString().ToEntero() + NumeroContrato = DbRowVenta("NumeroContrato").ToString() + DescripcionContrato = DbRowVenta("DescripcionContrato").ToString() + DdlContrato.Visible = False + HLContrato.Text = $"{DbRowVenta("NumeroContrato")} - {DbRowVenta("DescripcionContrato")}" + HLContrato.NavigateUrl = $"/Contratos/Contrato.aspx?CveContrato={CveContrato}" + 'trPresupuesto.Visible = True + 'HplPresupuesto.NavigateUrl = String.Format(" / Presupuestos / Presupuesto.aspx?CvePresupuesto={0}", DbRowVenta("CveContrato").ToString()) + Else + NumeroContrato = "" + DescripcionContrato = "" + End If - 'Verifico si tiene la funcionalidad (135) - If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then + 'DdlEstatus.Items.Remove(DdlEstatus.Items.FindByText("Cotización")) - Select Case UsuarioActual.Empresa.Funcionalidad(135) - Case "1" ' POR SUPERVISOR - Dim ObjVendedores As New ClsVtaVendedores + If DbRowVenta("SeTimbro").ToString() <> "No" Then + HplDownXML.Visible = True + 'If HLImprimir.Visible = False Then + HplDownPDF.Visible = True + 'End If + ElseIf UsuarioActual.Empresa.TipoFacturacion = "CBB" OrElse DdlTipoComprobante.SelectedValue = "Cot" Then + 'If drv("TipoEstatus").ToString().ToEntero() = 2 AndAlso drv("TipoDocto").ToString() = "Cot" Then + ' ImgDownPDF.Visible = True + 'Else + HplDownPDF.Visible = False + 'End If + ElseIf UsuarioActual.Empresa.TipoFacturacion = "CFDi" AndAlso DbRowVenta("SeTimbro").ToString() = "No" AndAlso DbRowVenta("CveEstatusFactura").ToString() = "2" AndAlso DbRowVenta("TipoDocto").ToString().Contiene("Ing", "Egs", "Dev", "Ant") Then + TrEmitir.Visible = True + If TxtFecha.Text.ToDate < NowADS().AddDays(-3) Then + TxtFecha.Enabled = True + End If + End If - If ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa) Then - Dim DTVendedores As New DataTable - If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then - DTVendedores = ObjVendedores.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor)) + 'NO DEBE IMPRIMIR PDF DE COTIZACION + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DbRowVenta("TipoDocto").ToString() = "Cot" Then + HplDownPDF.Visible = False + End If + + If DbRowVenta("SeTimbro").ToString() = "Si" Then + TrEmitir.Visible = False + End If + + 'CargaAcuseCancelacion + If DbRowVenta("CveEstatusFactura").ToString().Contiene("5", "20") Then + ImgDownCancelacion.Visible = True + ImgDownCancelacion.NavigateUrl = String.Format("/Compras/PopUpVerFactura.aspx?P={0}", Encripta(String.Format("OP=CAN&CVEVTA={0}", CveVenta))) + End If + IdPoliza = DbRowVenta("IdPoliza").ToString().ToEntero() + + 'Carga si es Contabilizada + If IdPoliza > 0 Then + HLContabilizada.Text = "Si" + HLContabilizada.NavigateUrl = $"/Contabilidad/RegPoliza.aspx?IdPoliza={DbRowVenta("IdPoliza")}" + trContabilizada.Visible = True + If UsuarioActual.TienePermisoProceso(107) Then BtnDescontabilizar.Visible = True + + Else + 'cuando no este contabilizada y usa AC, habilita el boton para generar la poliza + If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC AndAlso UsuarioActual.CveRol = 1 Then + BtnGenerarPoliza.Visible = True + End If + If UsuarioActual.Empresa.Funcionalidad(200) = "1" Then + BtnContabilizar.Visible = True + End If + End If + + If DbRowVenta("IdPolizaCancelacion").ToString().ToEntero() > 0 Then + HPLContaCancelacion.Text = "Cancelación" + HPLContaCancelacion.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", DbRowVenta("IdPolizaCancelacion")) + trContabilizada.Visible = True + End If + + + If UsuarioActual.Empresa.UsaOS AndAlso DbRowVenta("CveOS").ToString().ToEntero() = 0 Then + BtnGenerarOS.Visible = True + BtnGenerarOS.OnClientClick = String.Format("javascriptwindow.location.href = '/OS/OrdenesServicios.aspx?CveVenta={0}'; return false;", CveVenta) + ' BtnGenerarOS.OnClientClick = String.Format("/OS/OrdenesServicios.aspx?CveVenta={0}", CveVenta) + End If + + + '[IPP] COMENTADO 12/MARZO/2018 -SABRA QUE SE QUERIA ESCONDER + 'If DbRowVenta("TipoDocto").ToString() = "Rem" Then + ' GvPS.Columns(11).Visible = False + ' GvPS.Columns(12).Visible = False + 'End If + + + 'Ocultamos los botones Clonar y Ordenar + GvPS.Columns(19).Visible = False + GvPS.Columns(20).Visible = False + + GvFirmas.DataSource = DTmpF + GvFirmas.DataBind() + + If TmpDTImpuestos IsNot Nothing AndAlso TmpDTImpuestos.Rows.Count > 0 Then + TrOtros.Visible = True + GvImpuestosLocales2.DataSource = TmpDTImpuestos + GvImpuestosLocales2.DataBind() + + GvImpuestosLocales2.Enabled = False + GvImpuestosLocales2.Visible = True + End If + + DdlVendedor.SelectedValue = If(DbRowVenta("CveVendedor").ToString = "", "0", DbRowVenta("CveVendedor").ToString) 'si viene dbnull, que ponga cero. + DdlTipoComprobante.Enabled = False + 'TxtDocto.Enabled = False + + 'PORLET CLIENTE + 'DESACTIVA CAMBIO DE CLIENTE + HlCliente.Attributes.Remove("class") + HlCliente.Attributes.Add("class", "Texto disabled") + TxtCodigo.ReadOnly = True + ChkEnviarFactura.Enabled = False + ChkDireccionEnvio.Enabled = False + TxtAtencionA.Enabled = False + TxtFechaVencimientoCotizacion.Enabled = False + + TxtCantidad.Enabled = False + DdlClasificacion.Enabled = False + + DdlPS.Enabled = False + TxtObsPS.Enabled = False + DdlProyecto.Enabled = False + DdlSubProyecto.Enabled = False + TxtPrecio.Enabled = False + ImgDescPU.Attributes.Clear() + ImgDescTotal.Attributes.Clear() + ImgDescConcepto.Attributes.Clear() + LbAgregar.Enabled = False + DdlCuentasTerminal.Enabled = False + + For Each Row As GridViewRow In GvPS.Rows + Row.FCLiteral("LtlConsecutivo").Text = (Row.RowIndex + 1).ToString() + Next + GvPS.Columns(ColumnaEditar).HeaderText = "" + GvPS.Columns(ColumnaEliminar).HeaderText = "" + 'GvPS.Columns(ColumnaEliminar).Visible = False + + TxtObsFact.Enabled = False + TxtObsAlmacen.Enabled = False + TxtMotivoDescuento.Enabled = False + 'GvLeyendasFiscales.Enabled = False + TxtSubTotal.ReadOnly = True + TxtIVA.ReadOnly = True + TxtRetIVA.ReadOnly = True + TxtRetISR.ReadOnly = True + TxtIEPS.ReadOnly = True + TxtTotal.ReadOnly = True + + 'Sección Detalle + DdlMoneda.Enabled = False + DdlTipoRetencion.Enabled = False + TxtFechaEjecucion.ReadOnly = True + ImgCalendarFechaEje.Enabled = False + 'DdlSucursalEjecucion.Enabled = False + 'DdlSucursalCobranza.Enabled = False + DdlVendedor.Enabled = False + 'PERMITIR EDITAR EL VENDEDOR ANTES DE FACTURAR + If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (CveVenta > 0 AndAlso DdlTipoComprobante.SelectedValue = "Cot" AndAlso TmpDT IsNot Nothing AndAlso TmpDT.SUM("CantidadFacturadaCot") = 0) Then + DdlVendedor.Enabled = True + End If + DdlSucursalCliente.Enabled = False + TxtTiempoEntrega.Enabled = False + TxtAlfa1.ReadOnly = True + TxtAlfa2.ReadOnly = True + TxtAlfa3.ReadOnly = True + TxtNum1.ReadOnly = True + TxtNum2.ReadOnly = True + TxtNum3.ReadOnly = True + TxtFech1.ReadOnly = True : ImgFech1.Enabled = False + TxtFech2.ReadOnly = True : ImgFech2.Enabled = False + TxtFech3.ReadOnly = True : ImgFech3.Enabled = False + ChkConvertirDoctoPesos.Enabled = False + ChkConvertirDolares.Enabled = False + + TxtTipoCambio.Enabled = UsuarioActual.CveEmpresa.Contiene(13, 83) + TxtTipoCambioDlls.Enabled = UsuarioActual.CveEmpresa.Contiene(13, 83) + TxtTipoCambio.ReadOnly = Not UsuarioActual.CveEmpresa.Contiene(13, 83) + TxtTipoCambioDlls.ReadOnly = Not UsuarioActual.CveEmpresa.Contiene(13, 83) + + 'Condiciones de Pago + RBLPago.Enabled = False + DdlFormaPago33.Enabled = False + DdlUsoCFDI.Enabled = False + DdlMetodoPago33.Enabled = False + 'TxtNumCtaPago.Enabled = False + If DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Rem", "Cot") Then + TxtFechaPago.ReadOnly = Not UsuarioActual.TienePermisoProceso(260) + LnkUpdateFechaVencimiento.Visible = UsuarioActual.TienePermisoProceso(260) + Else + TxtFechaPago.ReadOnly = False + End If + + imgCalendario.Enabled = False + DdlFuenteRecaudacion.Enabled = False + + TrVistaPrevia.Visible = False + BtnEmitirImprimir.Visible = False + 'CargaLeyendasFiscales + ViewState("VentaFolio") = If(LblSerie.Text.Trim.Length = 0, TxtFolio.Text.Trim, LblSerie.Text.Trim & "-" & TxtFolio.Text.Trim) + + CalculaTotalesVenta(False) + + 'JJMQ 20160506: Se agrego para la validacion de pago de contado. + 'CVImporteContado.ValueToCompare = TxtTotal.Text.Replace(",", "") + + tdVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") + tdFechaVigencia.Visible = DdlTipoComprobante.SelectedValue.Contiene("Cot") + + If DbRowVenta("TipoDocto").ToString() = "Rem" Then + 'CANTIDAD FACTURADA + If TmpDT.SUM("CantidadFacturadaRem") > 0 Then + GvPS.Columns(6).Visible = True + ThCantidadFacturadaRem.Visible = True + ThCantidadFacturadaRem2.Visible = True + Else + GvPS.Columns(6).Visible = False + ThCantidadFacturadaRem.Visible = False + ThCantidadFacturadaRem2.Visible = False + End If + + 'ACTIVA EDITAR + 'SOLO LA PUEDE EDITAR CON PROCESO | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + If UsuarioActual.TienePermisoProceso(202) And TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad") Then + BtnPermisoEditarRemision.Visible = True + End If + + If UsuarioActual.TienePermisoProceso(302) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Rem", "Ped") Then BtnPermisoEditarRemision.Visible = True + If UsuarioActual.TienePermisoProceso(302) AndAlso DdlTipoComprobante.SelectedValue.Contiene("Ing", "Ant", "Egs") Then BtnEditar.Visible = True + + + 'si es de FNC contado. bloquear edición si está pagada o en proceso de cobro + If UsuarioActual.Empresa.Funcionalidad(109) = "1" AndAlso (DbRowVenta("CveCobranzaEstatus").ToString = "1" OrElse DbRowVenta("Saldo").ToString.ToDecimal = 0) Then + BtnPermisoEditarRemision.Visible = False + End If + + 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + If TmpDT.SUM("CantidadFacturadaRem") < TmpDT.SUM("Cantidad") Then + BtnsFacturar.Visible = True + + 'E119, bloquear la facturación de remisiones que no estén surtidas + If UsuarioActual.CveEmpresa = 119 Then + If TmpDT.SUM("Cantidad") <> TmpDT.SUM("CantidadInventario") Then 'que ya esté surtida totalmente + BtnsFacturar.Visible = False + End If + End If + LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) + + 'ACTIVA CONVERSION DE MONEDA + If DdlMoneda.SelectedValue.ToEntero() = 1 Then + TrConversionDolares.Visible = True + ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambioDlls.Enabled = True + Else + TrConversionTipoCambio.Visible = True + ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambio.Enabled = True End If - 'Verifico si es su supervisor asignado - If DTVendedores.Rows.Count > 0 Then + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + TrVistaPrevia.Visible = True + End If + End If + + 'Si es Empresa de Acumuladores + If CveVenta > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso DbRowVenta("TipoDocto").ToString() = "Rem" AndAlso (GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() <> 5) Then + + BtnsFacturar.Visible = False + + Dim DtUsadosPendientes As DataTable = Nothing + Dim DtGarantiasPendientes As DataTable = Nothing + + Dim ObjUsados As New ClsVentas + + If ObjUsados.GetVentasUsados(CveVenta, -1, DbRowVenta("Fecha").ToString().ToDateTime, UsuarioActual.CveEmpresa) Then + DtUsadosPendientes = ObjUsados.DtResultados.Copy() + End If + + If ObjUsados.GetVentasGarantiaPendiente(CveVenta, NowADS(), UsuarioActual.CveEmpresa) Then + DtGarantiasPendientes = ObjUsados.DtResultados.Copy() + End If + + 'If ObjUsados.GetVentasGarantiaPendiente(CveVenta, -1, NowADS(), UsuarioActual.CveEmpresa) Then + ' DtGarantiasPendientes = ObjUsados.DtResultados.Copy() + 'End If + + ObjUsados.Dispose() + + BtnsFacturar.Visible = True + + 'VERIFICA SI YA SE FACTURO COMPLETAMENTE + If TmpDT.SUM("CantidadFacturadaRem") = TmpDT.SUM("Cantidad") Then + BtnsFacturar.Visible = False + End If + + 'VERIFICA SI TIENE USADOS O GARANTIAS PENDIENTES + If BtnsFacturar.Visible Then + If (Not EsGarantia AndAlso (DtUsadosPendientes IsNot Nothing AndAlso DtUsadosPendientes.Rows.Count > 0)) Then + BtnsFacturar.Visible = False + Alert("Tiene usados pendiente de recibir", TipoMensaje.MsgAdvertencia) + End If + + If (EsGarantia AndAlso (DtGarantiasPendientes IsNot Nothing AndAlso DtGarantiasPendientes.Rows.Count > 0)) Then + Alert("Tiene garantías pendientes de recibir", TipoMensaje.MsgAdvertencia) + BtnsFacturar.Visible = False + End If + End If + + LBFacturarAnticipo.Visible = UsuarioActual.TienePermisoProceso(274) + End If + + 'SI ES COMPLEMENTARIA, NO DEBE PERMITIR FACTURAR + If UsuarioActual.Empresa.Funcionalidad(706) = "1" AndAlso DbRowVenta("TipoContable").ToString() <> "-1" Then + If DbRowVenta("TipoContable").ToString() = "0" Then + BtnsFacturar.Visible = False + End If + + TrTipoContable.Visible = True + DdlTipoContable.SelectedValueExist(DbRowVenta("TipoContable").ToString()) + DdlTipoContable.Enabled = False + End If + + End If + + If DbRowVenta("TipoDocto").ToString().Contiene("Cot") Then + 'CANTIDAD FACTURADA + If TmpDT.SUM("CantidadFacturadaCot") > 0 Then + GvPS.Columns(7).Visible = True + ThCantidadFacturada.Visible = True + ThCantidadFacturada2.Visible = True + Else + GvPS.Columns(7).Visible = False + ThCantidadFacturada.Visible = False + ThCantidadFacturada2.Visible = False + End If + + 'ACTIVA EDITAR + 'SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA + If (UsuarioActual.CveUsuario = DbRowVenta("CveUsuario").ToString().ToEntero() Or UsuarioActual.CveVendedor = DdlVendedor.SelectedValue.ToEntero()) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") + BtnPermisoEditarCotizacion.Visible = True + End If + + 'SOLO LA PUEDE EDITAR USUATIOACTUAL-VENDEDOR | NO DEBE ESTAR FACTURADA + If UsuarioActual.TienePermisoProceso(281) And TmpDT.SUM("CantidadFacturadaCot") = 0 Then 'And TmpDT.SUM("CantidadFacturadaCot") < TmpDT.SUM("Cantidad") + BtnPermisoEditarCotizacion.Visible = True + End If + + 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + VerificarBtnFacturarCotizacion(DbRowVenta("CveVendedor").ToString().ToEntero()) + End If + + If DbRowVenta("TipoDocto").ToString().Contiene("Ped") Then + 'ACTIVA BOTONERA | DEBE TENER CONCEPTOS PENDIENTES DE FACTURAR + If TmpDT.SUM("CantidadFacturadaPed2") < TmpDT.SUM("Cantidad") Then + BtnsFacturar.Visible = True + + 'bloquear la facturación de remisiones que no estén surtidas + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + If TmpDT.SUM("Cantidad") <> TmpDT.SUM("CantidadInventario") Then 'que ya esté surtida totalmente + BtnsFacturar.Visible = False + End If + End If + + LBFacturarAnticipo.Visible = False + + 'ACTIVA CONVERSION DE MONEDA + If DdlMoneda.SelectedValue.ToEntero() = 1 Then + TrConversionDolares.Visible = True + ChkConvertirDolares.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambioDlls.Enabled = True + Else + TrConversionTipoCambio.Visible = True + ChkConvertirDoctoPesos.Enabled = Not UsuarioActual.TienePermisoProceso(324) + TxtTipoCambio.Enabled = True + End If + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(280) = "1" Then + RblPaqueteria.SelectedValue = If(DbRowVenta("FormaPaqueteria").ToString = "", "1", DbRowVenta("FormaPaqueteria").ToString) + RblPaqueteria.Enabled = False + End If + + If UsuarioActual.CveEmpresa = 48 Then + TxtFecha.AutoPostBack = True + End If + + CargaCodigoUnico() + + DdlTipoRetencion.SelectedValueExist(DbRowVenta("CveTipoRetencion").ToString()) + + Me.FacturarSucursal = CBool(DbRowVenta("FacturarSucursal").ToString()) + + If Me.FacturarSucursal Then + HabilitarFacturacionSucursal() + End If + + CargaPS(-1, DdlPS) + + 'Verifico si tiene la funcionalidad (135) + If DdlTipoComprobante.SelectedValue = "Cot" AndAlso UsuarioActual.Empresa.Funcionalidad(135).Contiene("1", "2") Then + + Select Case UsuarioActual.Empresa.Funcionalidad(135) + Case "1" ' POR SUPERVISOR + Dim ObjVendedores As New ClsVtaVendedores + + If ObjVendedores.GetVendedores(UsuarioActual.CveEmpresa) Then + Dim DTVendedores As New DataTable + If DbRowVenta("CveVendedor").ToString().ToEntero() > 0 AndAlso UsuarioActual.CveVendedor > 0 Then + DTVendedores = ObjVendedores.DtResultados.FiltraParametros(String.Format("CveVendedor = {0}", DbRowVenta("CveVendedor").ToString())).FiltraParametros(String.Format("CveSupervisor = {0}", UsuarioActual.CveVendedor)) + End If + + 'Verifico si es su supervisor asignado + If DTVendedores.Rows.Count > 0 Then + If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then + BtnsFacturar.Visible = True + BtnGenerarRemision.Visible = True + Else + BtnsFacturar.Visible = False + BtnGenerarRemision.Visible = False + End If + End If + + DTVendedores.Dispose() + End If + ObjVendedores.Dispose() + + Case "2" ' POR PERMISO If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then - BtnsFacturar.Visible = True - BtnGenerarRemision.Visible = True + BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) + If UsuarioActual.TienePermisoProceso(199) Then + BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) + Else + BtnGenerarRemision.Visible = False + End If Else BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False End If - End If - DTVendedores.Dispose() - End If - ObjVendedores.Dispose() + End Select - Case "2" ' POR PERMISO - If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 2 Then - BtnsFacturar.Visible = UsuarioActual.TienePermisoProceso(60) - If UsuarioActual.TienePermisoProceso(199) Then - BtnGenerarRemision.Visible = If(CveEstatus = 10, False, True) - Else - BtnGenerarRemision.Visible = False - End If - Else + + End If + + If DdlTipoComprobante.SelectedValue = "Cot" Then + If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 5 Then BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False End If - - End Select - - - End If - - If DdlTipoComprobante.SelectedValue = "Cot" Then - If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 5 Then - BtnsFacturar.Visible = False - BtnGenerarRemision.Visible = False - End If - End If - - If DdlTipoComprobante.SelectedValue = "Rem" Then - If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 5 Then - BtnsFacturar.Visible = False - BtnEmitirImprimir.Visible = False - BtnPermisoEditarRemision.Visible = False - End If - End If - - If UsuarioActual.Empresa.Funcionalidad(705) = "1" AndAlso Me.CveLineaAdicionalVenta > 0 Then - CalculaLineasAdicionales() - End If - - UpPS.Update() - UpContado.Update() - UpEstatus.Update() - Retorno = True - - If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then - - CveTipoVenta = If(DbRowVenta("CveTipoVenta").ToString.ToEntero > 0, DbRowVenta("CveTipoVenta").ToString.ToEntero, -1) - - TrVentasMedicas3.Visible = True - - If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso CveTipoVenta.Contiene(1, 2, 3, 5) Then - TrVentasMedicas1.Visible = True - - DdlMedico.SelectedValueExist(DbRowVenta("CveMedico").ToString) - DdlProcedimiento.SelectedValueExist(DbRowVenta("CveProcedimiento").ToString) - TxtPaciente.Text = DbRowVenta("Paciente").ToString - TxtEpisodio.Text = DbRowVenta("Episodio").ToString - - DdlMedico.Enabled = False - DdlProcedimiento.Enabled = False - TxtPaciente.Enabled = False - TxtEpisodio.Enabled = False - - - If DbRowVenta("FechaParaSurtir").ToString().ToDate() > DateTime.MinValue Then - TrVentasMedicas2.Visible = True - ChkRequiereTecnico.Enabled = False - TxtFechaOS.Enabled = False - - TxtFechaOS.Text = DbRowVenta("FechaParaSurtir").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm").Replace(" ", "T") End If + If DdlTipoComprobante.SelectedValue = "Rem" Then + If GlobalDTEstatusFactura().FiltroPrimeroValor("TipoEstatus", $"CveEstatusFactura = {Me.CveEstatus}").ToEntero() = 5 Then + BtnsFacturar.Visible = False + BtnEmitirImprimir.Visible = False + BtnPermisoEditarRemision.Visible = False + End If + End If + + If UsuarioActual.Empresa.Funcionalidad(705) = "1" AndAlso Me.CveLineaAdicionalVenta > 0 Then + CalculaLineasAdicionales() + End If + + UpPS.Update() + UpContado.Update() + UpEstatus.Update() + Retorno = True + + If UsuarioActual.Empresa.Funcionalidad(578) = "1" Then + + CveTipoVenta = If(DbRowVenta("CveTipoVenta").ToString.ToEntero > 0, DbRowVenta("CveTipoVenta").ToString.ToEntero, -1) + + TrVentasMedicas3.Visible = True + + If DbRowVenta("CveMedico").ToString.ToEntero > 0 AndAlso CveTipoVenta.Contiene(1, 2, 3, 5) Then + TrVentasMedicas1.Visible = True + + DdlMedico.SelectedValueExist(DbRowVenta("CveMedico").ToString) + DdlProcedimiento.SelectedValueExist(DbRowVenta("CveProcedimiento").ToString) + TxtPaciente.Text = DbRowVenta("Paciente").ToString + TxtEpisodio.Text = DbRowVenta("Episodio").ToString + + DdlMedico.Enabled = False + DdlProcedimiento.Enabled = False + TxtPaciente.Enabled = False + TxtEpisodio.Enabled = False + + + If DbRowVenta("FechaParaSurtir").ToString().ToDate() > DateTime.MinValue Then + TrVentasMedicas2.Visible = True + ChkRequiereTecnico.Enabled = False + TxtFechaOS.Enabled = False + + TxtFechaOS.Text = DbRowVenta("FechaParaSurtir").ToString().ToDateTime().ToString("yyyy-MM-dd HH:mm").Replace(" ", "T") + End If + End If + + If DdlTipoDocto.SelectedValue.Contiene("Ing", "Rem") Then + TrVentasMedicas4.Visible = True + TxtFolioRemision.Text = DbRowVenta("Alfa1").ToString + End If + End If End If - - - If DdlTipoDocto.SelectedValue.Contiene("Ing", "Rem") Then - TrVentasMedicas4.Visible = True - TxtFolioRemision.Text = DbRowVenta("Alfa1").ToString - End If - - - End If - + End Using End If + Return Retorno End Function @@ -6185,7 +6185,6 @@ Partial Class Ventas Else BtnGenerarRemision.Visible = False End If - Else BtnsFacturar.Visible = False BtnGenerarRemision.Visible = False @@ -13667,11 +13666,14 @@ Partial Class Ventas If UsuarioActual.Empresa.Funcionalidad(578) = "1" AndAlso EsVentaMedica Then If DdlSucursalCliente.SelectedValue.ToEntero > 0 Then - Dim objclientes As New ClsClientes - If objclientes.GetSucursales(CveCliente, -1) Then - CveAlmacenTraspasoDestino = objclientes.DtResultados.FiltroPrimeroValor("CveAlmacenAsignado", $" CveClienteSucursal = {DdlSucursalCliente.SelectedValue.ToEntero}").ToEntero + Dim drr As DataRow = GlobalDTClientesSucursales(UsuarioActual.CveEmpresa, CveCliente).FiltroPrimero($" CveClienteSucursal = {DdlSucursalCliente.SelectedValue.ToEntero}") + If drr IsNot Nothing Then + If RBLTipoVenta.SelectedValue.Contiene("3", "6") Then 'cuando es A-vista + CveAlmacenTraspasoDestino = drr("CveAlmacenAlterno").ToString.ToEntero + Else + CveAlmacenTraspasoDestino = drr("CveAlmacenAsignado").ToString.ToEntero + End If End If - objclientes.Dispose() End If If Not CveAlmacenTraspasoDestino > 0 Then @@ -13693,7 +13695,6 @@ Partial Class Ventas End If End If - End If Dim TotalImpuestoLocal As Double = 0 @@ -16426,7 +16427,9 @@ Partial Class Ventas Try ' BytesPdfCotizacion(CveVenta) - Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto, CorreoContactoCRM:=CorreoContactoCRM)) + Dim capturedContext = HttpContext.Current + Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto, CorreoContactoCRM:=CorreoContactoCRM, + EsHilo:=True, Contexto:=capturedContext)) Hilo.Start() Catch ex As Exception OnError("Ocurrió error al mandar Mail", ex) @@ -16473,7 +16476,9 @@ Partial Class Ventas Try ' BytesPdfCotizacion(CveVenta) - Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto)) + Dim capturedContext = HttpContext.Current + Dim Hilo As New System.Threading.Thread(Sub() MandaMails(UsuarioActual, CveVenta, DdlTipoComprobante.SelectedValue.ToString(), LocalSerieFolio, ChkEnviarFactura.Checked, ArchivoXML, ArchivoPDF, ArchivoAdjunto, + EsHilo:=True, Contexto:=capturedContext)) Hilo.Start() Catch ex As Exception OnError("Ocurrió error al mandar Mail", ex) @@ -21922,7 +21927,13 @@ Partial Class Ventas #End Region #Region " MANDA CORREO " - Private Sub MandaMails(UsuarioActual As Usuario, CveVenta As Integer, TipoDocto As String, SerieFolio As String, EnviarFactura As Boolean, XML As String, PDF As String, Adjunto As String, Optional CorreoContactoCRM As String = "") + Private Sub MandaMails(UsuarioActual As Usuario, CveVenta As Integer, TipoDocto As String, SerieFolio As String, EnviarFactura As Boolean, XML As String, PDF As String, Adjunto As String, Optional CorreoContactoCRM As String = "", + Optional EsHilo As Boolean = False, Optional Contexto As HttpContext = Nothing) + + If EsHilo Then + HttpContext.Current = Contexto + HttpContext.Current.Session("UsuarioSIG") = UsuarioActual + End If Dim ObjMail As New ClsSisMail() Dim ResultadoMail As Integer = 0