public MainWindow()
        {
            try
            {
                InitializeComponent();

                db = new ADatabase("database");
                if (db.Connect())
                {
                    if (!ADatabase.MainDatabaseStructureIsOK(db.Connection))
                    {

                        db.CreateDBStructure();
                        db.WriteParameters();
                    }

                    ALayout.SetStatisticParametersListbox(allParameters_listbox, parametersToShow_listbox, ADatabaseWorker.GetAllParameters(db));
                    ALayout.SetStatisticZedgraphStyle(statistic_graph);
                    ALayout.SetReflectogramZedgraphStyle(refl_graph);

                    ScanTasks();
                }
                else
                {
                    MessageBox.Show("Не удалось соединиться с базой данных");
                    this.Close();
                }
            }
            catch(Exception ex)
            {
                FileWorker.WriteEventFile(DateTime.Now, "MainWindow", "Ini", ex.Message);
            }
        }
Example #2
0
        public Calibration(bool _twoZond, Dictionary<string, Dictionary<string, byte>> _devices)
        {
            InitializeComponent();

            db = new ADatabase("calibration");
            if (db.Connect())
            {
                if (!ADatabase.CalibrationDatabaseStructureIsOK(db.Connection))
                {
                    db.CreateCalibrationDBStructure();
                }

                twoZond = _twoZond;
                devices = _devices;

                List<string> devicesForCalibration = new List<string>();
                foreach (KeyValuePair<string, Dictionary<string, byte>> baseblock in devices)
                {
                    foreach (KeyValuePair<string, byte> channel in baseblock.Value)
                    {
                        devicesForCalibration.Add("ББ:" + baseblock.Key + " - CH" + channel.Value.ToString() + " Д:" + channel.Key.ToString());
                    }
                }

                channel_combobox.Items.Clear();

                foreach (string record in devicesForCalibration)
                {
                    channel_combobox.Items.Add(record);
                }
                channel_combobox.SelectedIndex = 0;

                dataGridView.Focus();

                bw = new BackgroundWorker();
                bw.DoWork += bw_DoWork;
                bw.ProgressChanged += bw_ProgressChanged;
                bw.RunWorkerCompleted += bw_RunWorkerCompleted;
                bw.WorkerReportsProgress = true;
            }
            else
            {
                MessageBox.Show("Не удалось соединиться с базой данных");
                this.Close();
            }
        }
Example #3
0
 public SqlWindow()
 {
     InitializeComponent();
     db = new ADatabase("database");
     if (db.Connect())
     {
         if (!ADatabase.MainDatabaseStructureIsOK(db.Connection))
         {
             db.CreateDBStructure();
             db.WriteParameters();
         }
     }
     else
     {
         MessageBox.Show("Не удалось соединиться с базой данных");
         this.Close();
     }
 }
Example #4
0
        private void connectToDatabase_btn_Click(object sender, EventArgs e)
        {
            IPAddress ipAddress;
            if (IPAddress.TryParse(databaseIP_textBox.Text, out ipAddress))
            {
                db = new ADatabase("database", databaseIP_textBox.Text);
                if (db.Connect())
                {
                    if (!ADatabase.MainDatabaseStructureIsOK(db.Connection))
                    {

                        db.CreateDBStructure();
                        db.WriteParameters();
                    }

                    allParameters_listbox.Items.Clear();
                    parametersToShow_listbox.Items.Clear();

                    ALayout.SetStatisticParametersListbox(allParameters_listbox, parametersToShow_listbox, ADatabaseWorker.GetAllParameters(db));

                    MessageBox.Show("Соединение установлено!");

                }
                else
                {
                    MessageBox.Show("Не удалось соединиться с базой данных");
                }
            }
            else
            {
                MessageBox.Show("Неверный адрес!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #5
0
        public TestCalibration(bool _twoZond, Dictionary<string, Dictionary<string, byte>> devices)
        {
            InitializeComponent();

            db = new ADatabase("calibration");
            if (db.Connect())
            {
                if (!ADatabase.CalibrationDatabaseStructureIsOK(db.Connection))
                {
                    db.CreateCalibrationDBStructure();
                }

                twoZond = _twoZond;

                List<string> devicesForCalibration = new List<string>();
                foreach (KeyValuePair<string, Dictionary<string, byte>> baseblock in devices)
                {
                    foreach (KeyValuePair<string, byte> channel in baseblock.Value)
                    {
                        devicesForCalibration.Add("ББ:" + baseblock.Key + " - CH" + channel.Value.ToString() + " Д:" + channel.Key.ToString());
                    }
                }

                channel_combobox.Items.Clear();

                foreach (string record in devicesForCalibration)
                {
                    channel_combobox.Items.Add(record);
                }
                channel_combobox.SelectedIndex = 0;

                dataGridView.Focus();

                bw = new BackgroundWorker();
                bw.DoWork += bw_DoWork;
                bw.ProgressChanged += bw_ProgressChanged;
                bw.RunWorkerCompleted += bw_RunWorkerCompleted;
                bw.WorkerReportsProgress = true;
            }
            else
            {
                MessageBox.Show("Не удалось соединиться с базой данных");
                this.Close();
            }

            //int MinID = dataGridView.Rows[0].Cells.Cast<DataGridViewTextBoxCell>()
            //            .Min(r => Convert.ToInt32(r.Value));

            //dataGridView.Rows[0].Cells.Cast<DataGridViewTextBoxCell>().Single(x => x.Value.ToString() == MinID.ToString()).Style.BackColor = Color.LightGreen;

            //int MaxID2 = dataGridView.Rows[1].Cells.Cast<DataGridViewTextBoxCell>()
            //            .Min(r => Convert.ToInt32(r.Value));

            //dataGridView.Rows[1].Cells.Cast<DataGridViewTextBoxCell>().Single(x => x.Value.ToString() == MaxID2.ToString()).Style.BackColor = Color.LightGreen;

            //int MaxID3 = dataGridView.Rows[2].Cells.Cast<DataGridViewTextBoxCell>()
            //            .Min(r => Convert.ToInt32(r.Value));

            //dataGridView.Rows[2].Cells.Cast<DataGridViewTextBoxCell>().Single(x => x.Value.ToString() == MaxID3.ToString()).Style.BackColor = Color.LightGreen;

            //int MaxID4 = dataGridView.Rows[3].Cells.Cast<DataGridViewTextBoxCell>()
            //            .Min(r => Convert.ToInt32(r.Value));

            //dataGridView.Rows[3].Cells.Cast<DataGridViewTextBoxCell>().Single(x => x.Value.ToString() == MaxID4.ToString()).Style.BackColor = Color.LightGreen;
        }