private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                db = new linqDataContext();
                test pinfo = new test();
                pinfo.lvl         = TestInf.lvl;
                pinfo.language    = TestInf.language;
                pinfo.theme       = TestInf.theme;
                pinfo.description = TestInf.descript;
                pinfo.t_name      = TestInf.name;
                db.test.InsertOnSubmit(pinfo);
                db.SubmitChanges();


                var query = from pe in db.test

                            select pe;
                dataGridView2.DataSource = query.ToList();


                var uinfo = Convert.ToInt32(dataGridView2.Rows[dataGridView2.RowCount - 1].Cells[0].Value.ToString());


                for (int i = 0; i < dataGridView1.RowCount - 1; i++)
                {
                    task_struct pcode = new task_struct();
                    pcode.id_test = uinfo;

                    pcode.position = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value.ToString());

                    if (TestInf.lvl == "Легкий")
                    {
                        pcode.code_text = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    }
                    if (TestInf.lvl == "Середній")
                    {
                        pcode.code_text = dataGridView1.Rows[i].Cells[1].Value.ToString();
                        if (dataGridView1.Rows[i].Cells[2].Value.ToString() != "")
                        {
                            pcode.code_text2 = dataGridView1.Rows[i].Cells[2].Value.ToString();
                        }
                    }
                    if (TestInf.lvl == "Складний")
                    {
                        pcode.handwork  = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value.ToString());
                        pcode.code_text = dataGridView1.Rows[i].Cells[2].Value.ToString();
                    }
                    db.task_struct.InsertOnSubmit(pcode);
                    db.SubmitChanges();
                }


                MessageBox.Show("Тест успішно додано");
                this.Close();
            }
            catch { MessageBox.Show("Помилка добавлення"); }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "")
         {
             db = new linqDataContext();
             users pinfo = new users();
             pinfo.login    = textBox1.Text;
             pinfo.password = textBox2.Text;
             pinfo.name     = textBox3.Text;
             pinfo.access   = comboBox1.SelectedIndex;
             pinfo.surname  = textBox4.Text;
             db.users.InsertOnSubmit(pinfo);
             db.SubmitChanges();
             MessageBox.Show("Додано");
         }
         else
         {
             MessageBox.Show("Заповніть всі дані");
         }
     }
     catch
     {
         MessageBox.Show("Такий логін вже існує");
     }
 }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text == user.pass.Replace(" ", ""))
                {
                    if (textBox2.Text != "")
                    {
                        db = new linqDataContext();
                        var pinfo = db.users.Where(w => w.Id == user.id_user).FirstOrDefault();

                        pinfo.password = textBox2.Text;

                        db.SubmitChanges();

                        MessageBox.Show("Пароль змінено");
                    }
                    else
                    {
                        MessageBox.Show("Заповніть всі дані");
                    }
                }
                else
                {
                    MessageBox.Show("Не вірний старий пароль");
                }
            }
            catch
            {
                MessageBox.Show("Не вірний формат ");
            }
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox2.Text != "" && textBox3.Text != "")
                {
                    db = new linqDataContext();
                    lib pinfo = new lib();

                    pinfo.theme = textBox2.Text;
                    pinfo.url   = textBox3.Text;

                    db.lib.InsertOnSubmit(pinfo);
                    db.SubmitChanges();

                    Select();
                }
                else
                {
                    MessageBox.Show("Заповніть всі дані");
                }
            }
            catch
            {
            }
        }
Exemple #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         db = new linqDataContext();
         var pinfo = db.test.Where(w => w.Id == id).FirstOrDefault();
         db.test.DeleteOnSubmit(pinfo);
         db.SubmitChanges();
         Select();
     }
     catch { MessageBox.Show("Помилка видалення"); }
 }
Exemple #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            int count = 0;

            if (TestGoInfo.lvl.Replace(" ", "") == "Легкий")
            {
                sort1();
                for (int i = 0; i < dataGridView2.RowCount; i++)
                {
                    if (Convert.ToInt32(dataGridView2.Rows[i].Cells[3].Value) == Convert.ToInt32(dataGridView2.Rows[i].Cells[1].Value))
                    {
                        count++;
                        dataGridView2.Rows[i].Cells[2].Style.BackColor = System.Drawing.Color.Lime;
                    }
                    else
                    {
                        dataGridView2.Rows[i].Cells[2].Style.BackColor = System.Drawing.Color.Red;
                    }
                }
            }

            if (TestGoInfo.lvl.Replace(" ", "") == "Середній")
            {
                sort2();
                for (int i = 0; i < dataGridView2.RowCount; i++)
                {
                    if (dataGridView2.Rows[i].Cells[1].Value.ToString().Replace(" ", "") != "")
                    {
                        if (Convert.ToInt32(dataGridView2.Rows[i].Cells[6].Value) == Convert.ToInt32(dataGridView2.Rows[i].Cells[1].Value))
                        {
                            count++;
                            dataGridView2.Rows[i].Cells[2].Style.BackColor = System.Drawing.Color.Lime;
                        }
                        else
                        {
                            dataGridView2.Rows[i].Cells[2].Style.BackColor = System.Drawing.Color.Red;
                        }
                    }
                    else
                    {
                        dataGridView2.Rows[i].Cells[2].Style.BackColor = System.Drawing.Color.Red;
                    }
                }
                for (int i = 0; i < dataGridView2.RowCount; i++)
                {
                    if (dataGridView2.Rows[i].Cells[3].Value.ToString().Replace(" ", "") != "")
                    {
                        if (Convert.ToInt32(dataGridView2.Rows[i].Cells[4].Value) == Convert.ToInt32(dataGridView2.Rows[i].Cells[0].Value))
                        {
                            count++;
                            dataGridView2.Rows[i].Cells[3].Style.BackColor = System.Drawing.Color.Lime;
                        }
                        else
                        {
                            dataGridView2.Rows[i].Cells[3].Style.BackColor = System.Drawing.Color.Red;
                        }
                    }
                }
            }



            int point = Convert.ToInt32(100 / dataGridView1.RowCount * count);

            MessageBox.Show("Набрано" + count.ToString() + "/" + dataGridView1.RowCount.ToString() + "балів(" + point + "%)", "Результат");
            dataGridView1.Enabled = false;
            dataGridView2.Enabled = false;
            button2.Enabled       = false;

            db = new linqDataContext();
            result pinfo = new result();

            pinfo.id_user  = user.id_user;
            pinfo.id_test  = TestGoInfo.id;
            pinfo.point    = point;
            pinfo.datatime = DateTime.Now.ToString();

            db.result.InsertOnSubmit(pinfo);
            db.SubmitChanges();
            var fr = new TruTest();

            fr.Show();
        }