private void btnOpen_Click(object sender, EventArgs e)
 {
     try
     {
         using (OpenFileDialog f = new OpenFileDialog())
         {
             f.FileName         = txtFileName.Text;
             f.AddExtension     = AddExtension;
             f.CheckFileExists  = this.CheckFileExists;
             f.CheckPathExists  = this.CheckPathExists;
             f.Filter           = this.Filter;
             f.RestoreDirectory = false;
             f.DefaultExt       = DefaultExt;
             f.Title            = Title;
             if (f.ShowDialog() == DialogResult.OK)
             {
                 txtFileName.Text = f.FileName;
                 if (FileSelected != null)
                 {
                     FileSelected(this, EventArgs.Empty);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ProgramBase.ShowError(ex);
     }
 }
 private void btnView_Click(object sender, EventArgs e)
 {
     try
     {
         System.Diagnostics.Process.Start(txtDirectory.Text);
     }
     catch (Exception ex)
     {
         ProgramBase.ShowError(ex);
     }
 }
Example #3
0
        public bool Connect(bool showMessage)
        {
            Cursor      = Cursors.WaitCursor;
            IsConnected = false;

            try
            {
                string cs;
                if (IsBuild())
                {
                    var ctrls = controls.ToDictionary(p => p.Control);
                    DbConnectionStringBuilder csb = Database.BuildConnectionString(providerType, ctrls[txtHost].Text, ctrls[txtDatabase].Text, ctrls[txtUserId].Text, ctrls[txtPassword].Text, ctrls[chkIntegSec].Boolean, ctrls[numPort].Integer, ctrls[chkEmbedded].Boolean);
                    cs = csb.ConnectionString;
                }
                else
                {
                    cs = txtConnectionString.Text.Trim();
                }

                if (!string.IsNullOrEmpty(cs))
                {
                    using (var db = new Database(providerType, cs))
                    {
                        db.Open();
                        db.Close();
                    }
                    ViewToData();
                    IsConnected = true;
                }
                else
                {
                    throw new Exception("Invalid connection string");
                }

                if (showMessage)
                {
                    ProgramBase.ShowInformation("Database set up successfully: '" + txtDatabase.Text + "'");
                }
            }
            catch (Exception ex)
            {
                if (showMessage)
                {
                    ProgramBase.ShowError(ex);
                }
                IsConnected = false;
            }
            Cursor = Cursors.Default;
            Draw();
            SetControls();
            return(IsConnected);
        }
 private void btnOpen_Click(object sender, EventArgs e)
 {
     try
     {
         using (FolderBrowserDialog f = new FolderBrowserDialog())
         {
             f.SelectedPath = txtDirectory.Text;
             if (f.ShowDialog() == DialogResult.OK)
             {
                 txtDirectory.Text = f.SelectedPath;
             }
         }
     }
     catch (Exception ex)
     {
         ProgramBase.ShowError(ex);
     }
 }