test

C++ code posted
created at 22 Feb 09:43, updated at 22 Feb 15:42

Edit | Back
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
// мускл

namespace SP.Dal.Poll
{
    public class Answer : DbObject
    {
        public override int Save()
        {
            try
            {
                bool flag = DbObject.IsRowExists<Answer>(this.Id);
                if (!flag)
                {
                    this.SetSortOrder();
                }
                ManagedCommand command = new ManagedCommand(!flag ? "INSERT INTO PollAnswer (AnswerQuestion, AnswerName, AnswerCount, AnswerSort) VALUES (?q, ?name, ?count, ?sort);SELECT LAST_INSERT_ID();" : "UPDATE PollAnswer SET AnswerQuestion=?q, AnswerName=?name, AnswerCount=?count, AnswerSort=?sort WHERE AnswerID=?id");
                command.AddInt32Parameter("?id", this.Id);
                command.AddInt32Parameter("?q", this.Question);
                command.AddStringParameter("?name", this.Name);
                command.AddInt32Parameter("?count", this.Count);
                command.AddInt32Parameter("?sort", this.Sort);
                int num = command.ExecuteInt(true);
                if (this.Id <= 0)
                {
                    this.Id = num;
                }
            }
            catch (Exception exception)
            {
                Trace.WriteLine(exception.Message);
                throw;
            }
            return this.Id;
        }
    }
}

// сессия
namespace SP.Modules.Poll
{

    public class Frontend : FrontendWebPart
    {

        private static void MarkAsAnswered(DbObject poll)
        {
            string str = Tools.ChkString(HttpContext.Current.Session["SP_Polls"]);
            int[] array = Tools.String2IntArray(str);
            if ((array == null) || (Array.IndexOf<int>(array, poll.Id) < 0))
            {
                HttpContext.Current.Session["SP_Polls"] = string.Format("{0}{1}{2}", str, ((array != null) && (array.Length > 0)) ? "," : string.Empty, poll.Id);
            }
        }

        private bool WasAnswered()
        {
            int[] array = Tools.String2IntArray(Tools.ChkString(HttpContext.Current.Session["SP_Polls"]));
            return ((array != null) && (Array.IndexOf<int>(array, this._poll.Id) >= 0));
        }

    }

}
2.18 KB in 6 ms with coderay