Пример #1
0
        public void ShowDataGridViews(List <DataTable> tables, Boolean isFromHistory)
        {
            int    icontrolIndex = 0;
            string changeTime    = "history";

            if (!isFromHistory)
            {
                changeTime = File.GetLastWriteTime(file).ToString("mm:ss");
                this.Text  = Path.GetFileName(file) + " " + changeTime;
            }
            dataTAbleLogManager.AddNewEntry(changeTime);


            var ff = this.Controls.OfType <DataGridView>().ToList();

            if (tables.Count == 0)
            {
                foreach (DataGridView item in ff)
                {
                    this.Controls.Remove(item);
                }
            }
            ;

            //var dt = TransposeDataTable(dtsourcfe);
            foreach (DataTable table in tables)
            {
                DataTable dt = table;
                if (!isFromHistory)
                {
                    dt = TransposeDataTable(table);
                }
                DataGridView dgrv = null;;
                if (ff.Count > icontrolIndex)
                {
                    dgrv = ff[icontrolIndex++];
                }
                if (dgrv == null)
                {
                    dgrv = new DataGridView();
                    this.Controls.Add(dgrv);
                    dgrv.Dock       = DockStyle.Left;
                    dgrv.Width      = (this.Width - 80) / tables.Count;
                    dgrv.DataSource = dt;
                }

                // if (!isFromHistory)
                {
                    dataTAbleLogManager.AddTable(dt);
                }
                dataTAbleLogManager.HighlightChangesInLadsTable(dgrv, isFromHistory);

                DatagridUtils.FormatDataGridView(tables.Count, dgrv);
            }
            if (!isFromHistory)
            {
                dataTAbleLogManager.RemoveLastLogIfNotHighlighted();
            }
        }
Пример #2
0
        internal bool HighlightChangesInLadsTable(DataGridView dgrv, Boolean isFromHistory)
        {
            int indexOfChanges = -1;
            DataTablesLogEntity lastInLog;

            if (indexOfChanges >= 0)
            {
            }
            else
            {
                lastInLog      = dataTablesLog.Last <DataTablesLogEntity>();
                indexOfChanges = dataTablesLog.IndexOf(lastInLog);
            }
            lastInLog = dataTablesLog[indexOfChanges];
            var lastTable = lastInLog.dataTables.Last();

            var index = lastInLog.dataTables.IndexOf(lastTable);

            if (dataTablesLog.Count >= 2)
            {
                if (!isFromHistory)
                {
                    indexOfPrevLogEntity = dataTablesLog.Count - 2;
                }

                DataTable prevTable = null;
                if (indexOfPrevLogEntity >= 0)
                {
                    var prevInLog = dataTablesLog[indexOfPrevLogEntity];
                    if (index + 1 <= prevInLog.dataTables.Count)
                    {
                        prevTable = prevInLog.dataTables[index];
                    }
                }
                else
                {
                }
                if ((prevTable != null) && (lastTable.Columns.Count == prevTable.Columns.Count) && (lastTable.Rows.Count == prevTable.Rows.Count))
                {
                    for (int j = 0; j <= lastTable.Columns.Count - 1; j++)
                    {
                        for (int k = 0; k <= lastTable.Rows.Count - 1; k++)
                        {
                            if (lastTable.Rows[k][j].ToString() != prevTable.Rows[k][j].ToString())
                            {
                                dgrv.Rows[k].Cells[j].Style.BackColor = Color.Yellow;
                                dgrv.Rows[k].Cells[j].Value           = lastTable.Rows[k][j];
                                wasHighlighted = true;
                            }
                            else
                            {
                                dgrv.Rows[k].Cells[j].Style.BackColor = Color.White;
                            }
                        }
                    }
                }
                else
                {
                    dgrv.DataSource = lastTable;
                    DatagridUtils.FormatDataGridView(lastInLog.dataTables.Count, dgrv);
                    wasHighlighted = true;
                }
            }
            else
            {
                wasHighlighted = true;
            }
            return(wasHighlighted);
        }