예제 #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 button3_Click(object sender, EventArgs e)
        {
            int expID = SQLMethonds.InsertIntoExperimentBD(Data.Experiment);

            SQLMethonds.InsertIntoUnBD(expID, CommentTextBox.Text);
            MessageBox.Show("Все записи успешно сохранены");
        }
예제 #3
0
 private void AcceptButton_Click(object sender, EventArgs e)
 {
     if (AdminPasswordTextBox.Text == "1nv1n0Ver1ta$")
     {
         AdminNeeded = true;
     }
     else
     {
         if (PrevComboBox.SelectedIndex == 0)
         {
             AdminNeeded = true;
         }
         else
         {
             AdminNeeded = false;
         }
         AdminNeeded = false;
     };
     if (AdminNeeded == true)
     {
         //Занесение в таблицу UserBD
         string Login    = "******" + LoginTextBox.Text + "'";
         string Password = "******" + PasswordTextBox.Text + "'";
         string FIO      = "N'" + FirstNameTextBox.Text + " " + SecondNameTextBox.Text + " " + ThirdNameTextBox.Text + "'";
         int    Prev     = Convert.ToInt32(PrevComboBox.SelectedIndex);
         string Question = "N'" + Convert.ToString(comboBox2.SelectedItem) + "'";
         string Req      = "N'" + SecretAnswerTextBox.Text + "'";
         SQLMethonds.InsertIntoUserBD(Login, Password, FIO, Prev, Question, Req);
         DialogResult result;
         result = MessageBox.Show(String.Format("Пользователь {0} успешно добавлен.", LoginTextBox.Text), "Регистрация пользователя", MessageBoxButtons.OKCancel);
         //Demonstration
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             //Closing Parent Form
             this.Close();
             Form AuthF = Application.OpenForms[0];
             AuthF.Show();
         }
     }
     else
     {
         DialogResult AdminNeedResult;
         AdminNeedResult = MessageBox.Show("Необходимо ввести пароль администратора", "Доступ заблокирован!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         if (AdminNeedResult == DialogResult.OK)
         {
             PrevComboBox.SelectedIndex   = 0;
             AdminLabel.Visible           = false;
             AdminPasswordTextBox.Text    = "";
             AdminPasswordTextBox.Visible = false;
         }
     };
 }
예제 #4
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();
        }
예제 #5
0
 private void SignInButton_Click(object sender, EventArgs e)
 {
     if (PasswordBox.Text == "" || LoginBox.Text == "")
     {
         MessageBox.Show("Пожалуйста, введите логин и пароль", "Неправильнйы ввод", MessageBoxButtons.OK);
     }
     else
     {
         Data.EntryLogin    = LoginBox.Text;
         Data.EntryPassword = PasswordBox.Text;
         bool tt = SQLMethonds.Authentication(Data.EntryLogin);
         if (tt == true)
         {
             Form MainF = new MainForm();
             MainF.Show();
             MainF.Activate();
             Hide();
         }
         else
         {
             MessageBox.Show("Доступ запрещен");
         }
     }
 }
예제 #6
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();
        }
예제 #7
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();
        }
예제 #8
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();
        }