PORCENTAJE DE COMISIONES POR VENDEDOR EN CADA MES/AÑO

This commit is contained in:
2020-01-31 18:50:58 -07:00
parent eb28a271e6
commit 53d9887893
3 changed files with 407 additions and 226 deletions

View File

@@ -18,26 +18,30 @@ Partial Class Ventas_RepComisiones
InicializaValores()
End If
End Sub
End Sub
#Region " INICIALIZA VALORES "
Private Sub InicializaValores()
txtFechaI.Text = FirstDayOfMonth(Now).ToShortDateString
txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString
TxtAnio.Text = Now.Year.ToString()
DdlMes.SelectedValueExist(Now.Month)
DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
DdlVendedor.DataBind()
DdlVendedorAjuste.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
DdlVendedorAjuste.DataBind()
End Sub
DdlVendedorPorcentaje.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
DdlVendedorPorcentaje.DataBind()
End Sub
#End Region
#Region " CARGA DATOS "
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
CargaDatos()
@@ -69,10 +73,9 @@ Partial Class Ventas_RepComisiones
BtnPagar.Visible = False
ImgExcel.Visible = False
End If
End Sub
End Sub
#End Region
#Region " GV DATOS "
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
@@ -90,11 +93,10 @@ Partial Class Ventas_RepComisiones
e.Row.FCHyperLink("HLVendedor").NavigateUrl = String.Format("/Ventas/RepComisionesDetalle.aspx?CveVendedor={0}&FI={1}&FF={2}&CveSubProyecto={3}", CveVendedorURL, If(txtFechaI.Text.Trim() = "", "-1", txtFechaI.Text.Trim()), If(txtFechaF.Text.Trim() = "", "-1", txtFechaF.Text.Trim()), DdlSubProyecto.SelectedValue.ToEntero)
End If
End Sub
End Sub
#End Region
#Region " PAGAR COMISIONES "
Protected Sub BtnPagar_Click(sender As Object, e As EventArgs)
If Not GvDatos.Rows.Count > 0 Then
@@ -153,10 +155,9 @@ Partial Class Ventas_RepComisiones
ObjComisiones.Dispose()
End Sub
End Sub
#End Region
#Region " AJUSTE "
Protected Sub DdlVendedorAjuste_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim ObjComisiones As New ClsEsquemasComisiones
@@ -194,22 +195,75 @@ Partial Class Ventas_RepComisiones
UPDatos.Update()
End If
End Sub
End Sub
#End Region
#Region " EXCEL "
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
GvDatos.ExportToExcel("ReporteComisiones_" & Now.ToShortDateString)
End Sub
End Sub
#End Region
Protected Sub BtnGuardarPorcentajeComision_Click(sender As Object, e As EventArgs)
Dim CveVendedor As Integer = DdlVendedorPorcentaje.SelectedValue.ToEntero()
Dim Mes As Integer = DdlMes.SelectedValue.ToEntero()
Dim Anio As Integer = TxtAnio.Text.ToEntero()
Dim Porcentaje As Decimal = TxtPorcentajeComision.Text.ToDecimal() / 100
Dim RowCierre As DataRow = Nothing
Dim ObjVentas As New ClsVentas
Try
If ObjVentas.GetCierreComisionVendedor(CveVendedor, Mes, Anio, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
RowCierre = ObjVentas.DtResultados.Rows(0)
End If
If RowCierre IsNot Nothing Then
If ObjVentas.UpdateCierreComisionVendedor(CveVendedor, Mes, Anio, Porcentaje) Then
Alert("El porcentaje de comisiones se guardo correctamente.", TipoMensaje.MsgInformacion)
Else
Alert("Ocurrió un error al guardar el porcentaje de comisiones.", TipoMensaje.MsgError)
End If
Else
If ObjVentas.AddCierreComisionVendedor(CveVendedor, Mes, Anio, Porcentaje) Then
Alert("El porcentaje de comisiones se guardo correctamente.", TipoMensaje.MsgInformacion)
Else
Alert("Ocurrió un error al guardar el porcentaje de comisiones.", TipoMensaje.MsgError)
End If
End If
Catch ex As Exception
OnError("Ocurrió un error al asginar el porcentaje de la comisión", ex)
End Try
ObjVentas.Dispose()
UpPorcentajeComisiones.Update()
End Sub
Protected Sub DdlVendedorPorcentaje_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaPorcentajeComisiones()
End Sub
Protected Sub DdlMes_SelectedIndexChanged(sender As Object, e As EventArgs)
CargaPorcentajeComisiones()
End Sub
Protected Sub CargaPorcentajeComisiones()
Dim CveVendedor As Integer = DdlVendedorPorcentaje.SelectedValue.ToEntero()
Dim Mes As Integer = DdlMes.SelectedValue.ToEntero()
Dim Anio As Integer = TxtAnio.Text.ToEntero()
Dim RowCierre As DataRow = Nothing
Dim ObjVentas As New ClsVentas
If ObjVentas.GetCierreComisionVendedor(CveVendedor, Mes, Anio, UsuarioActual.CveEmpresa) AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
RowCierre = ObjVentas.DtResultados.Rows(0)
End If
ObjVentas.Dispose()
If RowCierre IsNot Nothing Then
TxtPorcentajeComision.Text = (RowCierre("PorcentajeComision").ToString().ToDecimal() * 100).FormatoNumero(0)
Else
TxtPorcentajeComision.Text = "0"
End If
UpPorcentajeComisiones.Update()
End Sub
End Class