315 lines
12 KiB
VB.net
315 lines
12 KiB
VB.net
Imports Extensiones
|
|
|
|
Partial Class Acarreos_CatChoferes
|
|
|
|
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()
|
|
' CargaDdlTransportista()
|
|
|
|
CargaDdls()
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaDdls()
|
|
DdlEstado.DataSource = GlobalDTGralEstados("MEX")
|
|
DdlEstado.DataBind()
|
|
DdlEstado.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
|
|
DdlMunicipio.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
|
DdlLocalidad.Items.Insert(0, New ListItem("Seleccione Una", "-1"))
|
|
DdlColonia.Items.Insert(0, New ListItem("Seleccione Una", "-1"))
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim ObjAcar As New ClsAcarreos()
|
|
If ObjAcar.GetChofer(-1, UsuarioActual.CveEmpresa, -1, -1) Then
|
|
GvChofer.DataSource = ObjAcar.DtResultados
|
|
GvChofer.DataBind()
|
|
End If
|
|
ObjAcar.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
|
|
'Private Sub CargaDdlTransportista()
|
|
' Dim ObjAcar As New ClsAcarreos()
|
|
' If ObjAcar.GetTransportista(-1, UsuarioActual.CveEmpresa, 1) Then
|
|
' DdlTransportista.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
' DdlTransportista.DataSource = ObjAcar.DtResultados
|
|
' DdlTransportista.DataBind()
|
|
' End If
|
|
' ObjAcar.Dispose()
|
|
' UpAddChofer.Update()
|
|
'End Sub
|
|
|
|
Private Sub BtnAgregarChofer_Click(sender As Object, e As EventArgs) Handles BtnAgregarChofer.Click
|
|
|
|
|
|
|
|
If TxtRFC.Text.Length > 0 And TxtNumRegidTribOperador.Text.Trim.Length > 0 Then
|
|
Alert("Se debe de proporcionar RFC O Numero RegidTribOperador elimine uno", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
'If DdlTransportista.SelectedValue = "-1" Then
|
|
' Alert("Tiene que seleccionar un transportista.", TipoMensaje.MsgAdvertencia)
|
|
'Else
|
|
|
|
Dim ObjAcar As New ClsAcarreos
|
|
Dim Estatus As Integer = 0
|
|
If ChkEstatus.Checked Then Estatus = 1
|
|
|
|
If HdnModalidad.Value = "A" Then
|
|
If ObjAcar.AddChofer(TxtChofer.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, TxtIdentificacion.Text.Trim, TxtTelefono.Text.Trim, Licencia:=TxtLicencia.Text, RFC:=TxtRFC.Text.Trim, Domicilio:=TxtDomicilio.Text.Trim, NumeroExterior:=TxtNumExt.Text.Trim, NumeroInterior:=TxtNumInt.Text.Trim, Colonia:="", Ciudad:="", Estado:="", CP:=TxtCP.Text.Trim, NumRegidTribOperador:=TxtNumRegidTribOperador.Text.Trim, ResidenciaFiscalOperador:=DdlResidenciaFiscalOperador.SelectedValue, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveLocalidad:=DdlLocalidad.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero) Then
|
|
CargaDatos()
|
|
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
|
|
GlobalDTChoferes(UsuarioActual.CveEmpresa) = Nothing
|
|
End If
|
|
ElseIf HdnModalidad.Value = "U" Then
|
|
If ObjAcar.UpdateChofer(HdnID.Value.ToEntero(), TxtChofer.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, Estatus, -1, TxtIdentificacion.Text.Trim, TxtTelefono.Text.Trim, Licencia:=TxtLicencia.Text, RFC:=TxtRFC.Text.Trim, Domicilio:=TxtDomicilio.Text.Trim, NumeroExterior:=TxtNumExt.Text.Trim, NumeroInterior:=TxtNumInt.Text.Trim, Colonia:="", Ciudad:="", Estado:="", CP:=TxtCP.Text.Trim, NumRegidTribOperador:=TxtNumRegidTribOperador.Text.Trim, ResidenciaFiscalOperador:=DdlResidenciaFiscalOperador.SelectedValue, CveEstado:=DdlEstado.SelectedValue.ToEntero, CveMunicipio:=DdlMunicipio.SelectedValue.ToEntero, CveLocalidad:=DdlLocalidad.SelectedValue.ToEntero, CveColonia:=DdlColonia.SelectedValue.ToEntero) Then
|
|
CargaDatos()
|
|
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
|
|
GlobalDTChoferes(UsuarioActual.CveEmpresa) = Nothing
|
|
End If
|
|
End If
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddChofer"))
|
|
ObjAcar.Dispose()
|
|
UpDatos.Update()
|
|
|
|
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("CveChofer")
|
|
UpDatos.Update()
|
|
BtnAgregarChofer.Text = "Actualizar"
|
|
myModalLabel.InnerText = "Actualizar Chofer"
|
|
|
|
TxtChofer.Text = GvRow.DataKey("Chofer")
|
|
TxtIdentificacion.Text = GvRow.DataKey("Identificacion")
|
|
TxtTelefono.Text = GvRow.DataKey("Telefono")
|
|
TxtRFC.Text = GvRow.DataKey("RFC")
|
|
|
|
TxtDomicilio.Text = GvRow.DataKey("Domicilio")
|
|
TxtNumInt.Text = GvRow.DataKey("NumeroInterior")
|
|
TxtNumExt.Text = GvRow.DataKey("NumeroExterior")
|
|
'TxtColonia.Text = GvRow.DataKey("Colonia")
|
|
'TxtCiudad.Text = GvRow.DataKey("Ciudad")
|
|
'TxtEstado.Text = GvRow.DataKey("Estado")
|
|
TxtCP.Text = GvRow.DataKey("CP")
|
|
TxtLicencia.Text = GvRow.DataKey("Licencia")
|
|
|
|
TxtNumRegidTribOperador.Text = GvRow.DataKey("NumRegidTribOperador")
|
|
|
|
DdlResidenciaFiscalOperador.SelectedValueExist("-1")
|
|
DdlResidenciaFiscalOperador.SelectedValueExist(GvRow.DataKey("ResidenciaFiscalOperador"))
|
|
|
|
' DdlTransportista.SelectedValueExist(GvRow.DataKey("CveTransportista"))
|
|
|
|
divEstatus.Visible = True
|
|
ChkEstatus.Checked = CBool(GvRow.DataKey("Estatus"))
|
|
|
|
|
|
DdlEstado.SelectedValueExist(GvRow.DataKey("CveEstado"))
|
|
|
|
|
|
DdlMunicipio.Items.Clear()
|
|
If DdlEstado.SelectedValue.ToEntero > 0 Then
|
|
|
|
DdlMunicipio.DataSource = GlobalDTGralMunicipios("-1", CveEstado:=DdlEstado.SelectedValue.ToEntero)
|
|
DdlMunicipio.DataBind()
|
|
|
|
End If
|
|
DdlMunicipio.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
|
DdlMunicipio.SelectedValueExist(GvRow.DataKey("CveMunicipio"))
|
|
|
|
|
|
DdlLocalidad.Items.Clear()
|
|
DdlColonia.Items.Clear()
|
|
|
|
If DdlEstado.SelectedValue.ToEntero > 0 And DdlMunicipio.SelectedValue.ToEntero > 0 Then
|
|
|
|
DdlLocalidad.DataSource = GlobalDTLocalidad(DdlEstado.SelectedValue.ToEntero, DdlMunicipio.SelectedValue.ToEntero)
|
|
DdlLocalidad.DataBind()
|
|
|
|
DdlColonia.DataSource = GlobalDTGralColonias("-1", "-1", "-1", DdlMunicipio.SelectedValue.ToEntero, CodigoPostal:=If(TxtCP.Text.Trim.Length > 0, TxtCP.Text.ToEntero, -1))
|
|
DdlColonia.DataBind()
|
|
|
|
End If
|
|
|
|
DdlLocalidad.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
|
DdlLocalidad.SelectedValueExist(GvRow.DataKey("CveLocalidad"))
|
|
|
|
|
|
DdlColonia.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
|
DdlColonia.SelectedValueExist(GvRow.DataKey("CveColonia"))
|
|
|
|
|
|
|
|
UpAddChofer.Update()
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddChofer"))
|
|
|
|
End Sub
|
|
|
|
Public Sub Agregar()
|
|
HdnModalidad.Value = "A"
|
|
UpDatos.Update()
|
|
BtnAgregarChofer.Text = "Agregar"
|
|
myModalLabel.InnerText = "Agregar Chofer"
|
|
TxtChofer.Text = ""
|
|
TxtIdentificacion.Text = ""
|
|
TxtDomicilio.Text = ""
|
|
TxtTelefono.Text = ""
|
|
'TxtCiudad.Text = ""
|
|
TxtLicencia.Text = ""
|
|
|
|
|
|
' DdlTransportista.SelectedValueExist(-1)
|
|
TxtRFC.Text = ""
|
|
TxtNumInt.Text = ""
|
|
TxtNumExt.Text = ""
|
|
'TxtEstado.Text = ""
|
|
TxtCP.Text = ""
|
|
'TxtColonia.Text = ""
|
|
|
|
TxtNumRegidTribOperador.Text = ""
|
|
DdlResidenciaFiscalOperador.SelectedValueExist("-1")
|
|
|
|
|
|
|
|
DdlEstado.SelectedValueExist(-1)
|
|
DdlEstado_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
|
|
DdlColonia.SelectedValueExist(-1)
|
|
|
|
ChkEstatus.Checked = True
|
|
divEstatus.Visible = False
|
|
UpAddChofer.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddChofer"))
|
|
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("CveChofer")
|
|
UpDatos.Update()
|
|
If ObjAcar.RemoveChofer(HdnID.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
CargaDatos()
|
|
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("No se puede eliminar el chofer. verifique que no tenga movimientos registrados.", TipoMensaje.MsgError)
|
|
End If
|
|
ObjAcar.Dispose()
|
|
UpDatos.Update()
|
|
End Sub
|
|
|
|
Private Sub GvChofer_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvChofer.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 LnkChofer_Click(sender As Object, e As EventArgs) Handles LnkChofer.Click
|
|
Agregar()
|
|
End Sub
|
|
|
|
Protected Sub LnkValidar_Click(sender As Object, e As EventArgs)
|
|
validaCodigoPostal()
|
|
End Sub
|
|
|
|
Protected Sub DdlEstado_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
|
|
DdlMunicipio.Items.Clear()
|
|
|
|
If DdlEstado.SelectedValue.ToEntero > 0 Then
|
|
|
|
DdlMunicipio.DataSource = GlobalDTGralMunicipios("-1", CveEstado:=DdlEstado.SelectedValue.ToEntero)
|
|
DdlMunicipio.DataBind()
|
|
|
|
End If
|
|
|
|
DdlMunicipio.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
|
DdlMunicipio.SelectedValueExist(-1)
|
|
|
|
|
|
DdlLocalidad.Items.Clear()
|
|
DdlLocalidad.Items.Insert(0, New ListItem("Seleccione Una", "-1"))
|
|
|
|
|
|
UpAddChofer.Update()
|
|
|
|
|
|
End Sub
|
|
Protected Sub DdlMunicipio_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
|
|
DdlLocalidad.Items.Clear()
|
|
DdlColonia.Items.Clear()
|
|
|
|
If DdlMunicipio.SelectedValue.ToEntero > 0 Then
|
|
|
|
DdlLocalidad.DataSource = GlobalDTLocalidad(DdlEstado.SelectedValue.ToEntero, DdlMunicipio.SelectedValue.ToEntero)
|
|
DdlLocalidad.DataBind()
|
|
DdlColonia.DataSource = GlobalDTGralColonias("-1", "-1", "-1", DdlMunicipio.SelectedValue.ToEntero, CodigoPostal:=If(TxtCP.Text.Trim.Length > 0, TxtCP.Text.ToEntero, -1))
|
|
DdlColonia.DataBind()
|
|
|
|
End If
|
|
|
|
DdlLocalidad.Items.Insert(0, New ListItem("Seleccione Uno", "-1"))
|
|
DdlLocalidad.SelectedValueExist(-1)
|
|
DdlColonia.Items.Insert(0, New ListItem("Seleccione Una", "-1"))
|
|
DdlColonia.SelectedValueExist(-1)
|
|
UpAddChofer.Update()
|
|
End Sub
|
|
|
|
Protected Sub DdlColonias_selectedindexchange(sender As Object, e As EventArgs)
|
|
|
|
If DdlColonia.SelectedValue.ToEntero > 0 Then
|
|
validaCodigoPostal()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub validaCodigoPostal()
|
|
|
|
Dim CPTxt As Integer = TxtCP.Text.ToEntero()
|
|
|
|
Dim CveColonia As Integer = DdlColonia.SelectedValue.ToEntero
|
|
|
|
If CPTxt > 0 And CveColonia > 0 Then
|
|
Dim CP As Integer = GlobalDTGralColonias("-1", "-1", "-1", CveColonia:=CveColonia).FiltroPrimeroValor("CP", "").ToEntero
|
|
If CPTxt <> CP Then
|
|
Alert("El código postal seleccionado es diferente del codigo postal de la Colonia.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub DdlColonia_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
validaCodigoPostal()
|
|
End Sub
|
|
End Class
|