Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int aux = 0;

            cont = co.Matricula().Rows.Count;

            Conecta  cl = new Conecta();
            Variavel va = new Variavel();

            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
            {
                string      msg = "PREENCHER TODOS OS CAMPOS";
                frmMensagem mg  = new frmMensagem(msg);
                mg.ShowDialog();
            }
            else
            {
                if (cont == 0)
                {
                    va.Matricula = Convert.ToInt32(textBox1.Text);
                    va.Nome      = textBox2.Text;
                    va.Registro  = textBox3.Text;
                    cl.cadastro(va);
                    string      msg = "RM CADASTRADO";
                    frmMensagem mg  = new frmMensagem(msg);
                    mg.ShowDialog();
                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox3.Text = "";
                }

                while (aux < cont)
                {
                    if (co.Matricula().Rows[aux]["rm"].ToString() != textBox1.Text || co.Matricula().Rows[aux]["rg"].ToString() == textBox3.Text)
                    {
                        va.Matricula = Convert.ToInt32(textBox1.Text);
                        va.Nome      = textBox2.Text;
                        va.Registro  = textBox3.Text;
                        cl.cadastro(va);
                        string      msg = "RM CADASTRADO";
                        frmMensagem mg  = new frmMensagem(msg);
                        mg.ShowDialog();
                        aux = cont;
                    }
                    else
                    {
                        string      msg = "RM JÁ CADASTRADO";
                        frmMensagem mg  = new frmMensagem(msg);
                        mg.ShowDialog();
                    }
                    aux = aux + 1;
                }
                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
            }
        }