コード例 #1
0
        private void InitializeBox(string tableName, string schemaName)
        {
            minRow = 1;
            minCol = 1;
            MySqlDataAdapter data = new MySqlDataAdapter(
                "select count(*) from " + tableName,
                ConnectionStatus.thisConnection);
            DataSet dataSet = new DataSet();

            data.Fill(dataSet);
            DataTable dataTable = dataSet.Tables[0];

            maxRow = (long)dataTable.Rows[0].ItemArray[0];
            data   = new MySqlDataAdapter(
                "select count(*) from information_schema.columns where table_schema='" +
                schemaName + "' and table_name='" + tableName + "'",
                ConnectionStatus.thisConnection);
            dataSet = new DataSet();
            data.Fill(dataSet);
            dataTable = dataSet.Tables[0];
            maxCol    = (long)dataTable.Rows[0].ItemArray[0];
            MySQLOperation mysqlObj    = new MySQLOperation();
            DataTable      columnNames = mysqlObj.GetColumnNames(
                ConnectionStatus.thisConnection, tableName);

            keyCol.Items.Clear();
            for (int i = 0; i < columnNames.Rows.Count; i++)
            {
                var item = columnNames.Rows[i].ItemArray[0];
                keyCol.Items.Add(item);
                colExcList.Add(item);
                ColExc.Items.Add(item);
                ExportData.colExport.Add(item);
            }
        }
コード例 #2
0
        private void Schema_Changed(object sender, EventArgs e)
        {
            TableComboBox.Items.Clear();
            MySQLOperation thisOperation = new MySQLOperation();

            System.Data.DataTable tableNames = thisOperation.GetTableNames(
                ConnectionStatus.thisConnection, SchemaComboBox.Text);
            for (int i = 0; i < tableNames.Rows.Count; i++)
            {
                DataRow row = tableNames.Rows[i];
                TableComboBox.Items.Add(row.ItemArray[0]);
            }
        }
コード例 #3
0
        public ExportData()
        {
            InitializeComponent();
            MySQLOperation thisOperation = new MySQLOperation();

            System.Data.DataTable schemaNames = thisOperation.GetSchemaNames(
                ConnectionStatus.thisConnection);
            for (int i = 0; i < schemaNames.Rows.Count; i++)
            {
                DataRow row = schemaNames.Rows[i];
                SchemaComboBox.Items.Add(row.ItemArray[0]);
            }
        }
コード例 #4
0
        private void QuickConnectItems_Click(object sender, RibbonControlEventArgs e)
        {
            string hostName = e.Control.Id;
            string address, port, user, password, defaultSchema;

            ConnectionStatus.xmlPath = Environment.GetFolderPath(
                Environment.SpecialFolder.Personal) + "\\SEMC_SQL_For_Excel.xml";
            XmlDocument dbInfo = new XmlDocument();

            dbInfo.Load(ConnectionStatus.xmlPath);
            XmlNode root = dbInfo.DocumentElement;

            address = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                            hostName + "']/Address").InnerText;
            port = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                         hostName + "']/Port").InnerText;
            user = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                         hostName + "']/Account").InnerText;
            password = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                             hostName + "']/PWD").InnerText;
            defaultSchema = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
                                                  hostName + "']/DefaultSchema").InnerText;
            password = AESModel.AESHelper.AESDecryptWithVector(
                password, "SEMCWangsese8586", "SEMCWangVector00");
            MySQLOperation mySQLOperation = new MySQLOperation();

            if (mySQLOperation.MakeConnection(
                    hostName, address, user, password, port, defaultSchema))
            {
                System.Windows.Forms.MessageBox.Show("连接成功");
                ConnectionStatus.alive                        = true;
                ConnectionStatus.connectionName               = hostName;
                Globals.Ribbons.Ribbon1.Disconnect.Enabled    = true;
                Globals.Ribbons.Ribbon1.ExportFromSQL.Enabled = true;
                Globals.Ribbons.Ribbon1.ImportInDB.Enabled    = true;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(
                    "连接失败,请检查服务器或网络是否正常!");
            }
        }
コード例 #5
0
        private void ConnectionManagerButtonOK_Click(object sender, EventArgs e)
        {
            string hostName, hostAddress, port, userName, password, defaultSchema;

            hostName      = HostNameComboBox.Text;
            hostAddress   = HostAddressTextBox.Text;
            port          = PortTextBox.Text;
            userName      = UserNameTextBox.Text;
            password      = PasswordTextBox.Text;
            defaultSchema = DefaultSchemaTextBox.Text;
            MySQLOperation newOperation = new MySQLOperation();

            if (hostName != "" && hostAddress != "" && port != "" &&
                userName != "" && password != "")
            {
                if (newOperation.MakeConnection(hostName, hostAddress, userName,
                                                password, port, defaultSchema))
                {
                    ActiveForm.Close();
                    MessageBox.Show("连接成功!");
                    ConnectionStatus.alive                        = true;
                    ConnectionStatus.connectionName               = hostName;
                    Globals.Ribbons.Ribbon1.Disconnect.Enabled    = true;
                    Globals.Ribbons.Ribbon1.ExportFromSQL.Enabled = true;
                    Globals.Ribbons.Ribbon1.ImportInDB.Enabled    = true;
                    password = AESModel.AESHelper.AESEncryptWithVector(password,
                                                                       "SEMCWangsese8586", "SEMCWangVector00");
                    if (newOperation.NewConnection(hostName, hostAddress, userName,
                                                   password, port, defaultSchema))
                    {
                        MessageBox.Show("新连接已存储!");
                    }
                }
                else
                {
                    MessageBox.Show("连接失败,请检查填写是否有误,网络状态或服务器是否正常!");
                }
            }
            return;
        }
コード例 #6
0
 private void QuickConnectItems_Click(object sender, RibbonControlEventArgs e)
 {
     string hostName = e.Control.Id;
     string address, port, user, password, defaultSchema;
     ConnectionStatus.xmlPath = Environment.GetFolderPath(
     Environment.SpecialFolder.Personal) + "\\SEMC_SQL_For_Excel.xml";
     XmlDocument dbInfo = new XmlDocument();
     dbInfo.Load(ConnectionStatus.xmlPath);
     XmlNode root = dbInfo.DocumentElement;
     address = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/Address").InnerText;
     port = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/Port").InnerText;
     user = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/Account").InnerText;
     password = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/PWD").InnerText;
     defaultSchema = root.SelectSingleNode("//DBInfo/DB[@HostName='" +
         hostName + "']/DefaultSchema").InnerText;
     password = AESModel.AESHelper.AESDecryptWithVector(
         password, "SEMCWangsese8586", "SEMCWangVector00");
     MySQLOperation mySQLOperation = new MySQLOperation();
     if(mySQLOperation.MakeConnection(
         hostName, address, user, password, port, defaultSchema))
     {
         System.Windows.Forms.MessageBox.Show("连接成功");
         ConnectionStatus.alive = true;
         ConnectionStatus.connectionName = hostName;
         Globals.Ribbons.Ribbon1.Disconnect.Enabled = true;
         Globals.Ribbons.Ribbon1.ExportFromSQL.Enabled = true;
         Globals.Ribbons.Ribbon1.ImportInDB.Enabled = true;
     }
     else
     {
         System.Windows.Forms.MessageBox.Show(
             "连接失败,请检查服务器或网络是否正常!");
     }
 }
コード例 #7
0
 private void ConnectionManagerButtonOK_Click(object sender, EventArgs e)
 {
     string hostName, hostAddress, port, userName, password, defaultSchema;
     hostName = HostNameComboBox.Text;
     hostAddress = HostAddressTextBox.Text;
     port = PortTextBox.Text;
     userName = UserNameTextBox.Text;
     password = PasswordTextBox.Text;
     defaultSchema = DefaultSchemaTextBox.Text;
     MySQLOperation newOperation = new MySQLOperation();
     if (hostName != "" && hostAddress != "" &&port != "" &&
         userName != "" && password != "")
     {
         if (newOperation.MakeConnection(hostName, hostAddress, userName,
             password,port,defaultSchema))
         {
             ActiveForm.Close();
             MessageBox.Show("连接成功!");
             ConnectionStatus.alive = true;
             ConnectionStatus.connectionName = hostName;
             Globals.Ribbons.Ribbon1.Disconnect.Enabled = true;
             Globals.Ribbons.Ribbon1.ExportFromSQL.Enabled = true;
             Globals.Ribbons.Ribbon1.ImportInDB.Enabled = true;
             password = AESModel.AESHelper.AESEncryptWithVector(password,
                 "SEMCWangsese8586", "SEMCWangVector00");
             if(newOperation.NewConnection(hostName, hostAddress, userName,
                 password, port, defaultSchema))
             {
                 MessageBox.Show("新连接已存储!");
             }
         }
         else
         {
             MessageBox.Show("连接失败,请检查填写是否有误,网络状态或服务器是否正常!");
         }
     }
     return;
 }
コード例 #8
0
 private void InitializeBox(string tableName, string schemaName)
 {
     minRow = 1;
     minCol = 1;
     MySqlDataAdapter data = new MySqlDataAdapter(
         "select count(*) from " + tableName,
         ConnectionStatus.thisConnection);
     DataSet dataSet = new DataSet();
     data.Fill(dataSet);
     DataTable dataTable = dataSet.Tables[0];
     maxRow = (long)dataTable.Rows[0].ItemArray[0];
     data = new MySqlDataAdapter(
         "select count(*) from information_schema.columns where table_schema='" +
         schemaName + "' and table_name='" + tableName + "'",
         ConnectionStatus.thisConnection);
     dataSet = new DataSet();
     data.Fill(dataSet);
     dataTable = dataSet.Tables[0];
     maxCol = (long)dataTable.Rows[0].ItemArray[0];
     MySQLOperation mysqlObj = new MySQLOperation();
     DataTable columnNames = mysqlObj.GetColumnNames(
         ConnectionStatus.thisConnection, tableName);
     keyCol.Items.Clear();
     for (int i = 0; i < columnNames.Rows.Count; i++)
     {
         var item = columnNames.Rows[i].ItemArray[0];
         keyCol.Items.Add(item);
         colExcList.Add(item);
         ColExc.Items.Add(item);
         ExportData.colExport.Add(item);
     }
 }