Exemplo n.º 1
0
        public override string ToString()
        {
            StarDBContainer bd   = new StarDBContainer();
            Utilizadores    user = bd.UtilizadoresSet.Where(id => id.IdUtilizador == UtilizadoresIdUtilizador).First();

            if (Kms == null)
            {
                return(DataInicio + "" + user.Nome);
            }
            else
            {
                return("(Concluido)-" + user.Nome + "-" + Valor);
            }
        }
Exemplo n.º 2
0
 //Menus
 private void btnCliente_Click(object sender, EventArgs e)
 {
     bd = new StarDBContainer();
     setuserctr(clientes1);
     clientes1.lerdados();
     if (bd.UtilizadoresSet.Count() > 0)
     {
         clientes1.Dgv_Clientes_CellClick(null, null);
     }
     btnOficina.Normalcolor = Color.FromArgb(14, 25, 32);
     btnCliente.Normalcolor = Color.Maroon;
     btnVendas.Normalcolor  = Color.FromArgb(14, 25, 32);
     btnAluguer.Normalcolor = Color.FromArgb(14, 25, 32);
 }
Exemplo n.º 3
0
 public void lerdadosParcela(Servicos servico)
 {
     bd.Dispose();
     bd = new StarDBContainer();
     try
     {
         textBoxTotalParcela.Text = bd.ParcelaSet.Where(id => id.ServicoIdServicos == servico.IdServicos).Sum(tb => tb.Valor).ToString();
     }
     catch (Exception)
     {
         textBoxTotalParcela.Text = "0€";
     }
     listBoxParcela.list.DataSource = null;
     listBoxParcela.list.DataSource = servico.Parcela.ToList();
 }
Exemplo n.º 4
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.º 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;
     }
 }
Exemplo n.º 6
0
 public void lerdadosHistVenda()
 {
     bd = new StarDBContainer();
     listBoxHistVenda.list.DataSource = bd.VendaSet.ToList();
 }
Exemplo n.º 7
0
 public void lerdados()
 {
     bd = new StarDBContainer();
     (from Utilizadores in bd.UtilizadoresSet select Utilizadores).Load();
     utilizadoresBindingSource.DataSource = bd.UtilizadoresSet.Local.ToBindingList();
 }
Exemplo n.º 8
0
 public void lerdadosServicos(CarroOficina carro)
 {
     bd = new StarDBContainer();
     //listBoxServicos.list.DataSource = null;
     listBoxServicos.list.DataSource = carro.Servicos.ToList();
 }
Exemplo n.º 9
0
 public void lerdadosCarros(Utilizadores user)
 {
     bd = new StarDBContainer();
     listBoxCarros.list.DataSource = user.CarroOficina.ToList();
 }
Exemplo n.º 10
0
 //Funçôes
 public void lerdadosclientes()
 {
     bd = new StarDBContainer();
     listBoxClientes.list.DataSource = bd.UtilizadoresSet.ToList();
 }
Exemplo n.º 11
0
 //Funções
 public void lerdadosAluguer()
 {
     bd = new StarDBContainer();
     listBoxHist.list.DataSource = bd.AluguerSet.ToList();
 }
Exemplo n.º 12
0
 //Funçoes
 public void lerdadosCarro()
 {
     bd = new StarDBContainer();
     listboxCarros.list.DataSource = bd.CarrosSet.OfType <CarroAluguer>().ToList();
 }
Exemplo n.º 13
0
        private void BtnSubmeter_Click(object sender, EventArgs e)
        {
            bd = new StarDBContainer();
            if (listboxClientes.list.SelectedIndex != -1)
            {
                if (comboboxCombustivel.Text.Equals("Combustível"))
                {
                    MessageBox.Show("Comustível: Selecione um tipo de combustível!");
                    return;
                }
                if (comboBoxEstado.Text.Equals("Estado"))
                {
                    MessageBox.Show("Estado: Selecione um tipo de estado!");
                    return;
                }
                Utilizadores user = listboxClientes.list.SelectedItem as Utilizadores;

                Venda venda = new Venda();
                venda.Data   = DateTime.Now;
                venda.Estado = comboBoxEstado.Text;
                try
                {
                    venda.Valor = decimal.Parse(textboxValor.Text.Replace(".", ","));
                }
                catch (FormatException)
                {
                    MessageBox.Show("So pode inserir numeros e '.' ou ','");
                    textboxValor.Text = "";

                    setplaceholder(textboxValor, VALOR);
                    return;
                }
                venda.UtilizadoresIdUtilizador = user.IdUtilizador;
                CarroVenda carro = new CarroVenda();
                carro.Marca       = textBoxMarca.Text.Trim();
                carro.Modelo      = TextBoxModelo.Text.Trim();
                carro.Matricula   = TextboxMatricula.Text.Trim();
                carro.Combustivel = comboboxCombustivel.Text;
                if (textBoxExtras.Text == EXTRA || textBoxExtras.Text == "")
                {
                    carro.Extras = null;
                }

                else
                {
                    carro.Extras = textBoxExtras.Text;
                }
                venda.CarroVenda = carro;
                bd.CarrosSet.Add(carro);
                bd.VendaSet.Add(venda);
                bd.SaveChanges();

                CarroOficina carroOficina = new CarroOficina();
                carroOficina.Marca       = venda.CarroVenda.Marca;
                carroOficina.Modelo      = venda.CarroVenda.Modelo;
                carroOficina.Matricula   = venda.CarroVenda.Matricula;
                carroOficina.Combustivel = venda.CarroVenda.Combustivel;
                carroOficina.Kms         = 0;
                carroOficina.UtilizadoresIdUtilizador = venda.UtilizadoresIdUtilizador;
                bd.CarrosSet.Add(carroOficina);
                bd.SaveChanges();
                this.Close();
            }
        }