Example #1
0
        /// <summary>
        /// Создать и заполнить dataTable2 данными из srezTable
        /// </summary>
        private void FillDataTable2(DateTime srezDT)
        {
            DataTable newDataTable2 = new DataTable();

            newDataTable2.Columns.Add("CnlNum", typeof(int));
            newDataTable2.Columns.Add("Val", typeof(double));
            newDataTable2.Columns.Add("Stat", typeof(int));
            newDataTable2.DefaultView.AllowNew    = false;
            newDataTable2.DefaultView.AllowEdit   = editMode;
            newDataTable2.DefaultView.AllowDelete = false;

            selSrez = srezDT > DateTime.MinValue ? srezTable.GetSrez(srezDT) : null;

            if (selSrez != null)
            {
                newDataTable2.BeginLoadData();
                bindingSource2.DataSource = null; // для ускорения изменения данных в таблице
                int cnlCnt = selSrez.CnlNums.Length;

                for (int i = 0; i < cnlCnt; i++)
                {
                    DataRow row = newDataTable2.NewRow();
                    row["CnlNum"] = selSrez.CnlNums[i];
                    SrezTable.CnlData cnlData = selSrez.CnlData[i];
                    row["Val"]  = cnlData.Val;
                    row["Stat"] = cnlData.Stat;
                    newDataTable2.Rows.Add(row);
                }

                newDataTable2.EndLoadData();
                dataTable2                = newDataTable2;
                dataTable2.RowChanged    += dataTable2_RowChanged;
                bindingSource2.DataSource = dataTable2;
            }
        }
Example #2
0
        /// <summary>
        /// Initializes and fills dataTable2.
        /// </summary>
        private void FillDataTable2(DateTime srezDT)
        {
            DataTable newDataTable2 = new DataTable();

            newDataTable2.Columns.Add("CnlNum", typeof(int));
            newDataTable2.Columns.Add("Val", typeof(double));
            newDataTable2.Columns.Add("Stat", typeof(int));
            newDataTable2.DefaultView.AllowNew    = false;
            newDataTable2.DefaultView.AllowEdit   = AllowEdit;
            newDataTable2.DefaultView.AllowDelete = false;

            selSrez = srezDT > DateTime.MinValue ? srezTable.GetSrez(srezDT) : null;

            if (selSrez != null)
            {
                newDataTable2.BeginLoadData();
                bindingSource2.DataSource = null; // to speed up data changes in the table
                int cnlCnt = selSrez.CnlNums.Length;

                for (int i = 0; i < cnlCnt; i++)
                {
                    DataRow row = newDataTable2.NewRow();
                    row["CnlNum"] = selSrez.CnlNums[i];
                    SrezTable.CnlData cnlData = selSrez.CnlData[i];
                    row["Val"]  = cnlData.Val;
                    row["Stat"] = cnlData.Stat;
                    newDataTable2.Rows.Add(row);
                }

                newDataTable2.EndLoadData();
                dataTable2                = newDataTable2;
                dataTable2.RowChanged    += dataTable2_RowChanged;
                bindingSource2.DataSource = dataTable2;

                if (ScadaUtils.IsRunningOnMono)
                {
                    CommShellUtils.RefreshColumns(dataGridView2);
                }
            }
        }