public IEnumerable <Hotel> GetReservableHotel(Guid congressId) { try { var lst = new HotelBO().Where(this.ConnectionHandler, x => x.CongressId == congressId); new HotelBO().SetCapacity(ConnectionHandler, lst, congressId); var hotels = new List <Hotel>(); foreach (var hotel in lst) { if (string.IsNullOrEmpty(hotel.Name)) { continue; } if (hotel.FreeCapicity > 0) { hotels.Add(hotel); } } return(hotels); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
private void button1_Click(object sender, EventArgs e) { HotelBO h = new HotelBO(); if (codH.Text.Length != 0) { ControlaHoteis.InfoHotel(Int32.Parse(codH.Text)); if (Int32.Parse(codH.Text) == h.Cod) { MessageBox.Show("Hotel Encontrado"); this.Hide(); } else { MessageBox.Show("Hotel não existe!"); } } else { MessageBox.Show("Campos por preencher!!!"); } this.Close(); m1 = new Thread(volta_Menu); m1.TrySetApartmentState(ApartmentState.STA); m1.Start(); }
public override bool Delete(params object[] keys) { try { var obj = new HotelBO().Get(this.ConnectionHandler, keys); var list = new HotelUserBO().Any(ConnectionHandler, supporter => supporter.HotelId == obj.Id); if (list) { throw new Exception(Resources.Congress.ErrorInDeleteHotelBecauseThisReserved); } if (!new HotelBO().Delete(this.ConnectionHandler, keys)) { throw new Exception(Resources.Congress.ErrorInDeleteHotel); } return(true); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
/// <summary> /// Guarda infos dos parametros em BO /// </summary> /// <param name="hotel"></param> public void GuardaInfoHotel(HotelBO hotel) { base.MaxQuartos = hotel.MaxQuartos; base.Morada = hotel.Morada; base.Nome = hotel.Nome; base.NumTelemovel = hotel.NumTelemovel; }
/// <summary> /// Adiciona hotel validando as condiçoes /// </summary> /// <param name="hotel"></param> /// <param name="user"></param> /// <param name="pw"></param> /// <returns></returns> static public bool AddHotel(HotelBO hotel) { if (hotel.MaxQuartos != 0 && hotel.MaxQuartos <= 100) { return(Hoteis.AddHotel(hotel)); } return(false); }
public HotelBO DevolveInfo() { HotelBO hotel = new HotelBO(); hotel.MaxQuartos = base.MaxQuartos; hotel.Morada = base.Morada; hotel.Nome = base.Nome; hotel.NumTelemovel = base.NumTelemovel; return(hotel); }
/// <summary> /// Adiciona Hotel à lista /// </summary> /// <param name="hotel"></param> /// <returns></returns> static public bool AddHotel(HotelBO hotel) { if (ProcuraHotel(hotel.Cod) == false) { Hotel h = new Hotel(hotel.MaxQuartos); h.GuardaInfoHotel(hotel); //hoteis[quantHoteis] = h; //quantHoteis++; return(true); } else { return(false); } }
public List <Hotel> GetByCongressId(Guid congressId) { try { var lst = new HotelBO().Where(this.ConnectionHandler, x => x.CongressId == congressId); new HotelBO().SetCapacity(ConnectionHandler, lst, congressId); return(lst); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
private void InsertarHotel() { var hotel = new Hotel { Nombre = txtNombre.Text, Pais = txtPais.Text, Lugar = txtLugar.Text, Habitacion = txtPais.Text, }; var hotelBo = new HotelBO(); try { hotelBo.RegistrarHotel(hotel); MonstrarMensaje("hotel creado satisfactoriamente"); } catch (Exception e) { MonstrarError(e.Message); } }
private void EliminarHotel() { var hotel = new Hotel { Nombre = txtNombre.Text, }; var hotelBo = new HotelBO(); try { if (!txtNombre.Text.Equals("")) { hotelBo.Eliminar(txtNombre.Text.Trim()); MonstrarMensaje("hotel eliminado satisfactoriamente"); } } catch (Exception e) { MonstrarError(e.Message); } }
private void button1_Click(object sender, EventArgs e) { bool x = false; HotelBO hotel = new HotelBO(); if (nome.Text.Length != 0 && codH.Text.Length != 0 && morada.Text.Length != 0 && numTel.Text.Length != 0 && numQ.Text.Length != 0) { hotel = new HotelBO(nome.Text, morada.Text, Int32.Parse(numQ.Text), Int32.Parse(codH.Text)); x = ControlaHoteis.AddHotel(hotel); MessageBox.Show("Hotel " + nome.Text + " adicionado!"); this.Hide(); } else { MessageBox.Show("Campos por preencher!!!"); } try { hotel = new HotelBO(nome.Text, morada.Text, Int32.Parse(numQ.Text), Int32.Parse(codH.Text)); } catch (Exception ex) { throw new Exception(ex.Message); } /* * if (!x) * { * MessageBox.Show("Hotel " + nome.Text + " adicionado!"); * this.Hide(); * }*/ this.Close(); m1 = new Thread(volta_Menu); m1.TrySetApartmentState(ApartmentState.STA); m1.Start(); }