Promociones Franquicias

This commit is contained in:
Oscar Irigoyen
2022-10-27 15:45:50 -07:00
parent a7ebad2bfc
commit 854460fce6
7 changed files with 392 additions and 157 deletions

View File

@@ -221,9 +221,15 @@ Public Class ClsOIEventos
End Sub End Sub
#End Region #End Region
Public Sub IniciaTransacSQL() 'Public Sub IniciaTransacSQL()
SqlTransacc = SqlConexion.BeginTransaction() ' SqlTransacc = SqlConexion.BeginTransaction()
End Sub
'End Sub
Public Function IniciaTransacSQL() As SqlTransaction
If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction()
Return SqlTransacc
End Function
Public Sub RollBack() Public Sub RollBack()
SqlTransacc.Rollback() SqlTransacc.Rollback()
End Sub End Sub

View File

@@ -2151,7 +2151,7 @@ Public Class ClsVentas
End Function End Function
Public Function AddPromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, Public Function AddPromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean,
CveMoneda As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer, TipoAplicacion As String, CveMoneda As Integer, CveUsuario As Integer, CveEmpresa As Integer, CveSubProyecto As Integer, TipoAplicacion As String,
Optional CveMarca As Integer = -1, Optional EsDistribuidor As Integer = -1) As Integer Optional CveMarca As Integer = -1, Optional EsDistribuidor As Integer = -1, Optional CvePromocionPadre As Integer = -1) As Integer
Dim Retorno = -1 Dim Retorno = -1
DataAdapter("PA_Vta_PromocionesAdd") DataAdapter("PA_Vta_PromocionesAdd")
@@ -2169,6 +2169,7 @@ Public Class ClsVentas
.Add("@TipoAplicacion", SqlDbType.VarChar).Value = TipoAplicacion .Add("@TipoAplicacion", SqlDbType.VarChar).Value = TipoAplicacion
.Add("@CveMarca", SqlDbType.Int).Value = CveMarca .Add("@CveMarca", SqlDbType.Int).Value = CveMarca
.Add("@EsDistribuidor", SqlDbType.Int).Value = EsDistribuidor .Add("@EsDistribuidor", SqlDbType.Int).Value = EsDistribuidor
.Add("@CvePromocionPadre", SqlDbType.Int).Value = CvePromocionPadre
.Add("@CvePromocion", SqlDbType.Int).Direction = ParameterDirection.Output .Add("@CvePromocion", SqlDbType.Int).Direction = ParameterDirection.Output
End With End With
@@ -2181,6 +2182,30 @@ Public Class ClsVentas
Return Retorno Return Retorno
End Function End Function
Public Function AddPromociones(CvePromocion As Integer, CveUsuario As Integer, CveEmpresa As Integer, Actualizar As Boolean) As Integer
Dim Retorno = -1
DataAdapter("PA_Vta_PromocionesAddClonar")
With SqlAdapter.SelectCommand.Parameters
.Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion
.Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@Actualizar", SqlDbType.Bit).Value = Actualizar
End With
Try
SqlAdapter.Fill(Data)
Retorno = SqlAdapter.SelectCommand.Parameters("@CvePromocion").Value.ToString.ToEntero
Catch ex As Exception
OnError("Ocurrió un error al agregar la Promoción.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
Public Function UpdatePromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean, Public Function UpdatePromociones(Promocion As String, FechaInicio As Date, FechaFin As Date, CveVendedor As Integer, CveCliente As Integer, Estatus As Boolean,
CveMoneda As Integer, CveUsuario As Integer, CvePromocion As Integer, CveSubProyecto As Integer, TipoAplicacion As Integer, CveEmpresa As Integer, Optional CveMarca As Integer = -1, Optional EsDistribuidor As Integer = -1) As Boolean CveMoneda As Integer, CveUsuario As Integer, CvePromocion As Integer, CveSubProyecto As Integer, TipoAplicacion As Integer, CveEmpresa As Integer, Optional CveMarca As Integer = -1, Optional EsDistribuidor As Integer = -1) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
@@ -2278,7 +2303,7 @@ Public Class ClsVentas
Public Function AddPromocionesDetalle(CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double, Public Function AddPromocionesDetalle(CvePromocion As Integer, CvePS As Integer, TipoPromocion As Integer, Promocion As Double, PUAnterior As Double, PUPromocion As Double,
AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean, AplicaRestriccion As Boolean, AplicaLunes As Boolean, AplicaMartes As Boolean, AplicaMiercoles As Boolean, AplicaJueves As Boolean,
AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime, Optional CantidadMinima As Integer = 1, AplicaViernes As Boolean, AplicaSabado As Boolean, AplicaDomingo As Boolean, HoraInicio As DateTime, HoraFin As DateTime, Optional CantidadMinima As Integer = 1,
Optional CveClasificacion As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional IncluyeImpuestos As Boolean = False) As Boolean Optional CveClasificacion As Integer = -1, Optional CveRinTamaño As Integer = -1, Optional IncluyeImpuestos As Boolean = False, Optional Opcion As Integer = 1) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
DataAdapter("PA_Vta_PromocionesDetalleAdd") DataAdapter("PA_Vta_PromocionesDetalleAdd")
@@ -2304,6 +2329,7 @@ Public Class ClsVentas
.Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion .Add("@CveClasificacion", SqlDbType.Int).Value = CveClasificacion
.Add("@CveRinTamaño", SqlDbType.Int).Value = CveRinTamaño .Add("@CveRinTamaño", SqlDbType.Int).Value = CveRinTamaño
.Add("@IncluyeImpuestos", SqlDbType.Bit).Value = IncluyeImpuestos .Add("@IncluyeImpuestos", SqlDbType.Bit).Value = IncluyeImpuestos
.Add("@Opcion", SqlDbType.Int).Value = Opcion
End With End With
Try Try
@@ -2357,12 +2383,39 @@ Public Class ClsVentas
Return Retorno Return Retorno
End Function End Function
Public Function RemovePromocionesDetalle(CvePromocionDetalle As Integer) As Boolean Public Function SincronizarPromocionesClonar(CvePromocion As Integer, CveUsuario As Integer, CveEmpresa As Integer, Opcion As Integer) As Boolean
'Opcion 1 replicar insert
'Opcion 2 replicar actualización
Dim Retorno As Boolean = False
DataAdapter("PA_Vta_PromocionesClonar")
With SqlAdapter.SelectCommand.Parameters
.Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion
.Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@Opcion", SqlDbType.Int).Value = Opcion
End With
Try
SqlAdapter.Fill(Data)
Retorno = True
Catch ex As Exception
OnError($"Ocurrió un error al actualizar las franquicias.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try
Return Retorno
End Function
Public Function RemovePromocionesDetalle(CvePromocionDetalle As Integer, Optional Opcion As Integer = 1, Optional CvePromocion As Integer = -1) As Boolean
Dim Retorno As Boolean = False Dim Retorno As Boolean = False
DataAdapter("PA_Vta_PromocionesDetalleRemove") DataAdapter("PA_Vta_PromocionesDetalleRemove")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters
.Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle .Add("@CvePromocionDetalle", SqlDbType.Int).Value = CvePromocionDetalle
.Add("@CvePromocion", SqlDbType.Int).Value = CvePromocion
.Add("@Opcion", SqlDbType.Int).Value = Opcion
End With End With
Try Try
@@ -2374,6 +2427,7 @@ Public Class ClsVentas
Return Retorno Return Retorno
End Function End Function
#End Region #End Region
#Region "Pruebas" #Region "Pruebas"

View File

@@ -101,98 +101,138 @@ Public Class CargaEventos : Implements IHttpHandler, IRequiresSessionState
Try Try
For Each dr As DataRow In ObjEventos.DtResultados.Rows For Each dr As DataRow In ObjEventos.DtResultados.Rows
Dim cevent As CalendarEvent = New CalendarEvent()
cevent.id = dr("CveEvento").ToString.ToEntero
cevent.title = dr("Asunto").ToString
cevent.description = dr("Descripcion").ToString
cevent.start = String.Format("{0:s}", dr("FechaInicio").ToString.ToDateTime)
cevent.end = String.Format("{0:s}", dr("FechaFin").ToString.ToDateTime)
cevent.allDay = False
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
cevent.backgroundColor = dr("BackGroundColor").ToString
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
cevent.diassemana = dr("DiasSemana").ToString
cevent.dia = dr("Dia").ToString.ToEntero
cevent.mes = dr("Mes").ToString.ToEntero
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
cevent.Prospecto = dr("Prospecto").ToString
cevent.CveTipoEvento = dr("Prospecto").ToString.ToEntero
cevent.EmpresaCRM = dr("EmpresaCRM").ToString
cevent.SubProyecto = dr("SubProyecto").ToString
cevent.CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero
cevent.Direccion = dr("Direccion").ToString
'11/05/2018 - Evento Gasto Recurrente If dr("CveEventoEstatus").ToString.ToEntero <> 5 Then
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
If cevent.CveTipoEvento = 10 Then
cevent.Importe = dr("Importe").ToString.ToDouble
End If
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then Dim cevent As CalendarEvent = New CalendarEvent()
cevent.backgroundColor = "#1BBC9B" cevent.id = dr("CveEvento").ToString.ToEntero
End If cevent.title = dr("Asunto").ToString
cevent.description = dr("Descripcion").ToString
cevent.start = String.Format("{0:s}", dr("FechaInicio").ToString.ToDateTime)
cevent.end = String.Format("{0:s}", dr("FechaFin").ToString.ToDateTime)
cevent.allDay = False
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
cevent.backgroundColor = dr("BackGroundColor").ToString
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
cevent.diassemana = dr("DiasSemana").ToString
cevent.dia = dr("Dia").ToString.ToEntero
cevent.mes = dr("Mes").ToString.ToEntero
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
cevent.Prospecto = dr("Prospecto").ToString
cevent.CveTipoEvento = dr("Prospecto").ToString.ToEntero
cevent.EmpresaCRM = dr("EmpresaCRM").ToString
cevent.SubProyecto = dr("SubProyecto").ToString
cevent.CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero
cevent.Direccion = dr("Direccion").ToString
'VERIFICAMOS SI TIENE O NO RECURRENCIA '11/05/2018 - Evento Gasto Recurrente
If Not cevent.recurrenciatipo > 0 Then cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
If cevent.CveTipoEvento = 10 Then
'AGREGAMOS CUANDO NO ES RECURRENTE cevent.Importe = dr("Importe").ToString.ToDouble
Dim tFecha As DateTime = DateAdd(DateInterval.Month, -6, Date.Now)
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
If dr("FechaFin").ToString.ToDateTime > tFecha Or dr("FechaInicio").ToString.ToDateTime > tFecha Then
events.Add(cevent)
End If End If
Else
'EMPIEZA METODO PARA AGREGAR CUANDO SI ES RECURRENTE If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then
cevent.backgroundColor = "#1BBC9B"
End If
Dim FinRecurrencia = cevent.recurrenciafin.ToEntero 'VERIFICAMOS SI TIENE O NO RECURRENCIA
Dim FI As DateTime, FF As DateTime, FT As DateTime If Not cevent.recurrenciatipo > 0 Then
Dim DiasSemana = cevent.diassemana.Split(","c)
FI = cevent.start.ToDateTime
FF = cevent.end.ToDateTime
'OBTENEMOS LA FECHA TERMINO (FT) DE LA RECURRENCIA 'AGREGAMOS CUANDO NO ES RECURRENTE
Select Case FinRecurrencia Dim tFecha As DateTime = DateAdd(DateInterval.Month, -6, Date.Now)
Case -1 'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
FT = DateAdd(DateInterval.Year, 2, dr("FechaInicio").ToString.ToDateTime) If dr("FechaFin").ToString.ToDateTime > tFecha Or dr("FechaInicio").ToString.ToDateTime > tFecha Then
Case 0 events.Add(cevent)
FT = dr("RecurrenciaFin").ToString.ToDate End If
Case Is > 0 Else
FinRecurrencia -= 1
Select Case cevent.recurrenciatipo
Case 1
FT = DateAdd(DateInterval.Hour, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
Case 2
FT = DateAdd(DateInterval.Day, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
Case 3
FT = DateAdd(DateInterval.WeekOfYear, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
FT = DateAdd(DateInterval.Day, (7 - Weekday(FT)).ToString.ToDouble, FT)
Case 4
FT = DateAdd(DateInterval.Month, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
Case 5
FT = DateAdd(DateInterval.Year, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
End Select
End Select
'SI ES TIPO SEMANAL Y DIASSEMANA TIENE VALORES CHECKEA ESTOS VALORES 'EMPIEZA METODO PARA AGREGAR CUANDO SI ES RECURRENTE
Do
If DiasSemana.Length > 0 AndAlso DiasSemana(0) <> "" Then
For Each drDias As String In DiasSemana
Dim FIT = FI, FFT = FF
FIT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FI)).ToString.ToDouble, FI) Dim FinRecurrencia = cevent.recurrenciafin.ToEntero
FFT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FF)).ToString.ToDouble, FF) Dim FI As DateTime, FF As DateTime, FT As DateTime
Dim DiasSemana = cevent.diassemana.Split(","c)
FI = cevent.start.ToDateTime
FF = cevent.end.ToDateTime
'OBTENEMOS LA FECHA TERMINO (FT) DE LA RECURRENCIA
Select Case FinRecurrencia
Case -1
FT = DateAdd(DateInterval.Year, 2, dr("FechaInicio").ToString.ToDateTime)
Case 0
FT = dr("RecurrenciaFin").ToString.ToDate
Case Is > 0
FinRecurrencia -= 1
Select Case cevent.recurrenciatipo
Case 1
FT = DateAdd(DateInterval.Hour, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
Case 2
FT = DateAdd(DateInterval.Day, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
Case 3
FT = DateAdd(DateInterval.WeekOfYear, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
FT = DateAdd(DateInterval.Day, (7 - Weekday(FT)).ToString.ToDouble, FT)
Case 4
FT = DateAdd(DateInterval.Month, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
Case 5
FT = DateAdd(DateInterval.Year, FinRecurrencia * cevent.frecuencia, dr("FechaInicio").ToString.ToDateTime)
End Select
End Select
'SI ES TIPO SEMANAL Y DIASSEMANA TIENE VALORES CHECKEA ESTOS VALORES
Do
If DiasSemana.Length > 0 AndAlso DiasSemana(0) <> "" Then
For Each drDias As String In DiasSemana
Dim FIT = FI, FFT = FF
FIT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FI)).ToString.ToDouble, FI)
FFT = DateAdd(DateInterval.Day, (drDias.ToEntero - Weekday(FF)).ToString.ToDouble, FF)
cevent = New CalendarEvent()
cevent.id = dr("CveEvento").ToString.ToEntero
cevent.title = dr("Asunto").ToString
cevent.description = dr("Descripcion").ToString
cevent.start = String.Format("{0:s}", FIT)
cevent.end = String.Format("{0:s}", FFT)
cevent.allDay = False
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
cevent.backgroundColor = dr("BackGroundColor").ToString
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
cevent.diassemana = dr("DiasSemana").ToString
cevent.dia = dr("Dia").ToString.ToEntero
cevent.mes = dr("Mes").ToString.ToEntero
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
cevent.Prospecto = dr("Prospecto").ToString
'11/05/2018 - Evento Gasto Recurrente
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
If cevent.CveTipoEvento = 10 Then
cevent.Importe = dr("Importe").ToString.ToDouble
End If
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then
cevent.backgroundColor = "#1BBC9B"
End If
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL Y/0 SI LA FECHA INICIAL DE LA RECURRENCIA ES MENOR A LA FECHA QUE SE CREO EL EVENTO NO LO AGREGA
If FIT > DateAdd(DateInterval.Month, -6, Date.Now) And FIT >= dr("FechaInicio").ToString.ToDateTime Then
events.Add(cevent)
End If
Next
Else
cevent = New CalendarEvent() cevent = New CalendarEvent()
cevent.id = dr("CveEvento").ToString.ToEntero cevent.id = dr("CveEvento").ToString.ToEntero
cevent.title = dr("Asunto").ToString cevent.title = dr("Asunto").ToString
cevent.description = dr("Descripcion").ToString cevent.description = dr("Descripcion").ToString
cevent.start = String.Format("{0:s}", FIT) cevent.start = String.Format("{0:s}", FI)
cevent.end = String.Format("{0:s}", FFT) cevent.end = String.Format("{0:s}", FF)
cevent.allDay = False cevent.allDay = False
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
cevent.cveagendatipo = dr("CveAgendaTipo").ToString cevent.cveagendatipo = dr("CveAgendaTipo").ToString
@@ -218,69 +258,37 @@ Public Class CargaEventos : Implements IHttpHandler, IRequiresSessionState
cevent.backgroundColor = "#1BBC9B" cevent.backgroundColor = "#1BBC9B"
End If End If
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL Y/0 SI LA FECHA INICIAL DE LA RECURRENCIA ES MENOR A LA FECHA QUE SE CREO EL EVENTO NO LO AGREGA 'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA
If FIT > DateAdd(DateInterval.Month, -6, Date.Now) And FIT >= dr("FechaInicio").ToString.ToDateTime Then If FI > DateAdd(DateInterval.Month, -6, Date.Now) Then
events.Add(cevent) events.Add(cevent)
End If End If
Next
Else
cevent = New CalendarEvent()
cevent.id = dr("CveEvento").ToString.ToEntero
cevent.title = dr("Asunto").ToString
cevent.description = dr("Descripcion").ToString
cevent.start = String.Format("{0:s}", FI)
cevent.end = String.Format("{0:s}", FF)
cevent.allDay = False
cevent.CveEventoEstatus = dr("CveEventoEstatus").ToString.ToEntero
cevent.cveagendatipo = dr("CveAgendaTipo").ToString
cevent.prioridad = dr("CvePrioridad").ToString.ToEntero
cevent.backgroundColor = dr("BackGroundColor").ToString
cevent.recurrenciatipo = dr("RecurrenciaTipo").ToString.ToEntero
cevent.frecuencia = dr("Frecuencia").ToString.ToEntero
cevent.diassemana = dr("DiasSemana").ToString
cevent.dia = dr("Dia").ToString.ToEntero
cevent.mes = dr("Mes").ToString.ToEntero
cevent.recurrenciafin = dr("RecurrenciaFin").ToString
cevent.CveProspecto = dr("CveProspecto").ToString.ToEntero
cevent.Prospecto = dr("Prospecto").ToString
'11/05/2018 - Evento Gasto Recurrente
cevent.CveTipoEvento = dr("CveTipoEvento").ToString.ToEntero
If cevent.CveTipoEvento = 10 Then
cevent.Importe = dr("Importe").ToString.ToDouble
End If End If
If cevent.CveEventoEstatus.ToString.ToEntero = 3 Then Select Case cevent.recurrenciatipo
cevent.backgroundColor = "#1BBC9B" Case 1
End If FI = DateAdd(DateInterval.Hour, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.Hour, cevent.frecuencia, FF)
Case 2
FI = DateAdd(DateInterval.Day, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.Day, cevent.frecuencia, FF)
Case 3
FI = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FF)
Case 4
FI = DateAdd(DateInterval.Month, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.Month, cevent.frecuencia, FF)
Case 5
FI = DateAdd(DateInterval.Year, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.Year, cevent.frecuencia, FF)
End Select
'SI LA FECHA DEL EVENTO ES MENOR DE 6 MESES DE LA FECHA ACTUAL NO LO AGREGA Loop Until FI > FT
If FI > DateAdd(DateInterval.Month, -6, Date.Now) Then End If
events.Add(cevent)
End If
End If
Select Case cevent.recurrenciatipo
Case 1
FI = DateAdd(DateInterval.Hour, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.Hour, cevent.frecuencia, FF)
Case 2
FI = DateAdd(DateInterval.Day, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.Day, cevent.frecuencia, FF)
Case 3
FI = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.WeekOfYear, cevent.frecuencia, FF)
Case 4
FI = DateAdd(DateInterval.Month, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.Month, cevent.frecuencia, FF)
Case 5
FI = DateAdd(DateInterval.Year, cevent.frecuencia, FI)
FF = DateAdd(DateInterval.Year, cevent.frecuencia, FF)
End Select
Loop Until FI > FT
End If End If
Next Next
Catch ex As Exception Catch ex As Exception
GuardaLog(ex.ToString()) GuardaLog(ex.ToString())

View File

@@ -86,6 +86,7 @@
<asp:DropDownList ID="DdlEstatus" runat="server" AppendDataBoundItems="true" DataTextField="TipoGasto" DataValueField="CveTipoGasto" Class="table-group-action-input form-control input-inline input-sm select2me" Width="70%"> <asp:DropDownList ID="DdlEstatus" runat="server" AppendDataBoundItems="true" DataTextField="TipoGasto" DataValueField="CveTipoGasto" Class="table-group-action-input form-control input-inline input-sm select2me" Width="70%">
<asp:ListItem Selected="True" Text="No Aplicadas" Value="1"></asp:ListItem> <asp:ListItem Selected="True" Text="No Aplicadas" Value="1"></asp:ListItem>
<asp:ListItem Text="Aplicadas" Value="3"></asp:ListItem> <asp:ListItem Text="Aplicadas" Value="3"></asp:ListItem>
<asp:ListItem Text="Cancelado" Value="5"></asp:ListItem>
</asp:DropDownList> </asp:DropDownList>
</div> </div>
</div> </div>
@@ -120,10 +121,12 @@
<a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusqueda','{0}')", GvSolicitudes.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a> <a href="javascript:;" onclick="<%= String.Format("FiltrarTabla('TxtBusqueda','{0}')", GvSolicitudes.ClientID) %>" style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"><i class="icon-magnifier"></i></a>
</div> </div>
</div> </div>
<asp:GridView ID="GvSolicitudes" runat="server" GridLines="None" DataKeyNames="CveOrdenCompra,Folio, RazonSocial, ImporteSol, FolioMov, Importe, Nombre, CveEvento" <asp:GridView ID="GvSolicitudes" runat="server" GridLines="None" DataKeyNames="CveOrdenCompra,Folio, RazonSocial, ImporteSol, FolioMov, Importe, Nombre, CveEvento,CveEventoEstatus"
CssClass="table table-striped table-advance table-hover Widthall mysmallbtn ScrollAD" data-sort="true" data-footer="0" BorderWidth="1" BorderColor="#D3D3D3" CellSpacing="0" Width="100%" AutoGenerateColumns="False" CssClass="table table-striped table-advance table-hover Widthall mysmallbtn ScrollAD" data-sort="true" data-footer="0" BorderWidth="1" BorderColor="#D3D3D3" CellSpacing="0" Width="100%" AutoGenerateColumns="False"
OnRowDataBound="GvSolicitudes_RowDataBound"
EmptyDataText="No se encontraron registros"> EmptyDataText="No se encontraron registros">
<Columns> <Columns>
<%--0--%>
<asp:TemplateField Visible="false"> <asp:TemplateField Visible="false">
<HeaderTemplate> <HeaderTemplate>
<asp:CheckBox ID="ChkAll" runat="server"/> <asp:CheckBox ID="ChkAll" runat="server"/>
@@ -132,40 +135,53 @@
<asp:CheckBox ID="ChkOrdenCompra" runat="server" /> <asp:CheckBox ID="ChkOrdenCompra" runat="server" />
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<%--1--%>
<asp:TemplateField HeaderText="Ord. Compra" ItemStyle-Width="10%"> <asp:TemplateField HeaderText="Ord. Compra" ItemStyle-Width="10%">
<ItemTemplate> <ItemTemplate>
<asp:HyperLink ID="HplNumFolio" runat="server" CssClass="Texto" Target="_blank" NavigateUrl='<%# Eval("CveOrdenCompra", "/OC/OC.aspx?OC={0}")%>' Text='<%# Eval("Folio") %>'></asp:HyperLink> <asp:HyperLink ID="HplNumFolio" runat="server" CssClass="Texto" Target="_blank" NavigateUrl='<%# Eval("CveOrdenCompra", "/OC/OC.aspx?OC={0}")%>' Text='<%# Eval("Folio") %>'></asp:HyperLink>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<%--2--%>
<asp:BoundField DataField="RazonSocial" HeaderText="Proveedor" ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField DataField="RazonSocial" HeaderText="Proveedor" ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Left" />
<%--3--%>
<asp:BoundField DataField="Descripcion" HeaderText="Descripción" ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField DataField="Descripcion" HeaderText="Descripción" ItemStyle-Width="25%" ItemStyle-HorizontalAlign="Left" />
<%--4--%>
<asp:BoundField DataField="SubProyecto" HeaderText="SubProyecto" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField DataField="SubProyecto" HeaderText="SubProyecto" ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Left" />
<%--5--%>
<asp:BoundField DataField="Nombre" HeaderText="Usuario Solicitó" ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField DataField="Nombre" HeaderText="Usuario Solicitó" ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Left" />
<%--6--%>
<asp:BoundField DataField="ImporteSol" HeaderText="Importe Solicitud" ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Right" Visible ="true" /> <asp:BoundField DataField="ImporteSol" HeaderText="Importe Solicitud" ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Right" Visible ="true" />
<%--7--%>
<asp:TemplateField HeaderText="Folio Mov. Banc." ItemStyle-Width="10%" Visible="false"> <asp:TemplateField HeaderText="Folio Mov. Banc." ItemStyle-Width="10%" Visible="false">
<ItemTemplate> <ItemTemplate>
<asp:HyperLink ID="HplNumFolioMov" runat="server" CssClass="Texto" Target="_blank" NavigateUrl='<%# Eval("CveIE", "/Bancos/IE.aspx?CveIE={0}") %>' Text='<%# Eval("FolioMov") %>'></asp:HyperLink> <asp:HyperLink ID="HplNumFolioMov" runat="server" CssClass="Texto" Target="_blank" NavigateUrl='<%# Eval("CveIE", "/Bancos/IE.aspx?CveIE={0}") %>' Text='<%# Eval("FolioMov") %>'></asp:HyperLink>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<%--8--%>
<asp:TemplateField HeaderText="Importe" ItemStyle-Width="10%" Visible="false" ItemStyle-HorizontalAlign="Right"> <asp:TemplateField HeaderText="Importe" ItemStyle-Width="10%" Visible="false" ItemStyle-HorizontalAlign="Right">
<ItemTemplate> <ItemTemplate>
<asp:Label runat="server" CssClass="Texto" Text='<%# Eval("Importe", "${0:N2}") %>'></asp:Label> <asp:Label runat="server" CssClass="Texto" Text='<%# Eval("Importe", "${0:N2}") %>'></asp:Label>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<%--9--%>
<asp:TemplateField HeaderText="Moneda" ItemStyle-Width="2.5%" ItemStyle-HorizontalAlign="Left"> <asp:TemplateField HeaderText="Moneda" ItemStyle-Width="2.5%" ItemStyle-HorizontalAlign="Left">
<ItemTemplate> <ItemTemplate>
<asp:Label runat="server" CssClass="Texto" Text='<%# Eval("Abreviatura") %>'></asp:Label> <asp:Label runat="server" CssClass="Texto" Text='<%# Eval("Abreviatura") %>'></asp:Label>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<%--10--%>
<asp:TemplateField HeaderText="Pagar Anticipo" ItemStyle-Width="20%" Visible="false" ItemStyle-HorizontalAlign="Center"> <asp:TemplateField HeaderText="Pagar Anticipo" ItemStyle-Width="20%" Visible="false" ItemStyle-HorizontalAlign="Center">
<ItemTemplate> <ItemTemplate>
<asp:HyperLink ID="HplNum" runat="server" CssClass="Texto" Target="_blank" NavigateUrl='<%# Eval("CveOrdenCompra", "/Bancos/IE.aspx?Opcion=EGSSINFACT&CveOC={0}") %>' ToolTip="Pagar Anticipo"><i class='fa fa-money font-green'></i></asp:HyperLink> <asp:HyperLink ID="HplNum" runat="server" CssClass="Texto" Target="_blank" NavigateUrl='<%# Eval("CveOrdenCompra", "/Bancos/IE.aspx?Opcion=EGSSINFACT&CveOC={0}") %>' ToolTip="Pagar Anticipo"><i class='fa fa-money font-green'></i></asp:HyperLink>
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<%--11--%>
<asp:TemplateField ItemStyle-HorizontalAlign="Left" HeaderText="Cancelar" >
<ItemTemplate>
<asp:LinkButton ID="LnkCancelar" runat="server" AlternateText="Eliminar" Visible="false" CausesValidation="False" CommandName="Delete" OnClick="LnkCancelar_Click"
CssClass="btn btn-circle btn-sm red" Text="<i class='icon-trash'></i>" data-toggle="confirmation" data-popout="true" data-original-title="Confirmar" data-btn-ok-label="si" />
</ItemTemplate>
</asp:TemplateField>
</Columns> </Columns>
</asp:GridView> </asp:GridView>
</ContentTemplate> </ContentTemplate>

View File

@@ -14,6 +14,10 @@ using iTextSharp.text;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using System.IO; using System.IO;
using Ionic.Zip; using Ionic.Zip;
using StackExchange.Redis;
using static Stimulsoft.Report.Export.DeflaterHuffman;
public partial class OC_RepSolicitudesAnticipo : ClsPaginas public partial class OC_RepSolicitudesAnticipo : ClsPaginas
{ {
#region "Propiedades" #region "Propiedades"
@@ -286,4 +290,64 @@ public partial class OC_RepSolicitudesAnticipo : ClsPaginas
} }
protected void LnkCancelar_Click(object sender, EventArgs e)
{
bool errorProceso = false;
GridViewRow GvRow = (GridViewRow)((LinkButton)sender).NamingContainer;
int CveEvento = GvRow.DataKey("CveEvento").ToEntero();
int CveOrdenCompra = GvRow.DataKey("CveOrdenCompra").ToEntero();
string ImporteSol = GvRow.DataKey("ImporteSol") ;
ClsOIEventos objGenral = new ClsOIEventos();
ClsOIEventos objEventos = new ClsOIEventos(objGenral.IniciaTransacSQL());
if (objEventos.UpdateEstatusEvento(5,-1, CveEvento,UsuarioActual.CveUsuario))
{
if (!objGenral.AddEventoBitacora($"Se cancela solicitud de anticipo con importe {ImporteSol}","",UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,CveOC:CveOrdenCompra)){
errorProceso = true;
}
}
else
{
errorProceso = true;
}
if (!errorProceso)
{
objGenral.Commit();
Alert("Solicitud de anticipo cancelado correctamente.");
}
else
{
objGenral.RollBack();
}
objGenral.Dispose();
if (!errorProceso)
{
CargaDatos();
}
}
protected void GvSolicitudes_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
if(e.Row.DataKey("CveEventoEstatus").ToEntero() == 1)
{
e.Row.FCLinkButton("LnkCancelar").Visible = true;
}else if (e.Row.DataKey("CveEventoEstatus").ToEntero() == 5)
{
e.Row.FCHyperLink("HplNum").Visible = false;
}
}
}
} }

View File

@@ -187,7 +187,11 @@
</div> </div>
<div class="portlet-body form"> <div class="portlet-body form">
<asp:GridView ID="GvDatos" DataKeyNames="CvePromocionDetalle, CveClasificacion, CvePS, CodigoPS, HoraInicio, HoraFin, CveTipoPromocion, Promocion, PUAnterior, AplicaRestriccion, AplicaLunes, AplicaMartes, AplicaMiercoles, AplicaJueves, AplicaViernes, AplicaSabado, AplicaDomingo, CantidadMinima, CveRinTamaño,IncluyeImpuestos" CssClass="table table-striped table-hover Widthall mysmallbtn" AutoGenerateColumns="false" GridLines="None" EmptyDataText="Aun no se registran detalles" runat="server"> <asp:GridView ID="GvDatos"
DataKeyNames="CvePromocionDetalle, CveClasificacion, CvePS, CodigoPS, HoraInicio, HoraFin, CveTipoPromocion, Promocion, PUAnterior, AplicaRestriccion, AplicaLunes, AplicaMartes, AplicaMiercoles, AplicaJueves, AplicaViernes, AplicaSabado, AplicaDomingo, CantidadMinima, CveRinTamaño,IncluyeImpuestos"
CssClass="table table-striped table-hover Widthall mysmallbtn" AutoGenerateColumns="false" GridLines="None" EmptyDataText="Aun no se registran detalles" runat="server"
OnRowDataBound="GvDatos_RowDataBound"
>
<Columns> <Columns>
<asp:BoundField HeaderText="Producto / Servicio" DataField="CodigoPS" ItemStyle-Width="30%" /> <asp:BoundField HeaderText="Producto / Servicio" DataField="CodigoPS" ItemStyle-Width="30%" />
<%--<asp:BoundField HeaderText="Producto / Servicio" DataField="PS" ItemStyle-Width="30%" />--%> <%--<asp:BoundField HeaderText="Producto / Servicio" DataField="PS" ItemStyle-Width="30%" />--%>
@@ -201,12 +205,12 @@
<asp:BoundField HeaderText="Rin" ItemStyle-HorizontalAlign="Left" DataField="RinTamaño" Visible="false"/> <asp:BoundField HeaderText="Rin" ItemStyle-HorizontalAlign="Left" DataField="RinTamaño" Visible="false"/>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="5%"> <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="5%">
<ItemTemplate> <ItemTemplate>
<asp:LinkButton ID="ImgE" runat="server" AlternateText="Editar" CausesValidation="False" CommandArgument='<%# Container.DataItemIndex%>' CommandName="Editar" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-pencil'></i>" /> <asp:LinkButton ID="LnkGvDetalleEditar" runat="server" AlternateText="Editar" CausesValidation="False" CommandArgument='<%# Container.DataItemIndex%>' CommandName="Editar" CssClass="btn btn-circle btn-sm green" Text="<i class='fa fa-pencil'></i>" />
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="5%"> <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="5%">
<ItemTemplate> <ItemTemplate>
<asp:LinkButton ID="imgD" runat="server" AlternateText="Eliminar" CausesValidation="False" CommandName="Delete" CssClass="btn btn-circle btn-sm red" Text="<i class='icon-trash'></i>" data-toggle="confirmation" data-popout="true" data-original-title="Confirmar" data-btn-ok-label="si" /> <asp:LinkButton ID="LnkGvDetalleEliminar" runat="server" AlternateText="Eliminar" CausesValidation="False" CommandName="Delete" CssClass="btn btn-circle btn-sm red" Text="<i class='icon-trash'></i>" data-toggle="confirmation" data-popout="true" data-original-title="Confirmar" data-btn-ok-label="si" />
</ItemTemplate> </ItemTemplate>
</asp:TemplateField> </asp:TemplateField>
</Columns> </Columns>
@@ -265,6 +269,11 @@
<asp:UpdatePanel runat="server"> <asp:UpdatePanel runat="server">
<ContentTemplate> <ContentTemplate>
<asp:Button ID="BtnGuardar" Text="Guardar" CssClass="btn btn-primary" ValidationGroup="GrpGuardar" OnClick="BtnGuardar_Click" runat="server" /> <asp:Button ID="BtnGuardar" Text="Guardar" CssClass="btn btn-primary" ValidationGroup="GrpGuardar" OnClick="BtnGuardar_Click" runat="server" />
<asp:Button ID="ButBtnEliminar" Text="Eliminar" CssClass="btn btn-danger" OnClick="BtnEliminar_Click" runat="server" Visible="false"
data-toggle="confirmation" data-popout="true" data-original-title="Confirmar" data-btn-ok-label="si"
/>
</ContentTemplate> </ContentTemplate>
</asp:UpdatePanel> </asp:UpdatePanel>
</td> </td>

View File

@@ -53,6 +53,21 @@ Partial Class Ventas_Promociones
End Set End Set
End Property End Property
Private Property CvePromocionPadre As Integer
Get
If ViewState("CvePromocionPadre") Is Nothing Then
ViewState("CvePromocionPadre") = -1
End If
Return ViewState("CvePromocionPadre").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CvePromocionPadre") = value
End Set
End Property
#End Region #End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
@@ -64,9 +79,6 @@ Partial Class Ventas_Promociones
If Request("CvePromocion") IsNot Nothing AndAlso Request("CvePromocion").ToString.ToEntero > 0 Then If Request("CvePromocion") IsNot Nothing AndAlso Request("CvePromocion").ToString.ToEntero > 0 Then
CvePromocion = Request("CvePromocion").ToString.ToEntero CvePromocion = Request("CvePromocion").ToString.ToEntero
CargaDatos() CargaDatos()
Else Else
ChkEstatus.Enabled = True ChkEstatus.Enabled = True
ChkEstatus.Checked = True ChkEstatus.Checked = True
@@ -287,6 +299,8 @@ Partial Class Ventas_Promociones
DdlMarca.SelectedValueExist(Dr("CveMarca").ToString) DdlMarca.SelectedValueExist(Dr("CveMarca").ToString)
DdlTipoAplicacion.SelectedValueExist(Dr("TipoAplicacion").ToString) DdlTipoAplicacion.SelectedValueExist(Dr("TipoAplicacion").ToString)
CvePromocionPadre = If(Dr("CvePromocionPadre").ToString.ToEntero > 0, Dr("CvePromocionPadre").ToString.ToEntero, -1)
If ObjVentas.GetPromocionesDetalle(CvePromocion, UsuarioActual.CveEmpresa) Then If ObjVentas.GetPromocionesDetalle(CvePromocion, UsuarioActual.CveEmpresa) Then
TempDT = ObjVentas.DtResultados.Copy TempDT = ObjVentas.DtResultados.Copy
TempDTOrigial = ObjVentas.DtResultados.Copy TempDTOrigial = ObjVentas.DtResultados.Copy
@@ -299,6 +313,13 @@ Partial Class Ventas_Promociones
Alert("Ocurrió un error al consultar la promoción. Por favor vuelva a intentar.", TipoMensaje.MsgError) Alert("Ocurrió un error al consultar la promoción. Por favor vuelva a intentar.", TipoMensaje.MsgError)
End If End If
ButBtnEliminar.Visible = True
If CvePromocionPadre > 0 Then
BtnGuardar.Enabled = False
ButBtnEliminar.Enabled = False
End If
ObjVentas.Dispose() ObjVentas.Dispose()
End Sub End Sub
Private Sub CargaGrid() Private Sub CargaGrid()
@@ -537,6 +558,11 @@ Partial Class Ventas_Promociones
TieneError = True TieneError = True
End If End If
If UsuarioActual.Empresa.Funcionalidad(563) <> "" Then
TieneError = ObjVentas.SincronizarPromocionesClonar(CvePromocion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1)
End If
If Not TieneError Then If Not TieneError Then
ObjVentas.Commit() ObjVentas.Commit()
Alert("La promoción se guardo correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatPromociones.aspx"";") Alert("La promoción se guardo correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatPromociones.aspx"";")
@@ -547,6 +573,8 @@ Partial Class Ventas_Promociones
ObjVentas.Dispose() ObjVentas.Dispose()
End Sub End Sub
Private Sub ActualizaPromocion() Private Sub ActualizaPromocion()
Dim CveCliente As Integer = If(DdlClientes.SelectedValue = "", -1, DdlClientes.SelectedValue.ToEntero) Dim CveCliente As Integer = If(DdlClientes.SelectedValue = "", -1, DdlClientes.SelectedValue.ToEntero)
@@ -559,12 +587,17 @@ Partial Class Ventas_Promociones
If ObjVentas.UpdatePromociones(TxtPromocion.Text.Trim, If(IsDate(TxtFechaI.Text), TxtFechaI.Text.ToDate, MinFecha), If(IsDate(TxtFechaF.Text), TxtFechaF.Text.ToDate, MaxFecha), If ObjVentas.UpdatePromociones(TxtPromocion.Text.Trim, If(IsDate(TxtFechaI.Text), TxtFechaI.Text.ToDate, MinFecha), If(IsDate(TxtFechaF.Text), TxtFechaF.Text.ToDate, MaxFecha),
DdlVendedor.SelectedValue.ToEntero, CveCliente, ChkEstatus.Checked, DdlMoneda.SelectedValue.ToEntero, UsuarioActual.CveUsuario, DdlVendedor.SelectedValue.ToEntero, CveCliente, ChkEstatus.Checked, DdlMoneda.SelectedValue.ToEntero, UsuarioActual.CveUsuario,
CvePromocion, DdlSubProyecto.SelectedValue.ToEntero, DdlTipoAplicacion.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, CveMarca:=DdlMarca.SelectedValue.ToEntero, DdlDistribuidor.SelectedValue.ToEntero) Then CvePromocion, DdlSubProyecto.SelectedValue.ToEntero, DdlTipoAplicacion.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, CveMarca:=DdlMarca.SelectedValue.ToEntero, EsDistribuidor:=DdlDistribuidor.SelectedValue.ToEntero) Then
For Each Dr As DataRow In TempDT.FiltraParametros("Estatus = 0").Rows For Each Dr As DataRow In TempDT.FiltraParametros("Estatus = 0").Rows
Dim OpReplicarDetalleFranquicias As Integer = If(UsuarioActual.Empresa.Funcionalidad(563) <> "", 2, 1) ' op 2 Elimina detalles de franquicias
If Not ObjVentas.AddPromocionesDetalle(CvePromocion, Dr("CvePS").ToString.ToEntero, Dr("CveTipoPromocion").ToString.ToEntero, Dr("Promocion").ToString.ToDouble, Dr("PUAnterior").ToString.ToDouble, Dr("PUPromocion").ToString.ToDouble, If Not ObjVentas.AddPromocionesDetalle(CvePromocion, Dr("CvePS").ToString.ToEntero, Dr("CveTipoPromocion").ToString.ToEntero, Dr("Promocion").ToString.ToDouble, Dr("PUAnterior").ToString.ToDouble, Dr("PUPromocion").ToString.ToDouble,
CBool(Dr("AplicaRestriccion")), CBool(Dr("AplicaLunes")), CBool(Dr("AplicaMartes")), CBool(Dr("AplicaMiercoles")), CBool(Dr("AplicaJueves")), CBool(Dr("AplicaViernes")), CBool(Dr("AplicaSabado")), CBool(Dr("AplicaDomingo")), CBool(Dr("AplicaRestriccion")), CBool(Dr("AplicaLunes")), CBool(Dr("AplicaMartes")), CBool(Dr("AplicaMiercoles")), CBool(Dr("AplicaJueves")), CBool(Dr("AplicaViernes")), CBool(Dr("AplicaSabado")), CBool(Dr("AplicaDomingo")),
Dr("HoraInicio").ToString.ToDateTime, Dr("HoraFin").ToString.ToDateTime, Dr("CantidadMinima").ToString.ToEntero, CveClasificacion:=If(Dr("CvePS").ToString = "-1", Dr("CveClasificacion").ToString.ToEntero, -1), CveRinTamaño:=Dr("CveRinTamaño").ToString.ToEntero, IncluyeImpuestos:=ChkIncluyeImpuesto.Checked) Then Dr("HoraInicio").ToString.ToDateTime, Dr("HoraFin").ToString.ToDateTime, Dr("CantidadMinima").ToString.ToEntero, CveClasificacion:=If(Dr("CvePS").ToString = "-1", Dr("CveClasificacion").ToString.ToEntero, -1),
CveRinTamaño:=Dr("CveRinTamaño").ToString.ToEntero, IncluyeImpuestos:=ChkIncluyeImpuesto.Checked, Opcion:=OpReplicarDetalleFranquicias) Then
TieneError = True TieneError = True
Exit For Exit For
End If End If
@@ -759,8 +792,14 @@ Partial Class Ventas_Promociones
End If End If
If Not TieneError Then If Not TieneError Then
For Each Dr As DataRow In TempDT.FiltraParametros("Estatus = 2").Rows For Each Dr As DataRow In TempDT.FiltraParametros("Estatus = 2").Rows
If Not ObjVentas.RemovePromocionesDetalle(Dr("CvePromocionDetalle").ToString.ToEntero) Then
'RunPromocionesClonar
Dim OpEliminacionDetalle As Integer = If(UsuarioActual.Empresa.Funcionalidad(563) <> "", 2, 1) ' op 2 Elimina detalles de franquicias
If Not ObjVentas.RemovePromocionesDetalle(Dr("CvePromocionDetalle").ToString.ToEntero, OpEliminacionDetalle) Then
TieneError = True TieneError = True
Exit For Exit For
End If End If
@@ -781,6 +820,14 @@ Partial Class Ventas_Promociones
TieneError = True TieneError = True
End If End If
If UsuarioActual.Empresa.Funcionalidad(563) <> "" Then
If Not ObjVentas.SincronizarPromocionesClonar(CvePromocion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 2) Then
TieneError = True
End If
End If
If Not TieneError Then If Not TieneError Then
ObjVentas.Commit() ObjVentas.Commit()
Alert("La promoción se guardo correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatPromociones.aspx"";") Alert("La promoción se guardo correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Ventas/CatPromociones.aspx"";")
@@ -801,12 +848,21 @@ Partial Class Ventas_Promociones
ObjVentas.IniciaTransacSQL() ObjVentas.IniciaTransacSQL()
Dim TieneError = False Dim TieneError = False
If ObjVentas.RemovePromocionesDetalle(CvePromocion) Then
If Not ObjVentas.RemovePromociones(CvePromocion, UsuarioActual.CveEmpresa) Then If UsuarioActual.Empresa.Funcionalidad(563) <> "" Then
If Not ObjVentas.SincronizarPromocionesClonar(CvePromocion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 3) Then
TieneError = True
End If
End If
If Not TieneError Then
If ObjVentas.RemovePromocionesDetalle(-1, 3, CvePromocion) Then
If Not ObjVentas.RemovePromociones(CvePromocion, UsuarioActual.CveEmpresa) Then
TieneError = True
End If
Else
TieneError = True TieneError = True
End If End If
Else
TieneError = True
End If End If
If Not TieneError Then If Not TieneError Then
@@ -816,6 +872,15 @@ Partial Class Ventas_Promociones
ObjVentas.RollBack() ObjVentas.RollBack()
Alert("Ocurrió un error al registrar la promoción. Por favor vuelva a intentar.", TipoMensaje.MsgError) Alert("Ocurrió un error al registrar la promoción. Por favor vuelva a intentar.", TipoMensaje.MsgError)
End If End If
If UsuarioActual.Empresa.Funcionalidad(563) <> "" AndAlso TieneError Then
If ObjVentas.SincronizarPromocionesClonar(CvePromocion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 4) Then
Alert("Se presento un error al eliminar, se desactivo kla promoción actual y promociones relacionadas", TipoMensaje.MsgAdvertencia, $"document.location.href=""/Ventas/Promociones.aspx?CvePromocion={CvePromocion}"";")
End If
End If
ObjVentas.Dispose() ObjVentas.Dispose()
End Sub End Sub
#End Region #End Region
@@ -836,4 +901,17 @@ Partial Class Ventas_Promociones
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If CvePromocionPadre > 0 Then
e.Row.FCLinkButton("LnkGvDetalleEditar").Visible = False
e.Row.FCLinkButton("LnkGvDetalleEliminar").Visible = False
End If
End If
End Sub
End Class End Class