Exemplo n.º 1
0
        private void faturacao(Aluguer aluguer)
        {
            string textoFatura;

            textoFatura  = "<h1>StarStand</h1>";
            textoFatura += "<hr>";
            textoFatura += "<<h2>Dados do Cliente</h2>";
            textoFatura += "<span>" + aluguer.Utilizadores.Nome + "</span><br>";
            textoFatura += "<span>" + aluguer.Utilizadores.NIF + "</span><br>";
            textoFatura += "<span>" + aluguer.Utilizadores.Morada + "</span><br>";
            textoFatura += "<hr>";
            textoFatura += "<h2>Dados do Carro</h2>";
            textoFatura += "<span><b>Marca :  </b>" + aluguer.CarroAluguer.Marca + "</span><br>";
            textoFatura += "<span><b>Modelo :  </b>" + aluguer.CarroAluguer.Modelo + "</span><br>";
            textoFatura += "<span><b>Matricula :  </b>" + aluguer.CarroAluguer.Matricula + "</span><br>";
            textoFatura += "<span><b>Combustivel :  </b>" + aluguer.CarroAluguer.Combustivel + "</span><br>";
            textoFatura += "<hr>";
            textoFatura += "<h2>Dados do Aluguer</h2>";
            textoFatura += "<span>Iniciada :  " + aluguer.DataInicio.ToLongDateString() + "</span><br>";
            DateTime dataFim = (DateTime)aluguer.DataFim;

            textoFatura += "<span>Finalizada :  " + dataFim.ToLongDateString() + " </span><br>";
            textoFatura += "<span>Valor base :  " + aluguer.CarroAluguer.ValorBase + " €</span><br>";
            textoFatura += "<hr>";
            textoFatura += "<span>Total:" + aluguer.Valor + " €</span><br>";
            IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();
            Renderer.RenderHtmlAsPdf(textoFatura).SaveAs(Directory.GetCurrentDirectory() + "\\FaturaAluguer\\" + aluguer.IdAluguer + "_" + aluguer.Utilizadores.Nome + ".pdf");
        }
Exemplo n.º 2
0
        private void BtnInserir_Click(object sender, EventArgs e)
        {
            bd = new StarDBContainer();

            if (textboxKms.Text.Equals("") || textboxKms.Text.Equals("KMS") && textboxKms.Enabled == true)
            {
                MessageBox.Show("KMS: Campo Obrigatório!");
                return;
            }


            if (globalUser != null)
            {
                Aluguer aluguer = new Aluguer();
                aluguer.DataInicio = DatepickerEntrada.Value;
                aluguer.DataFim    = DatepickerSaida.Value;
                aluguer.UtilizadoresIdUtilizador = globalUser.IdUtilizador;
                aluguer.CarroAluguerId           = globalCarro.IdCarro;
                bd.AluguerSet.Add(aluguer);
                bd.SaveChanges();
                CarroAluguer carroAluguer = bd.CarrosSet.OfType <CarroAluguer>().Single(a => a.IdCarro == globalCarro.IdCarro);
                carroAluguer.Estado          = "Alugado";
                bd.Entry(carroAluguer).State = EntityState.Modified;
                bd.SaveChanges();
            }
            else
            {
                int     id      = globalCarro.Aluguer.OrderByDescending(a => a.IdAluguer).Select(a => a.IdAluguer).First();
                Aluguer aluguer = bd.AluguerSet.Single(a => a.IdAluguer == id);
                aluguer.DataFim         = DatepickerSaida.Value;
                aluguer.Kms             = int.Parse(textboxKms.Text);
                aluguer.Valor           = decimal.Parse(textboxTotal.Text.Replace("€", ""));
                bd.Entry(aluguer).State = EntityState.Modified;
                bd.SaveChanges();

                CarroAluguer carroAluguer = bd.CarrosSet.OfType <CarroAluguer>().Single(a => a.IdCarro == globalCarro.IdCarro);
                carroAluguer.Estado          = "Disponível";
                bd.Entry(carroAluguer).State = EntityState.Modified;
                bd.SaveChanges();
                DialogResult result = MessageBox.Show("Deseja fatura?", "Faturação", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    faturacao(aluguer);
                }
            }
            this.Close();
        }
Exemplo n.º 3
0
 private void BtnRemoveCarros_Click(object sender, EventArgs e)
 {
     if (listBoxHist.list.SelectedIndex != -1)
     {
         Aluguer aluguer = listBoxHist.list.SelectedItem as Aluguer;
         bd.AluguerSet.Remove(aluguer);
         bd.SaveChanges();
         CarroAluguer carro = (CarroAluguer)bd.CarrosSet.Where(id => id.IdCarro == aluguer.CarroAluguerId).First();
         carro.Estado          = "Disponível";
         bd.Entry(carro).State = EntityState.Modified;
         bd.SaveChanges();
         lerdadosAluguer();
     }
     else
     {
         MessageBox.Show("Tem de selecionar um aluguer");
     }
 }
Exemplo n.º 4
0
        public void mostrarDado()
        {
            CarroAluguer carroAluguer = listboxCarros.list.SelectedItem as CarroAluguer;

            labelMostraMarca.Text      = carroAluguer.Marca;
            labelMostraEstado.Text     = carroAluguer.Estado;
            labelMostraValor.Text      = carroAluguer.ValorBase + " €";
            labelMostrarModelo.Text    = carroAluguer.Modelo;
            labelMostrarMatricula.Text = carroAluguer.Matricula;

            panelright.Visible = true;
            lerdadosClientes();
            if (carroAluguer.Estado == "Alugado")
            {
                int     id      = carroAluguer.Aluguer.OrderByDescending(a => a.IdAluguer).Select(a => a.IdAluguer).First();
                Aluguer aluguer = bd.AluguerSet.Single(a => a.IdAluguer == id);
                buttonAlugar.Text        = ALUGADO;
                buttonAlugar.Enabled     = true;
                labelMostrarUser.Text    = aluguer.Utilizadores.Nome;
                labelUser.Visible        = true;
                labelMostrarUser.Visible = true;
                btnSwitch.Enabled        = false;
                btnSwitch.Value          = true;
            }
            else
            {
                buttonAlugar.Text        = Disponivel;
                labelUser.Visible        = false;
                labelMostrarUser.Visible = false;
                btnSwitch.Enabled        = true;
                if (carroAluguer.Estado == "Disponível")
                {
                    btnSwitch.Value      = true;
                    buttonAlugar.Enabled = true;
                }
                else
                {
                    btnSwitch.Value      = false;
                    buttonAlugar.Enabled = false;
                }
            }
        }
Exemplo n.º 5
0
 public GerirAluguer(Utilizadores user, CarroAluguer carro)
 {
     InitializeComponent();
     globalUser  = user;
     globalCarro = carro;
     if (user == null)
     {
         bd = new StarDBContainer();
         int     id      = globalCarro.Aluguer.OrderByDescending(a => a.IdAluguer).Select(a => a.IdAluguer).First();
         Aluguer aluguer = bd.AluguerSet.Single(a => a.IdAluguer == id);
         DatepickerEntrada.Enabled = false;
         textboxKms.Enabled        = true;
         DatepickerEntrada.Value   = aluguer.DataInicio;
         DatepickerSaida.Value     = (DateTime)aluguer.DataFim;
     }
     else
     {
         DatepickerEntrada.Enabled = true;
         textboxKms.Enabled        = false;
     }
 }