Exemplo n.º 1
0
        static List <MyParagraph> getTitleParagraphs(ADODB.Connection cnn, UInt64 titleId)
        {
            var paragraphLst = new List <MyParagraph>();
            //get title
            var qry = "select * from paragraphs where titleId = ? ";
            var rst = new ADODB.Recordset();

            rst.Open(qry.Replace("?", titleId.ToString()),
                     cnn, ADODB.CursorTypeEnum.adOpenKeyset,
                     ADODB.LockTypeEnum.adLockOptimistic,
                     (int)ADODB.CommandTypeEnum.adCmdText);
            rst.MoveFirst();
            while (!rst.EOF)
            {
                var par = new MyParagraph();
                par.order      = Convert.ToInt32(rst.Fields["order"].Value);
                par.alignment  = Convert.ToInt32(rst.Fields["alignment"].Value);
                par.leftIndent = Convert.ToInt32(rst.Fields["leftIndent"].Value);
                par.fontSize   = Convert.ToInt32(rst.Fields["fontSize"].Value);
                par.fontBold   = Convert.ToInt32(rst.Fields["fontBold"].Value);
                par.fontItalic = Convert.ToInt32(rst.Fields["fontItalic"].Value);
                par.content    = Convert.ToString(rst.Fields["content"].Value);
                paragraphLst.Add(par);

                rst.MoveNext();
            }
            rst.Close();
            return(paragraphLst);
        }
Exemplo n.º 2
0
        static List <MyParagraph> getTitleParagraphs(OleDbConnection cnn, UInt64 titleId)
        {
            var paragraphLst = new List <MyParagraph>();
            //get title
            var qry = "select * from paragraphs where titleId = @id ";
            var cmd = new OleDbCommand(qry, cnn);

            cmd.Parameters.AddWithValue("@id", titleId);
            var reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                var par = new MyParagraph();
                par.titleId    = Convert.ToUInt64(reader["titleId"]);
                par.order      = Convert.ToInt32(reader["order"]);
                par.alignment  = Convert.ToInt32(reader["alignment"]);
                par.leftIndent = Convert.ToInt32(reader["leftIndent"]);
                par.fontSize   = Convert.ToInt32(reader["fontSize"]);
                par.fontBold   = Convert.ToInt32(reader["fontBold"]);
                par.fontItalic = Convert.ToInt32(reader["fontItalic"]);
                par.content    = Convert.ToString(reader["content"]);
                paragraphLst.Add(par);
            }
            paragraphLst.Sort((x, y) => { return(x.order - y.order); });

            int order = 0;

            foreach (var par in paragraphLst)
            {
                Debug.Assert(par.order > order);
                order = par.order;
            }

            reader.Close();
            return(paragraphLst);
        }