public HotelContext(DbContextOptions <HotelContext> options) : base(options) { if (Agences.Count() == 0) { Agences.Add(new HotelModel.Agence { IdentifiantAgence = "hijk", MotDePasseAgence = "lmnop", Reduction = 0.75 }); SaveChanges(); } if (Chambres.Count() == 0) { Chambres.Add(new HotelModel.Chambre { NombreDeLits = 3, Surface = 40, BasePrix = 100, ImageUrl = "https://www.usine-digitale.fr/mediatheque/3/9/8/000493893/hotel-c-o-q-paris.jpg" }); Chambres.Add(new HotelModel.Chambre { NombreDeLits = 1, Surface = 100, BasePrix = 35, ImageUrl = "https://www.hotel-design-secret-de-paris.com/wp-content/uploads/2015/01/secret-de-paris-chambre-trocadero-21-md1.jpg" }); SaveChanges(); } }
protected void Page_Load(object sender, EventArgs e) { // Rien faire si c'est un postback if (IsPostBack) { return; } // Vérifier que le mois spécifié est correct this.ParseMois(Request.QueryString["mois"]); // Loader le dataset des chambres _chambres = AppartHelper.GetChambres(); // Loader le dataset de la consommation _usage = new Usage(); string year = (_mois > DateTime.Now.Month ? DateTime.Now.Year - 1 : DateTime.Now.Year).ToString(); string month = (_mois < 10 ? "0" + _mois : _mois.ToString()); _usage.ReadXml(this.MapPath("App_Data/" + year + month + ".xml")); lblPhaseAppartMois.Text = String.Format(lblPhaseAppartMois.Text, Mois[_mois - 1]); // Charger l'information et les rapports LoadSummary(); LoadPhases(); LoadHallOfFame(); }
private void chambreAutoCompleteBox_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (chambreAutoCompleteBox.SelectedItem != null) { Chambres Cham = chambreAutoCompleteBox.SelectedItem as Chambres; if (Cham.EtatOperation == "SALLE") { MessageBox.Show("La chambre est salle veuillez la nettoyée", "Message", MessageBoxButton.OK, MessageBoxImage.Warning); rcbChambres.SelectedItem = null; return; } else { rcbChambres.SelectedItem = chambreAutoCompleteBox.SelectedItem as Chambres; rnHeure.Focus(); UpdateMontant(); } } else if (chambreAutoCompleteBox.SearchText != "") { MessageBox.Show("Ce numéro de chambre n’existe pas. Veuillez entrer un numéro correct ou appuyez F1", "Message", MessageBoxButton.OK, MessageBoxImage.Warning); Clear(); } } }
public bool isAvailable(DateTime datedeb, DateTime dateF, Chambres chambre) { try { DateTime date = datedeb; DateTime datefin = dateF; if (chambre != null) { var resreserv = from res in model.Reservations where res.idChambre == chambre.ID && res.Etat != "TERMINER" && (date >= res.DateArrive || datefin >= res.DateArrive) && (date <= res.DateDepart || datefin <= res.DateDepart) select res; if (resreserv != null && resreserv.Count() != 0) { return(false); } } } catch (Exception) { } return(true); }
public override global::System.Data.DataSet Clone() { Chambres cln = ((Chambres)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
private void rcbChambres_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (rcbChambres.SelectedItem != null) { Chambres Cham = rcbChambres.SelectedItem as Chambres; chambreAutoCompleteBox.SelectedItem = rcbChambres.SelectedItem as Chambres; } }
private void chambreAutoCompleteBox_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (chambreAutoCompleteBox.SelectedItem != null) { Chambres Cham = chambreAutoCompleteBox.SelectedItem as Chambres; rcbChambres.SelectedItem = chambreAutoCompleteBox.SelectedItem as Chambres; } } }
public ActionResult Create([Bind(Include = "idCh,codeCh,libelle")] Chambres chambres) { if (ModelState.IsValid) { sw.AjouterChambre(chambres); //db.Chambres.Add(chambres); //db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chambres)); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { Chambres ds = new Chambres(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public ActionResult Edit([Bind(Include = "idCh,codeCh,libelle")] Chambres chambres) { if (ModelState.IsValid) { sw.EditerChambre(chambres); //db.Entry(chambres).State = EntityState.Modified; //db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chambres)); }
private void rcbChambres_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (rcbChambres.SelectedItem != null) { Chambres Cham = rcbChambres.SelectedItem as Chambres; chambreAutoCompleteBox.SelectedItem = rcbChambres.SelectedItem as Chambres; UpdateMontant(); } rtHD.Focus(); }
private const int Mois = 6; // juin static void Main(string[] args) { Console.WriteLine("Déterminer la liste des chambres..."); Chambres chambres = AppartHelper.GetChambres(); Console.WriteLine("Télécharger l'utilisation des chambres..."); Usage usage = AppartHelper.GetUsage(chambres, Mois); Console.WriteLine("Sauvegarder l'information dans un fichier XML..."); string filename = "20110" + (Mois >= 10 ? Mois.ToString() : "0" + Mois.ToString()) + " .xml"; usage.WriteXml(filename); }
public HotelContext(DbContextOptions <HotelContext> options) : base(options) { if (Agences.Count() == 0) { Agences.Add(new HotelModel.Agence { IdentifiantAgence = "abcd", MotDePasseAgence = "efgh", Reduction = 0.25 }); Agences.Add(new HotelModel.Agence { IdentifiantAgence = "hijk", MotDePasseAgence = "lmnop", Reduction = 0.5 }); SaveChanges(); } if (Chambres.Count() == 0) { Chambres.Add(new HotelModel.Chambre { NombreDeLits = 3, Surface = 20, BasePrix = 80, ImageUrl = "https://www.hotel-beaujolais.com/img/build/les-pierres-dorees-chambres.jpg" }); Chambres.Add(new HotelModel.Chambre { NombreDeLits = 5, Surface = 50, BasePrix = 100, ImageUrl = "https://assets.hotelaparis.com/uploads/pictures/000/043/953/Chambre-3-6.jpg" }); Chambres.Add(new HotelModel.Chambre { NombreDeLits = 2, Surface = 40, BasePrix = 60, ImageUrl = "https://www.hotel-diana-dauphine.com/media/cache/jadro_resize/rc/rhCiPkJe1582096951/jadroRoot/medias/5658345e8f976/chambre-1.jpg" }); SaveChanges(); } }
public bool AjouterChambre(Chambres ch) { bool rep = false; try { db.Chambres.Add(ch); db.SaveChanges(); rep = true; }catch (Exception ex) { } return(rep); }
public bool EditerChambre(Chambres ch) { bool rep = false; try { var i = db.Chambres.Find(ch.idCh); i.codeCh = ch.codeCh; i.libelle = ch.libelle; db.SaveChanges(); }catch (Exception ex) { } return(rep); }
// GET: Chambres/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Chambres chambres = sw.ListerChambres().Where(a => a.idCh == id).FirstOrDefault(); //sw.db.Chambres.Find(id); if (chambres == null) { return(HttpNotFound()); } return(View(chambres)); }
public InsertData(string etat, Chambres ele, ChambresViewModel view) { InitializeComponent(); this.DataContext = viewVM = view; Etat = etat; if (etat == "AJOUT") { this.Title = "Enregistrement d'un Quartier"; } else { this.Title = "Modification d'un Quartier"; } }
private void btnValider_Click(object sender, RoutedEventArgs e) { try { ChambresViewModel vm = this.DataContext as ChambresViewModel; Chambres ent = vm.SelectedData; if (Etat == "AJOUT") { try { ent.Etat = "ACTIF"; ent.EtatOperation = "LIBRE"; ent.idHotel = 1; viewVM.model.Chambres.Add(ent); viewVM.model.SaveChanges(); Msg = "OK"; this.Close(); } catch (Exception ex) { Msg = "Error"; ErrorMsg = ex.Message; } } else { try { viewVM.model.SaveChanges(); Msg = "OK"; this.Close(); } catch (Exception ex) { Msg = "Error"; ErrorMsg = ex.Message; } } } catch (Exception) { } }
private void rtHF_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { Chambres item = Res.Chambres; if (!isAvailable(rtHD.SelectedValue.Value, rtHF.SelectedValue.Value, item.ID)) { MessageBox.Show("Chambre pas disponible", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); } rnHeure.Focus(); btnValider.Focus(); //rntarif.Focus(); } }
private void rtHD_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (rcbChambres.SelectedItem != null) { Chambres item = rcbChambres.SelectedItem as Chambres; if (!isAvailable(rtHD.SelectedValue.Value, rtHF.SelectedValue.Value, item.ID)) { Load(); MessageBox.Show("Chambre pas disponible", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); } rnHeure.Focus(); } } }
private void rtHD_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (chambreAutoCompleteBox.SelectedItem != null) { Chambres item = chambreAutoCompleteBox.SelectedItem as Chambres; if (!isAvailable(rtHD.SelectedValue.Value, rtHF.SelectedValue.Value, item.ID)) { Load(); MessageBox.Show("Ce numéro de chambre n’existe pas. Veuillez entrer un numéro correct ou appuyez F1", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); } rnHeure.Focus(); } } }
private void rcbChambres_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (rcbChambres.SelectedItem != null) { Chambres Cham = rcbChambres.SelectedItem as Chambres; if (Cham.EtatOperation == "SALLE") { MessageBox.Show("La chambre est salle veuillez la nettoyée", "Message", MessageBoxButton.OK, MessageBoxImage.Warning); rcbChambres.SelectedItem = null; return; } else { chambreAutoCompleteBox.SelectedItem = rcbChambres.SelectedItem as Chambres; UpdateMontant(); } } rtHD.Focus(); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { //if (GlobalData.VerificationDroit("CanAddChambres")) //{ var result = MessageBox.Show("Voulez vous vraiment supprimer ?", "Message", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { if (dataGrid.SelectedItem != null) { try { viewM = this.Main.DataContext as ChambresViewModel; Chambres ent = dataGrid.SelectedItem as Chambres; ent.Etat = "SUPPRIMER"; viewM.model.SaveChanges(); viewM.Refresh(); MessageBox.Show("Opération effectuée avec succès", "Chambres", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Chambres", MessageBoxButton.OK, MessageBoxImage.Warning); viewM.Refresh(); } } else { MessageBox.Show("Aucune ligne selectionnée dans la liste", "Chambres", MessageBoxButton.OK, MessageBoxImage.Warning); } } //} }
private void UpdateMontant() { if (rcbChambres.SelectedItem != null) { Chambres Cham = rcbChambres.SelectedItem as Chambres; int NbreHr = -rtHD.SelectedTime.Value.Subtract(rtHF.SelectedTime.Value).Hours; if (NbreHr > 0) { ReservationTypes resSer = GlobalData.model.ReservationTypes.Where(c => c.Etat == "ACTIF" && c.ReservationType == "PASSAGE").FirstOrDefault(); TypePrix tpPrix = GlobalData.model.TypePrix.Where(c => c.Etat == "ACTIF" && c.idReservationType == resSer.ID).FirstOrDefault(); var resreserv = from res in GlobalData.model.PrixChambres where res.Etat == "ACTIF" && res.idTypePrix == tpPrix.idTypePrix && res.idTypeChambre == Cham.TypeChambre select res; if (resreserv != null && resreserv.Count() != 0) { PrixChambres prix = resreserv.FirstOrDefault(); var resOR = from res in GlobalData.model.OperationRules where res.Etat == "ACTIF" && res.idReservationTypes == resSer.ID && res.idTypeChambre == Cham.TypeChambre select res; if (resOR != null && resOR.Count() != 0) { rntarif.Value = NbreHr * (double)prix.Prix; foreach (OperationRules OpRule in resOR) { int nbr = (int)(NbreHr / (OpRule.Quantite + 1)); double h = NbreHr; double n = (double)OpRule.Quantite; double r = (double)OpRule.Reductions.Valeur; double p = (double)prix.Prix; double pc = 0; switch (OpRule.Rules.idRules) { case 1: pc = (r * (int)(h / (n + 1))); rntarif.Value -= pc; break; case 2: if (h > n) { pc = (r * (h - n)); } else { pc = 0; } rntarif.Value -= pc; break; case 3: pc = (r * h); rntarif.Value -= pc; break; case 4: pc = (r); rntarif.Value -= pc; break; case 5: pc = (r); rntarif.Value -= pc; break; default: break; } } } else { rntarif.Value = Convert.ToDouble(prix.Prix * NbreHr); } DisableBoutton(true); } else { return; } } else { DisableBoutton(false); } } }
private void btnEnregistrer_Click(object sender, RoutedEventArgs e) { try { //if (!GlobalData.VerifyClotureSession()) //{ // var result = MessageBox.Show("Voulez-vous fermer la session précédente ?", "Message", MessageBoxButton.YesNo, MessageBoxImage.Warning); // if (result == MessageBoxResult.Yes) // { // RadDocumentPane radMenu = new RadDocumentPane(); // radMenu.Content = new GESHOTEL.ReservationsModules.Views.Win.ClotureJourneeFrm("Cloture de la session du " + GlobalData.CurrentRegistres.DateDebut.Value.ToShortDateString()); // radMenu.Header = "Cloture de la session du " + GlobalData.CurrentRegistres.DateDebut.Value.ToShortDateString(); // GlobalData.rrvMain.Title = "Cloture de la session du " + GlobalData.CurrentRegistres.DateDebut.Value.ToShortDateString(); // radMenu.FontFamily = new FontFamily("Perpetua Titling MT"); // radMenu.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; // radMenu.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; // if (!GlobalData.VerifyDock("Cloture de la session du " + GlobalData.CurrentRegistres.DateDebut.Value.ToShortDateString())) // { // GlobalData.PaneGroup.AddItem(radMenu, Telerik.Windows.Controls.Docking.DockPosition.Center); // } // else // { // } // } // return; //} Chambres Cham = chambreAutoCompleteBox.SelectedItem as Chambres; if (Cham.EtatOperation == "SALLE") { MessageBox.Show("La chambre est salle veuillez la nettoyée", "Message", MessageBoxButton.OK, MessageBoxImage.Warning); return; } var results = MessageBox.Show("Voulez-vous enregistrer ?", "Message", MessageBoxButton.YesNo, MessageBoxImage.Question); if (results == MessageBoxResult.Yes) { int NbreHr = -rtHD.SelectedTime.Value.Subtract(rtHF.SelectedTime.Value).Hours; if (rnHeure.Value <= 0) { MessageBox.Show("Le nombre d'heure ne peut pa etre egale a 0", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); return; } if (chambreAutoCompleteBox.SelectedItem == null) { MessageBox.Show("Choisissez une chambre svp", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); return; } if (NbreHr <= 0) { MessageBox.Show("Le nombre d'heure ne peut pa etre egale a 0", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); return; } Transactions Trans = new Transactions(); Trans.DateTransaction = DateTime.Now; Trans.TotalPaye = Convert.ToDecimal(rntarif.Value); Trans.TotalTTC = Convert.ToDecimal(rntarif.Value); Trans.TotalHT = Convert.ToDecimal(rntarif.Value); Trans.TVA = 0; Trans.TotalReste = 0; Trans.Etat = "PAYE"; DetailPaiements dtPaie = new DetailPaiements(); dtPaie.Montant = rntarif.Value; dtPaie.DatePaiement = DateTime.Now; dtPaie.MethodePaiements = GlobalData.model.MethodePaiements.Where(c => c.Libelle == "ESPECE").First(); dtPaie.Transactions = Trans; dtPaie.Etat = "ACTIF"; //dtPaie.idHotel = GlobalData.HotId; Trans.DetailPaiements.Add(dtPaie); if (Cham.EtatOperation == "LIBRE" || Cham.EtatOperation == "RESERVER") { Cham.EtatOperation = "OCCUPER"; } DetailTransactions dtTrans = new DetailTransactions(); dtTrans.Date = DateTime.Now; dtTrans.Descriptions = "CHAMBRE " + Cham.TypeChambres.Libelle + " " + Cham.Numero; dtTrans.prix = Convert.ToDecimal(rntarif.Value); dtTrans.Quantite = 1; dtTrans.Montant = Convert.ToDecimal(rntarif.Value); dtTrans.Transactions = Trans; dtTrans.Etat = "ACTIF"; //dtTrans.idHotel = GlobalData.HotId; dtTrans.Produits = GlobalData.model.Produits.Where(c => c.Libelle == "CHAMBRE").First(); Trans.DetailTransactions.Add(dtTrans); ReservationTypes resType = GlobalData.model.ReservationTypes.Where(c => c.ReservationType == "PASSAGE").First(); Reservations Reservations = new Reservations(); Reservations.ReservationDate = DateTime.Now; Reservations.Chambres = Cham; Reservations.Transactions.Add(Trans); Reservations.ReservationTypes = resType; Reservations.NbreNuit = NbreHr; Reservations.Etat = "ACTIF"; Reservations.EtatOperation = "ARRIVEE"; Reservations.TotalPaye = Trans.TotalPaye; Reservations.TotalReste = Trans.TotalReste; Reservations.TotalTTC = Trans.TotalTTC; Reservations.DateDepart = new DateTime(rtHF.SelectedDate.Value.Year, rtHF.SelectedDate.Value.Month, rtHF.SelectedDate.Value.Day, rtHF.SelectedTime.Value.Hours, rtHF.SelectedTime.Value.Minutes, rtHF.SelectedTime.Value.Seconds); Reservations.DateArrive = new DateTime(rtHD.SelectedDate.Value.Year, rtHD.SelectedDate.Value.Month, rtHD.SelectedDate.Value.Day, rtHD.SelectedTime.Value.Hours, rtHD.SelectedTime.Value.Minutes, rtHD.SelectedTime.Value.Seconds); Reservations.TypeOperation = "LOCATION CHAMBRE"; Reservations.DateCheckIn = DateTime.Now; Reservations.isCheckIn = true; //Reservations.idHotel = GlobalData.HotId; Reservations.idRegistre = GlobalData.RegId; //Trans.idHotel = GlobalData.HotId; Trans.idRegistre = GlobalData.RegId; Trans.TypeTransaction = resType.ReservationType; Parametres param = GlobalData.model.Parametres.Where(c => c.IdParametre == 1).First(); Trans.TransactionNumero = GlobalData.GenerateFacture(param.TransNum.ToString(), 6); param.TransNum++; GlobalData.model.Transactions.Add(Trans); GlobalData.model.Reservations.Add(Reservations); GlobalData.model.SaveChanges(); var result = MessageBox.Show("Voulez vous imprimer le recu?", "Vente", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { try { //RapportWindows frm = new RapportWindows(Reservations.ID, "", "ALL"); //frm.ShowDialog(); //frm.Print(); } catch (Exception ex) { } } //MessageBox.Show("Operation terminée", "Message", MessageBoxButton.OK, MessageBoxImage.None); Clear(); GlobalFO.rpVM.Load(); chambreAutoCompleteBox.Focus(); } } catch (Exception ex) { if (ex.Message == "Échec du fournisseur sous-jacent sur Commit.") { } else { } } }
private void btnEnregistrer_Click(object sender, RoutedEventArgs e) { try { Chambres Cham = rcbChambres.SelectedItem as Chambres; int NbreHr = (int)rnHeure.Value; if (rcbChambres.SelectedIndex == -1) { MessageBox.Show("Choisissez une chambre svp", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); return; } if (NbreHr <= 0) { MessageBox.Show("Le nombre d'heure ne peut pas etre égale a 0", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); return; } Transactions Trans = Res.Transactions.FirstOrDefault(); Trans.TotalPaye = Convert.ToDecimal(rntarif.Value); Trans.TotalTTC = Convert.ToDecimal(rntarif.Value); Trans.TotalHT = Convert.ToDecimal(rntarif.Value); Trans.TVA = 0; Trans.TotalReste = 0; //Trans.Etat = "PAYE"; DetailPaiements dtPaie = Trans.DetailPaiements.FirstOrDefault(); dtPaie.Montant = rntarif.Value; DetailTransactions dtTrans = Trans.DetailTransactions.FirstOrDefault(); dtTrans.prix = Convert.ToDecimal(rntarif.Value); dtTrans.Quantite = 1; dtTrans.Montant = Convert.ToDecimal(rntarif.Value); Res.Chambres.EtatOperation = "LIBRE"; Res.Chambres = Cham; Cham.EtatOperation = "OCCUPER"; //Res.Chambres = Cham; Res.NbreNuit = NbreHr; Res.TotalPaye = Trans.TotalPaye; Res.TotalReste = Trans.TotalReste; Res.TotalTTC = Trans.TotalTTC; Res.DateDepart = new DateTime(rtHF.SelectedDate.Value.Year, rtHF.SelectedDate.Value.Month, rtHF.SelectedDate.Value.Day, rtHF.SelectedTime.Value.Hours, rtHF.SelectedTime.Value.Minutes, rtHF.SelectedTime.Value.Seconds); GlobalData.model.SaveChanges(); MessageBox.Show("Operation terminée", "Message", MessageBoxButton.OK, MessageBoxImage.None); this.Close(); } catch (Exception ex) { if (ex.Message == "Échec du fournisseur sous-jacent sur Commit.") { } else { } } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); Chambres ds = new Chambres(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "ChambresDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
// Transform the given rental orders to custom appointments ready to be bound to the scheduler public ObservableCollection <CustomAppointment> LoadAppointments(IEnumerable <Reservations> rentalOrders) { IEnumerable <Chambres> cars = GlobalData.model.Chambres.Where(c => c.Etat != "SUPPRIMER"); IEnumerable <ReservationTypes> cats = GlobalData.model.ReservationTypes.Where(c => c.Etat != "SUPPRIMER"); IEnumerable <TimeMarkers> tm = GlobalData.model.TimeMarkers; ObservableCollection <CustomAppointment> appointments = new ObservableCollection <CustomAppointment>(); if (rentalOrders != null) { foreach (Reservations order in rentalOrders) { try { CustomAppointment app = new CustomAppointment(); Chambres cham = cars.First(x => x.ID == order.idChambre); ReservationTypes category = cats.First(x => x.ID == order.idReservationType); TimeMarkers timemarker = tm.First(x => x.TimeMarkerName == order.EtatOperation); app.UniqueId = order.ID.ToString(); app.ReservationID = order.ID; app.ChambreID = order.idChambre.ToString(); app.Start = order.DateArrive.Value; app.End = order.DateDepart.Value; app.Category = category; app.TimeMarker = timemarker; app.Chambre = "Chambres : " + cham.Numero; //app.TypeChambreID = cham.TypeChambre.ToString(); if (order.ReservationTypes.ReservationType == "PASSAGE") { app.Subject = order.ReservationTypes.ReservationType; int nbr = -order.DateArrive.Value.Subtract(order.DateDepart.Value).Hours; app.NbreHeure = "" + nbr + " Hr"; } else if (order.ReservationTypes.ReservationType == "MAINTENANCE") { app.Subject = order.ReservationTypes.ReservationType; app.NbreHeure = "" + order.NbreNuit + " Nuit"; } else { app.Subject = order.Clients.Noms; app.NbreHeure = "" + order.NbreNuit + " Nuit"; } if (order.Etat == "RESERVER") { ReservationTypes Dcategory = cats.First(x => x.CategoryName == "RESERVATION"); Dcategory.ReservationEtat = order.Etat; app.Category = Dcategory; } if (order.Etat == "DUE OUT") { ReservationTypes Dcategory = cats.First(x => x.CategoryName == "DUE OUT"); Dcategory.ReservationEtat = order.Etat; app.Category = Dcategory; } //category.ReservationEtat = order.Etat; app.Etat = order.Etat; //app.Localite = order.Localite; appointments.Add(app); } catch (Exception) { } } } return(appointments); }
private void btnEnregistrer_Click(object sender, RoutedEventArgs e) { Chambres Cham = rcbChambres.SelectedItem as Chambres; if (rcbChambres.SelectedIndex == -1) { MessageBox.Show("Choisissez une chambre svp", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); return; } //Cham.EtatOperation = Res.Chambres.EtatOperation; //Res.Chambres.EtatOperation = "LIBRE"; Res.Chambres = Cham; //Cham.EtatOperation = "OCCUPER"; try { var result = MessageBox.Show("Voulez vous enregistrer cette arrivée?", "Message", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { if (Res.TotalReste == 0) { if (isAvailable(Res.DateArrive.Value, Res.DateDepart.Value, Res.Chambres)) { if (Res.Chambres.EtatOperation != "LIBRE" || Res.Chambres.EtatOperation != "RESERVER") { Res.Etat = "ACTIF"; Res.EtatOperation = "ARRIVEE"; Res.Chambres.EtatOperation = "OCCUPER"; Res.DateCheckIn = DateTime.Now; Res.isCheckIn = true; } else { MessageBox.Show("Cette chambre n'est pas disponible", "Message", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Cette chambre n'est pas disponible", "Message", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { BeginModifierReservation(null); //MessageBox.Show("Le Sejour de la chambre " + Res.Chambres.Numero + " n’a pas encore été soldé ", "Message", MessageBoxButton.OKCancel, MessageBoxImage.Warning); } } } catch (Exception) { } if (etat != "Modifier") { model.SaveChanges(); Msg = "OK"; MessageBox.Show("Operation terminée", "Message", MessageBoxButton.OK, MessageBoxImage.None); } this.Close(); }