public IHttpActionResult ReservationInsert(ReservationInputVM input) { try { BLReservations reservations = new BLReservations(); //if (!reservations.checkReservationDate(input)) //{ // return Content(HttpStatusCode.BadRequest, "Slot non disponibile, cambia la tua data"); //} //else //{ // var reservation = reservations.Insert(input.event_name, input.description, input.username, input.room, input.start_date, input.end_date); // return Ok(new ReservationsVM(reservation)); //} var reservation = reservations.Insert(input.event_name, input.description, input.username, input.room, input.start_date, input.end_date); if (reservation is null) { return(NotFound()); } else { return(Ok(new ReservationsVM(reservation))); } } catch (Exception ex) { return(InternalServerError(ex)); } }
private void InitializeTabOverview() { List <RES_GetResByClientId_Result> oList = new List <RES_GetResByClientId_Result>(); try { oList = BLReservations.GetResClient(_Client.CLIENT_ID); dataGridViewReservations.DataSource = oList; dataGridViewReservations.ReadOnly = true; } catch (CustomError cEx) { MessageBox.Show(cEx.Message); } catch (Exception ex) { throw new CustomError(666); } }
public IHttpActionResult AllReservations() { try { BLReservations reservations = new BLReservations(); var reservation_list = reservations.All(); ReservationsVM obj = new ReservationsVM(); return(Ok(obj.CreateList(reservation_list))); } catch (Exception ex) { return(InternalServerError(ex)); } }
public IHttpActionResult ReservationDetail(string start_date, string end_date, string username) { try { BLReservations reservations = new BLReservations(); var reservation_list = reservations.GetDetail(start_date, end_date, username); ReservationsVM obj = new ReservationsVM(); return(Ok(obj.CreateList(reservation_list))); } catch (Exception ex) { return(InternalServerError(ex)); } }
// TAB MODIFIER VOL // Initialisation du tab des modifications avec les vols réservés private void InitializeTabModification() { List <RES_GetResByClientId_Result> oList = new List <RES_GetResByClientId_Result>(); try { cmbListeVolsReserves.DataSource = BLReservations.GetResClient(_Client.CLIENT_ID); cmbListeVolsReserves.ValueMember = "RES_ID"; cmbListeVolsReserves.DisplayMember = "VOL_CODE"; } catch (CustomError cEx) { MessageBox.Show(cEx.Message); } catch (Exception ex) { CustomError Cex = new CustomError(666); MessageBox.Show(Cex.Message); } }
private void btnSupprimerReservation_Click(object sender, EventArgs e) { RES_GetResByClientId_Result oResult = (RES_GetResByClientId_Result)cmbListeVolsReserves.SelectedItem; int tmp = oResult.RES_ID; try { BLReservations.DeleteResId(oResult.RES_ID); MessageBox.Show("Réservation avec id " + tmp.ToString() + " effectuée"); List <RES_GetResByClientId_Result> oList = BLReservations.GetResClient(_Client.CLIENT_ID); cmbListeVolsReserves.DataSource = oList; cmbListeVolsReserves.ValueMember = "RES_ID"; cmbListeVolsReserves.DisplayMember = "VOL_CODE"; } catch (CustomError cEx) { MessageBox.Show(cEx.Message); } catch (Exception ex) { CustomError crEx = new CustomError(666); MessageBox.Show(crEx.Message); } }
public IHttpActionResult ReservationDelete(string id) { try { int reservation_id = Int32.Parse(id); BLReservations reservations = new BLReservations(); var reservation_delete = reservations.Delete(reservation_id); //if (reservation_delete > 0) //{ // return Ok(reservation_id); //} //else //{ // return NotFound(); //} return(Ok("Reservation deleted")); } catch (Exception ex) { return(InternalServerError(ex)); } }
// Réserver un vol private void btnSubmit_Click(object sender, EventArgs e) { RES_GetAller_Result oAller = new RES_GetAller_Result(); BLPlannings oBlPlanning = new BLPlannings(); BLVols oBlVol = new BLVols(); BLAllerRetours oBlAllerRetour = new BLAllerRetours(); BLReservations oBlRes = new BLReservations(); BLAccompagnateurs oBlAccompagnateur = new BLAccompagnateurs(); VOL_SelectAllListChoix_Result oVolSimple = (VOL_SelectAllListChoix_Result)cmbVolAller.SelectedItem; //vol simple PLA_GetDateByVolId_Result oDateSimple = (PLA_GetDateByVolId_Result)cmbDateVolAller.SelectedItem; //Date vol simple PLA_GetDateByVolIdDateCritere_Result oDateRetour = (PLA_GetDateByVolIdDateCritere_Result)cmbDateVolRetour.SelectedItem; //Date vol retour VOL_SelectAllListChoixRetour_Result oVolRetour = BLVols.GetVolRetour(oVolSimple.VOL_ID_VILLE_ARR, oVolSimple.VOL_ID_VILLE_DEP); //vol retour int cpt = 1; // on compte le client int nbPlacesRestantes = 1000; //pour le test if (txtNomVoyageur1.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { cpt++; } if (txtNomVoyageur2.TextLength != 0) { cpt++; } if (txtNomVoyageur3.TextLength != 0) { cpt++; } if (txtNomVoyageur4.TextLength != 0) { cpt++; } if (txtNomVoyageur5.TextLength != 0) { cpt++; } try { using (TransactionScope scope = new TransactionScope()) { oBlPlanning.GetNbPlacesRestantesNEW(oVolSimple.VOL_ID, oDateSimple.PLAN_ID, out nbPlacesRestantes); if (cpt > nbPlacesRestantes) // s'il y a plus de voyageurs pour cette réservation que de places disponibles, fallback et on cherche les bonnes dates { string datesDispos = null; int nbPlacesRestantesDateDispo; List <PLA_GetDatesMemeVolWithPlaId_Result> oList = new List <PLA_GetDatesMemeVolWithPlaId_Result>(); oList = oBlPlanning.GetDatesMemeVol(oVolSimple.VOL_ID, oDateSimple.PLAN_ID); foreach (PLA_GetDatesMemeVolWithPlaId_Result oRes in oList) { oBlPlanning.GetNbPlacesRestantesNEW(oVolSimple.VOL_ID, oRes.PLAN_ID, out nbPlacesRestantesDateDispo); if (cpt < nbPlacesRestantesDateDispo) // récupération des bonnes dates; { datesDispos += oRes.PLAN_VOL_DATE.ToShortDateString() + "; "; } } //throw new CustomError(5) ; throw new CustomError("Place insuffisante sur ce vol.\nAlternatives: " + datesDispos); } if (radioAllerRetour.Checked) { if (cpt > nbPlacesRestantes) { throw new CustomError(6); } } //reservation commence ici int resIns = oBlRes.InsertRes(_Client.CLIENT_ID, oDateSimple.PLAN_ID); if (radioAller.Checked) { oAller = oBlRes.GetResAller(oDateSimple.PLAN_VOL_DATE, _Client.CLIENT_ID, oVolSimple.VOL_ID_VILLE_DEP, oVolSimple.VOL_ID_VILLE_ARR); if (oAller != null) { oBlAllerRetour.ARInsert(oAller.RES_ID.Value, oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } } int resVoy = -1; if (resIns != -1) //vérifer condition... { if (txtNomVoyageur1.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur1.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur1.Text.ToUpper(), txtNomVoyageur1.Text, DateTime.Parse(dateTimePickerVoyageur1.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur1.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur1.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } } if (txtNomVoyageur2.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur2.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur2.Text.ToUpper(), txtNomVoyageur2.Text, DateTime.Parse(dateTimePickerVoyageur2.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur2.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur2.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } } if (txtNomVoyageur3.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur3.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur3.Text.ToUpper(), txtNomVoyageur3.Text, DateTime.Parse(dateTimePickerVoyageur3.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur3.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur3.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } } if (txtNomVoyageur4.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur4.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur1.Text.ToUpper(), txtNomVoyageur4.Text, DateTime.Parse(dateTimePickerVoyageur4.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur4.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur4.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } } if (txtNomVoyageur5.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur5.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur5.Text.ToUpper(), txtNomVoyageur5.Text, DateTime.Parse(dateTimePickerVoyageur5.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur5.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur5.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); } } decimal?res = oBlRes.GetResPrixTotal(oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); if (res == null) { throw new CustomError(1); } if (radioAller.Checked && oAller != null) { MessageBox.Show("Reservation pour Vol aller déjà encodée rajoutée"); } else if (radioAller.Checked && oAller == null) { MessageBox.Show("Reservation pour Vol aller ajoutée"); } } if (radioAllerRetour.Checked) { resIns = oBlRes.InsertRes(_Client.CLIENT_ID, oDateRetour.PLAN_ID); oBlAllerRetour.ARInsert(oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); // resIns = oBlRes.InsertResRetour(_Client.CLIENT_ID, oDateRetour.PLAN_ID); si booléen //oBlRes.SetRetour(oBlRes.GetResId(_Client.CLIENT_ID, oDateSimple.PLAN_ID)); // technique du booléen if (resIns != -1) { if (txtNomVoyageur1.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur1.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur1.Text.ToUpper(), txtNomVoyageur1.Text, DateTime.Parse(dateTimePickerVoyageur1.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur1.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur1.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } } if (txtNomVoyageur2.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur2.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur2.Text.ToUpper(), txtNomVoyageur2.Text, DateTime.Parse(dateTimePickerVoyageur2.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur2.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur2.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } } if (txtNomVoyageur3.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur3.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur3.Text.ToUpper(), txtNomVoyageur3.Text, DateTime.Parse(dateTimePickerVoyageur3.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur3.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur3.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } } if (txtNomVoyageur4.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur4.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur1.Text.ToUpper(), txtNomVoyageur4.Text, DateTime.Parse(dateTimePickerVoyageur4.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur4.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur4.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } } if (txtNomVoyageur5.TextLength != 0) //on compte le nombre de voyageurs supplémentaires { if (txtNomVoyageur5.TextLength != 0) { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur5.Text.ToUpper(), txtNomVoyageur5.Text, DateTime.Parse(dateTimePickerVoyageur5.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } else { resVoy = oBlAccompagnateur.InsertVoyageur(txtNomVoyageur5.Text.ToUpper(), DateTime.Parse(dateTimePickerVoyageur5.Text), oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); } } decimal?res = oBlRes.GetResPrixTotal(oBlRes.GetResId(_Client.CLIENT_ID, oDateRetour.PLAN_ID)); if (res == null) { throw new CustomError(1); } MessageBox.Show("Reservation du vol retour effectuée"); } } InitializeTabOverview(); // on recharge les données InitializeTabModification(); // on recharge les données scope.Complete(); } } catch (CustomError cEx) { MessageBox.Show(cEx.Message); } catch (FormatException fEx) { CustomError oCst = new CustomError(2); MessageBox.Show(oCst.Message); } catch (Exception ex) { CustomError cEx = new CustomError(666); MessageBox.Show(cEx.Message); } }