示例#1
0
        private void AddConnection(bool isSource, string type)
        {
            if (string.IsNullOrEmpty(type))
            {
                MessageBox.Show("Please select database type.");
                return;
            }

            DatabaseType dbType       = this.DatabaseType;
            frmDbConnect frmDbConnect = new frmDbConnect(dbType);

            if (this.SetConnectionInfo(frmDbConnect))
            {
                this.LoadProfileNames(frmDbConnect.ProflieName);
            }
        }
示例#2
0
        private bool SetConnectionInfo(frmDbConnect frmDbConnect)
        {
            DialogResult dialogResult = frmDbConnect.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                ConnectionInfo connectionInfo = frmDbConnect.ConnectionInfo;
                this.connectionInfo = connectionInfo;

                if (this.OnSelectedChanged != null)
                {
                    this.OnSelectedChanged(this, connectionInfo);
                }

                return(true);
            }
            return(false);
        }
示例#3
0
        private bool CheckConnection()
        {
            if (this.displayInfo.ConnectionInfo == null)
            {
                frmDbConnect dbConnect = new frmDbConnect(this.displayInfo.DatabaseType)
                {
                    NotUseProfile = true
                };
                if (dbConnect.ShowDialog() == DialogResult.OK)
                {
                    this.displayInfo.ConnectionInfo = dbConnect.ConnectionInfo;
                }
            }

            if (this.displayInfo.ConnectionInfo != null && !string.IsNullOrEmpty(this.displayInfo.ConnectionInfo.Database))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        public void ConfigConnection(bool requriePassword = false)
        {
            string type                   = this.cboDbType.Text;
            object selectedItem           = this.cboDbProfile.SelectedItem;
            ConnectionProfileInfo profile = selectedItem as ConnectionProfileInfo;
            string profileName            = selectedItem == null ? string.Empty : profile?.Name;

            if (string.IsNullOrEmpty(type))
            {
                MessageBox.Show("Please select database type.");
                return;
            }

            if (string.IsNullOrEmpty(profileName))
            {
                MessageBox.Show("Please select a profile.");
                return;
            }

            DatabaseType dbType = this.DatabaseType;
            frmDbConnect from   = new frmDbConnect(dbType, profileName, requriePassword);

            from.ConnectionInfo = profile?.ConnectionInfo;

            this.SetConnectionInfo(from);

            if (profileName != from.ProflieName)
            {
                this.LoadProfileNames(from.ProflieName);
            }

            if (this.cboDbProfile.SelectedItem != null)
            {
                (this.cboDbProfile.SelectedItem as ConnectionProfileInfo).ConnectionInfo = from.ConnectionInfo;
            }
        }