private void button1_Click(object sender, EventArgs e) { Modelos.Rastreio rast = new Modelos.Rastreio(); rast.codigorastreio = textBox1.Text; rast.desc = textBox2.Text; try { rast.idvenda = Int32.Parse(textBox3.Text); } catch { MessageBox.Show("Falha ao registrar rastreio... Verifique os dados no formulário!"); return; } if (rast.validar()) { RastreioDAO.salvar(rast); recarregarLista(); MessageBox.Show("Rastreio registrado com sucesso!"); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); } else { MessageBox.Show("Falha ao registrar rastreio... Verifique os dados no formulário!"); } }
private void button3_Click(object sender, EventArgs e) { var rasts = RastreioDAO.buscar($" codigorastreio = '{lista.SelectedItem.ToString()}'"); foreach (var rast in rasts) { MessageBox.Show( $"Codigo: {rast.codigorastreio}\n" + $"Descrição: {rast.desc}\n" + $"Venda: {rast.idvenda}\n"); } }
private void recarregarLista() { lista.Items.Clear(); var rastreios = RastreioDAO.retornarTudo(); if (rastreios.Count > 0) { foreach (var rast in rastreios) { lista.Items.Add(rast.codigorastreio); } } }
static void Main() { ProdutosDao.resetarTabela(); UsuarioDao.resetarTabela(); FornecedorDao.resetarTabela(); RastreioDAO.resetarTabela(); VendasDAO.resetarTabela(); FornecedorDao.criarTabela(); UsuarioDao.criarTabela(); ProdutosDao.criarTabela(); VendasDAO.criarTabela(); RastreioDAO.criarTabela(); UsuarioDao.salvar(new Usuario("admin", "admin")); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
private void button2_Click(object sender, EventArgs e) { RastreioDAO.deletar($" codigorastreio = '{lista.SelectedItem.ToString()}'"); recarregarLista(); }