From e4e7b952b74376d734177e7a56fe6cb8179f3032 Mon Sep 17 00:00:00 2001 From: Rakcsle Supertramp Date: Wed, 15 Apr 2020 09:13:02 -0700 Subject: [PATCH 01/18] Pago Electronico Por Grupos cambio de lugar Link que abre modal para validar cuentas beneficiarias --- Bancos/PagoElectronicoGrupos.aspx | 8 ++++---- Bancos/PagoElectronicoGrupos.aspx.vb | 7 +------ vwd.webinfo | 2 ++ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Bancos/PagoElectronicoGrupos.aspx b/Bancos/PagoElectronicoGrupos.aspx index 567686b7d..f9242d7a1 100644 --- a/Bancos/PagoElectronicoGrupos.aspx +++ b/Bancos/PagoElectronicoGrupos.aspx @@ -94,7 +94,9 @@ Altas: - + <%----%> + + Interbancarias: @@ -250,9 +252,7 @@    - - - + <%----%> diff --git a/Bancos/PagoElectronicoGrupos.aspx.vb b/Bancos/PagoElectronicoGrupos.aspx.vb index 09047cabb..683b16d2f 100644 --- a/Bancos/PagoElectronicoGrupos.aspx.vb +++ b/Bancos/PagoElectronicoGrupos.aspx.vb @@ -290,7 +290,7 @@ Partial Class Bancos_PagoElectronicoGrupos End If Next - LbNumeroAltas.Text = Altas.ToString + LnkNumeroAltas.Text = Altas.ToString LbNumeroInterbancarias.Text = Interbancarias.ToString LbNumeroBancomer.Text = Bancomer.ToString @@ -404,11 +404,6 @@ Partial Class Bancos_PagoElectronicoGrupos Protected Sub GvPendientes_RowDataBound(sender As Object, e As GridViewRowEventArgs) - If e.Row.RowType = DataControlRowType.Header Then - - e.Row.FCLinkButton("LnkCabeceraPendientes").Text = LbNumeroAltas.Text - - End If diff --git a/vwd.webinfo b/vwd.webinfo index c9e193dc4..6b76e11e1 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -50,6 +50,8 @@ + + From 2685e90023a60dad115498426f305832bc109c80 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Wed, 15 Apr 2020 14:30:01 -0700 Subject: [PATCH 02/18] --- App_Code/ClsPaginas.vb | 110 ++++++++++++++++----------- App_Code/Empresa.vb | 90 +++++++++++----------- App_Code/WS/WSSIGVentas.vb | 85 +++++++++++++++++++++ App_Code/WS/WSUSer.vb | 151 +++++++++++++++++++++++++++++++++++++ App_Code/WS/WsUtility.vb | 105 ++++++++++++++++++++++++++ App_Code/WebApiConfig.vb | 1 + App_Code/modExtensiones.vb | 63 +++++++++++----- packages.config | 4 + vwd.webinfo | 6 ++ 9 files changed, 507 insertions(+), 108 deletions(-) create mode 100644 App_Code/WS/WSSIGVentas.vb create mode 100644 App_Code/WS/WSUSer.vb create mode 100644 App_Code/WS/WsUtility.vb diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 70bf0364a..00f09143a 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -5138,56 +5138,74 @@ Public Class ClsPaginas 'limpio ReportViwer Dim sw As New System.Diagnostics.Stopwatch() sw.Start() + Dim bdir As String = AppDomain.CurrentDomain.BaseDirectory + RutaReporte.Replace("/", "\") + If Not RutaReporte.ToUpper().StartsWith(bdir.ToUpper()) Then + RutaReporte = String.Format("{0}{1}", bdir, RutaReporte) + End If + Dim CveUsuario As Integer = 0 + Dim CveEmpresa As Integer = 0 + If Context.Session("UsuarioSIG") IsNot Nothing Then + CveUsuario = UsuarioActual.CveUsuario + CveEmpresa = UsuarioActual.CveEmpresa + + End If Dim Bytes As Byte() = Nothing + Dim wsreport As New WSRDLC.WebServiceSoapClient + Dim params As New List(Of WSRDLC.ReportParameter) + Dim ds As New DataSet + For Each rpds As ReportDataSource In DataSource + Dim dt As DataTable = DirectCast(rpds.Value, Data.DataTable) + dt.TableName = rpds.Name + ds.Tables.Add(dt) + Next + For Each rpds As ReportParameter In Parametros + Dim param As New WSRDLC.ReportParameter + param.Name = rpds.Name + param.Values = {rpds.Values(0)} + params.Add(param) + Next + Dim ruta = wsreport.StreamPDF(RutaReporte, ds, params.ToArray(), NombreArchivo, Formato, CveEmpresa, CveUsuario) + If File.Exists(ruta) Then + Bytes = File.ReadAllBytes(ruta) + File.Delete(ruta) + End If + 'Dim setup As AppDomainSetup = New AppDomainSetup + 'With setup + ' .ApplicationBase = Environment.CurrentDirectory + ' .LoaderOptimization = LoaderOptimization.MultiDomainHost + 'End With + 'setup.SetCompatibilitySwitches({"NetFx40_LegacySecurityPolicy"}) + 'Dim _casPolicyEnabledDomain As AppDomain = AppDomain.CreateDomain("Full Trust", Nothing, setup) + 'Dim fllreport As ADSReportLib.FullTrustReportviewer = Nothing + 'Try - Dim setup As AppDomainSetup = New AppDomainSetup - With setup - .ApplicationBase = Environment.CurrentDirectory - .LoaderOptimization = LoaderOptimization.MultiDomainHost - End With - setup.SetCompatibilitySwitches({"NetFx40_LegacySecurityPolicy"}) - Dim _casPolicyEnabledDomain As AppDomain = AppDomain.CreateDomain("Full Trust", Nothing, setup) - Dim fllreport As ADSReportLib.FullTrustReportviewer = Nothing - Try - 'Dim rvNextgenReport2 As WebReportviewer.FullTrustReportviewer = CType(_casPolicyEnabledDomain.CreateInstanceFromAndUnwrap(GetType(WebReportviewer.FullTrustReportviewer).Assembly.CodeBase, GetType(WebReportviewer.FullTrustReportviewer).FullName), WebReportviewer.FullTrustReportviewer) - 'rvNextgenReport2.Initialize(DisplayName, ReportPath, Visible, reportParam, reportRenderFormat, DeviceInfo, repMainContent, repSubContent) + ' fllreport = CType(_casPolicyEnabledDomain.CreateInstanceFromAndUnwrap(GetType(ADSReportLib.FullTrustReportviewer).Assembly.CodeBase, GetType(ADSReportLib.FullTrustReportviewer).FullName), ADSReportLib.FullTrustReportviewer) - 'For Each _ReportDataSource As ReportDataSource In DataSources - ' rvNextgenReport2.AddDataSources(_ReportDataSource.Name, CType(_ReportDataSource.Value, DataTable)) - 'Next - - 'Return rvNextgenReport2.Render(reportRenderFormat, DeviceInfo) - fllreport = CType(_casPolicyEnabledDomain.CreateInstanceFromAndUnwrap(GetType(ADSReportLib.FullTrustReportviewer).Assembly.CodeBase, GetType(ADSReportLib.FullTrustReportviewer).FullName), ADSReportLib.FullTrustReportviewer) - - Dim bdir As String = AppDomain.CurrentDomain.BaseDirectory - RutaReporte.Replace("/", "\") - If Not RutaReporte.ToUpper().StartsWith(bdir.ToUpper()) Then - RutaReporte = String.Format("{0}{1}", bdir, RutaReporte) - End If - fllreport.Initialize("DisplayName", RutaReporte, Parametros.AsEnumerable(), New List(Of String()), True) - For Each RDS As ReportDataSource In DataSource - fllreport.AddDataSources(RDS.Name, DirectCast(RDS.Value, DataTable)) - Next - Dim Warnings As Warning() = Nothing - Dim StreamIds As String() = Nothing - Dim MimeType As String = Nothing - Dim Encoding As String = Nothing - Dim Extension As String = Nothing - Bytes = fllreport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds) - fllreport = Nothing - Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException - GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - Catch ex As Exception - GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - Finally - AppDomain.Unload(_casPolicyEnabledDomain) - End Try - If fllreport IsNot Nothing Then fllreport.liberarecursos() + ' fllreport.Initialize("DisplayName", RutaReporte, Parametros.AsEnumerable(), New List(Of String()), True) + ' For Each RDS As ReportDataSource In DataSource + ' fllreport.AddDataSources(RDS.Name, DirectCast(RDS.Value, DataTable)) + ' Next + ' Dim Warnings As Warning() = Nothing + ' Dim StreamIds As String() = Nothing + ' Dim MimeType As String = Nothing + ' Dim Encoding As String = Nothing + ' Dim Extension As String = Nothing + ' Bytes = fllreport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds) + ' fllreport = Nothing + 'Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException + ' GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") + ' 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + ' 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + 'Catch ex As Exception + ' GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") + ' 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + ' 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + 'Finally + ' AppDomain.Unload(_casPolicyEnabledDomain) + 'End Try + 'If fllreport IsNot Nothing Then fllreport.liberarecursos() sw.Stop() If sw.Elapsed.TotalSeconds > 10 Then diff --git a/App_Code/Empresa.vb b/App_Code/Empresa.vb index c16fa4e9b..2492f959c 100644 --- a/App_Code/Empresa.vb +++ b/App_Code/Empresa.vb @@ -4,51 +4,51 @@ Option Strict On Public Class Empresa - Public CveEmpresa As Integer - Public Empresa As String - Public NombreCorto As String - Public Direccion As String - Public NoExt As String - Public NoInt As String - Public Colonia As String - Public Ciudad As String - Public Estado As String - Public CP As Integer - Public RFC As String - Public CURP As String - Public RegistroPatronal As String - Public Telefono As String - Public Contacto As String - Public Mail As String - Public TipoFacturacion As String - Public ContraseñaKey As String - Public ArchivoKey As String - Public ArchivoCer As String - Public ArchivoPfx As String - Public BIUsuario As String - Public BIContraseña As String - Public Banner As String - Public FacturaProduccion As Boolean - Public FechaIng As Date - Public CveUsuario As Integer - Public SendMail As String - Public SendMailPassword As String - Public SendMailServer As String - Public SendMailPuerto As Integer - Public SendMailSSL As Boolean - Public Usuario As String - Public MostrarRetIVA As Boolean - Public EjercicioActual As Integer - Public PeriodoActual As Integer - Public GralSoloProyecto As Boolean - Public MetodoOC As Integer - Public CveMetodoInventario As Integer - Public RequiereCentroCostos As Boolean - Public EmpresaEncabezado As String - Public GrupoEmpresa As Integer - Public Extension As String - Public EsComercializadora As Boolean - Public BaseDatosNombre As String = "Ventas" + Public Property CveEmpresa As Integer + Public Property Empresa As String + Public Property NombreCorto As String + Public Property Direccion As String + Public Property NoExt As String + Public Property NoInt As String + Public Property Colonia As String + Public Property Ciudad As String + Public Property Estado As String + Public Property CP As Integer + Public Property RFC As String + Public Property CURP As String + Public Property RegistroPatronal As String + Public Property Telefono As String + Public Property Contacto As String + Public Property Mail As String + Public Property TipoFacturacion As String + Public Property ContraseñaKey As String + Public Property ArchivoKey As String + Public Property ArchivoCer As String + Public Property ArchivoPfx As String + Public Property BIUsuario As String + Public Property BIContraseña As String + Public Property Banner As String + Public Property FacturaProduccion As Boolean + Public Property FechaIng As Date + Public Property CveUsuario As Integer + Public Property SendMail As String + Public Property SendMailPassword As String + Public Property SendMailServer As String + Public Property SendMailPuerto As Integer + Public Property SendMailSSL As Boolean + Public Property Usuario As String + Public Property MostrarRetIVA As Boolean + Public Property EjercicioActual As Integer + Public Property PeriodoActual As Integer + Public Property GralSoloProyecto As Boolean + Public Property MetodoOC As Integer + Public Property CveMetodoInventario As Integer + Public Property RequiereCentroCostos As Boolean + Public Property EmpresaEncabezado As String + Public Property GrupoEmpresa As Integer + Public Property Extension As String + Public Property EsComercializadora As Boolean + Public Property BaseDatosNombre As String = "Ventas" 'Nuevos Public AreaGeografica As String diff --git a/App_Code/WS/WSSIGVentas.vb b/App_Code/WS/WSSIGVentas.vb new file mode 100644 index 000000000..1aefdebbe --- /dev/null +++ b/App_Code/WS/WSSIGVentas.vb @@ -0,0 +1,85 @@ +Imports System.Net +Imports System.Web.Http +Imports Extensiones +Imports WsUtility + +Namespace SIG + + + + Public Class SIGVentasController + Inherits ApiController + + + + Public Function CrearTrama( params As WsBody) As Object + Dim respuesta = "Entraste " 'New With {.Correcto = False, .Mensaje = "", .Datos = New JObject} + + Return respuesta + End Function + + + + + Public Function GetComplementoPago( params As WsBody) As Object + Dim respuesta As Data.DataTable = Nothing 'New With {.Correcto = False, .Mensaje = "", .Datos = New JObject} + + Dim CveCliente As Integer = -1 + Dim FechaI As DateTime = DateTime.Now + Dim FechaF As DateTime = DateTime.Now + Dim CveIE As Integer = -1 + Dim CveVenta As Integer = -1 + Dim opcion As Integer = -1 + Dim CveEmpresa As Integer = -1 + Dim status As Integer = -1 + + Dim continuar As Boolean = True + Dim jsobj As New JSutil(params.Datos) + + Dim value As String = Nothing + If continuar Then continuar = jsobj.GetValue("CveCliente", value) + If continuar Then CveCliente = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("FechaInicio", value) + If continuar Then DateTime.TryParseExact(value, "yyyyMMdd", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaI) + If continuar Then continuar = jsobj.GetValue("FechaFin", value) + If continuar Then DateTime.TryParseExact(value, "yyyyMMdd", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaF) + If continuar Then continuar = jsobj.GetValue("CveIE", value) + If continuar Then CveIE = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("Opcion", value) + If continuar Then opcion = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("CveVenta", value) + If continuar Then CveVenta = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("CveEmpresa", value) + If continuar Then CveEmpresa = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("Estatus", value) + If continuar Then status = value.ToEntero() + + + Using Banco As New ClsBancos() + If Banco.GetComplementoPagosRep(CveCliente, FechaI, FechaF, CveIE, CveVenta, opcion, CveEmpresa, Estatus:=status) Then + respuesta = Banco.DtResultados + End If + End Using + + Return JSutil.strresponse(respuesta, (Not IsNothing(respuesta)), "") + End Function + ' GET api/ + Public Function GetValues() As IEnumerable(Of String) + Return New String() {"value1", "value2"} + End Function + ' GET api//5 + Public Function GetValue(ByVal id As Integer) As String + Return "value" + End Function + ' POST api/ + Public Sub PostValue( ByVal value As String) + End Sub + ' PUT api//5 + Public Sub PutValue(ByVal id As Integer, ByVal value As String) + End Sub + ' DELETE api//5 + Public Sub DeleteValue(ByVal id As Integer) + End Sub + End Class + +End Namespace diff --git a/App_Code/WS/WSUSer.vb b/App_Code/WS/WSUSer.vb new file mode 100644 index 000000000..6d375f6d6 --- /dev/null +++ b/App_Code/WS/WSUSer.vb @@ -0,0 +1,151 @@ + +Imports System.Net +Imports System.Web.Http +Imports Extensiones +Imports WsUtility + +Namespace SIG + + + + Public Class usuarioController 'SIGVentasController + Inherits ApiController + + + + Public Function Login( params As WsBody) As Object + 'Dim respuesta = "" 'New With {.Correcto = False, .Mensaje = "", .Datos = New JObject} + Dim continuar As Boolean = True + Dim Token As Integer + If True Then + Dim authHeader = Request.Headers.Authorization + Dim dataArray = Extensiones.Decripta(authHeader.Parameter).Split("|"c) + If dataArray.Length > 4 AndAlso IsNumeric(dataArray(0)) AndAlso IsNumeric(dataArray(1)) AndAlso IsNumeric(dataArray(4)) Then + + Dim CveUsuario As Integer = dataArray(0).ToEntero() + Dim FechaPeticion As DateTime + DateTime.TryParseExact(String.Format("{0} {1}", dataArray(2), dataArray(3)), "ddMMyyyy HHmm", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaPeticion) + Dim CveEmpresa As Integer = dataArray(4).ToEntero() + + Dim diferencia As Double = (FechaPeticion - DateTime.Now).TotalMinutes + Token = diferencia.ToString("N0").ToEntero() + End If + End If + Dim jsobj As New JSutil(params.Datos) + + Dim username As String = Nothing + Dim password As String = Nothing + Dim CveEmpresastr As String = "-1" + Dim value As String = Nothing + If continuar Then continuar = jsobj.GetValue("UsuarioName", value) + If continuar Then username = value + If continuar Then continuar = jsobj.GetValue("Password", value) + If continuar Then password = value + If jsobj.GetValue("CveEmpresa", value) Then CveEmpresastr = value + + Dim Retorno As List(Of String) = Nothing + If continuar Then + Using objuser As New ClsSisUsuarios + Dim user As Usuario = objuser.ValidaUsuario(username, Extensiones.ModExtensiones.Encripta(password), "-1", CveEmpresastr.ToEntero()) + + Dim OjEmpresa As Empresa = Nothing + If user IsNot Nothing Then + If CveEmpresastr.ToEntero() > 0 Then + user.CveEmpresa = CveEmpresastr.ToEntero() + End If + Using ObjEmpresa As New ClsSisEmpresas() + + If ObjEmpresa.GetEmpresas(user.CveEmpresa, "-1", "-1", "-1", "-1") Then + 'If ObjEmpresa.GetEmpresasFuncionalidades(user.CveEmpresa) Then + ' Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados + + ' Dim EmpresasFuncionalidades As New HybridDictionary + ' For Each Row As Data.DataRow In dttmp.Rows + ' EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString) + ' Next + ' ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades) + 'End If + + OjEmpresa = ObjEmpresa.Empresa + End If + End Using + Dim Retornouser As UsuarioApp + Retornouser = New UsuarioApp With { + .CveUsuario = user.CveUsuario, + .Nombre = user.Nombre, + .UsuarioName = user.Usuario, + .CveRol = user.CveRol, + .Rol = user.Rol, + .CveEmpresa = user.CveEmpresa, + .Token = Token', .Empresa = OjEmpresa + } + Retorno = New List(Of String) + Retorno.Add(Extensiones.ModExtensiones.Encripta(Newtonsoft.Json.JsonConvert.SerializeObject(Retornouser))) + Retorno.Add(Extensiones.ModExtensiones.Encripta(Newtonsoft.Json.JsonConvert.SerializeObject(OjEmpresa))) + + End If + End Using + End If + Dim objrt = New WsBody With { + .Datos = Newtonsoft.Json.JsonConvert.SerializeObject(Retorno), + .IsFail = False, + .FailStr = "" + } + Return objrt + 'Return JSutil.strresponse(Retorno, (Not IsNothing(Retorno)), "") + End Function + + + + + + Public Function GetEmpresa() As Object + Dim retorno As Data.DataTable = Nothing + Using ObjEmpresas As New ClsSisEmpresas() + If ObjEmpresas.GetEmpresas(-1, "-1", "-1", "-1", "-1") Then + 'verifico si existe la carpeta de la empresa, sino la crea + For Each dr As Data.DataRow In ObjEmpresas.DtResultados.Rows + Dim Ruta As String = String.Format("{0}Empresas\{1}", AppDomain.CurrentDomain.BaseDirectory, dr("CveEmpresa")) + If Not IO.Directory.Exists(Ruta) Then IO.Directory.CreateDirectory(Ruta) + If Not System.IO.Directory.Exists(String.Format("{0}\XML\", Ruta)) Then System.IO.Directory.CreateDirectory(String.Format("{0}\XML\", Ruta)) + If Not System.IO.Directory.Exists(String.Format("{0}\PDF\", Ruta)) Then System.IO.Directory.CreateDirectory(String.Format("{0}\PDF\", Ruta)) + + Next + retorno = ObjEmpresas.DtResultados + End If + End Using + + + Return JSutil.strresponse(retorno, (Not IsNothing(retorno)), "") + End Function + + + + Public Function GetUsuariosEmpresa( params As WsBody) As Object + Dim retorno As Data.DataTable = Nothing + + Using ObjUsuarios As New ClsSisUsuarios() + If ObjUsuarios.GetUsuarios(-1, -1) Then + retorno = ObjUsuarios.DtResultados.FiltraParametros(String.Format("CveEmpresa = {0}", Extensiones.ModExtensiones.Decripta(params.Datos).ToEntero())) + End If + End Using + Return JSutil.strresponse(retorno, (Not IsNothing(retorno)), "") + End Function + End Class + + + Public Class UsuarioApp + Public Sub New() + End Sub + + Public Property CveUsuario As Integer + Public Property CveEmpresa As Integer + Public Property CveRol As Integer + Public Property Rol As String + Public Property Token As Integer + Public Property UsuarioName As String + Public Property Password As String + Public Property Nombre As String + + End Class +End Namespace diff --git a/App_Code/WS/WsUtility.vb b/App_Code/WS/WsUtility.vb new file mode 100644 index 000000000..ce5cf2ac1 --- /dev/null +++ b/App_Code/WS/WsUtility.vb @@ -0,0 +1,105 @@ +Imports System.Net.Http +Imports Microsoft.VisualBasic + + +Namespace WsUtility + + 'Public Class SigAuthenticationAttribute + ' Inherits Http.Filters.AuthorizationFilterAttribute + + + ' Public Sub New() + + ' End Sub + + ' Public Overrides Sub OnAuthorization(ByVal actionContext As Http.Controllers.HttpActionContext) + ' Dim authHeader = actionContext.Request.Headers.Authorization + ' Dim noautorizado As Boolean = True + ' If authHeader IsNot Nothing Then + ' Try + + ' Dim decodedAuthenticationToken = Extensiones.Decripta(authHeader.Parameter) + ' Dim dataArray = decodedAuthenticationToken.Split("|"c) + ' If dataArray.Length > 4 Then + + ' Dim CveUsuario As Integer = dataArray(0) + ' Dim Token As Integer = dataArray(1) + ' Dim FechaPeticion As DateTime + ' DateTime.TryParseExact(String.Format("{0} {1}", dataArray(2), dataArray(3)), "ddMMyyyy HHmm", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaPeticion) + ' FechaPeticion = FechaPeticion.AddMinutes(Token) + ' Dim CveEmpresa As Integer = dataArray(4) + + ' Dim diferencia As Integer = Math.Abs((FechaPeticion - DateTime.Now).TotalMinutes) + ' If diferencia < 30 Then + ' noautorizado = False + ' End If + ' End If + ' Catch ex As Exception + ' noautorizado = True + ' End Try + ' End If + ' If noautorizado Then + ' HandleUnathorized(actionContext) + ' End If + ' End Sub + + ' Private Shared Sub HandleUnathorized(ByVal actionContext As Http.Controllers.HttpActionContext) + ' actionContext.Response = actionContext.Request.CreateResponse(Net.HttpStatusCode.Unauthorized) + ' actionContext.Response.Headers.Add("WWW-Authenticate", "Basic Scheme='Data' location = 'http://localhost:") + ' End Sub + + 'End Class + Public Class JSutil + Public Property jsobj As Newtonsoft.Json.Linq.JObject + Public Sub New(strjson As String, Optional isencripted As Boolean = True) + If isencripted Then strjson = Extensiones.ModExtensiones.Decripta(strjson) + Try + jsobj = Newtonsoft.Json.Linq.JObject.Parse(strjson) + Catch ex As Exception + Extensiones.GuardaLog(String.Format("Json Invalido '{0}'{2}{1}", strjson, ex.ToString(), vbNewLine)) + End Try + End Sub + Public Function GetValue(FieldName As String, ByRef Valor As String) As Boolean + Dim continuar As Boolean = False + If Not IsNothing(jsobj) Then + + Dim value As Newtonsoft.Json.Linq.JToken = Nothing + + continuar = jsobj.TryGetValue(FieldName, value) + If continuar Then + Valor = value.ToString() + End If + End If + Return continuar + End Function + + Public Shared Function strresponse(objeto As Object, isFail As Boolean, FailStr As String) As WsBody + Dim retorno As String = "" + retorno = Newtonsoft.Json.JsonConvert.SerializeObject(objeto) + retorno = Extensiones.ModExtensiones.Encripta(retorno) + Dim objrt = New WsBody With { + .Datos = retorno, + .IsFail = isFail, + .FailStr = FailStr + } + 'retorno = Newtonsoft.Json.JsonConvert.SerializeObject(objrt) + Return objrt + End Function + + + End Class + Class UserValidation + Public Property CveUsuario As Integer + Public Property Token As String + Public Property Valida As Boolean + Public Property Min As Integer + + End Class + Public Class WsBody + Public Property Datos As String + Public Property Metodo As String + Public Property IsFail As Boolean + Public Property FailStr As String + End Class + +End Namespace diff --git a/App_Code/WebApiConfig.vb b/App_Code/WebApiConfig.vb index bc5121bcc..4b8bc43e6 100644 --- a/App_Code/WebApiConfig.vb +++ b/App_Code/WebApiConfig.vb @@ -9,5 +9,6 @@ Public Class WebApiConfig config.EnableCors(Cors) config.MapHttpAttributeRoutes() config.Filters.Add(New Extensiones.BasicAuthenticationAttribute("sigfoxapiuser", "_$83965./54")) + 'config.Filters.Add(New WsUtility.SigAuthenticationAttribute()) End Sub End Class \ No newline at end of file diff --git a/App_Code/modExtensiones.vb b/App_Code/modExtensiones.vb index 4fe2b853f..7a640df12 100644 --- a/App_Code/modExtensiones.vb +++ b/App_Code/modExtensiones.vb @@ -3330,33 +3330,62 @@ Namespace Extensiones #Region "A T R I B U T O S" Public Class BasicAuthenticationAttribute Inherits AuthorizationFilterAttribute - + Private Const SigfoxPath As String = "/api/sigfox" + Private Const LoginPath As String = "/api/usuario/Login" Public Property Usuario As String - Public Property Contra As String - + Public Property Contra As String + + Public Sub New() + End Sub Public Sub New(Usuario As String, Contra As String) Me.Usuario = Usuario Me.Contra = Contra End Sub Public Overrides Sub OnAuthorization(ByVal actionContext As HttpActionContext) - Dim authHeader = actionContext.Request.Headers.Authorization - + Dim authHeader = actionContext.Request.Headers.Authorization + Dim noautorizado As Boolean = True If authHeader IsNot Nothing Then - Dim authenticationToken = actionContext.Request.Headers.Authorization.Parameter - Dim decodedAuthenticationToken = Encoding.UTF8.GetString(Convert.FromBase64String(authenticationToken)) - Dim usernamePasswordArray = decodedAuthenticationToken.Split(":"c) - Dim userName = usernamePasswordArray(0) - Dim password = usernamePasswordArray(1) + If Left(actionContext.Request.RequestUri.AbsolutePath, 11).ToUpper() = SigfoxPath.ToUpper() Then + Dim usernamePasswordArray = Encoding.UTF8.GetString(Convert.FromBase64String(authHeader.Parameter)).Split(":"c) + Dim userName = usernamePasswordArray(0) + Dim password = usernamePasswordArray(1) + noautorizado = Not (userName = Me.Usuario AndAlso password = Me.Contra) + Else + Try + + If actionContext.Request.RequestUri.AbsolutePath.ToUpper() <> LoginPath.ToUpper() Then + Dim dataArray = Extensiones.Decripta(authHeader.Parameter).Split("|"c) + If dataArray.Length > 4 AndAlso IsNumeric(dataArray(0)) AndAlso IsNumeric(dataArray(1)) AndAlso IsNumeric(dataArray(4)) Then + + Dim CveUsuario As Integer = dataArray(0).ToEntero() + Dim Token As Integer = dataArray(1).ToEntero() + Dim FechaPeticion As DateTime + DateTime.TryParseExact(String.Format("{0} {1}", dataArray(2), dataArray(3)), "ddMMyyyy HHmm", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaPeticion) + FechaPeticion = FechaPeticion.AddMinutes(Token) + Dim CveEmpresa As Integer = dataArray(4).ToEntero() + + Dim diferencia As Double = (FechaPeticion - DateTime.Now).TotalMinutes + + diferencia = Math.Abs(diferencia) + If diferencia < 5 Then 'si la fecha que me envía es de cuando menos hace cinco minuto, se permite accesar, para que no se copie ese parámetro y se esté recuperando información "medida de seguridad" + noautorizado = False + End If + End If + Else + noautorizado = False + End If + Catch ex As Exception + noautorizado = True + End Try + End If + - Dim isValid = (userName = Me.Usuario AndAlso password = Me.Contra) - - If isValid Then - Return - End If + End If + + If noautorizado Then + HandleUnathorized(actionContext) End If - - HandleUnathorized(actionContext) End Sub Private Shared Sub HandleUnathorized(ByVal actionContext As HttpActionContext) diff --git a/packages.config b/packages.config index 888b93e1c..0878a2900 100644 --- a/packages.config +++ b/packages.config @@ -10,6 +10,10 @@ + + + + diff --git a/vwd.webinfo b/vwd.webinfo index 40d1fe36c..c9e193dc4 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -40,6 +40,12 @@ + + + + + + From 05acc43b783cd7637cdfd2bcffca712b0480f82e Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 15 Apr 2020 15:31:14 -0700 Subject: [PATCH 03/18] - folio poliza, cuando manda idpoliza --- Bancos/ProductosFinancieros.aspx.vb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Bancos/ProductosFinancieros.aspx.vb b/Bancos/ProductosFinancieros.aspx.vb index b8442756c..00fb880dc 100644 --- a/Bancos/ProductosFinancieros.aspx.vb +++ b/Bancos/ProductosFinancieros.aspx.vb @@ -304,6 +304,7 @@ Partial Class Bancos_ProductosFinancieros Dim CvePrePoliza = -1 Dim IdPoliza = -1 + Dim FolioPoliza As Integer = -1 Dim CveIE As Integer = -1 CvePrePoliza = ObjMov.AddPrePolizas("ProductosFinancieros/Registrar", DdlTipoMovimiento.SelectedValue.ToEntero, Importe, Importe, CveMoneda, TxtFecha.Text.ToDate, TxtConcepto.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) @@ -406,6 +407,7 @@ Partial Class Bancos_ProductosFinancieros IdPoliza = ObjContaAC.AddPoliza(3, TxtConcepto.Text.Trim, Importe, Importe, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate) If IdPoliza > 0 Then + FolioPoliza = ObjContaAC.Folio Dim DtPresupuestosTemp As DataTable Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz, IdCuentaEjercido, IdCuentaPagado As Integer @@ -493,6 +495,7 @@ Partial Class Bancos_ProductosFinancieros IdPoliza = ObjContaAC.AddPoliza(1, TxtConcepto.Text.Trim, Importe, Importe, UsuarioActual.CveUsuario, Fecha) If IdPoliza > 0 Then + FolioPoliza = ObjContaAC.Folio Dim DtPresupuestosTemp As DataTable Dim IdCuentaPorEjecutar, IdCuentaDevengado, IdCuentaRecaudado, IdCuentaMatriz As Integer @@ -559,7 +562,7 @@ Partial Class Bancos_ProductosFinancieros End If If Not ErrorTransaccion AndAlso Not ErrorAC Then - If Not ObjMov.UpdatePrePoliza(TxtFecha.Text.ToDate, -1, -1, IdPoliza, CvePrePoliza, UsuarioActual.CveEmpresa) Then + If Not ObjMov.UpdatePrePoliza(TxtFecha.Text.ToDate, FolioPoliza, -1, IdPoliza, CvePrePoliza, UsuarioActual.CveEmpresa) Then ErrorAC = True ErrorTransaccion = True End If From ba33616cf8da26a5e1735c97e0dc0b9579e6b228 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 15 Apr 2020 21:10:21 -0700 Subject: [PATCH 04/18] subiendo cambios en CRM --- App_Code/ClsCRM.vb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/App_Code/ClsCRM.vb b/App_Code/ClsCRM.vb index 67953b293..b4a4f540e 100644 --- a/App_Code/ClsCRM.vb +++ b/App_Code/ClsCRM.vb @@ -273,7 +273,7 @@ Public Class ClsCRM Return Retorno End Function - Public Function AddMedioCaptacion(MedioCaptacion As String, Descripcion As String, CveEmpresa As Integer, CveUsuarioIng As Integer) As Boolean + Public Function AddMedioCaptacion(MedioCaptacion As String, Descripcion As String, CveEmpresa As Integer, CveUsuarioIng As Integer, Optional CveTipoProceso As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_CRM_MedioCaptacionAdd") With SqlAdapter.SelectCommand.Parameters @@ -281,6 +281,7 @@ Public Class ClsCRM .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveUsuarioIng", SqlDbType.Int).Value = CveUsuarioIng + .Add("@CveTipoProceso", SqlDbType.Int).Value = CveTipoProceso End With Try SqlAdapter.Fill(Data) @@ -291,7 +292,8 @@ Public Class ClsCRM Return Retorno End Function - Public Function UpdateMedioCaptacion(MedioCaptacion As String, Descripcion As String, CveEstatus As Boolean, CveMedioCaptacion As Integer) As Boolean + Public Function UpdateMedioCaptacion(MedioCaptacion As String, Descripcion As String, CveEstatus As Boolean, CveMedioCaptacion As Integer, + Optional CveTipoProceso As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_CRM_MedioCaptacionUpdate") With SqlAdapter.SelectCommand.Parameters @@ -299,6 +301,7 @@ Public Class ClsCRM .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion .Add("@CveEstatus", SqlDbType.Bit).Value = CveEstatus .Add("@CveMedioCaptacion", SqlDbType.Int).Value = CveMedioCaptacion + .Add("@CveTipoProceso", SqlDbType.Int).Value = CveTipoProceso End With Try SqlAdapter.Fill(Data) @@ -590,13 +593,14 @@ Public Class ClsCRM Return Retorno End Function - Public Function AddProbabilidadAcercamiento(ProbabilidadAcercamiento As String, CveEmpresa As Integer, CveUsuarioIng As Integer) As Boolean + Public Function AddProbabilidadAcercamiento(ProbabilidadAcercamiento As String, CveEmpresa As Integer, CveUsuarioIng As Integer, Optional CveTipoProceso As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_CRM_ProbabilidadAcercamientoAdd") With SqlAdapter.SelectCommand.Parameters .Add("@ProbabilidadAcercamiento", SqlDbType.VarChar).Value = ProbabilidadAcercamiento .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveUsuarioIng", SqlDbType.Int).Value = CveUsuarioIng + .Add("@CveTipoProceso", SqlDbType.Int).Value = CveTipoProceso End With Try SqlAdapter.Fill(Data) @@ -607,7 +611,8 @@ Public Class ClsCRM Return Retorno End Function - Public Function UpdateProbabilidadAcercamiento(ProbabilidadAcercamiento As String, CveEstatus As Boolean, CveProbabilidadAcercamiento As Integer) As Boolean + Public Function UpdateProbabilidadAcercamiento(ProbabilidadAcercamiento As String, CveEstatus As Boolean, CveProbabilidadAcercamiento As Integer, + Optional CveTipoProceso As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_CRM_ProbabilidadAcercamientoUpdate") With SqlAdapter.SelectCommand.Parameters @@ -615,6 +620,7 @@ Public Class ClsCRM .Add("@CveEstatus", SqlDbType.Bit).Value = CveEstatus .Add("@CveProbabilidadAcercamiento", SqlDbType.Int).Value = CveProbabilidadAcercamiento + .Add("@CveTipoProceso", SqlDbType.Int).Value = CveTipoProceso End With Try SqlAdapter.Fill(Data) From 78711184075e8622e34f11cd25965f6c0e68aa22 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 16 Apr 2020 07:52:02 -0700 Subject: [PATCH 05/18] -ventaminima cambio de dato --- App_Code/ClsProductosServicios.vb | 10 +++++----- App_Code/Modelos.vb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index 9c6ca77d2..c90639042 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -385,7 +385,7 @@ Public Class ClsProductosServicios AplicaParaConcepto As Boolean, AplicaParaVenta As Boolean, CveUsuario As Integer, CveEmpresa As Integer, CveMetodoInventario As Integer, EsPaquete As Integer, Optional CveTipoPS As Integer = -1, Optional FuePorXML As Boolean = True, Optional TipoServicio As Integer = -1, Optional CveClasificacion2 As Integer = -1, Optional CveMarca As Integer = -1, Optional AlmacenSeccion As String = "", Optional AplicaIEPS As Boolean = False, Optional IEPSPorcentaje As Decimal = -1, - Optional CveConceptoContable As Integer = -1, Optional CveCompuesto As Integer = -1, Optional CveSATPS As Integer = -1, Optional IEPSGrabaIVA As Boolean = False, Optional VentaMinima As Integer = 0, + Optional CveConceptoContable As Integer = -1, Optional CveCompuesto As Integer = -1, Optional CveSATPS As Integer = -1, Optional IEPSGrabaIVA As Boolean = False, Optional VentaMinima As Decimal = 0, Optional CveMoneda As Integer = 1, Optional RetISR As Double = 0, Optional PrecioMinimo As Decimal = Nothing, Optional CveTipoFactor As Integer = 1, Optional CveFraccionArancelaria As Integer = -1, Optional CveClasificacionDetalle As Integer = -1, Optional CveTamaño As Integer = -1, Optional CveModelo As Integer = -1, Optional CveMedida As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional ClaveImpuestoEmpaque As String = "", Optional ClaveImpuestoUM As String = "", @@ -428,7 +428,7 @@ Public Class ClsProductosServicios 'Nuevo R: 26/09/2017' .Add("@Inventariable", SqlDbType.Bit).Value = Inventariable .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra - .Add("@VentaMinima", SqlDbType.Int).Value = VentaMinima + .Add("@VentaMinima", SqlDbType.Decimal).Value = VentaMinima 'Nuevo R: 08/11/2017' .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda @@ -522,7 +522,7 @@ Public Class ClsProductosServicios 'Nuevo R: 26/09/2017' .Add("@Inventariable", SqlDbType.Bit).Value = PS.Inventariable .Add("@CveProveedorCompra", SqlDbType.Int).Value = PS.CveProveedorCompra - .Add("@VentaMinima", SqlDbType.Int).Value = PS.VentaMinima + .Add("@VentaMinima", SqlDbType.Decimal).Value = PS.VentaMinima 'Nuevo R: 08/11/2017' .Add("@CveMoneda", SqlDbType.Int).Value = PS.CveMoneda @@ -604,7 +604,7 @@ Public Class ClsProductosServicios Public Function UpdatePS(CveClasificacion As Integer, CveClasificacionCosto As Integer, CveUnidadMedida As Integer, Codigo As String, Codigo2 As String, CodigoBarras As String, PS As String, Precio As Double, IVA As Double, RetIVA As Double, Inventariable As Boolean, CveProveedorCompra As Integer, AplicaParaConcepto As Boolean, AplicaParaVenta As Boolean, Estado As Boolean, CveUsuario As Integer, CvePS As Integer, CveMetodoInventario As Integer, EsPaquete As Integer, CveSATPS As Integer, Optional CveTipoPS As Integer = -1, Optional TipoServicio As Integer = -1, Optional CveClasificacion2 As Integer = -1, Optional CveMarca As Integer = -1, Optional AlmacenSeccion As String = "", Optional AplicaIEPS As Boolean = False, Optional IEPSPorcentaje As Decimal = -1, - Optional CveConceptoContable As Integer = -1, Optional CveCompuesto As Integer = -1, Optional IEPSGrabaIVA As Boolean = False, Optional VentaMinima As Integer = 0, + Optional CveConceptoContable As Integer = -1, Optional CveCompuesto As Integer = -1, Optional IEPSGrabaIVA As Boolean = False, Optional VentaMinima As Decimal = 0, Optional CveMoneda As Integer = 1, Optional RetISR As Double = 0, Optional PrecioMinimo As Decimal = Nothing, Optional CveTipoFactor As Integer = 1, Optional CveFraccionArancelaria As Integer = -1, Optional CveUsuarioModifico As Integer = -1, Optional CveClasificacionDetalle As Integer = -1, Optional CveTamaño As Integer = -1, Optional CveModelo As Integer = -1, Optional CveMedida As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional ClaveImpuestoEmpaque As String = "", Optional ClaveImpuestoUM As String = "", @@ -646,7 +646,7 @@ Public Class ClsProductosServicios 'Nuevo R: 26/09/2017' .Add("@Inventariable", SqlDbType.Bit).Value = Inventariable .Add("@CveProveedorCompra", SqlDbType.Int).Value = CveProveedorCompra - .Add("@VentaMinima", SqlDbType.Int).Value = VentaMinima + .Add("@VentaMinima", SqlDbType.Decimal).Value = VentaMinima 'Nuevo R: 08/11/2017' .Add("@CveMoneda", SqlDbType.Int).Value = CveMoneda diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index 8d4ebb2f7..e9b6b1ee3 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -9849,7 +9849,7 @@ Namespace Modelos Public Property Inventariable As Boolean? Public Property CveProveedorCompra As Integer? Public Property ProveedorCompra As String - Public Property VentaMinima As Integer? + Public Property VentaMinima As Decimal? Public Property RetISR As Integer? Public Property SATClaveProductoServicio As String Public Property PrecioMinimo As Double? From 591879dd432c39bcbdbb8b60fa35b68fdb6d675f Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 16 Apr 2020 07:52:17 -0700 Subject: [PATCH 06/18] -venta minima --- Ventas/ProductosServicios.aspx.vb | 5248 ++++++++++++++--------------- 1 file changed, 2624 insertions(+), 2624 deletions(-) diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb index 0f6f072f3..27d292fea 100644 --- a/Ventas/ProductosServicios.aspx.vb +++ b/Ventas/ProductosServicios.aspx.vb @@ -1,2626 +1,2626 @@ -Option Explicit On -Option Strict On - -Imports Extensiones -Imports System.IO -Imports System.Data -Imports ZXing - -Partial Class ProductosyServicios - Inherits ClsPaginas - -#Region " Propiedades " - Private ReadOnly Property CvePS As Integer - Get - Return ViewState("CvePS").ToString.ToEntero - End Get - End Property - - Private Property CveSATPS As Integer - Get - Return ViewState("CveSATPS").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CveSATPS") = value - End Set - End Property - - Private Property Ret As String - Get - Return ViewState("Ret").ToString - End Get - Set(value As String) - ViewState("Ret") = value - End Set - End Property - Private Property Borrar As Boolean - Get - Return CBool(ViewState("Borrar")) - End Get - Set(value As Boolean) - ViewState("Borrar") = value - End Set - End Property - Public Property dtPaqueteDetalles() As DataTable - Get - Return CType(ViewState("dtPaqueteDetalles"), DataTable) - End Get - Set(value As DataTable) - ViewState("dtPaqueteDetalles") = value - End Set - End Property - Public Property DtEquivalencias() As DataTable - Get - Return CType(ViewState("DtEquivalencias"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtEquivalencias") = value - End Set - End Property - Public Property dtFamily() As DataTable - Get - Return CType(ViewState("dtFamily"), DataTable) - End Get - Set(value As DataTable) - ViewState("dtFamily") = value - End Set - End Property - - - Property CodigoBarrasCargado As String - Get - If ViewState("CodigoBarrasCargado") Is Nothing Then - Return "" - Else - Return ViewState("CodigoBarrasCargado").ToString - End If - End Get - Set(value As String) - ViewState("CodigoBarrasCargado") = value - End Set - End Property - - Public Property DtPSAdicionales() As DataTable - Get - Return CType(ViewState("DtPSAdicionales"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtPSAdicionales") = value - End Set - End Property - - Private Property CvePSAdicional As Integer - Get - Return ViewState("CvePSAdicional").ToString.ToEntero - End Get - Set(value As Integer) - ViewState("CvePSAdicional") = value - End Set - End Property - Public Property DtSeccionAlmacen() As DataTable - Get - Return CType(ViewState("DtSeccionAlmacen"), DataTable) - End Get - Set(value As DataTable) - ViewState("DtSeccionAlmacen") = value - End Set - End Property - - -#End Region - - Private ReadOnly Property PermiteClasificacion2 As Boolean - Get - Return (UsuarioActual.CveEmpresa.Contiene(72, 80)) - End Get - End Property - - - -#Region " PROPIEDADES ECOMMERCE " - ''' - ''' Si es True existe en Eco_Produtcos - ''' - ''' - Private Property AplicaEcommerce As Boolean - Get - Return CBool(ViewState("AplicaEcommerce")) - End Get - Set(value As Boolean) - ViewState("AplicaEcommerce") = value - End Set - End Property -#End Region - - Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load - If Not IsPostBack Then - - InicializaValores() - If Request("CvePS") IsNot Nothing AndAlso IsNumeric(Request("CvePS")) AndAlso Request("CvePS").ToEntero > 0 Then - ViewState("CvePS") = Request("CvePS") - CargarMarcas() - - CargaDatos() - 'Configuración de Modalidad Update - BtnGuardar.Text = "Guardar Cambios" - - CargarAlias() - CargaExistencias() - CargaGvSeccionAlmacen() - Else - 'Configuración de Modalidad Insert - RegistraScript("$('#C_Tab_TabPaquetes_tab').css('display' , 'none')") - - ViewState("CvePS") = -1 - CargarMarcas() - - ChkEstado.Enabled = False - ChkEstado.Checked = True - LblFechaCaptura.Text = Now.ToShortDateString() - LblUsuarioCapturo.Text = UsuarioActual.Usuario - BtnEliminar.Visible = False - - If UsuarioActual.Empresa.Funcionalidad(543).ToString = "1" Then - Dim ObjSub As New ClsSubProyectos - Dim CveSubProyectoMatriz As Integer - - If ObjSub.GetSubProyectos() Then - CveSubProyectoMatriz = ObjSub.DtResultados.FiltroPrimeroValor("CveSubProyecto", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND TipoSucursal = 1").ToEntero - End If - - Dim ObjFolios As New ClsGralFolios() - If ObjFolios.GetFolios("PS", UsuarioActual.CveEmpresa) Then - - Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros($"CveSubProyecto = {CveSubProyectoMatriz} And Estado = 'Activo'") - If DT.Rows.Count > 0 Then - TxtCodigo.Text = DT.Rows(0)("FActual").ToString - TxtCodigo.Enabled = False - Else - Alert("No tiene registrados Folios para la sucursal matriz.", TipoMensaje.MsgAdvertencia) - End If - End If - End If - - End If - - If Request("Ret") IsNot Nothing AndAlso Request("Ret").ToString <> "" Then - Ret = Request("Ret") - End If - - 'CargaFamilia(ViewState("CveSubFamilia").ToString.ToEntero) - CargaSucursaless() - CargaImpuestosLocales() - CargaConceptoRelacionado() - - If UsuarioActual.TienePermisoProceso(122) Then - BtnEliminar.Visible = False - BtnGuardar.Visible = False - End If - - If UsuarioActual.Empresa.Funcionalidad(557) = "1" Then - DdlIVA.SelectedValueExist("-1") - DdlIVA.Attributes.Add("disabled", "disabled") - DdlIVA.Enabled = False - End If - - If CvePS > 0 Then - CargaEquivalencias() - CargaPSAdicionales() - CargaGvBitacora() - divBitacora.Visible = True - VerificaRequiereSerieLote() - End If - - If UsuarioActual.Empresa.Funcionalidad(524) <> "" Then - DivProveedorCompra.Visible = True - DivMoneda.Visible = True - End If - - UpDatos.Update() - - 'DdlClasificacion.AutoPostBack = UsuarioActual.CveEmpresa.Contiene(80, 72) - - InicializaEcommerce() - - If UsuarioActual.CveEmpresa.Contiene(141) Then - 'DivDatos.Attributes("class") = "col-md-12" - - DivDdlTipo.Visible = True - 'DdlTipoPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") - - End If - - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) And CvePS = -1 Then - 'DivDatos.Attributes("class") = "col-md-12" - TxtPS.Enabled = False - DivDdlTipo.Visible = True - DivTxtModelo.Visible = True - DivTxtAdicional.Visible = True - DdlTipoPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") - DdlMarcaPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") - TxtModelo.Attributes.Add("onKeyUp ", "CreaDescripcionPS();") - TxtAdicional.Attributes.Add("onKeyUp ", "CreaDescripcionPS();") - End If - - If ddlMetodos.SelectedValue.ToEntero = 5 And Not UsuarioActual.TienePermisoProceso(255) Then - ddlMetodos.Enabled = False - End If - Dim posiciontipo As String = If(UsuarioActual.Empresa.Funcionalidad(558).ToString = "1", "$('.DIVCLASIFICACIONCONTABLE').after( $('.DIVTIPO') );", "") - - LtlScripts.Text = $"" - If Not CvePS > 0 Then MuestraPanel(True) - - End If - End Sub - -#Region " INCIALIZA " - Private Sub InicializaValores() - ViewState("OrdenO") = "" - ViewState("OrdenC") = "" - ViewState("DTProductosServiciosCaracteristicas") = Nothing - ViewState("DTProductosServiciosCaracteristicasOpciones") = Nothing - ViewState("CveSubFamilia") = "-1" - Ret = "-1" - - 'CType(Me.Master, BaseMasterPage).EsPopup = True - 'CType(Me.Master, BaseMasterPage).PopupWidth = 700 - 'RegistraScript("$get('tdContenido').style.height='350px'") - - CargaClasificaciones() - CargaClasificaciones2() - CargaClasificacionesDetalles() - ClasificacionModal() - CargaTipoProductos() - CargaUnidadesMedida() - CargarMetodosInv() - 'CargaPSAdicional(DdlPSAdicional) - - 'Nuevo R: 26/09/2017 - CargaProveedores() - - CargarCompuestos() - CargaPS() - 'ChangeDdl() - CargaDdlSATPS() - CargaDdlFraccionArancelaria() - CveSATPS = -1 - - CargaCombosSeccionAlmacen() - DivSeccionAlmacen.Visible = UsuarioActual.Empresa.Funcionalidad(563).ToString = "1" - CreaDtSeccionAlmacen() - - If UsuarioActual.Empresa.UsaContabilidad Then - CargaCuentasContables() - If Not (Request("CvePS") IsNot Nothing AndAlso IsNumeric(Request("CvePS")) AndAlso Request("CvePS").ToEntero > 0) Then DivUsoClasificacion.Visible = True - End If - - 'CargaTipoServicio() - 'DivTipoServicio.Visible = False - - TxtDescripcion.Text = UCase(TxtDescripcion.Text) - - Dim objAcum As New ClsAcumuladores - If objAcum.TamañoGet(-1, UsuarioActual.CveEmpresa) Then - DdlTamanio.DataSource = objAcum.DtResultados - Else - DdlTamanio.DataSource = Nothing - End If - - objAcum.Dispose() - DdlTamanio.DataBind() - - If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then - DivLlantas.Visible = True - DivPSAdicionales.Visible = True - CargaPanelLlantas() - End If - - CvePSAdicional = -1 - - End Sub - - 'Private Sub CargaPSAdicional(Objeto As ADServerControl.Dropdownlost) - ' Objeto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(141).ToString = "1") - ' If Not UsuarioActual.Empresa.Funcionalidad(141).ToString = "1" Then - ' Objeto.ddl.Items.Clear() - ' Objeto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=-1, Estatus:=1, AplicaParaVenta:=1) - ' Objeto.ddl.DataBind() - ' Objeto.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) - ' Else - ' Objeto.ddlWS.Attributes.Add("data-Estatus", "1") - ' Objeto.SelectedValue = "-1" - ' Objeto.SelectedText = "Seleccione" - ' End If - 'End Sub - Private Sub CargaPanelLlantas() - Dim ObjGral As New ClsGenerales() - If ObjGral.GetModelos(UsuarioActual.CveEmpresa) Then - DdlModelo.DataSource = ObjGral.DtResultados.Copy() - End If - If ObjGral.GetMedidas(UsuarioActual.CveEmpresa) Then - DdlMedida.DataSource = ObjGral.DtResultados.Copy() - End If - If ObjGral.GetRimTamanios(UsuarioActual.CveEmpresa) Then - DdlRin.DataSource = ObjGral.DtResultados.Copy() - End If - ObjGral.Dispose() - - DdlModelo.DataBind() - DdlMedida.DataBind() - DdlRin.DataBind() - - End Sub - - Private Sub MuestraPanel(Optional AfterPageLoad As Boolean = False) - If AfterPageLoad Then - RegistraScript("window.onload = function MuestraPanel() { document.getElementById(""C_BtnMostrarPanel"").click(); }") - End If - End Sub - - - Protected Sub BtnTipoCla_Click(sender As Object, e As EventArgs) - PresionarBotonPanel("C_BtnCerrarPanel") - DivUsoClasificacion.Visible = False - DdlUsoClasificacion.SelectedValueExist(RblTipoClasificación.SelectedValue) - CargaClasificaciones() - UpDatos.Update() - End Sub - - Private Sub PresionarBotonPanel(Boton As String) - Dim Script As String = $"document.getElementById(""{Boton}"").click();" - Dim Pag As System.Web.UI.Page = CType(System.Web.HttpContext.Current.Handler, System.Web.UI.Page) - ScriptManager.RegisterStartupScript(Pag, Pag.GetType(), Boton, Script, True) - Pag = Nothing - End Sub -#End Region - -#Region "S U C U R S A L E S" - Private Sub CargaSucursaless() - 'Dim dtSuc As DataTable = GlobalDTSucursales().FiltraParametros("CveEmpresa = " + UsuarioActual.CveEmpresa.ToString) - 'dtSuc.AcceptChanges() - - 'dtSuc.Columns.Add("Importe") - 'dtSuc.Columns.Add("Activo") - - 'For Each row As DataRow In dtSuc.Rows - ' row("Activo") = False - 'Next - 'dtSuc.AcceptChanges() - - 'If Not ViewState("CvePS") Is Nothing Then - ' Dim ObjPS As New ClsProductosServicios - - ' If ObjPS.GetPSSucursales(CvePS) Then - ' Dim dtSucP As DataTable = ObjPS.DtResultados - - ' For Each Row As DataRow In dtSucP.Rows - ' Dim rowsToUpdate = dtSuc.AsEnumerable().Where(Function(r) r.Field(Of Integer)("CveSucursal") = Row("CveSucursal").ToString.ToEntero AndAlso r!CveSucursal.ToString.ToEntero > 0) - - ' For Each roww As DataRow In rowsToUpdate - ' roww.SetField("Importe", Row("Importe")) - ' roww.SetField("Activo", True) - ' Next - - ' 'For Each drtt As DataRow In TmpDT.Select(String.Format("PS='{0}' AND CvePS=0", Row("PS"))) - ' ' drtt("CvePS") = tCve - ' 'Next - - - ' dtSuc.AcceptChanges() - ' Next - ' End If - - ' ObjPS.Dispose() - 'End If - - 'gvSucursal.DataSource = dtSuc - 'gvSucursal.DataBind() - - Dim ObjPS As New ClsProductosServicios - - If ObjPS.GetPSSucursales(CvePS, UsuarioActual.CveEmpresa) Then - gvSucursal.DataSource = ObjPS.DtResultados - - End If - - ObjPS.Dispose() - gvSucursal.DataBind() - End Sub - - Protected Sub gvSucursal_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvSucursal.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - e.Row.Cells(0).Width = Unit.Pixel(50) - e.Row.Cells(1).Width = Unit.Pixel(100) - e.Row.Cells(2).Width = Unit.Pixel(100) - End If - - ' If e.Row.FCCheckBox("chkSucursal").Checked = True Then e.Row.Cells(0).BackColor = Drawing.Color.Yellow - End If - End Sub -#End Region - -#Region "C A R A C T E R I S T I C A S" - - Private Sub CargaCaracteristicas() - ' CargaDatosC() - CargaProductosServiciosCaracteristicas() - CambioProductosServiciosCaracteristicas(DdlCaracteristica.SelectedValue.ToEntero) - CargaDatosO() - UpDatos.Update() - UpDatosO.Update() - UpTitulosO.Update() - - End Sub - Public Sub CargaDatosO() - Dim Objeto As New ClsGenerales - If Objeto.GetCaracteristicasValores(-1, -1, CvePS, -1, -1, -1, 5, UsuarioActual.CveEmpresa, OpcionListado:=1) Then - GvDatosOpciones.DataSource = Objeto.DtResultados - End If - Objeto.Dispose() - UpDatosO.Update() - GvDatosOpciones.DataBind() - - End Sub - - - Private Sub LbAgregarO_Click(sender As Object, e As EventArgs) Handles LbAgregarO.Click - Dim Objeto As New ClsGenerales - Dim Opcion As String = If(TDTxtOpcion.Visible = True, TxtOpcion.Text, DdlOpcion.SelectedItem.Text) - Dim Opcion2 As Integer = If(TDDdlOpcion.Visible = True, DdlOpcion.SelectedValue.ToEntero, -1) - - If Objeto.AddUpdateCaracteristicasValores(DdlCaracteristica.SelectedValue.ToEntero, Opcion2, Opcion, UsuarioActual.CveUsuario, CvePs:=CvePS) Then - End If - Objeto.Dispose() - TxtOpcion.Text = "" - CargaDatosO() - UpDatosO.Update() - UpTitulosO.Update() - Alert("El valor de la caracteristica se agregó correctamente.", TipoMensaje.MsgInformacion) - End Sub - - Private Sub CargaProductosServiciosCaracteristicas() - Dim Objeto As New ClsGenerales - DdlCaracteristica.Items.Clear() - If Objeto.GetCaracteristicas(-1, 5, UsuarioActual.CveEmpresa) Then - DdlCaracteristica.DataSource = Objeto.DtResultados - End If - Objeto.Dispose() - DdlCaracteristica.DataBind() - End Sub - - Protected Sub DdlCaracteristica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCaracteristica.SelectedIndexChanged - CambioProductosServiciosCaracteristicas(DdlCaracteristica.SelectedValue.ToEntero) - End Sub - - Protected Sub CambioProductosServiciosCaracteristicas(CveCaracteristica As Integer) - Dim Objeto As New ClsGenerales - If Objeto.GetCaracteriscasOpciones(CveCaracteristica, UsuarioActual.CveEmpresa) Then - Dim dr As DataRow = Objeto.DtResultados.FiltroPrimero(String.Format(("CveCaracteristica={0}"), CveCaracteristica)) - If dr IsNot Nothing Then - If dr("CveCaracteristicaTipo").ToString = "1" Then - DdlOpcion.Items.Clear() - DdlOpcion.DataSource = Objeto.DtResultados.FiltraParametros(String.Format(("CveCaracteristica={0}"), CveCaracteristica)) - - TDDdlOpcion.Visible = True - TDTxtOpcion.Visible = False - Else - TDTxtOpcion.Visible = True - TDDdlOpcion.Visible = False - End If - - End If - End If - Objeto.Dispose() - DdlOpcion.DataBind() - End Sub - - Protected Sub CambioProductosServiciosCaracteristicasOpciones() - UpTitulosO.Update() - End Sub -#End Region - -#Region "G V O P C I O N E S" - Protected Sub GvDatosOpciones_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatosOpciones.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - e.Row.Cells(0).Width = Unit.Pixel(150) - e.Row.Cells(1).Width = Unit.Pixel(150) - e.Row.Cells(2).Width = Unit.Pixel(100) - e.Row.Cells(3).Width = Unit.Pixel(100) - e.Row.Cells(4).Width = Unit.Pixel(50) - End If - e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left - - If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then - e.Row.FCDropDownList("DdlCaracteristicaEdit").DataSource = GlobalDTProductosServiciosCaracteristicas(UsuarioActual.CveEmpresa).FiltraParametros("CvePS = " + CvePS.ToString) - e.Row.FCDropDownList("DdlCaracteristicaEdit").DataBind() - e.Row.FCDropDownList("DdlCaracteristicaEdit").SelectedValue = e.Row.DBCampo("CvePS") - End If - End If - End Sub - Protected Sub GvDatosOpciones_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatosOpciones.RowDeleting - Dim ObjOpciones As New ClsGenerales - Dim CveCaracteristicaValor As Integer = GvDatosOpciones.Rows(e.RowIndex).DataKey("CveCaracteristicaValor").ToEntero - - If ObjOpciones.RemoveCaracteristicasValores(CveCaracteristicaValor, CvePS:=CvePS) Then - GvDatosOpciones.EditIndex = -1 - CambioProductosServiciosCaracteristicasOpciones() - CargaDatosO() - UpDatosO.Update() - Alert("La Opción para Caracteristica del Producto o Servicio se eliminó correctamente.", TipoMensaje.MsgInformacion) - End If - - ObjOpciones.Dispose() - End Sub - Protected Sub GvDatosOpciones_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatosOpciones.RowCancelingEdit - GvDatosOpciones.EditIndex = -1 - End Sub - Protected Sub GvDatosOpciones_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatosOpciones.RowUpdating - Dim ObjOpciones As New ClsGralProductosServiciosCaracteristicas - Dim CveCaracteristica As Integer = DirectCast(GvDatosOpciones.Rows(e.RowIndex).FindControl("DdlCaracteristicaEdit"), DropDownList).SelectedValue.ToEntero - Dim CveOpcion As Integer = GvDatosOpciones.DataKeys(e.RowIndex).Value.ToString.ToEntero - - Dim Opcion As String = DirectCast(GvDatosOpciones.Rows(e.RowIndex).FindControl("TxtOpcion"), TextBox).Text.Trim - - If ObjOpciones.UpdateProductosServiciosCaracteristicasOpciones(Opcion, CveCaracteristica, CveOpcion) Then - GvDatosOpciones.EditIndex = -1 - ViewState("DTProductosServiciosCaracteristicasOpciones") = ObjOpciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) - GlobalDTProductosServiciosCaracteristicasOpciones(UsuarioActual.CveEmpresa) = ObjOpciones.DtResultados - Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) - - CambioProductosServiciosCaracteristicasOpciones() - End If - - ObjOpciones.Dispose() - End Sub - - 'Protected Sub GvDatosOpciones_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatosOpciones.RowEditing - ' GvDatosOpciones.EditIndex = e.NewEditIndex - ' CargaGrid() - 'End Sub -#End Region - -#Region "O R D E N A M I E N T O" - Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs) - Dim Orden As String = "" - Dim Campo As String = "" - Dim gvi As Integer = 0 - Dim Literal As Literal = Nothing - Const OrdenInicial As String = "" - Dim Arg(2) As String - - Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c) - Campo = Arg(0) - gvi = Arg(1).ToEntero - Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(", ", "_")), Literal) - Campo = Campo.Substring(0, Campo.Length - 1) - - If ViewState(String.Format("O{0}", Campo, gvi)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo, gvi)).ToString = String.Format("{0} DESC", Campo) Then - ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo) - Literal.Text = String.Format("") - Else - ViewState(String.Format("O{0}", Campo, gvi)) = String.Format("{0} DESC", Campo) - Literal.Text = String.Format("") - End If - Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo, gvi)).ToString - ViewState("Orden") = Orden - End Sub - - - - 'Private Sub CargaGrid() - ' Dim Objeto As New ClsGralProductosServiciosCaracteristicas - ' If Objeto.GetPSCaracteristicas(UsuarioActual.CveEmpresa) Then - ' GvDatosCaracteristicas.DataSource = Objeto.DtResultados - ' End If - ' GvDatosCaracteristicas.DataBind() - ' Objeto.Dispose() - 'End Sub - - - -#End Region - -#Region "C A R G A S" - Private Sub ClasificacionModal() - DdlClasificacionModal.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") - DdlClasificacionModal.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlClasificacionModal.DataBind() - UpModal.Update() - End Sub - - Private Sub CargaClasificacionesDetalles() - DdlTipoPSDes.Items.Clear() - DdlTipoPSDes.DataSource = GlobalDTClasificacionesDetalle(UsuarioActual.CveEmpresa) - 'If DdlClasificacion.SelectedValue.ToEntero > 0 Then - 'Dim ObjVenta As New ClsVentas - ' If ObjVenta.GetClasificacionDetalle(UsuarioActual.CveEmpresa, CveClasificacion:=-1) Then - ' DdlTipoPSDes.DataSource = ObjVenta.DtResultados - ' End If - ' ObjVenta.Dispose() - 'End If - DdlTipoPSDes.Items.Insert(0, New ListItem("Seleccione", "-1")) - DdlTipoPSDes.DataBind() - End Sub - Private Sub CargaClasificaciones() - DdlClasificacion.Items.Clear() - If UsuarioActual.Empresa.UsaAC Then - DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=If(UsuarioActual.Empresa.UsaContabilidad, DdlUsoClasificacion.SelectedValue.ToEntero, -1)).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") - Else - DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=If(UsuarioActual.Empresa.UsaContabilidad, DdlUsoClasificacion.SelectedValue.ToEntero, -1)).FiltraParametros("", Orderby:="Clasificacion") - End If - DdlClasificacion.Items.Insert(0, New ListItem("Seleccione", "-1")) - 'BLOQUEA DDL CLASIFICACION - If UsuarioActual.Empresa.Funcionalidad(121) = "1" Then - If Not UsuarioActual.TienePermisoProceso(147) Then - DdlClasificacion.Enabled = False - End If - End If - DdlClasificacion.DataBind() - End Sub - Private Sub CargaClasificaciones2() - DdlClasificacion2.DataSource = GlobalDTClasificaciones2(UsuarioActual.CveEmpresa) - DdlClasificacion2.DataBind() - DdlClasificacion2.Items.Insert(0, New ListItem("Sin Clasificacion", "-1")) - DdlClasificacion2.SelectedValueExist("-1") - - 'BLOQUEA DDL CLASIFICACION - If PermiteClasificacion2 Then - DivClasificacion2.Visible = True - End If - - End Sub - Private Sub CargaTipoProductos() - 'BLOQUEA DDL TIPO PRODUCTO - If UsuarioActual.Empresa.Funcionalidad(122) = "1" Then - If Not UsuarioActual.TienePermisoProceso(149) Then - DdlTipoPS.Enabled = False - DdlTipoPS.SelectedValueExist("2") - End If - End If - End Sub - Private Sub CargaConceptoRelacionado() - DdlConceptoRelacionado.DataSource = GlobalDTContaConceptosContables(-1) - DdlConceptoRelacionado.DataBind() - End Sub - Private Sub CargarMetodosInv() - ddlMetodos.DataSource = If(UsuarioActual.CveEmpresa.Contiene(72, 80), GlobalDTInvMetodosInventario.FiltraParametros("CveMetodoInventario IN (1,5)"), GlobalDTInvMetodosInventario) - ddlMetodos.DataBind() - ddlMetodos.Items.Insert(0, New ListItem("Seleccione", "-1")) - End Sub - - 'Nuevo R: 26/09/207' - Private Sub CargaProveedores() - DdlProveedor.setEsWebService(True) - 'DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) - 'DdlProveedor.DataBind() - 'DdlProveedor.Items.Insert(0, New ListItem("Seleccione", "-1")) - - DdlMoneda.DataSource = GlobalDTMonedas() - DdlMoneda.DataBind() - DdlMoneda.Items.Insert(0, New ListItem("Seleccione", "-1")) - - End Sub - - - - Private Sub CargaUnidadesMedida() - DdlUnidadMedida.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) - DdlUnidadMedida.DataBind() - End Sub - Private Sub CargaCuentasContables() - 'Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa.ServerContPAQi, UsuarioActual.Empresa.BDContPAQi, UsuarioActual.Empresa.UsrContPAQi, UsuarioActual.Empresa.PwdContPAQi) - 'If ObjContabilidad.GetCuentas(-1, "-1", -1) Then - ' DdlCtaContableVentas.DataSource = ObjContabilidad.DtResultados - ' DdlCtaContableCompras.DataSource = ObjContabilidad.DtResultados - ' DdlCtaContableInventarios.DataSource = ObjContabilidad.DtResultados - 'Else - ' DdlCtaContableVentas.DataSource = Nothing - ' DdlCtaContableCompras.DataSource = Nothing - ' DdlCtaContableInventarios.DataSource = Nothing - 'End If - 'DdlCtaContableVentas.DataBind() - 'DdlCtaContableCompras.DataBind() - 'DdlCtaContableInventarios.DataBind() - 'ObjContabilidad.Dispose() - End Sub - Private Sub CargaDatos() - Dim ObjProductosServicios As New ClsProductosServicios() - If ObjProductosServicios.GetPS(CvePS, -1, UsuarioActual.CveEmpresa) Then - If ObjProductosServicios.DtResultados.Rows.Count > 0 Then - - 'SI NO TIENE VALOR Y NO TIENE EL PROCESO MUESTRA SIN CLASIFICACION - If ObjProductosServicios.CveClasificacion.ToString.Equals("-1") And Not UsuarioActual.TienePermisoProceso(147) And UsuarioActual.Empresa.Funcionalidad(121) = "1" Then - DdlClasificacion.SelectedValueExist("0") - Else - DdlClasificacion.SelectedValueExist(ObjProductosServicios.CveClasificacion.ToString) - End If - CargaClasificacionesDetalles() - DdlClasificacion2.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveClasificacion2").ToString) - DdlCompuesto.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveCompuesto").ToString) - 'SI ES NUEVO TIPO = PRODUCTO Y SI NO TIENE PROCESO NO PUEDO EDITAR - If ObjProductosServicios.CveTipoPS.ToString.Equals("-1") And Not UsuarioActual.TienePermisoProceso(149) And UsuarioActual.Empresa.Funcionalidad(122) = "1" Then - DdlTipoPS.SelectedValueExist("2") - Else - DdlTipoPS.SelectedValueExist(ObjProductosServicios.CveTipoPS.ToString) - End If - - 'If ObjProductosServicios.CveTipoPS = 1 Then - ' DivTipoServicio.Visible = True - ' DdlTipoServicio.SelectedValueExist(ObjProductosServicios.Estado2.ToString) - - ' If Not DdlTipoServicio.SelectedValue.ToEntero > 0 Then - ' DdlTipoServicio.Items.Insert(1, New ListItem(If(ObjProductosServicios.Estado2 = 1, "General", "Maquinaria"), ObjProductosServicios.Estado2.ToString)) - ' DdlTipoServicio.SelectedValueExist(ObjProductosServicios.Estado2.ToString) - ' End If - 'End If - If ObjProductosServicios.CveSATPS.ToString <> Nothing Then - DdlSATPS.SelectedValue = ObjProductosServicios.CveSATPS.ToString - DdlSATPS.SelectedText = $"{ObjProductosServicios.SATClavePS} - {ObjProductosServicios.SATDescripcion}" - CveSATPS = ObjProductosServicios.CveSATPS - End If - If ObjProductosServicios.CveFraccionArancelaria.ToString <> Nothing Then - DdlFraccionArancelaria.SelectedValue = ObjProductosServicios.CveFraccionArancelaria.ToString - DdlFraccionArancelaria.SelectedText = ObjProductosServicios.ClaveSATFraccionArancelariaDescripcion - End If - If ObjProductosServicios.ClaveSATUnidadAduanaDescripcion.ToString <> Nothing Then - LblUnidadAduana.Text = ObjProductosServicios.ClaveSATUnidadAduanaDescripcion.ToString - End If - DdlTipoPSDes.SelectedValueExist(ObjProductosServicios.CveClasificacionDetalle.ToString) - DdlUnidadMedida.SelectedValue = ObjProductosServicios.CveUnidadMedida.ToString - DdlMarca.SelectedValue = ObjProductosServicios.CveMarca.ToString - DdlMarcaPSDes.SelectedValue = ObjProductosServicios.CveMarca.ToString - TxtCodigo.Text = ObjProductosServicios.Codigo - 'TxtCodigo2.Text = ObjProductosServicios.Codigo2 - TxtCodigoBarras.Text = ObjProductosServicios.CodigoBarras - CodigoBarrasCargado = ObjProductosServicios.CodigoBarras - - TxtPS.Text = ObjProductosServicios.PS - TxtPrecio.Text = ObjProductosServicios.Precio.ToString("F4") 'no usa N4, porque pone comma - TxtPrecioMinimo.Text = ObjProductosServicios.PrecioMinimo.ToString("F4") - - DdlTipoFactor.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveTipoFactor").ToString) - - If ObjProductosServicios.DtResultados.Rows(0)("CveTipoFactor").ToString.Contiene("1", "2") Then - LIva.Visible = True - DdlIVA.Visible = True - DdlIVA.Width = New Unit("163px") - Else - DdlIVA.Visible = False - DdlIVA.Visible = False - End If - DdlIVA.SelectedValueExist(ObjProductosServicios.IVA.ToString) - - - LblCostoPromedio.Text = ObjProductosServicios.DtResultados.Rows(0)("CostoPromedio").ToString.FormatoNumero - LblUltimoCosto.Text = ObjProductosServicios.DtResultados.Rows(0)("UltimoCosto").ToString.FormatoNumero - LblFechaUltimaCompra.Text = ObjProductosServicios.DtResultados.Rows(0)("FechaUltimaCompra").ToString - HplKardex.NavigateUrl = $"/Inventarios/Kardex.aspx?CvePS={CvePS}" - - TxtRetIVA.Text = (ObjProductosServicios.RetIVA * 100).ToString - ChkEstado.Checked = ObjProductosServicios.Estado - LblFechaCaptura.Text = ObjProductosServicios.Fecha.ToShortDateString - LblUsuarioCapturo.Text = ObjProductosServicios.Usuario - If ObjProductosServicios.CveUsuarioModifico > 0 Then - LblFechaModificacion.Text = ObjProductosServicios.FechaUltimaModificacion.ToString - LblUsuarioModifico.Text = ObjProductosServicios.UsuarioModifico - End If - 'ChkAplicaParaConcepto.Checked = ObjProductosServicios.AplicaParaConcepto - ChkAplicaParaVenta.Checked = ObjProductosServicios.AplicaParaVenta - lbTitulo.Text = $"{lbTitulo.Text}{ObjProductosServicios.PS}" - LtProductoUnificar.Text = ObjProductosServicios.PS - ddlMetodos.SelectedValue = ObjProductosServicios.CveMetodoInventario.ToString - TxtAlmacenSeccion.Text = ObjProductosServicios.AlmacenSeccion.ToString - DdlConceptoRelacionado.SelectedValueExist(ObjProductosServicios.CveConceptoContable.ToString) - - DdlProveedor.SelectedValue = ObjProductosServicios.CveProveedorCompra.ToString - DdlProveedor.SelectedText = ObjProductosServicios.ProveedorCompra - - DdlProveedor.txtText.Value = ObjProductosServicios.ProveedorCompra - DdlProveedor.txtValue.Value = ObjProductosServicios.CveProveedorCompra.ToString - - ChkInventariable.Checked = ObjProductosServicios.Inventariable - TxtVentaMinima.Text = ObjProductosServicios.VentaMinima.ToString - DdlMoneda.SelectedValueExist(ObjProductosServicios.CveMoneda) - TxtRetISR.Text = (ObjProductosServicios.RetISR * 100).ToString - - DdlTamanio.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveTamaño").ToString) - - DdlModelo.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveModelo").ToString) - DdlMedida.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveMedida").ToString) - DdlRin.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveRinTamaño").ToString) - - 'If ObjProductosServicios.CvePSAdicional > 0 Then - ' DdlPSAdicional.SelectedValue = ObjProductosServicios.CvePSAdicional.ToString - ' DdlPSAdicional.SelectedText = ObjProductosServicios.PSCodigoAdicional - 'Else - ' DdlPSAdicional.SelectedValue = "-1" - ' DdlPSAdicional.SelectedText = "Seleccione" - 'End If - - Try - DdlClasificacion_SelectedIndexChanged(DdlClasificacion, Nothing) - Catch ex As Exception - - End Try - - ChkAplicaIeps.Checked = ObjProductosServicios.AplicaIEPS - If ObjProductosServicios.AplicaIEPS = True Then - DdlIEPSPorcentaje.Enabled = True - DdlIEPSPorcentaje.SelectedValue = ObjProductosServicios.IEPSPorcentaje.ToString("N2") - ChkIepsIVA.Enabled = True - ChkIepsIVA.Checked = ObjProductosServicios.IEPSGrabaIVA - End If - - DdlImpTipoProducto.SelectedValueExist(ObjProductosServicios.ClaveImpuestoTipoProducto) - CargaClaveGenerica(DdlImpTipoProducto.SelectedValue) - DdlImpEmpaque.SelectedValueExist(ObjProductosServicios.ClaveImpuestoEmpaque) - DdlImpUM.SelectedValueExist(ObjProductosServicios.ClaveImpuestoUnidadMedida) - DdlCategoriaToxicidad.SelectedValueExist(ObjProductosServicios.ClaveCategoriaToxicidad) - - 'If ObjProductosServicios.CveMetodoInventario = 0 Then ddlMetodos.SelectedValue = UsuarioActual.Empresa.CveMetodoInventario.ToString - - ViewState("CveSubFamilia") = ObjProductosServicios.DtResultados.Rows(0)("CveSubFamilia") - - CargaCaracteristicas() - - LnkUnificar.Visible = True - ChkEsOutSourcing.Checked = ObjProductosServicios.EsOutSourcing - Else - Alert("El Producto o Servicio Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) - RegistraScript("$('#C_Tab_TabPaquetes_tab').css('display' , 'none')") - BtnGuardar.Enabled = False - End If - End If - - If ObjProductosServicios.GetPaqueteDetalle(CvePS, UsuarioActual.CveEmpresa) Then - gvPaqueteDetalle.DataSource = ObjProductosServicios.DtResultados - dtPaqueteDetalles = ObjProductosServicios.DtResultados - - End If - ObjProductosServicios.Dispose() - gvPaqueteDetalle.DataBind() - End Sub - Protected Sub CargarAlias() - Dim ObjAlias As New ClsProductosServicios - ObjAlias.GetPSAlias(CvePS, UsuarioActual.CveEmpresa) - GVAlias.DataSource = ObjAlias.DtResultados - ObjAlias.Dispose() - GVAlias.DataBind() - End Sub - - Public Sub CargaDdlSATPS() - DdlSATPS.setEsWebService(True) - DdlSATPS.Attributes.Add("data-metodo", "getpssat") - End Sub - - Public Sub CargaDdlFraccionArancelaria() - DdlFraccionArancelaria.setEsWebService(True) - DdlFraccionArancelaria.Attributes.Add("data-metodo", "getfraccionarancelaria") - End Sub - Private Sub VerificaRequiereSerieLote() - If UsuarioActual.CveEmpresa.Contiene(80, 72) And DdlClasificacion.SelectedIndex > 0 Then - Dim RequireSerieLote As Integer = (GlobalDTClasificaciones(UsuarioActual.CveEmpresa, -1).FiltraParametros("CveClasificacion=" & DdlClasificacion.SelectedValue.ToString))(0)("RequiereSerieLote").ToString.ToEntero - If RequireSerieLote = 1 Then - RfvddlMetodos.Enabled = True - Else - RfvddlMetodos.Enabled = False - End If - Else - RfvddlMetodos.Enabled = False - End If - UpMetodos.Update() - End Sub - -#End Region - - '#Region "Familias" - ' Protected Sub DdlFamilia_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlFamilia.SelectedIndexChanged - ' CargaDdlSubFamilia() - ' DdlSubFamilia.SelectedValue = "-1" - ' End Sub - ' Public Sub CargaFamilia(Optional CveSubFamilia As Integer = 0) - ' dtFamily = GlobalDTSubFamilias(UsuarioActual.CveEmpresa) - ' CargaDdlFamilia() - ' If dtFamily.FiltraParametros(String.Format("CveClasificacion={0}", CveSubFamilia)).Rows.Count > 0 Then - ' DdlFamilia.SelectedValue = dtFamily.FiltraParametros(String.Format("CveClasificacion={0}", CveSubFamilia)).Rows(0)("CveCategoria").ToString - ' End If - ' CargaDdlSubFamilia() - - ' If CveSubFamilia > 0 Then - ' DdlSubFamilia.SelectedValue = CveSubFamilia.ToString - ' End If - ' End Sub - ' Public Sub CargaDdlFamilia() - ' ' Alert( GlobalDTFamilias(UsuarioActual.CveEmpresa).Rows.Count.ToString()) - ' DdlFamilia.DataSource = GlobalDTFamilias(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'Activo'") - ' DdlFamilia.DataBind() - ' End Sub - ' Public Sub CargaDdlSubFamilia() - ' DdlSubFamilia.DataSource = dtFamily.FiltraParametros(String.Format("CveCategoria={0}", DdlFamilia.SelectedValue), "Clasificacion") - ' DdlSubFamilia.DataBind() - ' DdlSubFamilia.Items.Insert(0, New ListItem("----", "-1")) - ' End Sub - ' Private Function isWhitFamily() As Boolean - ' Return (UsuarioActual.CveEmpresa = 66) - ' End Function - '#End Region - -#Region " TIPO SERVICIO " - 'Public Sub CargaTipoServicio() - - ' 'GENERAL - ' If UsuarioActual.TienePermisoProceso(150) Then - ' DdlTipoServicio.Items.Insert(1, New ListItem("General", "1")) - ' DdlTipoServicio.SelectedValueExist(1) - ' End If - - ' 'MAQUINARIA - ' If UsuarioActual.TienePermisoProceso(151) Then - ' DdlTipoServicio.Items.Insert(1, New ListItem("Maquinaria", "2")) - ' DdlTipoServicio.SelectedValueExist(2) - ' End If - - ' If UsuarioActual.TienePermisoProceso(150) And UsuarioActual.TienePermisoProceso(151) Then - ' DdlTipoServicio.SelectedValueExist(-1) - ' End If - - 'End Sub - 'Private Sub DdlTipoPS_SelectedIndexChanged(sender As Object, e As EventArgs) ' Handles DdlTipoPS.SelectedIndexChanged - ' If UsuarioActual.TienePermisoProceso(150) And UsuarioActual.TienePermisoProceso(151) Then - - ' If DdlTipoPS.SelectedValue.ToEntero = 1 Then - ' DivTipoServicio.Visible = True - ' End If - - ' If DdlTipoPS.SelectedValue.ToEntero = 2 Then - ' DivTipoServicio.Visible = False - ' End If - ' End If - - ' UPPCostos.Update() - ' UpDatos.Update() - - 'End Sub -#End Region - -#Region " PAQUETES " - - Protected Sub BtnCargaPSPaquetes_Click(sender As Object, e As EventArgs) - If BtnCargaPSPaquetes.CommandArgument.ToEntero > 0 Then - CargaPS() - BtnCargaPSPaquetes.CommandArgument = "1" - End If - End Sub - Private Sub CargaPS() - 'RMF 2017.09.13, ajuste asume siempre que use el webservice - 'DdlProductows.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") - DdlProductows.setEsWebService(True) - If Not DdlProductows.UsaWebService AndAlso CType(DdlProductows.DataSource, DataTable) Is Nothing AndAlso GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) IsNot Nothing Then - DdlProductows.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - DdlProductows.DataBind() - End If - - ElProductoChange() - End Sub - Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProductows.selectedindexchange - ElProductoChange() - End Sub - Private Sub ElProductoChange() - ddlUnidad.Items.Clear() - ddlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductows.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) - ddlUnidad.DataBind() - UpDatos.Update() - End Sub - -#Region "GV PAQUETE DETALLE" - Protected Sub gvPaqueteDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvPaqueteDetalle.RowDataBound - If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then - e.Row.FCDropDownList("ddlEUnidad").DataSource = GlobalDTUnidadesMedida() - e.Row.FCDropDownList("ddlEUnidad").SelectedValue = e.Row.DBCampo("CveUnidadMedida") - e.Row.FCDropDownList("ddlEUnidad").DataBind() - End If - End Sub - Protected Sub gvPaqueteDetalle_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles gvPaqueteDetalle.RowDeleting - Dim ObjProductosServicios As New ClsProductosServicios - Dim tipo As Integer = 0 - If dtPaqueteDetalles.Rows.Item(e.RowIndex)("Tipo").ToString = "Paquete" Then - tipo = 1 - Else - tipo = 2 - End If - If ObjProductosServicios.DeletePaqueteDetalle(dtPaqueteDetalles.Rows.Item(e.RowIndex)("CvePSPaquete").ToString.ToEntero, - dtPaqueteDetalles.Rows.Item(e.RowIndex)("CvePS").ToString.ToEntero, - dtPaqueteDetalles.Rows.Item(e.RowIndex)("Cantidad").ToString.ToDouble, - tipo, - dtPaqueteDetalles.Rows.Item(e.RowIndex)("CveUnidadMedida").ToString.ToEntero) Then - - If ObjProductosServicios.GetPaqueteDetalle(CvePS, UsuarioActual.CveEmpresa) Then - gvPaqueteDetalle.EditIndex = -1 - gvPaqueteDetalle.DataSource = ObjProductosServicios.DtResultados - dtPaqueteDetalles = ObjProductosServicios.DtResultados - gvPaqueteDetalle.DataBind() - End If - End If - ObjProductosServicios.Dispose() - End Sub - Protected Sub gvPaqueteDetalle_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles gvPaqueteDetalle.RowEditing - gvPaqueteDetalle.EditIndex = e.NewEditIndex - gvPaqueteDetalle.DataSource = dtPaqueteDetalles - gvPaqueteDetalle.DataBind() - End Sub - Protected Sub gvPaqueteDetalle_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles gvPaqueteDetalle.RowCancelingEdit - gvPaqueteDetalle.EditIndex = -1 - gvPaqueteDetalle.DataSource = dtPaqueteDetalles - gvPaqueteDetalle.DataBind() - End Sub - Protected Sub gvPaqueteDetalle_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles gvPaqueteDetalle.RowUpdating - Dim ObjProductosServicios As New ClsProductosServicios - If ObjProductosServicios.UpdatePaqueteDetalle(CvePS, - dtPaqueteDetalles.Rows.Item(e.RowIndex)("CvePS").ToString.ToEntero, - DirectCast(gvPaqueteDetalle.Rows(e.RowIndex).FindControl("txtECantidad"), TextBox).Text.ToDouble, - DirectCast(gvPaqueteDetalle.Rows(e.RowIndex).FindControl("ddlETipo"), DropDownList).SelectedValue.ToEntero, - DirectCast(gvPaqueteDetalle.Rows(e.RowIndex).FindControl("ddlEUnidad"), DropDownList).SelectedValue.ToEntero, UsuarioActual.CveUsuario) Then - If ObjProductosServicios.GetPaqueteDetalle(CvePS, UsuarioActual.CveEmpresa) Then - gvPaqueteDetalle.EditIndex = -1 - gvPaqueteDetalle.DataSource = ObjProductosServicios.DtResultados - dtPaqueteDetalles = ObjProductosServicios.DtResultados - gvPaqueteDetalle.DataBind() - End If - End If - ObjProductosServicios.Dispose() - End Sub -#End Region - -#End Region - - -#Region "BTN'S" - Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click - 'Dim CerrarVentana As String = "opener.location.reload();window.close();" - 'If Request("Popup") IsNot Nothing Then CerrarVentana = "self.parent.tb_remove();self.parent.location.reload();window.close();" - RegistraScript(String.Format("$('#{0}').modal('show');", "divDescripcion")) - - End Sub - Protected Sub btguardar_Click(sender As Object, e As EventArgs) Handles btguardar.Click - Dim ObjProductosServicios As New ClsProductosServicios - If ObjProductosServicios.AddPaqueteDetalle(CvePS, DdlProductows.SelectedValue.ToEntero, txtCantidad.Text.ToDouble, ddlTipo.SelectedValue.ToEntero, ddlUnidad.SelectedValue.ToEntero, UsuarioActual.CveUsuario) Then - - If ObjProductosServicios.GetPaqueteDetalle(CvePS, UsuarioActual.CveEmpresa) Then - gvPaqueteDetalle.EditIndex = -1 - gvPaqueteDetalle.DataSource = ObjProductosServicios.DtResultados - gvPaqueteDetalle.DataBind() - - End If - - txtCantidad.Text = "" - DdlProductows.ddl.SelectedIndex = 0 - ddlUnidad.SelectedIndex = 0 - ddlTipo.SelectedIndex = 0 - End If - ObjProductosServicios.Dispose() - UpDatos.Update() - End Sub - Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click - - - If TxtPS.Text.Trim.Length = 0 Or DdlTipoPS.SelectedValue.ToEntero <= 0 Or DdlUnidadMedida.SelectedValue.ToEntero <= 0 Or DdlClasificacion.SelectedValue.ToEntero <= 0 Then - Alert("Los campos Producto/Servicio, Tipo, Unidad de medida, Clasificación Contable son requeridos por favor ingreselos.", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim CveClasificacion2 As Integer = DdlClasificacion2.SelectedValue.ToEntero - - If (TxtCodigo.Text = TxtCodigoBarras.Text AndAlso TxtCodigo.Text <> "") Then - Alert("Los codigos no pueden ser iguales. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - Return - End If - - 'If DdlSubFamilia.SelectedValue = "-1" AndAlso UsuarioActual.TienePermisoProceso(138) Then - ' Alert("Se debe especificar Familia y Subfamilia de Costos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) - ' Exit Sub - 'End If - - If UsuarioActual.Empresa.Funcionalidad(265) = "1" And TxtCodigo.Text = "" Then - Alert("El codigo es requerido.", TipoMensaje.MsgAdvertencia) - Return - End If - - If TxtCodigo.Text <> "" AndAlso Not TxtCodigo.Text.Length >= 3 Then - Alert("El codigo tiene que que tener una longitud de al menos 3 digitos.", TipoMensaje.MsgAdvertencia) - Return - End If - - Dim ObjProductosServicios As New ClsProductosServicios() - Dim ObjInv As New ClsInventarios(ObjProductosServicios.IniciaTransacSQL()) - - Dim TieneError = False - Dim AccionJS = "" - Dim EsPaquete As Integer = If(gvPaqueteDetalle.Rows.Count = 0, 0, 1) - Dim CveMetodoInv As Integer = If(UsuarioActual.Empresa.UsaInventarios, ddlMetodos.SelectedValue.ToEntero, -1) - - - Dim CveProveedor As Integer = -1 - If DdlProveedor.txtValue.Value.ToEntero > 0 Then - CveProveedor = DdlProveedor.txtValue.Value.ToEntero - End If - - Dim CveMarca As Integer = 0 - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then CveMarca = DdlMarcaPSDes.SelectedValue.ToEntero Else CveMarca = DdlMarca.SelectedValue.ToEntero - - If CvePS = -1 Then - Dim PSS As String = TxtPS.Text.Trim.Replace("|", "") - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then PSS = PSS.ToUpper - If ObjProductosServicios.AddPS(DdlClasificacion.SelectedValue.ToEntero, -1, DdlUnidadMedida.SelectedValue.ToEntero, TxtCodigo.Text.Trim, "", TxtCodigoBarras.Text.Trim, PSS, - TxtPrecio.Text.Trim.ToDouble, DdlIVA.SelectedValue.ToDouble, (TxtRetIVA.Text.Trim.ToDouble / 100), ChkInventariable.Checked, CveProveedor, True, - ChkAplicaParaVenta.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMetodoInv, EsPaquete, CveTipoPS:=DdlTipoPS.SelectedValue.ToEntero, - FuePorXML:=False, TipoServicio:=-1, CveClasificacion2:=CveClasificacion2, CveMarca:=CveMarca, AlmacenSeccion:=TxtAlmacenSeccion.Text.Trim, - AplicaIEPS:=ChkAplicaIeps.Checked, IEPSPorcentaje:=DdlIEPSPorcentaje.SelectedValue.ToDecimal, CveConceptoContable:=DdlConceptoRelacionado.SelectedValue.ToEntero, - CveCompuesto:=DdlCompuesto.SelectedValue.ToEntero, CveSATPS:=DdlSATPS.SelectedValue.ToEntero, IEPSGrabaIVA:=ChkIepsIVA.Checked, VentaMinima:=TxtVentaMinima.Text.ToEntero, - CveMoneda:=DdlMoneda.SelectedValue.ToEntero, RetISR:=(TxtRetISR.Text.Trim.ToDouble / 100), PrecioMinimo:=TxtPrecioMinimo.Text.ToDecimal, - CveTipoFactor:=DdlTipoFactor.SelectedValue.ToEntero, CveFraccionArancelaria:=DdlFraccionArancelaria.SelectedValue.ToEntero, - CveClasificacionDetalle:=DdlTipoPSDes.SelectedValue.ToEntero, CveTamaño:=DdlTamanio.SelectedValue.ToEntero, - CveModelo:=DdlModelo.SelectedValue.ToEntero(), CveMedida:=DdlMedida.SelectedValue.ToEntero(), CveRinTamaño:=DdlRin.SelectedValue.ToEntero(), - ClaveImpuestoEmpaque:=DdlImpEmpaque.SelectedValue.ToString, ClaveImpuestoUM:=DdlImpUM.SelectedValue.ToString, ClaveCategoriaToxicidad:=DdlCategoriaToxicidad.SelectedValue.ToString, - ClaveImpuestoTipoProducto:=DdlImpTipoProducto.SelectedValue.ToString, EsOutSourcing:=ChkEsOutSourcing.Checked) > 0 Then - ViewState("CvePS") = ObjProductosServicios.CvePS - For Each GVR As GridViewRow In GvImpuestosLocales.Rows - If GVR.FCCheckBox("ChkDeduccion").Checked Then - ObjProductosServicios.AddPSImpuestosLocales(CvePS, GVR.DataKey("CveImpuestoLocal").ToEntero) - End If - Next - 'Alert("El Producto o Servicio se guardó correctamente.", TipoMensaje.MsgInformacion, "document.location.href= "" / ProductosServicios.aspx?CvePS=" & ObjProductosServcios.CvePS.ToString & """;") - AccionJS = "document.location.href=""/Ventas/CatPS.aspx"";" - - - If Not TieneError Then - For Each Dr As DataRow In DtSeccionAlmacen.Rows - If Dr("CveAlmacen").ToString.ToEntero > 0 Then - If Not ObjInv.AddProductosServiciosAlmacenSeccion(CvePS, Dr("CveAlmacen").ToString.ToEntero, Dr("CveAlmacenSeccion").ToString.ToEntero) Then - TieneError = True - End If - End If - Next - End If - - Else - TieneError = True - Alert("Ocurrió un Error al agregar el Producto o Servicio. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - Else - - If CodigoBarrasCargado.Length > 0 And TxtCodigoBarras.Text.Length = 0 Then - TxtCodigoBarras.Text = CodigoBarrasCargado - End If - - Dim PSS As String = TxtPS.Text.Trim.Replace("|", "") - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then PSS = PSS.ToUpper - - If ObjProductosServicios.UpdatePS(DdlClasificacion.SelectedValue.ToEntero, -1, DdlUnidadMedida.SelectedValue.ToEntero, TxtCodigo.Text.Trim, "", TxtCodigoBarras.Text.Trim, PSS, - TxtPrecio.Text.Trim.ToDouble, DdlIVA.SelectedValue.ToDouble, (TxtRetIVA.Text.Trim.ToDouble / 100), ChkInventariable.Checked, CveProveedor, True, - ChkAplicaParaVenta.Checked, ChkEstado.Checked, UsuarioActual.CveUsuario, CvePS, CveMetodoInv, EsPaquete, DdlSATPS.SelectedValue.ToEntero, - CveTipoPS:=DdlTipoPS.SelectedValue.ToEntero, TipoServicio:=-1, CveClasificacion2:=CveClasificacion2, CveMarca:=CveMarca, AlmacenSeccion:=TxtAlmacenSeccion.Text.Trim, - AplicaIEPS:=ChkAplicaIeps.Checked, IEPSPorcentaje:=DdlIEPSPorcentaje.SelectedValue.ToDecimal, CveConceptoContable:=DdlConceptoRelacionado.SelectedValue.ToEntero, - CveCompuesto:=DdlCompuesto.SelectedValue.ToEntero, IEPSGrabaIVA:=ChkIepsIVA.Checked, VentaMinima:=TxtVentaMinima.Text.ToEntero, - CveMoneda:=DdlMoneda.SelectedValue.ToEntero, RetISR:=(TxtRetISR.Text.Trim.ToDouble / 100), PrecioMinimo:=TxtPrecioMinimo.Text.ToDecimal, - CveTipoFactor:=DdlTipoFactor.SelectedValue.ToEntero, CveFraccionArancelaria:=DdlFraccionArancelaria.SelectedValue.ToEntero, - CveUsuarioModifico:=UsuarioActual.CveUsuario, CveClasificacionDetalle:=DdlTipoPSDes.SelectedValue.ToEntero, CveTamaño:=DdlTamanio.SelectedValue.ToEntero, - CveModelo:=DdlModelo.SelectedValue.ToEntero(), CveMedida:=DdlMedida.SelectedValue.ToEntero(), CveRinTamaño:=DdlRin.SelectedValue.ToEntero(), - ClaveImpuestoEmpaque:=DdlImpEmpaque.SelectedValue.ToString, ClaveImpuestoUM:=DdlImpUM.SelectedValue.ToString, ClaveCategoriaToxicidad:=DdlCategoriaToxicidad.SelectedValue.ToString, - ClaveImpuestoTipoProducto:=DdlImpTipoProducto.SelectedValue.ToString, EsOutSourcing:=ChkEsOutSourcing.Checked) Then - - If Not ObjProductosServicios.LimpiaImpuestosLocales(CvePS) Then - TieneError = True - Alert("Ocurrió un Error al regenerar los impuestos locales. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - - If Not TieneError Then - For Each GVR As GridViewRow In GvImpuestosLocales.Rows - If GVR.FCCheckBox("ChkDeduccion").Checked Then - If Not ObjProductosServicios.AddPSImpuestosLocales(CvePS, GVR.DataKey("CveImpuestoLocal").ToEntero) Then - TieneError = True - Alert("Ocurrió un Error al agregar los impuestos locales. Por favor vuelva a intentar.", TipoMensaje.MsgError) - Exit For - End If - End If - Next - End If - - AccionJS = If(Ret = "Comp", "ircompras();", "document.location.href=""/Ventas/CatPS.aspx"";") - 'UpDatos.Update() - 'Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, AccionJS) - - If Not TieneError Then - For Each Dr As DataRow In DtSeccionAlmacen.Rows - If Dr("CveAlmacen").ToString.ToEntero > 0 AndAlso Not Dr("CvePSAlmacenSeccion").ToString.ToEntero > 0 Then - If Not ObjInv.AddProductosServiciosAlmacenSeccion(CvePS, Dr("CveAlmacen").ToString.ToEntero, Dr("CveAlmacenSeccion").ToString.ToEntero) Then - TieneError = True - End If - ElseIf Not Dr("CveAlmacen").ToString.ToEntero > 0 AndAlso Dr("CvePSAlmacenSeccion").ToString.ToEntero > 0 Then - If Not ObjInv.RemoveProductosServiciosAlmacenSeccion(Dr("CvePSAlmacenSeccion").ToString.ToEntero) Then - TieneError = True - End If - End If - Next - End If - - - Else - TieneError = True - Alert("Ocurrió un Error al actualizar el Producto o Servicio. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - ObjProductosServicios.CvePS = CvePS - End If - - If ObjProductosServicios.CvePS > 0 And Not TieneError Then - For i As Integer = 0 To gvSucursal.Rows.Count - 1 - If gvSucursal.Rows(i).FCCheckBox("chkSucursal").Checked = False Then - If Not ObjProductosServicios.RemovePSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).DataKey("CveSubProyecto").ToEntero) Then - TieneError = True - Alert("Ocurrió un Error al eliminar sucursales del producto. Por favor vuelva a intentar.", TipoMensaje.MsgError) - Exit For - End If - Else - If gvSucursal.Rows(i).FCHiddenField("hdnEnBD").Value.ToEntero = 1 Then - 'Actualizarlo - If Not ObjProductosServicios.UpdatePSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).FCTextBox("txtImporte").Text.ToDouble, gvSucursal.Rows(i).FCTextBox("TxtMinimo").Text.ToDouble, gvSucursal.Rows(i).FCTextBox("TxtMaximo").Text.ToDouble, UsuarioActual.CveUsuario, gvSucursal.Rows(i).DataKey("CveSubProyecto").ToEntero, PrecioMinimo:=gvSucursal.Rows(i).FCTextBox("TxtPrecioMinimo").Text.ToDecimal) Then - TieneError = True - Alert("Ocurrió un Error al actualizar sucursales del producto. Por favor vuelva a intentar.", TipoMensaje.MsgError) - Exit For - End If - 'ObjProductosServicios.UpdatePSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).FCHiddenField("hdnCveSucursal").Value.ToEntero, gvSucursal.Rows(i).FCTextBox("txtImporte").Text.ToDouble, UsuarioActual.CveUsuario) - Else - 'Insertarlo - 'ObjProductosServicios.AddPSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).FCHiddenField("hdnCveSucursal").Value.ToEntero, gvSucursal.Rows(i).FCTextBox("txtImporte").Text.ToDouble, UsuarioActual.CveUsuario) - If Not ObjProductosServicios.AddPSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).FCTextBox("txtImporte").Text.ToDouble, gvSucursal.Rows(i).FCTextBox("TxtMinimo").Text.ToDouble, gvSucursal.Rows(i).FCTextBox("TxtMaximo").Text.ToDouble, UsuarioActual.CveUsuario, gvSucursal.Rows(i).DataKey("CveSubProyecto").ToEntero, PrecioMinimo:=gvSucursal.Rows(i).FCTextBox("TxtPrecioMinimo").Text.ToDecimal) Then - TieneError = True - Alert("Ocurrió un Error al agregar sucursales del producto. Por favor vuelva a intentar.", TipoMensaje.MsgError) - Exit For - End If - End If - End If - Next - End If - - - If ObjProductosServicios.CvePS > 0 And Not TieneError Then - TieneError = GuardaEcommerce() - End If - - - If Not TieneError Then - ObjProductosServicios.Commit() - Alert("El Producto/Servicio se guardo correctamente.", TipoMensaje.MsgInformacion, AccionJS) - Else - ObjProductosServicios.RollBack() - End If - - ObjProductosServicios.Dispose() - - RecargaGlobal() - End Sub - Protected Sub HFProducto_ValueChanged(sender As Object, e As EventArgs) Handles HFProducto.ValueChanged - ddlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(HFProducto.Value.ToEntero, -1, UsuarioActual.CveEmpresa) - ddlUnidad.DataBind() - End Sub - Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click - Dim ObjAliasAdd As New ClsProductosServicios - Dim TieneError = False - - If ObjAliasAdd.AddPSAlias(TxtAlias.Text.ToString, CvePS, UsuarioActual.CveUsuario) Then - CargarAlias() - UPGVAlias.Update() - Alert("Alias " + TxtAlias.Text + " agregado.", TipoMensaje.MsgInformacion) - TxtAlias.Text = "" - Else - TieneError = True - End If - ObjAliasAdd.Dispose() - - If Not TieneError Then - RecargaGlobal() - End If - End Sub -#End Region - -#Region "G L O B L A L" - Private Sub RecargaGlobal() - 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalDT) - 'Hilo.Start() - GeneraGlobalDT() - End Sub - Private Sub GeneraGlobalDT() - - GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) = Nothing - GlobalDTProductosServiciosAlias(UsuarioActual.CveEmpresa) = Nothing - GlobalDTImpuestosLocales(-1, UsuarioActual.CveEmpresa) = Nothing - GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = Nothing - GlobalDTPSAdicionales(-1, UsuarioActual.CveEmpresa) = Nothing - - 'Dim ObjPS As New ClsProductosServicios - - 'If ObjPS.GetPSSimplificado(UsuarioActual.CveEmpresa) Then Application(String.Format("GlobalDTPSSimplificado{0}", UsuarioActual.CveEmpresa)) = ObjPS.DtResultados.AsEnumerable() - - ''If ObjPS.GetPSAlias(-1, UsuarioActual.CveEmpresa) Then - ' GlobalDTProductosServiciosAlias(UsuarioActual.CveEmpresa) = ObjPS.DtResultados - 'End If - - 'If ObjPS.GetPSImpuestosLocales(-1, UsuarioActual.CveEmpresa) Then - ' GlobalDTImpuestosLocales(-1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados - 'End If - - 'If ObjPS.GetPSEquivalencias(-1, UsuarioActual.CveEmpresa) Then - ' GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados - 'End If - - 'If ObjPS.GetPSAdicionales(-1, UsuarioActual.CveEmpresa) Then - ' GlobalDTPSAdicionales(-1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados - 'End If - - 'ObjPS.Dispose() - End Sub - -#End Region - -#Region "GV ALIAS" - Protected Sub GVAlias_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVAlias.RowDeleting - Dim ObjAliasDelete As New ClsProductosServicios - Dim TieneError = False - - If ObjAliasDelete.RemovePSAlias(GVAlias.Rows(e.RowIndex).DataKey("CvePS").ToString.ToEntero, GVAlias.Rows(e.RowIndex).DataKey("PSAlias").ToString) Then - GVAlias.EditIndex = -1 - CargarAlias() - UPGVAlias.Update() - Alert("El Alias ha sido Eliminado", TipoMensaje.MsgInformacion) - Else - Alert("Error al Eliminar", TipoMensaje.MsgError) - TieneError = True - End If - ObjAliasDelete.Dispose() - - If Not TieneError Then - RecargaGlobal() - End If - End Sub -#End Region - -#Region " EQUIVALENCIAS " - Private Sub CargaEquivalencias() - - DivEquivalencia.Visible = True - - Dim ObjProductosServicios As New ClsProductosServicios() - If ObjProductosServicios.GetPSEquivalencias(CvePS, UsuarioActual.CveEmpresa) Then - DtEquivalencias = ObjProductosServicios.DtResultados - Else - DtEquivalencias = Nothing - End If - ObjProductosServicios.Dispose() - - CargaGvEquivalencias() - - End Sub - Private Sub RecargaGlobalEquivalencias() - 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalEquivalencias) - 'Hilo.Start() - GeneraGlobalEquivalencias() - End Sub - Private Sub GeneraGlobalEquivalencias() - GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = Nothing - 'Dim ObjPS = New ClsProductosServicios - 'If ObjPS.GetPSEquivalencias(-1, -1) Then - ' GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados - 'End If - 'ObjPS.Dispose() - End Sub - Private Sub CargaGvEquivalencias() - If DtEquivalencias IsNot Nothing Then - GvEquivalencia.DataSource = DtEquivalencias - End If - GvEquivalencia.DataBind() - UpEquivalencias.Update() - End Sub - Private Sub GvEquivalencia_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEquivalencia.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - If e.Row.DBCampo("UnidadBase") = "True" Then - e.Row.FCLinkButton("imgR").Visible = False - End If - - If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then - If e.Row.DBCampo("UnidadBase") = "True" Then - 'e.Row.FCCheckBox("ChkBase").Checked = True - End If - End If - - End If - End Sub - Protected Sub GvEquivalencia_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvEquivalencia.RowEditing - GvEquivalencia.EditIndex = e.NewEditIndex - CargaGvEquivalencias() - End Sub - Protected Sub GvEquivalencia_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvEquivalencia.RowCancelingEdit - GvEquivalencia.EditIndex = -1 - CargaGvEquivalencias() - End Sub - Private Sub GvEquivalencia_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvEquivalencia.RowUpdating - Dim TieneError = False - - Dim CveUM = GvEquivalencia.Rows(e.RowIndex).DataKey("CveUM").ToEntero - Dim UnidadBase = GvEquivalencia.Rows(e.RowIndex).DataKey("UnidadBase").ToString = "True" - Dim Cantidad = DirectCast(GvEquivalencia.Rows(e.RowIndex).FindControl("TxtCantidadEquivalencia"), TextBox).Text.Trim.ToDecimal - - Dim ObjProductosServicios As New ClsProductosServicios() - If Not ObjProductosServicios.UpdatePSEquivalencias(CvePS, CveUM, Cantidad, UnidadBase, 0, UsuarioActual.CveUsuario) Then - TieneError = True - End If - ObjProductosServicios.Dispose() - - If Not TieneError Then - Alert("La equivalencia se actualizó correctamente.", TipoMensaje.MsgInformacion) - GvEquivalencia.EditIndex = -1 - CargaEquivalencias() - CargaGvEquivalencias() - RecargaGlobalEquivalencias() - Else - Alert("ocurrió un error al actualizar la equivalencia.", TipoMensaje.MsgError) - End If - - End Sub - Private Sub GvEquivalencia_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvEquivalencia.RowDeleting - Dim TieneError = False - - Dim CveUM = GvEquivalencia.Rows(e.RowIndex).DataKey("CveUM").ToEntero - - Dim ObjProductosServicios As New ClsProductosServicios() - If Not ObjProductosServicios.RemovePSEquivalencias(CvePS, CveUM) Then - TieneError = True - End If - ObjProductosServicios.Dispose() - - If Not TieneError Then - Alert("La equivalencia se eliminó correctamente.", TipoMensaje.MsgInformacion) - CargaEquivalencias() - CargaGvEquivalencias() - RecargaGlobalEquivalencias() - Else - Alert("ocurrió un error al eliminar la equivalencia.", TipoMensaje.MsgError) - End If - - End Sub - -#End Region - -#Region "PS ADICIONALES" - - Private Sub CargaPSAdicionales() - - Dim ObjProductosServicios As New ClsProductosServicios() - If ObjProductosServicios.GetPSAdicionales(CvePS, UsuarioActual.CveEmpresa) Then - DtPSAdicionales = ObjProductosServicios.DtResultados - Else - DtPSAdicionales = Nothing - End If - ObjProductosServicios.Dispose() - - CargaGvPSAdicionales() - - End Sub - Private Sub CargaGvPSAdicionales() - If DtPSAdicionales IsNot Nothing Then - GvPSAdicionales.DataSource = DtPSAdicionales - End If - GvPSAdicionales.DataBind() - UpPSAdicionales.Update() - End Sub - Private Sub GvPSAdicionales_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPSAdicionales.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then - e.Row.FCDropDownList("DdlPSAdicional").DataSource = GlobalDTPS(UsuarioActual.CveEmpresa) '.FiltraParametros("CvePS = " + CvePS.ToString) - e.Row.FCDropDownList("DdlPSAdicional").DataBind() - e.Row.FCDropDownList("DdlPSAdicional").SelectedValue = e.Row.DBCampo("CvePSAdicional") - End If - - End If - End Sub - Protected Sub GvPSAdicionales_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvPSAdicionales.RowCancelingEdit - GvPSAdicionales.EditIndex = -1 - CargaGvPSAdicionales() - End Sub - Private Sub GvPSAdicionales_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvPSAdicionales.RowDeleting - Dim TieneError = False - - Dim CvePSAdicional = GvPSAdicionales.Rows(e.RowIndex).DataKey("CvePSAdicional").ToEntero - - Dim ObjProductosServicios As New ClsProductosServicios() - If Not ObjProductosServicios.RemovePSAdicionales(CvePS, CvePSAdicional) Then - TieneError = True - End If - ObjProductosServicios.Dispose() - - If Not TieneError Then - Alert("El Producto/Servicio Adicionala se eliminó correctamente.", TipoMensaje.MsgInformacion) - CargaPSAdicionales() - CargaGvPSAdicionales() - 'RecargaGlobalEquivalencias() - RecargaGlobal() - Else - Alert("ocurrió un error al eliminar el Producto/Servicio Adicional.", TipoMensaje.MsgError) - End If - - End Sub - - Private Sub BtnAgregarPSAdicionalesModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarPSAdicionalesModal.Click - BtnAgregarPSAdicional.Text = "Agregar" - CvePSAdicional = -1 - - DdlPSAdicional.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa) - DdlPSAdicional.DataBind() - DdlPSAdicional.Items.Add(New ListItem("Seleccione", "-1")) - UpAddPSAdicional.Update() - - DdlPSAdicional.SelectedValue = "-1" - TxtCantidadPSAdicional.Text = "" - UpCantidad.Visible = False - RBLCantidad.SelectedValue = "1" - RegistraScript("$('#divAddPSAdicional').modal();") - End Sub - Private Sub BtnAgregarPSAdicional_Click(sender As Object, e As EventArgs) Handles BtnAgregarPSAdicional.Click - Dim ObjProductosServicios As New ClsProductosServicios() - ObjProductosServicios.IniciaTransacSQL() - Dim TieneError = False - - If CvePSAdicional < 0 Then - If Not ObjProductosServicios.AddPSAdicionales(CvePS, DdlPSAdicional.SelectedValue.ToEntero, If(TxtCantidadPSAdicional.Visible, TxtCantidadPSAdicional.Text.ToDecimal, 0)) Then - TieneError = True - End If - Else - - If Not ObjProductosServicios.UpdatePSAdicionales(CvePS, DdlPSAdicional.SelectedValue.ToEntero, CvePSAdicional, If(TxtCantidadPSAdicional.Visible, TxtCantidadPSAdicional.Text.ToDecimal, 0)) Then - TieneError = True - End If - - End If - - If TieneError Then - Alert("Ocurrio un error al agregar/actualizar el Producto/Servicio Adicional.", TipoMensaje.MsgError) - ObjProductosServicios.RollBack() - Else - ObjProductosServicios.Commit() - RegistraScript("$('#divAddPSAdicional').modal('hide');") - CvePSAdicional = -1 - CargaPSAdicionales() - CargaGvPSAdicionales() - RecargaGlobal() - End If - ObjProductosServicios.Dispose() - End Sub - - Protected Sub Edit_Click(sender As Object, e As EventArgs) - Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) - BtnAgregarPSAdicional.Text = "Guardar" - TxtCantidadPSAdicional.Text = GvRow.DataKey("Cantidad") - - If TxtCantidadPSAdicional.Text.ToEntero = 0 Then - UpCantidad.Visible = False - RBLCantidad.SelectedValue = "1" - Else - UpCantidad.Visible = True - RBLCantidad.SelectedValue = "2" - End If - UpAddPSAdicional.Update() - - DdlPSAdicional.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa) - DdlPSAdicional.DataBind() - DdlPSAdicional.Items.Add(New ListItem("Seleccione", "-1")) - UpAddPSAdicional.Update() - - CvePSAdicional = GvRow.DataKey("CvePSAdicional").ToEntero - DdlPSAdicional.SelectedValue = GvRow.DataKey("CvePSAdicional") - - RegistraScript("$('#divAddPSAdicional').modal();") - End Sub - - Protected Sub RBLCantidad_SelectedIndexChanged1(sender As Object, e As EventArgs) - If RBLCantidad.SelectedValue.ToEntero = 2 Then - UpCantidad.Visible = True - Else - UpCantidad.Visible = False - End If - UpAddPSAdicional.Update() - End Sub -#End Region - -#Region " CARGA MARCA Y COMPUESTOS " - - Protected Sub CargarMarcas() - If UsuarioActual.Empresa.Funcionalidad(130) = "1" Then - If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) And CvePS = -1 Then - DivMarcaPSDes.Visible = True - Else - DivMarca.Visible = True - End If - Dim ObjMarcas As New ClsProductosServicios - ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa) - DdlMarca.DataSource = ObjMarcas.DtResultados - DdlMarcaPSDes.DataSource = ObjMarcas.DtResultados - ObjMarcas.Dispose() - DdlMarca.DataBind() - DdlMarcaPSDes.DataBind() - End If - DdlMarca.Items.Insert(0, New ListItem(" - ", "-1")) - DdlMarcaPSDes.Items.Insert(0, New ListItem(" - ", "-1")) - End Sub - - Protected Sub CargarCompuestos() - If UsuarioActual.Empresa.Funcionalidad(143) = "1" Then - DivCompuesto.Visible = True - Dim PS As New ClsProductosServicios - PS.GetCompuestosActivos(UsuarioActual.CveEmpresa) - DdlCompuesto.DataSource = PS.DtResultados - PS.Dispose() - DdlCompuesto.DataBind() - End If - End Sub - - -#End Region - -#Region "IMPUESTOS LOCALES" - Public Sub CargaImpuestosLocales() - Dim ObjPS As New ClsProductosServicios - If ObjPS.GetPSImpuestosLocales(CvePS, UsuarioActual.CveEmpresa) Then - GvImpuestosLocales.DataSource = ObjPS.DtResultados - End If - ObjPS.Dispose() - GvImpuestosLocales.DataBind() - End Sub - -#End Region - -#Region " IEPS " - Private Sub ChkAplicaIeps_CheckedChanged(sender As Object, e As EventArgs) Handles ChkAplicaIeps.CheckedChanged - If ChkAplicaIeps.Checked Then - DdlIEPSPorcentaje.Enabled = True - ChkIepsIVA.Enabled = True - Else - DdlIEPSPorcentaje.SelectedIndex = 0 - DdlIEPSPorcentaje.Enabled = False - ChkIepsIVA.Enabled = False - ChkIepsIVA.Checked = False - End If - UpDatos.Update() - End Sub -#End Region - -#Region "UNIFICAR PRODUCTOS" - Private Sub LnkUnificar_Click(sender As Object, e As EventArgs) Handles LnkUnificar.Click - CargaPSUnificar() - RegistraScript("$('#DivUnificar').modal();LimpiaModalUnificar()") - End Sub - Public Sub CargaPSUnificar() - DdlPsUnificar.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) - DdlPsUnificar.DataBind() - 'DdlPsUnificar.setEsWebService(True) - 'DdlPsUnificar.ddlWS.Attributes.Add("data-clear", "1") - - UpBodyUnificar.Update() - End Sub - Private Sub BtnUnificar_Click(sender As Object, e As EventArgs) Handles BtnUnificar.Click - If DdlPsUnificar.SelectedValue.ToEntero() > 0 Then - If DdlPsUnificar.SelectedValue.ToEntero() = CvePS Then - Alert("No se puede seleccionar el mismo producto y/o servicio", TipoMensaje.MsgAdvertencia) - Else - Dim ObjPS As New ClsProductosServicios - If ObjPS.UnificarPS(CvePS, DdlPsUnificar.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("Los productos y/o servicios han sido unificados", TipoMensaje.MsgInformacion) - Else - Alert("Los productos y/o servicios no han podido ser unificados", TipoMensaje.MsgError) - End If - ObjPS.Dispose() - RecargaGlobal() - RegistraScript("$('#DivUnificar').modal('hide');") - UpDatos.Update() - End If - Else - Alert("Es necesario seleccionar un producto y/o servicio", TipoMensaje.MsgAdvertencia) - End If - - - End Sub -#End Region - -#Region "BITACORA" - - Private Sub CargaGvBitacora() - Dim ObjGral As New ClsGenerales() - If ObjGral.GetHistorialBitacora(-1, -1, -1, -1, CvePS, -1, -1, UsuarioActual.CveEmpresa) Then - GvBitacora.DataSource = ObjGral.DtResultados - GvBitacora.DataBind() - End If - ObjGral.Dispose() - UpDatos.Update() - End Sub - - Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click - If Not TxtDescripcion.Text = "" Then - Dim ObjProductosServcios As New ClsProductosServicios() - Dim ObjGral As New ClsGenerales(ObjProductosServcios.IniciaTransacSQL()) - - - If ObjProductosServcios.RemovePS(CvePS) Then - Borrar = True - Else - Borrar = False - End If - - If Borrar = True Then - If ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, TxtDescripcion.Text, "PS", TxtCodigo.Text + " / " + TxtPS.Text) Then - ObjProductosServcios.Commit() - RecargaGlobal() - Alert("El Producto o Servicio se eliminó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatPS.aspx"";") - Else - ObjProductosServcios.RollBack() - Alert("Ocurrió un Error al actualizar el historial de eliminación.", TipoMensaje.MsgError) - End If - Else - ObjProductosServcios.RollBack() - Alert("Ocurrió un Error al eliminar el Producto o Servicio. Por favor vuelva a intentar.", TipoMensaje.MsgError) - End If - ObjProductosServcios.Dispose() - ObjGral.Dispose() - Else - Alert("Tiene que decir el motivo de su eliminacion.", TipoMensaje.MsgInformacion) - End If - End Sub - -#End Region - -#Region "Codigo Barras" - - 'Codigo barras/QR se retorna como una imagen bmp - Private Function GeneraCodigoQR(CodigoBarras As String, Alto As Integer, Largo As Integer, Margen As Integer, Formato As String) As Byte() - - Dim barcodeWriter As New BarcodeWriter - Dim opciones As New ZXing.Common.EncodingOptions - Dim FormatoBar As New BarcodeFormat - 'Dim Respuesta As Byte() - - opciones.Height = Alto - opciones.Width = Largo - opciones.Margin = Margen - - barcodeWriter.Options = opciones - - Select Case Formato - Case "All_1D" - barcodeWriter.Format = BarcodeFormat.All_1D - Exit Select - Case "AZTEC" - barcodeWriter.Format = BarcodeFormat.AZTEC - Exit Select - Case "CODABAR" - barcodeWriter.Format = BarcodeFormat.CODABAR - Exit Select - Case "CODE_128" - barcodeWriter.Format = BarcodeFormat.CODE_128 - Exit Select - Case "CODE_39" - barcodeWriter.Format = BarcodeFormat.CODE_39 - Exit Select - Case "CODE_93" - barcodeWriter.Format = BarcodeFormat.CODE_93 - Exit Select - Case "DATA_MATRIX" - barcodeWriter.Format = BarcodeFormat.DATA_MATRIX - Exit Select - Case "EAN_13" - barcodeWriter.Format = BarcodeFormat.EAN_13 - Exit Select - Case "EAN_8" - barcodeWriter.Format = BarcodeFormat.EAN_8 - Exit Select - Case "IMB" - barcodeWriter.Format = BarcodeFormat.IMB - Exit Select - Case "ITF" - barcodeWriter.Format = BarcodeFormat.ITF - Exit Select - Case "MAXICODE" - barcodeWriter.Format = BarcodeFormat.MAXICODE - Exit Select - Case "MSI" - barcodeWriter.Format = BarcodeFormat.MSI - Exit Select - Case "PDF_417" - barcodeWriter.Format = BarcodeFormat.PDF_417 - Exit Select - Case "PLESSEY" - barcodeWriter.Format = BarcodeFormat.PLESSEY - Exit Select - Case "QR_CODE" - barcodeWriter.Format = BarcodeFormat.QR_CODE - Exit Select - Case "RSS_14" - barcodeWriter.Format = BarcodeFormat.RSS_14 - Exit Select - Case "RSS_EXPANDED" - barcodeWriter.Format = BarcodeFormat.RSS_EXPANDED - Exit Select - Case "UPC_A" - barcodeWriter.Format = BarcodeFormat.UPC_A - Exit Select - Case "UPC_E" - barcodeWriter.Format = BarcodeFormat.UPC_E - Exit Select - Case "UPC_EAN_EXTENSION" - barcodeWriter.Format = BarcodeFormat.UPC_EAN_EXTENSION - Exit Select - - End Select - - Dim imgCod As Drawing.Bitmap = barcodeWriter.Write(CodigoBarras) - Dim memoriStream As New System.IO.MemoryStream - imgCod.Save(memoriStream, Drawing.Imaging.ImageFormat.Bmp) - - 'Respuesta = Convert.ToBase64String(memoriStream.ToArray()) - - Return memoriStream.ToArray() - - End Function - - Private Sub LnkModalCodigoBarrasQr_Click(sender As Object, e As EventArgs) Handles LnkModalCodigoBarrasQr.Click - - LnkDescargaImagen.Enabled = False - LnkDescargaImpresion.Enabled = False - UpModalBotonesCodigos.Update() - - TxtCodigoBarrasModal.Text = TxtCodigoBarras.Text.Trim - UpModalUploadCodigoBarras.Update() - RegistraScript("$('#ModalCodigoBarrasQR').modal({ backdrop: 'static', keyboard: false});") - - End Sub - - - Private Sub LnkModalGenerarCodigoBarrasQR_Click(sender As Object, e As EventArgs) Handles LnkModalGenerarCodigoBarrasQR.Click - - Dim Alto As Integer = 150 - Dim Ancho As Integer = 150 - Dim Base64Code As String - - If TxtAlto.Text.ToEntero > 0 Then Alto = TxtAlto.Text.ToEntero - If TxtAncho.Text.ToEntero > 0 Then Ancho = TxtAncho.Text.ToEntero - - Try - Base64Code = Convert.ToBase64String(GeneraCodigoQR(TxtCodigoBarrasModal.Text.Trim, Alto, Ancho, 0, DDLCodigoFormato.SelectedValue)) - ImgModalCodigo.Attributes.Add("src", $"data:image/gif;base64,{Base64Code}") - ImgModalCodigo.Width = Ancho - ImgModalCodigo.Height = Alto - LnkDescargaImagen.Enabled = True - LnkDescargaImpresion.Enabled = True - UpModalBotonesCodigos.Update() - Catch ex As Exception - ImgModalCodigo.Attributes.Add("src", "") - ImgModalCodigo.Width = Ancho - ImgModalCodigo.Height = Alto - LnkDescargaImagen.Enabled = False - LnkDescargaImpresion.Enabled = False - UpModalBotonesCodigos.Update() - End Try - - UpModalUploadCodigoBarras.Update() - - End Sub - - Private Sub LnkDescargaImagen_Click(sender As Object, e As EventArgs) Handles LnkDescargaImagen.Click - - Dim Alto As Integer = 150 - Dim Ancho As Integer = 150 - - - If TxtAlto.Text.ToEntero > 0 Then Alto = TxtAlto.Text.ToEntero - If TxtAncho.Text.ToEntero > 0 Then Ancho = TxtAncho.Text.ToEntero - - Try - Dim memoryStream As New System.IO.MemoryStream(GeneraCodigoQR(TxtCodigoBarrasModal.Text.Trim, Alto, Ancho, 0, DDLCodigoFormato.SelectedValue)) - Response.Clear() - Response.ContentType = "application/bmp" - Response.AddHeader("content-disposition", $"attachment;filename=code_{TxtCodigoBarrasModal.Text.Trim}.bmp") - Response.Buffer = True - memoryStream.WriteTo(Response.OutputStream) - Response.End() - - Catch ex As Exception - - End Try - End Sub - - Private Sub DDLCodigoFormato_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDLCodigoFormato.SelectedIndexChanged - LnkDescargaImagen.Enabled = False - LnkDescargaImpresion.Enabled = False - UpModalBotonesCodigos.Update() - End Sub - Private Sub LnkDescargaImpresion_Click(sender As Object, e As EventArgs) Handles LnkDescargaImpresion.Click - Dim Alto As Integer = 150 - Dim Ancho As Integer = 150 - - - If TxtAlto.Text.ToEntero > 0 Then Alto = TxtAlto.Text.ToEntero - If TxtAncho.Text.ToEntero > 0 Then Ancho = TxtAncho.Text.ToEntero - - Try - - - Dim Doc As New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10.0F, 10.0F, 100.0F, 0F) - Dim para As New iTextSharp.text.Paragraph - Dim memoryStreamDoc As New System.IO.MemoryStream - - Dim gemBox As New clsGemBoxDocument() - - gemBox.AgregarImagen(GeneraCodigoQR(TxtCodigoBarrasModal.Text.Trim, Alto, Ancho, 0, DDLCodigoFormato.SelectedValue)) - gemBox.GuardarStreamPDF() - - - - Dim memoryStream As New System.IO.MemoryStream(gemBox.GetBytesDocumento()) - gemBox.Dispose() - Response.Clear() - Response.ContentType = "application/pdf" - Response.AddHeader("content-disposition", $"attachment;filename=code_{TxtCodigoBarrasModal.Text.Trim}.pdf") - Response.Buffer = True - memoryStream.WriteTo(Response.OutputStream) - Response.End() - - Catch ex As Exception - - End Try - End Sub - - - -#End Region - -#Region "SELECTED INDEX CHANGE" - Public Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClasificacion.SelectedIndexChanged - If DdlClasificacion.SelectedValue.ToEntero > 0 Then - If Not CveSATPS > 0 Or CveSATPS = 46920 Then - Dim Dr = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue.ToEntero()))(0) - - DdlSATPS.SelectedValue = Dr("CveSATPS").ToString - DdlSATPS.SelectedText = Dr("SATClaveProductoServicio").ToString - - - - If UsuarioActual.CveEmpresa.Contiene(72, 80) Then - VerificaRequiereSerieLote() - End If - End If - ' CargaClasificacionesDetalles() - End If - - Try - Dim Dr = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue.ToEntero()))(0) - If Boolean.Parse(Dr("EsAcumulador").ToString) Then - MostarOcultarDivTamanio(True) - Else - MostarOcultarDivTamanio(False) - End If - 'SI ES MOTOBATERIA +Option Explicit On +Option Strict On + +Imports Extensiones +Imports System.IO +Imports System.Data +Imports ZXing + +Partial Class ProductosyServicios + Inherits ClsPaginas + +#Region " Propiedades " + Private ReadOnly Property CvePS As Integer + Get + Return ViewState("CvePS").ToString.ToEntero + End Get + End Property + + Private Property CveSATPS As Integer + Get + Return ViewState("CveSATPS").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveSATPS") = value + End Set + End Property + + Private Property Ret As String + Get + Return ViewState("Ret").ToString + End Get + Set(value As String) + ViewState("Ret") = value + End Set + End Property + Private Property Borrar As Boolean + Get + Return CBool(ViewState("Borrar")) + End Get + Set(value As Boolean) + ViewState("Borrar") = value + End Set + End Property + Public Property dtPaqueteDetalles() As DataTable + Get + Return CType(ViewState("dtPaqueteDetalles"), DataTable) + End Get + Set(value As DataTable) + ViewState("dtPaqueteDetalles") = value + End Set + End Property + Public Property DtEquivalencias() As DataTable + Get + Return CType(ViewState("DtEquivalencias"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtEquivalencias") = value + End Set + End Property + Public Property dtFamily() As DataTable + Get + Return CType(ViewState("dtFamily"), DataTable) + End Get + Set(value As DataTable) + ViewState("dtFamily") = value + End Set + End Property + + + Property CodigoBarrasCargado As String + Get + If ViewState("CodigoBarrasCargado") Is Nothing Then + Return "" + Else + Return ViewState("CodigoBarrasCargado").ToString + End If + End Get + Set(value As String) + ViewState("CodigoBarrasCargado") = value + End Set + End Property + + Public Property DtPSAdicionales() As DataTable + Get + Return CType(ViewState("DtPSAdicionales"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtPSAdicionales") = value + End Set + End Property + + Private Property CvePSAdicional As Integer + Get + Return ViewState("CvePSAdicional").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CvePSAdicional") = value + End Set + End Property + Public Property DtSeccionAlmacen() As DataTable + Get + Return CType(ViewState("DtSeccionAlmacen"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtSeccionAlmacen") = value + End Set + End Property + + +#End Region + + Private ReadOnly Property PermiteClasificacion2 As Boolean + Get + Return (UsuarioActual.CveEmpresa.Contiene(72, 80)) + End Get + End Property + + + +#Region " PROPIEDADES ECOMMERCE " + ''' + ''' Si es True existe en Eco_Produtcos + ''' + ''' + Private Property AplicaEcommerce As Boolean + Get + Return CBool(ViewState("AplicaEcommerce")) + End Get + Set(value As Boolean) + ViewState("AplicaEcommerce") = value + End Set + End Property +#End Region + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + + InicializaValores() + If Request("CvePS") IsNot Nothing AndAlso IsNumeric(Request("CvePS")) AndAlso Request("CvePS").ToEntero > 0 Then + ViewState("CvePS") = Request("CvePS") + CargarMarcas() + + CargaDatos() + 'Configuración de Modalidad Update + BtnGuardar.Text = "Guardar Cambios" + + CargarAlias() + CargaExistencias() + CargaGvSeccionAlmacen() + Else + 'Configuración de Modalidad Insert + RegistraScript("$('#C_Tab_TabPaquetes_tab').css('display' , 'none')") + + ViewState("CvePS") = -1 + CargarMarcas() + + ChkEstado.Enabled = False + ChkEstado.Checked = True + LblFechaCaptura.Text = Now.ToShortDateString() + LblUsuarioCapturo.Text = UsuarioActual.Usuario + BtnEliminar.Visible = False + + If UsuarioActual.Empresa.Funcionalidad(543).ToString = "1" Then + Dim ObjSub As New ClsSubProyectos + Dim CveSubProyectoMatriz As Integer + + If ObjSub.GetSubProyectos() Then + CveSubProyectoMatriz = ObjSub.DtResultados.FiltroPrimeroValor("CveSubProyecto", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND TipoSucursal = 1").ToEntero + End If + + Dim ObjFolios As New ClsGralFolios() + If ObjFolios.GetFolios("PS", UsuarioActual.CveEmpresa) Then + + Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros($"CveSubProyecto = {CveSubProyectoMatriz} And Estado = 'Activo'") + If DT.Rows.Count > 0 Then + TxtCodigo.Text = DT.Rows(0)("FActual").ToString + TxtCodigo.Enabled = False + Else + Alert("No tiene registrados Folios para la sucursal matriz.", TipoMensaje.MsgAdvertencia) + End If + End If + End If + + End If + + If Request("Ret") IsNot Nothing AndAlso Request("Ret").ToString <> "" Then + Ret = Request("Ret") + End If + + 'CargaFamilia(ViewState("CveSubFamilia").ToString.ToEntero) + CargaSucursaless() + CargaImpuestosLocales() + CargaConceptoRelacionado() + + If UsuarioActual.TienePermisoProceso(122) Then + BtnEliminar.Visible = False + BtnGuardar.Visible = False + End If + + If UsuarioActual.Empresa.Funcionalidad(557) = "1" Then + DdlIVA.SelectedValueExist("-1") + DdlIVA.Attributes.Add("disabled", "disabled") + DdlIVA.Enabled = False + End If + + If CvePS > 0 Then + CargaEquivalencias() + CargaPSAdicionales() + CargaGvBitacora() + divBitacora.Visible = True + VerificaRequiereSerieLote() + End If + + If UsuarioActual.Empresa.Funcionalidad(524) <> "" Then + DivProveedorCompra.Visible = True + DivMoneda.Visible = True + End If + + UpDatos.Update() + + 'DdlClasificacion.AutoPostBack = UsuarioActual.CveEmpresa.Contiene(80, 72) + + InicializaEcommerce() + + If UsuarioActual.CveEmpresa.Contiene(141) Then + 'DivDatos.Attributes("class") = "col-md-12" + + DivDdlTipo.Visible = True + 'DdlTipoPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") + + End If + + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) And CvePS = -1 Then + 'DivDatos.Attributes("class") = "col-md-12" + TxtPS.Enabled = False + DivDdlTipo.Visible = True + DivTxtModelo.Visible = True + DivTxtAdicional.Visible = True + DdlTipoPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") + DdlMarcaPSDes.Attributes.Add("onChange", "CreaDescripcionPS();") + TxtModelo.Attributes.Add("onKeyUp ", "CreaDescripcionPS();") + TxtAdicional.Attributes.Add("onKeyUp ", "CreaDescripcionPS();") + End If + + If ddlMetodos.SelectedValue.ToEntero = 5 And Not UsuarioActual.TienePermisoProceso(255) Then + ddlMetodos.Enabled = False + End If + Dim posiciontipo As String = If(UsuarioActual.Empresa.Funcionalidad(558).ToString = "1", "$('.DIVCLASIFICACIONCONTABLE').after( $('.DIVTIPO') );", "") + + LtlScripts.Text = $"" + If Not CvePS > 0 Then MuestraPanel(True) + + End If + End Sub + +#Region " INCIALIZA " + Private Sub InicializaValores() + ViewState("OrdenO") = "" + ViewState("OrdenC") = "" + ViewState("DTProductosServiciosCaracteristicas") = Nothing + ViewState("DTProductosServiciosCaracteristicasOpciones") = Nothing + ViewState("CveSubFamilia") = "-1" + Ret = "-1" + + 'CType(Me.Master, BaseMasterPage).EsPopup = True + 'CType(Me.Master, BaseMasterPage).PopupWidth = 700 + 'RegistraScript("$get('tdContenido').style.height='350px'") + + CargaClasificaciones() + CargaClasificaciones2() + CargaClasificacionesDetalles() + ClasificacionModal() + CargaTipoProductos() + CargaUnidadesMedida() + CargarMetodosInv() + 'CargaPSAdicional(DdlPSAdicional) + + 'Nuevo R: 26/09/2017 + CargaProveedores() + + CargarCompuestos() + CargaPS() + 'ChangeDdl() + CargaDdlSATPS() + CargaDdlFraccionArancelaria() + CveSATPS = -1 + + CargaCombosSeccionAlmacen() + DivSeccionAlmacen.Visible = UsuarioActual.Empresa.Funcionalidad(563).ToString = "1" + CreaDtSeccionAlmacen() + + If UsuarioActual.Empresa.UsaContabilidad Then + CargaCuentasContables() + If Not (Request("CvePS") IsNot Nothing AndAlso IsNumeric(Request("CvePS")) AndAlso Request("CvePS").ToEntero > 0) Then DivUsoClasificacion.Visible = True + End If + + 'CargaTipoServicio() + 'DivTipoServicio.Visible = False + + TxtDescripcion.Text = UCase(TxtDescripcion.Text) + + Dim objAcum As New ClsAcumuladores + If objAcum.TamañoGet(-1, UsuarioActual.CveEmpresa) Then + DdlTamanio.DataSource = objAcum.DtResultados + Else + DdlTamanio.DataSource = Nothing + End If + + objAcum.Dispose() + DdlTamanio.DataBind() + + If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + DivLlantas.Visible = True + DivPSAdicionales.Visible = True + CargaPanelLlantas() + End If + + CvePSAdicional = -1 + + End Sub + + 'Private Sub CargaPSAdicional(Objeto As ADServerControl.Dropdownlost) + ' Objeto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(141).ToString = "1") + ' If Not UsuarioActual.Empresa.Funcionalidad(141).ToString = "1" Then + ' Objeto.ddl.Items.Clear() + ' Objeto.ddl.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=-1, Estatus:=1, AplicaParaVenta:=1) + ' Objeto.ddl.DataBind() + ' Objeto.ddl.Items.Insert(0, New ListItem("Seleccione", "-1")) + ' Else + ' Objeto.ddlWS.Attributes.Add("data-Estatus", "1") + ' Objeto.SelectedValue = "-1" + ' Objeto.SelectedText = "Seleccione" + ' End If + 'End Sub + Private Sub CargaPanelLlantas() + Dim ObjGral As New ClsGenerales() + If ObjGral.GetModelos(UsuarioActual.CveEmpresa) Then + DdlModelo.DataSource = ObjGral.DtResultados.Copy() + End If + If ObjGral.GetMedidas(UsuarioActual.CveEmpresa) Then + DdlMedida.DataSource = ObjGral.DtResultados.Copy() + End If + If ObjGral.GetRimTamanios(UsuarioActual.CveEmpresa) Then + DdlRin.DataSource = ObjGral.DtResultados.Copy() + End If + ObjGral.Dispose() + + DdlModelo.DataBind() + DdlMedida.DataBind() + DdlRin.DataBind() + + End Sub + + Private Sub MuestraPanel(Optional AfterPageLoad As Boolean = False) + If AfterPageLoad Then + RegistraScript("window.onload = function MuestraPanel() { document.getElementById(""C_BtnMostrarPanel"").click(); }") + End If + End Sub + + + Protected Sub BtnTipoCla_Click(sender As Object, e As EventArgs) + PresionarBotonPanel("C_BtnCerrarPanel") + DivUsoClasificacion.Visible = False + DdlUsoClasificacion.SelectedValueExist(RblTipoClasificación.SelectedValue) + CargaClasificaciones() + UpDatos.Update() + End Sub + + Private Sub PresionarBotonPanel(Boton As String) + Dim Script As String = $"document.getElementById(""{Boton}"").click();" + Dim Pag As System.Web.UI.Page = CType(System.Web.HttpContext.Current.Handler, System.Web.UI.Page) + ScriptManager.RegisterStartupScript(Pag, Pag.GetType(), Boton, Script, True) + Pag = Nothing + End Sub +#End Region + +#Region "S U C U R S A L E S" + Private Sub CargaSucursaless() + 'Dim dtSuc As DataTable = GlobalDTSucursales().FiltraParametros("CveEmpresa = " + UsuarioActual.CveEmpresa.ToString) + 'dtSuc.AcceptChanges() + + 'dtSuc.Columns.Add("Importe") + 'dtSuc.Columns.Add("Activo") + + 'For Each row As DataRow In dtSuc.Rows + ' row("Activo") = False + 'Next + 'dtSuc.AcceptChanges() + + 'If Not ViewState("CvePS") Is Nothing Then + ' Dim ObjPS As New ClsProductosServicios + + ' If ObjPS.GetPSSucursales(CvePS) Then + ' Dim dtSucP As DataTable = ObjPS.DtResultados + + ' For Each Row As DataRow In dtSucP.Rows + ' Dim rowsToUpdate = dtSuc.AsEnumerable().Where(Function(r) r.Field(Of Integer)("CveSucursal") = Row("CveSucursal").ToString.ToEntero AndAlso r!CveSucursal.ToString.ToEntero > 0) + + ' For Each roww As DataRow In rowsToUpdate + ' roww.SetField("Importe", Row("Importe")) + ' roww.SetField("Activo", True) + ' Next + + ' 'For Each drtt As DataRow In TmpDT.Select(String.Format("PS='{0}' AND CvePS=0", Row("PS"))) + ' ' drtt("CvePS") = tCve + ' 'Next + + + ' dtSuc.AcceptChanges() + ' Next + ' End If + + ' ObjPS.Dispose() + 'End If + + 'gvSucursal.DataSource = dtSuc + 'gvSucursal.DataBind() + + Dim ObjPS As New ClsProductosServicios + + If ObjPS.GetPSSucursales(CvePS, UsuarioActual.CveEmpresa) Then + gvSucursal.DataSource = ObjPS.DtResultados + + End If + + ObjPS.Dispose() + gvSucursal.DataBind() + End Sub + + Protected Sub gvSucursal_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvSucursal.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.RowIndex = 0 Then + e.Row.Cells(0).Width = Unit.Pixel(50) + e.Row.Cells(1).Width = Unit.Pixel(100) + e.Row.Cells(2).Width = Unit.Pixel(100) + End If + + ' If e.Row.FCCheckBox("chkSucursal").Checked = True Then e.Row.Cells(0).BackColor = Drawing.Color.Yellow + End If + End Sub +#End Region + +#Region "C A R A C T E R I S T I C A S" + + Private Sub CargaCaracteristicas() + ' CargaDatosC() + CargaProductosServiciosCaracteristicas() + CambioProductosServiciosCaracteristicas(DdlCaracteristica.SelectedValue.ToEntero) + CargaDatosO() + UpDatos.Update() + UpDatosO.Update() + UpTitulosO.Update() + + End Sub + Public Sub CargaDatosO() + Dim Objeto As New ClsGenerales + If Objeto.GetCaracteristicasValores(-1, -1, CvePS, -1, -1, -1, 5, UsuarioActual.CveEmpresa, OpcionListado:=1) Then + GvDatosOpciones.DataSource = Objeto.DtResultados + End If + Objeto.Dispose() + UpDatosO.Update() + GvDatosOpciones.DataBind() + + End Sub + + + Private Sub LbAgregarO_Click(sender As Object, e As EventArgs) Handles LbAgregarO.Click + Dim Objeto As New ClsGenerales + Dim Opcion As String = If(TDTxtOpcion.Visible = True, TxtOpcion.Text, DdlOpcion.SelectedItem.Text) + Dim Opcion2 As Integer = If(TDDdlOpcion.Visible = True, DdlOpcion.SelectedValue.ToEntero, -1) + + If Objeto.AddUpdateCaracteristicasValores(DdlCaracteristica.SelectedValue.ToEntero, Opcion2, Opcion, UsuarioActual.CveUsuario, CvePs:=CvePS) Then + End If + Objeto.Dispose() + TxtOpcion.Text = "" + CargaDatosO() + UpDatosO.Update() + UpTitulosO.Update() + Alert("El valor de la caracteristica se agregó correctamente.", TipoMensaje.MsgInformacion) + End Sub + + Private Sub CargaProductosServiciosCaracteristicas() + Dim Objeto As New ClsGenerales + DdlCaracteristica.Items.Clear() + If Objeto.GetCaracteristicas(-1, 5, UsuarioActual.CveEmpresa) Then + DdlCaracteristica.DataSource = Objeto.DtResultados + End If + Objeto.Dispose() + DdlCaracteristica.DataBind() + End Sub + + Protected Sub DdlCaracteristica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCaracteristica.SelectedIndexChanged + CambioProductosServiciosCaracteristicas(DdlCaracteristica.SelectedValue.ToEntero) + End Sub + + Protected Sub CambioProductosServiciosCaracteristicas(CveCaracteristica As Integer) + Dim Objeto As New ClsGenerales + If Objeto.GetCaracteriscasOpciones(CveCaracteristica, UsuarioActual.CveEmpresa) Then + Dim dr As DataRow = Objeto.DtResultados.FiltroPrimero(String.Format(("CveCaracteristica={0}"), CveCaracteristica)) + If dr IsNot Nothing Then + If dr("CveCaracteristicaTipo").ToString = "1" Then + DdlOpcion.Items.Clear() + DdlOpcion.DataSource = Objeto.DtResultados.FiltraParametros(String.Format(("CveCaracteristica={0}"), CveCaracteristica)) + + TDDdlOpcion.Visible = True + TDTxtOpcion.Visible = False + Else + TDTxtOpcion.Visible = True + TDDdlOpcion.Visible = False + End If + + End If + End If + Objeto.Dispose() + DdlOpcion.DataBind() + End Sub + + Protected Sub CambioProductosServiciosCaracteristicasOpciones() + UpTitulosO.Update() + End Sub +#End Region + +#Region "G V O P C I O N E S" + Protected Sub GvDatosOpciones_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatosOpciones.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.RowIndex = 0 Then + e.Row.Cells(0).Width = Unit.Pixel(150) + e.Row.Cells(1).Width = Unit.Pixel(150) + e.Row.Cells(2).Width = Unit.Pixel(100) + e.Row.Cells(3).Width = Unit.Pixel(100) + e.Row.Cells(4).Width = Unit.Pixel(50) + End If + e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left + + If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then + e.Row.FCDropDownList("DdlCaracteristicaEdit").DataSource = GlobalDTProductosServiciosCaracteristicas(UsuarioActual.CveEmpresa).FiltraParametros("CvePS = " + CvePS.ToString) + e.Row.FCDropDownList("DdlCaracteristicaEdit").DataBind() + e.Row.FCDropDownList("DdlCaracteristicaEdit").SelectedValue = e.Row.DBCampo("CvePS") + End If + End If + End Sub + Protected Sub GvDatosOpciones_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatosOpciones.RowDeleting + Dim ObjOpciones As New ClsGenerales + Dim CveCaracteristicaValor As Integer = GvDatosOpciones.Rows(e.RowIndex).DataKey("CveCaracteristicaValor").ToEntero + + If ObjOpciones.RemoveCaracteristicasValores(CveCaracteristicaValor, CvePS:=CvePS) Then + GvDatosOpciones.EditIndex = -1 + CambioProductosServiciosCaracteristicasOpciones() + CargaDatosO() + UpDatosO.Update() + Alert("La Opción para Caracteristica del Producto o Servicio se eliminó correctamente.", TipoMensaje.MsgInformacion) + End If + + ObjOpciones.Dispose() + End Sub + Protected Sub GvDatosOpciones_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatosOpciones.RowCancelingEdit + GvDatosOpciones.EditIndex = -1 + End Sub + Protected Sub GvDatosOpciones_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatosOpciones.RowUpdating + Dim ObjOpciones As New ClsGralProductosServiciosCaracteristicas + Dim CveCaracteristica As Integer = DirectCast(GvDatosOpciones.Rows(e.RowIndex).FindControl("DdlCaracteristicaEdit"), DropDownList).SelectedValue.ToEntero + Dim CveOpcion As Integer = GvDatosOpciones.DataKeys(e.RowIndex).Value.ToString.ToEntero + + Dim Opcion As String = DirectCast(GvDatosOpciones.Rows(e.RowIndex).FindControl("TxtOpcion"), TextBox).Text.Trim + + If ObjOpciones.UpdateProductosServiciosCaracteristicasOpciones(Opcion, CveCaracteristica, CveOpcion) Then + GvDatosOpciones.EditIndex = -1 + ViewState("DTProductosServiciosCaracteristicasOpciones") = ObjOpciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + GlobalDTProductosServiciosCaracteristicasOpciones(UsuarioActual.CveEmpresa) = ObjOpciones.DtResultados + Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) + + CambioProductosServiciosCaracteristicasOpciones() + End If + + ObjOpciones.Dispose() + End Sub + + 'Protected Sub GvDatosOpciones_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatosOpciones.RowEditing + ' GvDatosOpciones.EditIndex = e.NewEditIndex + ' CargaGrid() + 'End Sub +#End Region + +#Region "O R D E N A M I E N T O" + Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs) + Dim Orden As String = "" + Dim Campo As String = "" + Dim gvi As Integer = 0 + Dim Literal As Literal = Nothing + Const OrdenInicial As String = "" + Dim Arg(2) As String + + Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c) + Campo = Arg(0) + gvi = Arg(1).ToEntero + Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(", ", "_")), Literal) + Campo = Campo.Substring(0, Campo.Length - 1) + + If ViewState(String.Format("O{0}", Campo, gvi)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo, gvi)).ToString = String.Format("{0} DESC", Campo) Then + ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo) + Literal.Text = String.Format("") + Else + ViewState(String.Format("O{0}", Campo, gvi)) = String.Format("{0} DESC", Campo) + Literal.Text = String.Format("") + End If + Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo, gvi)).ToString + ViewState("Orden") = Orden + End Sub + + + + 'Private Sub CargaGrid() + ' Dim Objeto As New ClsGralProductosServiciosCaracteristicas + ' If Objeto.GetPSCaracteristicas(UsuarioActual.CveEmpresa) Then + ' GvDatosCaracteristicas.DataSource = Objeto.DtResultados + ' End If + ' GvDatosCaracteristicas.DataBind() + ' Objeto.Dispose() + 'End Sub + + + +#End Region + +#Region "C A R G A S" + Private Sub ClasificacionModal() + DdlClasificacionModal.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion") + DdlClasificacionModal.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlClasificacionModal.DataBind() + UpModal.Update() + End Sub + + Private Sub CargaClasificacionesDetalles() + DdlTipoPSDes.Items.Clear() + DdlTipoPSDes.DataSource = GlobalDTClasificacionesDetalle(UsuarioActual.CveEmpresa) + 'If DdlClasificacion.SelectedValue.ToEntero > 0 Then + 'Dim ObjVenta As New ClsVentas + ' If ObjVenta.GetClasificacionDetalle(UsuarioActual.CveEmpresa, CveClasificacion:=-1) Then + ' DdlTipoPSDes.DataSource = ObjVenta.DtResultados + ' End If + ' ObjVenta.Dispose() + 'End If + DdlTipoPSDes.Items.Insert(0, New ListItem("Seleccione", "-1")) + DdlTipoPSDes.DataBind() + End Sub + Private Sub CargaClasificaciones() + DdlClasificacion.Items.Clear() + If UsuarioActual.Empresa.UsaAC Then + DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=If(UsuarioActual.Empresa.UsaContabilidad, DdlUsoClasificacion.SelectedValue.ToEntero, -1)).FiltraParametros(" Codigo = '' OR Codigo IS NULL ", Orderby:="Clasificacion") + Else + DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=If(UsuarioActual.Empresa.UsaContabilidad, DdlUsoClasificacion.SelectedValue.ToEntero, -1)).FiltraParametros("", Orderby:="Clasificacion") + End If + DdlClasificacion.Items.Insert(0, New ListItem("Seleccione", "-1")) + 'BLOQUEA DDL CLASIFICACION + If UsuarioActual.Empresa.Funcionalidad(121) = "1" Then + If Not UsuarioActual.TienePermisoProceso(147) Then + DdlClasificacion.Enabled = False + End If + End If + DdlClasificacion.DataBind() + End Sub + Private Sub CargaClasificaciones2() + DdlClasificacion2.DataSource = GlobalDTClasificaciones2(UsuarioActual.CveEmpresa) + DdlClasificacion2.DataBind() + DdlClasificacion2.Items.Insert(0, New ListItem("Sin Clasificacion", "-1")) + DdlClasificacion2.SelectedValueExist("-1") + + 'BLOQUEA DDL CLASIFICACION + If PermiteClasificacion2 Then + DivClasificacion2.Visible = True + End If + + End Sub + Private Sub CargaTipoProductos() + 'BLOQUEA DDL TIPO PRODUCTO + If UsuarioActual.Empresa.Funcionalidad(122) = "1" Then + If Not UsuarioActual.TienePermisoProceso(149) Then + DdlTipoPS.Enabled = False + DdlTipoPS.SelectedValueExist("2") + End If + End If + End Sub + Private Sub CargaConceptoRelacionado() + DdlConceptoRelacionado.DataSource = GlobalDTContaConceptosContables(-1) + DdlConceptoRelacionado.DataBind() + End Sub + Private Sub CargarMetodosInv() + ddlMetodos.DataSource = If(UsuarioActual.CveEmpresa.Contiene(72, 80), GlobalDTInvMetodosInventario.FiltraParametros("CveMetodoInventario IN (1,5)"), GlobalDTInvMetodosInventario) + ddlMetodos.DataBind() + ddlMetodos.Items.Insert(0, New ListItem("Seleccione", "-1")) + End Sub + + 'Nuevo R: 26/09/207' + Private Sub CargaProveedores() + DdlProveedor.setEsWebService(True) + 'DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) + 'DdlProveedor.DataBind() + 'DdlProveedor.Items.Insert(0, New ListItem("Seleccione", "-1")) + + DdlMoneda.DataSource = GlobalDTMonedas() + DdlMoneda.DataBind() + DdlMoneda.Items.Insert(0, New ListItem("Seleccione", "-1")) + + End Sub + + + + Private Sub CargaUnidadesMedida() + DdlUnidadMedida.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa) + DdlUnidadMedida.DataBind() + End Sub + Private Sub CargaCuentasContables() + 'Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa.ServerContPAQi, UsuarioActual.Empresa.BDContPAQi, UsuarioActual.Empresa.UsrContPAQi, UsuarioActual.Empresa.PwdContPAQi) + 'If ObjContabilidad.GetCuentas(-1, "-1", -1) Then + ' DdlCtaContableVentas.DataSource = ObjContabilidad.DtResultados + ' DdlCtaContableCompras.DataSource = ObjContabilidad.DtResultados + ' DdlCtaContableInventarios.DataSource = ObjContabilidad.DtResultados + 'Else + ' DdlCtaContableVentas.DataSource = Nothing + ' DdlCtaContableCompras.DataSource = Nothing + ' DdlCtaContableInventarios.DataSource = Nothing + 'End If + 'DdlCtaContableVentas.DataBind() + 'DdlCtaContableCompras.DataBind() + 'DdlCtaContableInventarios.DataBind() + 'ObjContabilidad.Dispose() + End Sub + Private Sub CargaDatos() + Dim ObjProductosServicios As New ClsProductosServicios() + If ObjProductosServicios.GetPS(CvePS, -1, UsuarioActual.CveEmpresa) Then + If ObjProductosServicios.DtResultados.Rows.Count > 0 Then + + 'SI NO TIENE VALOR Y NO TIENE EL PROCESO MUESTRA SIN CLASIFICACION + If ObjProductosServicios.CveClasificacion.ToString.Equals("-1") And Not UsuarioActual.TienePermisoProceso(147) And UsuarioActual.Empresa.Funcionalidad(121) = "1" Then + DdlClasificacion.SelectedValueExist("0") + Else + DdlClasificacion.SelectedValueExist(ObjProductosServicios.CveClasificacion.ToString) + End If + CargaClasificacionesDetalles() + DdlClasificacion2.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveClasificacion2").ToString) + DdlCompuesto.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveCompuesto").ToString) + 'SI ES NUEVO TIPO = PRODUCTO Y SI NO TIENE PROCESO NO PUEDO EDITAR + If ObjProductosServicios.CveTipoPS.ToString.Equals("-1") And Not UsuarioActual.TienePermisoProceso(149) And UsuarioActual.Empresa.Funcionalidad(122) = "1" Then + DdlTipoPS.SelectedValueExist("2") + Else + DdlTipoPS.SelectedValueExist(ObjProductosServicios.CveTipoPS.ToString) + End If + + 'If ObjProductosServicios.CveTipoPS = 1 Then + ' DivTipoServicio.Visible = True + ' DdlTipoServicio.SelectedValueExist(ObjProductosServicios.Estado2.ToString) + + ' If Not DdlTipoServicio.SelectedValue.ToEntero > 0 Then + ' DdlTipoServicio.Items.Insert(1, New ListItem(If(ObjProductosServicios.Estado2 = 1, "General", "Maquinaria"), ObjProductosServicios.Estado2.ToString)) + ' DdlTipoServicio.SelectedValueExist(ObjProductosServicios.Estado2.ToString) + ' End If + 'End If + If ObjProductosServicios.CveSATPS.ToString <> Nothing Then + DdlSATPS.SelectedValue = ObjProductosServicios.CveSATPS.ToString + DdlSATPS.SelectedText = $"{ObjProductosServicios.SATClavePS} - {ObjProductosServicios.SATDescripcion}" + CveSATPS = ObjProductosServicios.CveSATPS + End If + If ObjProductosServicios.CveFraccionArancelaria.ToString <> Nothing Then + DdlFraccionArancelaria.SelectedValue = ObjProductosServicios.CveFraccionArancelaria.ToString + DdlFraccionArancelaria.SelectedText = ObjProductosServicios.ClaveSATFraccionArancelariaDescripcion + End If + If ObjProductosServicios.ClaveSATUnidadAduanaDescripcion.ToString <> Nothing Then + LblUnidadAduana.Text = ObjProductosServicios.ClaveSATUnidadAduanaDescripcion.ToString + End If + DdlTipoPSDes.SelectedValueExist(ObjProductosServicios.CveClasificacionDetalle.ToString) + DdlUnidadMedida.SelectedValue = ObjProductosServicios.CveUnidadMedida.ToString + DdlMarca.SelectedValue = ObjProductosServicios.CveMarca.ToString + DdlMarcaPSDes.SelectedValue = ObjProductosServicios.CveMarca.ToString + TxtCodigo.Text = ObjProductosServicios.Codigo + 'TxtCodigo2.Text = ObjProductosServicios.Codigo2 + TxtCodigoBarras.Text = ObjProductosServicios.CodigoBarras + CodigoBarrasCargado = ObjProductosServicios.CodigoBarras + + TxtPS.Text = ObjProductosServicios.PS + TxtPrecio.Text = ObjProductosServicios.Precio.ToString("F4") 'no usa N4, porque pone comma + TxtPrecioMinimo.Text = ObjProductosServicios.PrecioMinimo.ToString("F4") + + DdlTipoFactor.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveTipoFactor").ToString) + + If ObjProductosServicios.DtResultados.Rows(0)("CveTipoFactor").ToString.Contiene("1", "2") Then + LIva.Visible = True + DdlIVA.Visible = True + DdlIVA.Width = New Unit("163px") + Else + DdlIVA.Visible = False + DdlIVA.Visible = False + End If + DdlIVA.SelectedValueExist(ObjProductosServicios.IVA.ToString) + + + LblCostoPromedio.Text = ObjProductosServicios.DtResultados.Rows(0)("CostoPromedio").ToString.FormatoNumero + LblUltimoCosto.Text = ObjProductosServicios.DtResultados.Rows(0)("UltimoCosto").ToString.FormatoNumero + LblFechaUltimaCompra.Text = ObjProductosServicios.DtResultados.Rows(0)("FechaUltimaCompra").ToString + HplKardex.NavigateUrl = $"/Inventarios/Kardex.aspx?CvePS={CvePS}" + + TxtRetIVA.Text = (ObjProductosServicios.RetIVA * 100).ToString + ChkEstado.Checked = ObjProductosServicios.Estado + LblFechaCaptura.Text = ObjProductosServicios.Fecha.ToShortDateString + LblUsuarioCapturo.Text = ObjProductosServicios.Usuario + If ObjProductosServicios.CveUsuarioModifico > 0 Then + LblFechaModificacion.Text = ObjProductosServicios.FechaUltimaModificacion.ToString + LblUsuarioModifico.Text = ObjProductosServicios.UsuarioModifico + End If + 'ChkAplicaParaConcepto.Checked = ObjProductosServicios.AplicaParaConcepto + ChkAplicaParaVenta.Checked = ObjProductosServicios.AplicaParaVenta + lbTitulo.Text = $"{lbTitulo.Text}{ObjProductosServicios.PS}" + LtProductoUnificar.Text = ObjProductosServicios.PS + ddlMetodos.SelectedValue = ObjProductosServicios.CveMetodoInventario.ToString + TxtAlmacenSeccion.Text = ObjProductosServicios.AlmacenSeccion.ToString + DdlConceptoRelacionado.SelectedValueExist(ObjProductosServicios.CveConceptoContable.ToString) + + DdlProveedor.SelectedValue = ObjProductosServicios.CveProveedorCompra.ToString + DdlProveedor.SelectedText = ObjProductosServicios.ProveedorCompra + + DdlProveedor.txtText.Value = ObjProductosServicios.ProveedorCompra + DdlProveedor.txtValue.Value = ObjProductosServicios.CveProveedorCompra.ToString + + ChkInventariable.Checked = ObjProductosServicios.Inventariable + TxtVentaMinima.Text = ObjProductosServicios.VentaMinima.ToString + DdlMoneda.SelectedValueExist(ObjProductosServicios.CveMoneda) + TxtRetISR.Text = (ObjProductosServicios.RetISR * 100).ToString + + DdlTamanio.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveTamaño").ToString) + + DdlModelo.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveModelo").ToString) + DdlMedida.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveMedida").ToString) + DdlRin.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveRinTamaño").ToString) + + 'If ObjProductosServicios.CvePSAdicional > 0 Then + ' DdlPSAdicional.SelectedValue = ObjProductosServicios.CvePSAdicional.ToString + ' DdlPSAdicional.SelectedText = ObjProductosServicios.PSCodigoAdicional + 'Else + ' DdlPSAdicional.SelectedValue = "-1" + ' DdlPSAdicional.SelectedText = "Seleccione" + 'End If + + Try + DdlClasificacion_SelectedIndexChanged(DdlClasificacion, Nothing) + Catch ex As Exception + + End Try + + ChkAplicaIeps.Checked = ObjProductosServicios.AplicaIEPS + If ObjProductosServicios.AplicaIEPS = True Then + DdlIEPSPorcentaje.Enabled = True + DdlIEPSPorcentaje.SelectedValue = ObjProductosServicios.IEPSPorcentaje.ToString("N2") + ChkIepsIVA.Enabled = True + ChkIepsIVA.Checked = ObjProductosServicios.IEPSGrabaIVA + End If + + DdlImpTipoProducto.SelectedValueExist(ObjProductosServicios.ClaveImpuestoTipoProducto) + CargaClaveGenerica(DdlImpTipoProducto.SelectedValue) + DdlImpEmpaque.SelectedValueExist(ObjProductosServicios.ClaveImpuestoEmpaque) + DdlImpUM.SelectedValueExist(ObjProductosServicios.ClaveImpuestoUnidadMedida) + DdlCategoriaToxicidad.SelectedValueExist(ObjProductosServicios.ClaveCategoriaToxicidad) + + 'If ObjProductosServicios.CveMetodoInventario = 0 Then ddlMetodos.SelectedValue = UsuarioActual.Empresa.CveMetodoInventario.ToString + + ViewState("CveSubFamilia") = ObjProductosServicios.DtResultados.Rows(0)("CveSubFamilia") + + CargaCaracteristicas() + + LnkUnificar.Visible = True + ChkEsOutSourcing.Checked = ObjProductosServicios.EsOutSourcing + Else + Alert("El Producto o Servicio Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) + RegistraScript("$('#C_Tab_TabPaquetes_tab').css('display' , 'none')") + BtnGuardar.Enabled = False + End If + End If + + If ObjProductosServicios.GetPaqueteDetalle(CvePS, UsuarioActual.CveEmpresa) Then + gvPaqueteDetalle.DataSource = ObjProductosServicios.DtResultados + dtPaqueteDetalles = ObjProductosServicios.DtResultados + + End If + ObjProductosServicios.Dispose() + gvPaqueteDetalle.DataBind() + End Sub + Protected Sub CargarAlias() + Dim ObjAlias As New ClsProductosServicios + ObjAlias.GetPSAlias(CvePS, UsuarioActual.CveEmpresa) + GVAlias.DataSource = ObjAlias.DtResultados + ObjAlias.Dispose() + GVAlias.DataBind() + End Sub + + Public Sub CargaDdlSATPS() + DdlSATPS.setEsWebService(True) + DdlSATPS.Attributes.Add("data-metodo", "getpssat") + End Sub + + Public Sub CargaDdlFraccionArancelaria() + DdlFraccionArancelaria.setEsWebService(True) + DdlFraccionArancelaria.Attributes.Add("data-metodo", "getfraccionarancelaria") + End Sub + Private Sub VerificaRequiereSerieLote() + If UsuarioActual.CveEmpresa.Contiene(80, 72) And DdlClasificacion.SelectedIndex > 0 Then + Dim RequireSerieLote As Integer = (GlobalDTClasificaciones(UsuarioActual.CveEmpresa, -1).FiltraParametros("CveClasificacion=" & DdlClasificacion.SelectedValue.ToString))(0)("RequiereSerieLote").ToString.ToEntero + If RequireSerieLote = 1 Then + RfvddlMetodos.Enabled = True + Else + RfvddlMetodos.Enabled = False + End If + Else + RfvddlMetodos.Enabled = False + End If + UpMetodos.Update() + End Sub + +#End Region + + '#Region "Familias" + ' Protected Sub DdlFamilia_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlFamilia.SelectedIndexChanged + ' CargaDdlSubFamilia() + ' DdlSubFamilia.SelectedValue = "-1" + ' End Sub + ' Public Sub CargaFamilia(Optional CveSubFamilia As Integer = 0) + ' dtFamily = GlobalDTSubFamilias(UsuarioActual.CveEmpresa) + ' CargaDdlFamilia() + ' If dtFamily.FiltraParametros(String.Format("CveClasificacion={0}", CveSubFamilia)).Rows.Count > 0 Then + ' DdlFamilia.SelectedValue = dtFamily.FiltraParametros(String.Format("CveClasificacion={0}", CveSubFamilia)).Rows(0)("CveCategoria").ToString + ' End If + ' CargaDdlSubFamilia() + + ' If CveSubFamilia > 0 Then + ' DdlSubFamilia.SelectedValue = CveSubFamilia.ToString + ' End If + ' End Sub + ' Public Sub CargaDdlFamilia() + ' ' Alert( GlobalDTFamilias(UsuarioActual.CveEmpresa).Rows.Count.ToString()) + ' DdlFamilia.DataSource = GlobalDTFamilias(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'Activo'") + ' DdlFamilia.DataBind() + ' End Sub + ' Public Sub CargaDdlSubFamilia() + ' DdlSubFamilia.DataSource = dtFamily.FiltraParametros(String.Format("CveCategoria={0}", DdlFamilia.SelectedValue), "Clasificacion") + ' DdlSubFamilia.DataBind() + ' DdlSubFamilia.Items.Insert(0, New ListItem("----", "-1")) + ' End Sub + ' Private Function isWhitFamily() As Boolean + ' Return (UsuarioActual.CveEmpresa = 66) + ' End Function + '#End Region + +#Region " TIPO SERVICIO " + 'Public Sub CargaTipoServicio() + + ' 'GENERAL + ' If UsuarioActual.TienePermisoProceso(150) Then + ' DdlTipoServicio.Items.Insert(1, New ListItem("General", "1")) + ' DdlTipoServicio.SelectedValueExist(1) + ' End If + + ' 'MAQUINARIA + ' If UsuarioActual.TienePermisoProceso(151) Then + ' DdlTipoServicio.Items.Insert(1, New ListItem("Maquinaria", "2")) + ' DdlTipoServicio.SelectedValueExist(2) + ' End If + + ' If UsuarioActual.TienePermisoProceso(150) And UsuarioActual.TienePermisoProceso(151) Then + ' DdlTipoServicio.SelectedValueExist(-1) + ' End If + + 'End Sub + 'Private Sub DdlTipoPS_SelectedIndexChanged(sender As Object, e As EventArgs) ' Handles DdlTipoPS.SelectedIndexChanged + ' If UsuarioActual.TienePermisoProceso(150) And UsuarioActual.TienePermisoProceso(151) Then + + ' If DdlTipoPS.SelectedValue.ToEntero = 1 Then + ' DivTipoServicio.Visible = True + ' End If + + ' If DdlTipoPS.SelectedValue.ToEntero = 2 Then + ' DivTipoServicio.Visible = False + ' End If + ' End If + + ' UPPCostos.Update() + ' UpDatos.Update() + + 'End Sub +#End Region + +#Region " PAQUETES " + + Protected Sub BtnCargaPSPaquetes_Click(sender As Object, e As EventArgs) + If BtnCargaPSPaquetes.CommandArgument.ToEntero > 0 Then + CargaPS() + BtnCargaPSPaquetes.CommandArgument = "1" + End If + End Sub + Private Sub CargaPS() + 'RMF 2017.09.13, ajuste asume siempre que use el webservice + 'DdlProductows.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1") + DdlProductows.setEsWebService(True) + If Not DdlProductows.UsaWebService AndAlso CType(DdlProductows.DataSource, DataTable) Is Nothing AndAlso GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) IsNot Nothing Then + DdlProductows.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlProductows.DataBind() + End If + + ElProductoChange() + End Sub + Protected Sub DdlProducto_ValueChanged(sender As Object, e As EventArgs) Handles DdlProductows.selectedindexchange + ElProductoChange() + End Sub + Private Sub ElProductoChange() + ddlUnidad.Items.Clear() + ddlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(DdlProductows.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) + ddlUnidad.DataBind() + UpDatos.Update() + End Sub + +#Region "GV PAQUETE DETALLE" + Protected Sub gvPaqueteDetalle_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvPaqueteDetalle.RowDataBound + If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then + e.Row.FCDropDownList("ddlEUnidad").DataSource = GlobalDTUnidadesMedida() + e.Row.FCDropDownList("ddlEUnidad").SelectedValue = e.Row.DBCampo("CveUnidadMedida") + e.Row.FCDropDownList("ddlEUnidad").DataBind() + End If + End Sub + Protected Sub gvPaqueteDetalle_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles gvPaqueteDetalle.RowDeleting + Dim ObjProductosServicios As New ClsProductosServicios + Dim tipo As Integer = 0 + If dtPaqueteDetalles.Rows.Item(e.RowIndex)("Tipo").ToString = "Paquete" Then + tipo = 1 + Else + tipo = 2 + End If + If ObjProductosServicios.DeletePaqueteDetalle(dtPaqueteDetalles.Rows.Item(e.RowIndex)("CvePSPaquete").ToString.ToEntero, + dtPaqueteDetalles.Rows.Item(e.RowIndex)("CvePS").ToString.ToEntero, + dtPaqueteDetalles.Rows.Item(e.RowIndex)("Cantidad").ToString.ToDouble, + tipo, + dtPaqueteDetalles.Rows.Item(e.RowIndex)("CveUnidadMedida").ToString.ToEntero) Then + + If ObjProductosServicios.GetPaqueteDetalle(CvePS, UsuarioActual.CveEmpresa) Then + gvPaqueteDetalle.EditIndex = -1 + gvPaqueteDetalle.DataSource = ObjProductosServicios.DtResultados + dtPaqueteDetalles = ObjProductosServicios.DtResultados + gvPaqueteDetalle.DataBind() + End If + End If + ObjProductosServicios.Dispose() + End Sub + Protected Sub gvPaqueteDetalle_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles gvPaqueteDetalle.RowEditing + gvPaqueteDetalle.EditIndex = e.NewEditIndex + gvPaqueteDetalle.DataSource = dtPaqueteDetalles + gvPaqueteDetalle.DataBind() + End Sub + Protected Sub gvPaqueteDetalle_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles gvPaqueteDetalle.RowCancelingEdit + gvPaqueteDetalle.EditIndex = -1 + gvPaqueteDetalle.DataSource = dtPaqueteDetalles + gvPaqueteDetalle.DataBind() + End Sub + Protected Sub gvPaqueteDetalle_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles gvPaqueteDetalle.RowUpdating + Dim ObjProductosServicios As New ClsProductosServicios + If ObjProductosServicios.UpdatePaqueteDetalle(CvePS, + dtPaqueteDetalles.Rows.Item(e.RowIndex)("CvePS").ToString.ToEntero, + DirectCast(gvPaqueteDetalle.Rows(e.RowIndex).FindControl("txtECantidad"), TextBox).Text.ToDouble, + DirectCast(gvPaqueteDetalle.Rows(e.RowIndex).FindControl("ddlETipo"), DropDownList).SelectedValue.ToEntero, + DirectCast(gvPaqueteDetalle.Rows(e.RowIndex).FindControl("ddlEUnidad"), DropDownList).SelectedValue.ToEntero, UsuarioActual.CveUsuario) Then + If ObjProductosServicios.GetPaqueteDetalle(CvePS, UsuarioActual.CveEmpresa) Then + gvPaqueteDetalle.EditIndex = -1 + gvPaqueteDetalle.DataSource = ObjProductosServicios.DtResultados + dtPaqueteDetalles = ObjProductosServicios.DtResultados + gvPaqueteDetalle.DataBind() + End If + End If + ObjProductosServicios.Dispose() + End Sub +#End Region + +#End Region + + +#Region "BTN'S" + Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click + 'Dim CerrarVentana As String = "opener.location.reload();window.close();" + 'If Request("Popup") IsNot Nothing Then CerrarVentana = "self.parent.tb_remove();self.parent.location.reload();window.close();" + RegistraScript(String.Format("$('#{0}').modal('show');", "divDescripcion")) + + End Sub + Protected Sub btguardar_Click(sender As Object, e As EventArgs) Handles btguardar.Click + Dim ObjProductosServicios As New ClsProductosServicios + If ObjProductosServicios.AddPaqueteDetalle(CvePS, DdlProductows.SelectedValue.ToEntero, txtCantidad.Text.ToDouble, ddlTipo.SelectedValue.ToEntero, ddlUnidad.SelectedValue.ToEntero, UsuarioActual.CveUsuario) Then + + If ObjProductosServicios.GetPaqueteDetalle(CvePS, UsuarioActual.CveEmpresa) Then + gvPaqueteDetalle.EditIndex = -1 + gvPaqueteDetalle.DataSource = ObjProductosServicios.DtResultados + gvPaqueteDetalle.DataBind() + + End If + + txtCantidad.Text = "" + DdlProductows.ddl.SelectedIndex = 0 + ddlUnidad.SelectedIndex = 0 + ddlTipo.SelectedIndex = 0 + End If + ObjProductosServicios.Dispose() + UpDatos.Update() + End Sub + Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click + + + If TxtPS.Text.Trim.Length = 0 Or DdlTipoPS.SelectedValue.ToEntero <= 0 Or DdlUnidadMedida.SelectedValue.ToEntero <= 0 Or DdlClasificacion.SelectedValue.ToEntero <= 0 Then + Alert("Los campos Producto/Servicio, Tipo, Unidad de medida, Clasificación Contable son requeridos por favor ingreselos.", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim CveClasificacion2 As Integer = DdlClasificacion2.SelectedValue.ToEntero + + If (TxtCodigo.Text = TxtCodigoBarras.Text AndAlso TxtCodigo.Text <> "") Then + Alert("Los codigos no pueden ser iguales. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + Return + End If + + 'If DdlSubFamilia.SelectedValue = "-1" AndAlso UsuarioActual.TienePermisoProceso(138) Then + ' Alert("Se debe especificar Familia y Subfamilia de Costos. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia) + ' Exit Sub + 'End If + + If UsuarioActual.Empresa.Funcionalidad(265) = "1" And TxtCodigo.Text = "" Then + Alert("El codigo es requerido.", TipoMensaje.MsgAdvertencia) + Return + End If + + If TxtCodigo.Text <> "" AndAlso Not TxtCodigo.Text.Length >= 3 Then + Alert("El codigo tiene que que tener una longitud de al menos 3 digitos.", TipoMensaje.MsgAdvertencia) + Return + End If + + Dim ObjProductosServicios As New ClsProductosServicios() + Dim ObjInv As New ClsInventarios(ObjProductosServicios.IniciaTransacSQL()) + + Dim TieneError = False + Dim AccionJS = "" + Dim EsPaquete As Integer = If(gvPaqueteDetalle.Rows.Count = 0, 0, 1) + Dim CveMetodoInv As Integer = If(UsuarioActual.Empresa.UsaInventarios, ddlMetodos.SelectedValue.ToEntero, -1) + + + Dim CveProveedor As Integer = -1 + If DdlProveedor.txtValue.Value.ToEntero > 0 Then + CveProveedor = DdlProveedor.txtValue.Value.ToEntero + End If + + Dim CveMarca As Integer = 0 + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then CveMarca = DdlMarcaPSDes.SelectedValue.ToEntero Else CveMarca = DdlMarca.SelectedValue.ToEntero + + If CvePS = -1 Then + Dim PSS As String = TxtPS.Text.Trim.Replace("|", "") + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then PSS = PSS.ToUpper + If ObjProductosServicios.AddPS(DdlClasificacion.SelectedValue.ToEntero, -1, DdlUnidadMedida.SelectedValue.ToEntero, TxtCodigo.Text.Trim, "", TxtCodigoBarras.Text.Trim, PSS, + TxtPrecio.Text.Trim.ToDouble, DdlIVA.SelectedValue.ToDouble, (TxtRetIVA.Text.Trim.ToDouble / 100), ChkInventariable.Checked, CveProveedor, True, + ChkAplicaParaVenta.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveMetodoInv, EsPaquete, CveTipoPS:=DdlTipoPS.SelectedValue.ToEntero, + FuePorXML:=False, TipoServicio:=-1, CveClasificacion2:=CveClasificacion2, CveMarca:=CveMarca, AlmacenSeccion:=TxtAlmacenSeccion.Text.Trim, + AplicaIEPS:=ChkAplicaIeps.Checked, IEPSPorcentaje:=DdlIEPSPorcentaje.SelectedValue.ToDecimal, CveConceptoContable:=DdlConceptoRelacionado.SelectedValue.ToEntero, + CveCompuesto:=DdlCompuesto.SelectedValue.ToEntero, CveSATPS:=DdlSATPS.SelectedValue.ToEntero, IEPSGrabaIVA:=ChkIepsIVA.Checked, VentaMinima:=TxtVentaMinima.Text.ToDecimal, + CveMoneda:=DdlMoneda.SelectedValue.ToEntero, RetISR:=(TxtRetISR.Text.Trim.ToDouble / 100), PrecioMinimo:=TxtPrecioMinimo.Text.ToDecimal, + CveTipoFactor:=DdlTipoFactor.SelectedValue.ToEntero, CveFraccionArancelaria:=DdlFraccionArancelaria.SelectedValue.ToEntero, + CveClasificacionDetalle:=DdlTipoPSDes.SelectedValue.ToEntero, CveTamaño:=DdlTamanio.SelectedValue.ToEntero, + CveModelo:=DdlModelo.SelectedValue.ToEntero(), CveMedida:=DdlMedida.SelectedValue.ToEntero(), CveRinTamaño:=DdlRin.SelectedValue.ToEntero(), + ClaveImpuestoEmpaque:=DdlImpEmpaque.SelectedValue.ToString, ClaveImpuestoUM:=DdlImpUM.SelectedValue.ToString, ClaveCategoriaToxicidad:=DdlCategoriaToxicidad.SelectedValue.ToString, + ClaveImpuestoTipoProducto:=DdlImpTipoProducto.SelectedValue.ToString, EsOutSourcing:=ChkEsOutSourcing.Checked) > 0 Then + ViewState("CvePS") = ObjProductosServicios.CvePS + For Each GVR As GridViewRow In GvImpuestosLocales.Rows + If GVR.FCCheckBox("ChkDeduccion").Checked Then + ObjProductosServicios.AddPSImpuestosLocales(CvePS, GVR.DataKey("CveImpuestoLocal").ToEntero) + End If + Next + 'Alert("El Producto o Servicio se guardó correctamente.", TipoMensaje.MsgInformacion, "document.location.href= "" / ProductosServicios.aspx?CvePS=" & ObjProductosServcios.CvePS.ToString & """;") + AccionJS = "document.location.href=""/Ventas/CatPS.aspx"";" + + + If Not TieneError Then + For Each Dr As DataRow In DtSeccionAlmacen.Rows + If Dr("CveAlmacen").ToString.ToEntero > 0 Then + If Not ObjInv.AddProductosServiciosAlmacenSeccion(CvePS, Dr("CveAlmacen").ToString.ToEntero, Dr("CveAlmacenSeccion").ToString.ToEntero) Then + TieneError = True + End If + End If + Next + End If + + Else + TieneError = True + Alert("Ocurrió un Error al agregar el Producto o Servicio. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + Else + + If CodigoBarrasCargado.Length > 0 And TxtCodigoBarras.Text.Length = 0 Then + TxtCodigoBarras.Text = CodigoBarrasCargado + End If + + Dim PSS As String = TxtPS.Text.Trim.Replace("|", "") + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) Then PSS = PSS.ToUpper + + If ObjProductosServicios.UpdatePS(DdlClasificacion.SelectedValue.ToEntero, -1, DdlUnidadMedida.SelectedValue.ToEntero, TxtCodigo.Text.Trim, "", TxtCodigoBarras.Text.Trim, PSS, + TxtPrecio.Text.Trim.ToDouble, DdlIVA.SelectedValue.ToDouble, (TxtRetIVA.Text.Trim.ToDouble / 100), ChkInventariable.Checked, CveProveedor, True, + ChkAplicaParaVenta.Checked, ChkEstado.Checked, UsuarioActual.CveUsuario, CvePS, CveMetodoInv, EsPaquete, DdlSATPS.SelectedValue.ToEntero, + CveTipoPS:=DdlTipoPS.SelectedValue.ToEntero, TipoServicio:=-1, CveClasificacion2:=CveClasificacion2, CveMarca:=CveMarca, AlmacenSeccion:=TxtAlmacenSeccion.Text.Trim, + AplicaIEPS:=ChkAplicaIeps.Checked, IEPSPorcentaje:=DdlIEPSPorcentaje.SelectedValue.ToDecimal, CveConceptoContable:=DdlConceptoRelacionado.SelectedValue.ToEntero, + CveCompuesto:=DdlCompuesto.SelectedValue.ToEntero, IEPSGrabaIVA:=ChkIepsIVA.Checked, VentaMinima:=TxtVentaMinima.Text.ToDecimal, + CveMoneda:=DdlMoneda.SelectedValue.ToEntero, RetISR:=(TxtRetISR.Text.Trim.ToDouble / 100), PrecioMinimo:=TxtPrecioMinimo.Text.ToDecimal, + CveTipoFactor:=DdlTipoFactor.SelectedValue.ToEntero, CveFraccionArancelaria:=DdlFraccionArancelaria.SelectedValue.ToEntero, + CveUsuarioModifico:=UsuarioActual.CveUsuario, CveClasificacionDetalle:=DdlTipoPSDes.SelectedValue.ToEntero, CveTamaño:=DdlTamanio.SelectedValue.ToEntero, + CveModelo:=DdlModelo.SelectedValue.ToEntero(), CveMedida:=DdlMedida.SelectedValue.ToEntero(), CveRinTamaño:=DdlRin.SelectedValue.ToEntero(), + ClaveImpuestoEmpaque:=DdlImpEmpaque.SelectedValue.ToString, ClaveImpuestoUM:=DdlImpUM.SelectedValue.ToString, ClaveCategoriaToxicidad:=DdlCategoriaToxicidad.SelectedValue.ToString, + ClaveImpuestoTipoProducto:=DdlImpTipoProducto.SelectedValue.ToString, EsOutSourcing:=ChkEsOutSourcing.Checked) Then + + If Not ObjProductosServicios.LimpiaImpuestosLocales(CvePS) Then + TieneError = True + Alert("Ocurrió un Error al regenerar los impuestos locales. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + + If Not TieneError Then + For Each GVR As GridViewRow In GvImpuestosLocales.Rows + If GVR.FCCheckBox("ChkDeduccion").Checked Then + If Not ObjProductosServicios.AddPSImpuestosLocales(CvePS, GVR.DataKey("CveImpuestoLocal").ToEntero) Then + TieneError = True + Alert("Ocurrió un Error al agregar los impuestos locales. Por favor vuelva a intentar.", TipoMensaje.MsgError) + Exit For + End If + End If + Next + End If + + AccionJS = If(Ret = "Comp", "ircompras();", "document.location.href=""/Ventas/CatPS.aspx"";") + 'UpDatos.Update() + 'Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion, AccionJS) + + If Not TieneError Then + For Each Dr As DataRow In DtSeccionAlmacen.Rows + If Dr("CveAlmacen").ToString.ToEntero > 0 AndAlso Not Dr("CvePSAlmacenSeccion").ToString.ToEntero > 0 Then + If Not ObjInv.AddProductosServiciosAlmacenSeccion(CvePS, Dr("CveAlmacen").ToString.ToEntero, Dr("CveAlmacenSeccion").ToString.ToEntero) Then + TieneError = True + End If + ElseIf Not Dr("CveAlmacen").ToString.ToEntero > 0 AndAlso Dr("CvePSAlmacenSeccion").ToString.ToEntero > 0 Then + If Not ObjInv.RemoveProductosServiciosAlmacenSeccion(Dr("CvePSAlmacenSeccion").ToString.ToEntero) Then + TieneError = True + End If + End If + Next + End If + + + Else + TieneError = True + Alert("Ocurrió un Error al actualizar el Producto o Servicio. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + ObjProductosServicios.CvePS = CvePS + End If + + If ObjProductosServicios.CvePS > 0 And Not TieneError Then + For i As Integer = 0 To gvSucursal.Rows.Count - 1 + If gvSucursal.Rows(i).FCCheckBox("chkSucursal").Checked = False Then + If Not ObjProductosServicios.RemovePSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).DataKey("CveSubProyecto").ToEntero) Then + TieneError = True + Alert("Ocurrió un Error al eliminar sucursales del producto. Por favor vuelva a intentar.", TipoMensaje.MsgError) + Exit For + End If + Else + If gvSucursal.Rows(i).FCHiddenField("hdnEnBD").Value.ToEntero = 1 Then + 'Actualizarlo + If Not ObjProductosServicios.UpdatePSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).FCTextBox("txtImporte").Text.ToDouble, gvSucursal.Rows(i).FCTextBox("TxtMinimo").Text.ToDouble, gvSucursal.Rows(i).FCTextBox("TxtMaximo").Text.ToDouble, UsuarioActual.CveUsuario, gvSucursal.Rows(i).DataKey("CveSubProyecto").ToEntero, PrecioMinimo:=gvSucursal.Rows(i).FCTextBox("TxtPrecioMinimo").Text.ToDecimal) Then + TieneError = True + Alert("Ocurrió un Error al actualizar sucursales del producto. Por favor vuelva a intentar.", TipoMensaje.MsgError) + Exit For + End If + 'ObjProductosServicios.UpdatePSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).FCHiddenField("hdnCveSucursal").Value.ToEntero, gvSucursal.Rows(i).FCTextBox("txtImporte").Text.ToDouble, UsuarioActual.CveUsuario) + Else + 'Insertarlo + 'ObjProductosServicios.AddPSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).FCHiddenField("hdnCveSucursal").Value.ToEntero, gvSucursal.Rows(i).FCTextBox("txtImporte").Text.ToDouble, UsuarioActual.CveUsuario) + If Not ObjProductosServicios.AddPSSucursales(ObjProductosServicios.CvePS, gvSucursal.Rows(i).FCTextBox("txtImporte").Text.ToDouble, gvSucursal.Rows(i).FCTextBox("TxtMinimo").Text.ToDouble, gvSucursal.Rows(i).FCTextBox("TxtMaximo").Text.ToDouble, UsuarioActual.CveUsuario, gvSucursal.Rows(i).DataKey("CveSubProyecto").ToEntero, PrecioMinimo:=gvSucursal.Rows(i).FCTextBox("TxtPrecioMinimo").Text.ToDecimal) Then + TieneError = True + Alert("Ocurrió un Error al agregar sucursales del producto. Por favor vuelva a intentar.", TipoMensaje.MsgError) + Exit For + End If + End If + End If + Next + End If + + + If ObjProductosServicios.CvePS > 0 And Not TieneError Then + TieneError = GuardaEcommerce() + End If + + + If Not TieneError Then + ObjProductosServicios.Commit() + Alert("El Producto/Servicio se guardo correctamente.", TipoMensaje.MsgInformacion, AccionJS) + Else + ObjProductosServicios.RollBack() + End If + + ObjProductosServicios.Dispose() + + RecargaGlobal() + End Sub + Protected Sub HFProducto_ValueChanged(sender As Object, e As EventArgs) Handles HFProducto.ValueChanged + ddlUnidad.DataSource = GlobalDTProductosServiciosEquivalencias(HFProducto.Value.ToEntero, -1, UsuarioActual.CveEmpresa) + ddlUnidad.DataBind() + End Sub + Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click + Dim ObjAliasAdd As New ClsProductosServicios + Dim TieneError = False + + If ObjAliasAdd.AddPSAlias(TxtAlias.Text.ToString, CvePS, UsuarioActual.CveUsuario) Then + CargarAlias() + UPGVAlias.Update() + Alert("Alias " + TxtAlias.Text + " agregado.", TipoMensaje.MsgInformacion) + TxtAlias.Text = "" + Else + TieneError = True + End If + ObjAliasAdd.Dispose() + + If Not TieneError Then + RecargaGlobal() + End If + End Sub +#End Region + +#Region "G L O B L A L" + Private Sub RecargaGlobal() + 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalDT) + 'Hilo.Start() + GeneraGlobalDT() + End Sub + Private Sub GeneraGlobalDT() + + GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) = Nothing + GlobalDTProductosServiciosAlias(UsuarioActual.CveEmpresa) = Nothing + GlobalDTImpuestosLocales(-1, UsuarioActual.CveEmpresa) = Nothing + GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = Nothing + GlobalDTPSAdicionales(-1, UsuarioActual.CveEmpresa) = Nothing + + 'Dim ObjPS As New ClsProductosServicios + + 'If ObjPS.GetPSSimplificado(UsuarioActual.CveEmpresa) Then Application(String.Format("GlobalDTPSSimplificado{0}", UsuarioActual.CveEmpresa)) = ObjPS.DtResultados.AsEnumerable() + + ''If ObjPS.GetPSAlias(-1, UsuarioActual.CveEmpresa) Then + ' GlobalDTProductosServiciosAlias(UsuarioActual.CveEmpresa) = ObjPS.DtResultados + 'End If + + 'If ObjPS.GetPSImpuestosLocales(-1, UsuarioActual.CveEmpresa) Then + ' GlobalDTImpuestosLocales(-1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados + 'End If + + 'If ObjPS.GetPSEquivalencias(-1, UsuarioActual.CveEmpresa) Then + ' GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados + 'End If + + 'If ObjPS.GetPSAdicionales(-1, UsuarioActual.CveEmpresa) Then + ' GlobalDTPSAdicionales(-1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados + 'End If + + 'ObjPS.Dispose() + End Sub + +#End Region + +#Region "GV ALIAS" + Protected Sub GVAlias_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVAlias.RowDeleting + Dim ObjAliasDelete As New ClsProductosServicios + Dim TieneError = False + + If ObjAliasDelete.RemovePSAlias(GVAlias.Rows(e.RowIndex).DataKey("CvePS").ToString.ToEntero, GVAlias.Rows(e.RowIndex).DataKey("PSAlias").ToString) Then + GVAlias.EditIndex = -1 + CargarAlias() + UPGVAlias.Update() + Alert("El Alias ha sido Eliminado", TipoMensaje.MsgInformacion) + Else + Alert("Error al Eliminar", TipoMensaje.MsgError) + TieneError = True + End If + ObjAliasDelete.Dispose() + + If Not TieneError Then + RecargaGlobal() + End If + End Sub +#End Region + +#Region " EQUIVALENCIAS " + Private Sub CargaEquivalencias() + + DivEquivalencia.Visible = True + + Dim ObjProductosServicios As New ClsProductosServicios() + If ObjProductosServicios.GetPSEquivalencias(CvePS, UsuarioActual.CveEmpresa) Then + DtEquivalencias = ObjProductosServicios.DtResultados + Else + DtEquivalencias = Nothing + End If + ObjProductosServicios.Dispose() + + CargaGvEquivalencias() + + End Sub + Private Sub RecargaGlobalEquivalencias() + 'Dim Hilo As New System.Threading.Thread(AddressOf GeneraGlobalEquivalencias) + 'Hilo.Start() + GeneraGlobalEquivalencias() + End Sub + Private Sub GeneraGlobalEquivalencias() + GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = Nothing + 'Dim ObjPS = New ClsProductosServicios + 'If ObjPS.GetPSEquivalencias(-1, -1) Then + ' GlobalDTProductosServiciosEquivalencias(-1, -1, UsuarioActual.CveEmpresa) = ObjPS.DtResultados + 'End If + 'ObjPS.Dispose() + End Sub + Private Sub CargaGvEquivalencias() + If DtEquivalencias IsNot Nothing Then + GvEquivalencia.DataSource = DtEquivalencias + End If + GvEquivalencia.DataBind() + UpEquivalencias.Update() + End Sub + Private Sub GvEquivalencia_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEquivalencia.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DBCampo("UnidadBase") = "True" Then + e.Row.FCLinkButton("imgR").Visible = False + End If + + If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then + If e.Row.DBCampo("UnidadBase") = "True" Then + 'e.Row.FCCheckBox("ChkBase").Checked = True + End If + End If + + End If + End Sub + Protected Sub GvEquivalencia_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvEquivalencia.RowEditing + GvEquivalencia.EditIndex = e.NewEditIndex + CargaGvEquivalencias() + End Sub + Protected Sub GvEquivalencia_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvEquivalencia.RowCancelingEdit + GvEquivalencia.EditIndex = -1 + CargaGvEquivalencias() + End Sub + Private Sub GvEquivalencia_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvEquivalencia.RowUpdating + Dim TieneError = False + + Dim CveUM = GvEquivalencia.Rows(e.RowIndex).DataKey("CveUM").ToEntero + Dim UnidadBase = GvEquivalencia.Rows(e.RowIndex).DataKey("UnidadBase").ToString = "True" + Dim Cantidad = DirectCast(GvEquivalencia.Rows(e.RowIndex).FindControl("TxtCantidadEquivalencia"), TextBox).Text.Trim.ToDecimal + + Dim ObjProductosServicios As New ClsProductosServicios() + If Not ObjProductosServicios.UpdatePSEquivalencias(CvePS, CveUM, Cantidad, UnidadBase, 0, UsuarioActual.CveUsuario) Then + TieneError = True + End If + ObjProductosServicios.Dispose() + + If Not TieneError Then + Alert("La equivalencia se actualizó correctamente.", TipoMensaje.MsgInformacion) + GvEquivalencia.EditIndex = -1 + CargaEquivalencias() + CargaGvEquivalencias() + RecargaGlobalEquivalencias() + Else + Alert("ocurrió un error al actualizar la equivalencia.", TipoMensaje.MsgError) + End If + + End Sub + Private Sub GvEquivalencia_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvEquivalencia.RowDeleting + Dim TieneError = False + + Dim CveUM = GvEquivalencia.Rows(e.RowIndex).DataKey("CveUM").ToEntero + + Dim ObjProductosServicios As New ClsProductosServicios() + If Not ObjProductosServicios.RemovePSEquivalencias(CvePS, CveUM) Then + TieneError = True + End If + ObjProductosServicios.Dispose() + + If Not TieneError Then + Alert("La equivalencia se eliminó correctamente.", TipoMensaje.MsgInformacion) + CargaEquivalencias() + CargaGvEquivalencias() + RecargaGlobalEquivalencias() + Else + Alert("ocurrió un error al eliminar la equivalencia.", TipoMensaje.MsgError) + End If + + End Sub + +#End Region + +#Region "PS ADICIONALES" + + Private Sub CargaPSAdicionales() + + Dim ObjProductosServicios As New ClsProductosServicios() + If ObjProductosServicios.GetPSAdicionales(CvePS, UsuarioActual.CveEmpresa) Then + DtPSAdicionales = ObjProductosServicios.DtResultados + Else + DtPSAdicionales = Nothing + End If + ObjProductosServicios.Dispose() + + CargaGvPSAdicionales() + + End Sub + Private Sub CargaGvPSAdicionales() + If DtPSAdicionales IsNot Nothing Then + GvPSAdicionales.DataSource = DtPSAdicionales + End If + GvPSAdicionales.DataBind() + UpPSAdicionales.Update() + End Sub + Private Sub GvPSAdicionales_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPSAdicionales.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then + e.Row.FCDropDownList("DdlPSAdicional").DataSource = GlobalDTPS(UsuarioActual.CveEmpresa) '.FiltraParametros("CvePS = " + CvePS.ToString) + e.Row.FCDropDownList("DdlPSAdicional").DataBind() + e.Row.FCDropDownList("DdlPSAdicional").SelectedValue = e.Row.DBCampo("CvePSAdicional") + End If + + End If + End Sub + Protected Sub GvPSAdicionales_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvPSAdicionales.RowCancelingEdit + GvPSAdicionales.EditIndex = -1 + CargaGvPSAdicionales() + End Sub + Private Sub GvPSAdicionales_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvPSAdicionales.RowDeleting + Dim TieneError = False + + Dim CvePSAdicional = GvPSAdicionales.Rows(e.RowIndex).DataKey("CvePSAdicional").ToEntero + + Dim ObjProductosServicios As New ClsProductosServicios() + If Not ObjProductosServicios.RemovePSAdicionales(CvePS, CvePSAdicional) Then + TieneError = True + End If + ObjProductosServicios.Dispose() + + If Not TieneError Then + Alert("El Producto/Servicio Adicionala se eliminó correctamente.", TipoMensaje.MsgInformacion) + CargaPSAdicionales() + CargaGvPSAdicionales() + 'RecargaGlobalEquivalencias() + RecargaGlobal() + Else + Alert("ocurrió un error al eliminar el Producto/Servicio Adicional.", TipoMensaje.MsgError) + End If + + End Sub + + Private Sub BtnAgregarPSAdicionalesModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarPSAdicionalesModal.Click + BtnAgregarPSAdicional.Text = "Agregar" + CvePSAdicional = -1 + + DdlPSAdicional.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa) + DdlPSAdicional.DataBind() + DdlPSAdicional.Items.Add(New ListItem("Seleccione", "-1")) + UpAddPSAdicional.Update() + + DdlPSAdicional.SelectedValue = "-1" + TxtCantidadPSAdicional.Text = "" + UpCantidad.Visible = False + RBLCantidad.SelectedValue = "1" + RegistraScript("$('#divAddPSAdicional').modal();") + End Sub + Private Sub BtnAgregarPSAdicional_Click(sender As Object, e As EventArgs) Handles BtnAgregarPSAdicional.Click + Dim ObjProductosServicios As New ClsProductosServicios() + ObjProductosServicios.IniciaTransacSQL() + Dim TieneError = False + + If CvePSAdicional < 0 Then + If Not ObjProductosServicios.AddPSAdicionales(CvePS, DdlPSAdicional.SelectedValue.ToEntero, If(TxtCantidadPSAdicional.Visible, TxtCantidadPSAdicional.Text.ToDecimal, 0)) Then + TieneError = True + End If + Else + + If Not ObjProductosServicios.UpdatePSAdicionales(CvePS, DdlPSAdicional.SelectedValue.ToEntero, CvePSAdicional, If(TxtCantidadPSAdicional.Visible, TxtCantidadPSAdicional.Text.ToDecimal, 0)) Then + TieneError = True + End If + + End If + + If TieneError Then + Alert("Ocurrio un error al agregar/actualizar el Producto/Servicio Adicional.", TipoMensaje.MsgError) + ObjProductosServicios.RollBack() + Else + ObjProductosServicios.Commit() + RegistraScript("$('#divAddPSAdicional').modal('hide');") + CvePSAdicional = -1 + CargaPSAdicionales() + CargaGvPSAdicionales() + RecargaGlobal() + End If + ObjProductosServicios.Dispose() + End Sub + + Protected Sub Edit_Click(sender As Object, e As EventArgs) + Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) + BtnAgregarPSAdicional.Text = "Guardar" + TxtCantidadPSAdicional.Text = GvRow.DataKey("Cantidad") + + If TxtCantidadPSAdicional.Text.ToEntero = 0 Then + UpCantidad.Visible = False + RBLCantidad.SelectedValue = "1" + Else + UpCantidad.Visible = True + RBLCantidad.SelectedValue = "2" + End If + UpAddPSAdicional.Update() + + DdlPSAdicional.DataSource = GlobalDTPS(UsuarioActual.CveEmpresa) + DdlPSAdicional.DataBind() + DdlPSAdicional.Items.Add(New ListItem("Seleccione", "-1")) + UpAddPSAdicional.Update() + + CvePSAdicional = GvRow.DataKey("CvePSAdicional").ToEntero + DdlPSAdicional.SelectedValue = GvRow.DataKey("CvePSAdicional") + + RegistraScript("$('#divAddPSAdicional').modal();") + End Sub + + Protected Sub RBLCantidad_SelectedIndexChanged1(sender As Object, e As EventArgs) + If RBLCantidad.SelectedValue.ToEntero = 2 Then + UpCantidad.Visible = True + Else + UpCantidad.Visible = False + End If + UpAddPSAdicional.Update() + End Sub +#End Region + +#Region " CARGA MARCA Y COMPUESTOS " + + Protected Sub CargarMarcas() + If UsuarioActual.Empresa.Funcionalidad(130) = "1" Then + If UsuarioActual.CveEmpresa.Contiene(1, 72, 80) And CvePS = -1 Then + DivMarcaPSDes.Visible = True + Else + DivMarca.Visible = True + End If + Dim ObjMarcas As New ClsProductosServicios + ObjMarcas.GetMarcas(UsuarioActual.CveEmpresa) + DdlMarca.DataSource = ObjMarcas.DtResultados + DdlMarcaPSDes.DataSource = ObjMarcas.DtResultados + ObjMarcas.Dispose() + DdlMarca.DataBind() + DdlMarcaPSDes.DataBind() + End If + DdlMarca.Items.Insert(0, New ListItem(" - ", "-1")) + DdlMarcaPSDes.Items.Insert(0, New ListItem(" - ", "-1")) + End Sub + + Protected Sub CargarCompuestos() + If UsuarioActual.Empresa.Funcionalidad(143) = "1" Then + DivCompuesto.Visible = True + Dim PS As New ClsProductosServicios + PS.GetCompuestosActivos(UsuarioActual.CveEmpresa) + DdlCompuesto.DataSource = PS.DtResultados + PS.Dispose() + DdlCompuesto.DataBind() + End If + End Sub + + +#End Region + +#Region "IMPUESTOS LOCALES" + Public Sub CargaImpuestosLocales() + Dim ObjPS As New ClsProductosServicios + If ObjPS.GetPSImpuestosLocales(CvePS, UsuarioActual.CveEmpresa) Then + GvImpuestosLocales.DataSource = ObjPS.DtResultados + End If + ObjPS.Dispose() + GvImpuestosLocales.DataBind() + End Sub + +#End Region + +#Region " IEPS " + Private Sub ChkAplicaIeps_CheckedChanged(sender As Object, e As EventArgs) Handles ChkAplicaIeps.CheckedChanged + If ChkAplicaIeps.Checked Then + DdlIEPSPorcentaje.Enabled = True + ChkIepsIVA.Enabled = True + Else + DdlIEPSPorcentaje.SelectedIndex = 0 + DdlIEPSPorcentaje.Enabled = False + ChkIepsIVA.Enabled = False + ChkIepsIVA.Checked = False + End If + UpDatos.Update() + End Sub +#End Region + +#Region "UNIFICAR PRODUCTOS" + Private Sub LnkUnificar_Click(sender As Object, e As EventArgs) Handles LnkUnificar.Click + CargaPSUnificar() + RegistraScript("$('#DivUnificar').modal();LimpiaModalUnificar()") + End Sub + Public Sub CargaPSUnificar() + DdlPsUnificar.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa) + DdlPsUnificar.DataBind() + 'DdlPsUnificar.setEsWebService(True) + 'DdlPsUnificar.ddlWS.Attributes.Add("data-clear", "1") + + UpBodyUnificar.Update() + End Sub + Private Sub BtnUnificar_Click(sender As Object, e As EventArgs) Handles BtnUnificar.Click + If DdlPsUnificar.SelectedValue.ToEntero() > 0 Then + If DdlPsUnificar.SelectedValue.ToEntero() = CvePS Then + Alert("No se puede seleccionar el mismo producto y/o servicio", TipoMensaje.MsgAdvertencia) + Else + Dim ObjPS As New ClsProductosServicios + If ObjPS.UnificarPS(CvePS, DdlPsUnificar.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + Alert("Los productos y/o servicios han sido unificados", TipoMensaje.MsgInformacion) + Else + Alert("Los productos y/o servicios no han podido ser unificados", TipoMensaje.MsgError) + End If + ObjPS.Dispose() + RecargaGlobal() + RegistraScript("$('#DivUnificar').modal('hide');") + UpDatos.Update() + End If + Else + Alert("Es necesario seleccionar un producto y/o servicio", TipoMensaje.MsgAdvertencia) + End If + + + End Sub +#End Region + +#Region "BITACORA" + + Private Sub CargaGvBitacora() + Dim ObjGral As New ClsGenerales() + If ObjGral.GetHistorialBitacora(-1, -1, -1, -1, CvePS, -1, -1, UsuarioActual.CveEmpresa) Then + GvBitacora.DataSource = ObjGral.DtResultados + GvBitacora.DataBind() + End If + ObjGral.Dispose() + UpDatos.Update() + End Sub + + Private Sub BtnRemove_Click(sender As Object, e As EventArgs) Handles BtnRemove.Click + If Not TxtDescripcion.Text = "" Then + Dim ObjProductosServcios As New ClsProductosServicios() + Dim ObjGral As New ClsGenerales(ObjProductosServcios.IniciaTransacSQL()) + + + If ObjProductosServcios.RemovePS(CvePS) Then + Borrar = True + Else + Borrar = False + End If + + If Borrar = True Then + If ObjGral.AddHistorialBitacora(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, "", "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1, TxtDescripcion.Text, "PS", TxtCodigo.Text + " / " + TxtPS.Text) Then + ObjProductosServcios.Commit() + RecargaGlobal() + Alert("El Producto o Servicio se eliminó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatPS.aspx"";") + Else + ObjProductosServcios.RollBack() + Alert("Ocurrió un Error al actualizar el historial de eliminación.", TipoMensaje.MsgError) + End If + Else + ObjProductosServcios.RollBack() + Alert("Ocurrió un Error al eliminar el Producto o Servicio. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + ObjProductosServcios.Dispose() + ObjGral.Dispose() + Else + Alert("Tiene que decir el motivo de su eliminacion.", TipoMensaje.MsgInformacion) + End If + End Sub + +#End Region + +#Region "Codigo Barras" + + 'Codigo barras/QR se retorna como una imagen bmp + Private Function GeneraCodigoQR(CodigoBarras As String, Alto As Integer, Largo As Integer, Margen As Integer, Formato As String) As Byte() + + Dim barcodeWriter As New BarcodeWriter + Dim opciones As New ZXing.Common.EncodingOptions + Dim FormatoBar As New BarcodeFormat + 'Dim Respuesta As Byte() + + opciones.Height = Alto + opciones.Width = Largo + opciones.Margin = Margen + + barcodeWriter.Options = opciones + + Select Case Formato + Case "All_1D" + barcodeWriter.Format = BarcodeFormat.All_1D + Exit Select + Case "AZTEC" + barcodeWriter.Format = BarcodeFormat.AZTEC + Exit Select + Case "CODABAR" + barcodeWriter.Format = BarcodeFormat.CODABAR + Exit Select + Case "CODE_128" + barcodeWriter.Format = BarcodeFormat.CODE_128 + Exit Select + Case "CODE_39" + barcodeWriter.Format = BarcodeFormat.CODE_39 + Exit Select + Case "CODE_93" + barcodeWriter.Format = BarcodeFormat.CODE_93 + Exit Select + Case "DATA_MATRIX" + barcodeWriter.Format = BarcodeFormat.DATA_MATRIX + Exit Select + Case "EAN_13" + barcodeWriter.Format = BarcodeFormat.EAN_13 + Exit Select + Case "EAN_8" + barcodeWriter.Format = BarcodeFormat.EAN_8 + Exit Select + Case "IMB" + barcodeWriter.Format = BarcodeFormat.IMB + Exit Select + Case "ITF" + barcodeWriter.Format = BarcodeFormat.ITF + Exit Select + Case "MAXICODE" + barcodeWriter.Format = BarcodeFormat.MAXICODE + Exit Select + Case "MSI" + barcodeWriter.Format = BarcodeFormat.MSI + Exit Select + Case "PDF_417" + barcodeWriter.Format = BarcodeFormat.PDF_417 + Exit Select + Case "PLESSEY" + barcodeWriter.Format = BarcodeFormat.PLESSEY + Exit Select + Case "QR_CODE" + barcodeWriter.Format = BarcodeFormat.QR_CODE + Exit Select + Case "RSS_14" + barcodeWriter.Format = BarcodeFormat.RSS_14 + Exit Select + Case "RSS_EXPANDED" + barcodeWriter.Format = BarcodeFormat.RSS_EXPANDED + Exit Select + Case "UPC_A" + barcodeWriter.Format = BarcodeFormat.UPC_A + Exit Select + Case "UPC_E" + barcodeWriter.Format = BarcodeFormat.UPC_E + Exit Select + Case "UPC_EAN_EXTENSION" + barcodeWriter.Format = BarcodeFormat.UPC_EAN_EXTENSION + Exit Select + + End Select + + Dim imgCod As Drawing.Bitmap = barcodeWriter.Write(CodigoBarras) + Dim memoriStream As New System.IO.MemoryStream + imgCod.Save(memoriStream, Drawing.Imaging.ImageFormat.Bmp) + + 'Respuesta = Convert.ToBase64String(memoriStream.ToArray()) + + Return memoriStream.ToArray() + + End Function + + Private Sub LnkModalCodigoBarrasQr_Click(sender As Object, e As EventArgs) Handles LnkModalCodigoBarrasQr.Click + + LnkDescargaImagen.Enabled = False + LnkDescargaImpresion.Enabled = False + UpModalBotonesCodigos.Update() + + TxtCodigoBarrasModal.Text = TxtCodigoBarras.Text.Trim + UpModalUploadCodigoBarras.Update() + RegistraScript("$('#ModalCodigoBarrasQR').modal({ backdrop: 'static', keyboard: false});") + + End Sub + + + Private Sub LnkModalGenerarCodigoBarrasQR_Click(sender As Object, e As EventArgs) Handles LnkModalGenerarCodigoBarrasQR.Click + + Dim Alto As Integer = 150 + Dim Ancho As Integer = 150 + Dim Base64Code As String + + If TxtAlto.Text.ToEntero > 0 Then Alto = TxtAlto.Text.ToEntero + If TxtAncho.Text.ToEntero > 0 Then Ancho = TxtAncho.Text.ToEntero + + Try + Base64Code = Convert.ToBase64String(GeneraCodigoQR(TxtCodigoBarrasModal.Text.Trim, Alto, Ancho, 0, DDLCodigoFormato.SelectedValue)) + ImgModalCodigo.Attributes.Add("src", $"data:image/gif;base64,{Base64Code}") + ImgModalCodigo.Width = Ancho + ImgModalCodigo.Height = Alto + LnkDescargaImagen.Enabled = True + LnkDescargaImpresion.Enabled = True + UpModalBotonesCodigos.Update() + Catch ex As Exception + ImgModalCodigo.Attributes.Add("src", "") + ImgModalCodigo.Width = Ancho + ImgModalCodigo.Height = Alto + LnkDescargaImagen.Enabled = False + LnkDescargaImpresion.Enabled = False + UpModalBotonesCodigos.Update() + End Try + + UpModalUploadCodigoBarras.Update() + + End Sub + + Private Sub LnkDescargaImagen_Click(sender As Object, e As EventArgs) Handles LnkDescargaImagen.Click + + Dim Alto As Integer = 150 + Dim Ancho As Integer = 150 + + + If TxtAlto.Text.ToEntero > 0 Then Alto = TxtAlto.Text.ToEntero + If TxtAncho.Text.ToEntero > 0 Then Ancho = TxtAncho.Text.ToEntero + + Try + Dim memoryStream As New System.IO.MemoryStream(GeneraCodigoQR(TxtCodigoBarrasModal.Text.Trim, Alto, Ancho, 0, DDLCodigoFormato.SelectedValue)) + Response.Clear() + Response.ContentType = "application/bmp" + Response.AddHeader("content-disposition", $"attachment;filename=code_{TxtCodigoBarrasModal.Text.Trim}.bmp") + Response.Buffer = True + memoryStream.WriteTo(Response.OutputStream) + Response.End() + + Catch ex As Exception + + End Try + End Sub + + Private Sub DDLCodigoFormato_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDLCodigoFormato.SelectedIndexChanged + LnkDescargaImagen.Enabled = False + LnkDescargaImpresion.Enabled = False + UpModalBotonesCodigos.Update() + End Sub + Private Sub LnkDescargaImpresion_Click(sender As Object, e As EventArgs) Handles LnkDescargaImpresion.Click + Dim Alto As Integer = 150 + Dim Ancho As Integer = 150 + + + If TxtAlto.Text.ToEntero > 0 Then Alto = TxtAlto.Text.ToEntero + If TxtAncho.Text.ToEntero > 0 Then Ancho = TxtAncho.Text.ToEntero + + Try + + + Dim Doc As New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10.0F, 10.0F, 100.0F, 0F) + Dim para As New iTextSharp.text.Paragraph + Dim memoryStreamDoc As New System.IO.MemoryStream + + Dim gemBox As New clsGemBoxDocument() + + gemBox.AgregarImagen(GeneraCodigoQR(TxtCodigoBarrasModal.Text.Trim, Alto, Ancho, 0, DDLCodigoFormato.SelectedValue)) + gemBox.GuardarStreamPDF() + + + + Dim memoryStream As New System.IO.MemoryStream(gemBox.GetBytesDocumento()) + gemBox.Dispose() + Response.Clear() + Response.ContentType = "application/pdf" + Response.AddHeader("content-disposition", $"attachment;filename=code_{TxtCodigoBarrasModal.Text.Trim}.pdf") + Response.Buffer = True + memoryStream.WriteTo(Response.OutputStream) + Response.End() + + Catch ex As Exception + + End Try + End Sub + + + +#End Region + +#Region "SELECTED INDEX CHANGE" + Public Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClasificacion.SelectedIndexChanged + If DdlClasificacion.SelectedValue.ToEntero > 0 Then + If Not CveSATPS > 0 Or CveSATPS = 46920 Then + Dim Dr = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue.ToEntero()))(0) + + DdlSATPS.SelectedValue = Dr("CveSATPS").ToString + DdlSATPS.SelectedText = Dr("SATClaveProductoServicio").ToString + + + + If UsuarioActual.CveEmpresa.Contiene(72, 80) Then + VerificaRequiereSerieLote() + End If + End If + ' CargaClasificacionesDetalles() + End If + + Try + Dim Dr = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("CveClasificacion={0}", DdlClasificacion.SelectedValue.ToEntero()))(0) + If Boolean.Parse(Dr("EsAcumulador").ToString) Then + MostarOcultarDivTamanio(True) + Else + MostarOcultarDivTamanio(False) + End If + 'SI ES MOTOBATERIA If DdlClasificacion.SelectedValue = "20517" Then MostarOcultarDivTamanio(True) - End If - Catch ex As Exception - - End Try - End Sub - - Sub MostarOcultarDivTamanio(Mostrar As Boolean) - - - If Mostrar And UsuarioActual.Empresa.Funcionalidad(531) = "1" Then - DvTamanio.Visible = True - Else - DvTamanio.Visible = False - DdlTamanio.SelectedValueExist("-1") - End If - - - UpDatos.Update() - - End Sub - - - Private Sub DdlTipoFactor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoFactor.SelectedIndexChanged - If DdlTipoFactor.SelectedValue.Contiene("1", "2") Then 'tasa - DdlIVA.Visible = True - LIva.Visible = True - Else - DdlIVA.SelectedValue = "0" - DdlIVA.Visible = False - LIva.Visible = False - End If - End Sub - Protected Sub DdlUsoClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) - CargaClasificaciones() - End Sub -#End Region - -#Region "FRACCION ARANCELARIA" - - Protected Sub DdlFraccionArancelaria_selectedindexchange(sender As Object, e As EventArgs) - If DdlFraccionArancelaria.SelectedValue.ToEntero > 0 Then - LblUnidadAduana.Text = GlobalDTFraccionArancelaria().FiltraParametros($"CveFraccionArancelaria = {DdlFraccionArancelaria.SelectedValue}")(0)("ClaveSATUnidadAduanaDescripcion").ToString - End If - End Sub - -#End Region - -#Region " ECOMMERCE " - Private Sub InicializaEcommerce() - AplicaEcommerce = False - - If UsuarioActual.Empresa.Funcionalidad(700).ToEntero = 1 And CvePS > 0 Then - - TabEcommerce.Visible = True - LBBitacoraEcommerce.Visible = True - - 'INICIALIZA PRODUCTOS ECOMMERCE - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.InsigniasGet(-1, "", UsuarioActual.CveEmpresa) Then - DdlEcommerceInsignia.DataSource = ObjEcommerce.DtResultados - End If - ObjEcommerce.Dispose() - DdlEcommerceInsignia.DataBind() - CargaEcommerce() - - 'INICIALIZA PRODUCTOS INSIGNIAS - CargaPSInsigniasEcommerce() - - 'INICIALIZA PRODUCTOS IMAGENES - CargarGaleriaImagenesEcommerce() - - 'INICIALIZA PRODUCTOS RELACIONADOS - DdlEcommercePSRelacionado.setEsWebService(True) - CargaPSRelacionadosEcommerce() - - UpEcommerce.Update() - - End If - End Sub - -#Region " PRODUCTOS ECOMMERCE " - Private Sub CargaEcommerce() - Dim DrEcommerce As DataRow = Nothing - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosGet(CvePS, -1, -1, -1, UsuarioActual.CveEmpresa) Then - DrEcommerce = ObjEcommerce.DtResultados.FiltroPrimero("") - End If - ObjEcommerce.Dispose() - - If DrEcommerce IsNot Nothing Then - AplicaEcommerce = True - - TxtEcommerceDescripcion.Text = DrEcommerce("Descripcion").ToString - TxtEcommercePrecioBase.Text = DrEcommerce("PrecioBase").ToString.FormatoNumero - TxtEcommercePrecioPromocion.Text = DrEcommerce("PrecioPromocion").ToString.FormatoNumero - ChkEcommerceDisponible.Checked = CBool(DrEcommerce("Disponible").ToString) - End If - GvEcommercePSRealacionados.DataBind() - UpEcommercePSRelacionados.Update() - End Sub - Private Function GuardaEcommerce() As Boolean - Dim TieneError = False - - If UsuarioActual.Empresa.Funcionalidad(700) = "1" Then - - 'SI NO SE HA GUARDADO EN ECOMMERCE Y NO TIENE NINGUN VALOR OMITE - If Not AplicaEcommerce And Not ChkEcommerceDisponible.Checked And TxtEcommerceDescripcion.Text.Length = 0 And TxtEcommercePrecioBase.Text.Length = 0 And TxtEcommercePrecioPromocion.Text.Length = 0 Then - Return False - End If - - If ChkEcommerceDisponible.Checked Then - If Not ValidaGuardarEcommerce() Then - Return True - End If - End If - - Dim Descripcion = TxtEcommerceDescripcion.Text.Trim - Dim PrecioBase = TxtEcommercePrecioBase.Text.Trim.ToDouble - Dim PrecioPromocion = TxtEcommercePrecioPromocion.Text.Trim.ToDouble - Dim Disponible = ChkEcommerceDisponible.Checked - - Dim ObjEcommerce As New ClsECommerce - If Not ObjEcommerce.ProductosAddUpdate(CvePS, Descripcion, PrecioBase, PrecioPromocion, Disponible, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - TieneError = True - End If - ObjEcommerce.Dispose() - - End If - - Return TieneError - End Function - Private Function ValidaGuardarEcommerce() As Boolean - Dim Retorno = True - Dim Mensaje As New StringBuilder - - 'DESCRIPCION - Dim Descripcion = TxtEcommerceDescripcion.Text.Trim - If Descripcion.Length = 0 Then - Mensaje.Append("- El campo Descripción es obligatorio. Por favor introduzcalo y vuelva a intentar.
") - End If - If Descripcion.Length > 255 Then - Mensaje.Append("- El campo Descripción admite maximo 255 caracteres. Por favor verifique y vuelva a intentar.
") - End If - - 'PRECIO BASE - Dim PrecioBase = TxtEcommercePrecioBase.Text.Trim.ToDouble - If PrecioBase = 0 Then - Mensaje.Append("- El campo Precio es obligatorio. Por favor verifique y vuelva a intentar.
") - End If - If PrecioBase < 0 Then - Mensaje.Append("- El campo Precio no puede ser negativo. Por favor verifique y vuelva a intentar.
") - End If - - 'PRECIO FINAL - Dim PrecioPromocion = TxtEcommercePrecioPromocion.Text.Trim.ToDouble - If PrecioPromocion < 0 Then - Mensaje.Append("- El campo Precio Final no puede ser negativo. Por favor verifique y vuelva a intentar.
") - End If - - - 'VALIDACION - If Mensaje.ToString.Length > 0 Then - Retorno = False - Alert($"Si el producto aplica para Ecommerce es necesarios los siguientes campos:
{Mensaje.ToString}", TipoMensaje.MsgAdvertencia) - End If - - Return Retorno - End Function -#End Region - -#Region " PRODUCTOS INSIGNIAS " - - Private Sub CargaPSInsigniasEcommerce() - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosInsigniasGet(CvePS, -1, UsuarioActual.CveEmpresa) Then - GvEcommercePSInsignias.DataSource = ObjEcommerce.DtResultados - Else - GvEcommercePSInsignias.DataSource = Nothing - End If - ObjEcommerce.Dispose() - - GvEcommercePSInsignias.DataBind() - UpEcommerceInsignias.Update() - End Sub - Protected Sub BtnEcommerceInsignias_Click(sender As Object, e As EventArgs) - If Not ValidaAgregarProductosInsigniasEcommerce() Then - Exit Sub - End If - - Dim TieneError = False - Dim CveInsignia = DdlEcommerceInsignia.SelectedValue.ToEntero - - 'AGREGAR - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosInsigniasAdd(Me.CvePS, CveInsignia, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("La Insignia se agregó correctamente.", TipoMensaje.MsgInformacion) - Else - TieneError = True - End If - ObjEcommerce.Dispose() - - If Not TieneError Then - DdlEcommerceInsignia.SelectedValueExist(-1) - CargaPSInsigniasEcommerce() - End If - End Sub - Private Function ValidaAgregarProductosInsigniasEcommerce() As Boolean - Dim Retorno = True - Dim Mensaje As New StringBuilder - - 'INSIGNIA - Dim CveInsignia = DdlEcommerceInsignia.SelectedValue.ToEntero - If CveInsignia = 0 Then - Mensaje.Append("- El campo Insignia es obligatorio. Por favor introduzcalo y vuelva a intentar.
") - End If - For Each GvRow As GridViewRow In GvEcommercePSInsignias.Rows - If GvRow.DataKey("CveInsignia").ToString.ToEntero = CveInsignia Then - Mensaje.Append($"- La Insignia {DdlEcommerceInsignia.SelectedItem.Text} ya es parte del producto y no se puede duplicar. Por favor verifique y vuelva a intentar.
") - Exit For - End If - Next - - 'VALIDACION - If Mensaje.ToString.Length > 0 Then - Retorno = False - Alert(Mensaje.ToString, TipoMensaje.MsgAdvertencia) - End If - - Return Retorno - End Function - Protected Sub GvEcommercePSInsignias_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvEcommercePSInsignias.RowDeleting - Dim TieneError = False - Dim GvRow = GvEcommercePSInsignias.Rows(e.RowIndex) - - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosInsigniasRemove(GvRow.DataKey("CvePS").ToString.ToEntero, GvRow.DataKey("CveInsignia").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("La Insignia se eliminó correctamente.", TipoMensaje.MsgInformacion) - Else - TieneError = True - End If - ObjEcommerce.Dispose() - - If Not TieneError Then - CargaPSInsigniasEcommerce() - End If - End Sub -#End Region - -#Region " PRODUCTOS IMAGENES " - Private Sub CargarGaleriaImagenesEcommerce() - Dim TmpDT As DataTable = Nothing - - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosImagenesGet(CvePS, UsuarioActual.CveEmpresa) Then - TmpDT = ObjEcommerce.DtResultados - Else - TmpDT = Nothing - End If - ObjEcommerce.Dispose() - - RptFotos.DataSource = TmpDT - RptFotos.DataBind() - UpEcommerceGaleriaImagenes.Update() - End Sub - Protected Sub BtnEcommerceImagenes_Click(sender As Object, e As EventArgs) - - Dim FilesGral As List(Of Archivo) = TxtEcommerceImagenes.getfiles().Archivos - Dim FileMove = "" - Dim Archivo = "" - Dim DirectorioTemporal = "" - - Dim DirectorioDestino = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\Ecommerce\Productos\Imagenes\" - If Not Directory.Exists(DirectorioDestino) Then - Directory.CreateDirectory(DirectorioDestino) - End If - - Dim ObjEcommerce As New ClsECommerce - For Each FileItem As Archivo In FilesGral - Archivo = DateTime.Now.Ticks.ToString - Try - FileMove = FileItem.filename - DirectorioTemporal = $"{AppDomain.CurrentDomain.BaseDirectory}Temp\{FileMove}" - - Archivo = $"{Archivo}{IO.Path.GetExtension(DirectorioTemporal)}" - DirectorioDestino += Archivo - If ObjEcommerce.ProductosImagenesAdd(CvePS, $"Ecommerce\Productos\Imagenes\{Archivo}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - CargarGaleriaImagenesEcommerce() - My.Computer.FileSystem.MoveFile(DirectorioTemporal, DirectorioDestino) - End If - Catch ex As Exception - End Try - Next - ObjEcommerce.Dispose() - - RegistraScript("$(""#Modalupfotos"").modal(""hide"");initcarusel();") - TxtEcommerceImagenes.Text = "[]" - UpUpFotos.Update() - - End Sub - Protected Sub BtnEcommerceEliminarImagenes_Click(sender As Object, e As System.EventArgs) - Dim CveImagenActivoFijo As Integer = 0 - CveImagenActivoFijo = Integer.Parse(DirectCast(sender, Button).CommandArgument) - - If (CveImagenActivoFijo > 0) Then - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosImagenesRemove(CveImagenActivoFijo, UsuarioActual.CveEmpresa) Then - File.Delete(String.Format("{0}Empresas\{1}\{2}", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa, ObjEcommerce.DtResultados.Rows(0)("URL"))) - CargarGaleriaImagenesEcommerce() - RegistraScript("initcarusel();") - End If - ObjEcommerce.Dispose() - End If - - End Sub -#End Region - -#Region " PRODUCTOS RELACIONADOS " - Private Sub CargaPSRelacionadosEcommerce() - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosRelacionadosGet(CvePS, UsuarioActual.CveEmpresa) Then - GvEcommercePSRealacionados.DataSource = ObjEcommerce.DtResultados - Else - GvEcommercePSRealacionados.DataSource = Nothing - End If - ObjEcommerce.Dispose() - - GvEcommercePSRealacionados.DataBind() - UpEcommercePSRelacionados.Update() - End Sub - Protected Sub BtnEcommercePSRelacionados_Click(sender As Object, e As EventArgs) - If Not ValidaAgregarProductosRelacionadosEcommerce() Then - Exit Sub - End If - - Dim TieneError = False - Dim CvePS = DdlEcommercePSRelacionado.SelectedValue.ToEntero - - 'AGREGAR - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosRelacionadosAdd(Me.CvePS, CvePS, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("La relación se agregó correctamente.", TipoMensaje.MsgInformacion) - Else - TieneError = True - End If - ObjEcommerce.Dispose() - - If Not TieneError Then - DdlEcommercePSRelacionado.SelectedValue = "-1" - DdlEcommercePSRelacionado.SelectedText = "" - CargaPSRelacionadosEcommerce() - End If - End Sub - Private Function ValidaAgregarProductosRelacionadosEcommerce() As Boolean - Dim Retorno = True - Dim Mensaje As New StringBuilder - - 'PS - Dim CvePS = DdlEcommercePSRelacionado.SelectedValue.ToEntero - If CvePS = 0 Then - Mensaje.Append("- El campo Producto es obligatorio. Por favor introduzcalo y vuelva a intentar.
") - End If - For Each GvRow As GridViewRow In GvEcommercePSRealacionados.Rows - If GvRow.DataKey("CvePS").ToString.ToEntero = CvePS Then - Mensaje.Append($"- El producto {DdlEcommercePSRelacionado.SelectedText} ya esta relacionado y no se puede duplicar. Por favor verifique y vuelva a intentar.
") - Exit For - End If - Next - - 'VALIDACION - If Mensaje.ToString.Length > 0 Then - Retorno = False - Alert(Mensaje.ToString, TipoMensaje.MsgAdvertencia) - End If - - Return Retorno - End Function - Protected Sub GvEcommercePSRealacionados_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvEcommercePSRealacionados.RowDeleting - Dim TieneError = False - Dim GvRow = GvEcommercePSRealacionados.Rows(e.RowIndex) - - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosRelacionadosRemove(GvRow.DataKey("CvePS1").ToString.ToEntero, GvRow.DataKey("CvePS2").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - Alert("La relación se eliminó correctamente.", TipoMensaje.MsgInformacion) - Else - TieneError = True - End If - ObjEcommerce.Dispose() - - If Not TieneError Then - CargaPSRelacionadosEcommerce() - End If - End Sub - -#End Region - -#Region " BITACORA " - Protected Sub LBBitacoraEcommerce_Click(sender As Object, e As EventArgs) - CargaBitacoraEcommerce() - End Sub - Private Sub CargaBitacoraEcommerce() - Dim ObjEcommerce As New ClsECommerce - If ObjEcommerce.ProductosGetBitacora(CvePS, UsuarioActual.CveEmpresa) Then - GvBitacoraEcommerce.DataSource = ObjEcommerce.DtResultados - End If - ObjEcommerce.Dispose() - - GvBitacoraEcommerce.DataBind() - UpBitacoraEcommerce.Update() - RegistraScript("$('#ModalBitacoraEcommerce').modal('show');") - End Sub - Protected Sub GvBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvBitacora.RowDataBound - If e.Row.RowType = DataControlRowType.DataRow Then - - End If - End Sub -#End Region - -#End Region - -#Region "CLASIFICACIONES DETALLES" - - Protected Sub BtnAddClasificacionDetalle_Click(sender As Object, e As EventArgs) - TxtClasificacionDetalle.Text = "" - DdlClasificacionModal.SelectedValueExist(DdlClasificacion.SelectedValue) - UpModal.Update() - RegistraScript(String.Format("$('#{0}').modal('show');", "DModalClasificacion")) - End Sub - Protected Sub BtnAddClasificacionDetalleModal_Click(sender As Object, e As EventArgs) - Dim ObjVentas As New ClsVentas - If ObjVentas.AddClasificacionDetalle(TxtClasificacionDetalle.Text, DdlClasificacionModal.SelectedValue.ToEntero, - UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then - - If ObjVentas.GetClasificacionDetalle(-1, -1, -1, -1) Then - GlobalDTClasificacionesDetalle = ObjVentas.DtResultados - End If - CargaClasificacionesDetalles() - DdlTipoPSDes.SelectedValueExist(ObjVentas.CveClasificacionDetalle) - UpDatos.Update() - RegistraScript(String.Format("$('#{0}').modal('hide');", "DModalClasificacion"), "1") - RegistraScript("CreaDescripcionPS();", "2") - - - End If - - ObjVentas.Dispose() - End Sub - -#End Region - -#Region "EXISTENCIAS" - - Protected Sub GVExistencias_RowDataBound(sender As Object, e As GridViewRowEventArgs) - If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.DBCampo("CveAlmacen") = "" Then - e.Row.CssClass = "Totales" - End If - If UsuarioActual.CveEmpresa = 119 Then - GVExistencias.Columns(5).Visible = True - End If - End If - End Sub - - Private Sub CargaExistencias() - Dim ObjInventarios As New ClsInventarios() - If ObjInventarios.GetExistenciasProducto(CvePS, -1, UsuarioActual.CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), ExcluyeApartados:=-1) Then - If ObjInventarios.DtResultados.Rows.Count > 0 Then - GVExistencias.DataSource = ObjInventarios.DtResultados - Else - GVExistencias.DataSource = Nothing - End If - End If - - ObjInventarios.Dispose() - GVExistencias.DataBind() - UpDatos.Update() - End Sub - -#End Region - - Protected Sub DdlImpTipoProducto_SelectedIndexChanged(sender As Object, e As EventArgs) - - CargaClaveGenerica(DdlImpTipoProducto.SelectedValue) - - End Sub - - Private Sub CargaClaveGenerica(TipoProducto As String) - DdlCategoriaToxicidad.Items.Clear() - DdlCategoriaToxicidad.DataBind() 'para que quite el selectedvalue - - If TipoProducto = "019" Then - DdlCategoriaToxicidad.Items.Add(New ListItem("Seleccione", "-1")) - DdlCategoriaToxicidad.Items.Add(New ListItem("000 - Sin selección", "000")) - DdlCategoriaToxicidad.Items.Add(New ListItem("001 - Categorías 1 y 2", "001")) - DdlCategoriaToxicidad.Items.Add(New ListItem("002 - Categoría 3", "002")) - DdlCategoriaToxicidad.Items.Add(New ListItem("003 - Categoría 4", "003")) - DdlCategoriaToxicidad.SelectedValue = "000" - - ElseIf TipoProducto = "021" Then - DdlCategoriaToxicidad.Items.Add(New ListItem("Seleccione", "-1")) - DdlCategoriaToxicidad.Items.Add(New ListItem("000 - Sin selección", "000")) - DdlCategoriaToxicidad.Items.Add(New ListItem("001 - Gasolina Menor a 92 octanos", "001")) - DdlCategoriaToxicidad.Items.Add(New ListItem("002 - Gasolina Mayor o igual a 92 octanos", "002")) - DdlCategoriaToxicidad.Items.Add(New ListItem("003 - Diesel", "003")) - DdlCategoriaToxicidad.Items.Add(New ListItem("004 - Combustibles no fósiles", "004")) - DdlCategoriaToxicidad.SelectedValue = "000" - End If - End Sub - -#Region "SECCION ALMACEN" - - Private Sub CreaDtSeccionAlmacen() - DtSeccionAlmacen = New DataTable - DtSeccionAlmacen.Columns.Add("CvePSAlmacenSeccion", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("CveAlmacen", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("Almacen", GetType(String)) - DtSeccionAlmacen.Columns.Add("CveAlmacenSeccion", GetType(Integer)) - DtSeccionAlmacen.Columns.Add("AlmacenSeccion", GetType(String)) - End Sub - Private Sub CargaGvSeccionAlmacen() - Dim ObjInv As New ClsInventarios - If ObjInv.GetProductosServiciosAlmacenSeccion(CvePS, -1, -1) Then - GvSeccionAlmacen.DataSource = ObjInv.DtResultados - DtSeccionAlmacen = ObjInv.DtResultados - End If - ObjInv.Dispose() - GvSeccionAlmacen.DataBind() - UpSeccionAlmacen.Update() - End Sub - - - Private Sub CargaCombosSeccionAlmacen() - DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa) - DdlAlmacen.Items.Add(New ListItem("Seleccione", "-1")) - DdlAlmacen.DataBind() - - DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) - DdlSeccionAlmacen.Items.Add(New ListItem("Seleccione", "-1")) - DdlSeccionAlmacen.DataBind() - - UpModalSeccionAlmacen.Update() - End Sub - - Protected Sub LnkSeccionAlmacenAdd_Click(sender As Object, e As EventArgs) - DdlAlmacen.SelectedIndex = 0 - DdlSeccionAlmacen.SelectedIndex = 0 - RegistraScript("$('#DivAddSeccionAlmacen').modal();") - UpModalSeccionAlmacen.Update() - End Sub - 'Protected Sub LnkEditarSeccionAlmacen_Click(sender As Object, e As EventArgs) - ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - ' DdlAlmacen.SelectedValueExist(gvRow.DataKey("CvAlmacen")) - ' DdlSeccionAlmacen.SelectedValueExist(gvRow.DataKey("CveAlmacenSeccion")) - ' RegistraScript("$('#DivAddSeccionAlmacen').modal();") - ' UpModalSeccionAlmacen.Update() - 'End Sub - Protected Sub LnkRemoveSeccionAlmacen_Click(sender As Object, e As EventArgs) - Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) - If gvRow.DataKey("CvePSAlmacenSeccion").ToEntero > 0 Then - DtSeccionAlmacen.Rows(gvRow.RowIndex)("CveAlmacen") = -1 - Else - DtSeccionAlmacen.Rows(gvRow.RowIndex.ToEntero).Delete() - End If - DtSeccionAlmacen.AcceptChanges() - GvSeccionAlmacen.DataSource = DtSeccionAlmacen - GvSeccionAlmacen.DataBind() - UpSeccionAlmacen.Update() - End Sub - - Protected Sub BtnAddSeccionAlmacen_Click(sender As Object, e As EventArgs) - If DtSeccionAlmacen.FiltraParametros($"CveAlmacen = {DdlAlmacen.SelectedValue}").Rows.Count > 0 Then - Alert("No se puede especificar el mismo almacen en dos secciones", TipoMensaje.MsgAdvertencia) - Exit Sub - End If - - Dim Row As DataRow = Nothing - Row = DtSeccionAlmacen.NewRow - Row("CvePSAlmacenSeccion") = -1 - Row("CveAlmacen") = DdlAlmacen.SelectedValue.ToEntero - Row("Almacen") = DdlAlmacen.SelectedItem.Text - Row("CveAlmacenSeccion") = DdlSeccionAlmacen.SelectedValue.ToEntero - Row("AlmacenSeccion") = DdlSeccionAlmacen.SelectedItem.Text - DtSeccionAlmacen.Rows.Add(Row) - DtSeccionAlmacen.AcceptChanges() - GvSeccionAlmacen.DataSource = DtSeccionAlmacen - GvSeccionAlmacen.DataBind() - UpSeccionAlmacen.Update() - - RegistraScript("$('#DivAddSeccionAlmacen').modal('hide');") - End Sub - - Protected Sub GvSeccionAlmacen_RowDataBound(sender As Object, e As GridViewRowEventArgs) - If e.Row.RowType = DataControlRowType.DataRow Then - If Not e.Row.DBCampo("CveAlmacen").ToEntero > 0 Then - e.Row.Visible = False - End If - End If - End Sub - -#End Region - - - Protected Sub DdlIEPSPorcentaje_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlIEPSPorcentaje.SelectedIndexChanged - Select Case DdlIEPSPorcentaje.SelectedValue - Case "0.09" - DdlCategoriaToxicidad.SelectedValueExist("001") - Case "0.07" - DdlCategoriaToxicidad.SelectedValueExist("002") - Case "0.06" - DdlCategoriaToxicidad.SelectedValueExist("003") - Case Else - DdlCategoriaToxicidad.SelectedValueExist("000") - End Select - End Sub -End Class + End If + Catch ex As Exception + + End Try + End Sub + + Sub MostarOcultarDivTamanio(Mostrar As Boolean) + + + If Mostrar And UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + DvTamanio.Visible = True + Else + DvTamanio.Visible = False + DdlTamanio.SelectedValueExist("-1") + End If + + + UpDatos.Update() + + End Sub + + + Private Sub DdlTipoFactor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoFactor.SelectedIndexChanged + If DdlTipoFactor.SelectedValue.Contiene("1", "2") Then 'tasa + DdlIVA.Visible = True + LIva.Visible = True + Else + DdlIVA.SelectedValue = "0" + DdlIVA.Visible = False + LIva.Visible = False + End If + End Sub + Protected Sub DdlUsoClasificacion_SelectedIndexChanged(sender As Object, e As EventArgs) + CargaClasificaciones() + End Sub +#End Region + +#Region "FRACCION ARANCELARIA" + + Protected Sub DdlFraccionArancelaria_selectedindexchange(sender As Object, e As EventArgs) + If DdlFraccionArancelaria.SelectedValue.ToEntero > 0 Then + LblUnidadAduana.Text = GlobalDTFraccionArancelaria().FiltraParametros($"CveFraccionArancelaria = {DdlFraccionArancelaria.SelectedValue}")(0)("ClaveSATUnidadAduanaDescripcion").ToString + End If + End Sub + +#End Region + +#Region " ECOMMERCE " + Private Sub InicializaEcommerce() + AplicaEcommerce = False + + If UsuarioActual.Empresa.Funcionalidad(700).ToEntero = 1 And CvePS > 0 Then + + TabEcommerce.Visible = True + LBBitacoraEcommerce.Visible = True + + 'INICIALIZA PRODUCTOS ECOMMERCE + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.InsigniasGet(-1, "", UsuarioActual.CveEmpresa) Then + DdlEcommerceInsignia.DataSource = ObjEcommerce.DtResultados + End If + ObjEcommerce.Dispose() + DdlEcommerceInsignia.DataBind() + CargaEcommerce() + + 'INICIALIZA PRODUCTOS INSIGNIAS + CargaPSInsigniasEcommerce() + + 'INICIALIZA PRODUCTOS IMAGENES + CargarGaleriaImagenesEcommerce() + + 'INICIALIZA PRODUCTOS RELACIONADOS + DdlEcommercePSRelacionado.setEsWebService(True) + CargaPSRelacionadosEcommerce() + + UpEcommerce.Update() + + End If + End Sub + +#Region " PRODUCTOS ECOMMERCE " + Private Sub CargaEcommerce() + Dim DrEcommerce As DataRow = Nothing + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosGet(CvePS, -1, -1, -1, UsuarioActual.CveEmpresa) Then + DrEcommerce = ObjEcommerce.DtResultados.FiltroPrimero("") + End If + ObjEcommerce.Dispose() + + If DrEcommerce IsNot Nothing Then + AplicaEcommerce = True + + TxtEcommerceDescripcion.Text = DrEcommerce("Descripcion").ToString + TxtEcommercePrecioBase.Text = DrEcommerce("PrecioBase").ToString.FormatoNumero + TxtEcommercePrecioPromocion.Text = DrEcommerce("PrecioPromocion").ToString.FormatoNumero + ChkEcommerceDisponible.Checked = CBool(DrEcommerce("Disponible").ToString) + End If + GvEcommercePSRealacionados.DataBind() + UpEcommercePSRelacionados.Update() + End Sub + Private Function GuardaEcommerce() As Boolean + Dim TieneError = False + + If UsuarioActual.Empresa.Funcionalidad(700) = "1" Then + + 'SI NO SE HA GUARDADO EN ECOMMERCE Y NO TIENE NINGUN VALOR OMITE + If Not AplicaEcommerce And Not ChkEcommerceDisponible.Checked And TxtEcommerceDescripcion.Text.Length = 0 And TxtEcommercePrecioBase.Text.Length = 0 And TxtEcommercePrecioPromocion.Text.Length = 0 Then + Return False + End If + + If ChkEcommerceDisponible.Checked Then + If Not ValidaGuardarEcommerce() Then + Return True + End If + End If + + Dim Descripcion = TxtEcommerceDescripcion.Text.Trim + Dim PrecioBase = TxtEcommercePrecioBase.Text.Trim.ToDouble + Dim PrecioPromocion = TxtEcommercePrecioPromocion.Text.Trim.ToDouble + Dim Disponible = ChkEcommerceDisponible.Checked + + Dim ObjEcommerce As New ClsECommerce + If Not ObjEcommerce.ProductosAddUpdate(CvePS, Descripcion, PrecioBase, PrecioPromocion, Disponible, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + TieneError = True + End If + ObjEcommerce.Dispose() + + End If + + Return TieneError + End Function + Private Function ValidaGuardarEcommerce() As Boolean + Dim Retorno = True + Dim Mensaje As New StringBuilder + + 'DESCRIPCION + Dim Descripcion = TxtEcommerceDescripcion.Text.Trim + If Descripcion.Length = 0 Then + Mensaje.Append("- El campo Descripción es obligatorio. Por favor introduzcalo y vuelva a intentar.
") + End If + If Descripcion.Length > 255 Then + Mensaje.Append("- El campo Descripción admite maximo 255 caracteres. Por favor verifique y vuelva a intentar.
") + End If + + 'PRECIO BASE + Dim PrecioBase = TxtEcommercePrecioBase.Text.Trim.ToDouble + If PrecioBase = 0 Then + Mensaje.Append("- El campo Precio es obligatorio. Por favor verifique y vuelva a intentar.
") + End If + If PrecioBase < 0 Then + Mensaje.Append("- El campo Precio no puede ser negativo. Por favor verifique y vuelva a intentar.
") + End If + + 'PRECIO FINAL + Dim PrecioPromocion = TxtEcommercePrecioPromocion.Text.Trim.ToDouble + If PrecioPromocion < 0 Then + Mensaje.Append("- El campo Precio Final no puede ser negativo. Por favor verifique y vuelva a intentar.
") + End If + + + 'VALIDACION + If Mensaje.ToString.Length > 0 Then + Retorno = False + Alert($"Si el producto aplica para Ecommerce es necesarios los siguientes campos:
{Mensaje.ToString}", TipoMensaje.MsgAdvertencia) + End If + + Return Retorno + End Function +#End Region + +#Region " PRODUCTOS INSIGNIAS " + + Private Sub CargaPSInsigniasEcommerce() + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosInsigniasGet(CvePS, -1, UsuarioActual.CveEmpresa) Then + GvEcommercePSInsignias.DataSource = ObjEcommerce.DtResultados + Else + GvEcommercePSInsignias.DataSource = Nothing + End If + ObjEcommerce.Dispose() + + GvEcommercePSInsignias.DataBind() + UpEcommerceInsignias.Update() + End Sub + Protected Sub BtnEcommerceInsignias_Click(sender As Object, e As EventArgs) + If Not ValidaAgregarProductosInsigniasEcommerce() Then + Exit Sub + End If + + Dim TieneError = False + Dim CveInsignia = DdlEcommerceInsignia.SelectedValue.ToEntero + + 'AGREGAR + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosInsigniasAdd(Me.CvePS, CveInsignia, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + Alert("La Insignia se agregó correctamente.", TipoMensaje.MsgInformacion) + Else + TieneError = True + End If + ObjEcommerce.Dispose() + + If Not TieneError Then + DdlEcommerceInsignia.SelectedValueExist(-1) + CargaPSInsigniasEcommerce() + End If + End Sub + Private Function ValidaAgregarProductosInsigniasEcommerce() As Boolean + Dim Retorno = True + Dim Mensaje As New StringBuilder + + 'INSIGNIA + Dim CveInsignia = DdlEcommerceInsignia.SelectedValue.ToEntero + If CveInsignia = 0 Then + Mensaje.Append("- El campo Insignia es obligatorio. Por favor introduzcalo y vuelva a intentar.
") + End If + For Each GvRow As GridViewRow In GvEcommercePSInsignias.Rows + If GvRow.DataKey("CveInsignia").ToString.ToEntero = CveInsignia Then + Mensaje.Append($"- La Insignia {DdlEcommerceInsignia.SelectedItem.Text} ya es parte del producto y no se puede duplicar. Por favor verifique y vuelva a intentar.
") + Exit For + End If + Next + + 'VALIDACION + If Mensaje.ToString.Length > 0 Then + Retorno = False + Alert(Mensaje.ToString, TipoMensaje.MsgAdvertencia) + End If + + Return Retorno + End Function + Protected Sub GvEcommercePSInsignias_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvEcommercePSInsignias.RowDeleting + Dim TieneError = False + Dim GvRow = GvEcommercePSInsignias.Rows(e.RowIndex) + + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosInsigniasRemove(GvRow.DataKey("CvePS").ToString.ToEntero, GvRow.DataKey("CveInsignia").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + Alert("La Insignia se eliminó correctamente.", TipoMensaje.MsgInformacion) + Else + TieneError = True + End If + ObjEcommerce.Dispose() + + If Not TieneError Then + CargaPSInsigniasEcommerce() + End If + End Sub +#End Region + +#Region " PRODUCTOS IMAGENES " + Private Sub CargarGaleriaImagenesEcommerce() + Dim TmpDT As DataTable = Nothing + + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosImagenesGet(CvePS, UsuarioActual.CveEmpresa) Then + TmpDT = ObjEcommerce.DtResultados + Else + TmpDT = Nothing + End If + ObjEcommerce.Dispose() + + RptFotos.DataSource = TmpDT + RptFotos.DataBind() + UpEcommerceGaleriaImagenes.Update() + End Sub + Protected Sub BtnEcommerceImagenes_Click(sender As Object, e As EventArgs) + + Dim FilesGral As List(Of Archivo) = TxtEcommerceImagenes.getfiles().Archivos + Dim FileMove = "" + Dim Archivo = "" + Dim DirectorioTemporal = "" + + Dim DirectorioDestino = $"{AppDomain.CurrentDomain.BaseDirectory}Empresas\{UsuarioActual.CveEmpresa}\Ecommerce\Productos\Imagenes\" + If Not Directory.Exists(DirectorioDestino) Then + Directory.CreateDirectory(DirectorioDestino) + End If + + Dim ObjEcommerce As New ClsECommerce + For Each FileItem As Archivo In FilesGral + Archivo = DateTime.Now.Ticks.ToString + Try + FileMove = FileItem.filename + DirectorioTemporal = $"{AppDomain.CurrentDomain.BaseDirectory}Temp\{FileMove}" + + Archivo = $"{Archivo}{IO.Path.GetExtension(DirectorioTemporal)}" + DirectorioDestino += Archivo + If ObjEcommerce.ProductosImagenesAdd(CvePS, $"Ecommerce\Productos\Imagenes\{Archivo}", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + CargarGaleriaImagenesEcommerce() + My.Computer.FileSystem.MoveFile(DirectorioTemporal, DirectorioDestino) + End If + Catch ex As Exception + End Try + Next + ObjEcommerce.Dispose() + + RegistraScript("$(""#Modalupfotos"").modal(""hide"");initcarusel();") + TxtEcommerceImagenes.Text = "[]" + UpUpFotos.Update() + + End Sub + Protected Sub BtnEcommerceEliminarImagenes_Click(sender As Object, e As System.EventArgs) + Dim CveImagenActivoFijo As Integer = 0 + CveImagenActivoFijo = Integer.Parse(DirectCast(sender, Button).CommandArgument) + + If (CveImagenActivoFijo > 0) Then + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosImagenesRemove(CveImagenActivoFijo, UsuarioActual.CveEmpresa) Then + File.Delete(String.Format("{0}Empresas\{1}\{2}", AppDomain.CurrentDomain.BaseDirectory, UsuarioActual.CveEmpresa, ObjEcommerce.DtResultados.Rows(0)("URL"))) + CargarGaleriaImagenesEcommerce() + RegistraScript("initcarusel();") + End If + ObjEcommerce.Dispose() + End If + + End Sub +#End Region + +#Region " PRODUCTOS RELACIONADOS " + Private Sub CargaPSRelacionadosEcommerce() + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosRelacionadosGet(CvePS, UsuarioActual.CveEmpresa) Then + GvEcommercePSRealacionados.DataSource = ObjEcommerce.DtResultados + Else + GvEcommercePSRealacionados.DataSource = Nothing + End If + ObjEcommerce.Dispose() + + GvEcommercePSRealacionados.DataBind() + UpEcommercePSRelacionados.Update() + End Sub + Protected Sub BtnEcommercePSRelacionados_Click(sender As Object, e As EventArgs) + If Not ValidaAgregarProductosRelacionadosEcommerce() Then + Exit Sub + End If + + Dim TieneError = False + Dim CvePS = DdlEcommercePSRelacionado.SelectedValue.ToEntero + + 'AGREGAR + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosRelacionadosAdd(Me.CvePS, CvePS, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + Alert("La relación se agregó correctamente.", TipoMensaje.MsgInformacion) + Else + TieneError = True + End If + ObjEcommerce.Dispose() + + If Not TieneError Then + DdlEcommercePSRelacionado.SelectedValue = "-1" + DdlEcommercePSRelacionado.SelectedText = "" + CargaPSRelacionadosEcommerce() + End If + End Sub + Private Function ValidaAgregarProductosRelacionadosEcommerce() As Boolean + Dim Retorno = True + Dim Mensaje As New StringBuilder + + 'PS + Dim CvePS = DdlEcommercePSRelacionado.SelectedValue.ToEntero + If CvePS = 0 Then + Mensaje.Append("- El campo Producto es obligatorio. Por favor introduzcalo y vuelva a intentar.
") + End If + For Each GvRow As GridViewRow In GvEcommercePSRealacionados.Rows + If GvRow.DataKey("CvePS").ToString.ToEntero = CvePS Then + Mensaje.Append($"- El producto {DdlEcommercePSRelacionado.SelectedText} ya esta relacionado y no se puede duplicar. Por favor verifique y vuelva a intentar.
") + Exit For + End If + Next + + 'VALIDACION + If Mensaje.ToString.Length > 0 Then + Retorno = False + Alert(Mensaje.ToString, TipoMensaje.MsgAdvertencia) + End If + + Return Retorno + End Function + Protected Sub GvEcommercePSRealacionados_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvEcommercePSRealacionados.RowDeleting + Dim TieneError = False + Dim GvRow = GvEcommercePSRealacionados.Rows(e.RowIndex) + + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosRelacionadosRemove(GvRow.DataKey("CvePS1").ToString.ToEntero, GvRow.DataKey("CvePS2").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + Alert("La relación se eliminó correctamente.", TipoMensaje.MsgInformacion) + Else + TieneError = True + End If + ObjEcommerce.Dispose() + + If Not TieneError Then + CargaPSRelacionadosEcommerce() + End If + End Sub + +#End Region + +#Region " BITACORA " + Protected Sub LBBitacoraEcommerce_Click(sender As Object, e As EventArgs) + CargaBitacoraEcommerce() + End Sub + Private Sub CargaBitacoraEcommerce() + Dim ObjEcommerce As New ClsECommerce + If ObjEcommerce.ProductosGetBitacora(CvePS, UsuarioActual.CveEmpresa) Then + GvBitacoraEcommerce.DataSource = ObjEcommerce.DtResultados + End If + ObjEcommerce.Dispose() + + GvBitacoraEcommerce.DataBind() + UpBitacoraEcommerce.Update() + RegistraScript("$('#ModalBitacoraEcommerce').modal('show');") + End Sub + Protected Sub GvBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvBitacora.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + End If + End Sub +#End Region + +#End Region + +#Region "CLASIFICACIONES DETALLES" + + Protected Sub BtnAddClasificacionDetalle_Click(sender As Object, e As EventArgs) + TxtClasificacionDetalle.Text = "" + DdlClasificacionModal.SelectedValueExist(DdlClasificacion.SelectedValue) + UpModal.Update() + RegistraScript(String.Format("$('#{0}').modal('show');", "DModalClasificacion")) + End Sub + Protected Sub BtnAddClasificacionDetalleModal_Click(sender As Object, e As EventArgs) + Dim ObjVentas As New ClsVentas + If ObjVentas.AddClasificacionDetalle(TxtClasificacionDetalle.Text, DdlClasificacionModal.SelectedValue.ToEntero, + UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then + + If ObjVentas.GetClasificacionDetalle(-1, -1, -1, -1) Then + GlobalDTClasificacionesDetalle = ObjVentas.DtResultados + End If + CargaClasificacionesDetalles() + DdlTipoPSDes.SelectedValueExist(ObjVentas.CveClasificacionDetalle) + UpDatos.Update() + RegistraScript(String.Format("$('#{0}').modal('hide');", "DModalClasificacion"), "1") + RegistraScript("CreaDescripcionPS();", "2") + + + End If + + ObjVentas.Dispose() + End Sub + +#End Region + +#Region "EXISTENCIAS" + + Protected Sub GVExistencias_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If e.Row.DBCampo("CveAlmacen") = "" Then + e.Row.CssClass = "Totales" + End If + If UsuarioActual.CveEmpresa = 119 Then + GVExistencias.Columns(5).Visible = True + End If + End If + End Sub + + Private Sub CargaExistencias() + Dim ObjInventarios As New ClsInventarios() + If ObjInventarios.GetExistenciasProducto(CvePS, -1, UsuarioActual.CveEmpresa, -1, FechaMovto:=DateTime.Today.AddDays(1).ToString("yyyy/MM/dd HH:mm"), ExcluyeApartados:=-1) Then + If ObjInventarios.DtResultados.Rows.Count > 0 Then + GVExistencias.DataSource = ObjInventarios.DtResultados + Else + GVExistencias.DataSource = Nothing + End If + End If + + ObjInventarios.Dispose() + GVExistencias.DataBind() + UpDatos.Update() + End Sub + +#End Region + + Protected Sub DdlImpTipoProducto_SelectedIndexChanged(sender As Object, e As EventArgs) + + CargaClaveGenerica(DdlImpTipoProducto.SelectedValue) + + End Sub + + Private Sub CargaClaveGenerica(TipoProducto As String) + DdlCategoriaToxicidad.Items.Clear() + DdlCategoriaToxicidad.DataBind() 'para que quite el selectedvalue + + If TipoProducto = "019" Then + DdlCategoriaToxicidad.Items.Add(New ListItem("Seleccione", "-1")) + DdlCategoriaToxicidad.Items.Add(New ListItem("000 - Sin selección", "000")) + DdlCategoriaToxicidad.Items.Add(New ListItem("001 - Categorías 1 y 2", "001")) + DdlCategoriaToxicidad.Items.Add(New ListItem("002 - Categoría 3", "002")) + DdlCategoriaToxicidad.Items.Add(New ListItem("003 - Categoría 4", "003")) + DdlCategoriaToxicidad.SelectedValue = "000" + + ElseIf TipoProducto = "021" Then + DdlCategoriaToxicidad.Items.Add(New ListItem("Seleccione", "-1")) + DdlCategoriaToxicidad.Items.Add(New ListItem("000 - Sin selección", "000")) + DdlCategoriaToxicidad.Items.Add(New ListItem("001 - Gasolina Menor a 92 octanos", "001")) + DdlCategoriaToxicidad.Items.Add(New ListItem("002 - Gasolina Mayor o igual a 92 octanos", "002")) + DdlCategoriaToxicidad.Items.Add(New ListItem("003 - Diesel", "003")) + DdlCategoriaToxicidad.Items.Add(New ListItem("004 - Combustibles no fósiles", "004")) + DdlCategoriaToxicidad.SelectedValue = "000" + End If + End Sub + +#Region "SECCION ALMACEN" + + Private Sub CreaDtSeccionAlmacen() + DtSeccionAlmacen = New DataTable + DtSeccionAlmacen.Columns.Add("CvePSAlmacenSeccion", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("CveAlmacen", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("Almacen", GetType(String)) + DtSeccionAlmacen.Columns.Add("CveAlmacenSeccion", GetType(Integer)) + DtSeccionAlmacen.Columns.Add("AlmacenSeccion", GetType(String)) + End Sub + Private Sub CargaGvSeccionAlmacen() + Dim ObjInv As New ClsInventarios + If ObjInv.GetProductosServiciosAlmacenSeccion(CvePS, -1, -1) Then + GvSeccionAlmacen.DataSource = ObjInv.DtResultados + DtSeccionAlmacen = ObjInv.DtResultados + End If + ObjInv.Dispose() + GvSeccionAlmacen.DataBind() + UpSeccionAlmacen.Update() + End Sub + + + Private Sub CargaCombosSeccionAlmacen() + DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa) + DdlAlmacen.Items.Add(New ListItem("Seleccione", "-1")) + DdlAlmacen.DataBind() + + DdlSeccionAlmacen.DataSource = GlobalDTSeccionAlmacen(UsuarioActual.CveEmpresa) + DdlSeccionAlmacen.Items.Add(New ListItem("Seleccione", "-1")) + DdlSeccionAlmacen.DataBind() + + UpModalSeccionAlmacen.Update() + End Sub + + Protected Sub LnkSeccionAlmacenAdd_Click(sender As Object, e As EventArgs) + DdlAlmacen.SelectedIndex = 0 + DdlSeccionAlmacen.SelectedIndex = 0 + RegistraScript("$('#DivAddSeccionAlmacen').modal();") + UpModalSeccionAlmacen.Update() + End Sub + 'Protected Sub LnkEditarSeccionAlmacen_Click(sender As Object, e As EventArgs) + ' Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + ' DdlAlmacen.SelectedValueExist(gvRow.DataKey("CvAlmacen")) + ' DdlSeccionAlmacen.SelectedValueExist(gvRow.DataKey("CveAlmacenSeccion")) + ' RegistraScript("$('#DivAddSeccionAlmacen').modal();") + ' UpModalSeccionAlmacen.Update() + 'End Sub + Protected Sub LnkRemoveSeccionAlmacen_Click(sender As Object, e As EventArgs) + Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) + If gvRow.DataKey("CvePSAlmacenSeccion").ToEntero > 0 Then + DtSeccionAlmacen.Rows(gvRow.RowIndex)("CveAlmacen") = -1 + Else + DtSeccionAlmacen.Rows(gvRow.RowIndex.ToEntero).Delete() + End If + DtSeccionAlmacen.AcceptChanges() + GvSeccionAlmacen.DataSource = DtSeccionAlmacen + GvSeccionAlmacen.DataBind() + UpSeccionAlmacen.Update() + End Sub + + Protected Sub BtnAddSeccionAlmacen_Click(sender As Object, e As EventArgs) + If DtSeccionAlmacen.FiltraParametros($"CveAlmacen = {DdlAlmacen.SelectedValue}").Rows.Count > 0 Then + Alert("No se puede especificar el mismo almacen en dos secciones", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + Dim Row As DataRow = Nothing + Row = DtSeccionAlmacen.NewRow + Row("CvePSAlmacenSeccion") = -1 + Row("CveAlmacen") = DdlAlmacen.SelectedValue.ToEntero + Row("Almacen") = DdlAlmacen.SelectedItem.Text + Row("CveAlmacenSeccion") = DdlSeccionAlmacen.SelectedValue.ToEntero + Row("AlmacenSeccion") = DdlSeccionAlmacen.SelectedItem.Text + DtSeccionAlmacen.Rows.Add(Row) + DtSeccionAlmacen.AcceptChanges() + GvSeccionAlmacen.DataSource = DtSeccionAlmacen + GvSeccionAlmacen.DataBind() + UpSeccionAlmacen.Update() + + RegistraScript("$('#DivAddSeccionAlmacen').modal('hide');") + End Sub + + Protected Sub GvSeccionAlmacen_RowDataBound(sender As Object, e As GridViewRowEventArgs) + If e.Row.RowType = DataControlRowType.DataRow Then + If Not e.Row.DBCampo("CveAlmacen").ToEntero > 0 Then + e.Row.Visible = False + End If + End If + End Sub + +#End Region + + + Protected Sub DdlIEPSPorcentaje_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlIEPSPorcentaje.SelectedIndexChanged + Select Case DdlIEPSPorcentaje.SelectedValue + Case "0.09" + DdlCategoriaToxicidad.SelectedValueExist("001") + Case "0.07" + DdlCategoriaToxicidad.SelectedValueExist("002") + Case "0.06" + DdlCategoriaToxicidad.SelectedValueExist("003") + Case Else + DdlCategoriaToxicidad.SelectedValueExist("000") + End Select + End Sub +End Class From 9c1ffb1927d828ce5c646373497aef781bdd3125 Mon Sep 17 00:00:00 2001 From: rrene Date: Thu, 16 Apr 2020 07:52:32 -0700 Subject: [PATCH 07/18] -PU decimal --- RH/Personal.aspx.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RH/Personal.aspx.vb b/RH/Personal.aspx.vb index 05560ccb3..6228b0e4d 100644 --- a/RH/Personal.aspx.vb +++ b/RH/Personal.aspx.vb @@ -298,11 +298,11 @@ Partial Class RH_Personal End Set End Property - Private Property PU As Double + Private Property PU As Decimal Get Return CInt(ViewState("PU")) End Get - Set(value As Double) + Set(value As Decimal) ViewState("PU") = value End Set End Property @@ -4908,7 +4908,7 @@ Partial Class RH_Personal CveAlmacenUniforme = rowInfo.Item("CveAlmacen").ToString.ToEntero DescripcionUniforme = rowInfo.Item("CodigoPS").ToString - PU = rowInfo.Item("PU").ToString.ToDouble + PU = rowInfo.Item("PU").ToString.ToDecimal CveUM = rowInfo.Item("CveUM").ToString.ToEntero CvePS = rowInfo.Item("CvePS").ToString.ToEntero From 210267e2df2143231b44999de99be2b1a4b5e5de Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Thu, 16 Apr 2020 09:22:39 -0700 Subject: [PATCH 08/18] ruta de los reportes --- App_Code/ClsPaginas.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 6adcf411e..7ebca2bba 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -4123,8 +4123,8 @@ Public Class ClsPaginas PaginaDict.Add("/CRM/RepAcercamientosEtapas.aspx".ToUpper(), 1310) PaginaDict.Add("/CRM/RepAcercamientos.aspx".ToUpper(), 1311) PaginaDict.Add("/CRM/PopUpBuscarAcercamiento.aspx".ToUpper(), 1312) - PaginaDict.Add("/CRM/RepAcercamientosProcesos.aspx".ToUpper(), -1) - PaginaDict.Add("/CRM/RepAcercamientosRechazos.aspx".ToUpper(), -1) + PaginaDict.Add("/CRM/RepAcercamientosProcesos.aspx".ToUpper(), 1313) + PaginaDict.Add("/CRM/RepAcercamientosRechazos.aspx".ToUpper(), 1314) PaginaDict.Add("/CRM/RepAcercamientosProcesosDetalle.aspx".ToUpper(), -1) PaginaDict.Add("/CRM/CatMetas.aspx".ToUpper(), 684) #End Region From 828265f5e6cfef2c761309a878a4638763685e11 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Thu, 16 Apr 2020 09:45:31 -0700 Subject: [PATCH 09/18] --- App_WebReferences/WSRDLC/Reference.svcmap | 32 +++ App_WebReferences/WSRDLC/WebService.disco | 6 + App_WebReferences/WSRDLC/WebService.wsdl | 133 ++++++++++++ .../WSRDLC/configuration.svcinfo | 10 + .../WSRDLC/configuration91.svcinfo | 201 ++++++++++++++++++ 5 files changed, 382 insertions(+) create mode 100644 App_WebReferences/WSRDLC/Reference.svcmap create mode 100644 App_WebReferences/WSRDLC/WebService.disco create mode 100644 App_WebReferences/WSRDLC/WebService.wsdl create mode 100644 App_WebReferences/WSRDLC/configuration.svcinfo create mode 100644 App_WebReferences/WSRDLC/configuration91.svcinfo diff --git a/App_WebReferences/WSRDLC/Reference.svcmap b/App_WebReferences/WSRDLC/Reference.svcmap new file mode 100644 index 000000000..7d1170ffa --- /dev/null +++ b/App_WebReferences/WSRDLC/Reference.svcmap @@ -0,0 +1,32 @@ + + + + false + true + true + + false + false + false + + + true + Auto + true + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/WSRDLC/WebService.disco b/App_WebReferences/WSRDLC/WebService.disco new file mode 100644 index 000000000..f77fceb97 --- /dev/null +++ b/App_WebReferences/WSRDLC/WebService.disco @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/App_WebReferences/WSRDLC/WebService.wsdl b/App_WebReferences/WSRDLC/WebService.wsdl new file mode 100644 index 000000000..fca24a0ef --- /dev/null +++ b/App_WebReferences/WSRDLC/WebService.wsdl @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/WSRDLC/configuration.svcinfo b/App_WebReferences/WSRDLC/configuration.svcinfo new file mode 100644 index 000000000..a293d9338 --- /dev/null +++ b/App_WebReferences/WSRDLC/configuration.svcinfo @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/App_WebReferences/WSRDLC/configuration91.svcinfo b/App_WebReferences/WSRDLC/configuration91.svcinfo new file mode 100644 index 000000000..11320f6a5 --- /dev/null +++ b/App_WebReferences/WSRDLC/configuration91.svcinfo @@ -0,0 +1,201 @@ + + + + + + + WebServiceSoap + + + + + + + + + + + + + + + + + + + + + StrongWildcard + + + + + + 65536 + + + + + + + + + System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + System.Text.UTF8Encoding + + + Buffered + + + + + + Text + + + System.ServiceModel.Configuration.BasicHttpSecurityElement + + + None + + + System.ServiceModel.Configuration.HttpTransportSecurityElement + + + None + + + None + + + System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement + + + Never + + + TransportSelected + + + (Collection) + + + + + + System.ServiceModel.Configuration.BasicHttpMessageSecurityElement + + + UserName + + + Default + + + + + + + + + http://localhost:7999/WebService.asmx + + + + + + basicHttpBinding + + + WebServiceSoap + + + WSRDLC.WebServiceSoap + + + System.ServiceModel.Configuration.AddressHeaderCollectionElement + + + <Header /> + + + System.ServiceModel.Configuration.IdentityElement + + + System.ServiceModel.Configuration.UserPrincipalNameElement + + + + + + System.ServiceModel.Configuration.ServicePrincipalNameElement + + + + + + System.ServiceModel.Configuration.DnsElement + + + + + + System.ServiceModel.Configuration.RsaElement + + + + + + System.ServiceModel.Configuration.CertificateElement + + + + + + System.ServiceModel.Configuration.CertificateReferenceElement + + + My + + + LocalMachine + + + FindBySubjectDistinguishedName + + + + + + False + + + WebServiceSoap + + + + + + + + + + + \ No newline at end of file From 7f7e47f230def5cd266e5df9a0672f74c1481fb0 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Thu, 16 Apr 2020 11:19:34 -0700 Subject: [PATCH 10/18] =?UTF-8?q?filtro=20de=20drop=20down=20en=20p=C3=A1g?= =?UTF-8?q?inas=20de=20CRM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CRM/Acercamiento.aspx.cs | 7 +- CRM/CatMediosCaptacion.aspx | 11 ++- CRM/CatMediosCaptacion.aspx.cs | 21 +++++- CRM/CatProbabilidadAcercamiento.aspx | 11 ++- CRM/CatProbabilidadAcercamiento.aspx.cs | 21 +++++- CRM/EmpresaCRM.aspx | 2 +- CRM/EmpresaCRM.aspx.cs | 52 +++++++++++++- CRM/PopUpBuscarAcercamiento.aspx | 2 +- CRM/PopUpBuscarAcercamiento.aspx.cs | 66 ++++++++++++++++++ CRM/RepAcercamientos.aspx.cs | 26 ++++--- CRM/RepAcercamientosProcesos.aspx | 3 +- CRM/RepAcercamientosProcesos.aspx.cs | 45 ++++++++++++ CRM/RepAcercamientosRechazos.aspx | 1 + CRM/RepAcercamientosRechazos.aspx.cs | 43 ++++++++++++ Contabilidad2/CatCuentas.aspx.vb | 92 +++++++++++++------------ Ventas/RepTopClientesVentas.aspx.vb | 4 +- 16 files changed, 336 insertions(+), 71 deletions(-) diff --git a/CRM/Acercamiento.aspx.cs b/CRM/Acercamiento.aspx.cs index 3b8469ae4..9bd14d662 100644 --- a/CRM/Acercamiento.aspx.cs +++ b/CRM/Acercamiento.aspx.cs @@ -366,6 +366,7 @@ public partial class CRM_Acercamiento : ClsPaginas } CargaImagenes(); + CargaDdl(); UpEncabezado.Update(); UPAcercamiento.Update(); @@ -398,8 +399,6 @@ public partial class CRM_Acercamiento : ClsPaginas RecuperaCve(); TxtFechaApertura.Text = DateTime.Now.ToShortDateString(); - - CargaDdl(); } protected void RecuperaCve() @@ -420,7 +419,7 @@ public partial class CRM_Acercamiento : ClsPaginas if (ObjCRM.GetProbabilidadAcercamiento(UsuarioActual.CveEmpresa, 1)) { - DdlProbabilidadAcercamiento.DataSource = ObjCRM.DtResultados; + DdlProbabilidadAcercamiento.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}", CveTipoProceso)); } if (ObjCRM.GetEmpresasCRM(UsuarioActual.CveEmpresa)) { @@ -434,7 +433,7 @@ public partial class CRM_Acercamiento : ClsPaginas //} if (ObjCRM.GetMedioCaptacion(UsuarioActual.CveEmpresa, 1)) { - DdlMedioCaptacion.DataSource = ObjCRM.DtResultados; + DdlMedioCaptacion.DataSource = ObjCRM.DtResultados.FiltraParametros(String.Format("CveTipoProceso = {0}",CveTipoProceso)); DdlMedioCaptacion.Items.Insert(0, new ListItem("Seleccione ", "-1")); } diff --git a/CRM/CatMediosCaptacion.aspx b/CRM/CatMediosCaptacion.aspx index 40fd45942..60d82a951 100644 --- a/CRM/CatMediosCaptacion.aspx +++ b/CRM/CatMediosCaptacion.aspx @@ -27,7 +27,7 @@ " style="display: inline-block; margin-right: -20px; width: 150px;" /> " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> - @@ -52,6 +52,11 @@ + + + + + @@ -87,6 +92,10 @@ +
+
+ +
- @@ -53,6 +53,11 @@
+ + + + + @@ -88,6 +93,10 @@ +
+
+ +