Example #1
0
 private void BtnEditar_Click(object sender, EventArgs e)
 {
     if (dgvLivros.CurrentCell != null)
     {
         int       row    = dgvLivros.CurrentCell.RowIndex;
         IDataBase bd     = new BDDicionario();
         Livro     result = bd.Read(long.Parse(dgvLivros.Rows[row].Cells[0].Value.ToString()));
         Form1     form   = new Form1(true, result);
         form.StartPosition = FormStartPosition.CenterParent;
         form.ShowDialog(this);
         Fill("");
     }
 }
Example #2
0
        private void Fill(string filtro)
        {
            IDataBase    bd   = new BDDicionario();
            List <Livro> list = bd.ListAll();

            dgvLivros.Rows.Clear();
            foreach (Livro l in list)
            {
                if (filtro == "" || l.Autor.ToUpper().Contains(filtro.ToUpper()) || l.Titulo.ToUpper().Contains(filtro.ToUpper()))
                {
                    dgvLivros.Rows.Add(l.Codigo, l.Titulo, l.Autor);
                }
            }
        }
Example #3
0
 private void btnSalvar_Click(object sender, EventArgs e)
 {
     if (salvar)
     {
         IDataBase bd = new BDDicionario();
         bd.Save(new Livro(0, TxtTitulo.Text, TxtAutor.Text));
         Dispose();
     }
     else if (editavel)
     {
         IDataBase bd = new BDDicionario();
         bd.Update(new Livro(long.Parse(TxtNumero.Text), TxtTitulo.Text, TxtAutor.Text));
         Dispose();
     }
 }
Example #4
0
 private void BtnRemover_Click(object sender, EventArgs e)
 {
     if (dgvLivros.CurrentCell != null)
     {
         DialogResult result = MessageBox.Show("Deseja realmente remover?", "Remoção de livro", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             int       row = dgvLivros.CurrentCell.RowIndex;
             IDataBase bd  = new BDDicionario();
             bd.Delete(long.Parse(dgvLivros.Rows[row].Cells[0].Value.ToString()));
             Fill("");
         }
     }
     else
     {
         MessageBox.Show("Por favor selecione uma linha para remover", "Nenhuma linha selecionada", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }