277 lines
12 KiB
VB.net
277 lines
12 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
Partial Class CatEstatusFactura
|
|
Inherits ClsPaginas
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
ViewState("Orden") = ""
|
|
CargaDatos()
|
|
CargaCombo(DdlTipoDocto)
|
|
''Permiso Registro
|
|
'If PermisoRegistro Then
|
|
' LbAgregar.Enabled = True
|
|
'Else
|
|
' ' LbAgregar.Enabled = False
|
|
'End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjEstatusFactura As New ClsEstatusFactura
|
|
If ObjEstatusFactura.GetEstatusFactura() Then
|
|
GlobalDTEstatusFactura = ObjEstatusFactura.DtResultados
|
|
Else
|
|
Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
ObjEstatusFactura.Dispose()
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaCombo(Ddl As DropDownList)
|
|
Ddl.Items.Insert(1, New ListItem("Ingreso", "Ing"))
|
|
Ddl.Items.Insert(2, New ListItem("Remisión", "Rem"))
|
|
Ddl.Items.Insert(3, New ListItem("Cotización", "Cot"))
|
|
Ddl.Items.Insert(4, New ListItem("Anticipo", "Ant"))
|
|
Ddl.Items.Insert(5, New ListItem("Pedido", "Ped"))
|
|
Ddl.Items.Insert(6, New ListItem("Pedido2", "Pd2"))
|
|
Ddl.Items.Insert(7, New ListItem("PedidoA", "PA"))
|
|
|
|
End Sub
|
|
|
|
|
|
#Region "G V D A T O S"
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.FCLiteral("LtlTipoDocto").Text = "Ing" Then
|
|
e.Row.FCLiteral("LtlTipoDocto").Text = "Ingreso"
|
|
ElseIf e.Row.FCLiteral("LtlTipoDocto").Text = "Rem" Then
|
|
e.Row.FCLiteral("LtlTipoDocto").Text = "Remisión"
|
|
ElseIf e.Row.FCLiteral("LtlTipoDocto").Text = "Cot" Then
|
|
e.Row.FCLiteral("LtlTipoDocto").Text = "Cotización"
|
|
ElseIf e.Row.FCLiteral("LtlTipoDocto").Text = "Ant" Then
|
|
e.Row.FCLiteral("LtlTipoDocto").Text = "Anticipo"
|
|
ElseIf e.Row.FCLiteral("LtlTipoDocto").Text = "Ped" Then
|
|
e.Row.FCLiteral("LtlTipoDocto").Text = "Pedido"
|
|
End If
|
|
If e.Row.RowState = DataControlRowState.Alternate OrElse e.Row.RowState = DataControlRowState.Normal Then
|
|
If e.Row.RowIndex <= 1 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(80)
|
|
e.Row.Cells(1).Width = Unit.Pixel(250)
|
|
e.Row.Cells(2).Width = Unit.Pixel(100)
|
|
e.Row.Cells(3).Width = Unit.Pixel(100)
|
|
e.Row.Cells(4).Width = Unit.Pixel(100)
|
|
e.Row.Cells(5).Width = Unit.Pixel(120)
|
|
'e.Row.Cells(6).Width = Unit.Pixel(100)
|
|
'e.Row.Cells(7).Width = Unit.Pixel(61)
|
|
|
|
End If
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left
|
|
End If
|
|
'If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
|
|
' CargaCombo(e.Row.FCDropDownList("DdlTipoDocto"))
|
|
' e.Row.FCDropDownList("DdlTipoDocto").SelectedValue = e.Row.DBCampo("TipoDocto")
|
|
'End If
|
|
End If
|
|
End Sub
|
|
|
|
'Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
' Dim ObjEstatusFactura As New ClsEstatusFactura
|
|
' If ObjEstatusFactura.RemoveEstatusFactura(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
' GvDatos.EditIndex = -1
|
|
' GlobalDTEstatusFactura = ObjEstatusFactura.DtResultados
|
|
' Alert("El Estatus de Factura se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
' End If
|
|
' ObjEstatusFactura.Dispose()
|
|
' If ViewState("Orden").ToString() <> String.Empty Then
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' Else
|
|
' CargaGrid("")
|
|
' End If
|
|
'End Sub
|
|
|
|
'Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
|
|
' GvDatos.EditIndex = -1
|
|
' If ViewState("Orden").ToString() <> String.Empty Then
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' Else
|
|
' CargaGrid("")
|
|
' End If
|
|
'End Sub
|
|
|
|
'Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
|
|
' Dim ObjEstatusFactura As New ClsEstatusFactura
|
|
' Dim EstatusFactura As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtEstatus"), TextBox).Text.Trim
|
|
' Dim Estado As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstado").Checked
|
|
' Dim TipoDocto As String = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlTipoDocto").SelectedValue
|
|
' Dim CveEstatusFactura As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
|
|
' If ObjEstatusFactura.UpdateEstatusFactura(EstatusFactura, Estado, TipoDocto, UsuarioActual.CveUsuario, CveEstatusFactura) Then
|
|
' GvDatos.EditIndex = -1
|
|
' GlobalDTEstatusFactura = ObjEstatusFactura.DtResultados
|
|
' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
' End If
|
|
' ObjEstatusFactura.Dispose()
|
|
' If ViewState("Orden").ToString() <> String.Empty Then
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' Else
|
|
' CargaGrid("")
|
|
' End If
|
|
'End Sub
|
|
|
|
'Protected Sub GvDatos_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatos.RowEditing
|
|
' GvDatos.EditIndex = e.NewEditIndex
|
|
' If ViewState("Orden").ToString() <> String.Empty Then
|
|
' CargaGrid(ViewState("Orden").ToString())
|
|
' Else
|
|
' CargaGrid("")
|
|
' End If
|
|
'End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
Private Sub BtnAgregarEstatusFactura_Click(sender As Object, e As EventArgs) Handles BtnAgregarEstatusFactura.Click
|
|
|
|
If DdlTipoDocto.SelectedValue = "-1" Then
|
|
Alert("Tiene que seleccionar un tipo de documento.", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjEstatusFactura As New ClsEstatusFactura
|
|
|
|
If HdnModalidad.Value = "A" Then
|
|
If ObjEstatusFactura.AddEstatusFactura(TxtClave.Text.Trim.ToEntero, TxtEstatus.Text.Trim, UsuarioActual.CveUsuario, DdlTipoDocto.SelectedValue) Then
|
|
TxtClave.Text = ""
|
|
TxtEstatus.Text = ""
|
|
Alert("El Estatus de Factura se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
GlobalDTEstatusFactura = ObjEstatusFactura.DtResultados
|
|
End If
|
|
ElseIf HdnModalidad.Value = "U" Then
|
|
If ObjEstatusFactura.UpdateEstatusFactura(TxtEstatus.Text.Trim, ChkEstado.Checked, DdlTipoDocto.SelectedValue, UsuarioActual.CveUsuario, HdnID.Value.ToEntero) Then
|
|
GlobalDTEstatusFactura = ObjEstatusFactura.DtResultados
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
End If
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddEstatusFactura"))
|
|
ObjEstatusFactura.Dispose()
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub Delete_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
HdnID.Value = GvRow.DataKey("CveEstatusFactura")
|
|
UpDatos.Update()
|
|
Dim ObjEstatusFactura As New ClsEstatusFactura
|
|
If ObjEstatusFactura.RemoveEstatusFactura(HdnID.Value.ToEntero) Then
|
|
GlobalDTEstatusFactura = ObjEstatusFactura.DtResultados
|
|
Alert("El Estatus de Factura se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjEstatusFactura.Dispose()
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
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("CveEstatusFactura")
|
|
UpDatos.Update()
|
|
divclave.Visible = False
|
|
BtnAgregarEstatusFactura.Text = "Actualizar"
|
|
myModalLabel.InnerText = "Actualizar de Estatus Factura"
|
|
TxtEstatus.Text = GvRow.DataKey("EstatusFactura")
|
|
divEstado.Visible = True
|
|
If GvRow.DataKey("Estado") = "Activo" Then ChkEstado.Checked = True Else ChkEstado.Checked = False
|
|
DdlTipoDocto.SelectedValueExist(GvRow.DataKey("TipoDocto"))
|
|
UpAddEstatusFactura.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddEstatusFactura"))
|
|
|
|
End Sub
|
|
|
|
Private Sub LnkAgregar_Click(sender As Object, e As EventArgs) Handles LnkAgregar.Click
|
|
HdnModalidad.Value = "A"
|
|
UpDatos.Update()
|
|
BtnAgregarEstatusFactura.Text = "Agregar"
|
|
myModalLabel.InnerText = "Agregar de Estatus Factura"
|
|
divclave.Visible = True
|
|
TxtClave.Text = ""
|
|
TxtEstatus.Text = ""
|
|
divEstado.Visible = False
|
|
ChkEstado.Checked = True
|
|
DdlTipoDocto.SelectedValue = "-1"
|
|
UpAddEstatusFactura.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddEstatusFactura"))
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Region "O R D E N A M I E N T O"
|
|
Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim Orden As String = ""
|
|
Dim Campo As String = ""
|
|
Dim Literal As Literal = Nothing
|
|
Const OrdenInicial As String = ""
|
|
Dim Arg(2) As String
|
|
|
|
Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c)
|
|
Campo = Arg(0)
|
|
Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal)
|
|
|
|
If ViewState(String.Format("O{0}", Campo)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo)).ToString = String.Format("{0} DESC", Campo) Then
|
|
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo)
|
|
Literal.Text = String.Format("<i class='fa fa-sort-asc' style='color:#999' ></i>")
|
|
Else
|
|
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo)
|
|
Literal.Text = String.Format("<i class='fa fa-sort-desc' style='color:#999' ></i>")
|
|
End If
|
|
Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString
|
|
ViewState("Orden") = Orden
|
|
CargaGrid(Orden)
|
|
End Sub
|
|
|
|
Private Sub CargaGrid(Orden As String)
|
|
If Orden <> String.Empty Then
|
|
Dim DV As New DataView(GlobalDTEstatusFactura, "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = GlobalDTEstatusFactura.FiltraParametros($"{If(UsuarioActual.Empresa.CvePlataforma = 2, "TipoDocto IN ('Ing', 'Egs', 'Rem')", "1 = 1")}")
|
|
End If
|
|
GvDatos.DataBind()
|
|
If UsuarioActual.Empresa.CvePlataforma = 2 Then
|
|
GvDatos.Columns(6).Visible = False
|
|
GvDatos.Columns(7).Visible = False
|
|
End If
|
|
|
|
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
End Class
|