/*This method is invoked when you first start the application ,
         * and through a messagebox asking you if you want to create a database file. sdf
         * If the user decides to create the file will create an instance of the class ContactDataContext 
         * with the corresponding parameter of the path given by the FileName property of the control SaveFileDialog 
         * for connecting and using the method CreateDatabase will create the Database with related tables mapped i
         * nside of the file Contact.dbml of LinqToSql.
         * Will be valued the variable path and settings saved and passed as a parameter each 
         * time and request connection to the Database Created
         */
        public static void CreateFirstDataBase()
        {
            var dialog = new SaveFileDialog();
            dialog.Filter = "File sdf|*.sdf";


            if (System.Windows.Forms.MessageBox.Show(string.Format("{0}{1}{2}{3}{4}", "File",
                    "  ", Properties.Settings.Default.path, "  ", "not found ,want to create the file?"),
                     System.Windows.Forms.Application.ProductName.ToString(), MessageBoxButtons.YesNo,
                     MessageBoxIcon.Question).Equals(System.Windows.Forms.DialogResult.Yes) &&
                dialog.ShowDialog().Equals(System.Windows.Forms.DialogResult.OK))
            {
                using (var ctx = new ContactDataContext(dialog.FileName))
                {
                    ctx.CreateDatabase();
                    Properties.Settings.Default.path = dialog.FileName;
                    Properties.Settings.Default.Save();
                }
            }
        }
        /*This method and is nearly similar to the previous method, except that the user can decide when to create a new database, 
         * this method is not called the first time.
         */
        public static void CreateNewDataBase()
        {
            var dialog = new SaveFileDialog();
            dialog.Filter = "File sdf|*.sdf";
            var dialogresult = dialog.ShowDialog();

            if (dialogresult.Equals(System.Windows.Forms.DialogResult.Cancel)) return;

            if (dialogresult.Equals(System.Windows.Forms.DialogResult.OK) && (!System.IO.File.Exists(dialog.FileName)))
            {
                using (var ctx = new ContactDataContext(dialog.FileName))
                {
                    ctx.CreateDatabase();
                    Properties.Settings.Default.path = dialog.FileName;
                    Properties.Settings.Default.Save();
                }
                return;
            }

            System.Windows.Forms.MessageBox.Show(string.Format("{0}{1}{2}{3}{4}{5}", "File", "  "
                , dialog.FileName, "  ", "already exsist", "  ", "choose a different name"));
        }