Exemple #1
0
 public static List<BaStruct> getBaForSession(int sessionId)
 {
     string sql = "SELECT id,cdate from BEFORE_AFTER WHERE sid = @sid";
     List<BaStruct> BA = new List<BaStruct>();
     using (SQLiteConnection conn = getConnection())
     {
         conn.Open();
         using (SQLiteCommand command = conn.CreateCommand())
         {
             command.CommandText = sql;
             command.Parameters.Add(new SQLiteParameter("@sid", sessionId));
             using (SQLiteDataReader reader = command.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     BaStruct ba = new BaStruct();
                     ba.baid = (int)(Int64)reader["id"];
                     ba.cdate = (DateTime)reader["cdate"];
                     BA.Add(ba);
                 }
             }
         }
     }
     return BA;
 }
Exemple #2
0
        public static BaStruct getBa(int id)
        {
            string sql = "SELECT id,cdate,before,beforedate,after,afterdate from BEFORE_AFTER WHERE id = @id";

            using (SQLiteConnection conn = getConnection())
            {
                conn.Open();
                using (SQLiteCommand command = conn.CreateCommand())
                {
                    command.CommandText = sql;
                    command.Parameters.Add(new SQLiteParameter("@id", id));
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            BaStruct ba = new BaStruct();
                            ba.baid = (int)(Int64)reader["id"];
                            ba.cdate = (DateTime)reader["cdate"];
                            ba.before = (string) reader["before"];
                            ba.after = (string) reader["after"];
                            object date = reader["beforedate"];
                            if (date != null)
                            {
                                try
                                {
                                    ba.beforeDate = (DateTime)date;
                                }
                                catch (InvalidCastException) { }
                            }
                            date = reader["afterdate"];
                            if (date != null)
                            {
                                try
                                {
                                    ba.afterDate = (DateTime)date;
                                }
                                catch (InvalidCastException) { }
                            }

                            return ba;
                        }
                    }
                }
            }
            return null;
        }