233 lines
6.6 KiB
VB.net
233 lines
6.6 KiB
VB.net
Imports Extensiones
|
|
Partial Class Inventarios_RegRSCO
|
|
Inherits ClsPaginas
|
|
|
|
Private Property CveCompuestoVigencia As Integer
|
|
Get
|
|
|
|
If ViewState("CveCompuestoVigencia") Is Nothing Then
|
|
Return -1
|
|
Else
|
|
Return ViewState("CveCompuestoVigencia").ToString().ToEntero()
|
|
End If
|
|
End Get
|
|
Set(ByVal value As Integer)
|
|
ViewState("CveCompuestoVigencia") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Sub Inventarios_RegRSCO_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
CargaCombos()
|
|
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Public Sub CargaDatos()
|
|
|
|
|
|
Dim ObjInventarios As New ClsInventarios
|
|
|
|
If ObjInventarios.GetCompuestosVigencia(-1, -1, MinFecha, MaxFecha, 1, UsuarioActual.CveEmpresa) Then
|
|
GvDatos.DataSource = ObjInventarios.DtResultados
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjInventarios.Dispose()
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaCombos()
|
|
|
|
|
|
DdlProveedores.setEsWebService(True)
|
|
DdlProveedores.Attributes.Add("data-metodo", "getproveedores")
|
|
DdlProveedores.SelectedText = "Seleccione Uno"
|
|
DdlProveedores.SelectedValue = "-1"
|
|
|
|
|
|
Dim ObjPS As New ClsProductosServicios
|
|
|
|
If ObjPS.GetCompuestosActivos(UsuarioActual.CveEmpresa) Then
|
|
DdlCompuesto.DataSource = ObjPS.DtResultados
|
|
Else
|
|
DdlCompuesto.DataSource = Nothing
|
|
End If
|
|
|
|
ObjPS.Dispose()
|
|
DdlCompuesto.DataBind()
|
|
DdlCompuesto.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
|
|
|
|
|
|
|
UpModalRSCO.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub LimpiarModalDivAgregarRSCO()
|
|
CveCompuestoVigencia = -1
|
|
|
|
BtnAgregarRSCO.Text = "Agregar"
|
|
|
|
DdlProveedores.txtValue.Value = "-1"
|
|
DdlProveedores.txtText.Value = ""
|
|
|
|
DdlCompuesto.SelectedValueExist(-1)
|
|
|
|
TxtFechaVigencia.Text = ""
|
|
TxtRegistroRSCO.Text = ""
|
|
ChkFechaIndeterminada.Checked = False
|
|
|
|
LtlTituloModal.Text = "Agregar RSCO"
|
|
|
|
DivModalContinuarAgregando.Visible = True
|
|
ChkModalContinuarAgregando.Checked = True
|
|
|
|
UpModalRSCO.Update()
|
|
End Sub
|
|
|
|
Protected Sub LnkAgregarRSCO_Click(sender As Object, e As EventArgs)
|
|
|
|
LimpiarModalDivAgregarRSCO()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarRSCO"))
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkEditar_Click(sender As Object, e As EventArgs)
|
|
|
|
BtnAgregarRSCO.Text = "Actualizar"
|
|
Dim GvRow As GridViewRow = CType(((CType(sender, LinkButton)).NamingContainer), GridViewRow)
|
|
|
|
CveCompuestoVigencia = GvRow.DataKey("CveCompuestoVigencia").ToEntero()
|
|
|
|
|
|
|
|
DdlProveedores.txtValue.Value = GvRow.DataKey("CveProveedor")
|
|
DdlProveedores.txtText.Value = GvRow.DataKey("NombreComercial")
|
|
|
|
|
|
DdlCompuesto.SelectedValueExist(GvRow.DataKey("CveCompuesto"))
|
|
TxtFechaVigencia.Text = GvRow.DataKey("FechaVigencia").ToDate.ToString("dd/MM/yyyy")
|
|
TxtRegistroRSCO.Text = GvRow.DataKey("RegistroRSCO")
|
|
ChkFechaIndeterminada.Checked = Boolean.Parse(GvRow.DataKey("VigenciaIndeterminada"))
|
|
|
|
LtlTituloModal.Text = "Actualizar RSCO"
|
|
|
|
DivModalContinuarAgregando.Visible = False
|
|
ChkModalContinuarAgregando.Checked = False
|
|
|
|
|
|
If ChkFechaIndeterminada.Checked Then
|
|
DvFechaVijencia.Visible = False
|
|
TxtFechaVigencia.Text = "01/01/1900"
|
|
Else
|
|
DvFechaVijencia.Visible = True
|
|
End If
|
|
|
|
|
|
|
|
|
|
UpModalRSCO.Update()
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarRSCO"))
|
|
End Sub
|
|
|
|
Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ErrorAlElimiar As Boolean = False
|
|
|
|
Dim GvRow As GridViewRow = CType(((CType(sender, LinkButton)).NamingContainer), GridViewRow)
|
|
|
|
Dim CveCompuestoVigenciaEliminar = GvRow.DataKey("CveCompuestoVigencia").ToEntero()
|
|
|
|
Using ObjInventarios As New ClsInventarios
|
|
|
|
If (ObjInventarios.RemoveCompuestosVigencia(CveCompuestoVigenciaEliminar, UsuarioActual.CveEmpresa)) Then
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarRSCO"))
|
|
Alert("RSCO Eliminado Correctamente.")
|
|
Else
|
|
ErrorAlElimiar = True
|
|
End If
|
|
End Using
|
|
|
|
|
|
If Not ErrorAlElimiar Then
|
|
GlobalDTInvCamiones(UsuarioActual.CveEmpresa) = Nothing
|
|
CargaDatos()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnAgregarRSCO_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim ErrorPrceso As Boolean = False
|
|
|
|
|
|
If DdlProveedores.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Debe de seleccionar un proveedor.")
|
|
Exit Sub
|
|
End If
|
|
|
|
Using ObjInventarios As New ClsInventarios
|
|
|
|
If CveCompuestoVigencia <= 0 Then
|
|
If ObjInventarios.AddCompuestosVigencia(DdlCompuesto.SelectedValue.ToEntero, DdlProveedores.SelectedValue.ToEntero, TxtRegistroRSCO.Text, TxtFechaVigencia.Text.ToDate, ChkFechaIndeterminada.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
Alert("RSCO agregado correctamente")
|
|
Else
|
|
ErrorPrceso = True
|
|
End If
|
|
Else
|
|
If ObjInventarios.UpdateCompuestosVigencia(CveCompuestoVigencia, DdlCompuesto.SelectedValue.ToEntero, DdlProveedores.SelectedValue.ToEntero, TxtRegistroRSCO.Text, TxtFechaVigencia.Text.ToDate, ChkFechaIndeterminada.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
Alert("RSCO actualizado correctamente")
|
|
Else
|
|
ErrorPrceso = True
|
|
End If
|
|
End If
|
|
End Using
|
|
|
|
|
|
If Not ErrorPrceso Then
|
|
GlobalDTInvCamiones(UsuarioActual.CveEmpresa) = Nothing
|
|
CargaDatos()
|
|
|
|
If Not ChkModalContinuarAgregando.Checked Then
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivAgregarRSCO"))
|
|
Else
|
|
LimpiarModalDivAgregarRSCO()
|
|
End If
|
|
|
|
UpDatos.Update()
|
|
End If
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Protected Sub ChkFechaIndeterminada_CheckedChanged(sender As Object, e As EventArgs)
|
|
|
|
If ChkFechaIndeterminada.Checked Then
|
|
DvFechaVijencia.Visible = False
|
|
TxtFechaVigencia.Text = "01/01/1900"
|
|
Else
|
|
DvFechaVijencia.Visible = True
|
|
TxtFechaVigencia.Text = ""
|
|
End If
|
|
|
|
UpModalRSCO.Update()
|
|
|
|
End Sub
|
|
End Class
|