/// <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; } }
private bool editMode; // режим редактирования /// <summary> /// Конструктор /// </summary> private FrmSrezTableEdit() { InitializeComponent(); errLog = null; srezAdapter = null; srezTable = null; dataTable1 = null; dataTable2 = null; selSrez = null; editMode = false; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public FrmSnapshotTable(Log errLog) : this() { this.errLog = errLog ?? throw new ArgumentNullException("errLog"); srezAdapter = new SrezAdapter(); srezTable = new SrezTable(); dataTable1 = null; dataTable2 = null; selSrez = null; FileName = ""; AllowEdit = false; }
/// <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); } } }