Option Explicit On Option Strict On Imports Extensiones Partial Class Ventas_CatPreciosLista Inherits ClsPaginas #Region "Propiedades" Public Property CvePrecioLista As Integer Get Return ViewState("CveCompuesto").ToString.ToEntero End Get Set(value As Integer) ViewState("CveCompuesto") = 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 CvePrecioLista = -1 EsEditar = 0 dvEstatus.Visible = False CargaDatos() End If End Sub Private Sub CargaDatos() Dim ObjVta As New ClsVentas If ObjVta.GetPrecioListas(CveEmpresa:=UsuarioActual.CveEmpresa) Then GvDatos.DataSource = ObjVta.DtResultados GvDatos.DataBind() Else GvDatos.DataSource = Nothing End If ObjVta.Dispose() GvDatos.DataBind() GlobalDTPrecioListas(UsuarioActual.CveEmpresa) = Nothing End Sub Protected Sub imgE_Click(sender As Object, e As EventArgs) Dim Boton = CType(sender, LinkButton) CvePrecioLista = Boton.CommandArgument.ToEntero Dim GvRow As GridViewRow = DirectCast(Boton.NamingContainer, GridViewRow) TxtPrecioLista.Text = GvRow.DataKey("PrecioLista").ToString chkEstatus.Checked = CBool(GvRow.DataKey("Estatus")) 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 ObjVta As New ClsVentas If EsEditar = 0 Then If ObjVta.AddPrecioLista(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TxtPrecioLista.Text, 0) Then Alert("El Precio de Lista se agregó correctamente", TipoMensaje.MsgInformacion) Else Alert("Ocurrió un error al agregar el Precio de Lista", TipoMensaje.MsgError) End If ElseIf EsEditar = 1 Then If ObjVta.UpdatePrecioLista(TxtPrecioLista.Text, chkEstatus.Checked, UsuarioActual.CveUsuario, 0, CvePrecioLista) Then Alert("El Precio de Lista se editó correctamente", TipoMensaje.MsgInformacion) Else Alert("Ocurrió un error al editar al Precio de Lista", TipoMensaje.MsgError) End If EsEditar = 0 dvEstatus.Visible = False BtnAgregarCatalogo.Text = "Agregar" End If RegistraScript("$('#divAgregar').modal('hide')") ObjVta.Dispose() TxtPrecioLista.Text = "" 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 ObjPrecioLista As New ClsVentas Dim CvePrecioLista As Integer = GvDatos.Rows(e.RowIndex).DataKey("CvePrecioLista").ToEntero If ObjPrecioLista.RemovePrecioLista(CvePrecioLista) Then Alert("El Precio de lista se eliminó correctamente", TipoMensaje.MsgInformacion) End If ObjPrecioLista.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("CvePrecioLista").ToString If CBool(e.Row.DBCampo("Estatus")) = True 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" TxtPrecioLista.Text = "" dvEstatus.Visible = False UpBodyCompuesto.Update() UpFooter.Update() End Sub #Region "VIEJO" ' 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 ' CargaDatos() ' 'Permiso Registro ' If UsuarioActual.TienePermisoProceso(132) Then LbAgregar.Enabled = True Else LbAgregar.Enabled = False ' 'Permiso Eliminar ' If UsuarioActual.TienePermisoProceso(134) Then GvDatos.Columns(5).Visible = True Else GvDatos.Columns(6).Visible = False ' End If ' End Sub ' Private Sub CargaDatos() ' Dim ObjListas As New ClsVentas ' If ObjListas.GetPrecioListas(CveEmpresa:=UsuarioActual.CveEmpresa) Then ' GvDatos.DataSource = ObjListas.DtResultados ' GvDatos.DataBind() ' Else ' Me.GvDatos.DataSource = Nothing ' End If ' If ObjListas.GetPrecioListas(-1) Then ' GlobalDTPrecioListas(-1) = ObjListas.DtResultados ' End If ' ObjListas.Dispose() ' OrdenaDatos() ' End Sub ' Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click ' Dim ObjListas As New ClsVentas ' If HdnModalidad.Value = "I" Then ' If ObjListas.AddPrecioLista(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, TxtPrecioLista.Text.Trim, TxtPorcentaje.Text.Trim.ToDouble) Then ' TxtPrecioLista.Text = "" ' TxtPorcentaje.Text = "" ' Alert("La nueva Lista se guardó correctamente.", TipoMensaje.MsgInformacion) ' UpTitulos.Update() ' CargaDatos() ' UpDatos.Update() ' OcultaDiv() ' End If ' ObjListas.Dispose() ' Else ' If HdnID.Value.ToEntero <> -1 Then ' If ObjListas.UpdatePrecioLista(TxtPrecioLista.Text.Trim, True, UsuarioActual.CveUsuario, TxtPorcentaje.Text.Trim.ToDouble, HdnID.Value.ToEntero) Then ' TxtPrecioLista.Text = "" ' TxtPorcentaje.Text = "" ' Alert("La lista se actualizó correctamente.", TipoMensaje.MsgInformacion) ' UpTitulos.Update() ' CargaDatos() ' UpDatos.Update() ' OcultaDiv() ' End If ' End If ' End If ' 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 ' Dim URL As String = String.Format("javascript:CleanObjects();SetValue('HdnModalidad', 'U');SetValue('HdnID', '{0}'); SetObjects('{1}','{2}');ShowDivRegistro();return false;", e.Row.DBCampo("CvePrecioLista").ToEntero, e.Row.DBCampo("PrecioLista"), e.Row.DBCampo("Porcentaje")) ' 'GeneroLigas ' Dim Liga As String = String.Format("", URL) ' e.Row.VerticalAlign = VerticalAlign.Middle ' e.Row.FCLinkButton("ImgE").OnClientClick = URL ' End If ' End Sub ' Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting ' Dim ObjListas As New ClsVentas ' If ObjListas.RemovePrecioLista(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then ' GvDatos.EditIndex = -1 ' ViewState("DTPrecioListas") = ObjListas.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) ' Alert("La Lista se eliminó correctamente.", TipoMensaje.MsgInformacion) ' End If ' If ObjListas.GetPrecioListas(-1) Then ' GlobalDTPrecioListas(-1) = ObjListas.DtResultados ' End If ' ObjListas.Dispose() ' CargaDatos() ' UpDatos.Update() ' End Sub ' Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating ' Dim ObjListas As New ClsVentas ' Dim PrecioLista As String = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtPrecioLista"), TextBox).Text.Trim ' Dim Porcentaje As Double = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtPorcentaje"), TextBox).Text.Trim.ToDouble ' Dim Estatus As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEstatus").Checked ' Dim CvePrecioLista As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero ' If ObjListas.UpdatePrecioLista(PrecioLista, Estatus, UsuarioActual.CveUsuario, Porcentaje, CvePrecioLista) Then ' GvDatos.EditIndex = -1 ' ViewState("DTPrecioListas") = ObjListas.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) ' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) ' End If ' If ObjListas.GetPrecioListas(-1) Then ' GlobalDTPrecioListas(-1) = ObjListas.DtResultados ' End If ' ObjListas.Dispose() ' OrdenaDatos() ' End Sub '#End Region '#Region " O R D E N A M I E N T O JAVASCRIPT" ' Private Sub OrdenaDatos() ' If (GvDatos.Rows.Count > 0) Then ' GvDatos.UseAccessibleHeader = True ' GvDatos.HeaderRow.TableSection = TableRowSection.TableHeader ' RegistraScript("OrdenarGV();") ' End If ' End Sub '#End Region ' Private Sub OcultaDiv() ' ScriptManager.RegisterStartupScript(Me, Me.GetType, "Llave", "HideDivRegistro();", True) ' End Sub #End Region End Class