示例#1
0
 public DGVQuery(DataGridView dgv, Connexion.Connexion connexion)
 {
     this.dgv = dgv;
     this.connexion = connexion;
 }
示例#2
0
        public string Display(object obj, BackgroundWorker worker, DoWorkEventArgs eArgs)
        {
            string result = null;
            bool bConnexion = true;
            if (this.connexion == null || this.connexion.Cnn == null || this.connexion.Cnn.State.ToString() == "Closed")
            {
                connexion = new Connexion.Connexion("Oracle");
                bConnexion = connexion.Open();
            }
            if (bConnexion)
            {
                result = DisplayQueryData(connexion, Convert.ToString(obj), dgv, worker, eArgs);
            }

            return result;
        }
示例#3
0
 public DGVQuery(Connexion.Connexion connexion)
 {
     this.connexion = connexion;
 }
示例#4
0
        private void toolStripButtonDeleteCol_Click(object sender, EventArgs e)
        {
            if (
                MessageBox.Show(
                    string.Format("Are you sure you want to drop the column {0} from the table {1} ?",
                                  dataGridViewOracleFields.CurrentRow.Cells["cname"].Value, CurrentTablename),
                    "Drop column", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                string sql =
                    string.Format("ALTER TABLE {0} DROP COLUMN {1}", CurrentTablename,
                                  dataGridViewOracleFields.CurrentRow.Cells["cname"].Value);

                try
                {
                    if (this.connexion == null || this.connexion.Cnn == null ||
                        this.connexion.Cnn.State.ToString() == "Closed")
                    {
                        connexion = new Connexion.Connexion("Oracle");
                        connexion.Open();
                    }
                    if (connexion.IsOpen)
                    {
                        using (DbCommand cmd = connexion.Cnn.CreateCommand())
                        {
                            cmd.CommandText = sql;
                            cmd.Prepare();
                            //int colno = 0;
                            int result = cmd.ExecuteNonQuery();
                            getTable();
                        }
                    }
                }
                catch (Exception ex)
                {
                    string errorMessage = ex.Message;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        errorMessage += "\n" + ex.Message;
                    }
                    MessageBox.Show(errorMessage, "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#5
0
        private void toolStripButtonAddCol_Click(object sender, EventArgs e)
        {
            FormAddCol frmAddCol = new FormAddCol();
            frmAddCol.labelTablename.Text = CurrentTablename;
            frmAddCol.Tablename = CurrentTablename;
            if (frmAddCol.ShowDialog() == DialogResult.OK)
            {
                // Create the column
                string sql = frmAddCol.textBoxSql.Text;

                try
                {
                    if (this.connexion == null || this.connexion.Cnn == null ||
                        this.connexion.Cnn.State.ToString() == "Closed")
                    {
                        connexion = new Connexion.Connexion("Oracle");
                        connexion.Open();
                    }
                    if (connexion.IsOpen)
                    {
                        using (DbCommand cmd = connexion.Cnn.CreateCommand())
                        {
                            cmd.CommandText = sql;
                            cmd.Prepare();
                            //int colno = 0;
                            int result = cmd.ExecuteNonQuery();
                            getTable();
                        }
                    }
                }
                catch (Exception ex)
                {
                    string errorMessage = ex.Message;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        errorMessage += "\n" + ex.Message;
                    }
                    MessageBox.Show(errorMessage, "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            frmAddCol.Close();
            frmAddCol.Dispose();
        }
示例#6
0
 private void EventProcess(object sender, string data)
 {
     XmlDocument xmlData = new XmlDocument();
     xmlData.LoadXml(data);
     XmlNode xmlNode = null;
     foreach (XmlNode xmlNodeAction in xmlData.GetElementsByTagName("action"))
     {
         switch (xmlNodeAction.InnerText)
         {
             case "connect":
                 // Get Info for the oracle connection
                 xmlNode = xmlData.SelectSingleNode("//ToadDotNet/action/connection");
                 if (xmlNode != null)
                 {
                     connexion = new Connexion.Connexion("Oracle");
                     connexion.OracleConnexion.UserId = xmlNode.Attributes.GetNamedItem("userid").Value;
                     connexion.OracleConnexion.Password = xmlNode.Attributes.GetNamedItem("password").Value;
                     connexion.OracleConnexion.DataSource = xmlNode.Attributes.GetNamedItem("datasource").Value;
                     this.Text =
                         string.Format("{0}@{1}", connexion.OracleConnexion.UserId,
                                       connexion.OracleConnexion.DataSource);
                 }
                 break;
             default:
                 break;
         }
     }
 }
示例#7
0
        private void buttonSelectTarget_Click(object sender, EventArgs e)
        {
            FormConnection formConnection = new FormConnection();
            //formConnection.MdiParent = this.ParentForm;
            if (formConnection.ShowDialog() == DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(formConnection.textBoxOracleUserId.Text)
                    && !string.IsNullOrEmpty(formConnection.textBoxOraclePassword.Text)
                    && !string.IsNullOrEmpty(formConnection.TNSNamesComboBox.Text))
                {
                    Config.SaveLastConnectionInfo(formConnection.textBoxOracleUserId.Text,
                                           formConnection.textBoxOraclePassword.Text,
                                           formConnection.TNSNamesComboBox.Text);

                    labelTargetTnsnames.Text = string.Format("Source {0}@{1}", formConnection.textBoxOracleUserId.Text, formConnection.TNSNamesComboBox.Text);
                    TargetConnexion = new Connexion.Connexion("Oracle");
                    // Open connexions
                    TargetConnexion.Open(formConnection.textBoxOracleUserId.Text,
                                         formConnection.textBoxOraclePassword.Text, formConnection.TNSNamesComboBox.Text);
                    TargetConnexion.Close();
                }
            }
        }
示例#8
0
        private void buttonSelectSource_Click(object sender, EventArgs e)
        {
            FormConnection formConnection = new FormConnection();
            //formConnection.MdiParent = this.ParentForm;
            if (formConnection.ShowDialog() == DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(formConnection.textBoxOracleUserId.Text)
                    && !string.IsNullOrEmpty(formConnection.textBoxOraclePassword.Text)
                    && !string.IsNullOrEmpty(formConnection.TNSNamesComboBox.Text))
                {
                    labelSourceTnsnames.Text = string.Format("Source {0}@{1}", formConnection.textBoxOracleUserId.Text, formConnection.TNSNamesComboBox.Text);
                    SourceConnexion = new Connexion.Connexion("Oracle");
                    // Open connexions
                    SourceConnexion.Open(formConnection.textBoxOracleUserId.Text, formConnection.textBoxOraclePassword.Text, formConnection.TNSNamesComboBox.Text);
                    // Get Tables of source connexion
                    if (SourceConnexion.Cnn.State.ToString() != "Closed")
                    {
                        using (DbCommand cmd = SourceConnexion.Cnn.CreateCommand())
                        {
                            string SQL = "select distinct table_name  " +
                                         "  from user_tables " +
                                         " order by table_name ";

                            cmd.CommandText = SQL;
                            cmd.Prepare();

                            using (DbDataReader rd = cmd.ExecuteReader())
                            {
                                while (rd.Read())
                                {
                                    SourceTablesCheckedListBox.Items.Add(rd.GetValue(0), false);
                                }
                            }
                        }
                    }
                    // close connexions
                    SourceConnexion.Close();
                }
            }
        }