protected void Ajouter_Click(object sender, EventArgs e) { int idConducteur = int.Parse(drDownConducteur.SelectedItem.Value); string depart = txtDepart.Text; string destination = txtDestination.Text; int nbPassagers; bool isNbPassagersDigit = int.TryParse(txtNbPassagers.Text, out nbPassagers); double prix; bool isPrixDigit = double.TryParse(txtPrix.Text, out prix); DateTime heureDepart = calHeureDepart.SelectedDate; bool fumeur = ckBoxFumeur.Checked; bool animaux = ckBoxAnimaux.Checked; bool bcpBagages = ckBoxBcpBagage.Checked; if (isPrixDigit && isNbPassagersDigit) { Voyage voyage = new Voyage(0, idConducteur, prix, depart, destination, heureDepart, animaux, fumeur, bcpBagages, nbPassagers); VoyageFactory.Save(ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, voyage); Response.Redirect("Default.aspx"); } else { lblEnterNumber.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { membre = Session[TP3.SESSIONMEMBRE] as Membre; if (membre != null) { if (membre.IsAdmin) { btnDelete.Visible = true; } } if (Request.QueryString["ID"] != null) { ID = int.Parse(Request.QueryString["ID"]); } else { Response.Redirect("Default.aspx"); } voyage = VoyageFactory.GetByID(System.Configuration.ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, ID); lblPrix.Text = voyage.Prix.ToString(); lblDepart.Text = voyage.Depart; lblDestination.Text = voyage.Destination; lblHeure.Text = voyage.HeureDepart.ToString(); lblPassagers.Text = voyage.NbPassagers.ToString(); chkAnimaux.Checked = voyage.Animaux; chkFumeur.Checked = voyage.Fumeur; chkEquipe.Checked = voyage.BienEquipe; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Voyage[] voyages; voyages = VoyageFactory.GetAll(ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString); Repeater_Voyages.DataSource = voyages.ToArray(); Repeater_Voyages.DataBind(); } }
protected void btnReserver_Click(object sender, EventArgs e) { if (voyage.NbPassagers >= int.Parse(txtReserve.Text)) { int passager = voyage.NbPassagers - int.Parse(txtReserve.Text); VoyageFactory.UpdatePassager(System.Configuration.ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, passager, ID); Reservation reservation = new Reservation(0, membre.Id, ID, int.Parse(txtReserve.Text)); ReservationFactory.Save(System.Configuration.ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, reservation); Response.Redirect("SearchTrips.aspx"); } else { NotEnoughPlace.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { int ID = 0; if (Request.QueryString["ID"] != null) { ID = int.Parse(Request.QueryString["ID"]); } else { Response.Redirect("SearchTrips.aspx"); } Reservation reservation = ReservationFactory.GetByID(ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, ID); Voyage voyage = VoyageFactory.GetByID(ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, reservation.IdVoyage); int nbPassager = voyage.NbPassagers + reservation.NbPassager; VoyageFactory.UpdatePassager(ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, nbPassager, reservation.IdVoyage); ReservationFactory.Delete(ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, ID); Response.Redirect("SearchTrips.aspx"); }
protected void Rechercher_Click(object sender, EventArgs e) { string depart; string destination; bool fumeur; bool animaux; bool bienEquipe; DateTime dateDebut; DateTime dateFin; depart = txtDepart.Text; destination = txtDestination.Text; fumeur = ckBoxFumeur.Checked; animaux = ckBoxAnimaux.Checked; bienEquipe = ckBoxBcpBagage.Checked; dateDebut = calDebut.SelectedDate; dateFin = calFin.SelectedDate; Voyage[] voyages = VoyageFactory.Search(ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, fumeur, animaux, bienEquipe, depart, destination, dateDebut, dateFin); Repeater_Voyages.DataSource = voyages.ToArray(); Repeater_Voyages.DataBind(); }
protected void btnDelete_Click(object sender, EventArgs e) { VoyageFactory.Delete(System.Configuration.ConfigurationManager.ConnectionStrings["cnnStr"].ConnectionString, ID); Response.Redirect("SearchTrips.aspx"); }