Option Explicit On Option Strict On Imports Extensiones Partial Class General_CatMedidas Inherits ClsPaginas #Region "PROPIEDADES" Private Property CveMedida() As Integer Get Return If(IsNothing(ViewState("CveMedida")), -1, CInt(ViewState("CveMedida"))) End Get Set ViewState("CveMedida") = Value End Set End Property Private Property Modalidad() As String Get Return If(IsNothing(ViewState("Modalidad")), "", (ViewState("Modalidad").ToString)) End Get Set ViewState("Modalidad") = Value End Set End Property #End Region Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then CargaCombos() CargaDatos() End If End Sub #Region "CARGAS" Private Sub CargaCombos() DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) DdlClasificacion.DataBind() UpModal.Update() End Sub Private Sub CargaDatos() Dim ObjGral As New ClsGenerales If ObjGral.GetMedidas(UsuarioActual.CveEmpresa) Then GvDatos.DataSource = ObjGral.DtResultados End If ObjGral.Dispose() GvDatos.DataBind() UpDatos.Update() End Sub #End Region #Region "BOTONES" Protected Sub LnkEditar_Click(sender As Object, e As EventArgs) LimpiaModal() Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) CveMedida = gvRow.DataKey("CveMedida").ToEntero() TxtMedida.Text = gvRow.DataKey("Medida") TxtCodigo.Text = gvRow.DataKey("Codigo") DdlClasificacion.SelectedValueExist(gvRow.DataKey("CveClasificacion")) Modalidad = "U" BtnGuardar.Text = "Actualizar" ltlMotititulo.Text = "Actualizar Medida" RegistraScript("$('#DModal').modal('show')") UpModal.Update() End Sub Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs) Dim gvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow) Dim ObjGral As New ClsGenerales Dim CveMedida = gvRow.DataKey("CveMedida").ToEntero() If ObjGral.RemoveMedidas(CveMedida) Then Alert("La medida se eliminó correctamente.", TipoMensaje.MsgInformacion) Else Alert("La medida esta siendo utilizada por un Producto", TipoMensaje.MsgError) End If ObjGral.Dispose() CargaDatos() End Sub Protected Sub LnkAgregar_Click(sender As Object, e As EventArgs) LimpiaModal() Modalidad = "A" BtnGuardar.Text = "Agregar" ltlMotititulo.Text = "Agregar Medida" UpModal.Update() RegistraScript("$('#DModal').modal()") End Sub Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs) Dim ObjPS As New ClsGenerales If Modalidad = "A" Then If ObjPS.AddMedidas(DdlClasificacion.SelectedValue.ToEntero(), TxtCodigo.Text.Trim(), TxtMedida.Text.Trim(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then RegistraScript("$('#DModal').modal('hide')") Alert("La medida se agregó correctamente.", TipoMensaje.MsgInformacion) End If ElseIf Modalidad = "U" Then If ObjPS.UpdateMedidas(CveMedida, DdlClasificacion.SelectedValue.ToEntero(), TxtCodigo.Text.Trim(), TxtMedida.Text.Trim()) Then RegistraScript("$('#DModal').modal('hide')") Alert("La medida se actualizo correctamente.", TipoMensaje.MsgInformacion) End If End If ObjPS.Dispose() CargaDatos() End Sub #End Region #Region "LIMPIAR" Protected Sub LimpiaModal() TxtMedida.Text = "" TxtCodigo.Text = "" DdlClasificacion.SelectedValueExist("-1") End Sub #End Region #Region "GRIDVIEW" 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.DBCampo("Estatus") = "True" Then ' e.Row.Cells(1).ForeColor = Drawing.Color.Green ' e.Row.Cells(1).Font.Bold = True ' e.Row.Cells(1).Text = "Activo" 'Else ' e.Row.Cells(1).Text = "Inactivo" ' e.Row.Cells(1).ForeColor = Drawing.Color.Red ' e.Row.Cells(1).Font.Bold = True 'End If End If End Sub #End Region End Class