From 8cf0ce7cd76b15f9c099ac37f31bd2f1a46a60d1 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Mon, 9 Oct 2023 19:14:53 -0700 Subject: [PATCH] Promociones carga desde plantilla, ProductosServicios Ecomerce Etiquetas --- App_Code/ClsProductosServicios.vb | 6 +- Ventas/ProductosServicios.aspx | 14 +- Ventas/ProductosServicios.aspx.vb | 5 +- Ventas/Promociones.aspx | 40 +++++ Ventas/Promociones.aspx.vb | 280 +++++++++++++++++++++++++++++- 5 files changed, 337 insertions(+), 8 deletions(-) diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index d825969e1..bdd504361 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -412,7 +412,7 @@ Public Class ClsProductosServicios Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False, Optional TiempoCaducidad As Integer = -1, Optional CvePSAdicionalVigencia As Integer = -1, Optional PrecioLibre As Boolean = False, Optional CveMaterialPeligroso As Integer = -1, Optional CveEmbalaje As Integer = -1, Optional PesoKg As Decimal = -1, Optional Dimensiones As String = "", Optional CveObjetoImpuesto As Integer = 0, Optional RegistroRSCO As String = "-1", Optional FechaVigenciaRSCO As Date = MinFecha, Optional VigenciaIndeterminadaRSCO As Boolean = False, Optional CveTipoEmpacado As Integer = -1, Optional CveTipoOrganico As Integer = -1, - Optional NombreComercial As String = "", Optional NotasAdicionales As String = "") As Integer + Optional NombreComercial As String = "", Optional NotasAdicionales As String = "", Optional EcommerceEtiquetas As String = "") As Integer Dim Retorno As Integer = -1 DataAdapter("PA_ProductosServiciosAdd") @@ -512,6 +512,7 @@ Public Class ClsProductosServicios .Add("@CveTipoOrganico", SqlDbType.Int).Value = CveTipoOrganico .Add("@NombreComercial", SqlDbType.VarChar).Value = NombreComercial .Add("@NotasAdicionales", SqlDbType.VarChar).Value = NotasAdicionales + .Add("@EcommerceEtiquetas", SqlDbType.VarChar).Value = EcommerceEtiquetas End With @@ -647,7 +648,7 @@ Public Class ClsProductosServicios Optional AplicaSerie As Boolean = False, Optional AplicaLote As Boolean = False, Optional AplicaCaducidad As Boolean = False, Optional AplicaSeccion As Boolean = False, Optional TiempoCaducidad As Integer = -1, Optional CvePSAdicionalVigencia As Integer = -1, Optional PrecioLibre As Boolean = False, Optional CveMaterialPeligroso As Integer = -1, Optional CveEmbalaje As Integer = -1, Optional PesoKg As Decimal = -1, Optional Dimensiones As String = "", Optional CveObjetoImpuesto As Integer = 0, Optional RegistroRSCO As String = "-1", Optional FechaVigenciaRSCO As Date = MinFecha, Optional VigenciaIndeterminadaRSCO As Boolean = False, Optional CveTipoEmpacado As Integer = -1, Optional CveTipoOrganico As Integer = -1, - Optional NombreComercial As String = "", Optional NotasAdicionales As String = "") As Boolean + Optional NombreComercial As String = "", Optional NotasAdicionales As String = "", Optional EcommerceEtiquetas As String = "-") As Boolean Dim Retorno As Boolean = False @@ -746,6 +747,7 @@ Public Class ClsProductosServicios .Add("@CveTipoOrganico", SqlDbType.Int).Value = CveTipoOrganico .Add("@NombreComercial", SqlDbType.VarChar).Value = NombreComercial .Add("@NotasAdicionales", SqlDbType.VarChar).Value = NotasAdicionales + .Add("@EcommerceEtiquetas", SqlDbType.VarChar).Value = EcommerceEtiquetas End With diff --git a/Ventas/ProductosServicios.aspx b/Ventas/ProductosServicios.aspx index 8622c226a..091b4269b 100644 --- a/Ventas/ProductosServicios.aspx +++ b/Ventas/ProductosServicios.aspx @@ -547,17 +547,27 @@
- +
+
- +
+ + +
+ + + + +
+
diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb index f2a6db7ac..2ac66a252 100644 --- a/Ventas/ProductosServicios.aspx.vb +++ b/Ventas/ProductosServicios.aspx.vb @@ -974,6 +974,7 @@ Partial Class ProductosyServicios DdlTipoOrganico.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveTipoOrganico").ToString) TxtNombreComercial.Text = ObjProductosServicios.DtResultados.Rows(0)("NombreComercial").ToString TxtEcommerceNota.Text = ObjProductosServicios.DtResultados.Rows(0)("NotasAdicionales").ToString + TxtEcommerceEtiquetas.Text = ObjProductosServicios.DtResultados.Rows(0)("EcommerceEtiquetas").ToString Try DdlClasificacion_SelectedIndexChanged(DdlClasificacion, Nothing) @@ -1460,7 +1461,7 @@ Partial Class ProductosyServicios CvePSAdicionalVigencia:=DdlPSAdicionalVigencia.SelectedValue.ToEntero(), PrecioLibre:=ChkPrecioLibre.Checked, CveMaterialPeligroso:=DdlMaterialPeligroso.SelectedValue.ToEntero, CveEmbalaje:=DdlEmbalaje.SelectedValue.ToEntero, PesoKg:=TxtPesoKg.Text.ToDecimal, Dimensiones:=TxtDimensiones.Text.Trim, CveObjetoImpuesto:=DdlObjetoImpuesto.SelectedValue.ToEntero, Litraje:=TxtLitraje.Text.ToDecimal, RegistroRSCO:=TxtRegistroRSCO.Text, FechaVigenciaRSCO:=TxtFechaVigenciaRSCO.Text.ToDate, VigenciaIndeterminadaRSCO:=ChkFechaIndeterminadaRSCO.Checked, - NombreComercial:=TxtNombreComercial.Text.Trim, NotasAdicionales:=TxtEcommerceNota.Text.Trim) > 0 Then + NombreComercial:=TxtNombreComercial.Text.Trim, NotasAdicionales:=TxtEcommerceNota.Text.Trim, EcommerceEtiquetas:=TxtEcommerceEtiquetas.Text.Trim) > 0 Then ViewState("CvePS") = ObjProductosServicios.CvePS For Each GVR As GridViewRow In GvImpuestosLocales.Rows If GVR.FCCheckBox("ChkDeduccion").Checked Then @@ -1532,7 +1533,7 @@ Partial Class ProductosyServicios CveMaterialPeligroso:=DdlMaterialPeligroso.SelectedValue.ToEntero, CveEmbalaje:=DdlEmbalaje.SelectedValue.ToEntero, PesoKg:=TxtPesoKg.Text.ToDecimal, Dimensiones:=TxtDimensiones.Text.Trim, CveObjetoImpuesto:=DdlObjetoImpuesto.SelectedValue.ToEntero, Litraje:=TxtLitraje.Text.ToDecimal, RegistroRSCO:=TxtRegistroRSCO.Text, FechaVigenciaRSCO:=TxtFechaVigenciaRSCO.Text.ToDate, VigenciaIndeterminadaRSCO:=ChkFechaIndeterminadaRSCO.Checked, - NombreComercial:=TxtNombreComercial.Text.Trim, NotasAdicionales:=TxtEcommerceNota.Text.Trim) Then + NombreComercial:=TxtNombreComercial.Text.Trim, NotasAdicionales:=TxtEcommerceNota.Text.Trim, EcommerceEtiquetas:=TxtEcommerceEtiquetas.Text.Trim) Then If Not ObjProductosServicios.LimpiaImpuestosLocales(CvePS) Then TieneError = True diff --git a/Ventas/Promociones.aspx b/Ventas/Promociones.aspx index df074117d..8b0feaaa9 100644 --- a/Ventas/Promociones.aspx +++ b/Ventas/Promociones.aspx @@ -8,6 +8,9 @@
  • Generar a partir de
  • +
  • + Agregar Productos desde platilla +
  • @@ -439,6 +442,43 @@ + + diff --git a/Ventas/Promociones.aspx.vb b/Ventas/Promociones.aspx.vb index dc3bda72b..98f1eb50e 100644 --- a/Ventas/Promociones.aspx.vb +++ b/Ventas/Promociones.aspx.vb @@ -2,8 +2,10 @@ Option Strict On Imports System.Data +Imports DocumentFormat.OpenXml.Drawing.Diagrams Imports Extensiones - +Imports iText.StyledXmlParser.Css.Resolve.Shorthand.Impl +Imports Microsoft.Owin.Security.Provider Partial Class Ventas_Promociones Inherits ClsPaginas @@ -73,19 +75,22 @@ Partial Class Ventas_Promociones Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then + CvePromocion = -1 CargaValoresIniciales() CargaMonedas() + If Request("CvePromocion") IsNot Nothing AndAlso Request("CvePromocion").ToString.ToEntero > 0 Then + CvePromocion = Request("CvePromocion").ToString.ToEntero CargaDatos() + LnkAgrgarPlantillaPS.Visible = False Else ChkEstatus.Enabled = True ChkEstatus.Checked = True CreaDT() End If - CargaGvBitacora() End If @@ -917,4 +922,275 @@ Partial Class Ventas_Promociones End If End Sub + + Protected Sub LnkAgrgarPlantillaPS_Click(sender As Object, e As EventArgs) + TxtExcel.Text = "[]" + UpAgregarPlantilla.Update() + RegistraScript("$('#DivAgregarPlantilla').modal('show');") + End Sub + + Protected Sub LnkDecargaPlatilla_Click(sender As Object, e As EventArgs) + + Dim rutaArchivoPlantilla As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\CargaPromociones.xlsx" + + Dim nombreArchivo As String = "CargaPromociones.xlsx" + + ' Configurar la respuesta HTTP + Response.Clear() + Response.ContentType = "application/octet-stream" + Response.AppendHeader("Content-Disposition", "attachment; filename=" & nombreArchivo) + + Dim contenido As Byte() = System.IO.File.ReadAllBytes(rutaArchivoPlantilla) + Response.BinaryWrite(contenido) + + + Response.Flush() + Response.End() + + End Sub + + + + Protected Sub BrnAgregarPlantilla_Click(sender As Object, e As EventArgs) + + If TxtExcel.getfiles().Archivos.Count > 0 Then + Dim file As Archivo = TxtExcel.getfiles().Archivos(0) + Dim Directorio As String = Server.MapPath("~") & file.path + Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV") + + CargarArchivo(Directorio, file.filename, Tipo) + Else + Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError) + End If + + End Sub + + Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String) + + TempDT.Clear() + + CveConsecutivo = TempDT.Rows.Count + 1 + + Dim ProcesoOK As Boolean = False + Dim DTPlantilla As New DataTable + Dim ErrorArchivo = False + Dim ErrorExcel = False + DTPlantilla = ReadExcelFile(Ruta + FileName, True) + 'Alert(DT.Rows.Count.ToString) + + If DTPlantilla.Rows.Count = 0 Then + Alert("No encontraron registros.") + Exit Sub + End If + + If Not ValidaDTPlantilla(DTPlantilla) Then + Exit Sub + End If + + For Each dRowTemplate As DataRow In DTPlantilla.Rows + + 'Clasificacion Codigo TipoPromocion Promocion CantidadMinima Rin IncluyeImpuestos + + Dim CveClasificacion As Integer = dRowTemplate("CveClasificacion").ToString.ToEntero + Dim CvePS As Integer = dRowTemplate("CvePS").ToString.ToEntero + Dim CveTipoPromosicion As Integer = dRowTemplate("CveTipoPromosicion").ToString.ToEntero + Dim Promocion As Decimal = dRowTemplate("Promocion").ToString.ToDecimal + Dim CantidadMinima As Decimal = dRowTemplate("CantidadMinima").ToString.ToDecimal + Dim CveRin As Integer = dRowTemplate("CveRin").ToString.ToEntero + Dim IncluyeImpuestos As Boolean = Boolean.Parse(dRowTemplate("IncluyeImpuestos").ToString) + + + Dim Dr As DataRow = TempDT.NewRow + Dr = TempDT.NewRow + Dr("Estatus") = 0 + + If CveClasificacion > 0 Then + Dr("CveClasificacion") = CveClasificacion + Dr("Clasificacion") = dRowTemplate("Clasificacion").ToString + Dr("CvePS") = -1 + Else + Dr("CveClasificacion") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("CveClasificacion") + Dr("Clasificacion") = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePS).FiltroPrimeroValor("Clasificacion") + Dr("CvePS") = CvePS + End If + + + Dr("CodigoPS") = dRowTemplate("CodigoPS").ToString + Dr("PUAnterior") = 0 + + Dr("CveTipoPromocion") = CveTipoPromosicion + Dr("TipoPromocion") = dRowTemplate("TipoPromocion").ToString + Dr("Promocion") = Promocion + + Dr("PUPromocion") = 0 + + Dr("CantidadMinima") = CantidadMinima + + Dr("AplicaRestriccionTexto") = "No" + Dr("AplicaRestriccion") = False + Dr("HoraInicio") = MinFecha.ToDateTime + Dr("HoraFin") = MaxFecha.ToDateTime + Dr("AplicaLunes") = False + Dr("AplicaMartes") = False + Dr("AplicaMiercoles") = False + Dr("AplicaJueves") = False + Dr("AplicaViernes") = False + Dr("AplicaSabado") = False + Dr("AplicaDomingo") = False + + Dr("IncluyeImpuestos") = IncluyeImpuestos + + If UsuarioActual.Empresa.Funcionalidad(558) = "1" Then + Dr("CveRinTamaño") = CveRin + Dr("RinTamaño") = dRowTemplate("RinTamaño").ToString + Else + Dr("CveRinTamaño") = -1 + End If + + TempDT.Rows.Add(Dr) + + Next + + + + CargaGrid() + RegistraScript("$('#DivAgregarPlantilla').modal('hide')") + + + + End Sub + + Private Function ValidaDTPlantilla(ByRef DTPlantilla As DataTable) As Boolean + + Dim Errores As New StringBuilder + + + DTPlantilla.Columns.Add("CveClasificacion", GetType(Integer)) + DTPlantilla.Columns.Add("CvePS", GetType(Integer)) + DTPlantilla.Columns.Add("CveTipoPromosicion", GetType(Integer)) + 'DTPlantilla.Columns.Add("Promocion", GetType(Decimal)) + 'DTPlantilla.Columns.Add("CantidadMinima", GetType(Decimal)) + DTPlantilla.Columns.Add("CveRin", GetType(Integer)) + 'DTPlantilla.Columns.Add("IncluyeImpuestos", GetType(Boolean)) + DTPlantilla.Columns.Add("CodigoPS", GetType(String)) + DTPlantilla.Columns.Add("RinTamaño", GetType(String)) + + + Dim DTPS As DataTable = New DataTable + Dim DTRines As DataTable = New DataTable + Dim ObjPS As New ClsProductosServicios + If ObjPS.GetPS(-1, -1, UsuarioActual.CveEmpresa) Then + DTPS = ObjPS.DtResultados + End If + ObjPS.Dispose() + + + Dim ObjGral As New ClsGenerales + If ObjGral.GetRimTamanios(UsuarioActual.CveEmpresa) Then + DTRines = ObjGral.DtResultados + End If + ObjGral.Dispose() + + + Dim RegistroActual As Integer = 1 + For Each dRow As DataRow In DTPlantilla.Rows + + Dim SBErrorRegistro As New StringBuilder + + Dim ClasificacionStr, CodigoStr, TipoPromocionStr, PromocionStr, CantidadMinimaStr, RinStr, IncluyeImpuestosStr As String + + + + ClasificacionStr = dRow("Clasificacion").ToString.Trim + CodigoStr = dRow("Codigo").ToString.Trim + TipoPromocionStr = dRow("TipoPromocion").ToString.Trim + PromocionStr = dRow("Promocion").ToString.Trim + CantidadMinimaStr = dRow("CantidadMinima").ToString.Trim + RinStr = dRow("Rin").ToString.Trim + IncluyeImpuestosStr = dRow("IncluyeImpuestos").ToString.Trim + + If ClasificacionStr.Length > 0 Or CodigoStr.Length > 0 Then + + Dim CveClasificacion As Integer = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", $"Clasificacion = '{ClasificacionStr}'").ToString().ToEntero() + Dim CvePS As Integer = DTPS.FiltroPrimeroValor("CvePS", $"Codigo = '{CodigoStr}'").ToString().ToEntero() + Dim CodigoPS As String = DTPS.FiltroPrimeroValor("PSCodigo", $"Codigo = '{CodigoStr}'").ToString() + Dim CveTipoPromosicion As Integer = -1 + Dim Promocion As Decimal = PromocionStr.ToDecimal + Dim CantidadMinima As Decimal = CantidadMinimaStr.ToDecimal + Dim CveRin As Integer = DTRines.FiltroPrimeroValor("CveRinTamaño", $"Codigo = '{RinStr}'").ToString().ToEntero() + Dim RinTamaño As String = DTRines.FiltroPrimeroValor("RinTamaño", $"Codigo = '{RinStr}'").ToString() + Dim IncluyeImpuestos As Boolean = If(IncluyeImpuestosStr.ToUpper.Contiene("´SÍ", "SI", "1"), True, False) + + ' SBErrorRegistro.Append($"") + If ClasificacionStr.Length > 0 And CodigoStr.Length > 0 Then + SBErrorRegistro.Append($"No se puede agregar Clasificación y codigo en un mismo registro. ") + Else + + If ClasificacionStr.Length > 0 Then + SBErrorRegistro.Append(If(CveClasificacion > 0, "", $"No se encontro Clasificación {ClasificacionStr}. ")) + Else + SBErrorRegistro.Append(If(CvePS > 0, "", $"No se encontro codigo de Producto/Servicio {CodigoStr }. ")) + End If + + End If + + If TipoPromocionStr.ToUpper = "IMPORTE $" Then + CveTipoPromosicion = 1 + ElseIf TipoPromocionStr.ToUpper = "DESCUENTO %" Then + CveTipoPromosicion = 2 + ElseIf TipoPromocionStr.ToUpper = "CANTIDAD" Then + CveTipoPromosicion = 3 + Else + SBErrorRegistro.Append($"Tipo Promosion no encontrada {TipoPromocionStr}. ") + End If + + If Not Promocion > 0 Then + SBErrorRegistro.Append($"La Promoción debe de ser mayor a 0. ") + End If + + If Not CantidadMinima > 0 Then + SBErrorRegistro.Append($"La Cantidad Minima debe de ser mayor a 0. ") + End If + + If RinStr.Length > 0 And Not CveRin > 0 Then + SBErrorRegistro.Append($"Tamaño de Rin no encontrado {RinStr}. ") + End If + + If Not IncluyeImpuestosStr.ToUpper.Contiene("´SÍ", "SI", "1", "NO", "0") Then + SBErrorRegistro.Append($"Campo IncluyeImpuestos no valido {IncluyeImpuestos}.
    ") + End If + + If SBErrorRegistro.ToString.Length > 0 Then + Errores.AppendLine($"Registro {RegistroActual}, {SBErrorRegistro.ToString}") + Else + dRow("CveClasificacion") = CveClasificacion + dRow("CvePS") = CvePS + dRow("CveTipoPromosicion") = CveTipoPromosicion + dRow("Promocion") = Promocion + dRow("CantidadMinima") = CantidadMinima + dRow("RinTamaño") = RinTamaño + dRow("CveRin") = CveRin + dRow("IncluyeImpuestos") = IncluyeImpuestos + dRow("CodigoPS") = If(CveClasificacion > 0, "Todos", CodigoPS) + End If + + RegistroActual = RegistroActual + 1 + + End If + + Next + + + If Errores.ToString.Length = 0 Then + DTPlantilla.AcceptChanges() + Return True + Else + Alert(Errores.ToString, TipoMensaje.MsgAdvertencia) + Return False + End If + + + + + End Function End Class \ No newline at end of file