Beispiel #1
0
        private void ExibirAluguel(int idAluguel)
        {
            try
            {
                AluguelAction aluguelAction = new AluguelAction();

                var aluguel = aluguelAction.Detalhe(Convert.ToInt32(idAluguel));

                _idAluguel             = aluguel.IdAluguel;
                txtDataAluguel.Text    = aluguel.DataAluguel;
                txtDataDevAluguel.Text = aluguel.DataDevolucao;
                txtPrecoAluguel.Text   = Convert.ToString(aluguel.Preco);


                cmbCliente.SelectedIndex = cmbCliente.FindStringExact(aluguel.NomeCliente);
                cmbVeiculo.SelectedIndex = cmbVeiculo.FindStringExact(aluguel.NomeVeiculo);

                btnPesquisarMulta_Click(null, null);
                tabControl1.SelectedTab = tabCadastroAluguel;
            }
            catch (Exception ex)
            {
                throw new Exception("Houve um erro ao tentar realizar uma operação [" + MethodBase.GetCurrentMethod().ToString() + "]: " + ex.Message);
            }
        }
Beispiel #2
0
        public void btnPesquisar_Click(object sender, EventArgs e)
        {
            try
            {
                grdPesquisarAluguel.Rows.Clear();

                AluguelAction aluguelAction = new AluguelAction();


                var lista = aluguelAction.Lista(txtPesquisarDataAluguel.Text);

                if (lista.Count > 0)
                {
                    for (int i = 0; i < lista.Count; i++)
                    {
                        grdPesquisarAluguel.Rows.Add();

                        grdPesquisarAluguel.Rows[i].Cells["selecionar"].Value = "Exibir";
                        grdPesquisarAluguel.Rows[i].Cells["idAluguel"].Value  = lista[i].IdAluguel.ToString();
                        grdPesquisarAluguel.Rows[i].Cells["nome"].Value       = lista[i].NomeCliente.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Houve um erro ao tentar realizar uma operação [" + MethodBase.GetCurrentMethod().ToString() + "]: " + ex.Message);
            }
        }
Beispiel #3
0
        private void btnSalvarAluguel_Click(object sender, EventArgs e)
        {
            //AluguelAction aluguelAction = new AluguelAction
            try
            {
                var IdCliente = _funcoes.PegarIdCombo(cmbCliente);
                var IdVeiculo = _funcoes.PegarIdCombo(cmbVeiculo);

                if (ValidaCampos() == false)
                {
                    return;
                }

                AluguelAction aluguelAction = new AluguelAction();
                Aluguel       aluguel       = new Aluguel();

                aluguel.IdAluguel     = Convert.ToInt32(_idAluguel);
                aluguel.Preco         = Convert.ToInt32(txtPrecoAluguel.Text);
                aluguel.DataAluguel   = txtDataAluguel.Text;
                aluguel.DataDevolucao = txtDataDevAluguel.Text;
                aluguel.IdCliente     = IdCliente;
                aluguel.IdVeiculo     = IdVeiculo;

                var retorno = aluguelAction.Salvar(aluguel);

                if (retorno)
                {
                    MessageBox.Show("Aluguel Cadastrado com Sucesso!", "Cliente", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnNovo_Click(null, null);
                    btnPesquisar_Click(null, null);
                }
                else
                {
                    MessageBox.Show("Houve um erro ao Salvar!", "Cliente", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            catch (Exception ex)
            {
                throw new Exception("Houve um erro ao tentar realizar uma operação [" + MethodBase.GetCurrentMethod().ToString() + "]: " + ex.Message);
            }
        }
Beispiel #4
0
        private void btnExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                AluguelAction aluguelAction = new AluguelAction();

                var retorno = aluguelAction.Excluir(_idAluguel);

                if (retorno)
                {
                    MessageBox.Show("Aluguel Excluído com Sucesso!", "Cliente", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    btnNovo_Click(null, null);
                    btnPesquisar_Click(null, null);
                }
                else
                {
                    MessageBox.Show("Houve um erro ao excluir Cliente!", "Cliente", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Houve um erro ao tentar realizar uma operação [" + MethodBase.GetCurrentMethod().ToString() + "]: " + ex.Message);
            }
        }