Ejemplo n.º 1
0
        private void txtPlaca_Leave(object sender, EventArgs e)
        {
            Movimentos test = oDAO.GetByCampo("placa = '", txtPlaca.Text + "' ", 'S');

            txtPlaca.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
            txtPlaca.Text           = txtPlaca.Text.Trim().Replace(" ", "");
            if (txtPlaca.Text.Length < 7 && txtPlaca.Text.Length >= 0)
            {
                txtPlaca.Focus();
                btnSalvar.Enabled = false;
                txtPlaca.Clear();
            }
            else if (txtPlaca.Text.Length == 7)
            {
                if (test != null)
                {
                    btnSalvar.Enabled = false;
                    MessageBox.Show("Veiculo Já Estacionado! Placa: " + test.Placa, "RTPark", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPlaca.Focus();
                }
                else
                {
                    txtPlaca.TextMaskFormat = MaskFormat.IncludeLiterals;
                    BuscaPlaca();
                    btnSalvar.Enabled       = true;
                    txtPlaca.TextMaskFormat = MaskFormat.IncludeLiterals;
                    txtPlaca.TabStop        = false;
                    txtPlaca.ReadOnly       = true;
                    txtPlaca.BackColor      = Color.White;
                    txtPlaca.ForeColor      = Color.Blue;
                }
            }
            else
            {
                MessageBox.Show("O campo [ PLACA ] está inválido!");
                txtPlaca.Focus();
                btnSalvar.Enabled = false;
            }
        }
Ejemplo n.º 2
0
        } //OK

        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)
            {
                txtPlaca.Focus();
                btnSalvar.Enabled = false;
                txtPlaca.Clear();
            }
            else if (txtPlaca.Text.Length == 7)
            {
                txtPlaca.TextMaskFormat = MaskFormat.IncludeLiterals;
                obj = mDAO.GetByCampo("placa = '", txtPlaca.Text + "' ", 'S');
                if (obj != null)
                {
                    btnSalvar.Enabled = true;
                    PreencheMovimento();
                }
                else
                {
                    MessageBox.Show("PLACA INVÁLIDA! \n" +
                                    "Veiculo não estacionado.", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPlaca.Focus();
                    btnSalvar.Enabled = false;
                    txtPlaca.Clear();
                }
            }
            else
            {
                MessageBox.Show("O campo [ PLACA ] está inválido!", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPlaca.Focus();
                btnSalvar.Enabled = false;
            }
            txtPlaca.TextMaskFormat = MaskFormat.IncludeLiterals;
        }