1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| private void frmBooking_Load(object sender, EventArgs e)
{
//string pathBdd = Path.Combine(Application.StartupPath, "dbShelter.sdf"); //récupére le chemin du .sdf
string pathBdd = @"Data Source=|DataDirectory|\dbShelter.sdf;Password=;Persist Security Info=True";
try
{
clConnexionBdd.Init(pathBdd);
SqlCeCommand cmd = clConnexionBdd.PreparerCommande("SELECT DateBegin, DateEnd, ChoiceShelter FROM Booking");
SqlCeDataReader rdr = cmd.ExecuteReader();
Object[] row = null;
while (rdr.Read())
{
if (row == null)
{
object vDate1 = rdr.GetValue(0);
object vDate2 = rdr.GetValue(1);
object vShelter = rdr.GetValue(2);
if (Convert.ToString(vShelter) == "Gîte - La garderie -")
{
DateTime cur3;
List<DateTime> bold = new List<DateTime>();
DateTime myVacation1 = Convert.ToDateTime(vDate1);
DateTime myVacation2 = Convert.ToDateTime(vDate2);
cur3 = myVacation1;
while (cur3 <= myVacation2)
{
bold.Add(cur3);
cur3 = cur3.AddDays(1.0);
}
DateTime[] vacationDates = bold.ToArray();
mcBooking3.BoldedDates = vacationDates;
}
}
}
rdr.Close();
}
catch (Exception x)
{
MessageBox.Show(this, x.Message, "Erreur: Connexion à la base (frmBooking)", MessageBoxButtons.OK, MessageBoxIcon.Error);
Close();
}
} |
Partager