Exemplo n.º 1
0
        private void btnRemover_Click(object sender, EventArgs e)
        {
            CAMADAS.MODEL.Aluguel aluguel = new CAMADAS.MODEL.Aluguel();
            CAMADAS.BLL.Aluguel   bllAlu  = new CAMADAS.BLL.Aluguel();

            if (lblIdAluguel.Text != "-1")
            {
                bllAlu.Delete(Convert.ToInt32(lblIdAluguel.Text));
                dtGvAluguel.DataSource = "";
                dtGvAluguel.DataSource = bllAlu.Select();
            }
        }
Exemplo n.º 2
0
        private void btnGravar_Click(object sender, EventArgs e)
        {
            CAMADAS.MODEL.Aluguel aluguel = new CAMADAS.MODEL.Aluguel();
            CAMADAS.MODEL.Carros  carro   = new CAMADAS.MODEL.Carros();

            aluguel.id        = Convert.ToInt32(lblIdAluguel.Text);
            aluguel.clienteID = Convert.ToInt32(cmbCliente.SelectedValue.ToString());
            aluguel.nome      = cmbCliente.Text;
            aluguel.carroID   = Convert.ToInt32(cmbCarro.SelectedValue.ToString());
            aluguel.modelo    = cmbCarro.Text;

            CAMADAS.BLL.Aluguel bllAlu = new CAMADAS.BLL.Aluguel();
            int idC  = Convert.ToInt32(txtClienteId.Text);
            int idCr = Convert.ToInt32(txtCarroId.Text);

            CAMADAS.MODEL.Aluguel aluguel1 = bllAlu.BuscaCliente(idC);
            CAMADAS.MODEL.Aluguel aluguel2 = bllAlu.BuscaCarro(idCr);


            if (lblIdAluguel.Text == "-1")
            {
                if (aluguel1.clienteID == idC)
                {
                    MessageBox.Show("Cliente ja possui aluguel");
                }
                else if (aluguel2.carroID == idCr)
                {
                    MessageBox.Show("Carro não esta Disponivel");
                }
                else
                {
                    bllAlu.Insert(aluguel);
                }
            }



            dtGvAluguel.DataSource = "";
            dtGvAluguel.DataSource = bllAlu.Select();
        }