public SetupForm(MODBUS_srv value) { this.Text = "Выбор мотора"; // Server = value; InitializeComponent(); // initiate DB connection string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = motors.mdb"; try { OleDbConnection database = new OleDbConnection(connectionString); database.Open(); //SQL query to list movies // string sqlQueryString = "SELECT Имя, Тип, Мощность, Частота, Ток, КПД FROM Motors"; string sqlQueryString = "SELECT * FROM Motors"; OleDbCommand SQLQuery = new OleDbCommand(); DataTable data = null; dataGridView1.DataSource = null; SQLQuery.Connection = null; OleDbDataAdapter dataAdapter = null; dataGridView1.Columns.Clear(); // <-- clear SQLQuery.CommandText = sqlQueryString; SQLQuery.Connection = database; data = new DataTable(); dataAdapter = new OleDbDataAdapter(SQLQuery); dataAdapter.Fill(data); dataGridView1.DataSource = data; Server = value; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }
public FormScope(MODBUS_srv value) { InitializeComponent(); var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; this.Text = "Осциллограф " + version; Server = value; //Индексы комбо бокс при загрузке cmbBoxScpChNum.SelectedIndex = 0; cmBoxScpFreq.SelectedIndex = 2; comboBoxPageNum.SelectedIndex = 0; //цвета каналов chart1.Series[0].Color = Color.Red; chart1.Series[1].Color = Color.Blue; chart1.Series[2].Color = Color.Black; chart1.Series[3].Color = Color.Green; chart2.Series[0].Color = Color.Red; chart2.Series[1].Color = Color.Blue; chart2.Series[2].Color = Color.Black; chart2.Series[3].Color = Color.Green; //формат подписей по оси х chart1.ChartAreas[0].AxisX.LabelStyle.Format = "0.##"; chart1.ChartAreas[0].AxisX.Interval = 0.2; chart2.ChartAreas[0].AxisX.LabelStyle.Format = "0.##"; chart2.ChartAreas[0].AxisX.Interval = 0.2; //создание значений по оси х iaAxisX = new float[Server.scp_cntmax]; for (int i = 0; i < Server.scp_cntmax; i++) { iaAxisX[i] = (float)(i * ((cmBoxScpFreq.SelectedIndex + 1) * 0.001)); } // настройка параметров зума chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; chart1.ChartAreas[0].CursorX.Interval = 0.005; chart1.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true; chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true; chart1.ChartAreas[0].CursorX.AutoScroll = true; chart1.ChartAreas[0].CursorY.AutoScroll = true; chart2.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; chart2.ChartAreas[0].CursorX.Interval = 0.005; chart2.ChartAreas[0].CursorY.IsUserSelectionEnabled = true; chart2.ChartAreas[0].AxisX.ScaleView.Zoomable = true; chart2.ChartAreas[0].AxisY.ScaleView.Zoomable = true; chart2.ChartAreas[0].CursorX.AutoScroll = true; chart2.ChartAreas[0].CursorY.AutoScroll = true; //сброс графиков ResetAxis(); // tbaGain = new TextBox[] { textBoxGainCh1, textBoxGainCh2, textBoxGainCh3, textBoxGainCh4 }; tbaOffset = new TextBox[] { textBoxOffCh1, textBoxOffCh2, textBoxOffCh3, textBoxOffCh4 }; tbaAdr = new TextBox[] { textBoxAdrCh1, textBoxAdrCh2, textBoxAdrCh3, textBoxAdrCh4 }; tbaAdrSh = new TextBox[] { textBoxAdrShCh1, textBoxAdrShCh2, textBoxAdrShCh3, textBoxAdrShCh4 }; btaAdrSend = new Button[] { btnSendAdrCh1, btnSendAdrCh2, btnSendAdrCh3, btnSendAdrCh4 }; //массив чекбоксов для отображения каналов lsaRbEnbl.Add(new CheckBox[] { checkBox1, checkBox2, checkBox3, checkBox4 }); lsaRbEnbl.Add(new CheckBox[] { checkBox5, checkBox6, checkBox7, checkBox8 }); //все включены foreach (CheckBox[] el in lsaRbEnbl) { for (int i = 0; i < el.Length; i++) { el[i].Checked = true; } } ; for (int i = 0; i < 4; i++) { tbaGain[i].Text = "1"; tbaOffset[i].Text = "0"; } ; chart1.MouseWheel += new MouseEventHandler(chData_MouseWheel); chart2.MouseWheel += new MouseEventHandler(chData_MouseWheel); Server.blnScpEnbl = true; }