| 12
 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
 
 | #region ICallbackEventHandler Membres
 
string ICallbackEventHandler.GetCallbackResult()
{
    string retour = string.Empty;
 
    switch (f.getVar(callBackArgs, "action"))
    {
        case "activite":
            retour = fillActivite(callBackArgs);
            break;
        default:
            retour = fillIndicateur(callBackArgs);
            break;
    }
 
 
    return retour;
}
 
private string fillIndicateur(string callBackArgs)
{
    string retour = string.Empty;
 
    int indicateur_id = Convert.ToInt32(f.getVar(callBackArgs, "indicateur_id"));
    int activite_id = Convert.ToInt32(f.getVar(callBackArgs, "activite_id"));
 
    DataTable tbl_details = PlanAction.GetDetails(Session["entite_id"].ToString(), Convert.ToInt32(Session["entite_type_id"]), activite_id);
 
    string param = "MM=" + f.getVar(callBackArgs, "MM") + "&CLIENT=" + f.getVar(callBackArgs, "CLIENT") + "&TYPE=" + f.getVar(callBackArgs, "TYPE");
 
    DataRow[] cur_rows = tbl_details.Select("INDICATEUR_ID = " + indicateur_id.ToString() + " AND INDICATEUR_PARAMETRES = '" + param + "'");
 
    foreach (DataRow cur_row in cur_rows)
    {
        string valIni;
        string valCible;
        string dateCible;
        string commentaire;
 
        if (cur_row["DETAIL_VAL_INI"] != DBNull.Value)
            valIni = Math.Round(Convert.ToDouble(cur_row["DETAIL_VAL_INI"]), 2).ToString();
        else
            valIni = string.Empty;
 
        if (cur_row["DETAIL_CIBLE"] != DBNull.Value)
            valCible = Math.Round(Convert.ToDouble(cur_row["DETAIL_CIBLE"]), 2).ToString();
        else
            valCible = string.Empty;
 
        if (cur_row["DETAIL_DATE_FIN"] != DBNull.Value)
        {
            DateTime dateCourante = Convert.ToDateTime(cur_row["DETAIL_DATE_FIN"]);
            dateCible = dateCourante.Month + "/" + dateCourante.Year;
        }
        else
            dateCible = string.Empty;
 
        if (cur_row["DETAIL_COMMENTAIRE"] != DBNull.Value)
            commentaire = cur_row["DETAIL_COMMENTAIRE"].ToString();
        else
            commentaire = string.Empty;
 
        retour = "$('" + txb_valIni.ClientID + "').value = '" + valIni + "';";
        retour += "$('" + txb_cible.ClientID + "').value = '" + valCible + "';";
        retour += "$('" + txb_dateCible.ClientID + "').value = '" + dateCible + "';";
        retour += "$('" + txb_commentaire.ClientID + "').value = '" + commentaire.Replace("'", "\\'") + "';";
    }
 
    if (retour == string.Empty)
    {
        retour = "$('" + txb_valIni.ClientID + "').value = '';";
        retour += "$('" + txb_cible.ClientID + "').value = '';";
        retour += "$('" + txb_dateCible.ClientID + "').value = '';";
        retour += "$('" + txb_commentaire.ClientID + "').value = '';";
    }
 
    return retour;
}
 
private string fillActivite(string callBackArgs)
{
    int activite_id = Convert.ToInt32(f.getVar(callBackArgs, "activite_id"));
 
    DataTable tbl_indicateurs = PlanAction.IndicateursList(PlanAction.FacID(activite_id));
 
    ddl_indicateur.Items.Clear();
 
    string retour = "var ddl = $('" + ddl_indicateur.ClientID + "');\n" +
                    "var test = 0;\n" +
                    "for (j = 0; ddl.options.length > 0; ++j)\n" +
                    "    ddl.options[0] = null;\n";
 
    int? selectedOption = null;
 
    foreach (DataRow cur_row in tbl_indicateurs.Rows)
    {
        retour += "o = new Option('" + cur_row["INDICATEUR_DESCRIPTION"].ToString().Replace("'", "\\'") + "', '" + cur_row["INDICATEUR_ID"].ToString() + "');\n" +
                  "ddl.options[ddl.options.length] = o;\n";
 
        ddl_indicateur.Items.Add(new ListItem(cur_row["INDICATEUR_DESCRIPTION"].ToString(), cur_row["INDICATEUR_ID"].ToString()));
 
        ClientScript.RegisterForEventValidation(ddl_indicateur.UniqueID, cur_row["INDICATEUR_ID"].ToString());
 
        if (selectedOption == null)
            selectedOption = Convert.ToInt32(cur_row["INDICATEUR_ID"]);
    }
 
    if (selectedOption != null)
    {
        string param = "MM=" + f.getVar(callBackArgs, "MM") + "&CLIENT=" + f.getVar(callBackArgs, "CLIENT") + "&TYPE=" + f.getVar(callBackArgs, "TYPE");
 
        retour += fillIndicateur("indicateur_id=" + selectedOption.ToString() + "&activite_id=" + activite_id.ToString() + "&" + param);
    }
    if (activite_id == PlanAction.ActiviteID("Véhicule Neuf") || activite_id == PlanAction.ActiviteID("Distribution"))
        retour += ";$('" + pan_options.ClientID + "').style.display = 'block';";
    else
        retour += ";$('" + pan_options.ClientID + "').style.display = 'none';" +
                  "$('" + ddl_marque.ClientID + "').selectedIndex = 0;" +
                  "$('" + ddl_type.ClientID + "').selectedIndex = 0;";
 
    return retour;
}
 
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
    callBackArgs = eventArgument;
}
 
#endregion | 
Partager