300 lines
9.0 KiB
VB.net
300 lines
9.0 KiB
VB.net
Imports System.Data
|
|
Imports System.Drawing
|
|
Imports Extensiones
|
|
Imports Microsoft.Owin.Security.Provider
|
|
Imports Microsoft.Reporting.WebForms
|
|
Partial Class Ventas_CatProcedimientoDetalle
|
|
Inherits ClsPaginas
|
|
#Region "Propiedades"
|
|
Private Property CveProcedimiento As Integer
|
|
Get
|
|
|
|
If ViewState("CveProcedimiento") Is Nothing Then
|
|
ViewState("CveProcedimiento") = -1
|
|
End If
|
|
|
|
Return ViewState("CveProcedimiento").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveProcedimiento") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveProcedimientoProducto As Integer
|
|
Get
|
|
|
|
If ViewState("CveProcedimientoProducto") Is Nothing Then
|
|
ViewState("CveProcedimientoProducto") = -1
|
|
End If
|
|
|
|
Return ViewState("CveProcedimientoProducto").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveProcedimientoProducto") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
CveProcedimiento = If(Request("CveProcedimiento") <> "", Request("CveProcedimiento").ToString.ToEntero, "-1".ToEntero)
|
|
|
|
If CveProcedimiento > 0 Then
|
|
|
|
CargaDatos()
|
|
CargaProductos()
|
|
CargaVentas()
|
|
TabProductos.Visible = True
|
|
TabVentas.Visible = True
|
|
LnkAgregarProducto.Visible = True
|
|
Else
|
|
ChkEstatus.Checked = True
|
|
End If
|
|
|
|
DdlProducto.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
|
|
|
|
If Not DdlProducto.UsaWebService AndAlso CType(DdlProducto.DataSource, DataTable) Is Nothing Then
|
|
DdlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2")
|
|
DdlProducto.DataBind()
|
|
DdlProducto.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaVentas()
|
|
|
|
|
|
Dim objVenta As New ClsVentas
|
|
|
|
If objVenta.GetProcedimientoVentas(CveProcedimiento, UsuarioActual.CveEmpresa) Then
|
|
GvVentas.DataSource = objVenta.DtResultados
|
|
End If
|
|
|
|
objVenta.Dispose()
|
|
|
|
GvVentas.DataBind()
|
|
|
|
UpTabVentas.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
|
|
|
|
If CveProcedimiento > 0 Then
|
|
|
|
Dim DTProcedimiento As New DataTable
|
|
Dim Objeto As New ClsVentas
|
|
If Objeto.GetProcedimientos(CveProcedimiento, UsuarioActual.CveEmpresa, -1) Then
|
|
|
|
DTProcedimiento = Objeto.DtResultados
|
|
|
|
If DTProcedimiento.Rows.Count > 0 Then
|
|
LblProcedimiento.Text = DTProcedimiento.FiltroPrimeroValor("Procedimiento")
|
|
TxtProcedimiento.Text = DTProcedimiento.FiltroPrimeroValor("Procedimiento")
|
|
|
|
ChkEstatus.Checked = Boolean.Parse(DTProcedimiento.FiltroPrimeroValor("Estatus"))
|
|
|
|
LblFecha.Text = DTProcedimiento.FiltroPrimeroValor("FechaIng").ToDate.ToShortDateString
|
|
LblUsuario.Text = DTProcedimiento.FiltroPrimeroValor("Usuario")
|
|
Else
|
|
Dim Liga As String = $"document.location.href=""/Ventas/CatProcedimientos.aspx"";"
|
|
Alert("El Procedimiento solicitado no existe.", TipoMensaje.MsgAdvertencia, Liga)
|
|
End If
|
|
|
|
Objeto.Dispose()
|
|
End If
|
|
Else
|
|
|
|
LblFechaAlta.Visible = False
|
|
LblUsuarioAlta.Visible = False
|
|
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
|
|
|
Dim ProcesoOK = False
|
|
Dim ObjVentas As New ClsVentas
|
|
|
|
|
|
If CveProcedimiento > 0 Then
|
|
If ObjVentas.UpdateProcedimiento(CveProcedimiento, TxtProcedimiento.Text.Trim, ChkEstatus.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
Alert($"Procedimiento Actualizado Correctamente.")
|
|
ProcesoOK = True
|
|
End If
|
|
Else
|
|
|
|
CveProcedimiento = ObjVentas.AddProcedimiento(TxtProcedimiento.Text.Trim, ChkEstatus.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveProcedimiento > 0 Then
|
|
ProcesoOK = True
|
|
TabProductos.Visible = True
|
|
TabVentas.Visible = True
|
|
LnkAgregarProducto.Visible = True
|
|
UpDatos.Update()
|
|
Alert($"Procedimiento Guardado Correctamente.")
|
|
End If
|
|
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
If ProcesoOK Then
|
|
|
|
'RegistraScript("$('#DVAgregarProcedimiento').modal('hide');")
|
|
CargaDatos()
|
|
CargaGlobal()
|
|
UpDatos.Update()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs)
|
|
|
|
'Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
'CveProcedimiento = GvRow.DataKey("CveProcedimiento").ToEntero
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
Dim ProcesoOK = False
|
|
|
|
If ObjVentas.RemoveProcedimiento(CveProcedimiento, UsuarioActual.CveEmpresa) Then
|
|
ProcesoOK = True
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
|
|
If ProcesoOK Then
|
|
CargaGlobal()
|
|
Dim Liga As String = $"document.location.href=""/Ventas/CatProcedimientos.aspx"";"
|
|
Alert("Procedimiento eliminando correctamente.", TipoMensaje.MsgInformacion, Liga)
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaGlobal()
|
|
GlobalDTProcedimientos(UsuarioActual.CveEmpresa) = Nothing
|
|
End Sub
|
|
|
|
Protected Sub LnkAgregarProducto_Click() Handles LnkAgregarProducto.Click
|
|
|
|
limpiarModal()
|
|
UpAgregar.Update()
|
|
RegistraScript("$('#ModalAgregar').modal()")
|
|
|
|
End Sub
|
|
|
|
Private Sub limpiarModal()
|
|
|
|
LtlTituloAgregar.Text = "Agregar Producto"
|
|
CveProcedimientoProducto = -1
|
|
DdlProducto.SelectedValue = "-1"
|
|
DdlProducto.SelectedText = ""
|
|
DVProdcutoEstatus.Visible = False
|
|
UpAgregar.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub LkAgregarProducto_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ProcesoOK As Boolean = False
|
|
|
|
Dim objVenta As New ClsVentas
|
|
|
|
If CveProcedimientoProducto > 0 Then
|
|
|
|
If objVenta.UpdateProcedimientoProducto(CveProcedimientoProducto, DdlProducto.SelectedValue.ToEntero, False, True, UsuarioActual.CveUsuario) Then
|
|
ProcesoOK = True
|
|
End If
|
|
|
|
Else
|
|
|
|
If objVenta.AddProcedimientoProducto(CveProcedimiento, DdlProducto.SelectedValue.ToEntero, False, True, UsuarioActual.CveUsuario) Then
|
|
ProcesoOK = True
|
|
End If
|
|
|
|
End If
|
|
|
|
objVenta.Dispose()
|
|
|
|
If ProcesoOK Then
|
|
RegistraScript("$('#ModalAgregar').modal('hide')")
|
|
|
|
Alert($"Producto {If(CveProcedimientoProducto > 0, "actualizado", "agregado")} correctamente.")
|
|
|
|
CargaProductos()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaProductos()
|
|
|
|
Dim objVenta As New ClsVentas
|
|
|
|
If objVenta.GetProcedimientoProducto(CveProcedimiento, -1, UsuarioActual.CveEmpresa) Then
|
|
GvProductos.DataSource = objVenta.DtResultados
|
|
End If
|
|
|
|
objVenta.Dispose()
|
|
|
|
GvProductos.DataBind()
|
|
|
|
UpTabProductos.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkEditarProducto_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
CveProcedimientoProducto = GvRow.DataKey("CveProcedimientoProducto").ToEntero
|
|
Dim CvePS As String = GvRow.DataKey("CvePS")
|
|
Dim CodigoPS As String = GvRow.DataKey("CodigoPS")
|
|
Dim Estatus As Boolean = Boolean.Parse(GvRow.DataKey("Estatus"))
|
|
|
|
DdlProducto.ddl.SelectedValueExist(CvePS)
|
|
DdlProducto.txtText.Value = CodigoPS
|
|
DdlProducto.txtValue.Value = CvePS
|
|
ChkEstatusProducto.Checked = Estatus
|
|
LtlTituloAgregar.Text = "Actualizar producto"
|
|
|
|
DVProdcutoEstatus.Visible = True
|
|
UpAgregar.Update()
|
|
|
|
RegistraScript("$('#ModalAgregar').modal()")
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkEliminarProducto_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
Dim CveProcedimientoProductoEliminar = GvRow.DataKey("CveProcedimientoProducto").ToEntero
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
Dim ProcesoOK = False
|
|
|
|
If ObjVentas.RemoveProcedimientoProducto(CveProcedimientoProductoEliminar, UsuarioActual.CveEmpresa) Then
|
|
ProcesoOK = True
|
|
End If
|
|
|
|
ObjVentas.Dispose()
|
|
|
|
If ProcesoOK Then
|
|
Alert("Producto eliminando correctamente.")
|
|
CargaProductos()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
End Class
|