/// <summary> /// 测试数据库连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Conn_Click(object sender, RoutedEventArgs e) { dbConn = Common.GetConnStr(dbType, txtUserName, txtPwd, txtHostName, txtPort, txtServerName); if (DataSchema.CheckLink(dbType, dbConn)) { CodeBox.Show("连接成功!", this); } else { CodeBox.Show("连接失败!", this); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Save_Click(object sender, RoutedEventArgs e) { dbConn = Common.GetConnStr(dbType, txtUserName, txtPwd, txtHostName, txtPort, txtServerName); if (!DataSchema.CheckLink(dbType, dbConn)) { CodeBox.Show("连接数据库失败!", this); } else { var buildLink = Common.ControlsToData(dbType, txtHostName, txtUserName, txtPwd, txtPort, txtServerName, labServerName, true, txtLinkName); buildLink.connStr = dbConn; Common.SaveConfigLink(buildLink); AppCache.SetBuildLink(buildLink); this.Owner.Title = string.Format("数据工具-{0}", txtLinkName.Text); AppCache.SetTitle(this.Owner.Title); AppCache.SetOnLine(buildLink); this.Close(); } }