Add LastDatabase property
This eliminates the need to look at all of the databases on the server, and thus speeds-up startup Get and Save DefaultDB Setting Added DefaultDB Setting
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
//------------------------------------------------------------------------------
 | 
			
		||||
// <auto-generated>
 | 
			
		||||
//     This code was generated by a tool.
 | 
			
		||||
//     Runtime Version:2.0.50727.4211
 | 
			
		||||
//     Runtime Version:2.0.50727.4216
 | 
			
		||||
//
 | 
			
		||||
//     Changes to this file may cause incorrect behavior and will be lost if
 | 
			
		||||
//     the code is regenerated.
 | 
			
		||||
@@ -243,5 +243,17 @@ namespace VEPROMS.Properties {
 | 
			
		||||
                this["QATItems"] = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        [global::System.Configuration.UserScopedSettingAttribute()]
 | 
			
		||||
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
 | 
			
		||||
        [global::System.Configuration.DefaultSettingValueAttribute("")]
 | 
			
		||||
        public string DefaultDB {
 | 
			
		||||
            get {
 | 
			
		||||
                return ((string)(this["DefaultDB"]));
 | 
			
		||||
            }
 | 
			
		||||
            set {
 | 
			
		||||
                this["DefaultDB"] = value;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -59,5 +59,8 @@
 | 
			
		||||
    <Setting Name="QATItems" Type="System.String" Scope="User">
 | 
			
		||||
      <Value Profile="(Default)" />
 | 
			
		||||
    </Setting>
 | 
			
		||||
    <Setting Name="DefaultDB" Type="System.String" Scope="User">
 | 
			
		||||
      <Value Profile="(Default)" />
 | 
			
		||||
    </Setting>
 | 
			
		||||
  </Settings>
 | 
			
		||||
</SettingsFile>
 | 
			
		||||
@@ -174,10 +174,14 @@ namespace VEPROMS
 | 
			
		||||
				if (parameter.StartsWith("/DB="))
 | 
			
		||||
					Database.SelectedDatabase = parameter.Substring(4);
 | 
			
		||||
			}
 | 
			
		||||
			if (Properties.Settings.Default["DefaultDB"] != string.Empty)
 | 
			
		||||
				Database.LastDatabase = Properties.Settings.Default.DefaultDB;
 | 
			
		||||
			if (!FormatInfo.HasLatestChanges())
 | 
			
		||||
				throw new Exception("Inconsistent Formats");
 | 
			
		||||
			if (!ItemAuditInfo.IsChangeManagerVersion())
 | 
			
		||||
				throw new Exception("Inconsistent Data");
 | 
			
		||||
			Properties.Settings.Default.DefaultDB = Database.SelectedDatabase;
 | 
			
		||||
			Properties.Settings.Default.Save();
 | 
			
		||||
			VETreeNode tn = VETreeNode.GetFolder(1);
 | 
			
		||||
			tv.Nodes.Add(tn);
 | 
			
		||||
			tv.NodePSI += new vlnTreeViewPSIEvent(tv_NodePSI);
 | 
			
		||||
 
 | 
			
		||||
@@ -96,13 +96,36 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
			set { _VEPROMS_Connection = value; }
 | 
			
		||||
		}
 | 
			
		||||
		private static string _SelectedDatabase;
 | 
			
		||||
 | 
			
		||||
		public static string SelectedDatabase
 | 
			
		||||
		{
 | 
			
		||||
			get { return Database._SelectedDatabase; }
 | 
			
		||||
			set { Database._SelectedDatabase = value; }
 | 
			
		||||
		}
 | 
			
		||||
		private static string _LastDatabase="NoDefault";
 | 
			
		||||
		public static string LastDatabase
 | 
			
		||||
		{
 | 
			
		||||
			get { return Database._LastDatabase; }
 | 
			
		||||
			set { Database._LastDatabase = value; }
 | 
			
		||||
		}
 | 
			
		||||
		private static string ChooseDatabase(string constr)
 | 
			
		||||
		{
 | 
			
		||||
			if (LastDatabase != "NoDefault" && LastDatabase != "")
 | 
			
		||||
			{
 | 
			
		||||
				if (System.Windows.Forms.MessageBox.Show("Open " + LastDatabase, "Reopen Last Database", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
 | 
			
		||||
				{
 | 
			
		||||
					SelectedDatabase = LastDatabase;
 | 
			
		||||
					return constr.Replace("{MENU}", _SelectedDatabase);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			System.Windows.Forms.ContextMenuStrip cms = BuildDatabaseMenu(constr);
 | 
			
		||||
			while (_SelectedDatabase == null)
 | 
			
		||||
			{
 | 
			
		||||
				cms.Show(new System.Drawing.Point((System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - cms.Width) / 2, (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - cms.Height) / 2));
 | 
			
		||||
				System.Windows.Forms.Application.DoEvents();
 | 
			
		||||
			}
 | 
			
		||||
			return constr.Replace("{MENU}", _SelectedDatabase);
 | 
			
		||||
		}
 | 
			
		||||
		private static System.Windows.Forms.ContextMenuStrip BuildDatabaseMenu(string constr)
 | 
			
		||||
		{
 | 
			
		||||
			string tmp = constr.Replace("{MENU}", "master");
 | 
			
		||||
			SqlConnection cn = new SqlConnection(tmp);
 | 
			
		||||
@@ -123,12 +146,7 @@ namespace VEPROMS.CSLA.Library
 | 
			
		||||
				if (dr["functionality"].ToString() == "Approval")
 | 
			
		||||
					cms.Items.Add(dr["name"].ToString(), null, new EventHandler(Database_Click));
 | 
			
		||||
			}
 | 
			
		||||
			while (_SelectedDatabase == null)
 | 
			
		||||
			{
 | 
			
		||||
				cms.Show(new System.Drawing.Point((System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width - cms.Width) / 2, (System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - cms.Height) / 2));
 | 
			
		||||
				System.Windows.Forms.Application.DoEvents();
 | 
			
		||||
			}
 | 
			
		||||
			return constr.Replace("{MENU}", _SelectedDatabase);
 | 
			
		||||
			return cms;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		static void Database_Click(object sender, EventArgs e)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user