private void LoadSettings() { if (new FileInfo(ConfigPathname).Exists) { DBRefConfigSetting xDS = new DBRefConfigSetting(); xDS.ReadXml(ConfigPathname, System.Data.XmlReadMode.IgnoreSchema); if (xDS.MESRefDBType.Rows.Count > 0) { DBRefConfigSetting.MESRefDBTypeRow dRow = xDS.MESRefDBType[0]; if (!dRow.IsTypeNull()) { this.tabControl1.SelectedIndex = dRow.Type; } } if (xDS.MSSQLServer.Rows.Count > 0) { DBRefConfigSetting.MSSQLServerRow xRow = xDS.MSSQLServer[0]; if (!xRow.IsServerNameNull()) { comboBox_Server.Text = xRow.ServerName; } if (!xRow.IsDBNameNull()) { comboBox_DB.Text = xRow.DBName; } if (!xRow.IsUserIDNull()) { textBox_UserName.Text = xRow.UserID; } if (!xRow.IsPassWordNull()) { textBox_Password.Text = xRow.PassWord; } if (!xRow.IsConnectTypeNull()) { comboBox_Protocol.SelectedIndex = xRow.ConnectType - 1; } if (!xRow.IsPortIDNull()) { textBox_PortID.Text = xRow.PortID; } } if (xDS.Oracle.Rows.Count > 0) { DBRefConfigSetting.OracleRow oRow = xDS.Oracle[0]; if (!oRow.IsServerNameNull()) { comboBox_OracleServer.Text = oRow.ServerName; } if (!oRow.IsUserIDNull()) { textBox_OracleUserID.Text = oRow.UserID; } if (!oRow.IsPassWordNull()) { textBox_OracleUserPass.Text = oRow.PassWord; } if (!oRow.IsConnectAsNull()) { comboBox_ConnectAs.Text = oRow.ConnectAs; } if (!oRow.IsConnectModeNull()) { comboBox_ConnectMode.Text = oRow.ConnectMode; } if (!oRow.IsHomeNull()) { comboBox_OracleHome.Text = oRow.Home; } if (!oRow.IsSIDNull()) { comboBox_SID.Text = oRow.SID; } if (!oRow.IsPortIDNull()) { textBox_OracleProtID.Text = oRow.PortID; } if (!oRow.IsOwnerNull()) { textBox_Owner.Text = oRow.Owner; } if (!oRow.IsDirectNull()) { this.checkBox_Direct.Checked = oRow.Direct; } } if (xDS.MSAccess.Rows.Count > 0) { DBRefConfigSetting.MSAccessRow aRow = xDS.MSAccess[0]; if (!aRow.IsDBPathNull()) { textBox_MSAccessPath.Text = aRow.DBPath; } if (!aRow.IsUserIDNull()) { textBox_MSAccessUID.Text = aRow.UserID; } if (!aRow.IsPassWordNull()) { textBox_MSAccessPass.Text = aRow.PassWord; } } if (xDS.OleDB.Rows.Count > 0) { DBRefConfigSetting.OleDBDataTable aRowTable = xDS.OleDB; foreach (DBRefConfigSetting.OleDBRow aRow in aRowTable) { this.comboBox_ConnectString.Items.Add(aRow.ConnectString); } DBRefConfigSetting.OleDBRow oleRow = xDS.OleDB[0]; this.comboBox_ConnectString.SelectedIndex = oleRow.Selected; } } }
private void SaveSettings() { DBRefConfigSetting xDS = new DBRefConfigSetting(); DBRefConfigSetting.MESRefDBTypeRow dRow = xDS.MESRefDBType.NewMESRefDBTypeRow(); dRow.Type = this.tabControl1.SelectedIndex; xDS.MESRefDBType.AddMESRefDBTypeRow(dRow); DBRefConfigSetting.MSSQLServerRow mRow = xDS.MSSQLServer.NewMSSQLServerRow(); string myServerName = comboBox_Server.Text.Trim(); string myDBName = comboBox_DB.Text.Trim(); string userId = textBox_UserName.Text.Trim(); string passWord = textBox_Password.Text.Trim(); int ConnectType = comboBox_Protocol.SelectedIndex + 1; string portID = textBox_PortID.Text; mRow.ServerName = myServerName; mRow.DBName = myDBName; mRow.UserID = userId; mRow.PassWord = passWord; mRow.ConnectType = ConnectType; mRow.PortID = portID; xDS.MSSQLServer.AddMSSQLServerRow(mRow); DBRefConfigSetting.OracleRow oRow = xDS.Oracle.NewOracleRow(); string OracleServerName = comboBox_OracleServer.Text.Trim(); string OracleUserId = textBox_OracleUserID.Text.Trim(); string OraclePassWord = textBox_OracleUserPass.Text.Trim(); string OracleConnectAs = comboBox_ConnectAs.Text.Trim(); string OracleConnectMode = comboBox_ConnectMode.Text.Trim(); string OracleHome = comboBox_OracleHome.Text.Trim(); string OracleSID = comboBox_SID.Text.Trim(); string OraclePortID = textBox_OracleProtID.Text.Trim(); string OracleOwner = textBox_Owner.Text.Trim(); bool OracleDirect = checkBox_Direct.Checked; oRow.ServerName = OracleServerName; oRow.UserID = OracleUserId; oRow.PassWord = OraclePassWord; oRow.ConnectAs = OracleConnectAs; oRow.ConnectMode = OracleConnectMode; oRow.Home = OracleHome; oRow.Direct = OracleDirect; oRow.SID = OracleSID; oRow.PortID = OraclePortID; oRow.Owner = OracleOwner; xDS.Oracle.AddOracleRow(oRow); DBRefConfigSetting.MSAccessRow aRow = xDS.MSAccess.NewMSAccessRow(); string strMSAcessDBPath = textBox_MSAccessPath.Text.Trim(); string strMSAcessUserId = textBox_MSAccessUID.Text.Trim(); string strMSAcessPassWord = textBox_MSAccessPass.Text.Trim(); aRow.DBPath = strMSAcessDBPath; aRow.UserID = strMSAcessUserId; aRow.PassWord = strMSAcessPassWord; xDS.MSAccess.AddMSAccessRow(aRow); if (this.comboBox_ConnectString.Items.Count > 0) { foreach (var item in this.comboBox_ConnectString.Items) { DBRefConfigSetting.OleDBRow oleRow = xDS.OleDB.NewOleDBRow(); oleRow.ConnectString = item.ToString(); xDS.OleDB.AddOleDBRow(oleRow); } xDS.OleDB[0].Selected = this.comboBox_ConnectString.SelectedIndex; } xDS.WriteXml(ConfigPathname, System.Data.XmlWriteMode.IgnoreSchema); }