public void ajouterVol(clsVolEntity vol, clsInfoClient client) { SqlConnection MyC = new SqlConnection(); MyC.ConnectionString = Connection; MyC.Open(); SqlCommand MyCom = new SqlCommand("dbo.enregistrerVol", MyC); MyCom.CommandType = CommandType.StoredProcedure; MyCom.Parameters.Add("@nomUser", SqlDbType.Text); MyCom.Parameters["@nomUser"].Value = client.nomUser; MyCom.Parameters.Add("@prenomUser", SqlDbType.Text); MyCom.Parameters["@prenomUser"].Value = client.prenomUser; MyCom.Parameters.Add("@adresseUser", SqlDbType.Text); MyCom.Parameters["@adresseUser"].Value = client.adresseUser; MyCom.Parameters.Add("@cpUser", SqlDbType.Int); MyCom.Parameters["@cpUser"].Value = client.cpUser; MyCom.Parameters.Add("@villeUser", SqlDbType.Text); MyCom.Parameters["@villeUser"].Value = client.villeUser; MyCom.Parameters.Add("@paysUser", SqlDbType.Text); MyCom.Parameters["@paysUser"].Value = client.paysUser; MyCom.Parameters.Add("@compteUser", SqlDbType.Text); MyCom.Parameters["@compteUser"].Value = client.compteUser; MyCom.Parameters.Add("@villeDepartVol", SqlDbType.Text); MyCom.Parameters["@villeDepartVol"].Value = vol.villeDepart; MyCom.Parameters.Add("@paysDepartVol", SqlDbType.Text); MyCom.Parameters["@paysDepartVol"].Value = vol.paysDepart; MyCom.Parameters.Add("@villeDestinationVol", SqlDbType.Text); MyCom.Parameters["@villeDestinationVol"].Value = vol.villeDestination; MyCom.Parameters.Add("@paysDestinationVol", SqlDbType.Text); MyCom.Parameters["@paysDestinationVol"].Value = vol.paysDestination; MyCom.Parameters.Add("@dateDepartVol", SqlDbType.Date); MyCom.Parameters["@dateDepartVol"].Value = vol.dateDepart; MyCom.Parameters.Add("@prixVol", SqlDbType.Int); MyCom.Parameters["@prixVol"].Value = vol.prixVol; MyCom.ExecuteScalar(); MyCom.Dispose(); MyC.Close(); }
public bool ajouterCommande(clsHotelEntity hotel, clsVolEntity vol, clsInfoClient client) { bool R = true; try { (new clsEnregistrerHotel()).ajouterHotel(hotel, client); (new clsEnregistrerVol()).ajouterVol(vol, client); } catch(SqlException e) { Console.WriteLine(e); R = false; } return R; }
private void btnLire_Click(object sender, EventArgs e) { MessageQueue mqVols = new MessageQueue(@".\private$\cmdvols"); MessageQueue mqHotels = new MessageQueue(@".\private$\cmdhotels"); mqVols.Formatter = new XmlMessageFormatter(new Type[] { typeof(clsVolEntity) }); mqHotels.Formatter = new XmlMessageFormatter(new Type[] { typeof(clsHotelEntity) }); var messageVol = (clsVolEntity)mqVols.Peek().Body; var messageHotel = (clsHotelEntity)mqHotels.Peek().Body; clsVolEntity vol = new clsVolEntity(); vol.dateDepart = messageVol.dateDepart; vol.villeDepart = messageVol.villeDepart; vol.paysDepart = messageVol.paysDepart; vol.villeDestination = messageVol.villeDestination; vol.paysDestination = messageVol.paysDestination; vol.prixVol = messageVol.prixVol; vol.infoClient = messageVol.infoClient; clsHotelEntity hotel = new clsHotelEntity(); hotel.nomHotel = messageHotel.nomHotel; hotel.adresseHotel = messageHotel.adresseHotel; hotel.cpHotel = messageHotel.cpHotel; hotel.villeHotel = messageHotel.villeHotel; hotel.paysHotel = messageHotel.paysHotel; hotel.dateArrivee = messageHotel.dateArrivee; hotel.duree = messageHotel.duree; hotel.infoClient = messageHotel.infoClient; clsInfoClient client = vol.infoClient; // Enregistrement en mode transactionnel bool resEnregistrement = new TraitementCommandeLibrary.libTraitementCommande().ajouterCommande(hotel, vol, client); // Transaction OK if (resEnregistrement == true) { txtListe.AppendText("Enregistrement du vol " + vol.villeDepart + " - " + vol.villeDestination + " et l'hotel " + hotel.nomHotel); mqVols.Receive(); mqHotels.Receive(); } // Transaction KO else { txtListe.AppendText("Impossible d'enregsitrer le vol " + vol.villeDepart + " - " + vol.villeDestination + " et l'hotel " + hotel.nomHotel); } mqVols.Close(); mqHotels.Close(); }
protected void btnValider_Click(object sender, EventArgs e) { GridViewRow rowVol = gvVols.SelectedRow; GridViewRow rowHotel = gvHotels.SelectedRow; DateTime dateDepart = cldDateDepart.SelectedDate; DateTime dateRetour = calHotel.SelectedDate; clsVolEntity volEntity = new clsVolEntity(); clsHotelEntity hotelEntity = new clsHotelEntity(); if (rowHotel != null && rowVol != null && verifierDateSelectionnee(dateDepart) && verifierDateSelectionnee(dateRetour)) { TimeSpan ts = dateRetour - dateDepart; int duree = ts.Days; volEntity.dateDepart = Convert.ToDateTime(rowVol.Cells[5].Text); volEntity.villeDepart = rowVol.Cells[1].Text; volEntity.paysDepart = rowVol.Cells[2].Text; volEntity.villeDestination = rowVol.Cells[3].Text; volEntity.paysDestination = rowVol.Cells[4].Text; volEntity.prixVol = Convert.ToInt32(rowVol.Cells[6].Text); hotelEntity.nomHotel = rowHotel.Cells[1].Text; hotelEntity.adresseHotel = rowHotel.Cells[2].Text; hotelEntity.cpHotel = Convert.ToInt32(rowHotel.Cells[3].Text); hotelEntity.villeHotel = rowHotel.Cells[4].Text; hotelEntity.paysHotel = rowHotel.Cells[5].Text; hotelEntity.dateArrivee = Convert.ToDateTime(rowHotel.Cells[8].Text); hotelEntity.duree = duree; hotelEntity.prixNuit = Convert.ToInt32(rowHotel.Cells[6].Text); Session["vol"] = volEntity; Session["hotel"] = hotelEntity; Session["arrivee"] = dateRetour.ToShortDateString(); Session["depart"] = dateDepart.ToShortDateString(); Response.Redirect("UIPaiement.aspx"); } else { lblError.Visible = true; lblError.Text = "Veuillez vérifier les vols et hotels choisis"; } }
protected void Button_valider_Click(object sender, EventArgs e) { // vol.nom // Donnée à envoyer string nom = txtNom.Text; string prenom = txtPrenom.Text; string age = txtAge.Text; string nationalite = txtNationalite.Text; string ville = txtVille.Text; string adresse = txtAdresse.Text; string tel = txtTelephone.Text; string numCarte = txtNumCarte.Text; string crypto = txtCryptogramme.Text; // date d'expiration de la carte DateTime dateExp = new DateTime(Convert.ToInt32(drpAnneeExpiration.SelectedValue), Convert.ToInt32(drpMoisExpiration.SelectedValue), 1); // Verification de remplissable des champs if (!String.IsNullOrEmpty(nom) && !String.IsNullOrEmpty(prenom) && !String.IsNullOrEmpty(age) && !String.IsNullOrEmpty(nationalite) && !String.IsNullOrEmpty(ville) && !String.IsNullOrEmpty(txtCp.Text) && !String.IsNullOrEmpty(adresse) && !String.IsNullOrEmpty(tel)&& !String.IsNullOrEmpty(numCarte) && !String.IsNullOrEmpty(crypto) && dateExp != null) { // Informations client clsInfoClient client = new clsInfoClient(); client.nomUser = nom; client.prenomUser = prenom; client.age = age; client.paysUser = nationalite; client.villeUser = ville; client.cpUser = Convert.ToInt32(txtCp.Text); client.adresseUser = adresse; client.tel = tel; client.compteUser = numCarte + ' ' + crypto; client.dateExp = dateExp; // Recuperation du vol et de l'hotel clsVolEntity vol = new clsVolEntity(); clsHotelEntity hotel = new clsHotelEntity(); vol = (clsVolEntity) Session["vol"]; hotel = (clsHotelEntity) Session["hotel"]; vol.infoClient = client; hotel.infoClient = client; // Ajout a la file d'attente MessageQueue mqVols = new MessageQueue(@".\private$\cmdvols"); MessageQueue mqHotels = new MessageQueue(@".\private$\cmdhotels"); mqVols.Send(vol, "Commande vol"); mqHotels.Send(hotel, "Commande hotel"); mqVols.Close(); mqHotels.Close(); Response.Redirect("UICommandeValidee.aspx"); } else { lblError.Text = "Veuillez remplir les champs !"; lblError.Visible = true; } }