214 lines
8.5 KiB
VB.net
214 lines
8.5 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
|
|
Partial Class Ventas_CatMesas
|
|
Inherits ClsPaginas
|
|
|
|
Public Property PuedeEditar As Boolean
|
|
Get
|
|
Return CBool(ViewState("PuedeEditar"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("PuedeEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property PuedeEliminar As Boolean
|
|
Get
|
|
Return CBool(ViewState("PuedeEditar"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("PuedeEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
ViewState("Orden") = ""
|
|
CargaSucursales()
|
|
CargaDatos()
|
|
|
|
''Permiso Registro
|
|
'If PermisoRegistro Then
|
|
' LbAgregar.Enabled = True
|
|
'Else
|
|
' LbAgregar.Enabled = False
|
|
'End If
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaSucursales()
|
|
ddlSucursal.DataSource = GlobalDTSubProyectos(UsuarioActual.CveEmpresa)
|
|
ddlSucursal.DataBind()
|
|
ddlSucursal.Items.Insert(0, New ListItem("Todas", "-1"))
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjMesas As New ClsVentas
|
|
If ObjMesas.GetMesas() Then
|
|
ViewState("DTMesas") = ObjMesas.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTMesas = ObjMesas.DtResultados
|
|
Else
|
|
Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjMesas.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub ddlSucursal_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlSucursal.SelectedIndexChanged
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click
|
|
Dim ObjMesas As New ClsVentas
|
|
If ObjMesas.AddMesa(TxtMesa.Text.Trim, UsuarioActual.CveUsuario, ddlSucursal.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
TxtMesa.Text = ""
|
|
Alert("La nueva Mesa se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
UpTitulos.Update()
|
|
ViewState("DTMesas") = ObjMesas.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTMesas = ObjMesas.DtResultados
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End If
|
|
ObjMesas.Dispose()
|
|
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.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(150)
|
|
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(100)
|
|
e.Row.Cells(6).Width = Unit.Pixel(61)
|
|
End If
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
|
|
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
|
|
e.Row.FCDropDownList("ddlSucursal").DataSource = GlobalDTSubProyectos(UsuarioActual.CveEmpresa)
|
|
e.Row.FCDropDownList("ddlSucursal").DataBind()
|
|
e.Row.FCDropDownList("ddlSucursal").SelectedValue = e.Row.DBCampo("CveSucursal")
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim ObjMesas As New ClsVentas
|
|
If ObjMesas.RemoveMesa(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTMesas") = ObjMesas.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTMesas = ObjMesas.DtResultados
|
|
Alert("La Mesa se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjMesas.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 ObjMesas As New ClsVentas
|
|
Dim CveSucursal As Integer = GvDatos.Rows(e.RowIndex).FCDropDownList("ddlSucursal").SelectedValue.ToEntero
|
|
Dim Mesa As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtMesa"), TextBox).Text.Trim
|
|
Dim Estatus As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstatus").Checked
|
|
Dim CveMesa As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
|
|
If ObjMesas.UpdateMesa(Mesa, Estatus, CveSucursal, CveMesa) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTMesas") = ObjMesas.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTMesas = ObjMesas.DtResultados
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjMesas.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
|
|
|
|
#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(CType(ViewState("DTMesas"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable().FiltraParametros(String.Format("CveSucursal = {0} OR {0} = -1", ddlSucursal.SelectedValue))
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = CType(ViewState("DTMesas"), DataTable).FiltraParametros(String.Format("CveSucursal = {0} OR {0} = -1", ddlSucursal.SelectedValue))
|
|
End If
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
End Class
|