Option Explicit On Option Strict On Imports Extensiones Partial Class General_CatPSCaracteristicas Inherits ClsPaginas #Region "PROPIEDADES" #End Region Private Sub General_CatPSCaracteristicas_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then CargaDatos() CargaDDLCaracteristicas() End If End Sub #Region " CARGAS " Private Sub CargaDatos() Dim Objeto As New ClsGralProductosServiciosCaracteristicas If Objeto.GetPSCaracteristicas(UsuarioActual.CveEmpresa) Then GvDatosCaracteristicas.DataSource = Objeto.DtResultados End If GvDatosCaracteristicas.DataBind() Objeto.Dispose() End Sub Private Sub CargaDatosOpciones(Caracteristica As Integer) Dim Objeto As New ClsGralProductosServiciosCaracteristicas If Objeto.GetPSCaracteristicasOpciones(Caracteristica) Then GvDatosOpciones.DataSource = Objeto.DtResultados End If GvDatosOpciones.DataBind() Objeto.Dispose() End Sub Public Sub CargaDDLCaracteristicas() DdlCaracteristica.Items.Clear() Dim Objeto As New ClsGralProductosServiciosCaracteristicas If Objeto.GetPSCaracteristicas(UsuarioActual.CveEmpresa) Then DdlCaracteristica.DataSource = Objeto.DtResultados End If DdlCaracteristica.DataBind() Objeto.Dispose() End Sub Private Sub DdlCaracteristica_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCaracteristica.SelectedIndexChanged CargaDatosOpciones(DdlCaracteristica.SelectedValue.ToEntero) End Sub #End Region #Region " GV CARACTERISTICAS Y AGREGAR " Private Sub LbAgregarC_Click(sender As Object, e As EventArgs) Handles LbAgregarC.Click Dim Objeto As New ClsGralProductosServiciosCaracteristicas Dim Caracteristica = TxtCaracteristica.Text Dim EsOpcion = ChkEsOpcion.Checked If Objeto.AddPSCaracteristicas(Caracteristica, EsOpcion, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then TxtCaracteristica.Text = "" CargaDatos() CargaDDLCaracteristicas() UpCaracteristicas.Update() End If Objeto.Dispose() Alert("La Caracteristica se agregó correctamente.", TipoMensaje.MsgInformacion) End Sub Protected Sub GvDatosCaracteristicas_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatosCaracteristicas.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then 'ESTATUS NORMAL If Not (e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5) Then If e.Row.DBCampo("EsOpcion") = "True" Then e.Row.FCLabel("LtlEsOpcion").ForeColor = Drawing.Color.Green e.Row.FCLabel("LtlEsOpcion").Font.Bold = True e.Row.FCLabel("LtlEsOpcion").Text = "Si" Else e.Row.FCLabel("LtlEsOpcion").Text = "No" e.Row.FCLabel("LtlEsOpcion").ForeColor = Drawing.Color.Red e.Row.FCLabel("LtlEsOpcion").Font.Bold = True End If End If 'ESTATUS EDICION If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then If e.Row.DBCampo("EsOpcion") = "True" Then e.Row.FCCheckBox("ChkEsOpcion").Checked = True Else e.Row.FCCheckBox("ChkEsOpcion").Checked = False End If End If End If End Sub Protected Sub GVCarac_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatosCaracteristicas.RowEditing GvDatosCaracteristicas.EditIndex = e.NewEditIndex CargaDatos() End Sub Protected Sub GvDatosCaracteristicas_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatosCaracteristicas.RowUpdating Dim Update As New ClsGralProductosServiciosCaracteristicas Dim Caracteristica = GvDatosCaracteristicas.Rows(e.RowIndex).FCTextBox("TxtCaracteristica").Text.Trim Dim EsOpcion = GvDatosCaracteristicas.Rows(e.RowIndex).FCCheckBox("ChkEsOpcion").Checked Dim Clave = GvDatosCaracteristicas.Rows(e.RowIndex).DataKey("CvePSCaracteristica").ToEntero If Update.UpdatePSCaracteristicas(Caracteristica, Clave, EsOpcion) Then Alert("Se actualizó correctamente.", TipoMensaje.MsgInformacion) End If GvDatosCaracteristicas.EditIndex = -1 CargaDatos() UpCaracteristicas.Update() End Sub Protected Sub GvDatosCaracteristicas_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatosCaracteristicas.RowCancelingEdit GvDatosCaracteristicas.EditIndex = -1 CargaDatos() Alert("Se canceló la edición de los campos.") End Sub Protected Sub GvDatosCaracteristicas_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatosCaracteristicas.RowDeleting Dim Objeto As New ClsGralProductosServiciosCaracteristicas Dim Clave = GvDatosCaracteristicas.Rows(e.RowIndex).DataKey("CvePSCaracteristica").ToEntero If Objeto.RemovePSCaracteristica(Clave) Then Alert("Se borró correctamente de la base de Datos.", TipoMensaje.MsgInformacion) End If Objeto.Dispose() GvDatosCaracteristicas.EditIndex = -1 CargaDatos() CargaDDLCaracteristicas() UpDatosOpciones.Update() End Sub #End Region #Region " GV OPCIONES Y AGREGAR " Protected Sub GvDatosOpciones_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatosOpciones.RowDeleting Dim Objeto As New ClsGralProductosServiciosCaracteristicas Dim Clave = GvDatosOpciones.Rows(e.RowIndex).DataKey("CveOpcion").ToEntero Objeto.RemovePSCaracteristicaOpciones(Clave) GvDatosOpciones.EditIndex = -1 CargaDatosOpciones(DdlCaracteristica.SelectedValue.ToEntero) UpDatosOpciones.Update() Alert("Se borró correctamente de la base de Datos.", TipoMensaje.MsgInformacion) End Sub Private Sub LbAgregarO_Click(sender As Object, e As EventArgs) Handles LbAgregarO.Click Dim Objeto As New ClsGralProductosServiciosCaracteristicas Dim Opcion = TxtOpcion.Text If Objeto.AddPSCaracteristicasOpciones(Opcion, DdlCaracteristica.SelectedValue.ToEntero, UsuarioActual.CveUsuario) Then End If TxtOpcion.Text = "" CargaDatosOpciones(DdlCaracteristica.SelectedValue.ToEntero) UpDatosOpciones.Update() UpTitulosO.Update() Objeto.Dispose() Alert("El valor de la caracteristica se agregó correctamente.", TipoMensaje.MsgInformacion) End Sub Protected Sub GvDatosOpciones_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatosOpciones.RowUpdating Dim Update As New ClsGralProductosServiciosCaracteristicas Dim Caracteristica = GvDatosOpciones.Rows(e.RowIndex).FCDropDownList("DdlCaracteristicaEdit").ToEntero Dim Opcion = GvDatosOpciones.Rows(e.RowIndex).FCTextBox("TxtOpcionEdit").Text.Trim Dim Clave = GvDatosOpciones.Rows(e.RowIndex).DataKey("CveOpcion").ToEntero If Update.UpdatePSCaracteristicasOpciones(Opcion, Clave) Then Alert("Se actualizó correctamente.", TipoMensaje.MsgInformacion) End If GvDatosOpciones.EditIndex = -1 CargaDatosOpciones(DdlCaracteristica.SelectedValue.ToEntero) UpDatosOpciones.Update() End Sub Protected Sub GvDatosOpciones_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatosOpciones.RowCancelingEdit GvDatosOpciones.EditIndex = -1 CargaDatosOpciones(DdlCaracteristica.SelectedValue.ToEntero) UpDatosOpciones.Update() Alert("Se canceló la edición de los campos.") End Sub Protected Sub GVOpc_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatosOpciones.RowEditing GvDatosOpciones.EditIndex = e.NewEditIndex CargaDatosOpciones(DdlCaracteristica.SelectedValue.ToEntero) End Sub #End Region End Class