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,322 @@
Option Explicit On
Imports System.Data
Imports Extensiones
Partial Class Inventarios_CatAlmacenes
Inherits ClsPaginas
#Region " PROPIEDADES"
Private Property DtCuentasContables As Data.DataTable
Get
Return CType(ViewState("DtCuentasContables"), DataTable)
End Get
Set(value As Data.DataTable)
ViewState("DtCuentasContables") = value
End Set
End Property
'Private Property DtSubProyectos As DataTable
' Get
' Return If(IsNothing(ViewState("DtSubProyectos")), Nothing, CType(ViewState("DtSubProyectos"), DataTable))
' End Get
' Set(value As DataTable)
' ViewState("DtSubProyectos") = value
' End Set
'End Property
'Private Property CveSucursal As Integer
' Get
' If ViewState("CveSucursal") Is Nothing Then
' Return -1
' Else
' Return ViewState("CveSucursal").ToString.ToEntero
' End If
' End Get
' Set(value As Integer)
' ViewState("CveSucursal") = value
' End Set
'End Property
#End Region
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
ViewState("Orden") = ""
CargaCuentasContables()
CargaSubProyectos()
CargaTipoAlmacen()
CargaDatos()
End If
End Sub
Public Sub CargaDatos()
Dim ObjAlmacen As New ClsInventarios
If ObjAlmacen.GetAlmacenes(-1, -1, UsuarioActual.CveEmpresa, -1) Then
GvDatos.DataSource = ObjAlmacen.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
Else
GvDatos.DataSource = Nothing
End If
GvDatos.DataBind()
ObjAlmacen.Dispose()
End Sub
#Region "C O M B O S"
Private Sub CargaSubProyectos()
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
DdlSubProyectoFiltro.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
DdlSubProyectoFiltro.DataBind()
DdlSubProyecto.DataBind()
End Sub
Private Sub CargaTipoAlmacen()
DdlTipoAlmacen.DataSource = GlobalDTTipoAlmacen(-1)
DdlTipoAlmacenFiltro.DataSource = GlobalDTTipoAlmacen(-1)
DdlTipoAlmacenFiltro.DataBind()
DdlTipoAlmacen.DataBind()
End Sub
Private Sub CargaCuentasContables()
Dim ObjContabilidad As New ClsContPAQi(UsuarioActual.Empresa)
'UsuarioActual.Empresa.Funcionalidad(208).ToEntero
If ObjContabilidad.GetCuentasRecursiva(UsuarioActual.Empresa.Funcionalidad(208).ToEntero, 1) Then
DtCuentasContables = ObjContabilidad.DtResultados
Else
DtCuentasContables = Nothing
End If
ObjContabilidad.Dispose()
DdlCuentasContables.DataSource = DtCuentasContables
DdlCuentasContables.DataBind()
UpAddAlmacen.Update()
End Sub
#End Region
#Region "G V D A T O S"
Protected Sub GvDatos_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
'If e.Row.RowIndex <= 1 Then
' e.Row.Cells(0).Width = Unit.Pixel(230)
' e.Row.Cells(1).Width = Unit.Pixel(170)
' e.Row.Cells(2).Width = Unit.Pixel(170)
' e.Row.Cells(3).Width = Unit.Pixel(100)
' e.Row.Cells(4).Width = Unit.Pixel(100)
' e.Row.Cells(5).Width = Unit.Pixel(65)
' e.Row.Cells(6).Width = Unit.Pixel(65)
' e.Row.Cells(7).Width = Unit.Pixel(65)
'End If
If e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal Then
'e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
'e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
'e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Center
'e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Center
'e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center
'e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Center
'e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Center
'e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Center
If e.Row.DBCampo("IdCtaContable").ToEntero > 0 Then
e.Row.FCLiteral("LtlCuentaContable").Text = DtCuentasContables.FiltroPrimeroValor("CtaCodigo", $"Id = {e.Row.DBCampo("IdCtaContable")}")
Else
e.Row.FCLiteral("LtlCuentaContable").Text = "Sin Cuenta"
End If
End If
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.FCLiteral("LtlInventariable").Text = "True" Then
e.Row.FCLiteral("LtlInventariable").Text = "Si"
Else
e.Row.FCLiteral("LtlInventariable").Text = "No"
End If
End If
'Cargar Combos al Editar
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
'e.Row.FCDropDownList("DdlSucursal").DataSource = GlobalDTSucursales.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
'e.Row.FCDropDownList("DdlSucursal").DataBind()
'e.Row.FCDropDownList("DdlSucursal").SelectedValue = e.Row.DBCampo("CveSucursal")
e.Row.FCDropDownList("DdlTipoAlmacen").DataSource = GlobalDTTipoAlmacen(-1)
e.Row.FCDropDownList("DdlTipoAlmacen").DataBind()
e.Row.FCDropDownList("DdlTipoAlmacen").SelectedValue = e.Row.DBCampo("CveTipoAlmacen")
e.Row.FCDropDownList("DdlCuentasContables").DataSource = DtCuentasContables
e.Row.FCDropDownList("DdlCuentasContables").DataBind()
e.Row.FCDropDownList("DdlCuentasContables").Items.Add(New ListItem("Seleccione", "-1"))
e.Row.FCDropDownList("DdlCuentasContables").SelectedValue = e.Row.DBCampo("IdCtaContable")
'e.Row.FCDropDownList("DdlModalidad").DataSource =
'e.Row.FCDropDownList("DdlModalidad").DataBind()
e.Row.FCDropDownList("DdlModalidad").Items.Add(New ListItem("Solo Existencia", "0"))
e.Row.FCDropDownList("DdlModalidad").Items.Add(New ListItem("Contable", "1"))
e.Row.FCDropDownList("DdlModalidad").SelectedValue = If(e.Row.DBCampo("Modalidad").ToString = "Contable", "1", "0")
End If
End If
End Sub
#End Region
#Region "O R D E N A M I E N T O"
'Private Sub OrdenaDatos()
' If (GvDatos.Rows.Count > 0) Then
' GvDatos.UseAccessibleHeader = True
' GvDatos.HeaderRow.TableSection = TableRowSection.TableHeader
' RegistraScript("OrdenarGV();")
' End If
'End Sub
#End Region
Private Sub RecargaGlobalAlmacenes()
Dim ObjAlmacen As New ClsInventarios
If ObjAlmacen.GetAlmacenes(-1, -1, -1, -1) Then
GlobalDTAlmacen(-1) = ObjAlmacen.DtResultados
End If
ObjAlmacen.Dispose()
End Sub
Private Sub RecargaGlobalAlmacenesUsuarios()
Dim ObjUsuarios As New ClsSisUsuarios
If ObjUsuarios.GetAlmacen(-1) Then
Application("GlobalDTAlmacenUsuarios") = ObjUsuarios.DtResultados
End If
ObjUsuarios.Dispose()
End Sub
'Private Sub CargaSucursal()
' DtSubProyectos = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("CveSubProyecto =" & DdlSubProyecto.SelectedValue.ToEntero)
' Dim dr As DataRow
' dr = DtSubProyectos(0)
' CveSucursal = dr("CveSucursal").ToString.ToEntero
'End Sub
Private Sub BtnAgregarAlmacen_Click(sender As Object, e As EventArgs) Handles BtnAgregarAlmacen.Click
'CargaSucursal()
Dim ObjAlmacen As New ClsInventarios
Dim TieneError = False
Dim Estatus = 0
If ChkEstatus.Checked Then Estatus = 1
Dim CuentaContable = DdlCuentasContables.SelectedValue.ToEntero
If divddlcc.Visible = False Then
CuentaContable = 0
End If
If HdnModalidad.Value = "A" Then
If ObjAlmacen.AddAlmacen(TxtAlmacen.Text.Trim, DdlTipoAlmacen.SelectedValue.ToEntero, CuentaContable, DdlModalidad.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CByte(DdlInventariable.SelectedValue), DdlSubProyecto.SelectedValue.ToEntero, TxtOrden.Text.ToEntero) Then
Alert("El nuevo Almacen se guardó correctamente.", TipoMensaje.MsgInformacion)
UpDatos.Update()
ViewState("DTAlmacenes") = ObjAlmacen.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddAlmacen"))
CargaDatos()
'OrdenaDatos()
Else
TieneError = True
End If
ElseIf ObjAlmacen.UpdateAlmacen(TxtAlmacen.Text.Trim, DdlTipoAlmacen.SelectedValue.ToEntero, CuentaContable, DdlModalidad.SelectedValue.ToEntero, (CByte(Estatus)), HdnID.Value.ToEntero, CByte(DdlInventariable.SelectedValue), DdlSubProyecto.SelectedValue.ToEntero, TxtOrden.Text.ToEntero) Then
Alert("El Almacen se actualizo correctamente.", TipoMensaje.MsgInformacion)
UpDatos.Update()
ViewState("DTAlmacenes") = ObjAlmacen.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddAlmacen"))
CargaDatos()
'OrdenaDatos()
End If
ObjAlmacen.Dispose()
RecargaGlobalAlmacenes()
RecargaGlobalAlmacenesUsuarios()
End Sub
Public Sub Agregar()
HdnModalidad.Value = "A"
UpDatos.Update()
If DdlModalidad.SelectedValue = 1 Then
DdlCuentasContables.Visible = True
End If
BtnAgregarAlmacen.Text = "Agregar"
myModalLabel.InnerText = "Agregar Almacen"
TxtAlmacen.Text = ""
TxtOrden.Text = ""
ChkEstatus.Checked = True
divEstatus.Visible = False
UpAddAlmacen.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddAlmacen"))
End Sub
Public Sub Delete_Click(sender As Object, e As EventArgs)
Dim ObjInv As New ClsInventarios()
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
HdnID.Value = GvRow.DataKey("CveAlmacen")
UpDatos.Update()
If ObjInv.RemoveAlmacen(HdnID.Value.ToEntero) Then
CargaDatos()
End If
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
ObjInv.Dispose()
UpDatos.Update()
End Sub
Public Sub Edit_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
HdnModalidad.Value = "U"
HdnID.Value = GvRow.DataKey("CveAlmacen")
UpDatos.Update()
BtnAgregarAlmacen.Text = "Actualizar"
myModalLabel.InnerText = "Actualizar Almacen"
DdlInventariable.SelectedValue = If((GvRow.DataKey("Inventariable")) = "True", 1, 0)
DdlModalidad.SelectedValue = If((GvRow.DataKey("Modalidad")) = "Solo Existencia", 0, 1)
divddlcc.Visible = If((DdlModalidad.SelectedValue) = 1, True, False)
DdlCuentasContables.SelectedValueExist(GvRow.DataKey("IdCtaContable"))
DdlSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto"))
DdlTipoAlmacen.SelectedValueExist(GvRow.DataKey("CveTipoAlmacen"))
TxtAlmacen.Text = GvRow.DataKey("Almacen")
TxtOrden.Text = GvRow.DataKey("Orden")
divEstatus.Visible = True
ChkEstatus.Checked = If((GvRow.DataKey("Estatus")) = "Activo", True, False)
UpAddAlmacen.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddAlmacen"))
End Sub
Private Sub LnkAlmacen_Click(sender As Object, e As EventArgs) Handles LnkAlmacen.Click
Agregar()
End Sub
Private Sub DdlModalidad_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlModalidad.SelectedIndexChanged
If DdlModalidad.SelectedValue = 1 Then
divddlcc.Visible = True
Else
divddlcc.Visible = False
End If
UpAddAlmacen.Update()
End Sub
Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
Dim ObjAlmacen As New ClsInventarios
If ObjAlmacen.GetAlmacenes(DdlTipoAlmacenFiltro.SelectedValue, DdlModalidadFiltro.SelectedValue, UsuarioActual.CveEmpresa, DdlSubProyectoFiltro.SelectedValue.ToEntero) Then
GvDatos.DataSource = ObjAlmacen.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
GvDatos.DataBind()
Else
GvDatos.DataSource = Nothing
End If
ObjAlmacen.Dispose()
UpDatos.Update()
'OrdenaDatos()
End Sub
End Class