⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connectionset.cs

📁 数据集导出到EXCEL文件接口程序
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace DataExport
{
    public partial class ConnectionSet : Form
    {
        public ConnectionSet()
        {
            InitializeComponent();

            this.ServiceNameTB.Text = DataExport.m_serverName;
            this.UserNameTB.Text = DataExport.m_userName;
            this.PasswardTB.Text = DataExport.m_passward;
        }

        private void AlterConnectionBT_Click(object sender, EventArgs e)
        {
            if (this.ServiceNameTB.Text == "" )
            {
                MessageBox.Show("请输入服务名!");
                return;
            }
            if (this.UserNameTB.Text == "")
            {
                MessageBox.Show("请输入用户名!");
                return;
            }
            if ( this.PasswardTB.Text == "")
            {
                MessageBox.Show("请输入密码!");
                return;
            }

            try
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                if (config.AppSettings.Settings["ServerName"] == null)
                {
                    config.AppSettings.Settings.Add("ServerName", this.ServiceNameTB.Text);
                    config.Save(ConfigurationSaveMode.Full);
                }
                else
                {
                    config.AppSettings.Settings.Remove("ServerName");
                    config.AppSettings.Settings.Add("ServerName", this.ServiceNameTB.Text);
                    config.Save(ConfigurationSaveMode.Full);
                }

                if (config.AppSettings.Settings["UserName"] == null)
                {
                    config.AppSettings.Settings.Add("UserName", this.UserNameTB.Text);
                    config.Save(ConfigurationSaveMode.Full);
                }
                else
                {
                    config.AppSettings.Settings.Remove("UserName");
                    config.AppSettings.Settings.Add("UserName", this.UserNameTB.Text);
                    config.Save(ConfigurationSaveMode.Full);
                }

                if (config.AppSettings.Settings["Passward"] == null)
                {
                    config.AppSettings.Settings.Add("Passward", this.PasswardTB.Text);
                    config.Save(ConfigurationSaveMode.Full);
                }
                else
                {
                    config.AppSettings.Settings.Remove("Passward");
                    config.AppSettings.Settings.Add("Passward", this.PasswardTB.Text);
                    config.Save(ConfigurationSaveMode.Full);
                }

                DataExport.ChangeCnnectionSet(this.ServiceNameTB.Text, this.UserNameTB.Text, this.PasswardTB.Text);

                MessageBox.Show("修改成功!");

            }
            catch (Exception ex)
            {
                MessageBox.Show("连接设置失败!" + ex.Message, "提示:");
                return;
            }

            this.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -