public bool updateRecord()
        {
            Type ja = this.GetType();
            string tmp = "UPDATE " + ja.Name + " SET ";
            System.Reflection.FieldInfo[] fieldInfo = ja.GetFields();

            bool was = false;
            foreach (System.Reflection.FieldInfo info in fieldInfo)
            {
                if (info.IsDefined(typeof(PrimaryKey), true)) continue;
                if (was) tmp += ",";
                tmp += info.Name+"=@"+info.Name;
                was = true;
            }
            tmp+=" WHERE ";
            string where = "";
            foreach (System.Reflection.FieldInfo info in fieldInfo)
            {
                if (info.IsDefined(typeof(PrimaryKey), true))
                {
                    if (where.Length != 0) where += " AND ";
                    where += "("+info.Name+" = @"+info.Name+")";
                }
            }
            tmp += where;

            SqliteCommand sql = new SqliteCommand(tmp, SqliteManager.connection);
            foreach (System.Reflection.FieldInfo info in fieldInfo)
            {
                object temp = info.GetValue(this);
                if (temp is long)
                {
                    sql.Parameters.Add(new SqliteParameter("@"+info.Name, temp));
                }
                else
                    if (temp is string)
                    {
                        sql.Parameters.Add(new SqliteParameter("@" + info.Name, temp));
                    }
                    else
                        if (temp is double)
                        {
                            sql.Parameters.Add(new SqliteParameter("@" + info.Name, temp));
                        }
                        else
                            if (temp is bool)
                            {
                                if ((Boolean)temp)
                                    sql.Parameters.Add(new SqliteParameter("@" + info.Name, "1"));
                                else
                                    sql.Parameters.Add(new SqliteParameter("@" + info.Name, "0"));
                            }
                            else
                            {
                                sql.Parameters.Add(new SqliteParameter("@" + info.Name, temp.ToString()));
                            }
            }

            try
            {
                return sql.ExecuteNonQuery() != 0;
            }
            catch (Exception e)
            {
                MessageBox.Show("Error durring row update.\n" + sql.ToString() + "\n"+tmp+"\n" + e.ToString());
                return false;
            }
        }
        public bool insertRecord()
        {
            Type ja = this.GetType();
            string tmp = "INSERT INTO " + ja.Name + "(";
            System.Reflection.FieldInfo[] fieldInfo = ja.GetFields();

            bool was = false;
            foreach (System.Reflection.FieldInfo info in fieldInfo)
            {
                if (was) tmp += ",";
                tmp += info.Name;
                was = true;
            }
            tmp += ") VALUES (";
            was = false;
            foreach (System.Reflection.FieldInfo info in fieldInfo)
            {
                if (was) tmp += ",";
                tmp += "@" + info.Name;
                was = true;
            }
            tmp += ");";

            SqliteCommand sql = new SqliteCommand(tmp, SqliteManager.connection);

            foreach (System.Reflection.FieldInfo info in fieldInfo)
            {
                object temp = info.GetValue(this);
                if (temp is long)
                {
                    sql.Parameters.Add(new SqliteParameter("@"+info.Name, temp));
                }
                else
                    if (temp is string)
                    {
                        sql.Parameters.Add(new SqliteParameter("@" + info.Name, temp));
                    }
                    else
                        if (temp is double)
                        {
                            sql.Parameters.Add(new SqliteParameter("@" + info.Name, temp));
                        }
                        else
                            if (temp is bool)
                            {
                                if ((Boolean)temp)
                                    sql.Parameters.Add(new SqliteParameter("@" + info.Name, "1"));
                                else
                                    sql.Parameters.Add(new SqliteParameter("@" + info.Name, "0"));
                            }
                            else
                            {
                                sql.Parameters.Add(new SqliteParameter("@" + info.Name, temp.ToString()));
                            }
            }

            try
            {
                return sql.ExecuteNonQuery() != 0;
            }
            catch (Exception e)
            {
                MessageBox.Show("Error durring row insert.\n" + sql.ToString() + "\n" + e.ToString());
                return false;
            }
        }