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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WindowsApplication1
{
public partial class PlaceForm : Form
{
public CheckBox[] c = new CheckBox[721];
public ToolTip[] tooltip = new ToolTip[721];
public PlaceForm()
{
InitializeComponent();
RefreshPlace();
}
private void PlaceForm_Load(object sender, EventArgs e)
{
}
public void RefreshPlace()
{
String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=theatre.mdb";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
String queryString = "SELECT * FROM PlacePublic";
OleDbCommand command = new OleDbCommand(queryString, connection);
connection.Open();
OleDbDataReader reader = command.ExecuteReader();
int id_siege;
String rang;
String siege;
String Nom;
Boolean disponible;
Boolean Vip;
//ToolTip tooltip = new ToolTip();
while (reader.Read())
{
id_siege = (int)reader["ID_siege"];
rang = reader["rang"].ToString();
siege = reader["siege"].ToString();
Nom = reader["Nom"].ToString();
disponible = (Boolean)reader["Disponible"];
Vip = (Boolean)reader["VIP"];
foreach (Control cntrl in this.Controls.Find("CheckBox" + id_siege, true))
{
if (cntrl is CheckBox)
{
//Console.WriteLine(cntrl.Name +" "+ id_siege + " " + rang + " " + siege + " " + Nom);
//CheckBox c = new CheckBox();
//c = (CheckBox)cntrl;
c[id_siege] = (CheckBox)cntrl;
if (Nom.Equals(""))
c[id_siege].Checked = false;
else
c[id_siege].Checked = true;
tooltip[id_siege] = new ToolTip();
tooltip[id_siege].AutomaticDelay = 10;
tooltip[id_siege].AutoPopDelay = 10000;
if (Vip)
{
tooltip[id_siege].ToolTipTitle = "Place VIP" + rang + " " + siege;
tooltip[id_siege].BackColor = Color.AliceBlue;
}
else
tooltip[id_siege].ToolTipTitle = "Place " + rang + " " + siege;
if (Nom.Equals(""))
{
tooltip[id_siege].SetToolTip(c[id_siege], "Libre");
c[id_siege].BackColor = Color.Green;
}
else
{
c[id_siege].BackColor = Color.Red;
tooltip[id_siege].SetToolTip(c[id_siege], "Réservé par " + Nom + " ");
}
if (!disponible)
{
c[id_siege].Enabled = false;
c[id_siege].Visible = false;
}
}
}
}
reader.Close();
connection.Close();
reader.Dispose();
command.Dispose();
connection.Dispose();
}
}
private void RefreshButton_Click(object sender, EventArgs e)
{
this.RefreshPlace();
}
private void PlaceForm_FormClosed(object sender, FormClosedEventArgs e)
{
this.Dispose(true);
}
}
} |
Partager