예제 #1
0
        private void bSave_Click(object sender, EventArgs e)
        {
            firedumpdbDataSetTableAdapters.sql_serversTableAdapter adapter = new firedumpdbDataSetTableAdapters.sql_serversTableAdapter();
            if (string.IsNullOrEmpty(tbName.Text))
            {
                MessageBox.Show("Type a name for the new server", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if ((Int64)adapter.numberOfOccurances(tbName.Text) == 0 || isUpdate)
            {
                if (!performChecks())
                {
                    return;
                }
                sqlservers server = createMySqlServerInfoCreds();
                String     passwd = EncryptionUtils.sEncrypt(server.password);
                string     path   = null;
                DbType     type   = Firedump.core.sql.Utils._convert(((ToolStripItemDbType)this.comboBoxDbTypes.SelectedItem).db_type);
                if (Firedump.core.sql.Utils.IsDbEmbedded(type))
                {
                    path = textBoxPath.Text;
                }
                if (isUpdate)
                {
                    adapter.UpdateMySqlServerById(tbName.Text, server.port, server.host, server.username, passwd, tbDatabase.Text, mysqlserver.id);
                }
                else
                {
                    adapter.InsertQuery(tbName.Text, server.port, server.host, server.username, passwd, tbDatabase.Text, (int)type, path);
                }
                int id = Convert.ToInt32((Int64)adapter.GetIdByName(tbName.Text));
                onReloadServerData(id);
                this.Close();
                return;
            }


            MessageBox.Show("Name " + tbName.Text + " already exists", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            tbPassword.Text = "";
            tbName.Text     = "";
            isUpdate        = false;
        }
예제 #2
0
        private void bSave_Click(object sender, EventArgs e)
        {
            firedumpdbDataSetTableAdapters.sql_serversTableAdapter adapter = new firedumpdbDataSetTableAdapters.sql_serversTableAdapter();
            if (string.IsNullOrEmpty(tbName.Text))
            {
                MessageBox.Show("Type a name for the new server", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if ((Int64)adapter.numberOfOccurances(tbName.Text) == 0 || isUpdate)
            {
                if (!performChecks())
                {
                    return;
                }
                sqlservers server = createMySqlServerInfoCreds();
                String     passwd = EncryptionUtils.sEncrypt(server.password);
                if (isUpdate)
                {
                    adapter.UpdateMySqlServerById(tbName.Text, server.port, server.host, server.username, passwd, tbDatabase.Text, mysqlserver.id);
                }
                else
                {
                    adapter.InsertQuery(tbName.Text, server.port, server.host, server.username, passwd, tbDatabase.Text, 0); //prepei na bei kai
                }
                //adapter.Insert(tbName.Text, server.port, server.host, server.username, server.password, tbDatabase.Text); //prepei na bei kai database
                int id = Convert.ToInt32((Int64)adapter.GetIdByName(tbName.Text));
                onReloadServerData(id);
                this.Close();
                return;
            }


            MessageBox.Show("Name " + tbName.Text + " already exists", "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            tbUsername.Text = "";
            tbPassword.Text = "";
            tbHost.Text     = "";
            tbName.Text     = "";
            tbDatabase.Text = "";
            isUpdate        = false;
        }