Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == -1 || comboBox2.SelectedIndex == -1)
            {
                return;
            }
            insertListView.Columns.Clear();
            deleteListView.Columns.Clear();
            insertListView.Clear();
            deleteListView.Clear();
            updateListView.Columns.Clear();
            updateListView.Clear();
            var metadata = new DataManager().MetaData(this.comboBox1.SelectedItem.ToString(), this.comboBox2.SelectedItem.ToString());
            var redoInsert = "INSERT INTO " + this.comboBox2.SelectedItem.ToString() + "(";
            var undoInsert = "DELETE FROM " + this.comboBox2.SelectedItem.ToString() + " WHERE ";
            for (int i = 0, x = 0; i < metadata.Count - x; i++)
            {
                if (metadata.ElementAt(i).Types == Types.VarChar)
                {
                    var value = metadata.ElementAt(i);
                    metadata.RemoveAt(i);
                    metadata.Add(value);
                    i = -1;
                    x++;
                }
            }

            insertListView.Columns.Add("Transaction ID");
            insertListView.Columns.Add("Begin Time");
            deleteListView.Columns.Add("Transaction ID");
            deleteListView.Columns.Add("Begin Time");
            updateListView.Columns.Add("Transaction ID");
            updateListView.Columns.Add("Begin Time");
            ;            for (var i = 0; i < metadata.Count; i++)
            {

                if (i == metadata.Count - 1)
                {
                    this.deleteListView.Columns.Add(metadata[i].Name);
                    insertListView.Columns.Add(metadata[i].Name);
                    updateListView.Columns.Add(metadata[i].Name);
                    redoInsert += metadata[i].Name + ")";
                }
                else
                {
                    this.deleteListView.Columns.Add(metadata[i].Name);
                    insertListView.Columns.Add(metadata[i].Name);
                    updateListView.Columns.Add(metadata[i].Name);
                    redoInsert += metadata[i].Name + ",";
                }
            }
            this.deleteListView.Columns.Add("Redo SQL");
            this.deleteListView.Columns.Add("Undo SQL");
            insertListView.Columns.Add("Redo SQL");
            insertListView.Columns.Add("Undo SQL");
            updateListView.Columns.Add("Redo SQL");
            updateListView.Columns.Add("Undo SQL");

            redoInsert += " values(";

            AddValues(metadata, "LOP_DELETE_ROWS", undoInsert, redoInsert, metadata);
            AddValues(metadata, "LOP_INSERT_ROWS", redoInsert, undoInsert, metadata);
        }