private void btnGravarAlug_Click(object sender, EventArgs e) { CAMADAS.MODEL.Aluguel aluguel = new CAMADAS.MODEL.Aluguel(); aluguel.id = Convert.ToInt32(lblAlugID.Text); aluguel.clienteID = Convert.ToInt32(txtClienteID.Text); aluguel.data = dptData.Value; CAMADAS.BLL.Aluguel bllAlug = new CAMADAS.BLL.Aluguel(); if (lblAlugID.Text == "-1") { bllAlug.Insert(aluguel); } else { bllAlug.Update(aluguel); } dtgAluguel.DataSource = bllAlug.Select(); habilitaControlesAluguel(false); }
private void btnEditarAlug_Click(object sender, EventArgs e) { habilitaControlesAluguel(true); if (lblAlugID.Text != "" && lblAlugID.Text != "-1") { txtClienteID.Focus(); CAMADAS.MODEL.Aluguel aluguel = new CAMADAS.MODEL.Aluguel(); aluguel.id = Convert.ToInt32(lblAlugID.Text); aluguel.clienteID = Convert.ToInt32(cmbCliente.SelectedIndex); aluguel.data = Convert.ToDateTime(dptData.Value); CAMADAS.DAL.Aluguel dalAlug = new CAMADAS.DAL.Aluguel(); dalAlug.Update(aluguel); dtgAluguel.DataSource = ""; dtgAluguel.DataSource = dalAlug.Select(); } else { MessageBox.Show("Não há dados para atualizar", "Atualizar", MessageBoxButtons.OK, MessageBoxIcon.Information); } }