コード例 #1
0
        private void btnIncluir_Click(object sender, EventArgs e)
        {
            try
            {
                Aluguel aluguel = new Aluguel();

                aluguel.IdUsuario       = (int)cmbCliente.SelectedValue;
                aluguel.IdTema          = (int)cmbTema.SelectedValue;
                aluguel.EnderecoUsuario = txtEndereco.Text;
                aluguel.DataFesta       = mtxtData.Text;
                aluguel.HoraInicio      = mtxtHoraInicio.Text;
                aluguel.HoraFim         = mtxtHoraFim.Text;
                aluguel.NumeroPessoas   = int.Parse(txtNumeroPessoas.Text);
                aluguel.ValorAluguel    = float.Parse(txtValorAluguel.Text);


                AluguelBll obj = new AluguelBll();
                obj.Incluir(aluguel);

                MessageBox.Show("O aluguel   foi incluído com sucesso!");

                txtCodigo.Text = Convert.ToString(aluguel.IdAluguel);
                AtualizaGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex.Message);
            }
        }
コード例 #2
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            if (txtCodigo.Text.Length == 0)
            {
                MessageBox.Show("Um aluguel deve ser selecionado antes da exclusão.");
            }

            else
            {
                try
                {
                    int codigo = Convert.ToInt32(txtCodigo.Text);

                    AluguelBll obj = new AluguelBll();

                    obj.Excluir(codigo);

                    MessageBox.Show("O aluguel foi excluído com sucesso!");

                    AtualizaGrid();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #3
0
        public void CarregaCombo()
        {
            AluguelBll obj = new AluguelBll();

            cmbCliente.DataSource    = obj.ListagemCliente();
            cmbCliente.DisplayMember = "nomeUsuario";
            cmbCliente.ValueMember   = "idUsuario";

            cmbTema.DataSource    = obj.ListagemTema();
            cmbTema.DisplayMember = "temaFesta";
            cmbTema.ValueMember   = "idTema";
        }
コード例 #4
0
        public void AtualizaGrid()
        {
            // Comunicação com a Camada BLL
            AluguelBll obj = new AluguelBll();

            aluguelDataGridView.DataSource = obj.Listagem();

            // Atualizando os objetos TextBox

            txtCodigo.Text        = aluguelDataGridView[0, aluguelDataGridView.CurrentRow.Index].Value.ToString();
            txtEndereco.Text      = aluguelDataGridView[3, aluguelDataGridView.CurrentRow.Index].Value.ToString();
            mtxtData.Text         = aluguelDataGridView[4, aluguelDataGridView.CurrentRow.Index].Value.ToString();
            mtxtHoraInicio.Text   = aluguelDataGridView[5, aluguelDataGridView.CurrentRow.Index].Value.ToString();
            mtxtHoraFim.Text      = aluguelDataGridView[6, aluguelDataGridView.CurrentRow.Index].Value.ToString();
            txtNumeroPessoas.Text = aluguelDataGridView[7, aluguelDataGridView.CurrentRow.Index].Value.ToString();
            txtValorAluguel.Text  = aluguelDataGridView[8, aluguelDataGridView.CurrentRow.Index].Value.ToString();
        }
コード例 #5
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (txtCodigo.Text.Length == 0)
            {
                MessageBox.Show("Um aluguel deve ser selecionado para alteração.");
            }
            else
            {
                try

                {
                    Aluguel aluguel = new Aluguel();

                    aluguel.IdAluguel = int.Parse(txtCodigo.Text);

                    aluguel.IdUsuario       = (int)cmbCliente.SelectedValue;
                    aluguel.IdTema          = (int)cmbTema.SelectedValue;
                    aluguel.EnderecoUsuario = txtEndereco.Text;
                    aluguel.DataFesta       = mtxtData.Text;
                    aluguel.HoraInicio      = mtxtHoraInicio.Text;
                    aluguel.HoraFim         = mtxtHoraFim.Text;
                    aluguel.NumeroPessoas   = int.Parse(txtNumeroPessoas.Text);
                    aluguel.ValorAluguel    = float.Parse(txtValorAluguel.Text);


                    AluguelBll obj = new AluguelBll();
                    obj.Alterar(aluguel);

                    MessageBox.Show("O aluguel   foi alterado com sucesso!");

                    AtualizaGrid();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro: " + ex.ToString());
                }
            }
        }