public bool SaveConfig() { if (m_currentConfig != null) { m_currentDBConfig = m_currentConfig.GetConfig(); m_currentDBConfig.DisplayNull = chkDisplayNull.Checked; m_currentDBConfig.UserFieldName = txtUserFieldName.Text; m_currentDBConfig.TraceUser = txtUser.Text; XmlNode node = GetDBTypeNode(m_currentDBConfig.DbType); //替换默认属性类型 XmlNode root = node.ParentNode; root.Attributes.RemoveNamedItem("default"); //取值,创建属性对象 var type = node.Attributes["type"].Value; var attr = root.OwnerDocument.CreateAttribute("default"); attr.Value = type; //添加属性 root.Attributes.Append(attr); m_currentDBConfig.SaveToNode(node); m_doc.Save(Path.Combine(Application.StartupPath, "dbviewerconfig.xml")); Util.ShowMessage("保存成功."); return(true); } else { Util.ShowMessage("请选择数据库类型."); return(false); } }
private void cmbDBType_SelectionChanged(object sender, SelectionChangedEventArgs e) { m_doc = new XmlDocument(); m_doc.Load("dbviewerconfig.xml"); EnumDBType enuDBType; switch (cmbDBType.SelectedIndex) { case 0: //SQL Server enuDBType = EnumDBType.SQLServer; txtServer.Visibility = Visibility.Visible; lblServer.Visibility = Visibility.Visible; break; case 1: enuDBType = EnumDBType.Oracle; txtServer.Visibility = Visibility.Hidden; lblServer.Visibility = Visibility.Hidden; break; default: return; } m_currentDBConfig = DBViewerConfig.Create(GetDBTypeNode(enuDBType)); txtServer.Text = m_currentDBConfig.Server; txtDBName.Text = m_currentDBConfig.DbName; txtDBUser.Text = m_currentDBConfig.User; txtPassword.Text = m_currentDBConfig.Password; chkDisplayNull.IsChecked = m_currentDBConfig.DisplayNull; txtUserFieldName.Text = m_currentDBConfig.UserFieldName; txtUser.Text = m_currentDBConfig.TraceUser; }
private void RefreshData() { string fileName = GetConfigFileName(); DBViewerConfig config = ConfigService.GetConfig(fileName); DataTable table = m_currentModel.GetTraceData(config.TraceUser, DateTime.Today.AddDays(-2)); this.changeListViewer1.Table = table; }
private Control GetPanelControl(EnumDBType enuDBType) { m_currentConfig = ConfigService.CreateConfigModel(enuDBType); m_currentDBConfig = DBViewerConfig.Create(GetDBTypeNode(enuDBType)); Control ctl = m_currentConfig.GetConfigPanel(m_currentDBConfig); return(ctl); }
private void btnClear_Click(object sender, EventArgs e) { string fileName = GetConfigFileName(); DBViewerConfig config = ConfigService.GetConfig(fileName); m_currentModel.ClearTraceData(config.TraceUser); RefreshData(); }
public Control GetConfigPanel(DBViewerConfig config) { if (m_ctl == null) { m_ctl = new ConnectionConfig(); } m_ctl.Config = config; return(m_ctl); }
public ConnectionManager(DBViewerConfig config) { this.config = config; }