예제 #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 = "";
            }
        }
예제 #2
0
        public void Excluir(Variavel va)
        {
            conexao = new MySqlConnection(Endereco());
            conexao.Open();
            string       alterar = "DELETE FROM matricula WHERE rm = '" + va.Matricula + "'";
            MySqlCommand comando = new MySqlCommand(alterar, conexao);

            comando.ExecuteNonQuery();
            conexao.Close();
        }
예제 #3
0
        public void Editar(Variavel va)
        {
            conexao = new MySqlConnection(Endereco());
            conexao.Open();
            string       alterar = "UPDATE matricula SET rm = '" + va.Matricula + "',nome = '" + va.Nome + "',rg = '" + va.Registro + "'WHERE rm = '" + va.Matricula + "'";
            MySqlCommand comando = new MySqlCommand(alterar, conexao);

            comando.ExecuteNonQuery();
            conexao.Close();
        }
예제 #4
0
        public DataTable Selecionar(Variavel va)
        {
            DataTable dt = new System.Data.DataTable();

            try
            {
                if (va.Opcao == "Nome")
                {
                    conexao = new MySqlConnection(Endereco());
                    conexao.Open();
                    string           selecionar = "SELECT rm, nome, rg, spdoc FROM matricula where nome like'%" + va.Nome + "%'";
                    MySqlDataAdapter comandos   = new MySqlDataAdapter(selecionar, conexao);
                    comandos.Fill(dt);
                    conexao.Close();
                }
                else if (va.Opcao == "RG")
                {
                    conexao = new MySqlConnection(Endereco());
                    conexao.Open();
                    string           selecionar = "SELECT rm, nome, rg, spdoc FROM matricula where rg='" + va.Registro + "'";
                    MySqlDataAdapter comandos   = new MySqlDataAdapter(selecionar, conexao);
                    comandos.Fill(dt);
                    conexao.Close();
                }
                else if (va.Opcao == "RM")
                {
                    conexao = new MySqlConnection(Endereco());
                    conexao.Open();
                    string           selecionar = "SELECT rm, nome, rg, spdoc FROM matricula where rm='" + va.Matricula + "'";
                    MySqlDataAdapter comandos   = new MySqlDataAdapter(selecionar, conexao);
                    comandos.Fill(dt);
                    conexao.Close();
                }
                else if (va.Opcao == "Intervalo")
                {
                    conexao = new MySqlConnection(Endereco());
                    conexao.Open();
                    string           selecionar = "SELECT rm, nome, rg, spdoc FROM matricula where rm between'" + va.Matricula + "' and '" + va.MatriculaFinal + "'";
                    MySqlDataAdapter comandos   = new MySqlDataAdapter(selecionar, conexao);
                    comandos.Fill(dt);
                    conexao.Close();
                }
                return(dt);
            }
            catch (Exception ex)
            {
                throw new Exception("Erro de comandos: " + ex.Message);
            }
        }
예제 #5
0
 public void spdoc(Variavel va)
 {
     try
     {
         conexao = new MySqlConnection(Endereco());
         conexao.Open();
         string       atualizar = "update matricula set spdoc='" + va.SpDoc + "' where rm='" + va.Matricula + "'";
         MySqlCommand comandos  = new MySqlCommand(atualizar, conexao);
         comandos.ExecuteNonQuery();
         conexao.Close();
     }
     catch (Exception ex)
     {
         throw new Exception("Erro de comandos: " + ex.Message);
     }
 }
예제 #6
0
 public void cadastro(Variavel va)
 {
     try
     {
         conexao = new MySqlConnection(Endereco());
         conexao.Open();
         string       inserir  = "INSERT INTO matricula(rm, nome, rg)VALUES('" + va.Matricula + "','" + va.Nome + "','" + va.Registro + "')";
         MySqlCommand comandos = new MySqlCommand(inserir, conexao);
         comandos.ExecuteNonQuery();
         conexao.Close();
     }
     catch (Exception ex)
     {
         throw new Exception("Erro de comandos: " + ex.Message);
     }
 }
예제 #7
0
 public DataTable Excel(Variavel va)
 {
     try
     {
         OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + va.Caminho + ";Extended Properties=Excel 12.0;");
         con.Open();
         OleDbDataAdapter query = new OleDbDataAdapter(" SELECT * FROM [Planilha1$]", con);
         DataTable        dt    = new DataTable();
         query.Fill(dt);
         con.Close();
         return(dt);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro de comandos: " + ex.Message);
     }
 }
예제 #8
0
 public DataTable CompararRM(Variavel va)
 {
     try
     {
         conexao = new MySqlConnection(Endereco());
         conexao.Open();
         string           selecionar = "SELECT rm FROM matricula WHERE rm = '" + va.Opcao + "'";
         MySqlDataAdapter comandos   = new MySqlDataAdapter(selecionar, conexao);
         DataTable        dt         = new System.Data.DataTable();
         comandos.Fill(dt);
         conexao.Close();
         return(dt);
     }
     catch (Exception ex)
     {
         throw new Exception("Erro de comandos: " + ex.Message);
     }
 }