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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
| protected void Page_Load(object sender, EventArgs e)
{
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
return;
// Met à jour l'affichage des jours : normal, férié, heure sup ...
//this.RefreshClass();
if (!IsPostBack)
{
#region AJOUT DES FUNCTION JS DE LA PAGE (ICI À CAUSE DE FIREFOX)
string script = @"
function updateValue(item)
{// Met à jour la textbox : si elle est vide, insert 1 et place le curseur en fin de textbox
// Si elle est déjà remplie, do nothing
if(item.value == null || item.value == '')
{
item.value = '1';
try
{
// Change le caret index de l'élément pour le placer à la fin
var range = item.createTextRange();
range.move('character', 2);
range.select();
}catch(ex)
{// Ne marche pas sous firefox
}
}
}
function updateTotalSousProjet(textbox, indexTotal, indexProjet, indexJour)
{// Met à jour le tableau lors du lost focus d'une textbox
var idTotal = prefixeTotal + indexTotal + sufixeTotal
var idTotalJourFooter = prefixeJourTotal + indexJour + sufixeJourTotal;
// Compatibilité IE-firefox
var IE = true;
var key = textbox.key;
if(key == null)
{// Firefox
// Firefox
for (n = 0 ; n < textbox.attributes.length; n ++)
{
if(textbox.attributes[n].nodeName == ""key"")
{
key = textbox.attributes[n].nodeValue;
break;
}
}
IE = false;
}
var newValue = parseFloat(textbox.value.replace("","", "".""));
if(isNaN(newValue)|| newValue <= 0 || newValue >3.5 )
{// Je demande à voir celui qui arrive à travailler 24.5h dans la meme journée
newValue = 0;
}
var oldValue = parseFloat(key.replace("","", "".""));
if(IE)
{ // Total ligne
document.getElementById(idTotal).innerText =(parseFloat(document.getElementById(idTotal).innerText.replace("","", ""."")) - oldValue + newValue).toFixed(2).toString().replace(""."","","").replace("",00"", """");
// Total footer (jour / jour ouvrable
document.getElementById(idTotalFooter).innerText =(parseFloat(document.getElementById(idTotalFooter).innerText.replace("","", ""."")) - oldValue + newValue).toFixed(2).toString().replace(""."","","").replace("",00"", """");
}
else
{ // Total ligne
document.getElementById(idTotal).innerHTML =(parseFloat(document.getElementById(idTotal).innerHTML.replace("","", ""."")) - oldValue + newValue).toFixed(2).toString().replace(""."","","").replace("",00"", """");
// Total footer (jour / jour ouvrable
document.getElementById(idTotalFooter).innerHTML =(parseFloat(document.getElementById(idTotalFooter).innerHTML.replace("","", ""."")) - oldValue + newValue).toFixed(2).toString().replace(""."","","").replace("",00"", """");
}
if(indexProjet != ""Non"")
{
// Mise à jour ligne projet
var idJourProjet = prefixeJour + indexProjet + prefixeJour2 + indexJour + sufixeJour;
var idTotal2 = prefixeTotal + indexProjet + sufixeTotal;
var oldValueJour = parseFloat(document.getElementById(idJourProjet).value.replace("","", ""."").replace("""",""0""));
var newValueJour = parseFloat((oldValueJour - oldValue + newValue).toFixed(2));
document.getElementById(idJourProjet).value = newValueJour.toString().replace(""."","","").replace("",00"", """").replace(""0,"", "","");
if(document.getElementById(idJourProjet).value == ""0"")
document.getElementById(idJourProjet).value = """";
if(IE)
{
// Mise à jour ligne projet total
var totaL = parseFloat(parseFloat(document.getElementById(idTotal2).innerText.replace("","", ""."").replace("""",""0"")) - oldValueJour + newValueJour).toFixed(2);
document.getElementById(idTotal2).innerText = totaL.toString().replace(""."","","").replace("",00"", """");
}else
{// Firefox
// Mise à jour ligne projet total
var totaL = parseFloat(parseFloat(document.getElementById(idTotal2).innerHTML.replace("","", ""."").replace("""",""0"")) - oldValueJour + newValueJour).toFixed(2);
document.getElementById(idTotal2).innerHTML = totaL.toString().replace(""."","","").replace("",00"", """");
}
// Un temps total > 1 => heure sup => à commenter
if(newValueJour > 1)
{
document.getElementById(idJourProjet).className = ""CraBad"";
}else
{
if(document.getElementById(idJourProjet).title != """")
{
if(document.getElementById(idJourProjet).value == 0)
document.getElementById(idJourProjet).className = ""Ferie"";
else
document.getElementById(idJourProjet).className = ""CraBad"";
}else
{
document.getElementById(idJourProjet).className = ""CraTemps"";
}
}
}
// Mise à jour total du jour (footer)
var textJourFooter = document.getElementById(idTotalJourFooter);
textJourFooter.value = parseFloat(parseFloat(textJourFooter.value.replace("","", ""."")) - oldValue + newValue).toFixed(2).toString().replace(""."","","").replace("",00"", """");
if(textJourFooter.title != """")
{
// Jour férié ou we
if (textJourFooter.value != ""0"")
{
textJourFooter.className = ""TempsTotalBad"";
textbox.className = ""CraBad"";
}
else
{
textJourFooter.className = ""Ferie"";
textbox.className = ""Ferie"";
}
}else
{// Jour normal
if(textJourFooter.value != ""1"")
{
if(parseFloat(textJourFooter.value.toString().replace("","",""."")) > 1)
{
textJourFooter.className = ""TempsTotalBad"";
textbox.className = ""CraBad"";
}
else
{
textJourFooter.className = ""TempsTotal"";
textbox.className = ""CraTemps"";
}
}
else
{
textJourFooter.className = ""TempsTotalOk"";
textbox.className = ""CraTemps"";
}
}
// Mise à jour de la textbox
if(IE)
{
textbox.key = newValue.toString();
}else
{
// Firefox
for (n = 0 ; n < textbox.attributes.length; n ++)
{
if(textbox.attributes[n].nodeName == ""key"")
{
textbox.attributes[n].nodeValue = newValue.toString();;
break;
}
}
}
textbox.value = newValue.toString().replace(""."","","").replace(""0,"","","");
if(textbox.value == ""0"")
textbox.value = """";
// Mise à jour du total général
var LabTotalGeneral = document.getElementById(""idTotalFooter"");
LabTotalGeneral.value = parseFloat(parseFloat(LabTotalGeneral.value.replace("","", ""."")) - oldValue + newValue).toFixed(2).toString().replace(""."","","").replace("",00"", """");
}";
ScriptManager.RegisterClientScriptBlock(this, typeof(tableauCRA), "Fonction", script, true);
#endregion AJOUT DES FUNCTION JS DE LA PAGE (ICI À CAUSE DE FIREFOX)
}
} |