Ejemplo n.º 1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            dbConn = BaseLink.GetConnStr(dbType, txtUserName, txtPwd, txtHostName, txtPort, txtServerName);

            if (!BaseLink.CheckLink(dbType, dbConn))
            {
                CodeBox.Show("连接数据库失败!", this);
            }
            else
            {
                var buildLink = BaseLink.ControlsToData(dbType, txtHostName, txtUserName, txtPwd, txtPort, txtServerName, labServerName, true, txtLinkName);
                buildLink.LinkName = buildLink.LinkName == "" ? BaseLink.GetLinkName(buildLink) : buildLink.LinkName;
                buildLink.Id       = Guid.NewGuid().ToString();
                AppCache.SetLink(buildLink);

                if (FastRead.Query <Data_Source>(a => a.LinkName == buildLink.LinkName).ToCount() == 1)
                {
                    FastWrite.Update <Data_Source>(buildLink, a => a.LinkName == buildLink.LinkName,
                                                   a => new { a.Host, a.PassWord, a.Port, a.ServerName, a.Type, a.UserName });
                }
                else
                {
                    FastWrite.Add(buildLink);
                }

                CodeBox.Show("连接数据库成功!", this);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 测试数据库连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Conn_Click(object sender, RoutedEventArgs e)
        {
            dbConn = BaseLink.GetConnStr(dbType, txtUserName, txtPwd, txtHostName, txtPort, txtServerName);

            if (BaseLink.CheckLink(dbType, dbConn))
            {
                CodeBox.Show("连接成功!", this);
            }
            else
            {
                CodeBox.Show("连接失败!", this);
            }
        }