Пример #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection connection = SQLMethonds.StartConnection();

            comboBox2.Items.Clear();

            string        selecteduser  = Convert.ToString(comboBox1.SelectedItem);
            string        SQLExpression = "SELECT Id FROM dbo.userBD WHERE Login='******'";
            SqlCommand    command       = new SqlCommand(SQLExpression, connection);
            SqlDataReader reader        = command.ExecuteReader();

            reader.Read();
            int selectedId = Convert.ToInt32(ReadRow((IDataRecord)reader));

            reader.Close();

            SQLExpression = "SELECT experimentID,experimentDate FROM dbo.UnBD WHERE userID=" + Convert.ToString(selectedId);
            command       = new SqlCommand(SQLExpression, connection);
            reader        = command.ExecuteReader();
            while (reader.Read())
            {
                string item = ReadCombobox2((IDataReader)reader);
                comboBox2.Items.Add(item);
            }
            reader.Close();

            connection.Close();
        }
Пример #2
0
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            SqlConnection connection = SQLMethonds.StartConnection();
            string        h          = Convert.ToString(comboBox2.SelectedItem);
            int           index      = h.IndexOf(" ");
            string        show       = "";

            for (int i = 1; i < index; i++)
            {
                show += h[i];
            }
            string        SQLExpression = "SELECT comment FROM dbo.UnBD WHERE experimentID=" + show;
            SqlCommand    command       = new SqlCommand(SQLExpression, connection);
            SqlDataReader reader        = command.ExecuteReader();

            reader.Read();
            string comment = Convert.ToString(ReadRow((IDataRecord)reader));

            label11.Text = comment;

            connection.Close();
        }
Пример #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            SqlConnection connection = SQLMethonds.StartConnection();
            string        h          = Convert.ToString(comboBox2.SelectedItem);
            int           index      = h.IndexOf(" ");
            string        show       = "";

            for (int i = 1; i < index; i++)
            {
                show += h[i];
            }

            string        SQLExpression = "SELECT COUNt(ch77) FROM dbo.ExperimentBD WHERE expID=" + show;
            SqlCommand    command       = new SqlCommand(SQLExpression, connection);
            SqlDataReader reader        = command.ExecuteReader();

            reader.Read();
            int rows_amount = Convert.ToInt32(ReadSingle((IDataRecord)reader));

            reader.Close();

            string ordstr = "";

            switch (comboBox4.SelectedIndex)
            {
            case 0:
                ordstr = "ch1";
                break;

            case 1:
                ordstr = "ch2_normed";
                break;

            case 2:
                ordstr = "ch3";
                break;

            case 3:
                ordstr = "ch4";
                break;

            case 4:
                ordstr = "ch5";
                break;

            case 5:
                ordstr = "ch6_mean";
                break;

            case 6:
                ordstr = "ch6_disp";
                break;

            case 7:
                ordstr = "ch9";
                break;

            case 8:
                ordstr = "ch19";
                break;

            case 9:
                ordstr = "ch49";
                break;

            case 10:
                ordstr = "ch69";
                break;

            case 11:
                ordstr = "ch77";
                break;
            }


            SQLExpression     = "SELECT frameNum,ch1,ch2_normed,ch3,ch4,ch5,ch6_mean,ch6_disp,ch9,ch19,ch49,ch69,ch77 FROM dbo.ExperimentBD WHERE expID=" + show + " AND " + ordstr + comboBox3.SelectedItem + textBox1.Text;
            command           = new SqlCommand(SQLExpression, connection);
            reader            = command.ExecuteReader();
            double[,] dataset = new double[rows_amount, 12];
            int k = 0;

            while (reader.Read())
            {
                double[] response = new double[12];
                response = ReadOneRow((IDataReader)reader);
                for (int i = 0; i < 12; i++)
                {
                    dataset[k, i] = response[i];
                }
                k += 1;
            }
            reader.Close();
            dataGridView1.RowCount    = rows_amount;
            dataGridView1.ColumnCount = 12;
            for (int i = 0; i < rows_amount; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    //пишем значения из массива в ячейки контролла
                    dataGridView1.Rows[i].Cells[j].Value = dataset[i, j];
                }
            }
            dataGridView1.Update();
            MessageBox.Show("OK");



            connection.Close();
        }
Пример #4
0
        private void DataProcessingForm_Load(object sender, EventArgs e)
        {
            SqlConnection connection = SQLMethonds.StartConnection();

            string        SQLExpression = "SELECT COUNT(DISTINCT(userID)) FROM dbo.UnBD";
            SqlCommand    command       = new SqlCommand(SQLExpression, connection);
            SqlDataReader reader        = command.ExecuteReader();

            reader.Read();
            int users_amount = Convert.ToInt32(ReadSingle((IDataRecord)reader));

            reader.Close();
            int[] idarray = new int[users_amount];
            SQLExpression = "SELECT DISTINCT(userID) FROM dbo.UnBD";
            command       = new SqlCommand(SQLExpression, connection);
            reader        = command.ExecuteReader();
            int k = 0;

            while (reader.Read())
            {
                idarray[k] = Convert.ToInt32(ReadSingle((IDataReader)reader));
                k         += 1;
            }
            reader.Close();
            k = 0;
            string[] showme = new string[users_amount];
            for (int i = 0; i < users_amount; i++)
            {
                string        SQLExpress = "SELECT Login FROM dbo.userBD WHERE Id=" + Convert.ToString(idarray[i]);
                SqlCommand    com        = new SqlCommand(SQLExpress, connection);
                SqlDataReader re         = com.ExecuteReader();
                while (re.Read())
                {
                    showme[i] = ReadSingle((IDataReader)re);
                }
                re.Close();
            }
            comboBox1.DataSource = showme;

            comboBox1.SelectedIndex = 0;
            comboBox2.Items.Clear();

            string selecteduser = Convert.ToString(comboBox1.SelectedItem);

            SQLExpression = "SELECT Id FROM dbo.userBD WHERE Login='******'";
            command       = new SqlCommand(SQLExpression, connection);
            reader        = command.ExecuteReader();
            reader.Read();
            int selectedId = Convert.ToInt32(ReadRow((IDataRecord)reader));

            reader.Close();

            SQLExpression = "SELECT experimentID,experimentDate FROM dbo.UnBD WHERE userID=" + Convert.ToString(selectedId);
            command       = new SqlCommand(SQLExpression, connection);
            reader        = command.ExecuteReader();
            while (reader.Read())
            {
                string item = ReadCombobox2((IDataReader)reader);
                comboBox2.Items.Add(item);
            }
            reader.Close();

            connection.Close();
        }
Пример #5
0
        private void StartOPROSButton_Click(object sender, EventArgs e)
        {
            SqlConnection connection = SQLMethonds.StartConnection();
            string        h          = Convert.ToString(comboBox2.SelectedItem);
            int           index      = h.IndexOf(" ");
            string        show       = "";

            for (int i = 1; i < index; i++)
            {
                show += h[i];
            }

            string        SQLExpression = "SELECT COUNt(ch77) FROM dbo.ExperimentBD WHERE expID=" + show;
            SqlCommand    command       = new SqlCommand(SQLExpression, connection);
            SqlDataReader reader        = command.ExecuteReader();

            reader.Read();
            int rows_amount = Convert.ToInt32(ReadSingle((IDataRecord)reader));

            Data.FramesForPoll = rows_amount;
            reader.Close();

            SQLExpression           = "SELECT frameNum,ch1,ch2_normed,ch3,ch4,ch5,ch6_mean,ch6_disp,ch9,ch19,ch49,ch69,ch77 FROM dbo.ExperimentBD WHERE expID=" + show;
            command                 = new SqlCommand(SQLExpression, connection);
            reader                  = command.ExecuteReader();
            double[,] dataset       = new double[rows_amount, 13];
            Data.SelectedExperiment = new double[rows_amount, 13];
            int k = 0;

            while (reader.Read())
            {
                double[] response = new double[12];
                response = ReadOneRow((IDataReader)reader);
                for (int i = 0; i < 12; i++)
                {
                    dataset[k, i] = response[i];
                    Data.SelectedExperiment[k, i] = response[i];
                }
                k += 1;
            }
            reader.Close();
            dataGridView1.RowCount    = rows_amount;
            dataGridView1.ColumnCount = 13;
            for (int i = 0; i < rows_amount; i++)
            {
                for (int j = 0; j < 13; j++)
                {
                    //пишем значения из массива в ячейки контролла
                    dataGridView1.Rows[i].Cells[j].Value = dataset[i, j];
                }
            }
            dataGridView1.Update();
            Data.SelectedExperiment = dataset;

            SQLExpression = "SELECT AVG(ch1),AVG(ch2_normed),AVG(ch3),AVG(ch4),AVG(ch5),AVG(ch6_mean),AVG(ch6_disp),AVG(ch9),AVG(ch19),AVG(ch49),AVG(ch69),AVG(ch77) FROM dbo.ExperimentBD WHERE expID=" + show;
            command       = new SqlCommand(SQLExpression, connection);
            reader        = command.ExecuteReader();
            double[,] avg = new double[2, 12];
            while (reader.Read())
            {
                double[] res = new double[12];
                res = ReadAVG((IDataReader)reader);
                for (int i = 0; i < 12; i++)
                {
                    avg[1, i] = res[i];
                }
            }
            reader.Close();
            dataGridView2.RowCount    = 1;
            dataGridView2.ColumnCount = 12;
            for (int j = 0; j < 12; j++)
            {
                //пишем значения из массива в ячейки контролла
                dataGridView2.Rows[0].Cells[j].Value = avg[1, j];
            }
            connection.Close();
        }