Imports Extensiones Imports System.Data Partial Class Acarreos_CatTransportistas Inherits ClsPaginas #Region " PROPIEDADES" #End Region Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaDatos() CargaDdlProveedor() End If End Sub Private Sub CargaDatos() Dim ObjAcar As New ClsAcarreos() If ObjAcar.GetTransportista(-1, UsuarioActual.CveEmpresa, -1) Then GvTransportista.DataSource = ObjAcar.DtResultados GvTransportista.DataBind() End If ObjAcar.Dispose() UpDatos.Update() End Sub Private Sub CargaDdlProveedor() DdlProveedor.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) DdlProveedor.DataBind() End Sub Private Sub BtnAgregarTransportista_Click(sender As Object, e As EventArgs) Handles BtnAgregarTransportista.Click If DdlProveedor.SelectedValue = "-1" Then Alert("Tiene que seleccionar un proveedor.", TipoMensaje.MsgAdvertencia) Else Dim ObjAcar As New ClsAcarreos Dim Estatus = 0 If ChkEstatus.Checked Then Estatus = 1 If HdnModalidad.Value = "A" Then If ObjAcar.AddTransportista(TxtTransportista.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlProveedor.SelectedValue) Then CargaDatos() Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion) End If ElseIf HdnModalidad.Value = "U" Then If ObjAcar.UpdateTransportista(HdnID.Value, TxtTransportista.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Estatus, DdlProveedor.SelectedValue) Then CargaDatos() Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion) End If End If RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddTransportista")) ObjAcar.Dispose() UpDatos.Update() End If End Sub Public Sub Edit_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) HdnModalidad.Value = "U" HdnID.Value = GvRow.DataKey("CveTransportista") UpDatos.Update() BtnAgregarTransportista.Text = "Actualizar" myModalLabel.InnerText = "Actualizar Transportista" TxtTransportista.Text = GvRow.DataKey("Transportista") DdlProveedor.SelectedValueExist(GvRow.DataKey("CveProveedor")) divEstatus.Visible = True ChkEstatus.Checked = CBool(GvRow.DataKey("Estatus")) UpAddTransportista.Update() RegistraScript(String.Format("$('#{0}').modal('show');", "divAddTransportista")) End Sub Public Sub Agregar() HdnModalidad.Value = "A" UpDatos.Update() BtnAgregarTransportista.Text = "Agregar" myModalLabel.InnerText = "Agregar Transportista" TxtTransportista.Text = "" ChkEstatus.Checked = True divEstatus.Visible = False UpAddTransportista.Update() RegistraScript(String.Format("$('#{0}').modal('show');", "divAddTransportista")) End Sub Public Sub Delete_Click(sender As Object, e As EventArgs) Dim ObjAcar As New ClsAcarreos() Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) HdnID.Value = GvRow.DataKey("CveTransportista") UpDatos.Update() If ObjAcar.RemoveTransportista(HdnID.Value) Then CargaDatos() Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion) End If ObjAcar.Dispose() UpDatos.Update() End Sub Private Sub GvTransportista_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvTransportista.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If 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 Private Sub LnkTransportista_Click(sender As Object, e As EventArgs) Handles LnkTransportista.Click Agregar() End Sub End Class