[chronojump] Fixed: 608928 DJ with and without using arms. DB now 0.74



commit 624ef5378421968f500b567a5070b7b64594b07f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Feb 22 20:03:45 2010 +0800

    Fixed: 608928 DJ with and without using arms. DB now 0.74

 chronojump_server/bin/chronojumpServer.dll |  Bin 276480 -> 273920 bytes
 glade/chronojump.glade                     |   75 ++++++++++++++++++++------
 src/chronojump.cs                          |    7 ++-
 src/gui/chronojump.cs                      |   10 ++++
 src/gui/chronopic.cs                       |   67 -----------------------
 src/gui/event.cs                           |    2 +-
 src/gui/jump.cs                            |   75 +++++++++++++++-----------
 src/jumpType.cs                            |   20 ++++++-
 src/sqlite/jumpType.cs                     |   16 ++++--
 src/sqlite/main.cs                         |   80 +++++++++++++++++++++++++++-
 src/sqlite/stat.cs                         |    8 ++-
 src/stats/global.cs                        |    2 +
 12 files changed, 232 insertions(+), 130 deletions(-)
---
diff --git a/chronojump_server/bin/chronojumpServer.dll b/chronojump_server/bin/chronojumpServer.dll
index ccf0126..de00929 100755
Binary files a/chronojump_server/bin/chronojumpServer.dll and b/chronojump_server/bin/chronojumpServer.dll differ
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index f2bfc4c..45900da 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -2001,6 +2001,7 @@ comments</property>
     <child>
       <widget class="GtkVBox" id="vbox11">
         <property name="visible">True</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">8</property>
         <child>
           <widget class="GtkLabel" id="label90">
@@ -2016,10 +2017,10 @@ comments</property>
         <child>
           <widget class="GtkTable" id="table11">
             <property name="visible">True</property>
-            <property name="n_rows">3</property>
+            <property name="n_rows">4</property>
             <property name="n_columns">4</property>
-            <property name="column_spacing">3</property>
-            <property name="row_spacing">4</property>
+            <property name="column_spacing">6</property>
+            <property name="row_spacing">6</property>
             <child>
               <widget class="GtkLabel" id="label_weight">
                 <property name="visible">True</property>
@@ -2040,8 +2041,8 @@ comments</property>
                 <property name="label" translatable="yes">Falling height</property>
               </widget>
               <packing>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
                 <property name="x_options">GTK_FILL</property>
                 <property name="y_options"></property>
               </packing>
@@ -2095,8 +2096,8 @@ weight</property>
               <packing>
                 <property name="left_attach">2</property>
                 <property name="right_attach">3</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
                 <property name="x_options">GTK_FILL</property>
                 <property name="y_options"></property>
               </packing>
@@ -2105,7 +2106,7 @@ weight</property>
               <widget class="GtkSpinButton" id="spinbutton_weight">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="adjustment">10 0 200 1 10 10</property>
+                <property name="adjustment">10 0 200 1 10 0</property>
                 <property name="climb_rate">1</property>
                 <property name="numeric">True</property>
               </widget>
@@ -2114,7 +2115,7 @@ weight</property>
                 <property name="right_attach">2</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
-                <property name="x_options">GTK_EXPAND</property>
+                <property name="x_options">GTK_FILL</property>
                 <property name="y_options"></property>
               </packing>
             </child>
@@ -2122,16 +2123,16 @@ weight</property>
               <widget class="GtkSpinButton" id="spinbutton_fall">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="adjustment">20 0 200 1 10 10</property>
+                <property name="adjustment">20 0 200 1 10 0</property>
                 <property name="climb_rate">1</property>
                 <property name="numeric">True</property>
               </widget>
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options">GTK_EXPAND</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+                <property name="x_options">GTK_FILL</property>
                 <property name="y_options"></property>
               </packing>
             </child>
@@ -2161,7 +2162,7 @@ weight</property>
               <widget class="GtkSpinButton" id="spinbutton_limit">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="adjustment">10 1 100 1 10 10</property>
+                <property name="adjustment">10 1 100 1 10 0</property>
                 <property name="snap_to_ticks">True</property>
                 <property name="numeric">True</property>
                 <property name="wrap">True</property>
@@ -2170,12 +2171,47 @@ weight</property>
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
-                <property name="x_options"></property>
+                <property name="x_options">GTK_FILL</property>
                 <property name="y_options"></property>
-                <property name="x_padding">4</property>
               </packing>
             </child>
             <child>
+              <widget class="GtkLabel" id="label_dj_arms">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Technique</property>
+              </widget>
+              <packing>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkCheckButton" id="check_dj_arms">
+                <property name="label" translatable="yes">Using arms</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="draw_indicator">True</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
               <placeholder/>
             </child>
             <child>
@@ -2340,6 +2376,8 @@ weight</property>
     <child>
       <widget class="GtkVBox" id="vbox22">
         <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">10</property>
         <child>
           <widget class="GtkLabel" id="label1">
             <property name="visible">True</property>
@@ -4518,6 +4556,7 @@ options</property>
     <child>
       <widget class="GtkVBox" id="vbox42">
         <property name="visible">True</property>
+        <property name="orientation">vertical</property>
         <child>
           <widget class="GtkLabel" id="label106">
             <property name="visible">True</property>
@@ -4567,7 +4606,7 @@ options</property>
               <widget class="GtkSpinButton" id="spinbutton_limit">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="adjustment">100 0 100000 1 10 10</property>
+                <property name="adjustment">100 0 100000 1 10 0</property>
                 <property name="snap_to_ticks">True</property>
                 <property name="numeric">True</property>
                 <property name="update_policy">if-valid</property>
@@ -4610,7 +4649,7 @@ options</property>
               <widget class="GtkSpinButton" id="spinbutton_distance">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="adjustment">100 0 10000 1 10 10</property>
+                <property name="adjustment">100 0 10000 1 10 0</property>
                 <property name="snap_to_ticks">True</property>
                 <property name="numeric">True</property>
                 <property name="update_policy">if-valid</property>
diff --git a/src/chronojump.cs b/src/chronojump.cs
index 014ba97..212882a 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -228,9 +228,14 @@ Log.WriteLine("doing backup");
 			splashMessageChange(4);  //updating DB
 			updatingDB = true;
 
+			if(Sqlite.ChangeDjToDJna())
+				messageToShowOnBoot += Catalog.GetString("All DJ jumps have been renamed as 'DJna' (Drop Jumps with No Arms).") + "\n\n"+ 
+					Catalog.GetString("If your Drop Jumps were executed using the arms, please rename them manually as 'DJa'.");
+
 			bool softwareIsNew = Sqlite.ConvertToLastChronojumpDBVersion();
 			updatingDB = false;
-
+			
+				
 			if(! softwareIsNew) {
 				//Console.Clear();
 				string errorMessage = string.Format(Catalog.GetString ("Sorry, this Chronojump version ({0}) is too old for your database."), progVersion) + "\n" +  
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index f7d626f..cbc3e3c 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2872,6 +2872,14 @@ Console.WriteLine("X");
 		} else {
 		}
 	
+		//jumpType is a DJ?... with or without arms?
+		if(currentJumpType.Name == "DJ") {
+			if(jumpExtraWin.Arms)
+				currentJumpType = new JumpType("DJa");
+			else
+				currentJumpType = new JumpType("DJna");
+		}
+
 		changeTestImage(EventType.Types.JUMP.ToString(), currentJumpType.Name, currentJumpType.ImageFileName);
 			
 		double jumpWeight = 0;
@@ -2884,11 +2892,13 @@ Console.WriteLine("X");
 			}
 		}
 		int myFall = 0;
+		bool arms = false;
 		if(currentJumpType.Name == Constants.TakeOffName || currentJumpType.Name == Constants.TakeOffWeightName)
 			myFall = 0;
 		else if( ! currentJumpType.StartIn) {
 			myFall = jumpExtraWin.Fall;
 		}
+		
 			
 		//used by cancel and finish
 		//currentEventType = new JumpType();
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index db6af0b..542a7ed 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -86,16 +86,8 @@ public class ChronopicWindow
 
 	bool isWindows;	
 
-	/*
-	//preferences variables
-	private static string chronopicPort1 = "";
-	private static string chronopicPort2 = "";
-	private static string chronopicPort3 = "";
-	private static string chronopicPort4 = "";
-	*/
 	//ArrayList of ChronopicPortData
 	static ArrayList cpd;
-	//ArrayList cpd;
 	
 	//platform state variables
 	enum States {
@@ -149,11 +141,6 @@ public class ChronopicWindow
 		chronopic_image.Pixbuf = pixbuf;
 
 		/*
-		chronopicPort1 = SqlitePreferences.Select("chronopicPort");
-		chronopicPort2 = "";
-		chronopicPort3 = "";
-		chronopicPort4 = "";
-
 		if(chronopicPort1 != Constants.ChronopicDefaultPortWindows && 
 				(chronopicPort1 != Constants.ChronopicDefaultPortLinux && File.Exists(chronopicPort1))
 		  ) {
@@ -268,52 +255,6 @@ public class ChronopicWindow
 				combo_windows4.Changed += new EventHandler (on_combo_changed);
 			}
 		}
-		/*	
-		UtilGtk.ComboUpdate(myCombo, comboWindowsOptions, comboWindowsOptions[0]);
-
-		//TODO: fix this
-		if(myPort.Length > 0) {
-			if (myCombo == combo_windows1)
-				myCombo.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, myPort);
-			else { //don't show connected port as an option for other ports
-				UtilGtk.ComboDelThisValue(myCombo, myPort);
-				myCombo.Active = 0; //first option
-			}
-		} else 
-			myCombo.Active = 0; //first option
-			
-		myCombo.Changed += new EventHandler (on_combo_changed);
-			*/
-
-		
-
-		/*
-		foreach(ChronopicPortData a in cpd) {
-			if(a.Port.Length > 0) {
-				if(a.Num == 1) {
-					combo_windows1.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
-					UtilGtk.ComboDelThisValue(combo_windows2, a.Port);
-					UtilGtk.ComboDelThisValue(combo_windows3, a.Port);
-					UtilGtk.ComboDelThisValue(combo_windows4, a.Port);
-					combo_windows1.Changed += new EventHandler (on_combo_changed);
-				} else if(a.Num == 2) {
-					combo_windows2.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
-					UtilGtk.ComboDelThisValue(combo_windows3, a.Port);
-					UtilGtk.ComboDelThisValue(combo_windows4, a.Port);
-					combo_windows2.Changed += new EventHandler (on_combo_changed);
-				} else if(a.Num == 3) {
-					combo_windows3.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
-					UtilGtk.ComboDelThisValue(combo_windows4, a.Port);
-					combo_windows3.Changed += new EventHandler (on_combo_changed);
-				} else { //4
-					combo_windows4.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
-					combo_windows4.Changed += new EventHandler (on_combo_changed);
-				}
-			} 
-//			else 
-//				myCombo.Active = 0; //first option
-		}
-		*/
 	}
 
 	private void createComboLinux() {
@@ -850,23 +791,16 @@ public class ChronopicWindow
 		//kill the chronopicInit function that is waiting event 
 		thread.Abort();
 		
-		//menuitem_chronopic.Active = false;
-		//menuitem_simulated.Active = true;
-				
 		updateChronopicWinValuesState= false; //disconnected
 		updateChronopicWinValuesMessage= Catalog.GetString("Cancelled by user");
 		needUpdateChronopicWin = true;
 			
 	}
 	
-	//private void on_chronopic_closed (object o, EventArgs args) {
-	//}
-
 	void on_button_close_clicked (object o, EventArgs args)
 	{
 		Log.WriteLine("CLOSE");
 		ChronopicWindowBox.chronopic_window.Hide();
-//		ChronopicWindowBox = null;
 	}
 
 	void on_delete_event (object o, DeleteEventArgs args)
@@ -874,7 +808,6 @@ public class ChronopicWindow
 		//nice: this makes windows no destroyed, then it works like button_close
 		args.RetVal = true;
 		ChronopicWindowBox.chronopic_window.Hide();
-//		ChronopicWindowBox = null;
 	}
 
 
diff --git a/src/gui/event.cs b/src/gui/event.cs
index 1a629b9..1499b39 100644
--- a/src/gui/event.cs
+++ b/src/gui/event.cs
@@ -610,7 +610,7 @@ public class EventMoreWindow
 	protected void on_button_delete_type_accepted (object o, EventArgs args)
 	{
 		if(selectedEventType == EventType.Types.JUMP.ToString())
-			SqliteJumpType.Delete(selectedEventName);
+			SqliteJumpType.Delete(selectedEventName, false);
 		else //RUN
 			SqliteRunType.Delete(selectedEventName);
 
diff --git a/src/gui/jump.cs b/src/gui/jump.cs
index 24452b4..4563691 100644
--- a/src/gui/jump.cs
+++ b/src/gui/jump.cs
@@ -790,6 +790,9 @@ public class JumpExtraWindow
 	[Widget] Gtk.Label label_fall;
 	[Widget] Gtk.Label label_cm;
 	
+	[Widget] Gtk.Label label_dj_arms;
+	[Widget] Gtk.CheckButton check_dj_arms;
+	
 	//for RunAnalysis
 	//but will be used and recorded with "fall"
 	static int distance;
@@ -798,6 +801,7 @@ public class JumpExtraWindow
 	static double limited = 10;
 	static bool jumpsLimited;
 	static int weight = 20;
+	static bool arms = false;
 	static int fall = 20;
 	
 	static JumpExtraWindow JumpExtraWindowBox;
@@ -859,10 +863,14 @@ public class JumpExtraWindow
 		if(! myJumpType.HasWeight) {
 			hideWeightData();	
 		}
-		if(myJumpType.StartIn || myJumpType.Name == Constants.TakeOffName || myJumpType.Name == Constants.TakeOffWeightName) {
-			hideFallData();	
-		}
+		if(myJumpType.StartIn || myJumpType.Name == Constants.TakeOffName || myJumpType.Name == Constants.TakeOffWeightName)
+			       hideFallData();	
 		
+		//show technique (arms) only in DJ
+		if(myJumpType.StartIn || myJumpType.IsRepetitive)
+			hideTechniqueArmsData();
+		
+		JumpExtraWindowBox.check_dj_arms.Active = arms;
 		JumpExtraWindowBox.spinbutton_weight.Value = weight;
 		JumpExtraWindowBox.spinbutton_fall.Value = fall;
 		if (option == "Kg") {
@@ -877,22 +885,27 @@ public class JumpExtraWindow
 	}
 	
 	static void hideRepetitiveData () {
-		JumpExtraWindowBox.label_limit.Sensitive = false;
-		JumpExtraWindowBox.spinbutton_limit.Sensitive = false;
-		JumpExtraWindowBox.label_limit_units.Sensitive = false;
+		JumpExtraWindowBox.label_limit.Hide();
+		JumpExtraWindowBox.spinbutton_limit.Hide();
+		JumpExtraWindowBox.label_limit_units.Hide();
 	}
 	
 	static void hideWeightData () {
-		JumpExtraWindowBox.label_weight.Sensitive = false;
-		JumpExtraWindowBox.spinbutton_weight.Sensitive = false;
-		JumpExtraWindowBox.radiobutton_kg.Sensitive = false;
-		JumpExtraWindowBox.radiobutton_weight.Sensitive = false;
+		JumpExtraWindowBox.label_weight.Hide();
+		JumpExtraWindowBox.spinbutton_weight.Hide();
+		JumpExtraWindowBox.radiobutton_kg.Hide();
+		JumpExtraWindowBox.radiobutton_weight.Hide();
+	}
+	
+	static void hideTechniqueArmsData () {
+		JumpExtraWindowBox.label_dj_arms.Hide();
+		JumpExtraWindowBox.check_dj_arms.Hide();
 	}
 	
 	static void hideFallData () {
-		JumpExtraWindowBox.label_fall.Sensitive = false;
-		JumpExtraWindowBox.spinbutton_fall.Sensitive = false;
-		JumpExtraWindowBox.label_cm.Sensitive = false;
+		JumpExtraWindowBox.label_fall.Hide();
+		JumpExtraWindowBox.spinbutton_fall.Hide();
+		JumpExtraWindowBox.label_cm.Hide();
 	}
 	
 	void on_button_cancel_clicked (object o, EventArgs args)
@@ -913,6 +926,7 @@ public class JumpExtraWindow
 		weight = (int) spinbutton_weight.Value;
 		fall = (int) spinbutton_fall.Value;
 		distance = (int) spinbutton_fall.Value;
+		arms = check_dj_arms.Active;
 		
 		JumpExtraWindowBox.jump_extra.Hide();
 		JumpExtraWindowBox = null;
@@ -936,41 +950,38 @@ public class JumpExtraWindow
 		get { return button_accept;	}
 	}
 
-	public string Option 
-	{
-		get { return option;	}
+	public string Option {
+		get { return option; }
 	}
 
-	public bool JumpsLimited 
-	{
-		get { return jumpsLimited;	}
+	public bool JumpsLimited {
+		get { return jumpsLimited; }
 	}
 	
-	public double Limited 
-	{
-		get { return limited;	}
+	public double Limited {
+		get { return limited; }
 	}
 	
-	
 	public string LimitString
 	{
 		get { 
-			if(jumpsLimited) {
+			if(jumpsLimited) 
 				return limited.ToString() + "J";
-			} else {
+			else 
 				return Limited.ToString() + "T";
-			}
 		}
 	}
 	
-	public int Weight 
-	{
-		get { return weight;	}
+	public int Weight {
+		get { return weight; }
 	}
 	
-	public int Fall 
-	{
-		get { return fall;	}
+	public bool Arms {
+		get { return arms; }
+	}
+
+	public int Fall {
+		get { return fall; }
 	}
 }
 
diff --git a/src/jumpType.cs b/src/jumpType.cs
index 37e5746..5c69b8d 100644
--- a/src/jumpType.cs
+++ b/src/jumpType.cs
@@ -40,7 +40,7 @@ public class JumpType : EventType
 	public override bool FindIfIsPredefined() {
 		string [] predefinedTests = {
 			"Free", "SJ", "CMJ", "ABK", "Rocket",
-			"SJl", "CMJl", "ABKl", "DJ",
+			"SJl", "CMJl", "ABKl", "DJa", "DJna",
 			"RJ(j)", "RJ(t)", "RJ(unlimited)",
 			"RJ(hexagon)", "triple jump"
 		};
@@ -129,7 +129,7 @@ public class JumpType : EventType
 			fixedValue 	= 0; //for repetitive
 			description	= Catalog.GetString("Take off with weight");
 			imageFileName = "";
-		} else if(name == "DJ") {
+		} else if(name == "DJ") { //not used for end user, but used in software to initially define jump
 			startIn 	= false;
 			hasWeight 	= false;
 			isRepetitive 	= false;
@@ -137,6 +137,22 @@ public class JumpType : EventType
 			fixedValue 	= 0;
 			description	= Catalog.GetString("DJ Jump");
 			imageFileName = "jump_dj.png";
+		} else if(name == "DJa") { //DJ using arms
+			startIn 	= false;
+			hasWeight 	= false;
+			isRepetitive 	= false;
+			jumpsLimited 	= false;
+			fixedValue 	= 0;
+			description	= Catalog.GetString("DJ Jump using arms");
+			imageFileName = "jump_dj.png";
+		} else if(name == "DJna") { //DJ Not using arms
+			startIn 	= false;
+			hasWeight 	= false;
+			isRepetitive 	= false;
+			jumpsLimited 	= false;
+			fixedValue 	= 0;
+			description	= Catalog.GetString("DJ Jump without using arms");
+			imageFileName = "jump_dj.png";
 		} else if(name == "RJ(j)") {
 			startIn 	= false;
 			hasWeight 	= false;
diff --git a/src/sqlite/jumpType.cs b/src/sqlite/jumpType.cs
index f6160f9..96a06c8 100644
--- a/src/sqlite/jumpType.cs
+++ b/src/sqlite/jumpType.cs
@@ -58,7 +58,9 @@ class SqliteJumpType : Sqlite
 			"ABK:1:0:ABK jump", 
 			"ABKl:1:1:ABK jump with weight", 
 			"Max:1:0:;Maximum jump", 
-			"DJ:0:0:DJ jump",
+			//"DJ:0:0:DJ jump",
+			"DJa:0:0:DJ jump using arms",
+			"DJna:0:0:DJ jump without using arms",
 			"Rocket:1:0:Rocket jump",
 			"TakeOff:0:0:Take off",
 			"TakeOffWeight:0:1:Take off with weight"
@@ -86,7 +88,9 @@ class SqliteJumpType : Sqlite
 		SqliteEvent.GraphLinkInsert (Constants.JumpTable, "ABKl", "jump_abk_l.png", true);
 		SqliteEvent.GraphLinkInsert (Constants.JumpTable, "Max", "jump_max.png", true);
 		SqliteEvent.GraphLinkInsert (Constants.JumpTable, "Rocket", "jump_rocket.png", true);
-		SqliteEvent.GraphLinkInsert (Constants.JumpTable, "DJ", "jump_dj.png", true);
+		//SqliteEvent.GraphLinkInsert (Constants.JumpTable, "DJ", "jump_dj.png", true);
+		SqliteEvent.GraphLinkInsert (Constants.JumpTable, "DJa", "jump_dj.png", true);
+		SqliteEvent.GraphLinkInsert (Constants.JumpTable, "DJna", "jump_dj.png", true);
 	}
 
 	//creates table containing the types of repetitive Jumps
@@ -434,14 +438,16 @@ class SqliteJumpType : Sqlite
 		//dbcon.Close();
 	}
 	
-	public static void Delete(string name)
+	public static void Delete(string name, bool dbconOpened)
 	{
-		dbcon.Open();
+		if(!dbconOpened)
+			dbcon.Open();
 		dbcmd.CommandText = "Delete FROM " + Constants.JumpTypeTable +
 			" WHERE name == '" + name + "'";
 		Log.WriteLine(dbcmd.CommandText.ToString());
 		dbcmd.ExecuteNonQuery();
-		dbcon.Close();
+		if(!dbconOpened)
+			dbcon.Close();
 	}
 
 }	
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index ba0a3ca..416ef1b 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -72,7 +72,7 @@ class Sqlite
 	 * Important, change this if there's any update to database
 	 * Important2: if database version get numbers higher than 1, check if the comparisons with currentVersion works ok
 	 */
-	static string lastChronojumpDatabaseVersion = "0.73";
+	static string lastChronojumpDatabaseVersion = "0.74";
 
 	public Sqlite() {
 	}
@@ -959,6 +959,17 @@ class Sqlite
 				dbcon.Close();
 				currentVersion = "0.73";
 			}
+			if(currentVersion == "0.73") {
+				//dbcon open laters on mid convertDJinDJna()
+				
+				convertDJInDJna();
+
+				SqlitePreferences.Update ("databaseVersion", "0.74", true); 
+				
+				Log.WriteLine("Converted DB to 0.74 (All DJ converted to DJna)"); 
+				dbcon.Close();
+				currentVersion = "0.74";
+			}
 
 
 		}
@@ -969,6 +980,14 @@ class Sqlite
 		return returnSoftwareIsNew;
 	}
 
+	public static bool ChangeDjToDJna() {
+		string v = SqlitePreferences.Select("databaseVersion");
+		Log.WriteLine(Convert.ToDouble(Util.ChangeDecimalSeparator(v)).ToString());
+		if(Convert.ToDouble(Util.ChangeDecimalSeparator(v)) < Convert.ToDouble(Util.ChangeDecimalSeparator("0.74")))
+			return true;
+		return false;
+	}
+
 	private static void addChronopicPortNameIfNotExists() {
 		string myPort = SqlitePreferences.Select("chronopicPort");
 		if(myPort == "0") {
@@ -1084,6 +1103,7 @@ class Sqlite
 		SqliteCountry.initialize();
 		
 		//changes [from - to - desc]
+		//0.73 - 0.74 Converted DB to 0.74 (All DJ converted to DJna)
 		//0.72 - 0.73 Converted DB to 0.73 (deleted orphaned persons (in person table but not in personSessionWeight table))
 		//0.71 - 0.72 dates to YYYY-MM-DD
 		//0.70 - 0.71 created personNotUploadTable on client
@@ -1305,6 +1325,64 @@ class Sqlite
 				SqlitePerson.Delete(personID);
 		}
 	}
+				
+	//used to convert to sqlite 0.74
+	protected internal static void convertDJInDJna()
+	{
+		//Dja exists in DB? (user defined)
+		if(Exists(Constants.JumpTypeTable, "DJa")) {
+			string [] names = { "DJa-user", "DJa-user2", "DJa-user3", "DJa-user4" }; //sorry, we cannot check all the names in the world, ok, yes, i know, we can, but it's ok like this
+			bool success = false;
+			foreach(string name in names) {
+				if(!Exists(Constants.JumpTypeTable, name)) {
+					success = true;
+					dbcmd.CommandText = "UPDATE jump SET type = '" + name + "' WHERE type == 'DJa'";
+					Log.WriteLine(dbcmd.CommandText.ToString());
+					dbcmd.ExecuteNonQuery();
+				}
+				if(success) 
+					break;
+			}
+		}
+		
+		//Djna exists in DB? (user defined)
+		if(Exists(Constants.JumpTypeTable, "DJna")) {
+			string [] names = { "DJna-user", "DJna-user2", "DJna-user3", "DJna-user4" }; //sorry, we cannot check all the names in the world, ok, yes, i know, we can, but it's ok like this
+			bool success = false;
+			foreach(string name in names) {
+				if(!Exists(Constants.JumpTypeTable, name)) {
+					success = true;
+					dbcmd.CommandText = "UPDATE jump SET type = '" + name + "' WHERE type == 'DJna'";
+					Log.WriteLine(dbcmd.CommandText.ToString());
+					dbcmd.ExecuteNonQuery();
+				}
+				if(success) 
+					break;
+			}
+		}
+
+		//no opened before because Exists is for closed dbcon
+		dbcon.Open();
+
+		//create new jump types
+		SqliteJumpType.JumpTypeInsert ("DJa:0:0:DJ jump using arms", true); 
+		SqliteJumpType.JumpTypeInsert ("DJna:0:0:DJ jump without using arms", true); 
+		
+		//add auto-converted on description
+		dbcmd.CommandText = "UPDATE jump SET description = description || ' Auto-converted from DJ' WHERE type == 'DJ'";
+		Log.WriteLine(dbcmd.CommandText.ToString());
+		dbcmd.ExecuteNonQuery();
+
+		//conversion
+		dbcmd.CommandText = "UPDATE jump SET type = 'DJna' WHERE type == 'DJ'";
+		Log.WriteLine(dbcmd.CommandText.ToString());
+		dbcmd.ExecuteNonQuery();
+
+		//delete DJ
+		SqliteJumpType.Delete("DJ", true);
+	}
+
+
 
 	protected internal static void convertTables(Sqlite sqliteObject, string tableName, int columnsBefore, ArrayList columnsToAdd, bool putDescriptionInMiddle) 
 	{
diff --git a/src/sqlite/stat.cs b/src/sqlite/stat.cs
index eb6fda6..8589b7f 100644
--- a/src/sqlite/stat.cs
+++ b/src/sqlite/stat.cs
@@ -1038,6 +1038,7 @@ class SqliteStat : Sqlite
 		return myArray;
 	}
 
+	/*
 	public static ArrayList GlobalNormal (string sessionString, string operation, bool sexSeparated, 
 			int personID, bool heightPreferred)
 	{
@@ -1208,9 +1209,9 @@ class SqliteStat : Sqlite
 			}
 			//weightString = " AND (j1.weight == \"100%\" OR j1.weight == person.weight||'" + "Kg' ) ";
 			weightString = 
-				/* now jump weight is not stores as % or kg and with the '%' or 'kg' after. Is always a %
-				" AND (j1.weight == \"100%\" OR j1.weight == personSessionWeight.weight||'" + "Kg' ) " +
-				*/
+				// now jump weight is not stores as % or kg and with the '%' or 'kg' after. Is always a %
+				//" AND (j1.weight == \"100%\" OR j1.weight == personSessionWeight.weight||'" + "Kg' ) " +
+				
 				" AND j1.weight == \"100\" ";
 			sexColumn = 4;
 		} else {	//IE, IUB
@@ -1290,5 +1291,6 @@ class SqliteStat : Sqlite
 		
 		return myArray;
 	}
+	*/
 
 }
diff --git a/src/stats/global.cs b/src/stats/global.cs
index e2285f4..42a6b90 100644
--- a/src/stats/global.cs
+++ b/src/stats/global.cs
@@ -83,6 +83,7 @@ public class StatGlobal : Stat
 
 	public override void PrepareData() 
 	{
+		/*
 		string sessionString = obtainSessionSqlString(sessions, "jump");
 				
 		//it's better (nicer, cleaner, easier) to leave all the AVGSD as 'false'
@@ -120,6 +121,7 @@ public class StatGlobal : Stat
 					"(9.81*9.81 * tvavg*jumps * time / (4*jumps*(time - tvavg*jumps)) )", "jumpRj",
 					sessionString, operation, showSex, personID),
 				false, sessions.Count );
+				*/
 	
 	}
 



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