public List <Facteur> ListeFacteurs() { using (DataClasses1DataContext entity = new DataClasses1DataContext()) { var retour = entity.T_FACTEUR.ToList(); List <Facteur> ListFacteur = new List <Facteur>(); foreach (var Element in retour) { var retourTypeFacteur = entity.T_TYPEFACTEUR.FirstOrDefault(elt => elt.ID == Element.IDTypeFacteur); TypeFacteur typeFacteur = new TypeFacteur() { ID = retourTypeFacteur.ID, Type = retourTypeFacteur.Type }; var retourTypeReponse = entity.T_TYPEREPONSE.FirstOrDefault(elt => elt.ID == Element.IDTypeResponse); TypeReponse typeReponse = new TypeReponse() { ID = retourTypeReponse.ID, Type = retourTypeReponse.TypeReponse, Information = retourTypeReponse.Information }; Facteur facteur = new Facteur() { ID = Element.ID, Nom = Element.Nom, Question = Element.Question, Reponse = (int)Element.Reponse, TypeDeFacteur = typeFacteur, TypeDeReponse = typeReponse }; ListFacteur.Add(facteur); } return(ListFacteur); } }
public Facteur VoirFacteur(int IdFacteur) { using (DataClasses1DataContext entity = new DataClasses1DataContext()) { var retour = entity.T_FACTEUR.Where(elt => elt.ID == IdFacteur).FirstOrDefault(); var retourTypeFacteur = entity.T_TYPEFACTEUR.FirstOrDefault(elt => elt.ID == retour.IDTypeFacteur); TypeFacteur typeFacteur = new TypeFacteur() { ID = retourTypeFacteur.ID, Type = retourTypeFacteur.Type }; var retourTypeReponse = entity.T_TYPEREPONSE.FirstOrDefault(elt => elt.ID == retour.IDTypeResponse); TypeReponse typeReponse = new TypeReponse() { ID = retourTypeReponse.ID, Type = retourTypeReponse.TypeReponse, Information = retourTypeReponse.Information }; Facteur facteur = new Facteur() { ID = retour.ID, Nom = retour.Nom, Question = retour.Question, Reponse = (int)retour.Reponse, TypeDeFacteur = typeFacteur, TypeDeReponse = typeReponse }; return(facteur); } }
private void mapFromDataReaderToObject(IDataReader reader, TypeReponse mClass) { if (reader != null) { if (!Convert.IsDBNull(reader["ID"])) { mClass.ID = (short)reader["ID"]; } if (!Convert.IsDBNull(reader["Libelle"])) { mClass.Libelle = reader["Libelle"].ToString(); } if (!Convert.IsDBNull(reader["CreationDate"])) { mClass.CreationDate = DateTime.Parse(reader["CreationDate"].ToString()); } if (!Convert.IsDBNull(reader["CreationUtilisateur"])) { mClass.CreationUtilisateur = reader["CreationUtilisateur"].ToString(); } if (!Convert.IsDBNull(reader["ModificationUtilisateur"])) { mClass.ModificationUtilisateur = reader["ModificationUtilisateur"].ToString(); } if (!Convert.IsDBNull(reader["ModificationDate"])) { mClass.ModificationDate = DateTime.Parse(reader["ModificationDate"].ToString()); } if (!Convert.IsDBNull(reader["Rowversion"])) { mClass.RowVersion = (byte[])reader["RowVersion"]; } if (!Convert.IsDBNull(reader["Statut"])) { mClass.EstDesactive = (bool)reader["Statut"]; } } }
protected void ComputeTypeReponseColumn() { Trace.Warn("ComputeAlignementColumn"); if (GridView1.Rows.Count > 0) { int indexRow = GridView1.Rows.Count - 1; Guid reponseGuid = new Guid(GridView1.DataKeys[indexRow].Value.ToString()); PollAnswer reponse = Reponses.FindByPollAnswerID(reponseGuid); DropDownListGridView ddlQ = ( DropDownListGridView )GridView1.Rows[indexRow].FindControl("DropDownListTypeReponse"); ddlQ.DataSource = TypeReponse.List(); ddlQ.DataBind(); ddlQ.Valeur = indexRow.ToString(); ddlQ.SelectedValue = reponse.TypeReponse; } }
public List <Facteur> ListeFacteurMigraine(int IDmigraine) { using (DataClasses1DataContext entity = new DataClasses1DataContext()) { var retour = entity.T_FACTEUR .Join(entity.T_FACTEURS_MIGRAINE, F => F.ID, FM => FM.IDFacteur, (F, FM) => new { ID = F.ID, IDTypeFacteur = F.IDTypeFacteur, IDTypeResponse = F.IDTypeResponse, Nom = F.Nom, IDMigraine = FM.IDMigraine, Question = F.Question, Reponse = FM.Reponse }) .Join(entity.T_MIGRAINE, FFM => FFM.IDMigraine, M => M.ID, (FFM, M) => new { IDMigraine = FFM.IDMigraine, ID = FFM.ID, IDTypeFacteur = FFM.IDTypeFacteur, IDTypeResponse = FFM.IDTypeResponse, Nom = FFM.Nom, Question = FFM.Question, Reponse = FFM.Reponse }).Where(elt => elt.IDMigraine == IDmigraine) .ToList(); //var retour1 = entity.T_FACTEURS_MIGRAINE. // Join(entity.T_FACTEUR, FM => FM.IDFacteur, F => F.ID, (FM,F) => new { } List <Facteur> ListFacteur = new List <Facteur>(); foreach (var Element in retour) { var retourTypeFacteur = entity.T_TYPEFACTEUR.FirstOrDefault(elt => elt.ID == Element.IDTypeFacteur); TypeFacteur typeFacteur = new TypeFacteur() { ID = retourTypeFacteur.ID, Type = retourTypeFacteur.Type }; var retourTypeReponse = entity.T_TYPEREPONSE.FirstOrDefault(elt => elt.ID == Element.IDTypeResponse); TypeReponse typeReponse = new TypeReponse() { ID = retourTypeReponse.ID, Type = retourTypeReponse.TypeReponse, Information = retourTypeReponse.Information }; Facteur facteur = new Facteur() { ID = Element.ID, Nom = Element.Nom, Question = Element.Question, Reponse = (int)Element.Reponse, TypeDeFacteur = typeFacteur, TypeDeReponse = typeReponse }; ListFacteur.Add(facteur); } return(ListFacteur); } }
public IEnumerable <Persist> fnSelect(short status) { List <TypeReponse> mListe = new List <TypeReponse>(); db.definirProcedureStockee("TypeReponse_Lister"); db.ajouterParametreEntree("@Status", 8, SqlDbType.SmallInt, status); IDataReader reader = db.executeReader(); while (reader.Read()) { TypeReponse mClass = new TypeReponse(); mapFromDataReaderToObject(reader, mClass); mListe.Add(mClass); } reader.Close(); return(mListe); }
public List <Facteur> ListeFacteurPatient(int IDPatient) { using (DataClasses1DataContext entity = new DataClasses1DataContext()) { var retour = entity.T_FACTEUR.Join(entity.T_FACTEURS, F => F.ID, FS => FS.IDFacteur, (F, FS) => new { ID = F.ID, IDPatient = FS.IDPatient, IDTypeFacteur = F.IDTypeFacteur, IDTypeResponse = F.IDTypeResponse, Nom = F.Nom, Question = F.Question, Reponse = F.Reponse }).Where(elt => elt.IDPatient == IDPatient).ToList(); List <Facteur> ListFacteur = new List <Facteur>(); foreach (var Element in retour) { var retourTypeFacteur = entity.T_TYPEFACTEUR.FirstOrDefault(elt => elt.ID == Element.IDTypeFacteur); TypeFacteur typeFacteur = new TypeFacteur() { ID = retourTypeFacteur.ID, Type = retourTypeFacteur.Type }; var retourTypeReponse = entity.T_TYPEREPONSE.FirstOrDefault(elt => elt.ID == Element.IDTypeResponse); TypeReponse typeReponse = new TypeReponse() { ID = retourTypeReponse.ID, Type = retourTypeReponse.TypeReponse, Information = retourTypeReponse.Information }; Facteur facteur = new Facteur() { ID = Element.ID, Nom = Element.Nom, Question = Element.Question, Reponse = (int)Element.Reponse, TypeDeFacteur = typeFacteur, TypeDeReponse = typeReponse }; ListFacteur.Add(facteur); } return(ListFacteur); } }
private void BuildDataList() { DataListQuestion.DataSource = SessionState.QuestionsEnCours; DataListQuestion.DataBind(); // Trouver les Reponses et les Votes foreach (DataListItem dli in DataListQuestion.Items) { DataList dl = new DataList(); dl = ( DataList )dli.FindControl("DataListReponse"); HiddenField hf = new HiddenField(); hf = ( HiddenField )dli.FindControl("PollQuestionId"); Guid pollQuestionId = new Guid(hf.Value); PollAnswerCollection answers = PollAnswerCollection.GetByPollQuestionID(pollQuestionId); dl.DataSource = answers; dl.DataBind(); // Rechercher dans les Votes deja effectues if (answers.Count > 0 && SessionState.Votes != null) { int indexReponse = 0; // Trouver le bon LabelVote dans DataListReponse foreach (PollAnswer answer in answers) { PollVoteCollection pvc = SessionState.Votes.FindByAnswerID(answer.PollAnswerId); if (pvc.Count >= 1) // surement un seul mais bon ... { Label lbl = ( Label )dl.Controls[indexReponse].FindControl("LabelVote"); lbl.Text = "X"; lbl.CssClass = "LabelQuestionEnCoursVoteDejaFaitStyle"; if (TypeReponse.EstTextuelle(answer.TypeReponse)) { Label lblVoteTexte = ( Label )dl.Controls[indexReponse].FindControl("LabelVoteTexte"); lblVoteTexte.Text = pvc[0].Vote; } } indexReponse += 1; } } // Rechercher dans les Votes en Cours if (answers.Count > 0 && SessionState.VotesEnCours != null) { int indexReponse = 0; // Trouver le bon LabelVote dans DataListReponse foreach (PollAnswer answer in answers) { PollVoteCollection pvc = SessionState.VotesEnCours.FindByAnswerID(answer.PollAnswerId); if (pvc.Count >= 1) // surement un seul mais ... { Label lbl = ( Label )dl.Controls[indexReponse].FindControl("LabelVote"); lbl.Text = "X"; if (TypeReponse.EstTextuelle(answer.TypeReponse)) { Label lblVoteTexte = ( Label )dl.Controls[indexReponse].FindControl("LabelVoteTexte"); lblVoteTexte.Text = pvc[0].Vote; } } indexReponse += 1; } } } }
private void BuildDataList() { Reporter.Trace("BuildDataList"); // AME19102010 Mode Pagination - Il y a t-il plusieurs pages ? if (modePage()) { // AME19102010 - Mettre ou remettre les boutons des pager en fonction de CurrentPage if (CurrentPage == 0) // premiere page { ButtonPagePrecedenteHaut.Visible = false; ButtonPagePrecedenteBas.Visible = false; ButtonPageSuivanteHaut.Visible = true; ButtonPageSuivanteBas.Visible = true; } if (CurrentPage > 0) { ButtonPagePrecedenteHaut.Visible = true; ButtonPagePrecedenteBas.Visible = true; ButtonPageSuivanteHaut.Visible = true; ButtonPageSuivanteBas.Visible = true; } if (nombrePage() > 0 && CurrentPage + 1 >= nombrePage()) // derniere page { CurrentPage = nombrePage() - 1; // si on a change la pagination CurrentPage ne peut pas depasser nombrePage() - 1 ButtonPagePrecedenteHaut.Visible = true; ButtonPagePrecedenteBas.Visible = true; ButtonPageSuivanteHaut.Visible = false; ButtonPageSuivanteBas.Visible = false; } PagedDataSource pagedDataSource = new PagedDataSource(); pagedDataSource.AllowPaging = true; pagedDataSource.DataSource = SessionState.Questions; pagedDataSource.PageSize = int.Parse(SessionState.MemberSettings.TaillePageQuestions); pagedDataSource.CurrentPageIndex = CurrentPage; LabelPageCouranteHaut.Text = (CurrentPage + 1).ToString() + "/" + nombrePage().ToString(); LabelPageCouranteBas.Text = LabelPageCouranteHaut.Text; LabelPageCouranteHaut.ToolTip = "Page courante/Nombre de pages - taille d'une page : " + SessionState.MemberSettings.TaillePageQuestions; LabelPageCouranteBas.ToolTip = LabelPageCouranteHaut.ToolTip; PanelPagerHaut.Visible = true; PanelPagerBas.Visible = true; DataListQuestion.DataSource = pagedDataSource; } else { PanelPagerHaut.Visible = false; PanelPagerBas.Visible = false; DataListQuestion.DataSource = SessionState.Questions; } DataListQuestion.DataBind(); // Trouver toutes les reponses foreach (DataListItem dli in DataListQuestion.Items) { DataList dl = new DataList(); dl = ( DataList )dli.FindControl("DataListReponse"); HiddenField hf = new HiddenField(); hf = ( HiddenField )dli.FindControl("PollQuestionId"); Guid pollQuestionId = new Guid(hf.Value); PollAnswerCollection answers = PollAnswerCollection.GetByPollQuestionID(pollQuestionId); dl.DataSource = answers; dl.DataBind(); DropDownList ddlTypReponse = ( DropDownList )dli.FindControl("DropDownListTypeReponse"); ddlTypReponse.DataSource = TypeReponse.List(); ddlTypReponse.DataBind(); ddlTypReponse.Items.Insert(0, new ListItem("Type de Réponse", "-1")); // Par defaut on propose toujours le type de reponse "Choix" ddlTypReponse.SelectedValue = TypeReponse.Choix; } }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { Trace.Warn("GridView1_RowUpdating"); // Recuperer la Reponse cliquee Guid answerGuid = new Guid(GridView1.DataKeys[e.RowIndex].Value.ToString()); PollAnswer reponse = Reponses.FindByPollAnswerID(answerGuid); e.NewValues["TypeReponse"] = reponse.TypeReponse; // BUG20100407 // Faire comme dans ButtonReponseTextuelleOk_Click if (e.NewValues["Answer"] == null && TypeReponse.EstTextuelle(( string )e.NewValues["TypeReponse"])) { e.NewValues["Answer"] = " "; // reponse textuelle vide } // Si elle est encore nulle c'est qu'elle n'est pas textuelle alors on met une chaine "Réponse ?" if (e.NewValues["Answer"] == null) { e.NewValues["Answer"] = "Réponse ?"; } //if ( string.IsNullOrEmpty( e.NewValues[ "Answer" ].ToString() ) ) //{ // e.NewValues[ "Answer" ] = "Réponse ?"; //} if (TypeReponse.EstTextuelle((string)e.NewValues["TypeReponse"])) { if (e.NewValues["Width"] != null) { try { int i = int.Parse(e.NewValues["Width"].ToString()); if (i < int.Parse(Global.SettingsXml.ReponseTextuelleLargeurMin)) { e.NewValues["Width"] = Global.SettingsXml.ReponseTextuelleLargeurMin; } if (i > int.Parse(Global.SettingsXml.ReponseTextuelleLargeurMax)) { e.NewValues["Width"] = Global.SettingsXml.ReponseTextuelleLargeurMax; } } catch { ValidationMessage.Text += "Largeur est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.NewValues["Width"] = null; } } if (e.NewValues["Rows"] != null) { try { int i = int.Parse(e.NewValues["Rows"].ToString()); if (i > int.Parse(Global.SettingsXml.ReponseTextuelleLigneMax)) { e.NewValues["Rows"] = Global.SettingsXml.ReponseTextuelleLigneMax; } } catch { ValidationMessage.Text += "Lignes est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.NewValues["Rows"] = null; } } } else // Ce n'est pas une reponse textuelle { e.NewValues["Rows"] = null; e.NewValues["Width"] = null; e.NewValues["Obligatoire"] = null; } if (e.NewValues["Rank"] == null) { e.NewValues["Rank"] = 10; } else { try { int i = int.Parse(e.NewValues["Rank"].ToString()); } catch { ValidationMessage.Text += "Rang est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.NewValues["Rank"] = 10; } } if (e.NewValues["Score"] != null) { try { int i = int.Parse(e.NewValues["Score"].ToString()); if (i <= 0) { ValidationMessage.Text += "Score est un entier positif<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.NewValues["Score"] = null; } } catch { ValidationMessage.Text += "Score est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.NewValues["Score"] = null; } } }
protected void DetailsView1_ItemInserting(object sender, System.Web.UI.WebControls.DetailsViewInsertEventArgs e) { Trace.Warn("DetailsView1_ItemInserting"); if (e.Values["PollQuestionId"] == null) { e.Values["PollQuestionId"] = PollQuestionGUID; } if (e.Values["PollAnswerId"] == null) { e.Values["PollAnswerId"] = Guid.NewGuid(); } // Recuperer la valeur de DropDownListTypeReponse DropDownList ddlTypeReponse = ( DropDownList )DetailsView1.Rows[columnDropDownListTypeReponse].FindControl("DropDownListTypeReponse"); string valeur = ddlTypeReponse.SelectedItem.Text; e.Values["TypeReponse"] = valeur; if (TypeReponse.EstTextuelle((string)e.Values["TypeReponse"]) == false) { if (e.Values["Width"] != null) { e.Values["Width"] = null; ValidationMessage.Text += "La largeur ne concerne que les Réponses textuelles<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } if (e.Values["Rows"] != null) { e.Values["Rows"] = null; ValidationMessage.Text += "Le nombre de lignes ne concerne que les Réponses textuelles<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } if (( bool )e.Values["Obligatoire"] == true) { e.Values["Obligatoire"] = null; ValidationMessage.Text += "Obligatoire ici ne concerne que les Réponses textuelles<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } } else { if (e.Values["Width"] != null) { try { int i = int.Parse(e.Values["Width"].ToString()); if (i < int.Parse(Global.SettingsXml.ReponseTextuelleLargeurMin)) { e.Values["Width"] = Global.SettingsXml.ReponseTextuelleLargeurMin; } if (i > int.Parse(Global.SettingsXml.ReponseTextuelleLargeurMax)) { e.Values["Width"] = Global.SettingsXml.ReponseTextuelleLargeurMax; } } catch { e.Values["Width"] = null; ValidationMessage.Text += "Largeur est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } } if (e.Values["Rows"] != null) { try { int i = int.Parse(e.Values["Rows"].ToString()); if (i > int.Parse(Global.SettingsXml.ReponseTextuelleLigneMax)) { e.Values["Rows"] = Global.SettingsXml.ReponseTextuelleLigneMax; } } catch { e.Values["Rows"] = null; ValidationMessage.Text += "Lignes est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; } } } // BUG20100407 // Faire comme dans ButtonReponseTextuelleOk_Click if (e.Values["Answer"] == null && TypeReponse.EstTextuelle(( string )e.Values["TypeReponse"])) { e.Values["Answer"] = " "; // reponse textuelle vide } // Si elle est encore nulle c'est qu'elle n'est pas textuelle alors on met une chaine "Réponse ?" if (e.Values["Answer"] == null) { e.Values["Answer"] = "Réponse ?"; } //if ( string.IsNullOrEmpty( e.Values[ "Answer" ].ToString() ) ) //{ // e.Values[ "Answer" ] = "Réponse ?"; //} if (e.Values["Rank"] == null) { e.Values["Rank"] = ReponseRankMax + 1; } else { try { int i = int.Parse(e.Values["Rank"].ToString()); } catch { ValidationMessage.Text += "Rang est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.Values["Rank"] = ReponseRankMax + 1; } } if (e.Values["Score"] != null) { try { int i = int.Parse(e.Values["Score"].ToString()); if (i <= 0) { ValidationMessage.Text += "Score est un entier positif<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.Values["Rank"] = null; } } catch { ValidationMessage.Text += "Score est un entier<br/>"; ValidationMessage.Visible = true; ValidationMessage.CssClass = "LabelValidationMessageErrorStyle"; e.Values["Rank"] = null; } } if (e.Values["Obligatoire"] != null) { if (( bool )e.Values["Obligatoire"] == false) { e.Values["Obligatoire"] = null; // effacer } } }
private Table CreateReponseTable(Guid pollQuestionID) { PollAnswerCollection answers = SessionState.Reponses.FindByPollQuestionID(pollQuestionID); Table table = new Table(); TableRow row = new TableRow(); TableCell cell = new TableCell(); TableCell cellPix = new TableCell(); cellPix.CssClass = "TableReponseCellPix"; row.Cells.Add(cellPix); cell.Text = "Réponse"; cell.CssClass = "TdHeaderReponseTableStyle"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Vote"; cell.CssClass = "TdHeaderReponseTableStyle"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "%"; cell.CssClass = "TdHeaderReponseTableStyle"; row.Cells.Add(cell); PollVoteCollection pvc = new PollVoteCollection(); TableCell cellDateVote = new TableCell(); if (SelectedPersonneGUID != Guid.Empty) { pvc = SessionState.Votes.FindByPersonneGUID(SelectedPersonneGUID); //cell = new TableCell(); //cell.Text = "A voté"; //cell.CssClass = "TdHeaderReponseTableStyle"; //row.Cells.Add( cell ); //if ( AfficherLaDateDesVotes ) //{ // cellDateVote.Text = "Date"; // cellDateVote.CssClass = "TdHeaderReponseTableStyle"; // row.Cells.Add( cellDateVote ); //} } table.Rows.Add(row); int totalVotant = 0; foreach (Personne p in PersonneVotants) { if (SessionState.Votes.FindIfPersonneHasVoted(pollQuestionID, p.PersonneGUID)) { totalVotant += 1; } } int totalVotes = 0; foreach (PollAnswer answer in answers) { int votes = SessionState.Votes.FindNumberOfVotesByAnswer(answer.PollAnswerId); totalVotes = SessionState.Votes.FindCountTotalVotes(answer.PollQuestionId); decimal percentage = ComputePercentage(votes, totalVotes); row = new TableRow(); cell = new TableCell(); cellPix = new TableCell(); cellPix.CssClass = "TableReponseCellPix"; row.Cells.Add(cellPix); HyperLink hyp = new HyperLink(); hyp.NavigateUrl = "~/Questionnaire/Publication.aspx?PollAnswerID=" + answer.PollAnswerId; hyp.Text = answer.Rank + " - " + answer.Answer; hyp.ToolTip = "Qui a répondu"; hyp.CssClass = "HyperLinkReponseStatAllStyle"; if (TypeReponse.EstTextuelle(answer.TypeReponse)) { hyp.CssClass = "HyperLinkReponseTextuelleStatAllStyle"; } cell.Controls.Add(hyp); if (TypeReponse.EstTextuelle(answer.TypeReponse) && SelectedPersonneGUID != Guid.Empty && AfficherReponseTextuelle) { Label lbl = new Label(); foreach (PollVote pv in pvc) { if (pv.UserGUID == SelectedPersonneGUID && answer.PollAnswerId == pv.PollAnswerId) { lbl.Text = " " + pv.Vote; break; } } cell.Controls.Add(lbl); } cell.CssClass = "CellLinkReponseStatAllStyle"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = votes.ToString(); cell.CssClass = "TdStatTableStyle"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = percentage.ToString(); cell.CssClass = "TdStatTableStyle"; row.Cells.Add(cell); //if ( SelectedPersonneGUID != Guid.Empty ) //{ // cell = new TableCell(); // if ( AfficherLaDateDesVotes ) // { // cellDateVote = new TableCell(); // } // // A t-il vote pour cette reponse ? // cell.Text = " "; // cellDateVote.Text = " "; // foreach ( PollVote pv in pvc ) // { // if ( pv.UserGUID == SelectedPersonneGUID && answer.PollAnswerId == pv.PollAnswerId ) // { // cell.Text = "X"; // if ( AfficherLaDateDesVotes ) // { // cellDateVote.Text = pv.CreationDate.ToString(); // } // break; // } // } // cell.CssClass = "TdVoteTableStyle"; // row.Cells.Add( cell ); // if ( AfficherLaDateDesVotes ) // { // cellDateVote.CssClass = "TdStatTableDateStyle"; // row.Cells.Add( cellDateVote ); // } //} cell = new TableCell(); System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image(); img.ImageUrl = "~/Images/pixel.png"; img.Height = new Unit(7); img.Width = new Unit(percentage.ToString()); cell.Controls.Add(img); row.Cells.Add(cell); table.Rows.Add(row); } row = new TableRow(); cell = new TableCell(); cell.Text = "Votants : " + totalVotant.ToString(); cell.CssClass = "TdTotalVoteTableStyle"; cell.ColumnSpan = 2; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Votes : " + totalVotes.ToString(); cell.CssClass = "TdTotalVoteTableStyle"; cell.ColumnSpan = 3; row.Cells.Add(cell); table.Rows.Add(row); return(table); }
private Table CreateReponseTable(Guid pollQuestionID) { PollAnswerCollection answers = SessionState.Reponses.FindByPollQuestionID(pollQuestionID); Table table = new Table(); TableRow row = new TableRow(); TableCell cell = new TableCell(); TableCell cellPix = new TableCell(); cellPix.CssClass = "TableReponseCellPix"; row.Cells.Add(cellPix); cell.Text = "Réponse"; cell.CssClass = "TdHeaderReponseTableLeftStyle"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Vote"; cell.CssClass = "TdHeaderReponseTableCenterStyle"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "%"; cell.CssClass = "TdHeaderReponseTableCenterStyle"; row.Cells.Add(cell); Label moyenne = new Label(); Style style = new Style(); if (AfficherLaMoyennePonderee) { cell = new TableCell(); cell.Text = "Poid"; cell.CssClass = "TdHeaderReponseTableCenterStyle"; row.Cells.Add(cell); cell = new TableCell(); style.Font.Overline = true; moyenne.ApplyStyle(style); moyenne.Text = "x"; cell.Controls.Add(moyenne); cell.CssClass = "TdHeaderReponseTableCenterStyle"; row.Cells.Add(cell); } PollVoteCollection pvc = new PollVoteCollection(); TableCell cellDateVote = new TableCell(); if (SelectedPersonneGUID != Guid.Empty) { pvc = SessionState.Votes.FindByPersonneGUID(SelectedPersonneGUID); cell = new TableCell(); cell.Text = "A voté"; cell.CssClass = "TdHeaderReponseTableCenterStyle"; row.Cells.Add(cell); if (AfficherLaDateDesVotes) { cellDateVote.Text = "Date"; cellDateVote.CssClass = "TdHeaderReponseTableCenterStyle"; row.Cells.Add(cellDateVote); } } table.Rows.Add(row); int totalVotant = 0; foreach (Personne p in PersonneVotants) { if (SessionState.Votes.FindIfPersonneHasVoted(pollQuestionID, p.PersonneGUID)) { totalVotant += 1; } } double sommePoid = 0; foreach (PollAnswer answer in answers) { sommePoid += answer.Score; } sommePoid = sommePoid == 0 ? 1.0 : sommePoid; // ne pas laisser 0 int totalVotes = 0; double sommePoids = 0.0; foreach (PollAnswer answer in answers) { int votes = SessionState.Votes.FindNumberOfVotesByAnswer(answer.PollAnswerId); totalVotes = SessionState.Votes.FindCountTotalVotes(answer.PollQuestionId); decimal percentage = ComputePercentage(votes, totalVotes); // On ne Score que les Reponses choix double poid = 0.0; if (answer.TypeReponse == TypeReponse.Choix) { poid = votes * (answer.Score == 0 ? 1.0 : answer.Score) / sommePoid; sommePoids += poid; } row = new TableRow(); cell = new TableCell(); cellPix = new TableCell(); cellPix.CssClass = "TableReponseCellPix"; row.Cells.Add(cellPix); if (ModePrint) { Label lbl = new Label(); lbl.Text = answer.Rank + " - " + answer.Answer; if (TypeReponse.EstTextuelle(answer.TypeReponse)) { lbl.CssClass = "HyperLinkReponseTextuelleStatAllStyle"; } cell.Controls.Add(lbl); } else if (ModeExcel) { Label lbl = new Label(); lbl.Text = "r : " + answer.Rank + " - " + answer.Answer; // ajout d'un petit "r:" pour que ce con d'excel ne prenne pas ca pour une date !!! if (TypeReponse.EstTextuelle(answer.TypeReponse)) { lbl.CssClass = "HyperLinkReponseTextuelleStatAllStyle"; } cell.Controls.Add(lbl); } else { HyperLink hyp = new HyperLink(); hyp.NavigateUrl = "~/Poll/QuestionnaireStatAll.aspx?PollAnswerID=" + answer.PollAnswerId; hyp.Text = answer.Rank + " - " + answer.Answer; hyp.ToolTip = "Qui a répondu"; hyp.CssClass = "HyperLinkReponseStatAllStyle"; if (TypeReponse.EstTextuelle(answer.TypeReponse)) { hyp.CssClass = "HyperLinkReponseTextuelleStatAllStyle"; } cell.Controls.Add(hyp); } if (TypeReponse.EstTextuelle(answer.TypeReponse) && SelectedPersonneGUID != Guid.Empty && AfficherReponseTextuelle) { Label lbl = new Label(); foreach (PollVote pv in pvc) { if (pv.UserGUID == SelectedPersonneGUID && answer.PollAnswerId == pv.PollAnswerId) { lbl.Text = " " + pv.Vote; break; } } cell.Controls.Add(lbl); } cell.CssClass = "CellLinkReponseStatAllStyle"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = votes.ToString(); cell.CssClass = "TdStatTableStyle"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = percentage.ToString(); cell.CssClass = "TdStatTableStyle"; row.Cells.Add(cell); if (AfficherLaMoyennePonderee) { cell = new TableCell(); cell.Text = ""; if (answer.TypeReponse == TypeReponse.Choix) { cell.Text = answer.Score.ToString(); } cell.CssClass = "TdStatTableStyle"; row.Cells.Add(cell); cell = new TableCell(); cell.Text = ""; if (answer.TypeReponse == TypeReponse.Choix) { cell.Text = poid.ToString("##0.###"); } cell.CssClass = "TdStatTableStyle"; row.Cells.Add(cell); } if (SelectedPersonneGUID != Guid.Empty) { cell = new TableCell(); if (AfficherLaDateDesVotes) { cellDateVote = new TableCell(); } // A t-il vote pour cette reponse ? cell.Text = " "; cellDateVote.Text = " "; foreach (PollVote pv in pvc) { if (pv.UserGUID == SelectedPersonneGUID && answer.PollAnswerId == pv.PollAnswerId) { cell.Text = "X"; if (AfficherLaDateDesVotes) { cellDateVote.Text = pv.CreationDate.ToString(); } break; } } cell.CssClass = "TdVoteTableStyle"; row.Cells.Add(cell); if (AfficherLaDateDesVotes) { cellDateVote.CssClass = "TdStatTableDateStyle"; row.Cells.Add(cellDateVote); } } if (ModeExcel == false) { cell = new TableCell(); System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image(); img.ImageUrl = "~/Images/pixel.png"; img.Height = new Unit(7); img.Width = new Unit(percentage.ToString()); cell.Controls.Add(img); row.Cells.Add(cell); } table.Rows.Add(row); } row = new TableRow(); cell = new TableCell(); cell.Text = "Votants : " + totalVotant.ToString(); cell.CssClass = "TdTotalVoteTableStyle"; cell.ColumnSpan = 2; row.Cells.Add(cell); cell = new TableCell(); cell.Text = "Votes : " + totalVotes.ToString(); cell.CssClass = "TdTotalVoteTableStyle"; cell.ColumnSpan = 3; row.Cells.Add(cell); if (AfficherLaMoyennePonderee) { moyenne = new Label(); moyenne.ApplyStyle(style); moyenne.Text = "x"; cell = new TableCell(); cell.Controls.Add(moyenne); moyenne = new Label(); moyenne.Text = " : " + sommePoids.ToString("##0.###"); cell.Controls.Add(moyenne); cell.CssClass = "TdTotalVoteTableStyle"; row.Cells.Add(cell); } table.Rows.Add(row); return(table); }