예제 #1
0
        public ActionResult Index(int id)
        {
            ViewBag.Veiculo = _veiculoDao.Get(id);

            IList <Hodometro> registros = _dao.FindByVeiculo(id);

            return(View(registros));
        }
예제 #2
0
        public ActionResult Editar(int id)
        {
            ViewBag.Combustiveis = _combustivelDao.GetAll();

            Veiculo veiculo = _veiculoDao.Get(id);

            if (veiculo == null)
            {
                return(RedirectToAction("Index", "Veiculo"));
            }

            return(View(veiculo));
        }
예제 #3
0
        private void BtnEditarCarro_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Carro carro = new Carro();
                if (ValidaCamposEmBranco())
                {
                    carro.Placa        = Parameter;
                    carro              = (Carro)VeiculoDAO.Get(carro, null);
                    carro.Nome         = txtNome.Text;
                    carro.Cor          = txtCor.Text;
                    carro.Modelo       = txtModelo.Text;
                    carro.Status       = txtStatus.Text;
                    carro.ValorPorDia  = Convert.ToDouble(txtValorPorDia.Text);
                    carro.ValorPorHora = Convert.ToDouble(txtValorPorHora.Text);

                    VeiculoDAO.AlterarDadosVeiculo(carro, null);

                    MessageBox.Show("Dados alterados com sucesso!!", "", MessageBoxButton.OK, MessageBoxImage.Information);
                    LimpaCampos();
                    Usc.ListarCarro();
                    Close();
                }
                else
                {
                    MessageBox.Show("Favor preencher as informações!", "Mensagem", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString(), "LocadoraWPF", MessageBoxButton.OK, MessageBoxImage.Error); }
        }
        public ActionResult Novo(int id)
        {
            Veiculo veiculo = _veiculoDao.Get(id);

            if (veiculo == null)
            {
                this.Info("Veículo não encontrado.");
                return(RedirectToAction("Index"));
            }

            if (veiculo.Situacao != Situacao.Emuso)
            {
                this.Info("O veículo selecionado não e está mais disponível.");
                return(RedirectToAction("Index"));
            }

            ViewBag.Veiculo = veiculo;
            LoadResources();

            return(View());
        }
예제 #5
0
 public frmAdmEditaCarro(string parameter, usListarCarro usc)
 {
     this.Usc  = usc;
     Parameter = parameter;
     InitializeComponent();
     #region Dados do carro
     Carro carro = new Carro();
     carro.Placa          = parameter;
     carro                = (Carro)VeiculoDAO.Get(carro, null);
     txtNome.Text         = carro.Nome;
     txtCor.Text          = carro.Cor;
     txtModelo.Text       = carro.Modelo;
     txtStatus.Text       = carro.Status;
     txtValorPorDia.Text  = carro.ValorPorDia.ToString();
     txtValorPorHora.Text = carro.ValorPorHora.ToString();
     #endregion
 }
예제 #6
0
 public frmAdmEditaMoto(string parameter, usListarMoto usc)
 {
     this.Usc  = usc;
     Parameter = parameter;
     InitializeComponent();
     #region Dados da moto
     Moto moto = new Moto();
     moto.Placa           = parameter;
     moto                 = (Moto)VeiculoDAO.Get(null, moto);
     txtNome.Text         = moto.Nome;
     txtCor.Text          = moto.Cor;
     txtModelo.Text       = moto.Modelo;
     txtStatus.Text       = moto.Status;
     txtValorPorDia.Text  = moto.ValorPorDia.ToString();
     txtValorPorHora.Text = moto.ValorPorHora.ToString();
     #endregion
 }
예제 #7
0
        private void BtnConfirmar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Cliente cliente = new Cliente();
                Moto    moto    = new Moto();
                Reserva reserva = new Reserva();
                cliente.Cpf = ParameterCliente;
                moto.Placa  = ParameterCarro;
                cliente     = ClienteDAO.Get(cliente);
                moto        = (Moto)VeiculoDAO.Get(null, moto);

                DateTime?dtR = dtReserva.SelectedDate;
                DateTime?dtD = dtDevolucao.SelectedDate;

                if (dtDevolucao.SelectedDate == null || dtReserva.SelectedDate == null)
                {
                    MessageBox.Show("Preencha os Campos em branco!", "LocadoraWPF", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                ComboBoxItem itemR = (ComboBoxItem)cboHoraReserva.SelectedItem;
                ComboBoxItem itemD = (ComboBoxItem)cboHoraDevolucao.SelectedItem;

                if (cboHoraDevolucao.SelectedItem == null || cboHoraReserva.SelectedItem == null)
                {
                    MessageBox.Show("Preencha os Campos em branco!", "LocadoraWPF", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                int horaDevolucao = Convert.ToInt32(itemD.Content.ToString().Replace(":00", ""));
                int horaReserva   = Convert.ToInt32(itemR.Content.ToString().Replace(":00", ""));

                reserva.DataReserva   = Convert.ToDateTime(dtR.Value.AddHours(horaReserva));
                reserva.DataDevolucao = Convert.ToDateTime(dtD.Value.AddHours(horaDevolucao));

                if (string.IsNullOrWhiteSpace(cboHoraDevolucao.Text) || string.IsNullOrWhiteSpace(cboHoraReserva.Text) ||
                    string.IsNullOrWhiteSpace(dtDevolucao.Text) || string.IsNullOrWhiteSpace(dtReserva.Text))
                {
                    MessageBox.Show("Preencha os Campos em branco!", "LocadoraWPF", MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                if (reserva.DataReserva.Day > reserva.DataDevolucao.Day &&
                    reserva.DataReserva.DayOfWeek > reserva.DataDevolucao.DayOfWeek &&
                    reserva.DataReserva.DayOfYear > reserva.DataDevolucao.DayOfYear)
                {
                    MessageBox.Show("Data de devolução não pode ser menor que a data de reserva!", "LocadoraWPF", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }

                if (ReservaDAO.DefineVeiculoParaSalvarReserva(cliente, reserva, null, moto))
                {
                    MessageBox.Show("A sua reserva foi registrada! \n" +
                                    "Aguarde a aprovação do Administrador! \n" +
                                    "O Valor da reserva ficou: " + reserva.ValorTotalReserva.ToString("C2") + "\n" +
                                    "\nPagamento será realizado na hora da devolução do veiculo!", "LocadoraWPF",
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                    Close();
                }
                else
                {
                    MessageBox.Show("Algo deu errado", "LocadoraWPF", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString(), "LocadoraWPF", MessageBoxButton.OK, MessageBoxImage.Error); return; }
        }