504 lines
16 KiB
VB.net
504 lines
16 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports Extensiones
|
|
|
|
Partial Class Ventas_CatMedicos
|
|
Inherits ClsPaginas
|
|
|
|
Public Property CveMedico As Integer
|
|
Get
|
|
If ViewState("CveMedico") Is Nothing Then
|
|
ViewState("CveMedico") = -1
|
|
End If
|
|
Return ViewState("CveMedico").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMedico") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Public Property CveMedicoEspecialidad As Integer
|
|
Get
|
|
If ViewState("CveMedicoEspecialidad") Is Nothing Then
|
|
ViewState("CveMedicoEspecialidad") = -1
|
|
End If
|
|
Return ViewState("CveMedicoEspecialidad").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMedicoEspecialidad") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Public Property EsFrame As Boolean
|
|
Get
|
|
If ViewState("EsFrame") Is Nothing Then
|
|
ViewState("EsFrame") = False
|
|
End If
|
|
Return Boolean.Parse(ViewState("EsFrame").ToString)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EsFrame") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
|
|
If Not Page.IsPostBack Then
|
|
|
|
|
|
|
|
CargaCombos()
|
|
'CargaEspecialidad()
|
|
'CargaSubEspecialidad(-1)
|
|
|
|
|
|
CargaDatos()
|
|
BtnConsultar_Click(Nothing, Nothing)
|
|
|
|
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Public Sub CargaDatos()
|
|
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
|
|
If ObjVentas.GetMedicos(-1, UsuarioActual.CveEmpresa, -1) Then
|
|
|
|
If UsuarioActual.CveVendedor > 0 Then
|
|
GvDatos.DataSource = ObjVentas.DtResultados.FiltraParametros($" CveVendedor = {UsuarioActual.CveVendedor}")
|
|
Else
|
|
GvDatos.DataSource = ObjVentas.DtResultados
|
|
End If
|
|
|
|
|
|
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
GvDatos.DataBind()
|
|
|
|
ValidaExcelTab()
|
|
|
|
UpDatos.Update()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
'Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click
|
|
|
|
' Dim ProcesoOK = False
|
|
' Dim ObjVentas As New ClsVentas
|
|
|
|
|
|
' Dim Telefono As String = If(TxtTelefono.Text = "(___) ___-____", "", TxtTelefono.Text)
|
|
' Dim Celular As String = If(TxtCelular.Text = "(___) ___-____", "", TxtCelular.Text)
|
|
|
|
' If CveMedico > 0 Then
|
|
' If ObjVentas.UpdateMedico(CveMedico, TxtMedico.Text.Trim, TxtCedulaProfecional.Text.Trim, TxtFechaNacimiento.Text.ToDate, TxtNotas.Text.Trim, TxtDiasAtencion.Text.Trim, TxtHorario.Text.Trim, TxtLugar.Text.Trim, ChkEstatus.Checked,
|
|
' UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Telefono, TxtMail.Text, DdlEspecialidad.SelectedValue.ToEntero, Celular, TxtConsultorio.Text.Trim, DdlSubEspecialidad.SelectedValue.ToEntero, TxtTorre.Text.Trim) Then
|
|
' ProcesoOK = True
|
|
' End If
|
|
' Else
|
|
' If ObjVentas.AddMedico(TxtMedico.Text.Trim, TxtCedulaProfecional.Text.Trim, TxtFechaNacimiento.Text.ToDate, TxtNotas.Text.Trim, TxtDiasAtencion.Text.Trim, TxtHorario.Text.Trim, TxtLugar.Text.Trim, ChkEstatus.Checked, UsuarioActual.CveUsuario,
|
|
' UsuarioActual.CveEmpresa, Telefono, TxtMail.Text, DdlEspecialidad.SelectedValue.ToEntero, Celular, TxtConsultorio.Text.Trim, DdlSubEspecialidad.SelectedValue.ToEntero, TxtTorre.Text.Trim) > 0 Then
|
|
' ProcesoOK = True
|
|
' End If
|
|
' End If
|
|
|
|
' ObjVentas.Dispose()
|
|
|
|
' If ProcesoOK Then
|
|
' Alert($"Medico {If(CveMedico > 0, "Actualizado", "Guardado")} Correctamente.")
|
|
' RegistraScript("$('#DVAgregarMedico').modal('hide');")
|
|
' CargaDatos()
|
|
' CargaGlobal()
|
|
' UpDatos.Update()
|
|
' End If
|
|
|
|
|
|
|
|
|
|
'End Sub
|
|
|
|
#Region "G V D A T O S"
|
|
|
|
|
|
Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
CveMedico = GvRow.DataKey("CveMedico").ToEntero
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
Dim ProcesoOK = False
|
|
|
|
If ObjVentas.RemoveMedico(CveMedico, UsuarioActual.CveEmpresa) Then
|
|
ProcesoOK = True
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
|
|
If ProcesoOK Then
|
|
Alert("Medico eliminando correctamente.")
|
|
|
|
CargaDatos()
|
|
CargaGlobal()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "CARGA GLOBAL"
|
|
Private Sub CargaGlobal()
|
|
GlobalDTMedicos(UsuarioActual.CveEmpresa) = Nothing
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
Public Sub LnkAgregarMedico_Click(sender As Object, e As EventArgs)
|
|
|
|
AddMedicoControl.CveMedico = -1
|
|
AddMedicoControl.LimpiarControles()
|
|
UpModalAddMedico.Update()
|
|
RegistraScript("$('#DvModalAddMedico').modal({ backdrop: 'static', keyboard: false });")
|
|
End Sub
|
|
|
|
Public Sub Edit_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
CveMedico = GvRow.DataKey("CveMedico").ToEntero
|
|
|
|
AddMedicoControl.PreparaEdicion(CveMedico, GvRow.DataKey("Nombre"), GvRow.DataKey("Apellidos"), GvRow.DataKey("CedulaProfesional"), GvRow.DataKey("FechaNacimiento").ToDate(), GvRow.DataKey("Notas"),
|
|
Boolean.Parse(GvRow.DataKey("Estatus")), GvRow.DataKey("Mail"), GvRow.DataKey("Telefono"), GvRow.DataKey("Celular"), GvRow.DataKey("CveMedicoEspecialidad").ToEntero, GvRow.DataKey("CveMedicoSubEspecialidad").ToEntero,
|
|
GvRow.DataKey("FechaIng").ToDateTime, GvRow.DataKey("Usuario"), GvRow.DataKey("CveVendedor").ToEntero, CvePeriodoPago:=GvRow.DataKey("CvePeriodoPago").ToEntero)
|
|
|
|
|
|
|
|
|
|
|
|
'TxtMedico.Text = GvRow.DataKey("Medico")
|
|
'TxtCedulaProfecional.Text = GvRow.DataKey("CedulaProfesional")
|
|
'TxtFechaNacimiento.Text = GvRow.DataKey("FechaNacimiento").ToDate().ToString("dd/MM/yyyy")
|
|
'TxtNotas.Text = GvRow.DataKey("Notas")
|
|
'TxtDiasAtencion.Text = GvRow.DataKey("DiasAtencion")
|
|
'TxtHorario.Text = GvRow.DataKey("Horario")
|
|
'TxtLugar.Text = GvRow.DataKey("Lugar")
|
|
'TxtConsultorio.Text = GvRow.DataKey("Consultorio")
|
|
'ChkEstatus.Checked = Boolean.Parse(GvRow.DataKey("Estatus"))
|
|
'TxtMail.Text = GvRow.DataKey("Mail")
|
|
'TxtTelefono.Text = GvRow.DataKey("Telefono")
|
|
'TxtCelular.Text = GvRow.DataKey("Celular")
|
|
'DdlEspecialidad.SelectedValueExist(-1)
|
|
'DdlEspecialidad.SelectedValueExist(GvRow.DataKey("CveMedicoEspecialidad").ToEntero)
|
|
'CargaSubEspecialidad(GvRow.DataKey("CveMedicoEspecialidad").ToEntero)
|
|
'DdlSubEspecialidad.SelectedValueExist(GvRow.DataKey("CveMedicoSubEspecialidad").ToEntero)
|
|
'TxtTorre.Text = GvRow.DataKey("Torre")
|
|
|
|
'DVUsuarioFechaIng.Visible = True
|
|
'TxtFechaIng.Text = GvRow.DataKey("FechaIng").ToDateTime.ToString("dd/MM/yyyy hh:mm:ss tt")
|
|
'TxtUsuario.Text = GvRow.DataKey("Usuario")
|
|
|
|
'DVEstatus.Visible = True
|
|
'LbAgregar.Text = "Actualizar"
|
|
'LtlTituloModal.Text = $"Actualizar Médico {TxtCedulaProfecional.Text}"
|
|
|
|
'UpModal.Update()
|
|
UpModalAddMedico.Update()
|
|
RegistraScript("$('#DvModalAddMedico').modal({ backdrop: 'static', keyboard: false });")
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
#Region "INDICADORES"
|
|
|
|
Private Sub CargaCombos()
|
|
|
|
|
|
Dim EsWS As Boolean = If(UsuarioActual.Empresa.Funcionalidad(105) = "1" Or UsuarioActual.Empresa.Funcionalidad(141) = "1", True, False)
|
|
If EsWS Then
|
|
DdlClientes.setEsWebService(True)
|
|
Else
|
|
DdlClientes.setEsWebService(False)
|
|
DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa, -1)
|
|
DdlClientes.DataBind()
|
|
DdlClientes.ddl.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End If
|
|
|
|
|
|
|
|
txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString
|
|
txtFechaF.Text = NowADS().ToShortDateString
|
|
|
|
DdlMedico.DataSource = GlobalDTMedicos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")
|
|
DdlMedico.DataBind()
|
|
|
|
DdlProcedimiento.DataSource = GlobalDTProcedimientos(UsuarioActual.CveEmpresa).FiltraParametros("Estatus = 'True' ")
|
|
DdlProcedimiento.DataBind()
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
Dim objVentas As New ClsVentas
|
|
Dim CveVendedor As Integer = If(UsuarioActual.CveVendedor > 0, UsuarioActual.CveVendedor, -1)
|
|
Dim CveCliente As Integer = If(DdlClientes.SelectedValue.ToEntero > 0, DdlClientes.SelectedValue.ToEntero, -1)
|
|
|
|
If objVentas.GetVentasMedicasIndicadoresRep(DdlGrupo.SelectedValue.ToEntero, txtFechaI.Text.ToDate, txtFechaF.Text.ToDate, CveCliente, DdlMedico.SelectedValue.ToEntero, DdlProcedimiento.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, CveVendedor) Then
|
|
GvIndicadores.DataSource = objVentas.DtResultados
|
|
End If
|
|
|
|
objVentas.Dispose()
|
|
|
|
GvIndicadores.DataBind()
|
|
|
|
ValidaExcelTab()
|
|
|
|
UpIndicadores.Update()
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "EXCEL"
|
|
|
|
Private Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click
|
|
|
|
|
|
If Tabs.ActiveTabIndex = 0 Then
|
|
Dim SbFiltros As New StringBuilder()
|
|
SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|")
|
|
SbFiltros.Append($"Grupo:{DdlGrupo.SelectedItem.Text}, Médico: {DdlMedico.SelectedItem.Text}, Procedimiento: {DdlProcedimiento.SelectedItem.Text}")
|
|
GvIndicadores.ExportToExcelGembox("IndicadoresMedicos", UsuarioActual, "Indicadores Médicos", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString())
|
|
ElseIf Tabs.ActiveTabIndex = 1 Then
|
|
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
|
|
'ElseIf Tabs.ActiveTabIndex = 2 Then
|
|
' GvEspecialidad.Columns(4).Visible = False
|
|
' Dim SbFiltros As New StringBuilder()
|
|
' SbFiltros.AppendFormat($"Fecha Inicio: {txtFechaI.Text} Fecha Fin: {txtFechaF.Text}|")
|
|
' GvEspecialidad.ExportToExcelGembox("CatEspecialidades", UsuarioActual, "Catálogo de Especialidades", DatoTituloExtra:=$"", DatosFiltros:=SbFiltros.ToString())
|
|
'GvEspecialidad.Columns(4).Visible = True
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
|
|
End Sub
|
|
|
|
|
|
Sub ValidaExcelTab()
|
|
If Tabs.ActiveTabIndex = 0 Then
|
|
LnkExportar.Visible = GvDatos.Rows.Count > 0
|
|
Else
|
|
LnkExportar.Visible = GvIndicadores.Rows.Count > 0
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "CUMPLEAÑOS"
|
|
|
|
Private Sub CargaCyumpleAnios()
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
|
|
If ObjVentas.GetMedicos(-1, UsuarioActual.CveEmpresa, -1, DdlmesCumple.SelectedValue.ToEntero()) Then
|
|
GvCumple.DataSource = ObjVentas.DtResultados
|
|
Else
|
|
GvCumple.DataSource = Nothing
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
GvCumple.DataBind()
|
|
|
|
UpDVModalCumple.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkCumpleanios_Click(sender As Object, e As EventArgs)
|
|
|
|
DdlmesCumple.SelectedValueExist(NowADS.Month)
|
|
CargaCyumpleAnios()
|
|
RegistraScript("$('#DVModalCumple').modal();")
|
|
End Sub
|
|
|
|
Protected Sub btnConsultarcumpleAnios_Click(sender As Object, e As EventArgs)
|
|
CargaCyumpleAnios()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "Especialidad"
|
|
|
|
|
|
Protected Sub LnkAgregarEspecialidad_Click(sender As Object, e As EventArgs)
|
|
CveMedicoEspecialidad = -1
|
|
DVEstatusEspecialidad.Visible = False
|
|
LimpiarModalEspecialdiad()
|
|
RegistraScript("$('#DVAgregarEspecialidad').modal();")
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnAgergarEspecialidad_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
Dim ProcesoOK As Boolean = True
|
|
|
|
If CveMedicoEspecialidad > 0 Then
|
|
If Not ObjVentas.UpdateMedicoEspecialidad(CveMedicoEspecialidad, TxtEspecialidad.Text.Trim, ChkEstatusEspecialidad.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
ProcesoOK = False
|
|
End If
|
|
Else
|
|
If Not ObjVentas.AddMedicoEspecialidad(TxtEspecialidad.Text.Trim, True, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
ProcesoOK = False
|
|
End If
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
If ProcesoOK Then
|
|
'CargaEspecialidad()
|
|
Alert($"Especialidad {If(CveMedicoEspecialidad > 0, "actualizada", "agregada")} correctamente.")
|
|
RegistraScript("$('#DVAgregarEspecialidad').modal('hide');")
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Sub LimpiarModalEspecialdiad()
|
|
TxtEspecialidad.Text = ""
|
|
ChkEstatusEspecialidad.Checked = True
|
|
UpModalEspecialidad.Update()
|
|
End Sub
|
|
|
|
'Sub CargaEspecialidad()
|
|
' Dim ObjVentas As New ClsVentas
|
|
|
|
' If ObjVentas.GetMedicosEspecialidades(-1, UsuarioActual.CveEmpresa, -1) Then
|
|
' 'GvEspecialidad.DataSource = ObjVentas.DtResultados
|
|
' DdlEspecialidad.DataSource = ObjVentas.DtResultados
|
|
' Else
|
|
' 'GvEspecialidad.DataSource = Nothing
|
|
' End If
|
|
|
|
' ObjVentas.Dispose()
|
|
|
|
' 'GvEspecialidad.DataBind()
|
|
|
|
' DdlEspecialidad.DataBind()
|
|
' DdlEspecialidad.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
|
|
' UpModal.Update()
|
|
' 'UpEspecialidad.Update()
|
|
|
|
'End Sub
|
|
|
|
|
|
'Sub CargaSubEspecialidad(CveMedicoEspecialidad As Integer)
|
|
' Dim ObjVentas As New ClsVentas
|
|
|
|
' If ObjVentas.GetMedicosSubEspecialidades(-1, UsuarioActual.CveEmpresa, -1) Then
|
|
' If CveMedicoEspecialidad > 0 Then
|
|
' DdlSubEspecialidad.DataSource = ObjVentas.DtResultados.FiltraParametros($"CveMedicoEspecialidad = {CveMedicoEspecialidad}")
|
|
' Else
|
|
' DdlSubEspecialidad.DataSource = ObjVentas.DtResultados
|
|
' End If
|
|
' End If
|
|
|
|
' ObjVentas.Dispose()
|
|
|
|
' DdlSubEspecialidad.DataBind()
|
|
' DdlSubEspecialidad.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
' UpModal.Update()
|
|
|
|
'End Sub
|
|
|
|
Protected Sub LnkEditarEspecialidad_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
|
|
CveMedicoEspecialidad = GvRow.DataKey("CveMedicoEspecialidad").ToEntero
|
|
TxtEspecialidad.Text = GvRow.DataKey("Especialidad")
|
|
ChkEstatusEspecialidad.Checked = Boolean.Parse(GvRow.DataKey("Estatus").ToString)
|
|
DVEstatusEspecialidad.Visible = True
|
|
UpModalEspecialidad.Update()
|
|
|
|
RegistraScript("$('#DVAgregarEspecialidad').modal();")
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkEliminarEspecialidad_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ProcesoOK As Boolean = True
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
Dim CveMedicoEspecialidadEliminar As Integer = GvRow.DataKey("CveMedicoEspecialidad").ToEntero
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
|
|
If Not ObjVentas.RemoveMedicoEspecialidad(CveMedicoEspecialidadEliminar, UsuarioActual.CveEmpresa) Then
|
|
ProcesoOK = False
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
If ProcesoOK Then
|
|
'CargaEspecialidad()
|
|
Alert("Especialidad eliminada correctamente")
|
|
End If
|
|
|
|
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
'Protected Sub DdlEspecialidad_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
' CargaSubEspecialidad(DdlEspecialidad.SelectedValue.ToEntero)
|
|
'End Sub
|
|
|
|
|
|
Protected Sub BtnRecargaMedicos_Click(sender As Object, e As EventArgs)
|
|
CargaDatos()
|
|
End Sub
|
|
|
|
|
|
End Class
|