Esempio n. 1
0
        protected string GetHtmlAnswerRow(Answer answer)
        {
            string str = "";

            if (answer.CountVoice != 0)
            {
                str += "<tr>" +
                       "<td style=\"width: 10px\">" +
                       "<span class=\"NameAnswer\">" + answer.Name + "</span>" +
                       "</td>" +

                       "<td style=\"width: 95%\">" +
                       "<div style=\"width: " + answer.Percent + "%\" class=\"barAnswer\"></div>" +
                       "</td>" +

                       "<td>" +
                       answer.Percent + "%" +
                       "</td>" +
                       "</tr>" +
                       "<tr>" +
                       "<td align=\"center\" colspan=\"3\">" +
                       Resources.Resource.Admin_VotingHistory_Votes + " " + answer.CountVoice +
                       "</td>" +
                       "</tr>";
            }
            else
            {
                str += "<tr>" +
                       "<td align=\"center\">" +
                       Resources.Resource.Admin_VotingHistory_NoAnswers +
                       "</td>" +
                       "</tr>" +
                       "<tr>" +
                       "<td align=\"center\">" +
                       Resources.Resource.Admin_VotingHistory_Votes + " 0" +
                       "</td>" +
                       "</tr>";
            }

            return str;
        }
Esempio n. 2
0
 public static void UpdateAnswer(Answer answer)
 {
     SQLDataAccess.ExecuteNonQuery(@"UPDATE [Voice].[Answer] SET [FKIDTheme] = @FKIDTheme,[Name] = @Name,[CountVoice] = @CountVoice, [Sort] = @Sort, [IsVisible] = @IsVisible, [DateModify] = @DateModify WHERE [AnswerID] = @AnswerID",
                                     CommandType.Text,
                                     new SqlParameter("@AnswerID", answer.AnswerId),
                                     new SqlParameter("@FKIDTheme", answer.FkidTheme),
                                     new SqlParameter("@Name", answer.Name),
                                     new SqlParameter("@CountVoice", answer.CountVoice),
                                     new SqlParameter("@Sort", answer.Sort),
                                     new SqlParameter("@IsVisible", answer.IsVisible),
                                     new SqlParameter("@DateModify", DateTime.Now));
 }
Esempio n. 3
0
 public static void InsertAnswer(Answer answer)
 {
     answer.AnswerId = SQLDataAccess.ExecuteScalar<int>(@"INSERT INTO [Voice].[Answer] ([FKIDTheme], [Name], [CountVoice], [Sort], [IsVisible], [DateAdded], [DateModify]) VALUES (@FKIDTheme,  @Name,  @CountVoice,  @Sort,  @IsVisible,  @DateAdded,  @DateModify); SELECT scope_identity();",
                                          CommandType.Text,
                                          new SqlParameter("@FKIDTheme", answer.FkidTheme),
                                          new SqlParameter("@Name", answer.Name),
                                          new SqlParameter("@CountVoice", answer.CountVoice),
                                          new SqlParameter("@Sort", answer.Sort),
                                          new SqlParameter("@IsVisible", answer.IsVisible),
                                          new SqlParameter("@DateAdded", DateTime.Now),
                                          new SqlParameter("@DateModify", DateTime.Now));
 }
Esempio n. 4
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (grid.UpdatedRow != null)
            {
                try
                {
                    int countVoices = 0;
                    int sort = 0;
                    if (Int32.TryParse(grid.UpdatedRow["CountVoice"], out countVoices) && Int32.TryParse(grid.UpdatedRow["Sort"], out sort))
                    {
                        var answer = new Answer
                            {
                                AnswerId = SQLDataHelper.GetInt(grid.UpdatedRow["ID"]),
                                Name = grid.UpdatedRow["Name"],
                                IsVisible = SQLDataHelper.GetBoolean(grid.UpdatedRow["IsVisible"]),
                                FkidTheme = ThemeId,
                                CountVoice = countVoices,
                                Sort = sort
                            };
                        VoiceService.UpdateAnswer(answer);
                    }

                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }

            DataTable data = _paging.PageItems;
            while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1)
            {
                _paging.CurrentPageIndex--;
                data = _paging.PageItems;
            }

            data.Columns.Add(new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection });
            if ((_selectionFilter != null) && (_selectionFilter.Values != null))
            {
                for (int i = 0; i <= data.Rows.Count - 1; i++)
                {
                    int intIndex = i;
                    if (Array.Exists(_selectionFilter.Values, c => c == (data.Rows[intIndex]["ID"]).ToString()))
                    {
                        data.Rows[i]["IsSelected"] = !_inverseSelection;
                    }
                }
            }

            if (data.Rows.Count < 1)
            {
                goToPage.Visible = false;
            }

            grid.DataSource = data;
            grid.DataBind();

            pageNumberer.PageCount = _paging.PageCount;
            lblFound.Text = _paging.TotalRowsCount.ToString();
        }
Esempio n. 5
0
        protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteAnswer")
            {
                VoiceService.DeleteAnswer(SQLDataHelper.GetInt(e.CommandArgument));
            }

            if (e.CommandName == "AddAnswer")
            {
                try
                {
                    var answer = new Answer
                        {
                            Name = ((TextBox)grid.FooterRow.FindControl("txtNewName")).Text,
                            CountVoice = ((TextBox)grid.FooterRow.FindControl("txtNewCountVoice")).Text.TryParseInt(),
                            Sort = ((TextBox)grid.FooterRow.FindControl("txtNewSort")).Text.TryParseInt(),
                            IsVisible = ((CheckBox)grid.FooterRow.FindControl("chkNewIsVisible")).Checked,
                            FkidTheme = ThemeId
                        };

                    VoiceService.InsertAnswer(answer);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
                grid.ShowFooter = false;
            }

            if (e.CommandName == "CancelAdd")
            {
                grid.ShowFooter = false;
            }
        }