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

@@ -53,6 +53,21 @@ Partial Class Ventas_Promociones
End Set
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
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
CvePromocion = Request("CvePromocion").ToString.ToEntero
CargaDatos()
Else
ChkEstatus.Enabled = True
ChkEstatus.Checked = True
@@ -287,6 +299,8 @@ Partial Class Ventas_Promociones
DdlMarca.SelectedValueExist(Dr("CveMarca").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
TempDT = 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)
End If
ButBtnEliminar.Visible = True
If CvePromocionPadre > 0 Then
BtnGuardar.Enabled = False
ButBtnEliminar.Enabled = False
End If
ObjVentas.Dispose()
End Sub
Private Sub CargaGrid()
@@ -537,6 +558,11 @@ Partial Class Ventas_Promociones
TieneError = True
End If
If UsuarioActual.Empresa.Funcionalidad(563) <> "" Then
TieneError = ObjVentas.SincronizarPromocionesClonar(CvePromocion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 1)
End If
If Not TieneError Then
ObjVentas.Commit()
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()
End Sub
Private Sub ActualizaPromocion()
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),
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
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,
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
Exit For
End If
@@ -759,8 +792,14 @@ Partial Class Ventas_Promociones
End If
If Not TieneError Then
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
Exit For
End If
@@ -781,6 +820,14 @@ Partial Class Ventas_Promociones
TieneError = True
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
ObjVentas.Commit()
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()
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
End If
Else
TieneError = True
End If
If Not TieneError Then
@@ -816,6 +872,15 @@ Partial Class Ventas_Promociones
ObjVentas.RollBack()
Alert("Ocurrió un error al registrar la promoción. Por favor vuelva a intentar.", TipoMensaje.MsgError)
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()
End Sub
#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