Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

View File

@@ -0,0 +1,573 @@
Imports Extensiones
Imports System.Data
Partial Class Inventarios_InventarioFisico
Inherits ClsPaginas
#Region "PROPIEDADES"
Public Property DtEquivalencias() As DataTable
Get
Return CType(ViewState("dtIF"), DataTable)
End Get
Set(value As DataTable)
ViewState("dtIF") = value
End Set
End Property
Private Property tDTClasif As DataTable
Get
Return If(IsNothing(ViewState("tDTClasif")), Nothing, CType(ViewState("tDTClasif"), DataTable))
End Get
Set(value As DataTable)
ViewState("tDTClasif") = value
End Set
End Property
Private Property tDTClasifExcluye As DataTable
Get
Return If(IsNothing(ViewState("tDTClasifExcluye")), Nothing, CType(ViewState("tDTClasifExcluye"), DataTable))
End Get
Set(value As DataTable)
ViewState("tDTClasifExcluye") = value
End Set
End Property
Private Property tDTPS As DataTable
Get
Return If(IsNothing(ViewState("tDTPS")), Nothing, CType(ViewState("tDTPS"), DataTable))
End Get
Set(value As DataTable)
ViewState("tDTPS") = value
End Set
End Property
Private Property tDTPSExcluye As DataTable
Get
Return If(IsNothing(ViewState("tDTPSExcluye")), Nothing, CType(ViewState("tDTPSExcluye"), DataTable))
End Get
Set(value As DataTable)
ViewState("tDTPSExcluye") = value
End Set
End Property
Private Property tALM As DataTable
Get
Return If(IsNothing(ViewState("tALM")), Nothing, CType(ViewState("tALM"), DataTable))
End Get
Set(value As DataTable)
ViewState("tALM") = value
End Set
End Property
Property FechaInicio As String
Property FechaFin As String
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
CargaDdlSubProyectos()
CargaDdlClasificacion()
CargaDdlProductosServicios()
CargDdlAlmacen()
CreaTmpClasificaciones()
CreaTmpProductosServicios()
CreaTmpAlmacen()
CargaDatos(UsuarioActual.CveEmpresa)
End If
End Sub
#Region "CARGAS"
Private Sub CargaDatos(CveEmpresa As Integer)
Dim Inventario As New ClsInventarios
Dim dt As New DataTable
If Inventario.GetInventarioFisico(-1, CveEmpresa, DdlFiltroSubProyecto.SelectedValue.ToEntero, DdlEstado.SelectedValue.ToEntero) Then
dt = Inventario.DtResultados
End If
Inventario.Dispose()
gvIF.DataSource = dt
gvIF.EditIndex = -1
gvIF.DataBind()
gvIF.Columns(6).Visible = UsuarioActual.TienePermisoProceso(178)
End Sub
Private Sub CargaGvAlmacen()
Dim ObjInventario As New ClsInventarios()
If ObjInventario.GetInventarioFisicoDetallesAlmacen(HdnID.Value, UsuarioActual.CveEmpresa) Then
GvAlmacen.DataSource = ObjInventario.DtResultados
GvAlmacen.DataBind()
End If
ObjInventario.Dispose()
UpSubProyecto.Update()
End Sub
Private Sub CargaGvClasificacion()
Dim ObjInventario As New ClsInventarios()
If ObjInventario.GetInventarioFisicoDetallesClasificacion(HdnID.Value, UsuarioActual.CveEmpresa) Then
GvClasificacion.DataSource = ObjInventario.DtResultados.FiltraParametros("Incluye = 1")
GvClasificacionExcluida.DataSource = ObjInventario.DtResultados.FiltraParametros("Incluye = 0")
End If
ObjInventario.Dispose()
GvClasificacion.DataBind()
GvClasificacionExcluida.DataBind()
UpClasificacionExcluida.Update()
UpClasificacion.Update()
End Sub
Private Sub CargaGvProductosServicios()
Dim ObjInventario As New ClsInventarios()
If ObjInventario.GetInventarioFisicoDetallesProductosServicios(HdnID.Value, UsuarioActual.CveEmpresa) Then
GvPS.DataSource = ObjInventario.DtResultados.FiltraParametros("Incluye = 1")
GvPSExcluye.DataSource = ObjInventario.DtResultados.FiltraParametros("Incluye = 0")
End If
ObjInventario.Dispose()
GvPS.DataBind()
GvPSExcluye.DataBind()
UpProductosServicios.Update()
UPPPSExcluye.Update()
End Sub
Private Sub CargaDdlSubProyectos()
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
DdlSubProyecto.DataBind()
DdlFiltroSubProyecto.Items.Insert(0, New ListItem("Todas", "-1"))
DdlFiltroSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
DdlFiltroSubProyecto.DataBind()
End Sub
Private Sub CargaDdlClasificacion()
DdlClasificacion.Items.Insert(0, New ListItem("Todos", "-1"))
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("UsoClasificacion IN (1,3)")
DdlClasificacion.DataBind()
DdlClasificacionExcluida.Items.Insert(0, New ListItem("Todos", "-1"))
DdlClasificacionExcluida.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltraParametros("UsoClasificacion IN (1,3)")
DdlClasificacionExcluida.DataBind()
End Sub
Private Sub CargaDdlProductosServicios()
DdlProductosServicios.setEsWebService(True)
DdlProductosServicios.ddlWS.Attributes.Add("data-cveclasificacion", "-1")
DdlProductosServicios.SelectedText = "Todos"
DdlProductosServicios.SelectedValue = "-1"
DdlPSExcluye.setEsWebService(True)
DdlPSExcluye.ddlWS.Attributes.Add("data-cveclasificacion", "-1")
DdlPSExcluye.SelectedText = "Todos"
DdlPSExcluye.SelectedValue = "-1"
End Sub
Private Sub CargDdlAlmacen()
DdlAlmacen.Items.Clear()
DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa).FiltraParametros($"CveSubProyecto ={DdlSubProyecto.SelectedValue} AND Inventariable= 'True'")
DdlAlmacen.DataBind()
End Sub
#End Region
#Region "PRODUCTOS SERVICIOS"
Public Sub DeleteProductosServicios_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
tDTPS.Rows(GvRow.RowIndex.ToEntero).Delete()
GvPS.DataSource = tDTPS
GvPS.DataBind()
UpProductosServicios.Update()
End Sub
Public Sub DeleteProductosServiciosExcluye_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
tDTPSExcluye.Rows(GvRow.RowIndex.ToEntero).Delete()
GvPSExcluye.DataSource = tDTPSExcluye
GvPSExcluye.DataBind()
UPPPSExcluye.Update()
End Sub
Private Sub BtnAgregarProductosServicios_Click(sender As Object, e As EventArgs) Handles BtnAgregarProductosServicios.Click
If DdlProductosServicios.SelectedValue = -1 Then
Alert("Tienes seleccionada la opcion 'Todos'.", TipoMensaje.MsgInformacion)
GvPS.DataSource = Nothing
GvPS.DataBind()
tDTPS.Rows.Clear()
Else
Dim Row As DataRow = Nothing
Row = tDTPS.NewRow
Row("CvePS") = DdlProductosServicios.SelectedValue.ToEntero
Row("CodigoPS") = DdlProductosServicios.SelectedText
tDTPS.Rows.Add(Row)
GvPS.DataSource = tDTPS
GvPS.DataBind()
UpProductosServicios.Update()
End If
End Sub
Private Sub BtnAddPSExcluye_Click(sender As Object, e As EventArgs) Handles BtnAddPSExcluye.Click
If DdlPSExcluye.SelectedValue = -1 Then
Alert("Tienes seleccionada la opcion 'Todos'.", TipoMensaje.MsgInformacion)
GvPSExcluye.DataSource = Nothing
GvPSExcluye.DataBind()
tDTPSExcluye.Rows.Clear()
Else
Dim Row As DataRow = Nothing
Row = tDTPSExcluye.NewRow
Row("CvePS") = DdlPSExcluye.SelectedValue.ToEntero
Row("CodigoPS") = DdlPSExcluye.SelectedText
tDTPSExcluye.Rows.Add(Row)
GvPSExcluye.DataSource = tDTPSExcluye
GvPSExcluye.DataBind()
UPPPSExcluye.Update()
End If
End Sub
Private Sub CreaTmpProductosServicios()
tDTPS = New DataTable
tDTPS.Columns.Add("CvePS", GetType(Integer))
tDTPS.Columns.Add("CodigoPS", GetType(String))
tDTPS.Columns.Add("Incluye", GetType(Integer))
tDTPSExcluye = New DataTable
tDTPSExcluye.Columns.Add("CvePS", GetType(Integer))
tDTPSExcluye.Columns.Add("CodigoPS", GetType(String))
tDTPSExcluye.Columns.Add("Incluye", GetType(Integer))
End Sub
#End Region
#Region "CLASIFICACIONES"
Public Sub DeleteClasificacion_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
tDTClasif.Rows(GvRow.RowIndex.ToEntero).Delete()
GvClasificacion.DataSource = tDTClasif
GvClasificacion.DataBind()
UpClasificacion.Update()
End Sub
Private Sub BtnAgregarClasificaciones_Click(sender As Object, e As EventArgs) Handles BtnAgregarClasificaciones.Click
If DdlClasificacion.SelectedValue = -1 Then
Alert("Tienes seleccionada la opcion 'Todos'.", TipoMensaje.MsgInformacion)
GvClasificacion.DataSource = Nothing
GvClasificacion.DataBind()
tDTClasif.Rows.Clear()
Else
Dim Row As DataRow = Nothing
Row = tDTClasif.NewRow
Row("CveClasificacion") = DdlClasificacion.SelectedValue.ToEntero
Row("Clasificacion") = DdlClasificacion.SelectedItem.Text
tDTClasif.Rows.Add(Row)
GvClasificacion.DataSource = tDTClasif
GvClasificacion.DataBind()
UpClasificacion.Update()
End If
End Sub
Private Sub CreaTmpClasificaciones()
tDTClasif = New DataTable
tDTClasif.Columns.Add("CveClasificacion", GetType(Integer))
tDTClasif.Columns.Add("Clasificacion", GetType(String))
tDTClasif.Columns.Add("Incluye", GetType(Integer))
tDTClasifExcluye = New DataTable
tDTClasifExcluye.Columns.Add("CveClasificacion", GetType(Integer))
tDTClasifExcluye.Columns.Add("Clasificacion", GetType(String))
tDTClasifExcluye.Columns.Add("Incluye", GetType(Integer))
End Sub
Protected Sub BtnClasificacionExcluida_Click(sender As Object, e As EventArgs)
If DdlClasificacionExcluida.SelectedValue = -1 Then
Alert("Tienes seleccionada la opcion 'Todos'.", TipoMensaje.MsgInformacion)
GvClasificacionExcluida.DataSource = Nothing
GvClasificacionExcluida.DataBind()
tDTClasifExcluye.Rows.Clear()
Else
Dim Row As DataRow = Nothing
Row = tDTClasifExcluye.NewRow
Row("CveClasificacion") = DdlClasificacionExcluida.SelectedValue.ToEntero
Row("Clasificacion") = DdlClasificacionExcluida.SelectedItem.Text
tDTClasifExcluye.Rows.Add(Row)
GvClasificacionExcluida.DataSource = tDTClasifExcluye
GvClasificacionExcluida.DataBind()
UpClasificacionExcluida.Update()
End If
End Sub
Protected Sub LnkEliminarClasificacionExcluida_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
tDTClasifExcluye.Rows(GvRow.RowIndex.ToEntero).Delete()
GvClasificacionExcluida.DataSource = tDTClasifExcluye
GvClasificacionExcluida.DataBind()
UpClasificacionExcluida.Update()
End Sub
#End Region
#Region "INVENTARIO FISICO"
Public Sub Delete_Click(sender As Object, e As EventArgs)
Dim ObjInventario As New ClsInventarios()
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
HdnID.Value = GvRow.DataKey("CveInventarioFisico")
UppInventarioFisico.Update()
If ObjInventario.RemoveInventarioFisico(HdnID.Value) Then
CargaDatos(UsuarioActual.CveEmpresa)
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
End If
ObjInventario.Dispose()
UppInventarioFisico.Update()
End Sub
Public Sub Edit_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
tDTClasif.Rows.Clear()
tDTClasifExcluye.Rows.Clear()
tDTPS.Rows.Clear()
tDTPSExcluye.Rows.Clear()
tALM.Rows.Clear()
GvAlmacen.DataSource = Nothing
GvAlmacen.DataBind()
GvClasificacion.DataSource = Nothing
GvClasificacion.DataBind()
GvClasificacionExcluida.DataSource = Nothing
GvClasificacionExcluida.DataBind()
GvPS.DataSource = Nothing
GvPS.DataBind()
HdnModalidad.Value = "U"
HdnID.Value = GvRow.DataKey("CveInventarioFisico")
UppInventarioFisico.Update()
BtnAgregarInventarioFisico.Text = "Actualizar"
myModalLabel.InnerText = "Actualizar Inventario Fisico"
TxtTitulo.Text = GvRow.DataKey("InventarioFisico")
TxtObservaciones.Text = GvRow.DataKey("Observaciones")
FechaInicio = GvRow.DataKey("FechaInicio").ToEntero
FechaFin = GvRow.DataKey("FechaFin").ToEntero
DdlSubProyecto.SelectedValue = GvRow.DataKey("CveSubProyecto").ToEntero
CargaGvAlmacen()
CargaGvClasificacion()
CargaGvProductosServicios()
tDTClasif = GvClasificacion.DataSource
tDTClasifExcluye = GvClasificacionExcluida.DataSource
tDTPS = GvPS.DataSource
tDTPSExcluye = GvPSExcluye.DataSource
tALM = GvAlmacen.DataSource
UpAddInventarioFisico.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddInventarioFisico"))
End Sub
Private Sub LnkInventarioFisico_Click(sender As Object, e As EventArgs) Handles LnkInventarioFisico.Click
Agregar()
End Sub
Public Sub Agregar()
If tDTClasif IsNot Nothing AndAlso tDTPS IsNot Nothing Then
tDTClasif.Rows.Clear()
tDTPS.Rows.Clear()
tDTPSExcluye.Rows.Clear()
tDTClasifExcluye.Rows.Clear()
tALM.Rows.Clear()
End If
HdnModalidad.Value = "A"
UppInventarioFisico.Update()
BtnAgregarInventarioFisico.Text = "Agregar"
myModalLabel.InnerText = "Agregar Inventario Fisico"
TxtTitulo.Text = ""
TxtObservaciones.Text = ""
GvAlmacen.DataSource = Nothing
GvAlmacen.DataBind()
GvClasificacion.DataSource = Nothing
GvClasificacion.DataBind()
GvClasificacionExcluida.DataSource = Nothing
GvClasificacionExcluida.DataBind()
GvPS.DataSource = Nothing
GvPS.DataBind()
GvPSExcluye.DataSource = Nothing
GvPSExcluye.DataBind()
UpAddInventarioFisico.Update()
RegistraScript("$('#divAddInventarioFisico').modal('show');")
End Sub
Private Sub BtnAgregarInventarioFisico_Click(sender As Object, e As EventArgs) Handles BtnAgregarInventarioFisico.Click
'verificar almacen
If GvAlmacen.Rows.Count = 0 Then Alert("Favor de especificar cuando menos un almacen", TipoMensaje.MsgAdvertencia) : Exit Sub
Dim ErrorClasif As Boolean = False
Dim ObjInventario As New ClsInventarios
Dim CveInventarioFisico As Integer
ObjInventario.IniciaTransacSQL()
If HdnModalidad.Value = "A" Then
If ObjInventario.AddInventarioFisico(UsuarioActual.CveEmpresa, TxtTitulo.Text, TxtObservaciones.Text, 0, DdlSubProyecto.SelectedValue.ToEntero) Then
CveInventarioFisico = ObjInventario.CveInventarioFisico
For Each Gvr As GridViewRow In GvAlmacen.Rows
If Not ObjInventario.AddInventarioFisicoAlmacenes(CveInventarioFisico, Gvr.DataKey("CveAlmacen").ToEntero) Then
ErrorClasif = True
Exit For
End If
Next
If ErrorClasif = False Then
For Each Gvr As GridViewRow In GvClasificacion.Rows
If Not ObjInventario.AddInventarioFisicoClasificaciones(CveInventarioFisico, Gvr.DataKey("CveClasificacion").ToEntero, UsuarioActual.CveUsuario, True) Then
ErrorClasif = True
Exit For
End If
Next
For Each Gvr As GridViewRow In GvClasificacionExcluida.Rows
If Not ObjInventario.AddInventarioFisicoClasificaciones(CveInventarioFisico, Gvr.DataKey("CveClasificacion").ToEntero, UsuarioActual.CveUsuario, False) Then
ErrorClasif = True
Exit For
End If
Next
End If
If ErrorClasif = False Then
For Each Gvr As GridViewRow In GvPS.Rows
If Not ObjInventario.AddInventarioFisicoProductosServicios(CveInventarioFisico, Gvr.DataKey("CvePS").ToEntero, True) Then
ErrorClasif = True
Exit For
End If
Next
For Each Gvr As GridViewRow In GvPSExcluye.Rows
If Not ObjInventario.AddInventarioFisicoProductosServicios(CveInventarioFisico, Gvr.DataKey("CvePS").ToEntero, False) Then
ErrorClasif = True
Exit For
End If
Next
End If
If ErrorClasif = False And CveInventarioFisico > 0 Then
ObjInventario.Commit()
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddInventarioFisico"))
CargaDatos(UsuarioActual.CveEmpresa)
UppInventarioFisico.Update()
Else
ObjInventario.RollBack()
End If
End If
Else
If ObjInventario.UpdateInventarioFisico(HdnID.Value, TxtTitulo.Text, TxtObservaciones.Text, DdlSubProyecto.SelectedValue.ToEntero) Then
If Not ObjInventario.RemoveInventarioFisicoAlamacen(HdnID.Value) Then
ErrorClasif = True
End If
If Not ObjInventario.RemoveInventarioFisicoClasificacion(HdnID.Value) Then
ErrorClasif = True
End If
If Not ObjInventario.RemoveInventarioFisicoProductosServicios(HdnID.Value) Then
ErrorClasif = True
End If
If ErrorClasif = False Then
For Each Gvr As GridViewRow In GvAlmacen.Rows
If Not ObjInventario.AddInventarioFisicoAlmacenes(HdnID.Value, Gvr.DataKey("CveAlmacen").ToEntero) Then
ErrorClasif = True
Exit For
End If
Next
End If
If ErrorClasif = False Then
For Each Gvr As GridViewRow In GvClasificacion.Rows
If Not ObjInventario.AddInventarioFisicoClasificaciones(HdnID.Value, Gvr.DataKey("CveClasificacion").ToEntero, UsuarioActual.CveUsuario, True) Then
ErrorClasif = True
Exit For
End If
Next
For Each Gvr As GridViewRow In GvClasificacionExcluida.Rows
If Not ObjInventario.AddInventarioFisicoClasificaciones(HdnID.Value, Gvr.DataKey("CveClasificacion").ToEntero, UsuarioActual.CveUsuario, False) Then
ErrorClasif = True
Exit For
End If
Next
End If
If ErrorClasif = False Then
For Each Gvr As GridViewRow In GvPS.Rows
If Not ObjInventario.AddInventarioFisicoProductosServicios(HdnID.Value, Gvr.DataKey("CvePS").ToEntero, True) Then
ErrorClasif = True
Exit For
End If
Next
For Each Gvr As GridViewRow In GvPSExcluye.Rows
If Not ObjInventario.AddInventarioFisicoProductosServicios(HdnID.Value, Gvr.DataKey("CvePS").ToEntero, False) Then
ErrorClasif = True
Exit For
End If
Next
End If
If ErrorClasif = False And HdnID.Value > 0 Then
ObjInventario.Commit()
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddInventarioFisico"))
CargaDatos(UsuarioActual.CveEmpresa)
UppInventarioFisico.Update()
Else
ObjInventario.RollBack()
End If
End If
End If
End Sub
Protected Sub gvIF_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvIF.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("CveEstatus") = "3" Then
e.Row.FCLinkButton("imgE").Visible = False
e.Row.FCLinkButton("imgD").Visible = False
End If
End If
End Sub
#End Region
#Region "ALMACEN"
Public Sub DeleteAlmacen_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
tALM.Rows(GvRow.RowIndex.ToEntero).Delete()
GvAlmacen.DataSource = tALM
GvAlmacen.DataBind()
UpSubProyecto.Update()
End Sub
Private Sub BtnAgregarAlmacen_Click(sender As Object, e As EventArgs) Handles BtnAgregarAlmacen.Click
Dim Row As DataRow = Nothing
Row = tALM.NewRow
Row("CveAlmacen") = DdlAlmacen.SelectedValue.ToEntero
Row("Almacen") = DdlAlmacen.SelectedItem.Text
tALM.Rows.Add(Row)
GvAlmacen.DataSource = tALM
GvAlmacen.DataBind()
UpSubProyecto.Update()
End Sub
Private Sub CreaTmpAlmacen()
tALM = New DataTable
tALM.Columns.Add("CveAlmacen", GetType(Integer))
tALM.Columns.Add("Almacen", GetType(String))
End Sub
#End Region
#Region "CONSULTA"
Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
Dim ObjInventario As New ClsInventarios
If ObjInventario.GetInventarioFisico(-1, UsuarioActual.CveEmpresa, DdlFiltroSubProyecto.SelectedValue.ToEntero, DdlEstado.SelectedValue) Then
gvIF.DataSource = ObjInventario.DtResultados
gvIF.DataBind()
End If
UppInventarioFisico.Update()
ObjInventario.Dispose()
End Sub
#End Region
#Region "SELECTED INDEX CHANGE"
Private Sub DdlSubProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubProyecto.SelectedIndexChanged
CargDdlAlmacen()
GvAlmacen.DataSource = Nothing
GvAlmacen.DataBind()
tALM.Rows.Clear()
UpSubProyecto.Update()
End Sub
#End Region
End Class