Beispiel #1
0
 private void txtPlaca_Leave(object sender, EventArgs e)
 {
     txtPlaca.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
     txtPlaca.Text           = txtPlaca.Text.Trim().Replace(" ", "");
     if (txtPlaca.Text.Length < 7 && txtPlaca.Text.Length >= 0)
     {
         MessageBox.Show("O campo [ PLACA ] está inválido!");
         txtPlaca.Focus();
         btnSalvar.Enabled = false;
     }
     else if (txtPlaca.Text.Length == 7)
     {
         txtPlaca.TextMaskFormat = MaskFormat.IncludeLiterals;
         var teste = oDAO.GetByPlaca(txtPlaca.Text, cli.Idcliente);
         if (teste != null)
         {
             btnSalvar.Enabled = false;
             Clientes old_cli = new ClienteDAO().GetById(teste.Idcliente);
             MessageBox.Show("Veiculo Já Cadastrado para: \n" + old_cli.Idcliente + " - " + old_cli.Nome, "RTPark", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtPlaca.Focus();
         }
         else
         {
             txtPlaca.TextMaskFormat = MaskFormat.IncludeLiterals;
             btnSalvar.Enabled       = true;
         }
     }
     else
     {
         MessageBox.Show("O campo [ PLACA ] está inválido!");
         txtPlaca.Focus();
         btnSalvar.Enabled = false;
     }
     txtPlaca.TextMaskFormat = MaskFormat.IncludeLiterals;
 }
        private void BuscaPlaca()
        {
            VeiculosClienteDAO vDAO = new VeiculosClienteDAO();

            vc = vDAO.GetByPlaca(txtPlaca.Text);

            if (vc != null)
            {
                txtVeiculo.Text = vc.Veiculo;
                switch (vc.Tipo)
                {
                case 'C':
                    rbCarro.Checked = true;
                    break;

                case 'M':
                    rbMoto.Checked = true;
                    break;

                case 'O':
                    rbOutros.Checked = true;
                    break;
                }
                BuscaCLiente();
            }
            else
            {
                txtVeiculo.Text = null;
                rbCarro.Checked = true;

                txtIdContrato.Text       = null;
                txtNomeContrato.Text     = null;
                cboServico.SelectedValue = config.CobrancaPadrao;

                lblCliente.Text             = null;
                txtDocFed.Text              = null;
                cboTipoPessoa.SelectedIndex = 0;

                vc    = null;
                cli   = null;
                contr = null;
            }
            MontaCupom();
        }