Você está na página 1de 3

' Limpa todos os controles de entrada de dados (TextBox ou Mas edTextBox) Public Sub LimparCampos(ByVal Controle As Control) For

Each Objeto As Control In Controle.Controls If Objeto.Controls.Count > 0 Then LimparCampos(Objeto) Else If (TypeOf Objeto Is TextBox) Or (TypeOf Objeto Is Mas edTextBox ) Then Objeto.Text = "" End If End If Next Objeto End Sub ' Bloqueia os os controles de entrada de dados Public Sub BloquearCampo(ByVal Controle As System.Object) Controle.ReadOnly = True End Sub ' Desbloqueia os os controles de entrada de dados Public Sub DesbloquearCampo(ByVal Controle As System.Object) Controle.ReadOnly = False End Sub ' Converte uma data no formato DD/MM/AAAA para AAAA/MM/DD, aceita pelo MysQL Public Function DataInvertida(ByVal strData As String) Dim strNovaData As String strNovaData = strData.Substring(6, 4) + "/" + strData.Substring(3, 2) + "/" + strData.Substring(0, 2) Return strNovaData End Function ' Troca o ponto por vrgula nas casas decimais Public Sub PontoParaVirgula(ByVal e As System.Windows.Forms.KeyPressEventArg s) Dim strDigitos As String = "0123456789" If e.KeyChar <> Microsoft.VisualBasic.Chr(8) Then If e.KeyChar = "." Then System.Windows.Forms.SendKeys.Send(",") Else If InStr(strDigitos, e.KeyChar) = 0 Then e = Nothing End If End If End If End Sub ' Troca a vrgula nas casas decimais por ponto Public Function VirgulaParaPonto(ByVal strValor As String) Return strValor.Replace(",", ".") End Function ' Limpa controles Chec Box atribuindo o valor False propriedade Chec ed Public Sub LimparChec Box(ByVal Controle As Control) For Each Objeto As Object In Controle.Controls If Objeto.Controls.Count > 0 Then LimparChec Box(Objeto)

Else If (TypeOf Objeto Is Chec Box) Then Objeto.Chec ed = False End If End If Next Objeto End Sub ' Retorna se o usurio possui ou no acesso ao boto do formulrio de cadastro Public Function HabilitaBotao(ByVal strTabela As String, ByVal strBotao As S tring, ByVal intNivelAcesso As Integer) As Boolean Dim strComandoSQL, strNomeCampo As String Dim cmdComandoSQL As MySqlCommand Dim rdrRegistro As MySqlDataReader Dim BancoDados As ClasseBancoDados Dim blnRetorno As Boolean blnRetorno = True strNomeCampo = "" BancoDados = New ClasseBancoDados("Server=localhost;Database=db_imobilia ria;Uid=usuario1;Pwd=a1b2c3;") BancoDados.Abrir() strComandoSQL = "SELECT * FROM nivel_acesso WHERE Nivel_Acesso = " + int NivelAcesso.ToString cmdComandoSQL = New MySqlCommand(strComandoSQL, BancoDados.ConexaoAtiva) rdrRegistro = cmdComandoSQL.ExecuteReader() rdrRegistro.Read() If strBotao.ToUpper = "BTNADICIONAR" Then strNomeCampo = "Cadastrar" ElseIf strBotao.ToUpper = "BTNEDITAR" Then strNomeCampo = "Editar" ElseIf strBotao.ToUpper = "BTNEXCLUIR" Then strNomeCampo = "Excluir" End If If strTabela.ToLower = "usuarios" Then strNomeCampo = strNomeCampo + "_Usuario" ElseIf strTabela.ToLower = "clientes" Then strNomeCampo = strNomeCampo + "_Clientes" ElseIf strTabela.ToLower = "fiadores" Then strNomeCampo = strNomeCampo + "_Fiadores" ElseIf strTabela.ToLower = "cidades" Then strNomeCampo = strNomeCampo + "_Cidades" ElseIf strTabela.ToLower = "corretores" Then strNomeCampo = strNomeCampo + "_Corretores" ElseIf strTabela.ToLower = "imoveis" Then strNomeCampo = strNomeCampo + "_Imoveis" End If blnRetorno = IIf(rdrRegistro(strNomeCampo).ToString = "S", True, False) rdrRegistro.Close() cmdComandoSQL.Dispose() BancoDados.Fechar()

BancoDados = Nothing Return blnRetorno End Function

Você também pode gostar