Option Explicit On Option Strict On Imports System.Data Imports System.Linq Imports Extensiones Partial Class Bancos_CatTiposTransaccion Inherits ClsPaginas #Region "Propiedades" Public Property CveTipoTransaccion As Integer Get Return ViewState("CveTipoTransaccion").ToString.ToEntero End Get Set(value As Integer) ViewState("CveTipoTransaccion") = value End Set End Property Public Property EsEditar As Integer Get Return ViewState("EsEditar").ToString.ToEntero End Get Set(value As Integer) ViewState("EsEditar") = value End Set End Property #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CveTipoTransaccion = -1 EsEditar = 0 dvEstatus.Visible = False CargaDatos() End If End Sub Public Sub CargaDatos() Dim ObjEstatusIE As New ClsBancos If ObjEstatusIE.GetBancos_TiposTransaccion(-1) Then GlobalDTTipoTransacciones = ObjEstatusIE.DtResultados GvDatos.DataSource = ObjEstatusIE.DtResultados Else GvDatos.DataSource = Nothing End If ObjEstatusIE.Dispose() GvDatos.DataBind() If UsuarioActual.Empresa.CvePlataforma = 2 Then GvDatos.Columns(6).Visible = False GvDatos.Columns(7).Visible = False End If End Sub Protected Sub imgE_Click(sender As Object, e As EventArgs) Dim Boton = CType(sender, LinkButton) CveTipoTransaccion = Boton.CommandArgument.ToEntero Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow) TxtTipoTransaccion.Text = GvRow.DataKey("TipoTransaccion").ToString TxtCveTipoTransaccion.Text = GvRow.DataKey("CveTipoTransaccion").ToString DdlCveTipo.SelectedValue = GvRow.DataKey("Tipo").ToString TxtCveTipoTransaccion.Enabled = False chkEstatus.Checked = If(GvRow.DataKey("EstatusTexto") = "Activo", True, False) EsEditar = 1 BtnAgregarCatalogo.Text = "Actualizar" dvEstatus.Visible = True UpBodyCompuesto.Update() UpFooter.Update() RegistraScript("$('#divAgregar').modal()") End Sub Protected Sub BtnAgregarCatalogo_Click(sender As Object, e As EventArgs) Handles BtnAgregarCatalogo.Click Dim ObjEstatusIE As New ClsBancos If EsEditar = 0 Then If ObjEstatusIE.AddBancos_TiposTransaccion(TxtCveTipoTransaccion.Text.Trim.ToEntero, TxtTipoTransaccion.Text.Trim, DdlCveTipo.SelectedValue, UsuarioActual.CveUsuario) Then Alert("El Tipo de Transacción se agregó correctamente", TipoMensaje.MsgInformacion) End If ElseIf EsEditar = 1 Then If ObjEstatusIE.UpdateBancos_TiposTransaccion(TxtTipoTransaccion.Text, DdlCveTipo.SelectedValue, chkEstatus.Checked, CveTipoTransaccion) Then Alert("El Tipo de Transacción se editó correctamente", TipoMensaje.MsgInformacion) End If EsEditar = 0 dvEstatus.Visible = False BtnAgregarCatalogo.Text = "Agregar" End If RegistraScript("$('#divAgregar').modal('hide')") ObjEstatusIE.Dispose() TxtCveTipoTransaccion.Text = "" TxtTipoTransaccion.Text = "" DdlCveTipo.SelectedValue = "-1" CargaDatos() UpDatos.Update() UpBodyCompuesto.Update() End Sub Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting Dim ObjEstatusIE As New ClsBancos Dim CveTipoTransaccion As Integer = GvDatos.Rows(e.RowIndex).DataKey("CveTipoTransaccion").ToEntero If ObjEstatusIE.RemoveBancos_TiposTransaccion(CveTipoTransaccion) Then Alert("El Tipo de Transaccion se eliminó correctamente", TipoMensaje.MsgInformacion) End If ObjEstatusIE.Dispose() CargaDatos() UpDatos.Update() End Sub Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then e.Row.VerticalAlign = VerticalAlign.Middle e.Row.FCLinkButton("ImgE").CommandArgument = e.Row.DataKey("CveTipoTransaccion").ToString If e.Row.DBCampo("EstatusTexto") = "Activo" Then e.Row.FCLabel("LblEstatus").Text = "Activo" e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Green Else e.Row.FCLabel("LblEstatus").Text = "Inactivo" e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Red End If End If End Sub Protected Sub btnCancelar_Click(sender As Object, e As EventArgs) Handles BtnOpenDiv.Click EsEditar = 0 RegistraScript("$('#divAgregar').modal()") BtnAgregarCatalogo.Text = "Agregar" TxtCveTipoTransaccion.Text = "" TxtCveTipoTransaccion.Enabled = True TxtTipoTransaccion.Text = "" DdlCveTipo.SelectedValue = "-1" dvEstatus.Visible = False UpBodyCompuesto.Update() UpFooter.Update() End Sub ' Public Sub CargaDatos() ' Dim ObjTipoTransacciones As New ClsBancos ' If ObjTipoTransacciones.GetBancos_TiposTransaccion() Then ' ViewState("DTTipoTransacciones") = ObjTipoTransacciones.DtResultados ' GlobalDTTipoTransacciones = ObjTipoTransacciones.DtResultados ' Else ' Me.GvDatos.DataSource = Nothing ' End If ' ObjTipoTransacciones.Dispose() ' 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 ObjTipoTransacciones As New ClsBancos ' If ObjTipoTransacciones.AddBancos_TiposTransaccion(TxtCveTipoTransaccion.Text.Trim.ToEntero, TxtTipoTransaccion.Text.Trim, DdlCveTipo.SelectedValue, UsuarioActual.CveUsuario) Then ' TxtTipoTransaccion.Text = "" ' TxtCveTipoTransaccion.Text = "" ' Alert("El nuevo Tipo de Transacción se guardó correctamente.", TipoMensaje.MsgInformacion) ' UpTitulos.Update() ' ViewState("DTTipoTransacciones") = ObjTipoTransacciones.DtResultados ' GlobalDTTipoTransacciones = ObjTipoTransacciones.DtResultados ' If ViewState("Orden").ToString() <> String.Empty Then ' CargaGrid(ViewState("Orden").ToString()) ' Else ' CargaGrid("") ' End If ' End If ' ObjTipoTransacciones.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(86) 'CveTipoTransaccion ' e.Row.Cells(1).Width = Unit.Pixel(256) 'Tipo Transacción ' e.Row.Cells(2).Width = Unit.Pixel(126) 'Tipo ' e.Row.Cells(3).Width = Unit.Pixel(100) 'Estatus ' e.Row.Cells(4).Width = Unit.Pixel(100) 'Fecha Ing ' e.Row.Cells(5).Width = Unit.Pixel(100) 'Usuario ' e.Row.Cells(6).Width = Unit.Pixel(100) ' e.Row.Cells(7).Width = Unit.Pixel(65) ' End If ' e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Center ' e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Left ' 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.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then ' e.Row.FCDropDownList("DdlTipo").SelectedValue = e.Row.DBCampo("Tipo") ' End If ' End If ' End Sub ' Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting ' Dim ObjTipoTransacciones As New ClsBancos ' If ObjTipoTransacciones.RemoveBancos_TiposTransaccion(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then ' GvDatos.EditIndex = -1 ' ViewState("DTTipoTransacciones") = ObjTipoTransacciones.DtResultados ' GlobalDTTipoTransacciones = ObjTipoTransacciones.DtResultados ' Alert("El Tipo de Transacción se eliminó correctamente.", TipoMensaje.MsgInformacion) ' End If ' ObjTipoTransacciones.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 ObjTipoTransacciones As New ClsBancos ' Dim TipoTransaccion As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtTipoTransaccion"), TextBox).Text.Trim ' Dim Tipo As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("DdlTipo"), DropDownList).SelectedValue ' Dim Estatus As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstatus").Checked ' Dim CveTipoTransaccion As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero ' If ObjTipoTransacciones.UpdateBancos_TiposTransaccion(TipoTransaccion, Tipo, Estatus, CveTipoTransaccion) Then ' GvDatos.EditIndex = -1 ' ViewState("DTTipoTransacciones") = ObjTipoTransacciones.DtResultados ' GlobalDTTipoTransacciones = ObjTipoTransacciones.DtResultados ' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) ' End If ' ObjTipoTransacciones.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("") ' Else ' ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo) ' Literal.Text = String.Format("") ' 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("DTTipoTransacciones"), DataTable), "", Orden, DataViewRowState.CurrentRows) ' GvDatos.DataSource = DV.ToTable() ' DV.Dispose() ' Else ' GvDatos.DataSource = CType(ViewState("DTTipoTransacciones"), DataTable) ' End If ' GvDatos.DataBind() ' UpDatos.Update() ' End Sub '#End Region End Class