194 lines
6.2 KiB
VB.net
194 lines
6.2 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
|
|
Partial Class Ventas_RepComisionesSMS
|
|
Inherits ClsPaginas
|
|
|
|
Property DTDatos As DataTable
|
|
Get
|
|
If ViewState("DTDatos") Is Nothing Then
|
|
ViewState("DTDatos") = New DataTable
|
|
End If
|
|
Return DirectCast(ViewState("DTDatos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTDatos") = value
|
|
End Set
|
|
End Property
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
|
|
If Not Page.IsPostBack Then
|
|
|
|
Dim FechaInicial As Date = New Date(10)
|
|
|
|
txtFechaI.Text = Now.FirstDayOfMonth.ToString("dd/MM/yyyy")
|
|
txtFechaF.Text = Now.ToString("dd/MM/yyyy")
|
|
CargaCombos()
|
|
CargaDatos()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaCombos()
|
|
|
|
|
|
'If UsuarioActual.Empresa.Funcionalidad(302) = "1" AndAlso DdlSubProyectoDatos.SelectedValue.ToEntero() > 0 Then
|
|
' DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa, VendedorTipo:=-1).FiltraParametros(String.Format("VendedorTipo IN (1,4) AND (CveSubProyecto IS NULL OR CveSubProyecto = {0})", DdlSubProyectoDatos.SelectedValue))
|
|
'Else
|
|
DdlVendedor.DataSource = GlobalDTVendedores(UsuarioActual.CveEmpresa).FiltraParametros("VendedorTipo = 1")
|
|
'End If
|
|
DdlVendedor.DataBind()
|
|
DdlVendedor.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
|
|
DdlMedico.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")
|
|
DdlMedico.DataBind()
|
|
DdlMedico.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
DdlUsuarioAtendio.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa)
|
|
DdlUsuarioAtendio.DataBind()
|
|
DdlUsuarioAtendio.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
|
|
|
|
|
|
LnkExportar.Visible = False
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
|
|
If ObjVentas.GetComisionesMedicasRep(txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, UsuarioActual.CveEmpresa, -1, -1, DdlMedico.SelectedValue.ToEntero, DdlVendedor.SelectedValue.ToEntero, DdlUsuarioAtendio.SelectedValue.ToEntero, -1) Then
|
|
GvDatos.DataSource = ObjVentas.DtResultados
|
|
|
|
If ObjVentas.DtResultados IsNot Nothing AndAlso ObjVentas.DtResultados.Rows.Count > 0 Then
|
|
LnkExportar.Visible = True
|
|
End If
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
GvDatos.DataBind()
|
|
|
|
UpDatos.Update()
|
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
#Region "EXCEL"
|
|
|
|
Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
|
|
|
|
GvDatos.Columns(10).Visible = False
|
|
Dim SbFiltros As New StringBuilder()
|
|
SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|")
|
|
GvDatos.ExportToExcelGembox("CatMedicos", UsuarioActual, "Catálogo de Médicos", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString())
|
|
GvDatos.Columns(10).Visible = True
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
Protected Sub LnkComisiones_Click(sender As Object, e As EventArgs)
|
|
CargaComisiones()
|
|
RegistraScript("$('#DvModalComisiones').modal('show');")
|
|
End Sub
|
|
|
|
Private Sub CargaComisiones()
|
|
DTDatos = New DataTable
|
|
GvComisiones.DataSource = Nothing
|
|
|
|
Dim objVentas As New ClsVentas
|
|
|
|
If objVentas.GetComisionesMedicas(UsuarioActual.CveEmpresa) Then
|
|
GvComisiones.DataSource = objVentas.DtResultados
|
|
DTDatos = objVentas.DtResultados
|
|
End If
|
|
|
|
objVentas.Dispose()
|
|
|
|
GvComisiones.DataBind()
|
|
|
|
UpDvModalComisiones.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Sub BtnGuardarComisiones_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim objVentas As New ClsVentas
|
|
objVentas.IniciaTransacSQL()
|
|
|
|
Dim TieneError As Boolean = False
|
|
|
|
For Each GvRow As GridViewRow In GvComisiones.Rows
|
|
|
|
Dim CvePS As Integer = GvRow.DataKey("CvePS").ToEntero
|
|
Dim ComisionMedicoDT As Decimal = DTDatos.FiltroPrimeroValor("ComisionMedico", $"CvePS = {CvePS} ").ToDecimal
|
|
Dim ComisionVendedorDT As Decimal = DTDatos.FiltroPrimeroValor("ComisionVendedor", $"CvePS = {CvePS} ").ToDecimal
|
|
Dim ComisionTecnicoDT As Decimal = DTDatos.FiltroPrimeroValor("ComisionTecnico", $"CvePS = {CvePS} ").ToDecimal
|
|
|
|
Dim ComisionMedicoGV As Decimal = GvRow.FCTextBox("TxtComisionMedico").Text.ToDecimal
|
|
Dim ComisionVendedorGV As Decimal = GvRow.FCTextBox("TxtComisionVendedor").Text.ToDecimal
|
|
Dim ComisionTecnicoGV As Decimal = GvRow.FCTextBox("TxtComisionTecnico").Text.ToDecimal
|
|
|
|
If ComisionMedicoDT <> ComisionMedicoGV Or ComisionVendedorDT <> ComisionVendedorGV Or ComisionTecnicoDT <> ComisionTecnicoGV Then
|
|
If Not objVentas.AddUpdateComisionesMedicas(GvRow.DataKey("CvePS").ToEntero, UsuarioActual.CveEmpresa, ComisionMedicoGV, ComisionVendedorGV, ComisionTecnicoGV) Then
|
|
TieneError = True
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
If TieneError Then
|
|
objVentas.RollBack()
|
|
Else
|
|
objVentas.Commit()
|
|
Alert("Comisiones Actualizadas correctamente")
|
|
End If
|
|
|
|
objVentas.Dispose()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvComisiones_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.FCTextBox("TxtComisionMedico").Text.ToDecimal = 0 Then
|
|
e.Row.FCTextBox("TxtComisionMedico").Text = ""
|
|
End If
|
|
If e.Row.FCTextBox("TxtComisionVendedor").Text.ToDecimal = 0 Then
|
|
e.Row.FCTextBox("TxtComisionVendedor").Text = ""
|
|
End If
|
|
If e.Row.FCTextBox("TxtComisionTecnico").Text.ToDecimal = 0 Then
|
|
e.Row.FCTextBox("TxtComisionTecnico").Text = ""
|
|
End If
|
|
|
|
End If
|
|
|
|
End Sub
|
|
End Class
|