private void AfficherOccupation() { t_occuper = new DataTable(); t_occuper.Columns.Add(new DataColumn("ID", System.Type.GetType("System.Int32"))); t_occuper.Columns.Add(new DataColumn("Patient")); t_occuper.Columns.Add(new DataColumn("Chambre")); t_occuper.Columns.Add(new DataColumn("Entrée le")); t_occuper.Columns.Add(new DataColumn("Sortie le")); t_occuper.Columns.Add(new DataColumn("Coût journalier")); List <C_t_chambres> lTmp_Cha = new G_t_chambres(sConnexion).Lire("NomCha"); List <C_t_patients> lTmp_Pat = new G_t_patients(sConnexion).Lire("NomPat"); List <C_t_occuper> lTmp_Occ = new G_t_occuper(sConnexion).Lire("IDOcc"); foreach (C_t_occuper o in lTmp_Occ) { string Chambre = "", Patient = ""; foreach (C_t_chambres c in lTmp_Cha) { if (o.IDCha == c.IDCha) { Chambre = c.NomCha.ToString(); break; } } foreach (C_t_patients p in lTmp_Pat) { if (o.IDPat == p.IDPat) { Patient = p.NomPat + " " + p.PrenomPat; break; } } t_occuper.Rows.Add(o.IDOcc, Patient, Chambre, o.DateEntree.ToShortDateString(), o.DateSortie.ToString(), o.PrixJournalier.ToString()); } bs_occuper = new BindingSource(); bs_occuper.DataSource = t_occuper; dgvOccupation.DataSource = bs_occuper; }
public static void AfficherDispoCha(string NumCha, DataGridView dgv, int i) { if (NumCha == "") { MessageBox.Show("Veuillez saisir un numéro de chambre.", "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { int id = 0, nbr_lit = 0; DateTime Premier_J_Semaine = GestionDates.Date_Premier_J_Semaine(i); DataTable t_dispo_chambre = new DataTable(); t_dispo_chambre.Columns.Add(new DataColumn("Lundi\n" + Premier_J_Semaine.ToShortDateString())); t_dispo_chambre.Columns.Add( new DataColumn("Mardi\n" + Premier_J_Semaine.AddDays(1).ToShortDateString())); t_dispo_chambre.Columns.Add( new DataColumn("Mercredi\n" + Premier_J_Semaine.AddDays(2).ToShortDateString())); t_dispo_chambre.Columns.Add( new DataColumn("Jeudi\n" + Premier_J_Semaine.AddDays(3).ToShortDateString())); t_dispo_chambre.Columns.Add( new DataColumn("Vendredi\n" + Premier_J_Semaine.AddDays(4).ToShortDateString())); t_dispo_chambre.Columns.Add( new DataColumn("Samedi\n" + Premier_J_Semaine.AddDays(5).ToShortDateString())); t_dispo_chambre.Columns.Add( new DataColumn("Dimanche\n" + Premier_J_Semaine.AddDays(6).ToShortDateString())); List <C_t_chambres> lTmp_Cha = new G_t_chambres(TablesDeDonnees.SConnexion).Lire("IDCha"); foreach (C_t_chambres c in lTmp_Cha) { if (c.NomCha == int.Parse(NumCha)) { id = c.IDCha; nbr_lit = c.QuantiteLits; break; } } if (id != 0) { int[] Lit_occupe = new int[] { 0, 0, 0, 0, 0, 0, 0 }; List <C_t_occuper> lTmp_Occ = new G_t_occuper(TablesDeDonnees.SConnexion).Lire("IDOcc"); for (int j = 0; j < 7; j++) { DateTime Date_Comp = Premier_J_Semaine.AddDays(j); foreach (C_t_occuper o in lTmp_Occ) { if (o.IDCha == id && (Date_Comp.Date >= o.DateEntree.Date && Date_Comp.Date <= o.DateSortie.Value)) { Lit_occupe[j] += 1; } } } t_dispo_chambre.Rows.Add(nbr_lit - Lit_occupe[0], nbr_lit - Lit_occupe[1], nbr_lit - Lit_occupe[2], nbr_lit - Lit_occupe[3], nbr_lit - Lit_occupe[4], nbr_lit - Lit_occupe[5], nbr_lit - Lit_occupe[6]); BindingSource bs_dispo_chambre = new BindingSource(); bs_dispo_chambre.DataSource = t_dispo_chambre; dgv.DataSource = bs_dispo_chambre; // Bloque du tri sur les colonnes \\ dgv.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; dgv.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; dgv.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; dgv.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable; dgv.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable; dgv.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable; dgv.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable; // désactive le fait d'avoir la première cellule sélectionnée \\ dgv.FirstDisplayedCell.Selected = false; } else { MessageBox.Show("La chambre recherchée n'existe pas!", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }