예제 #1
0
        public void DeleteLaptop()
        {
            IRepositorio rep = new RepositorioMySQL();

            try
            {
                rep.Delete("Dell Latitude 5410");
            }
            catch (Exception ex)
            {
            }
            Assert.IsNull(rep.Consult("Dell Latitude 5410"));
        }
예제 #2
0
        public void CreateLaptop()
        {
            IRepositorio rep = new RepositorioMySQL();

            try
            {
                rep.Create(new Laptop("Dell Latitude 5410", 16, 500));
            }
            catch (Exception ex)
            {
            }
            Assert.IsNotNull(rep.Consult("Dell Latitude 5410"));
        }
예제 #3
0
        public void ListLaptops()
        {
            List <Laptop> laptops = null;
            IRepositorio  rep     = new RepositorioMySQL();

            try
            {
                laptops = rep.List();
            }
            catch (Exception ex)
            {
            }
            Assert.IsNotNull(laptops);
        }
예제 #4
0
        public void ConsultLaptop()
        {
            Laptop       lap = null;
            IRepositorio rep = new RepositorioMySQL();

            try
            {
                lap = rep.Consult("Lenovo");
            }
            catch (Exception ex)
            {
            }
            Assert.IsNotNull(lap);
        }
예제 #5
0
        private void ListLaptops()
        {
            IRepositorio rep = new RepositorioMySQL();

            try
            {
                gridLaptops.DataSource = null;
                gridLaptops.DataSource = rep.List();
                gridLaptops.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Ocorreu um erro: {ex.Message}");
            }
        }
예제 #6
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            IRepositorio rep = new RepositorioMySQL();

            try
            {
                rep.Create(laptop: new Laptop(txtBrand.Text, int.Parse(txtRam.Text), int.Parse(txtStorage.Text)));
                ListLaptops();
                MessageBox.Show(text: $"Notebook {txtBrand.Text} de {txtRam.Text}GB de RAM e {txtStorage.Text} de armazenamento foi adicionado.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(text: $"Ocorreu um erro: {ex.Message}");
            }
        }