Imports System.Data Imports Extensiones 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 tDTProv As DataTable Get Return If(IsNothing(ViewState("tDTProv")), Nothing, CType(ViewState("tDTProv"), DataTable)) End Get Set(value As DataTable) ViewState("tDTProv") = value End Set End Property Private Property tDTUsuario As DataTable Get Return If(IsNothing(ViewState("tDTUsuario")), Nothing, CType(ViewState("tDTUsuario"), DataTable)) End Get Set(value As DataTable) ViewState("tDTUsuario") = 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 If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then DivSelectiva.Visible = True CargaSelectivas() End If CargaDdlSubProyectos() CargaDdlClasificacion() CargDdlProveedor() CargaDdlProductosServicios() CargDdlAlmacen() CargaDdlUsuarios() CreaTmpClasificaciones() CreaTmpProductosServicios() CreaTmpAlmacen() CreaTmpProveedores() CreaTmpUsuario() CargaDatos(UsuarioActual.CveEmpresa) End If End Sub #Region "CARGAS" Private Sub CargaSelectivas() Using ObjPS As New ClsProductosServicios If ObjPS.GetSelectiva(-1, UsuarioActual.CveEmpresa) Then DdlSelectiva.DataSource = ObjPS.DtResultados End If End Using DdlSelectiva.DataBind() DdlSelectiva.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub 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, UsuarioActual.CveUsuario) Then dt = Inventario.DtResultados End If Inventario.Dispose() gvIF.DataSource = dt gvIF.EditIndex = -1 gvIF.Columns(1).HeaderText = LblSubProyecto.Text gvIF.DataBind() gvIF.Columns(6).Visible = UsuarioActual.TienePermisoProceso(178) End Sub Private Sub CargaGvAlmacen() Dim ObjInventario As New ClsInventarios() If ObjInventario.GetInventarioFisicoDetallesAlmacen(HdnID.Value.ToEntero, 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.ToEntero, 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.ToEntero, 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 CargaGvProveedores() Dim ObjInventario As New ClsInventarios() If ObjInventario.GetInventarioFisicoDetallesProveedores(HdnID.Value.ToEntero, UsuarioActual.CveEmpresa) Then GvProveedor.DataSource = ObjInventario.DtResultados.FiltraParametros("Incluye = 1") End If ObjInventario.Dispose() GvProveedor.DataBind() UpProveedor.Update() End Sub Private Sub CargaGvUsuarios() Dim ObjInventario As New ClsInventarios() If ObjInventario.GetInventarioFisicoDetallesUsuarios(HdnID.Value.ToEntero, UsuarioActual.CveEmpresa) Then gvUsuarios.DataSource = ObjInventario.DtResultados.FiltraParametros("Incluye = 1") End If ObjInventario.Dispose() gvUsuarios.DataBind() upUsuarios.Update() End Sub Private Sub CargaDdlSubProyectos() CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, LblSubProyecto) CargarCentrosDeCosto(Nothing, DdlFiltroSubProyecto, Nothing, LblFiltroSubProyecto) 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 Private Sub CargDdlProveedor() If (UsuarioActual.Empresa.Funcionalidad(105) = "1") Then DdlProveedor.setEsWebService(True) DdlProveedor.Attributes.Add("data-metodo", "getproveedores") DdlProveedor.SelectedText = "Todos" DdlProveedor.SelectedValue = "-1" Else DdlProveedor.setEsWebService(False) DdlProveedor.ddl.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) DdlProveedor.ddl.DataBind() DdlProveedor.ddl.Items.Insert(0, New ListItem("Todos", "-1")) End If End Sub Private Sub CargaDdlUsuarios() Dim FiltroAD() As String = {"CveUsuario", "Usuario", "Nombre", "Contraseña", "CveEmpresa", "Rol", "Correo", "Empresa", "CveRol"} DdlUsuarios.DataSource = GlobalDTUsuarios(-1, UsuarioActual.CveEmpresa).FiltraParametros(" Estatus =1", "Rol ASC", FiltroAD) DdlUsuarios.Items.Insert(0, New ListItem("Todos", "-1")) DdlUsuarios.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 BtnSelectiva_Click(sender As Object, e As EventArgs) Handles BtnSelectiva.Click If DdlSelectiva.SelectedValue = "-1" Then Alert("Tienes seleccionada la opcion 'Seleccione'.", TipoMensaje.MsgInformacion) GvPS.DataSource = Nothing GvPS.DataBind() tDTPS.Rows.Clear() Else If tDTPS IsNot Nothing Then tDTPS.Rows.Clear() End If Using ObjPS As New ClsProductosServicios If ObjPS.GetPSSelectiva(DdlSelectiva.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa) Then For Each RowPS As DataRow In ObjPS.DtResultados.Rows Dim Row As DataRow = tDTPS.NewRow Row("CvePS") = RowPS("CvePS") Row("CodigoPS") = RowPS("CodigoPS") tDTPS.Rows.Add(Row) Next End If End Using 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 "PROVEEDORES" Private Sub BtnAgregarProveedor_Click(sender As Object, e As EventArgs) Handles BtnAgregarProveedor.Click If DdlProveedor.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 = tDTProv.NewRow Row("CveProveedor") = DdlProveedor.SelectedValue.ToEntero Row("RazonSocial") = DdlProveedor.SelectedText tDTProv.Rows.Add(Row) GvProveedor.DataSource = tDTProv GvProveedor.DataBind() UpProveedor.Update() End If End Sub Private Sub CreaTmpProveedores() tDTProv = New DataTable tDTProv.Columns.Add("CveProveedor", GetType(Integer)) tDTProv.Columns.Add("RazonSocial", GetType(String)) tDTProv.Columns.Add("Incluye", GetType(Integer)) End Sub Protected Sub DeleteProveedor_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) tDTProv.Rows(GvRow.RowIndex.ToEntero).Delete() GvProveedor.DataSource = tDTProv GvProveedor.DataBind() UpProveedor.Update() End Sub #End Region #Region "USUARIOS" Private Sub btnAddUsuarios_Click(sender As Object, e As EventArgs) Handles btnAddUsuarios.Click If DdlUsuarios.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 = tDTUsuario.NewRow Row("CveUsuario") = DdlUsuarios.SelectedValue.ToEntero Row("Nombre") = DdlUsuarios.SelectedItem.ToString Row("Cerrado") = False Row("Bloqueado") = False tDTUsuario.Rows.Add(Row) gvUsuarios.DataSource = tDTUsuario gvUsuarios.DataBind() upUsuarios.Update() End If End Sub Private Sub CreaTmpUsuario() tDTUsuario = New DataTable tDTUsuario.Columns.Add("CveUsuario", GetType(Integer)) tDTUsuario.Columns.Add("Nombre", GetType(String)) tDTUsuario.Columns.Add("Incluye", GetType(Integer)) tDTUsuario.Columns.Add("Cerrado", GetType(Boolean)) tDTUsuario.Columns.Add("Bloqueado", GetType(Boolean)) End Sub Public Sub DeleteUsurios_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) tDTUsuario.Rows(GvRow.RowIndex.ToEntero).Delete() gvUsuarios.DataSource = tDTUsuario gvUsuarios.DataBind() upUsuarios.Update() End Sub Public Sub imgCerrar_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim Estado As Boolean = Convert.ToBoolean(tDTUsuario.Rows(GvRow.RowIndex.ToEntero).Item(3)) If Estado Then tDTUsuario.Rows(GvRow.RowIndex.ToEntero).Item(3) = False Else tDTUsuario.Rows(GvRow.RowIndex.ToEntero).Item(3) = True End If Dim ObjInventario As New ClsInventarios() Dim CveUsuario As Integer = tDTUsuario.Rows(GvRow.RowIndex.ToEntero).Item(0).ToString().ToEntero() Dim Cerrado As Boolean = Convert.ToBoolean(tDTUsuario.Rows(GvRow.RowIndex.ToEntero).Item(3)) Dim Bloqueado As Boolean = Convert.ToBoolean(tDTUsuario.Rows(GvRow.RowIndex.ToEntero).Item(4)) ObjInventario.UpdateInventarioFisicoUsuarios(HdnID.Value.ToEntero, CveUsuario, Cerrado, Bloqueado) gvUsuarios.DataSource = tDTUsuario gvUsuarios.DataBind() upUsuarios.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.ToEntero) 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) DdlProductosServicios.ddl.SelectedValueExist(-1) DdlProveedor.ddl.SelectedValueExist(-1) DdlPSExcluye.ddl.SelectedValueExist(-1) DdlClasificacion.SelectedValueExist(-1) DdlClasificacionExcluida.SelectedValueExist(-1) DdlUsuarios.SelectedValueExist(-1) tDTUsuario.Rows.Clear() tDTClasif.Rows.Clear() tDTClasifExcluye.Rows.Clear() tDTPS.Rows.Clear() tDTPSExcluye.Rows.Clear() tALM.Rows.Clear() gvUsuarios.DataSource = Nothing gvUsuarios.DataBind() 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") FechaFin = GvRow.DataKey("FechaFin") DdlSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto").ToEntero) chkUsarApp.Checked = Convert.ToBoolean(GvRow.DataKey("ConAplicacion").ToString) divUsuarios.Visible = chkUsarApp.Checked CargaGvAlmacen() CargaGvClasificacion() CargaGvProductosServicios() CargaGvProveedores() CargaGvUsuarios() tDTClasif = CType(GvClasificacion.DataSource, DataTable) tDTClasifExcluye = CType(GvClasificacionExcluida.DataSource, DataTable) tDTPS = CType(GvPS.DataSource, DataTable) tDTPSExcluye = CType(GvPSExcluye.DataSource, DataTable) tDTProv = CType(GvProveedor.DataSource, DataTable) tDTUsuario = CType(gvUsuarios.DataSource, DataTable) tALM = CType(GvAlmacen.DataSource, DataTable) 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() tDTProv.Rows.Clear() tDTUsuario.Rows.Clear() End If DdlProductosServicios.ddl.SelectedValueExist(-1) DdlPSExcluye.ddl.SelectedValueExist(-1) DdlProveedor.ddl.SelectedValueExist(-1) DdlUsuarios.SelectedValueExist(-1) DdlClasificacion.SelectedValueExist(-1) DdlClasificacionExcluida.SelectedValueExist(-1) 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() GvProveedor.DataSource = Nothing GvProveedor.DataBind() gvUsuarios.DataSource = Nothing gvUsuarios.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 Dim aplicacion As Boolean = chkUsarApp.Checked ObjInventario.IniciaTransacSQL() If HdnModalidad.Value = "A" Then If ObjInventario.AddInventarioFisico(UsuarioActual.CveEmpresa, TxtTitulo.Text, TxtObservaciones.Text, 0, DdlSubProyecto.SelectedValue.ToEntero, aplicacion) Then CveInventarioFisico = ObjInventario.CveInventarioFisico If CveInventarioFisico > 0 Then 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 Then For Each Gvr As GridViewRow In GvProveedor.Rows If Not ObjInventario.AddInventarioFisicoProveedores(CveInventarioFisico, Gvr.DataKey("CveProveedor").ToEntero, True) Then ErrorClasif = True Exit For End If Next End If If ErrorClasif = False Then For Each Gvr As GridViewRow In gvUsuarios.Rows If Not ObjInventario.AddInventarioFisicoUsuarios(CveInventarioFisico, Gvr.DataKey("CveUsuario").ToEntero, True, False, False) Then ErrorClasif = True Exit For End If Next End If Else ErrorClasif = False 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 HdnID.Value.ToEntero > 0 Then If ObjInventario.UpdateInventarioFisico(HdnID.Value.ToEntero, TxtTitulo.Text, TxtObservaciones.Text, DdlSubProyecto.SelectedValue.ToEntero, aplicacion) Then If Not ObjInventario.RemoveInventarioFisicoAlamacen(HdnID.Value.ToEntero) Then ErrorClasif = True End If If Not ObjInventario.RemoveInventarioFisicoClasificacion(HdnID.Value.ToEntero) Then ErrorClasif = True End If If Not ObjInventario.RemoveInventarioFisicoProductosServicios(HdnID.Value.ToEntero) Then ErrorClasif = True End If If Not ObjInventario.RemoveInventarioFisicoProveedores(HdnID.Value.ToEntero) Then ErrorClasif = True End If If Not ObjInventario.RemoveInventarioFisicoUsuarios(HdnID.Value.ToEntero) Then ErrorClasif = True End If If ErrorClasif = False Then For Each Gvr As GridViewRow In GvAlmacen.Rows If Not ObjInventario.AddInventarioFisicoAlmacenes(HdnID.Value.ToEntero, 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.ToEntero, 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.ToEntero, 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.ToEntero, 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.ToEntero, Gvr.DataKey("CvePS").ToEntero, False) Then ErrorClasif = True Exit For End If Next End If If ErrorClasif = False Then For Each Gvr As GridViewRow In GvProveedor.Rows If Not ObjInventario.AddInventarioFisicoProveedores(HdnID.Value.ToEntero, Gvr.DataKey("CveProveedor").ToEntero, True) Then ErrorClasif = True Exit For End If Next End If If ErrorClasif = False Then Dim cerrado As Boolean = False Dim bloqueado As Boolean = False For Each Gvr As GridViewRow In gvUsuarios.Rows cerrado = Convert.ToBoolean(Gvr.DataKey("Cerrado").ToString) bloqueado = Gvr.FCCheckBox("chkBloqueado").Checked If Not ObjInventario.AddInventarioFisicoUsuarios(HdnID.Value.ToEntero, Gvr.DataKey("CveUsuario").ToEntero, True, cerrado, bloqueado) Then ErrorClasif = True Exit For End If Next End If Else ErrorClasif = False End If If ErrorClasif = False And HdnID.Value.ToEntero > 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 ElseIf e.Row.DBCampo("CveEstatus") = "1" Then ' cuando es en proceso e.Row.FCHyperLink("HplDif").NavigateUrl = String.Format("/Inventarios/RepAnomalias.aspx?CveInventarioFisico={0}&EsAvance=1", e.Row.DBCampo("CveInventarioFisico")) ElseIf e.Row.DBCampo("CveEstatus") = "0" Then ' Nuevo e.Row.FCHyperLink("HplDif").Visible = False End If End If End Sub Protected Sub gvUsuarios_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvUsuarios.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If Convert.ToBoolean(e.Row.DBCampo("Bloqueado")) Then e.Row.FCCheckBox("chkBloqueado").Checked = True End If If Convert.ToBoolean(e.Row.DBCampo("Cerrado")) Then e.Row.FCLinkButton("imgCerrar").Text = "" Else e.Row.FCLinkButton("imgCerrar").Text = "" 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.ToEntero, UsuarioActual.CveUsuario) Then gvIF.DataSource = ObjInventario.DtResultados gvIF.DataBind() gvIF.Columns(1).HeaderText = LblSubProyecto.Text 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 Protected Sub chkUsarApp_CheckedChanged(sender As Object, e As EventArgs) Handles chkUsarApp.CheckedChanged If chkUsarApp.Checked Then divUsuarios.Visible = True Else divUsuarios.Visible = False End If End Sub End Class