コード例 #1
0
        private void butonConfirmarReserva_Click(object sender, EventArgs e)
        {
            string bnum = textBoxNumBungalow.Text;

            if (bnum != "")
            {
                using (var context = new AlojamentoDbEntities3())
                {
                    Alojamento queryAloj = context.Alojamentoes
                                           .Where(s => s.num == textBoxNumBungalow.Text)
                                           .FirstOrDefault <Alojamento>();

                    Customer queryCustomer = context.Customers
                                             .Where(s => s.id == queryAloj.id) // valor estático tem de se alterar!!!!
                                             .FirstOrDefault <Customer>();

                    Reserva reserva = new Reserva()
                    {
                        idAlojamento = queryAloj.id,
                        dateReserva  = DateTime.Now,
                        dateCheckIn  = dateTimePicker1.Value,
                        dateCheckOut = dateTimePicker2.Value,
                        custo        = queryAloj.custoNoite,
                        idCustomer   = queryCustomer.id
                    };
                    context.Reservas.Add(reserva);
                    context.SaveChanges();
                    Close();
                }
            }
            else
            {
                MessageBox.Show("dados Invalidos");
            }
        }
コード例 #2
0
 public ReservaAlojamento(string UserName, string passWord, string nome, string sobreNome, string address, string phone, string email, DateTime resdate, DateTime checkInDate, DateTime checkOutDate)
 {
     client   = new Cliente(UserName, passWord, nome, sobreNome, address, phone, email);
     bungalow = new Alojamento();
     resDate  = DateTime.Now;
     inDate   = checkInDate;
     outDate  = checkOutDate;
 }