private void BtnInserir_Click(object sender, EventArgs e) { if (txtPlaca.Text != "" && txtModelo.Text != "" && txtIdCor.Text != "" && txtModelo.Text != "") { CAMADAS.BLL.Caminhoes bllCaminhoes = new CAMADAS.BLL.Caminhoes(); CAMADAS.MODEL.Caminhao caminhoes = new CAMADAS.MODEL.Caminhao(); caminhoes.placa = txtPlaca.Text; caminhoes.modelo = txtModelo.Text; caminhoes.cor = Convert.ToInt32(txtIdCor.Text); caminhoes.motorista = Convert.ToInt32(txtIdMotorista.Text); bllCaminhoes.Insert(caminhoes); limparcontrole(); DGCaminhoes.DataSource = ""; DGCaminhoes.DataSource = bllCaminhoes.Select(); MessageBox.Show("CAMINHÃO INSERIDO COM SUCESSO!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("TODOS OS ITENS DEVEM SER PREENCHIDOS!", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnEditar_Click(object sender, EventArgs e) { if (txtID.Text != "-1") { CAMADAS.MODEL.Caminhao caminhao = new CAMADAS.MODEL.Caminhao(); caminhao.id = Convert.ToInt32(txtID.Text); caminhao.placa = txtPlaca.Text; caminhao.modelo = txtModelo.Text; caminhao.cor = Convert.ToInt32(txtIdCor.Text); caminhao.motorista = Convert.ToInt32(txtIdMotorista.Text); CAMADAS.BLL.Caminhoes bllCaminhoes = new CAMADAS.BLL.Caminhoes(); bllCaminhoes.Update(caminhao); MessageBox.Show("Alteração Realizada com Sucesso!", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); limparcontrole(); DGCaminhoes.DataSource = ""; DGCaminhoes.DataSource = bllCaminhoes.Select(); } else { MessageBox.Show("Nenhum Caminhão Selecionado para Edição", "Editar", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void FormCombustivel_Load(object sender, EventArgs e) { CAMADAS.BLL.Combustivel bllCombustivel = new CAMADAS.BLL.Combustivel(); CAMADAS.BLL.Caminhoes bllCaminhoes = new CAMADAS.BLL.Caminhoes(); CAMADAS.BLL.Motorista bllMotorista = new CAMADAS.BLL.Motorista(); CAMADAS.DAL.Combustivel dalcombustivel = new CAMADAS.DAL.Combustivel(); DGCombustivel.DataSource = bllCombustivel.Select(); txtEstoque.Text = calcularEstoque().ToString(); cmbCaminhao.DisplayMember = "placa"; cmbCaminhao.ValueMember = "id"; cmbCaminhao.DataSource = bllCaminhoes.Select(); cmbMotorista.DisplayMember = "nome"; cmbMotorista.ValueMember = "id"; cmbMotorista.DataSource = bllMotorista.Select(); limparControles(); }
private void BtnExcluir_Click(object sender, EventArgs e) { CAMADAS.BLL.Caminhoes bllCaminhoes = new CAMADAS.BLL.Caminhoes(); if (txtID.Text != "-1") { DialogResult resp = MessageBox.Show("Deseja Excluir Realmente Caminhão?", "Excluir", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (resp == DialogResult.Yes) { int idCaminhoes = Convert.ToInt32(txtID.Text); bllCaminhoes.Delete(idCaminhoes); } } else { MessageBox.Show("Nenhum Caminhão Selecionado Para Exclusão!", "Excluir Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } limparcontrole(); DGCaminhoes.DataSource = ""; DGCaminhoes.DataSource = bllCaminhoes.Select(); }