Exemplo n.º 1
0
Arquivo: Form1.cs Projeto: Miktor/pub
        //================================================================================================================================================================
        private void compareTables()
        {
            listView1.Clear();
            listView1.Columns.Add("Первая БД", listView1.Width / 2, HorizontalAlignment.Left);
            listView1.Columns.Add("Вторая БД", listView1.Width / 2, HorizontalAlignment.Left);
            listView1.Groups.Add("main", "Таблицы БДых");
            modFunc modF = new modFunc(itemModyfaer);
            compFunc CollumnFunc = new compFunc(addTable2List);
            if (!MainDB.Tables.Contains("fstDBTablesSchema"))
            {
                MainDB.Tables.Add(loadTableSchema("Data Source=" + fstFilePath.Text + ";" + "FailIfMissing=True;Read Only=True;", null, "Tables", "fstDBTablesSchema"));
                MainDB.Tables.Add(loadTableSchema("Data Source=" + sndFilePath.Text + ";" + "FailIfMissing=True;Read Only=True;", null, "Tables", "sndDBTablesSchema"));
            }

            int counter = LoadList(MainDB.Tables["fstDBTablesSchema"], MainDB.Tables["sndDBTablesSchema"], 2, listView1, "main", CollumnFunc, modF);

            AllResultsout.Text = "Сравнение баз: " + Environment.NewLine +
                fstFilePath.Text.Substring(fstFilePath.Text.LastIndexOf("\\") + 1) + Environment.NewLine +
                sndFilePath.Text.Substring(sndFilePath.Text.LastIndexOf("\\") + 1) + Environment.NewLine + AllResultsout.Text;
            if(counter==0)
                AllResultsout.Text = "Все таблицы в базах данных одинаковы." + Environment.NewLine + AllResultsout.Text;
            else
                AllResultsout.Text = counter.ToString() + " таблиц в базе данных не совпадают." + Environment.NewLine + AllResultsout.Text;
        }
Exemplo n.º 2
0
Arquivo: Form1.cs Projeto: Miktor/pub
        private int LoadList(DataTable fstTable, DataTable sndTable, int NamePole, ListView lv,string group, compFunc del,modFunc mod)
        {
            int counter = 0;
            List<int> nAdded = new List<int> { };

            List<object[]> list = new List<object[]> { };
            for (int j = 0; j < sndTable.Rows.Count; j++)
                list.Add(sndTable.Rows[j].ItemArray);

            for (int i = 0; i < fstTable.Rows.Count && i < sndTable.Rows.Count; i++)
            {
                int tmp = findRowInList(fstTable.Rows[i].ItemArray, list, new List<int> { 4, 5 });
                if (tmp >= 0)
                {
                    ListViewItem lvi = new ListViewItem(fstTable.Rows[i].ItemArray[NamePole].ToString(), lv.Groups[group]);
                    lvi.SubItems.Add(sndTable.Rows[tmp].ItemArray[NamePole].ToString());
                    mod(lvi, true);
                    lv.Items.Add(lvi);
                    try
                    {
                        del(fstTable.Rows[i].ItemArray[NamePole].ToString());
                    }
                    catch { }
                    int c = fillCollumn(new ListView.ListViewItemCollection(listView2), fstTable.Rows[i].ItemArray[NamePole].ToString(), false);
                    if (c > 0)
                    {
                        AllResultsout.Text += "В таблице " + fstTable.Rows[i].ItemArray[NamePole].ToString() + " обнаруженно " + c.ToString() + " ошибок!" + Environment.NewLine;
                        lvi.BackColor = Color.Yellow;
                    }
                    counter++;
                }
                else
                {
                    nAdded.Add(i);
                    counter++;
                }
            }
            lv.Groups[group].Header = "     Ошибок:" + counter.ToString();
            autoSizeColumns(lv.Columns);
            return counter;
        }
Exemplo n.º 3
0
Arquivo: Form1.cs Projeto: Miktor/pub
        private void addTable2List(string table)
        {
            comboBox1.Items.Add(table);
            listView1.Groups.Add(table, "Столбцы таблицы: " + table);

            modFunc modF = new modFunc(itemModyfaer);
            if (!MainDB.Tables.Contains("fstDBCollSchema" + table))
                MainDB.Tables.Add(loadTableSchema("Data Source=" + fstFilePath.Text + ";" + "FailIfMissing=True;Read Only=True;", new string[4] { null, null, table, null }, "Columns", "fstDBCollSchema" + table));

            if (!MainDB.Tables.Contains("sndDBCollSchema" + table))
                MainDB.Tables.Add(loadTableSchema("Data Source=" + sndFilePath.Text + ";" + "FailIfMissing=True;Read Only=True;", new string[4] { null, null, table, null }, "Columns", "sndDBCollSchema" + table));
        }