private void button_editSqlDef_Click(object sender, EventArgs e) { string strError = ""; if (this.comboBox_sqlServerType.Text == "SQLite") { SqliteDataSourceDlg datasource_dlg = new SqliteDataSourceDlg(); GuiUtil.AutoSetDefaultFont(datasource_dlg); datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于内置的 SQLite 实现,不再需要任何其他数据库底层软件。请设置下列 SQLite 相关参数。"; if (this.LineInfo != null) { datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName; } else { datasource_dlg.InstanceName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; // 应当没有空格和特殊字符 } datasource_dlg.StartPosition = FormStartPosition.CenterScreen; datasource_dlg.ShowDialog(this); if (datasource_dlg.DialogResult != DialogResult.OK) return; if (this.LineInfo == null) this.LineInfo = new LineInfo(); this.LineInfo.SqlServerType = "SQLite"; this.LineInfo.SqlServerName = "~sqlite"; this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName; this.LineInfo.DatabaseLoginName = ""; this.LineInfo.DatabaseLoginPassword = ""; RefreshSqlDef(); } else if (this.comboBox_sqlServerType.Text == "MS SQL Server") { // MS SQL Server // 调对话框得到数据源配置参数 MsSqlServerDataSourceDlg datasource_dlg = new MsSqlServerDataSourceDlg(); GuiUtil.AutoSetDefaultFont(datasource_dlg); datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MS SQL Server 2000 以上版本实现。请设置下列 SQL Server 相关参数。"; if (this.LineInfo != null) { datasource_dlg.SqlServerName = this.LineInfo.SqlServerName; datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName; datasource_dlg.KernelLoginName = this.LineInfo.DatabaseLoginName; datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword; } else { datasource_dlg.SqlServerName = ""; datasource_dlg.InstanceName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; // 应当没有空格和特殊字符 datasource_dlg.KernelLoginName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; datasource_dlg.KernelLoginPassword = ""; } datasource_dlg.StartPosition = FormStartPosition.CenterScreen; datasource_dlg.ShowDialog(this); if (datasource_dlg.DialogResult != DialogResult.OK) return; if (this.LineInfo == null) this.LineInfo = new LineInfo(); this.LineInfo.SqlServerType = "MS SQL Server"; this.LineInfo.SqlServerName = datasource_dlg.SqlServerName; this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName; this.LineInfo.DatabaseLoginName = datasource_dlg.KernelLoginName; this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword; RefreshSqlDef(); } else if (this.comboBox_sqlServerType.Text == "MySQL Server") { // MySQL Server // 调对话框得到数据源配置参数 MySqlDataSourceDlg datasource_dlg = new MySqlDataSourceDlg(); GuiUtil.AutoSetDefaultFont(datasource_dlg); datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MySQL Server 5.5 以上版本实现。请设置下列 MySQL Server 相关参数。"; if (this.LineInfo != null) { datasource_dlg.SqlServerName = this.LineInfo.SqlServerName; datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName; datasource_dlg.KernelLoginName = this.LineInfo.DatabaseLoginName; datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword; } else { datasource_dlg.SqlServerName = ""; datasource_dlg.InstanceName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; // 应当没有空格和特殊字符 datasource_dlg.KernelLoginName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; datasource_dlg.KernelLoginPassword = ""; } datasource_dlg.StartPosition = FormStartPosition.CenterScreen; datasource_dlg.ShowDialog(this); if (datasource_dlg.DialogResult != DialogResult.OK) return; if (this.LineInfo == null) this.LineInfo = new LineInfo(); this.LineInfo.SqlServerType = "MySQL Server"; this.LineInfo.SqlServerName = datasource_dlg.SqlServerName; this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName; this.LineInfo.DatabaseLoginName = datasource_dlg.KernelLoginName; this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword; RefreshSqlDef(); } else if (this.comboBox_sqlServerType.Text == "Oracle") { // Oracle // 调对话框得到数据源配置参数 OracleDataSourceDlg datasource_dlg = new OracleDataSourceDlg(); GuiUtil.AutoSetDefaultFont(datasource_dlg); datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 Oracle 11g 以上版本实现。请设置下列 Oracle 相关参数。"; if (this.LineInfo != null) { datasource_dlg.SqlServerName = this.LineInfo.SqlServerName; // datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName; datasource_dlg.KernelLoginName = this.LineInfo.DatabaseLoginName; datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword; } else { datasource_dlg.SqlServerName = ""; /* datasource_dlg.InstanceName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; // 应当没有空格和特殊字符 * */ datasource_dlg.KernelLoginName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; datasource_dlg.KernelLoginPassword = ""; } datasource_dlg.StartPosition = FormStartPosition.CenterScreen; datasource_dlg.ShowDialog(this); if (datasource_dlg.DialogResult != DialogResult.OK) return; if (this.LineInfo == null) this.LineInfo = new LineInfo(); this.LineInfo.SqlServerType = "Oracle"; this.LineInfo.SqlServerName = datasource_dlg.SqlServerName; this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName; this.LineInfo.DatabaseLoginName = datasource_dlg.KernelLoginName; this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword; RefreshSqlDef(); } else { strError = "未知的 SQL 服务器类型 '" + this.comboBox_sqlServerType.Text + "'"; goto ERROR1; } return; ERROR1: MessageBox.Show(this, strError); return; }
private void button_editSqlDef_Click(object sender, EventArgs e) { string strError = ""; if (this.comboBox_sqlServerType.Text == "SQLite") { SqliteDataSourceDlg datasource_dlg = new SqliteDataSourceDlg(); GuiUtil.AutoSetDefaultFont(datasource_dlg); datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于内置的 SQLite 实现,不再需要任何其他数据库底层软件。请设置下列 SQLite 相关参数。"; if (this.LineInfo != null) { datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName; } else { datasource_dlg.InstanceName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; // 应当没有空格和特殊字符 } datasource_dlg.StartPosition = FormStartPosition.CenterScreen; datasource_dlg.ShowDialog(this); if (datasource_dlg.DialogResult != DialogResult.OK) { return; } if (this.LineInfo == null) { this.LineInfo = new LineInfo(); } this.LineInfo.SqlServerType = "SQLite"; this.LineInfo.SqlServerName = "~sqlite"; this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName; this.LineInfo.DatabaseLoginName = ""; this.LineInfo.DatabaseLoginPassword = ""; RefreshSqlDef(); } else if (this.comboBox_sqlServerType.Text == "MS SQL Server") { // MS SQL Server // 调对话框得到数据源配置参数 MsSqlServerDataSourceDlg datasource_dlg = new MsSqlServerDataSourceDlg(); GuiUtil.AutoSetDefaultFont(datasource_dlg); datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MS SQL Server 2000 以上版本实现。请设置下列 SQL Server 相关参数。"; if (this.LineInfo != null) { datasource_dlg.SqlServerName = this.LineInfo.SqlServerName; datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName; datasource_dlg.KernelLoginName = this.LineInfo.DatabaseLoginName; datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword; } else { datasource_dlg.SqlServerName = ""; datasource_dlg.InstanceName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; // 应当没有空格和特殊字符 datasource_dlg.KernelLoginName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; datasource_dlg.KernelLoginPassword = ""; } datasource_dlg.StartPosition = FormStartPosition.CenterScreen; datasource_dlg.ShowDialog(this); if (datasource_dlg.DialogResult != DialogResult.OK) { return; } if (this.LineInfo == null) { this.LineInfo = new LineInfo(); } this.LineInfo.SqlServerType = "MS SQL Server"; this.LineInfo.SqlServerName = datasource_dlg.SqlServerName; this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName; this.LineInfo.DatabaseLoginName = datasource_dlg.KernelLoginName; this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword; RefreshSqlDef(); } else if (this.comboBox_sqlServerType.Text == "MySQL Server") { // MySQL Server // 调对话框得到数据源配置参数 MySqlDataSourceDlg datasource_dlg = new MySqlDataSourceDlg(); GuiUtil.AutoSetDefaultFont(datasource_dlg); datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 MySQL Server 5.5 以上版本实现。请设置下列 MySQL Server 相关参数。"; if (this.LineInfo != null) { datasource_dlg.SqlServerName = this.LineInfo.SqlServerName; datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName; datasource_dlg.KernelLoginName = this.LineInfo.DatabaseLoginName; datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword; } else { datasource_dlg.SqlServerName = ""; datasource_dlg.InstanceName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; // 应当没有空格和特殊字符 datasource_dlg.KernelLoginName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; datasource_dlg.KernelLoginPassword = ""; } datasource_dlg.StartPosition = FormStartPosition.CenterScreen; datasource_dlg.ShowDialog(this); if (datasource_dlg.DialogResult != DialogResult.OK) { return; } if (this.LineInfo == null) { this.LineInfo = new LineInfo(); } this.LineInfo.SqlServerType = "MySQL Server"; this.LineInfo.SqlServerName = datasource_dlg.SqlServerName; this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName; this.LineInfo.DatabaseLoginName = datasource_dlg.KernelLoginName; this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword; RefreshSqlDef(); } else if (this.comboBox_sqlServerType.Text == "Oracle") { // Oracle // 调对话框得到数据源配置参数 OracleDataSourceDlg datasource_dlg = new OracleDataSourceDlg(); GuiUtil.AutoSetDefaultFont(datasource_dlg); datasource_dlg.Comment = "dp2Kernel 内核的数据库功能可以基于 Oracle 11g 以上版本实现。请设置下列 Oracle 相关参数。"; if (this.LineInfo != null) { datasource_dlg.SqlServerName = this.LineInfo.SqlServerName; // datasource_dlg.InstanceName = this.LineInfo.DatabaseInstanceName; datasource_dlg.KernelLoginName = this.LineInfo.DatabaseLoginName; datasource_dlg.KernelLoginPassword = this.LineInfo.DatabaseLoginPassword; } else { datasource_dlg.SqlServerName = ""; /* * datasource_dlg.InstanceName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; // 应当没有空格和特殊字符 * */ datasource_dlg.KernelLoginName = "dp2kernel" + (String.IsNullOrEmpty(this.InstanceName) == false ? "_" : "") + this.InstanceName; datasource_dlg.KernelLoginPassword = ""; } datasource_dlg.StartPosition = FormStartPosition.CenterScreen; datasource_dlg.ShowDialog(this); if (datasource_dlg.DialogResult != DialogResult.OK) { return; } if (this.LineInfo == null) { this.LineInfo = new LineInfo(); } this.LineInfo.SqlServerType = "Oracle"; this.LineInfo.SqlServerName = datasource_dlg.SqlServerName; this.LineInfo.DatabaseInstanceName = datasource_dlg.InstanceName; this.LineInfo.DatabaseLoginName = datasource_dlg.KernelLoginName; this.LineInfo.DatabaseLoginPassword = datasource_dlg.KernelLoginPassword; RefreshSqlDef(); } else { strError = "未知的 SQL 服务器类型 '" + this.comboBox_sqlServerType.Text + "'"; goto ERROR1; } return; ERROR1: MessageBox.Show(this, strError); return; }