Esempio n. 1
0
        private void GetTable()
        {
            CreateSQL();

            connection = TestToConnectMySQLServer.OpenConnection(Form2.server, Form2.port, db, Form2.userID, Form2.password);

            if (checkBox1.Checked)
            {
                searchList = TestToConnectMySQLServer.FillData(dbSQLEditor, connection);
            }
            else
            {
                searchList = TestToConnectMySQLServer.FillData(dbSQL, connection);
            }
        }
Esempio n. 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                useSQLEditor = true;
                connection   = TestToConnectMySQLServer.OpenConnection(Form2.server, Form2.port, db, Form2.userID, Form2.password);
            }

            else
            {
                useSQLEditor = false;
            }


            CreateSQL();

            Form5 form5 = new Form5();

            form5.Show();
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
            {
                File.WriteAllText(path_Server, textBox1.Text);
                File.WriteAllText(path_Port, textBox2.Text);
                File.WriteAllText(path_Database, textBox3.Text);



                byte[] userID   = Encoding.UTF8.GetBytes(textBox4.Text);
                byte[] password = Encoding.UTF8.GetBytes(textBox5.Text);

                byte[] entropy = new byte[20];

                using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
                {
                    rng.GetBytes(entropy);
                }

                byte[] cipherUserID   = ProtectedData.Protect(userID, entropy, DataProtectionScope.CurrentUser);
                byte[] cipherPassword = ProtectedData.Protect(password, entropy, DataProtectionScope.CurrentUser);

                File.WriteAllBytes(path_entropy, entropy);
                File.WriteAllBytes(path_UserID, cipherUserID);
                File.WriteAllBytes(path_Password, cipherPassword);
            }

            connection = TestToConnectMySQLServer.OpenConnection(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text);

            try
            {
                string accessPaths = GlobalCryptography.Decrypt(File.ReadAllText(path_access));

                string[] accessPath = accessPaths.Split('\n');

                bool pathExist = false;

                foreach (string _ in accessPath)
                {
                    if (_ == Directory.GetCurrentDirectory())
                    {
                        pathExist = true;
                    }
                }

                if (connection.State == ConnectionState.Open && pathExist)
                {
                    server   = textBox1.Text;
                    port     = textBox2.Text;
                    db       = textBox3.Text;
                    userID   = textBox4.Text;
                    password = textBox5.Text;


                    Hide();

                    Form1 f1 = new Form1();

                    f1.Show();

                    File.AppendAllText(path_logger, DateTime.Now + "|" + WindowsIdentity.GetCurrent().Name + "|" + Environment.MachineName + "|" + Directory.GetCurrentDirectory() + "\n");
                }

                else
                {
                    MessageBox.Show("Current Path is Not Allowed", "Information");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }