Commit inicial Ventas Productivo
This commit is contained in:
205
Inventarios/Equivalencias.aspx.vb
Normal file
205
Inventarios/Equivalencias.aspx.vb
Normal file
@@ -0,0 +1,205 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
|
||||
Partial Class Inventarios_Equivalencias
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region "Propiedades"
|
||||
|
||||
Public Property DtEquivalencias() As DataTable
|
||||
Get
|
||||
Return CType(ViewState("dtEquivalencias"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("dtEquivalencias") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#End Region
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
inicializarTabla()
|
||||
InicializarListas()
|
||||
btAgregar.Enabled = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
#Region " INICIALIZA VALORES "
|
||||
Private Sub CargaClasificaciones()
|
||||
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
|
||||
DdlClasificacion.DataBind()
|
||||
End Sub
|
||||
Private Sub InicializarListas()
|
||||
'Llenar el dropdownlist de unidad de medida
|
||||
|
||||
ddlUnidad.DataSource = GlobalDTUnidadesMedida(UsuarioActual.CveEmpresa)
|
||||
ddlUnidad.DataBind()
|
||||
|
||||
'Llenar el dropdownlist de Productosy servicios
|
||||
ddlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
||||
|
||||
ddlProducto.Items.Insert(0, New ListItem("----", "0"))
|
||||
CargaClasificaciones()
|
||||
End Sub
|
||||
Protected Sub inicializarTabla()
|
||||
Dim dt As New DataTable
|
||||
|
||||
dt.Columns.Add("No")
|
||||
dt.Columns.Add("Cantidad")
|
||||
dt.Columns.Add("CveUnidadMedida", Type.GetType("System.Int32"))
|
||||
dt.Columns.Add("Unidad")
|
||||
dt.Columns.Add("Precio")
|
||||
dt.Columns.Add("Base")
|
||||
|
||||
Me.gvEquivalencias.DataSource = dt
|
||||
Me.gvEquivalencias.DataBind()
|
||||
Me.ViewState("dtEquivalencias") = dt
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
Protected Sub DdlClasificacion_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlClasificacion.SelectedIndexChanged
|
||||
If DdlClasificacion.SelectedValue = "-1" Then
|
||||
ddlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa)
|
||||
ddlProducto.DataBind()
|
||||
ddlProducto.Items.Insert(0, New ListItem("----", "-1"))
|
||||
Else
|
||||
ddlProducto.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa, CveClasificacion:=DdlClasificacion.SelectedValue.ToEntero)
|
||||
ddlProducto.DataBind()
|
||||
ddlProducto.Items.Insert(0, New ListItem("----", "-1"))
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub ddlProducto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlProducto.SelectedIndexChanged
|
||||
gvEquivalencias.EditIndex = -1
|
||||
|
||||
If ddlProducto.SelectedValue = "0" Then
|
||||
btAgregar.Enabled = False
|
||||
Else
|
||||
btAgregar.Enabled = True
|
||||
End If
|
||||
|
||||
If btAgregar.Text = "Editar" Then
|
||||
btAgregar.Text = "Agregar"
|
||||
btCancelar.Visible = False
|
||||
End If
|
||||
|
||||
CargaGV()
|
||||
|
||||
UPPEquiv.Update()
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
#Region " AGREGAR "
|
||||
Protected Sub btAgregar_Click(sender As Object, e As EventArgs) Handles btAgregar.Click
|
||||
Dim Precio As Double = txtPrecio.Text.ToDouble
|
||||
Dim CveUnidadMedida As Integer = ddlUnidad.SelectedValue.ToEntero
|
||||
Dim Cantidad As Decimal = txtCantidad.Text.ToDecimal
|
||||
|
||||
Dim psEquivalencias As New ClsProductosServicios
|
||||
If psEquivalencias.AddPSEquivalencias(ddlProducto.SelectedValue.ToEntero, CveUnidadMedida, Cantidad, False, Precio, 1) Then
|
||||
txtCantidad.Text = ""
|
||||
txtPrecio.Text = ""
|
||||
ddlUnidad.SelectedIndex = -1
|
||||
Alert("Equivalencia agrega con éxito.", TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
psEquivalencias.Dispose()
|
||||
|
||||
CargaGV()
|
||||
UPPEquiv.Update()
|
||||
|
||||
RecargaGlobal()
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " GV EQUIVALENCIAS "
|
||||
Private Sub CargaGV()
|
||||
Dim equivalencias As New ClsProductosServicios
|
||||
If equivalencias.GetPSEquivalencias(ddlProducto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
||||
DtEquivalencias = equivalencias.DtResultados
|
||||
gvEquivalencias.DataSource = DtEquivalencias
|
||||
gvEquivalencias.DataBind()
|
||||
End If
|
||||
equivalencias.Dispose()
|
||||
End Sub
|
||||
Protected Sub gvEquivalencias_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gvEquivalencias.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If CBool(e.Row.DBCampo("UnidadBase")) = True Then
|
||||
e.Row.FCLinkButton("imgE").Visible = False
|
||||
e.Row.FCLinkButton("imgD").Visible = False
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub gvEquivalencias_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles gvEquivalencias.RowDeleting
|
||||
Dim psEquivalencias As New ClsProductosServicios
|
||||
Dim CveUnidadMedida As Integer = gvEquivalencias.DataKeys(e.RowIndex)("CveUM").ToString().ToEntero ' dt.Rows(e.RowIndex).Item("CveUnidadMedida")
|
||||
|
||||
If psEquivalencias.RemovePSEquivalencias(ddlProducto.SelectedValue.ToEntero, CveUnidadMedida) Then
|
||||
gvEquivalencias.DataSource = psEquivalencias.DtResultados
|
||||
DtEquivalencias = psEquivalencias.DtResultados
|
||||
gvEquivalencias.DataBind()
|
||||
End If
|
||||
|
||||
psEquivalencias.Dispose()
|
||||
|
||||
RecargaGlobal()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub EditRow(ByVal sender As Object, ByVal e As GridViewEditEventArgs) Handles gvEquivalencias.RowEditing
|
||||
gvEquivalencias.EditIndex = e.NewEditIndex
|
||||
gvEquivalencias.DataSource = DtEquivalencias
|
||||
gvEquivalencias.DataBind()
|
||||
End Sub
|
||||
|
||||
Protected Sub CancelEdit(ByVal sender As Object, ByVal e As GridViewCancelEditEventArgs)
|
||||
gvEquivalencias.EditIndex = -1
|
||||
gvEquivalencias.DataSource = DtEquivalencias
|
||||
gvEquivalencias.DataBind()
|
||||
End Sub
|
||||
|
||||
Protected Sub gvEquivalencias_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles gvEquivalencias.RowUpdating
|
||||
Dim psEquivalencias As New ClsProductosServicios
|
||||
Dim Mensaje As String = ""
|
||||
Dim dt As DataTable
|
||||
Dim cantidad As Decimal = DirectCast(gvEquivalencias.Rows(e.RowIndex).FindControl("txtECantidad"), TextBox).Text.ToDecimal
|
||||
Dim precio As Double = DirectCast(gvEquivalencias.Rows(e.RowIndex).FindControl("txtEPrecio"), TextBox).Text.ToDouble
|
||||
Dim CveUnidadMedida As Integer = DtEquivalencias.Rows(e.RowIndex).Item("CveUM").ToString.ToEntero
|
||||
Dim CvePSE As Integer = ddlProducto.SelectedValue.ToEntero
|
||||
|
||||
If psEquivalencias.UpdatePSEquivalencias(CvePSE, CveUnidadMedida, cantidad, False, precio, UsuarioActual.CveUsuario) Then
|
||||
dt = psEquivalencias.DtResultados
|
||||
ViewState("dtEquivalencias") = dt
|
||||
gvEquivalencias.EditIndex = -1
|
||||
gvEquivalencias.DataSource = dt
|
||||
gvEquivalencias.DataBind()
|
||||
End If
|
||||
|
||||
psEquivalencias.Dispose()
|
||||
|
||||
RecargaGlobal()
|
||||
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " RECARGA GLOBAL "
|
||||
Private Sub RecargaGlobal()
|
||||
Dim equivalencias As New ClsProductosServicios
|
||||
If equivalencias.GetPSEquivalencias(-1, -1) Then
|
||||
GlobalDTProductosServiciosEquivalencias(-1, -1) = equivalencias.DtResultados
|
||||
End If
|
||||
equivalencias.Dispose()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user