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
| private ArrayList buildArrayDays(currentsInfo datesInfo) //cree un arraylist avec toutes les demi journees du mois
{
ArrayList days = new ArrayList();
halfDay hDay;
for (int count = 0; count < datesInfo.monthLen; count++)
{
hDay = new halfDay();
hDay.dayNb = count + 1;
hDay.dayType = (datesInfo.firstDayType + hDay.dayNb) % 7;
hDay.period = halfDay.Period.am;
days.Add(hDay);
hDay = new halfDay(hDay);
hDay.period = halfDay.Period.pm;
days.Add(hDay);
}
return (days);
}
protected void loadForm() //construit le tableau du formulaire a partir des objets de demi journees
{
currentsInfo datesInfo = new currentsInfo();
ArrayList days = buildArrayDays(datesInfo);
int listLen = days.Count;
TableRow line;
TableCell cell;
DropDownList ddl;
CheckBox ChB;
HtmlButton btn;
TBLForm.BorderWidth = 2;
TBLForm.CellSpacing = 0;
for (int count = 0; count < listLen; count++) //ajoute chaque lignes
{
line = new TableRow();
/**/
line.ID = "ligne" + count;
if (!(((halfDay)days[count]).isWorked()))//set les couleurs de fond des lignes selon types de jours
line.BackColor = System.Drawing.Color.Gray;
else if ((count % 2) != 1)
line.BackColor = System.Drawing.Color.Yellow;
else
line.BackColor = System.Drawing.Color.YellowGreen;
cell = new TableCell(); // ajoute le numero du jour
cell.Controls.Add(new LiteralControl(((halfDay)days[count]).dayNb.ToString()));
line.Cells.Add(cell);
cell = new TableCell();// ajoute am/pm
cell.Controls.Add(new LiteralControl(((halfDay)days[count]).getPeriod()));
line.Cells.Add(cell);
cell = new TableCell();// ajoute lla check-box
ChB = new CheckBox();
if ((((halfDay)days[count]).isWorked()))
ChB.Checked = true; // les jours ouvres sont coches par defaut (voir specs)
cell.Controls.Add(ChB);
line.Cells.Add(cell);
cell = new TableCell();// ajoute la drop down list des clients
ddl = new DropDownList();
cell.Controls.Add(ddl);
line.Cells.Add(cell);
cell = new TableCell();// ajoute la drop down list des projets
ddl = new DropDownList();
cell.Controls.Add(ddl);
line.Cells.Add(cell);
cell = new TableCell();// ajoute l'input de saisie libre
cell.Width = 150;
cell.Controls.Add(new HtmlInputText());
line.Cells.Add(cell);
TBLForm.Rows.Add(line);
}
/* line = new TableRow();//ajout d'une ligne avec le bouton de validation des modifications
cell = new TableCell();
cell.ColumnSpan = 6;
btn = new HtmlButton();
btn.InnerText = "Valider les modifications";
cell.Controls.Add(btn);
line.Cells.Add(cell);
TBLForm.Rows.Add(line);*/
}
public void btnSave_clic(object sender, EventArgs e)
{
// toto.Text = TBLForm.Rows[0].Cells[0].Controls[0].GetType().ToString();
// toto.Text = TBLForm.Controls.Count.ToString();
toto.Text = TBLForm.Attributes.Count.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) // si premier affichage de la page, il faut builder le formulaire
{
loadForm();
toto.Text = TBLForm.Controls.Count.ToString();
}
}
} |
Partager