Пример #1
0
        public List <Bicicletas> ListaId(string id)
        {
            List <Bicicletas> ListBikes = new List <Bicicletas>();

            try
            {
                BD.conectar();
                MySqlCommand cmd = BD.MConn.CreateCommand();
                cmd.CommandText = "SELECT * FROM bicicletas  WHERE codigo_bicicleta = " + id;
                MySqlDataReader dr = cmd.ExecuteReader();
                cmd = new MySqlCommand(cmd.CommandText, BD.MConn);

                while (dr.Read())
                {
                    EstacoesDAO eDAO = new EstacoesDAO();
                    Estacoes    e    = eDAO.SelecionaEstacaoNome((String)dr["nome"]);

                    Bicicletas b = new Bicicletas((Convert.ToInt16(dr["codigo_bicicleta"])), (String)dr["cor"], (String)dr["modelo"], e);

                    ListBikes.Add(b);
                }
            }

            catch (MySqlException ex)
            {
                MessageBox.Show("Errp no select @atracoes!\n" + ex);
            }

            finally
            {
                BD.desconectar();
            }

            return(ListBikes);
        }
Пример #2
0
        private void btnCadastrarBicicletas_Click(object sender, EventArgs e)
        {
            int    CODIGO_BICICLETA = 0;
            string MODELO           = txtbModelo.Text;
            string COR = txtbCor.Text;

            if (modo == "EditaBicicleta")
            {
                Estacoes    et   = new Estacoes();
                EstacoesDAO eDAO = new EstacoesDAO();
                et = eDAO.SelecionaEstacaoNome(cmbSelecionaEstacao.Text);
                BicicletasDAO bDAO = new BicicletasDAO();
                bDAO.Editar(new Bicicletas(CODIGO_BICICLETA, COR, MODELO, et), id);
                this.Close();
            }


            else if (txtbCor.Text == "" || txtbModelo.Text == "")
            {
                MessageBox.Show("Preencha Todos os Campos !", "Atenção !", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            else
            {
                Estacoes    er   = new Estacoes();
                EstacoesDAO eDAO = new EstacoesDAO();
                er = eDAO.SelecionaEstacaoNome(cmbSelecionaEstacao.Text);
                BicicletasDAO bDAO = new BicicletasDAO();
                bDAO.Inserir(new Bicicletas(CODIGO_BICICLETA, COR, MODELO, er));
                this.Close();
            }
        }
        private void btnCadastrarEstacoes_Click(object sender, EventArgs e)
        {
            int CODIGO_ESTACAO = 0;
            string NOME = txtbNome.Text;
            string RUA = txtbRua.Text;
            string BAIRRO = txtbBairro.Text;
            string NUMERO = txtbNumero.Text;
            string TELEFONE = txtbTelefone.Text;
            string CEP = txtbCEP.Text;

            if (modo == "EditaEstacao")
            {
                EstacoesDAO eDAO = new EstacoesDAO();
                eDAO.Editar(new Estacoes(CODIGO_ESTACAO, NOME, RUA, BAIRRO, NUMERO, CEP, TELEFONE), id);
                this.Close();

            }

            else if (txtbNome.Text == "" || txtbRua.Text == "" || txtbBairro.Text == "" || txtbNumero.Text == "" || txtbTelefone.Text=="")
            {

                MessageBox.Show("Preencha Todos os Campos !", "Atenção !", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            else
            {
                Estacoes et = new Estacoes(CODIGO_ESTACAO, NOME, RUA, BAIRRO, NUMERO, CEP, TELEFONE);
                EstacoesDAO ed = new EstacoesDAO();
                ed.Inserir(et);
                Close();
            }
        }
Пример #4
0
        private void PrincipalEstacoesFORM_Load(object sender, EventArgs e)
        {
            EstacoesDAO     ed = new EstacoesDAO();
            List <Estacoes> le = new List <Estacoes>();

            le = ed.ListaTodos();
            dtgEstacoes.DataSource = le;
        }
Пример #5
0
        public void atualizaDataGridComboBox()
        {
            EstacoesDAO eDAO = new EstacoesDAO();

            cmbSelecionaEstacao.DataSource    = eDAO.ListaTodos();
            cmbSelecionaEstacao.DisplayMember = "nome";

            dtgEstacoes.DataSource = eDAO.ListaTodos();
        }
Пример #6
0
        private void btnPesquisaEstacao_Click(object sender, EventArgs e)
        {
            EstacoesDAO     er = new EstacoesDAO();
            List <Estacoes> ListE;

            string where = "";
            if (txtbPesquisaEstacao.Text != "")
            {
                where = "nome like " + "'%" + txtbPesquisaEstacao.Text + "%'";
            }


            ListE = er.SelecionaEstacaoNomeWhere(where);
            dtgEstacoes.DataSource = ListE;
        }
Пример #7
0
        private void CadastrarBicicletasFORM_Load(object sender, EventArgs e)
        {
            int    CODIGO_BICICLETA = 0;
            string MODELO           = txtbModelo.Text;
            string COR = txtbCor.Text;

            if (modo == "EditaBicicleta")
            {
                Estacoes    es   = new Estacoes();
                EstacoesDAO eDAO = new EstacoesDAO();
                es = eDAO.SelecionaEstacaoNome(cmbSelecionaEstacao.Text);
                BicicletasDAO bDAO = new BicicletasDAO();
                bDAO.Editar(new Bicicletas(CODIGO_BICICLETA, COR, MODELO, es), id);
                this.Close();
            }
        }
Пример #8
0
 private void btnRemoverEstacao_Click(object sender, EventArgs e)
 {
     if (dtgEstacoes.SelectedRows.Count > 0)
     {
         DialogResult result = MessageBox.Show("Tem certeza que deseja excluir essa estação?", "?", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             EstacoesDAO er = new EstacoesDAO();
             string      id = dtgEstacoes.CurrentRow.Cells[0].Value.ToString();
             er.Remover(id);
             ListE = er.ListaTodos();
             dtgEstacoes.DataSource = ListE;
         }
     }
     else
     {
         MessageBox.Show("Nenhum parque selecionado!");
     }
 }
        private void CadastrarEstacoesFORM_Load(object sender, EventArgs e)
        {
            if (modo == "EditaEstacao")
            {
                EstacoesDAO er = new EstacoesDAO();
                List<Estacoes> lista;
                lista = er.ListaId(id);
                foreach (Estacoes ec in lista)
                {
                    txtbNome.Text = ec.Nome;
                    txtbBairro.Text = ec.Bairro;
                    txtbCEP.Text = ec.Cep;
                    txtbNumero.Text = ec.Numero;
                    txtbRua.Text = ec.Rua;
                    txtbTelefone.Text = ec.Telefone;

                    btnCadastrarEstacoes.Text = "Salvar";
                    lblEstacao.Text = "Edição de Estações";
                }
            }
        }
Пример #10
0
 private void btnEditarEstacao_Click(object sender, EventArgs e)
 {
     if (dtgEstacoes.SelectedRows.Count > 0)
     {
         EstacoesDAO er = new EstacoesDAO();
         using (CadastrarEstacoesFORM finc = new CadastrarEstacoesFORM())
         {
             finc.id   = dtgEstacoes.CurrentRow.Cells[0].Value.ToString();
             finc.modo = "EditaEstacao";
             if (finc.ShowDialog() == DialogResult.OK)
             {
                 ListE = er.ListaTodos();
                 dtgEstacoes.DataSource = ListE;
                 finc.Dispose();
             }
         }
     }
     else
     {
         MessageBox.Show("Nenhuma pessoa selecionado!");
     }
 }