コード例 #1
0
 private void NR_CPF_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(NR_CPF.Text.SoNumero()))
     {
         Utils.CPF_Valido.nr_CPF = NR_CPF.Text;
         if (string.IsNullOrEmpty(Utils.CPF_Valido.nr_CPF))
         {
             MessageBox.Show("CPF Invalido.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
             NR_CPF.Clear();
             NR_CPF.Focus();
         }
     }
 }
コード例 #2
0
 private void Valida_CPF()
 {
     if ((NR_CPF.Text.Trim() != string.Empty) && (NR_CPF.Text.Trim() != ".   .   -"))
     {
         CPF_Valido.nr_CPF = NR_CPF.Text;
         if (CPF_Valido.nr_CPF.Trim() != string.Empty)
         {
             if (Convert.ToDecimal(CPF_Valido.nr_CPF.SoNumero()) != 0)
             {
                 object obj = new TCD_CadClifor().BuscarEscalar(
                     new TpBusca[]
                 {
                     new TpBusca()
                     {
                         vNM_Campo = "a.cd_clifor",
                         vOperador = "<>",
                         vVL_Busca = "'" + cd_clifor.Text.Trim() + "'"
                     },
                     new TpBusca()
                     {
                         vNM_Campo = "a.nr_cpf",
                         vOperador = "=",
                         vVL_Busca = "'" + NR_CPF.Text.Trim() + "'"
                     }
                 }, "a.cd_clifor + a.nm_clifor");
                 if (obj == null ? false : obj.ToString().Trim() != string.Empty)
                 {
                     MessageBox.Show("O número do CPF: " + NR_CPF.Text + " já está cadastrado no sistema, \r\n com o CLIFOR: " + obj.ToString().Trim() + "\r\n Por Favor, Verifique!",
                                     "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                     NR_CPF.Clear();
                     NR_CPF.Focus();
                 }
             }
         }
         else
         {
             MessageBox.Show("Por Favor! Entre com um CPF Válido!", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
             NR_CPF.Clear();
             NR_CPF.Focus();
         }
     }
 }