Comisione cobradas en reporte de comisiones

This commit is contained in:
2020-02-05 13:11:06 -07:00
parent 6f4b7109a0
commit 555773d044
3 changed files with 54 additions and 55 deletions

View File

@@ -24,8 +24,8 @@ Partial Class Ventas_RepComisiones
Private Sub InicializaValores()
txtFechaI.Text = FirstDayOfMonth(Now).ToShortDateString
txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString
txtFechaF.Text = Now.LastDayOfMonth.ToShortDateString
TxtAnio.Text = Now.Year.ToString()
DdlMes.SelectedValueExist(Now.Month)
@@ -35,8 +35,8 @@ Partial Class Ventas_RepComisiones
DdlVendedorAjuste.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
DdlVendedorAjuste.DataBind()
DdlVendedorPorcentaje.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
DdlVendedorPorcentaje.DataBind()
'DdlVendedorPorcentaje.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa)
'DdlVendedorPorcentaje.DataBind()
End Sub
@@ -205,65 +205,59 @@ Partial Class Ventas_RepComisiones
#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 TieneError As Boolean = False
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
ObjVentas.IniciaTransacSQL()
Dim Mes As Integer = DdlMes.SelectedValue.ToEntero()
Dim Anio As Integer = TxtAnio.Text.ToEntero()
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)
For Each GvRow As GridViewRow In GvDatos.Rows
If GvRow.RowType = DataControlRowType.DataRow Then
If GvRow.DataKey("CveVendedor").ToEntero() > 0 Then
Dim Porcentaje As Decimal = GvRow.DataKey("Comision").ToDecimal() / 100
If ObjVentas.GetCierreComisionVendedor(GvRow.DataKey("CveVendedor").ToEntero(), Mes, Anio, UsuarioActual.CveEmpresa) Then
If ObjVentas.DtResultados.Rows.Count > 0 Then
RowCierre = ObjVentas.DtResultados.Rows(0)
End If
Else
TieneError = True
End If
If RowCierre IsNot Nothing Then
TieneError = Not ObjVentas.UpdateCierreComisionVendedor(GvRow.DataKey("CveVendedor").ToEntero(), Mes, Anio, Porcentaje)
Else
TieneError = Not ObjVentas.AddCierreComisionVendedor(GvRow.DataKey("CveVendedor").ToEntero(), Mes, Anio, Porcentaje)
End If
If TieneError Then
Exit For
End If
End If
RowCierre = Nothing
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
Next
Catch ex As Exception
TieneError = True
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)
If TieneError Then
ObjVentas.RollBack()
Alert("Ocurrió un error al guardar el porcentaje de comisiones.", TipoMensaje.MsgError)
Else
TxtPorcentajeComision.Text = "0"
ObjVentas.Commit()
Alert("El porcentaje de comisiones se guardó correctamente.", TipoMensaje.MsgInformacion)
End If
ObjVentas.Dispose()
CargaDatos()
UPDatos.Update()
UpPorcentajeComisiones.Update()
End Sub
End Class