コード例 #1
0
ファイル: SQLiteDBOperation.cs プロジェクト: sv-dev2/ELEVEN
        public static List <ChartZoomOut> ReteriveChartZoomList(string formName)
        {
            // We use these three SQLite objects:
            List <ChartZoomOut> modelList = new List <ChartZoomOut>();
            SQLiteConnection    sqlite_conn;
            SQLiteCommand       sqlite_cmd;
            SQLiteDataReader    sqlite_datareader;

            // create a new database connection:

            sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");
            // open the connection:
            sqlite_conn.Open();
            // create a new SQL command:
            sqlite_cmd = sqlite_conn.CreateCommand();

            // First lets build a SQL-Query again:
            sqlite_cmd.CommandText = $"SELECT * FROM tblChartZoomPoints where formUniqueName='{formName}'";
            // Now the SQLiteCommand object can give us a DataReader-Object:
            sqlite_datareader = sqlite_cmd.ExecuteReader();
            // The SQLiteDataReader allows us to run through the result lines:
            while (sqlite_datareader.Read()) // Read() returns true if there is still a result line to read
            {
                // Print out the content of the text field:
                //System.Console.WriteLine( sqlite_datareader["text"] );
                ChartZoomOut model = new ChartZoomOut();
                model.Index      = Convert.ToInt32(sqlite_datareader["Id"]);
                model.PosXFinish = Convert.ToDouble(sqlite_datareader["PosXFinish"]);
                model.PosXStart  = Convert.ToDouble(sqlite_datareader["PosXStart"]);
                model.PosYFinish = Convert.ToDouble(sqlite_datareader["PosYFinish"]);
                model.PosYStart  = Convert.ToDouble(sqlite_datareader["PosYStart"]);

                modelList.Add(model);
            }
            // We are ready, now lets cleanup and close our connection:
            sqlite_conn.Close();
            sqlite_conn.Dispose();
            sqlite_cmd.Dispose();
            return(modelList);
        }
コード例 #2
0
ファイル: SQLiteDBOperation.cs プロジェクト: sv-dev2/ELEVEN
        public static void SaveZoomList(ChartZoomOut model, string formName)
        {
            // We use these three SQLite objects:

            SQLiteConnection sqlite_conn;
            SQLiteCommand    sqlite_cmd;

            // create a new database connection:

            sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");
            // open the connection:
            sqlite_conn.Open();
            // create a new SQL command:
            sqlite_cmd = sqlite_conn.CreateCommand();

            // Lets insert something into our new table:
            sqlite_cmd.CommandText = $"INSERT INTO tblChartZoomPoints (formUniqueName,[Index],PosXStart,PosXFinish,PosYStart,PosYFinish) VALUES ('{formName}',{model.Index},{model.PosXStart},{model.PosXFinish},{model.PosYStart},{model.PosYFinish});";
            // And execute this again ;D
            sqlite_cmd.ExecuteNonQuery();
            // We are ready, now lets cleanup and close our connection:
            sqlite_conn.Close();
            sqlite_conn.Dispose();
            sqlite_cmd.Dispose();
        }