736 lines
34 KiB
VB.net
736 lines
34 KiB
VB.net
Imports System.Collections.Generic
|
||
Imports System.Linq
|
||
|
||
Public Class FrmFuncionario
|
||
|
||
Private Sub FrmFuncionario_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
|
||
|
||
Me.Text = "Funcionarios"
|
||
Me.PnDatos.Visible = True
|
||
BtnOk.Enabled = False
|
||
BtnEditar.Enabled = False
|
||
LLenaGrid()
|
||
DeshabilitaCampos()
|
||
DesHeader.Text = Me.Text
|
||
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, btnExportar)
|
||
End Sub
|
||
|
||
Private Sub BtnAgregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAgregar.Click
|
||
|
||
'txtClave.Enabled = True
|
||
'txtClave.ReadOnly = False
|
||
|
||
LimpiaCampos()
|
||
HabilitaCampos()
|
||
|
||
chkActivo.CheckState = 1
|
||
clsVaribles.varProceso = "Agregar"
|
||
'txtClave.Focus()
|
||
BtnOk.Enabled = True
|
||
|
||
Me.chkActivo.Enabled = True
|
||
|
||
|
||
For Each item As Control In PnDatos.Controls
|
||
|
||
If TypeOf item Is TextBox Or TypeOf item Is ComboBox Or TypeOf item Is CheckBox Or TypeOf item Is DateTimePicker Then
|
||
item.Enabled = True
|
||
End If
|
||
Next
|
||
|
||
txtClave.Enabled = False
|
||
'txtNumEmpleado.Enabled = False
|
||
dtpFechaNac.Checked = False
|
||
dtpFechaNac.CustomFormat = "NULL"
|
||
txtNumEmpleado.Focus()
|
||
|
||
cboDelegacion.SelectedIndex = -1
|
||
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, btnExportar)
|
||
|
||
End Sub
|
||
|
||
Private Sub BtnEditar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEditar.Click
|
||
|
||
clsVaribles.varProceso = "Actualizar"
|
||
HabilitaCampos()
|
||
|
||
txtClave.Enabled = False
|
||
'txtFuncionario2.Enabled = False
|
||
|
||
BtnOk.Enabled = True
|
||
BtnAgregar.Enabled = True
|
||
|
||
txtNumEmpleado.Enabled = True
|
||
txtNumEmpleado.Focus()
|
||
BtnEditar.Enabled = False
|
||
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, btnExportar)
|
||
End Sub
|
||
|
||
Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
|
||
|
||
Dim classcom As New clsComplejo
|
||
Dim sSQL As String
|
||
|
||
Dim ClassAud As New ClassMyUtils
|
||
Dim varUser As Long
|
||
Dim ClassComodin As New clsComplejo
|
||
Dim sError As String
|
||
|
||
Call colorLabel()
|
||
|
||
Try
|
||
Select Case UCase(clsVaribles.varProceso)
|
||
|
||
Case Is = "AGREGAR"
|
||
|
||
txtClave.Enabled = True
|
||
|
||
'VALIDACION DE CAMPOS
|
||
'sError = ValidaCampos()
|
||
If sError <> "" Then
|
||
MessageBox.Show(sError, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||
Exit Sub
|
||
End If
|
||
|
||
'sSQL = "INSERT INTO FUNCIONARIO (IdFuncionario, IdSucursal, IdEstado, IdNacionalidad, IdTipoEmpleado, " + _
|
||
'"IdPlaza, Nombre, ApellidoPaterno, ApellidoMaterno, NoEmpleado, Area, Activo, RFC, CURP, Calle, Colonia, " + _
|
||
'"CodigoPostal, Delegacion, Telefono, Puesto, Departamento, idFuncionario2) VALUES ( "
|
||
'sSQL = sSQL & txtClave.Text & ","
|
||
'If cmbSucursal.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbSucursal.SelectedValue & ", "
|
||
'If cmbEstado.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbEstado.SelectedValue & ", "
|
||
'If cmbNacionalidad.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbNacionalidad.SelectedValue & ", "
|
||
'If cmbTipoEmpleado.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbTipoEmpleado.SelectedValue & ", "
|
||
'If cmbPlaza.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbPlaza.SelectedValue & ", "
|
||
'sSQL = sSQL & "'" & txtNombre.Text & "',"
|
||
'sSQL = sSQL & "'" & txtApePaterno.Text & "',"
|
||
'sSQL = sSQL & "'" & txtApeMaterno.Text & "',"
|
||
'sSQL = sSQL & "'" & txtNumEmpleado.Text & "',"
|
||
'sSQL = sSQL & "'" & txtArea.Text & "',"
|
||
'sSQL = sSQL & chkActivo.CheckState & ","
|
||
'sSQL = sSQL & "'" & txtRFC.Text & "',"
|
||
'sSQL = sSQL & "'" & txtCurp.Text & "',"
|
||
'sSQL = sSQL & "'" & txtCalle.Text & "',"
|
||
'sSQL = sSQL & "'" & txtColonia.Text & "',"
|
||
'sSQL = sSQL & "'" & txtCP.Text & "',"
|
||
'sSQL = sSQL & "'" & txtDelegacion.Text & "',"
|
||
'sSQL = sSQL & "'" & txtTelefono.Text & "',"
|
||
'sSQL = sSQL & "'" & txtPuesto.Text & "',"
|
||
'sSQL = sSQL & "'" & txtDepartamento.Text & "',"
|
||
'sSQL = sSQL & "'" & txtFuncionario2.Text & "' )"
|
||
|
||
If Not valiarCampos() Then
|
||
Exit Sub
|
||
End If
|
||
|
||
|
||
sSQL = "sp_CargarFuncionario NULL" & "," & IIf(cboPaisNac.SelectedValue <> Nothing, cboPaisNac.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboEstadoNac.SelectedValue <> Nothing, cboEstadoNac.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboPais.SelectedValue <> Nothing, cboPais.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboEstado.SelectedValue <> Nothing, cboEstado.SelectedValue, "NULL")
|
||
'sSQL = sSQL & "," & IIf(cmbEstado.SelectedValue <> Nothing, cmbEstado.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboDelegacion.SelectedValue <> Nothing, cboDelegacion.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cbobPlaza.SelectedValue <> Nothing, cbobPlaza.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboNacionalidad.SelectedValue <> Nothing, cboNacionalidad.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboSucursal.SelectedValue <> Nothing, cboSucursal.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboGenero.SelectedValue <> Nothing, cboGenero.SelectedValue, "NULL")
|
||
sSQL = sSQL & ",'" & txtNumEmpleado.Text & "'"
|
||
sSQL = sSQL & ",'" & txtNombre.Text & "'"
|
||
sSQL = sSQL & ",'" & txtApePaterno.Text & "'"
|
||
sSQL = sSQL & ",'" & txtApeMaterno.Text & "'"
|
||
sSQL = sSQL & "," & IIf(dtpFechaNac.Checked, "'" & dtpFechaNac.Value.ToString("yyyy/MM/dd") & "'", "NULL")
|
||
'sSQL = sSQL & ",'" & txtApeMaterno.Text & "'"
|
||
sSQL = sSQL & ",'" & txtRFC.Text & "'"
|
||
sSQL = sSQL & ",'" & txtCurp.Text & "'"
|
||
sSQL = sSQL & ",'" & txtCalle.Text & "'"
|
||
sSQL = sSQL & ",'" & txtNoExterior.Text & "'"
|
||
sSQL = sSQL & ",'" & txtNoInterior.Text & "'"
|
||
sSQL = sSQL & ",'" & txtColonia.Text & "'"
|
||
sSQL = sSQL & ",'" & txtCP.Text & "'"
|
||
sSQL = sSQL & ",'" & txtTelefono.Text & "'"
|
||
sSQL = sSQL & ",'" & txtEmail.Text & "'"
|
||
sSQL = sSQL & ",'" & txtArea.Text & "'"
|
||
sSQL = sSQL & ",'" & txtDepartamento.Text & "'"
|
||
sSQL = sSQL & ",'" & txtPuesto.Text & "'"
|
||
sSQL = sSQL & ",'" & Now.Date.ToString("yyyy/MM/dd") & "'"
|
||
sSQL = sSQL & "," & "NULL"
|
||
sSQL = sSQL & "," & chkActivo.CheckState
|
||
|
||
sError = classcom.fnInserta(sSQL)
|
||
If sError <> "" Then
|
||
MessageBox.Show(sError, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||
Exit Sub
|
||
End If
|
||
|
||
'AUDITORIA
|
||
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 95, 1, "Funcionario Nuevo: IdFuncionario: " & txtClave.Text & ", Nombre: " & txtNombre.Text & ",Apellido Paterno: " & txtApePaterno.Text & ", Apellido Materno: " & txtApeMaterno.Text)
|
||
'FIN AUDITORIA
|
||
|
||
MessageBox.Show("Operaci<EFBFBD>n Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||
|
||
Case Is = "ACTUALIZAR"
|
||
|
||
'VALIDACION DE CAMPOS
|
||
'sError = ValidaCampos()
|
||
If sError <> "" Then
|
||
MessageBox.Show(sError, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||
Exit Sub
|
||
End If
|
||
|
||
'sSQL = "UPDATE FUNCIONARIO SET IdSucursal = "
|
||
'If cmbSucursal.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbSucursal.SelectedValue & ", "
|
||
'sSQL = sSQL & "IdEstado = "
|
||
'If cmbEstado.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbEstado.SelectedValue & ", "
|
||
'sSQL = sSQL & "IdNacionalidad = "
|
||
'If cmbNacionalidad.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbNacionalidad.SelectedValue & ", "
|
||
'sSQL = sSQL & "IdTipoEmpleado = "
|
||
'If cmbTipoEmpleado.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbTipoEmpleado.SelectedValue & ", "
|
||
'sSQL = sSQL & "IdPlaza = "
|
||
'If cmbPlaza.SelectedValue Is Nothing Then sSQL = sSQL & "NULL, " Else sSQL = sSQL & cmbPlaza.SelectedValue & ", "
|
||
'sSQL = sSQL & "Nombre = '" & txtNombre.Text & "', "
|
||
'sSQL = sSQL & "ApellidoPaterno = '" & txtApePaterno.Text & "', "
|
||
'sSQL = sSQL & "ApellidoMaterno = '" & txtApeMaterno.Text & "', "
|
||
'sSQL = sSQL & "NoEmpleado = '" & txtNumEmpleado.Text & "', "
|
||
'sSQL = sSQL & "Area = '" & txtArea.Text & "', "
|
||
'sSQL = sSQL & "Activo = " & chkActivo.CheckState & ", "
|
||
'sSQL = sSQL & "RFC = '" & txtRFC.Text & "', "
|
||
'sSQL = sSQL & "CURP = '" & txtCurp.Text & "', "
|
||
'sSQL = sSQL & "Calle = '" & txtCalle.Text & "', "
|
||
'sSQL = sSQL & "Colonia = '" & txtColonia.Text & "', "
|
||
'sSQL = sSQL & "CodigoPostal = '" & txtCP.Text & "', "
|
||
'sSQL = sSQL & "Delegacion = '" & txtDelegacion.Text & "', "
|
||
'sSQL = sSQL & "Telefono = '" & txtTelefono.Text & "', "
|
||
'sSQL = sSQL & "Puesto = '" & txtPuesto.Text & "', "
|
||
'sSQL = sSQL & "Departamento = '" & txtDepartamento.Text & "', "
|
||
''sSQL = sSQL & "idFuncionario2 = '" & txtFuncionario2.Text & "' "
|
||
'sSQL = sSQL & "WHERE IdFuncionario = " & txtClave.Text & " "
|
||
|
||
'If Not valiarCampos() Then
|
||
' Exit Sub
|
||
'End If
|
||
|
||
sSQL = "sp_CargarFuncionario " & txtClave.Text & "," & IIf(cboPaisNac.SelectedValue <> Nothing, cboPaisNac.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboEstadoNac.SelectedValue <> Nothing, cboEstadoNac.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboPais.SelectedValue <> Nothing, cboPais.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboEstado.SelectedValue <> Nothing, cboEstado.SelectedValue, "NULL")
|
||
'sSQL = sSQL & "," & IIf(cmbEstado.SelectedValue <> Nothing, cmbEstado.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboDelegacion.SelectedValue <> Nothing, cboDelegacion.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cbobPlaza.SelectedValue <> Nothing, cbobPlaza.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboNacionalidad.SelectedValue <> Nothing, cboNacionalidad.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboSucursal.SelectedValue <> Nothing, cboSucursal.SelectedValue, "NULL")
|
||
sSQL = sSQL & "," & IIf(cboGenero.SelectedValue <> Nothing, cboGenero.SelectedValue, "NULL")
|
||
sSQL = sSQL & ",'" & txtNumEmpleado.Text & "'"
|
||
sSQL = sSQL & ",'" & txtNombre.Text & "'"
|
||
sSQL = sSQL & ",'" & txtApePaterno.Text & "'"
|
||
sSQL = sSQL & ",'" & txtApeMaterno.Text & "'"
|
||
sSQL = sSQL & "," & IIf(dtpFechaNac.Checked, "'" & dtpFechaNac.Value.ToString("yyyy/MM/dd") & "'", "NULL")
|
||
'sSQL = sSQL & ",'" & txtApeMaterno.Text & "'"
|
||
sSQL = sSQL & ",'" & txtRFC.Text & "'"
|
||
sSQL = sSQL & ",'" & txtCurp.Text & "'"
|
||
sSQL = sSQL & ",'" & txtCalle.Text & "'"
|
||
sSQL = sSQL & ",'" & txtNoExterior.Text & "'"
|
||
sSQL = sSQL & ",'" & txtNoInterior.Text & "'"
|
||
sSQL = sSQL & ",'" & txtColonia.Text & "'"
|
||
sSQL = sSQL & ",'" & txtCP.Text & "'"
|
||
sSQL = sSQL & ",'" & txtTelefono.Text & "'"
|
||
sSQL = sSQL & ",'" & txtEmail.Text & "'"
|
||
sSQL = sSQL & ",'" & txtArea.Text & "'"
|
||
sSQL = sSQL & ",'" & txtDepartamento.Text & "'"
|
||
sSQL = sSQL & ",'" & txtPuesto.Text & "'"
|
||
sSQL = sSQL & ",'" & Now.Date.ToString("yyyy/MM/dd") & "'"
|
||
sSQL = sSQL & "," & "NULL"
|
||
sSQL = sSQL & "," & chkActivo.CheckState
|
||
|
||
classcom = New clsComplejo
|
||
sError = classcom.fnInserta(sSQL)
|
||
If sError <> "" Then
|
||
MessageBox.Show(sError, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||
Exit Sub
|
||
End If
|
||
|
||
'AUDITORIA
|
||
ClassAud.RT_Auditoria(clsVaribles.varUsuario, 96, 1, clsVaribles.lsValAnt & "Funcionario Actualizado: IdFuncionario: " & txtClave.Text & ", Nombre: " & txtNombre.Text & ",Apellido Paterno: " & txtApePaterno.Text & ", Apellido Materno: " & txtApeMaterno.Text)
|
||
'FIN AUDITORIA
|
||
|
||
MessageBox.Show("Operaci<EFBFBD>n Satisfactoria ", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||
|
||
End Select
|
||
|
||
|
||
BtnOk.Enabled = False
|
||
LLenaGrid()
|
||
Dim CLASSCATALOGOS As New ClassCatalogos
|
||
CLASSCATALOGOS.sbLimpiaControlesEsp(PnDatos)
|
||
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, btnExportar)
|
||
DeshabilitaCampos()
|
||
BtnOk.Enabled = False
|
||
BtnEditar.Enabled = False
|
||
BtnAgregar.Enabled = True
|
||
|
||
Catch ex As Exception
|
||
MessageBox.Show("Hubo un error al actualizar los datos." & vbCrLf & ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||
End Try
|
||
|
||
End Sub
|
||
|
||
Private Sub btnCerrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCerrar.Click
|
||
Me.Close()
|
||
End Sub
|
||
|
||
Private Sub GridMaster_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridMaster.DoubleClick
|
||
|
||
For Each item As Control In PnDatos.Controls
|
||
|
||
If TypeOf item Is TextBox Or TypeOf item Is ComboBox Or TypeOf item Is CheckBox Then
|
||
item.Enabled = False
|
||
End If
|
||
Next
|
||
LimpiaCampos()
|
||
clsVaribles.varProceso = "ACTUALIZAR"
|
||
txtClave.Text = Me.GridMaster.Columns("IdFuncionario").Value.ToString()
|
||
txtNombre.Text = Me.GridMaster.Columns("Nombre1").Value.ToString()
|
||
txtApePaterno.Text = Me.GridMaster.Columns("ApellidoPaterno").Value.ToString()
|
||
txtApeMaterno.Text = Me.GridMaster.Columns("ApellidoMaterno").Value.ToString()
|
||
txtNumEmpleado.Text = Me.GridMaster.Columns("NoEmpleado").Value.ToString()
|
||
If Not IsDBNull((Me.GridMaster.Columns("FECHANACIMIENTO").Value)) Then dtpFechaNac.Value = GridMaster.Columns("FECHANACIMIENTO").Value.ToString()
|
||
If Not IsDBNull((Me.GridMaster.Columns("IDSEXO").Value)) Then
|
||
cboGenero.SelectedValue = IIf(GridMaster.Columns("IDSEXO").Value.ToString().Trim = "", -1, GridMaster.Columns("IDSEXO").Value.ToString())
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("IDESTADONACIMIENTO").Value)) Then
|
||
cboEstadoNac.SelectedValue = IIf(GridMaster.Columns("IDESTADONACIMIENTO").Value.ToString().Trim = "", -1, GridMaster.Columns("IDESTADONACIMIENTO").Value.ToString())
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("IDPAISNACIMIENTO").Value)) Then
|
||
cboPaisNac.SelectedValue = IIf(GridMaster.Columns("IDPAISNACIMIENTO").Value.ToString().Trim = "", -1, GridMaster.Columns("IDPAISNACIMIENTO").Value.ToString())
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("NUMEROINT").Value)) Then
|
||
txtNoInterior.Text = GridMaster.Columns("NUMEROINT").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("NUMEROEXT").Value)) Then
|
||
txtNoExterior.Text = GridMaster.Columns("NUMEROEXT").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("IDPAIS").Value)) Then
|
||
cboPais.SelectedValue = IIf(GridMaster.Columns("IDPAIS").Value.ToString() = "", -1, GridMaster.Columns("IDPAIS").Value.ToString())
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("Area").Value)) Then
|
||
txtArea.Text = Me.GridMaster.Columns("Area").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("RFC").Value)) Then
|
||
txtRFC.Text = Me.GridMaster.Columns("RFC").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("CURP").Value)) Then
|
||
txtCurp.Text = Me.GridMaster.Columns("CURP").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("Calle").Value)) Then
|
||
txtCalle.Text = Me.GridMaster.Columns("Calle").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("Colonia").Value)) Then
|
||
txtColonia.Text = Me.GridMaster.Columns("Colonia").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("CP").Value)) Then
|
||
txtCP.Text = Me.GridMaster.Columns("CP").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("Telefono").Value)) Then
|
||
txtTelefono.Text = Me.GridMaster.Columns("Telefono").Value.ToString()
|
||
End If
|
||
'dtpFechaNac.Value = GridMaster.Columns("FECHANACIMIENTO").Value.ToString()
|
||
'dtpFechaNac.Value = IIf(IsDBNull(Me.GridMaster.Columns("FECHANACIMIENTO").Value), 0, Me.GridMaster.Columns("FECHANACIMIENTO").Value)
|
||
'cboGenero.SelectedValue = IIf(GridMaster.Columns("IDSEXO").Value.ToString().Trim = "", -1, GridMaster.Columns("IDSEXO").Value.ToString())
|
||
' cboEstadoNac.SelectedValue = IIf(GridMaster.Columns("IDESTADONACIMIENTO").Value.ToString().Trim = "", -1, GridMaster.Columns("IDESTADONACIMIENTO").Value.ToString())
|
||
' cboPaisNac.SelectedValue = IIf(GridMaster.Columns("IDPAISNACIMIENTO").Value.ToString().Trim = "", -1, GridMaster.Columns("IDPAISNACIMIENTO").Value.ToString())
|
||
'cmbTipoEmpleado.SelectedValue = GridMaster.Columns("").Value.ToString()
|
||
|
||
' txtNoInterior.Text = GridMaster.Columns("NUMEROINT").Value.ToString()
|
||
'txtNoExterior.Text = GridMaster.Columns("NUMEROEXT").Value.ToString()
|
||
'cboPais.SelectedValue = IIf(GridMaster.Columns("IDPAIS").Value.ToString() = "", -1, GridMaster.Columns("IDPAIS").Value.ToString())
|
||
|
||
|
||
' txtArea.Text = Me.GridMaster.Columns("Area").Value.ToString()
|
||
' txtRFC.Text = Me.GridMaster.Columns("RFC").Value.ToString()
|
||
'txtCurp.Text = Me.GridMaster.Columns("CURP").Value.ToString()
|
||
'txtCalle.Text = Me.GridMaster.Columns("Calle").Value.ToString()
|
||
'txtColonia.Text = Me.GridMaster.Columns("Colonia").Value.ToString()
|
||
' txtCP.Text = Me.GridMaster.Columns("CP").Value.ToString()
|
||
'txtDelegacion.Text = Me.GridMaster.Columns("Delegacion").Value.ToString()
|
||
' txtTelefono.Text = Me.GridMaster.Columns("Telefono").Value.ToString()
|
||
If Not IsDBNull((Me.GridMaster.Columns("Puesto").Value)) Then
|
||
txtPuesto.Text = Me.GridMaster.Columns("Puesto").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("Departamento").Value)) Then
|
||
txtDepartamento.Text = Me.GridMaster.Columns("Departamento").Value.ToString()
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("IdSucursal").Value)) Then
|
||
cboSucursal.SelectedValue = IIf(Me.GridMaster.Columns("IdSucursal").Value.ToString() = "", -1, GridMaster.Columns("IdSucursal").Value.ToString())
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("IdEstado").Value)) Then
|
||
cboEstado.SelectedValue = IIf(Me.GridMaster.Columns("IdEstado").Value.ToString() = "", -1, GridMaster.Columns("IdEstado").Value.ToString())
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("IdNacionalidad").Value)) Then
|
||
cboNacionalidad.SelectedValue = IIf(Me.GridMaster.Columns("IdNacionalidad").Value.ToString() = "", -1, GridMaster.Columns("IdNacionalidad").Value.ToString())
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("IdPlaza").Value)) Then
|
||
cbobPlaza.SelectedValue = IIf(Me.GridMaster.Columns("IdPlaza").Value.ToString() = "", -1, GridMaster.Columns("IdPlaza").Value.ToString())
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("IDMUNICIPIO").Value)) Then
|
||
cboDelegacion.SelectedValue = IIf(GridMaster.Columns("IDMUNICIPIO").Value.ToString() = "", -1, GridMaster.Columns("IDMUNICIPIO").Value.ToString())
|
||
End If
|
||
|
||
If Not IsDBNull((Me.GridMaster.Columns("EMAIL").Value)) Then
|
||
|
||
txtEmail.Text = GridMaster.Columns("EMAIL").Value
|
||
End If
|
||
If Not IsDBNull((Me.GridMaster.Columns("ESTATUS").Value)) Then
|
||
chkActivo.Checked = IIf(IsDBNull(Me.GridMaster.Columns("ESTATUS").Value), 0, Me.GridMaster.Columns("ESTATUS").Value)
|
||
End If
|
||
'txtDepartamento.Text = Me.GridMaster.Columns("Departamento").Value.ToString()
|
||
'txtFuncionario2.Text = Me.GridMaster.Columns("idFuncionario2").Value.ToString()
|
||
|
||
'cboSucursal.SelectedValue = IIf(Me.GridMaster.Columns("IdSucursal").Value.ToString() = "", -1, GridMaster.Columns("IdSucursal").Value.ToString())
|
||
'cboEstado.SelectedValue = IIf(Me.GridMaster.Columns("IdEstado").Value.ToString() = "", -1, GridMaster.Columns("IdEstado").Value.ToString())
|
||
' cboNacionalidad.SelectedValue = IIf(Me.GridMaster.Columns("IdNacionalidad").Value.ToString() = "", -1, GridMaster.Columns("IdNacionalidad").Value.ToString())
|
||
'cmbTipoEmpleado.SelectedValue = IIf(Me.GridMaster.Columns("IdTipoEmpleado").Value.ToString() = "", -1, GridMaster.Columns("IdTipoEmpleado").Value.ToString())
|
||
'cbobPlaza.SelectedValue = IIf(Me.GridMaster.Columns("IdPlaza").Value.ToString() = "", -1, GridMaster.Columns("IdPlaza").Value.ToString())
|
||
' cboDelegacion.SelectedValue = IIf(GridMaster.Columns("IDMUNICIPIO").Value.ToString() = "", -1, GridMaster.Columns("IDMUNICIPIO").Value.ToString())
|
||
|
||
'txtEmail.Text = GridMaster.Columns("EMAIL").Value
|
||
|
||
' chkActivo.Checked = IIf(IsDBNull(Me.GridMaster.Columns("ESTATUS").Value), 0, Me.GridMaster.Columns("ESTATUS").Value)
|
||
chkActivo.Enabled = True
|
||
|
||
txtClave.Enabled = False
|
||
BtnEditar.Enabled = True
|
||
ClassCatalogos.CambiaColorbloque2(BtnAgregar, BtnEditar, BtnOk, btnExportar)
|
||
|
||
End Sub
|
||
|
||
Public Sub LimpiaCampos()
|
||
|
||
Dim CLASSCATALOGOS As New ClassCatalogos
|
||
CLASSCATALOGOS.sbLimpiaControlesEsp(PnDatos)
|
||
DeshabilitaCampos()
|
||
|
||
''Limpio los combobox.
|
||
cboSucursal.SelectedIndex = -1
|
||
cboEstado.SelectedIndex = -1
|
||
cboNacionalidad.SelectedIndex = -1
|
||
'cmbTipoEmpleado.SelectedIndex = -1
|
||
cbobPlaza.SelectedIndex = -1
|
||
|
||
cboSucursal.SelectedIndex = -1
|
||
cboEstado.SelectedIndex = -1
|
||
cboNacionalidad.SelectedIndex = -1
|
||
'cmbTipoEmpleado.SelectedIndex = -1
|
||
cbobPlaza.SelectedIndex = -1
|
||
|
||
|
||
cboEstadoNac.SelectedIndex = -1
|
||
cboPaisNac.SelectedIndex = -1
|
||
|
||
cboPais.SelectedIndex = -1
|
||
|
||
End Sub
|
||
|
||
Public Sub LLenaGrid()
|
||
'LLENA GRID
|
||
Dim Classcom As New clsComplejo
|
||
Dim ClassCatalogos As New ClassCatalogos
|
||
Dim SQL As String
|
||
'Sql = "SELECT IdFuncionario, IdSucursal, IdEstado, IdNacionalidad, IdTipoEmpleado, IdPlaza, Nombre, ApellidoPaterno, "
|
||
'Sql = Sql & "ApellidoMaterno, NoEmpleado, Area, Activo, RFC, CURP, Calle, Colonia, CodigoPostal, Delegacion, Telefono, "
|
||
'SQL = SQL & "Puesto, Departamento, idFuncionario2 FROM Funcionario ORDER BY IdFuncionario"
|
||
|
||
|
||
SQL = "sp_ConsultarFuncionario 0"
|
||
|
||
|
||
ClassCatalogos.LlenaGrid(SQL, Me.GridMaster)
|
||
For Each col As C1.Win.C1TrueDBGrid.C1DisplayColumn In GridMaster.Splits(0).DisplayColumns
|
||
col.AutoSize()
|
||
If InStr(col.Name, "ID") > 0 Then
|
||
col.Visible = False
|
||
End If
|
||
If col.Name = "NOMBRE1" Then
|
||
col.Visible = False
|
||
End If
|
||
Next
|
||
Classcom = New clsComplejo
|
||
Classcom.sbLlenaCombo("sp_ConsultarGenero 0", cboGenero)
|
||
Classcom = New clsComplejo
|
||
Classcom.sbLlenaCombo("sp_ConsultarEstado 0", cboEstadoNac)
|
||
Classcom = New clsComplejo
|
||
Classcom.sbLlenaCombo("sp_ConsultarPais ", cboPaisNac)
|
||
Classcom = New clsComplejo
|
||
|
||
Classcom.sbLlenaCombo("sp_ConsultarSucursal 0", cboSucursal)
|
||
'Classcom = New clsComplejo
|
||
'Classcom.sbLlenaCombo("sp_ConsultarTEmpleado 0", cmbTipoEmpleado)
|
||
|
||
Classcom = New clsComplejo
|
||
Classcom.sbLlenaCombo("sp_ComboPlaza 0", cbobPlaza)
|
||
|
||
Classcom = New clsComplejo
|
||
Classcom.sbLlenaCombo("sp_ConsultarMunicipio 0", cboDelegacion)
|
||
|
||
Classcom = New clsComplejo
|
||
Classcom.sbLlenaCombo("sp_ConsultarNacionalidad 0", cboNacionalidad)
|
||
|
||
Classcom = New clsComplejo
|
||
Classcom.sbLlenaCombo("sp_ConsultarEstado 0", cboEstado)
|
||
Classcom = New clsComplejo
|
||
|
||
Classcom.sbLlenaCombo("sp_ConsultarPais ", cboPais)
|
||
|
||
'Classcom.sbLlenaComboESP("SELECT IdSucursal AS clave, CAST(IdSucursal AS VARCHAR) + ') ' + Sucursal AS nombre FROM Cat_Sucursal", Me.cmbSucursal, "Nombre")
|
||
'Classcom.sbLlenaComboESP("SELECT IdEstado AS clave, CAST(IdEstado AS VARCHAR) + ') ' + Estado AS Nombre FROM Cat_Estado", Me.cmbEstado, "Nombre")
|
||
'Classcom.sbLlenaComboESP("SELECT IdNacionalidad AS clave, CAST(IdNacionalidad AS VARCHAR) + ') ' + Nacionalidad AS Nombre FROM Cat_Nacionalidad ", Me.cmbNacionalidad, "Nombre")
|
||
'Classcom.sbLlenaComboESP("SELECT IdTipoEmpleado AS clave, CAST(IdTipoEmpleado AS VARCHAR) + ') ' + TipoEmpleado AS Nombre FROM Cat_TipoEmpleado ", Me.cmbTipoEmpleado, "Nombre")
|
||
'Classcom.sbLlenaComboESP("SELECT IdPlaza AS clave, CAST(IdPlaza AS VARCHAR) + ') ' + Plaza AS Nombre FROM Cat_Plaza", Me.cmbPlaza, "Nombre")
|
||
|
||
cboSucursal.SelectedIndex = -1
|
||
cboEstado.SelectedIndex = -1
|
||
cboNacionalidad.SelectedIndex = -1
|
||
'cmbTipoEmpleado.SelectedIndex = -1
|
||
cbobPlaza.SelectedIndex = -1
|
||
|
||
cboSucursal.SelectedIndex = -1
|
||
cboEstado.SelectedIndex = -1
|
||
cboNacionalidad.SelectedIndex = -1
|
||
'cmbTipoEmpleado.SelectedIndex = -1
|
||
cbobPlaza.SelectedIndex = -1
|
||
|
||
cboGenero.SelectedIndex = -1
|
||
|
||
cboEstadoNac.SelectedIndex = -1
|
||
cboPaisNac.SelectedIndex = -1
|
||
|
||
cboPais.SelectedIndex = -1
|
||
|
||
|
||
|
||
End Sub
|
||
|
||
Public Sub DeshabilitaCampos()
|
||
|
||
For Each ctrl As Control In PnDatos.Controls
|
||
If TypeOf ctrl Is Label Then
|
||
ctrl.Enabled = True
|
||
Else
|
||
ctrl.Enabled = False
|
||
End If
|
||
|
||
Next
|
||
|
||
|
||
|
||
End Sub
|
||
|
||
Private Sub colorLabel()
|
||
|
||
For Each ctrl As Control In PnDatos.Controls
|
||
If TypeOf ctrl Is Label Then
|
||
ctrl.ForeColor = Color.DarkBlue
|
||
End If
|
||
|
||
Next
|
||
|
||
End Sub
|
||
|
||
Public Sub HabilitaCampos()
|
||
''Deshabilida campos
|
||
'txtClave.Enabled = True
|
||
'txtNombre.Enabled = True
|
||
'txtApePaterno.Enabled = True
|
||
'txtApeMaterno.Enabled = True
|
||
'txtNumEmpleado.Enabled = True
|
||
'txtArea.Enabled = True
|
||
'txtRFC.Enabled = True
|
||
'txtCurp.Enabled = True
|
||
'txtCalle.Enabled = True
|
||
'txtColonia.Enabled = True
|
||
'txtCP.Enabled = True
|
||
''txtDelegacion.Enabled = True
|
||
'cboDelegacion.Enabled = True
|
||
'txtTelefono.Enabled = True
|
||
'txtPuesto.Enabled = True
|
||
'txtDepartamento.Enabled = True
|
||
''txtFuncionario2.Enabled = True
|
||
|
||
'cmbSucursal.Enabled = True
|
||
'cmbEstado.Enabled = True
|
||
'cmbNacionalidad.Enabled = True
|
||
'cmbTipoEmpleado.Enabled = True
|
||
'cmbPlaza.Enabled = True
|
||
|
||
|
||
For Each item As Control In PnDatos.Controls
|
||
|
||
If TypeOf item Is TextBox Or TypeOf item Is ComboBox Or TypeOf item Is CheckBox Or TypeOf item Is DateTimePicker Then
|
||
item.Enabled = True
|
||
End If
|
||
Next
|
||
|
||
|
||
|
||
End Sub
|
||
|
||
Public Function ValidaCampos() As String
|
||
|
||
Dim sResultado As String
|
||
sResultado = ""
|
||
|
||
If txtClave.Text = "" Then
|
||
sResultado = sResultado & "Es Necesario Introducir el Id del Funcionario. " & vbCrLf
|
||
End If
|
||
If cboSucursal.SelectedValue Is Nothing Then
|
||
sResultado = sResultado & "Es Necesario Introducir la Sucursal del Funcionario. " & vbCrLf
|
||
End If
|
||
|
||
If cboEstado.SelectedValue Is Nothing Then
|
||
sResultado = sResultado & "Es Necesario Introducir el Estado. " & vbCrLf
|
||
End If
|
||
|
||
If cboNacionalidad.SelectedValue Is Nothing Then
|
||
sResultado = sResultado & "Es Necesario Introducir la Nacionalidad del Funcionario. " & vbCrLf
|
||
End If
|
||
|
||
'If cmbTipoEmpleado.SelectedValue Is Nothing Then
|
||
' sResultado = sResultado & "Es Necesario Introducir el tipo de empleado del Funcionario. " & vbCrLf
|
||
'End If
|
||
|
||
If txtNombre.Text = "" Then
|
||
sResultado = sResultado & "Es Necesario Introducir el nombre del Funcionario. " & vbCrLf
|
||
End If
|
||
If txtApePaterno.Text = "" Then
|
||
sResultado = sResultado & "Es Necesario Introducir el apellido paterno del Funcionario. " & vbCrLf
|
||
End If
|
||
If txtApeMaterno.Text = "" Then
|
||
sResultado = sResultado & "Es Necesario Introducir el apellido materno del Funcionario. " & vbCrLf
|
||
End If
|
||
|
||
If txtNumEmpleado.Text = "" Then
|
||
sResultado = sResultado & "Es Necesario Introducir el N<>mero de Empleado del Funcionario. " & vbCrLf
|
||
End If
|
||
|
||
'If txtFuncionario2.Text = "" Then
|
||
' sResultado = sResultado & "Es Necesario Introducir el IdFuncionario2. " & vbCrLf
|
||
'End If
|
||
|
||
''Valida CP
|
||
If txtCP.Text <> "" Then
|
||
If IsNumeric(txtCP.Text) = False Or txtCP.Text.Length <> 5 Then
|
||
sResultado = sResultado & "El c<>digo postal debe ser un n<>mero de 5 digitos. " & vbCrLf
|
||
End If
|
||
End If
|
||
|
||
ValidaCampos = sResultado
|
||
End Function
|
||
|
||
Private Sub ComboBox3_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboPais.SelectedIndexChanged, cboPaisNac.SelectedIndexChanged
|
||
|
||
End Sub
|
||
Private Sub Label27_Click(sender As System.Object, e As System.EventArgs) Handles lblPais.Click, lblPaisNac.Click
|
||
|
||
End Sub
|
||
|
||
Private Sub PnDatos_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles PnDatos.Paint
|
||
|
||
End Sub
|
||
|
||
Private Sub dtpFechaNac_ValueChanged(sender As System.Object, e As System.EventArgs) Handles dtpFechaNac.ValueChanged
|
||
|
||
If dtpFechaNac.Checked Then
|
||
dtpFechaNac.CustomFormat = "dd/MM/yyyy"
|
||
|
||
Else
|
||
dtpFechaNac.CustomFormat = "NULL"
|
||
End If
|
||
|
||
End Sub
|
||
|
||
Private Function valiarCampos() As Boolean
|
||
Dim listaControlesParaValidacion As New List(Of Control)
|
||
Dim listaControlTotal As New List(Of Control)
|
||
Dim resultado As New List(Of elementoLista)
|
||
|
||
For Each ctrl As Control In Me.Controls
|
||
|
||
If ctrl.Tag <> Nothing Then
|
||
listaControlesParaValidacion.Add(ctrl)
|
||
End If
|
||
|
||
listaControlTotal.Add(ctrl)
|
||
ObtenerControlesHijos(ctrl, listaControlesParaValidacion, listaControlTotal)
|
||
|
||
Next
|
||
|
||
resultado = VariablesGlobales.validarFuncionario(listaControlesParaValidacion, listaControlTotal)
|
||
|
||
|
||
Dim mensaje As String = ""
|
||
|
||
For Each elem As elementoLista In resultado.OrderBy(Function(e) e.Orden)
|
||
|
||
mensaje &= elem.Mensaje & Environment.NewLine
|
||
|
||
elem.ctrl.ForeColor = Color.Red
|
||
|
||
Next
|
||
|
||
If mensaje = "" Then
|
||
Return True
|
||
Else
|
||
MessageBox.Show(mensaje)
|
||
Return False
|
||
End If
|
||
|
||
End Function
|
||
|
||
Private Sub ObtenerControlesHijos(ctrl As Control, ByRef listaControlesParaValidacion As List(Of Control), ByRef listaControlesTotal As List(Of Control))
|
||
|
||
For Each ctrlHijo As Control In ctrl.Controls
|
||
|
||
If ctrlHijo.Tag <> Nothing Then
|
||
listaControlesParaValidacion.Add(ctrlHijo)
|
||
End If
|
||
|
||
listaControlesTotal.Add(ctrlHijo)
|
||
ObtenerControlesHijos(ctrlHijo, listaControlesParaValidacion, listaControlesTotal)
|
||
|
||
Next
|
||
|
||
End Sub
|
||
|
||
Private Sub txtNumEmpleado_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtNumEmpleado.KeyPress
|
||
Dim classCom As New ClassCatalogos
|
||
'If e.KeyChar <> Convert.ToChar(Keys.Back) Then
|
||
' e.KeyChar = classCom.ValidaCampos("numeros", e.KeyChar)
|
||
'End If
|
||
End Sub
|
||
|
||
Private Sub btnExportar_Click(sender As System.Object, e As System.EventArgs) Handles btnExportar.Click
|
||
Exportar()
|
||
End Sub
|
||
|
||
Private Sub Exportar()
|
||
Dim cls As clsComplejo
|
||
Try
|
||
If GridMaster.DataSource Is Nothing Then
|
||
MessageBox.Show("No hay datos para exportar.", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
||
Return
|
||
End If
|
||
cls = New clsComplejo()
|
||
Dim DS As DataSet = cls.fdtDataSet("spS_FuncionariosExport")
|
||
|
||
|
||
Dim sError As String = ""
|
||
''Inicia Exportacion
|
||
'Creo una instancia de la clase aExcel
|
||
Dim clsExcel As aExcel = New aExcel
|
||
'Obtenemos el nombre o el titulo del form
|
||
clsExcel.Titulo = "Funcionarios"
|
||
'Utilizo la funcion ExportDataset de la clase aExcel
|
||
clsExcel.ExportDataset(DS) 'Asigno el dataset a exportar
|
||
Catch ex As Exception
|
||
|
||
End Try
|
||
End Sub
|
||
|
||
End Class |