/// <summary> /// Initializes and fills dataTable1. /// </summary> private void FillDataTable1() { DataTable newDataTable1 = new DataTable(); newDataTable1.Columns.Add("DateTime", typeof(DateTime)); newDataTable1.DefaultView.AllowNew = false; newDataTable1.DefaultView.AllowEdit = false; newDataTable1.DefaultView.AllowDelete = false; newDataTable1.BeginLoadData(); foreach (DateTime srezDT in srezTable.SrezList.Keys) { DataRow row = newDataTable1.NewRow(); row["DateTime"] = srezDT; newDataTable1.Rows.Add(row); } newDataTable1.EndLoadData(); dataTable1 = newDataTable1; bindingSource1.DataSource = dataTable1; if (ScadaUtils.IsRunningOnMono) { CommShellUtils.RefreshColumns(dataGridView1); } }
private void FrmEventTableEdit_Load(object sender, EventArgs e) { Translator.TranslateForm(this, GetType().FullName); sfdCsv.Filter = ServerShellPhrases.CsvFileFilter; if (lblCount.Text.Contains("{0}")) { bindingNavigator.CountItemFormat = lblCount.Text; } Text = string.Format(AllowEdit ? ServerShellPhrases.EditEventsTitle : ServerShellPhrases.ViewEventsTitle, Path.GetFileName(FileName)); btnSave.Visible = AllowEdit; if (LoadEventTable(dataTable)) { dataTable.DefaultView.AllowNew = AllowEdit; dataTable.DefaultView.AllowEdit = AllowEdit; bindingSource.DataSource = dataTable; if (ScadaUtils.IsRunningOnMono) { CommShellUtils.RefreshColumns(dataGridView); } } else { bindingNavigator.Enabled = false; dataGridView.Enabled = false; pnlBottom.Enabled = 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); } } }