private void FrmCarros_Load(object sender, EventArgs e) { controlesOnOff(false); btnOnOff(true); CAMADAS.BLL.Carros bllCarro = new CAMADAS.BLL.Carros(); dtGrvCarro.DataSource = ""; dtGrvCarro.DataSource = bllCarro.Select(); }
private void btnGravar_Click(object sender, EventArgs e) { CAMADAS.BLL.Carros bllCarro = new CAMADAS.BLL.Carros(); string msg = ""; if (lblId.Text == "-1") { msg = "Deseja Inserir um novo Carro?"; } else { msg = "Deseja Alterar o Carro atual?"; } DialogResult resposta = MessageBox.Show(msg, "Gravar", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (resposta == DialogResult.Yes) { CAMADAS.MODEL.Carros carro = new CAMADAS.MODEL.Carros(); carro.id = Convert.ToInt32(lblId.Text); carro.modelo = txtModelo.Text; carro.marca = txtMarca.Text; carro.chassi = txtChassi.Text; carro.ano = Convert.ToInt32(txtAno.Text); carro.placa = txtPlaca.Text; if (lblId.Text == "-1") { bllCarro.Insert(carro); } else { bllCarro.Update(carro); } } else { MessageBox.Show("Não Gravado", "Gravar", MessageBoxButtons.OK, MessageBoxIcon.Warning); } dtGrvCarro.DataSource = bllCarro.Select(); //apaga limparTxts(); controlesOnOff(false); btnOnOff(true); }
private void btnFiltro_Click(object sender, EventArgs e) { CAMADAS.BLL.Carros bllcarro = new CAMADAS.BLL.Carros(); List <CAMADAS.MODEL.Carros> lstCarros = new List <CAMADAS.MODEL.Carros>(); if (rdbTodos.Checked) { lstCarros = bllcarro.Select(); } else if (rdbId.Checked) { int id = Convert.ToInt32(txtFiltro.Text); lstCarros = bllcarro.SelectById(id); } else { lstCarros = bllcarro.SelectByModelo(txtFiltro.Text); } dtGrvCarro.DataSource = ""; dtGrvCarro.DataSource = lstCarros; }
private void btnRemover_Click(object sender, EventArgs e) { CAMADAS.BLL.Carros bllCarro = new CAMADAS.BLL.Carros(); string msg = ""; if (lblId.Text != "-1") { msg = "Deseja Remover o Carro selecionado?"; DialogResult resp = MessageBox.Show(msg, "Remover", MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2); if (resp == DialogResult.Yes) { int idCarro = Convert.ToInt32(lblId.Text); bllCarro.Delete(idCarro); } } else { MessageBox.Show("Não há dados para Remover", "Remover", MessageBoxButtons.OK, MessageBoxIcon.Information); } dtGrvCarro.DataSource = ""; dtGrvCarro.DataSource = bllCarro.Select(); limparTxts(); }