[chronojump] Fixed delete of all test types



commit 6c98bcd0f83b5553150cd477e0381f6d1e3b8c5b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Mar 22 12:42:12 2011 +0100

    Fixed delete of all test types

 src/gui/event.cs       |   16 +++++-----------
 src/gui/jump.cs        |    8 ++++++++
 src/gui/run.cs         |    9 +++++++++
 src/sqlite/jumpType.cs |    4 ++--
 src/sqlite/main.cs     |    2 +-
 src/sqlite/runType.cs  |   11 +++++++++++
 6 files changed, 36 insertions(+), 14 deletions(-)
---
diff --git a/src/gui/event.cs b/src/gui/event.cs
index b52f69e..22fc73c 100644
--- a/src/gui/event.cs
+++ b/src/gui/event.cs
@@ -652,13 +652,6 @@ public class EventMoreWindow
 	
 	void on_button_delete_type_clicked (object o, EventArgs args)
 	{
-		/*
-		//search for events of that type on db
-		if(selectedEventType == EventType.Types.JUMP.ToString())
-			tests = SqliteJump.SelectJumps(-1, -1, "", selectedEventName); 
-		else //RUN
-			tests = SqliteRun.SelectRuns(-1, -1, selectedEventName); 
-		*/
 		string [] tests = findTestTypesInSessions();
 
 		//this will be much better doing a select distinct(session) instead of using SelectJumps or Runs
@@ -680,12 +673,13 @@ public class EventMoreWindow
 		}
 	}
 	
+
+	protected virtual void deleteTestLine() {
+	}
+	
 	protected void on_button_delete_type_accepted (object o, EventArgs args)
 	{
-		if(selectedEventType == EventType.Types.JUMP.ToString())
-			SqliteJumpType.Delete(selectedEventName, false);
-		else //RUN
-			SqliteRunType.Delete(selectedEventName);
+		deleteTestLine();
 
 		TreeModel model;
 		TreeIter iter;
diff --git a/src/gui/jump.cs b/src/gui/jump.cs
index 75b5258..19e1029 100644
--- a/src/gui/jump.cs
+++ b/src/gui/jump.cs
@@ -1325,6 +1325,10 @@ public class JumpsMoreWindow : EventMoreWindow
 		}
 	}
 	
+	protected override void deleteTestLine() {
+		SqliteJumpType.Delete(Constants.JumpTypeTable, selectedEventName, false);
+	}
+
 	protected override string [] findTestTypesInSessions() {
 		return SqliteJump.SelectJumps(-1, -1, "", selectedEventName); 
 	}
@@ -1581,6 +1585,10 @@ public class JumpsRjMoreWindow : EventMoreWindow
 		}
 	}
 	
+	protected override void deleteTestLine() {
+		SqliteJumpType.Delete(Constants.JumpRjTypeTable, selectedEventName, false);
+	}
+	
 	protected override string [] findTestTypesInSessions() {
 		return SqliteJumpRj.SelectJumps(-1, -1, "", selectedEventName); 
 	}
diff --git a/src/gui/run.cs b/src/gui/run.cs
index 232b4f1..9749920 100644
--- a/src/gui/run.cs
+++ b/src/gui/run.cs
@@ -1119,9 +1119,14 @@ public class RunsMoreWindow : EventMoreWindow
 		}
 	}
 	
+	protected override void deleteTestLine() {
+		SqliteRunType.Delete(selectedEventName);
+	}
+
 	protected override string [] findTestTypesInSessions() {
 		return SqliteRun.SelectRuns(-1, -1, selectedEventName); 
 	}
+
 	void on_button_cancel_clicked (object o, EventArgs args)
 	{
 		RunsMoreWindowBox.jumps_runs_more.Hide();
@@ -1362,6 +1367,10 @@ public class RunsIntervalMoreWindow : EventMoreWindow
 		}
 	}
 	
+	protected override void deleteTestLine() {
+		SqliteRunIntervalType.Delete(selectedEventName);
+	}
+
 	protected override string [] findTestTypesInSessions() {
 		return SqliteRunInterval.SelectRuns(-1, -1, selectedEventName); 
 	}
diff --git a/src/sqlite/jumpType.cs b/src/sqlite/jumpType.cs
index 839581b..f43bdf8 100644
--- a/src/sqlite/jumpType.cs
+++ b/src/sqlite/jumpType.cs
@@ -451,11 +451,11 @@ class SqliteJumpType : Sqlite
 		//dbcon.Close();
 	}
 	
-	public static void Delete(string name, bool dbconOpened)
+	public static void Delete(string tableName, string name, bool dbconOpened)
 	{
 		if(!dbconOpened)
 			dbcon.Open();
-		dbcmd.CommandText = "Delete FROM " + Constants.JumpTypeTable +
+		dbcmd.CommandText = "Delete FROM " + tableName + 
 			" WHERE name == '" + name + "'";
 		Log.WriteLine(dbcmd.CommandText.ToString());
 		dbcmd.ExecuteNonQuery();
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index b63cda6..7f32ffc 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -1658,7 +1658,7 @@ class Sqlite
 		dbcmd.ExecuteNonQuery();
 
 		//delete DJ
-		SqliteJumpType.Delete("DJ", true);
+		SqliteJumpType.Delete(Constants.JumpTypeTable, "DJ", true);
 	}
 
 
diff --git a/src/sqlite/runType.cs b/src/sqlite/runType.cs
index 78f52e5..2d116d2 100644
--- a/src/sqlite/runType.cs
+++ b/src/sqlite/runType.cs
@@ -470,5 +470,16 @@ class SqliteRunIntervalType : SqliteRunType
 		SqliteEvent.GraphLinkInsert (Constants.RunIntervalTable, "20m endurance", "run_interval.png", true);
 		SqliteEvent.GraphLinkInsert (Constants.RunIntervalTable, "MTGUG", "mtgug.png", true);
 	}
+	
+	public static void Delete(string name)
+	{
+		dbcon.Open();
+		dbcmd.CommandText = "Delete FROM " + Constants.RunIntervalTypeTable +
+			" WHERE name == '" + name + "'";
+		Log.WriteLine(dbcmd.CommandText.ToString());
+		dbcmd.ExecuteNonQuery();
+		dbcon.Close();
+	}
+
 
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]