Beispiel #1
0
 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("Такий логін вже існує");
     }
 }
Beispiel #2
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("Не вірний формат ");
            }
        }
Beispiel #3
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
            {
            }
        }
        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("Помилка добавлення"); }
        }
Beispiel #5
0
        public void Select()
        {
            db = new linqDataContext();

            var dbb = from t1 in db.lib
                      where SqlMethods.Like(t1.theme, "%" + textBox1.Text + "%")
                      select new { t1.Id, t1.theme, t1.url };

            dataGridView1.DataSource = dbb;
            headerText();
        }
Beispiel #6
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("Помилка видалення"); }
 }
Beispiel #7
0
        public void Select()
        {
            db = new linqDataContext();

            var query = from pe in db.test
                        where SqlMethods.Like(pe.language, "%" + comboBox1.Text + "%") &&
                        SqlMethods.Like(pe.theme, "%" + textBox1.Text + "%")
                        select pe;

            dataGridView1.DataSource = query.ToList();
            headerText();
        }
Beispiel #8
0
        public void select()
        {
            db = new linqDataContext();

            var cinfo = from t in db.task_struct
                        where (t.id_test == TestGoInfo.id)
                        orderby t.position
                        select t;

            dataGridView1.DataSource = cinfo.ToList();
            headerText();
        }
Beispiel #9
0
        public void Select()
        {
            db = new linqDataContext();
            if (user.access == 2)
            {
                var dbb = from t1 in db.result
                          join t2 in db.users on t1.id_user equals t2.Id
                          join t3 in db.test on t1.id_test equals t3.Id
                          where (t2.Id == user.id_user) &&
                          SqlMethods.Like(t1.datatime, "%" + textBox2.Text + "%") &&
                          SqlMethods.Like(t2.surname, "%" + textBox1.Text + "%")
                          &&
                          SqlMethods.Like(t3.t_name, "%" + textBox3.Text + "%")
                          select new { t1.Id, t2.name, t2.surname, t3.t_name, t3.theme, t1.point };
                dataGridView1.DataSource = dbb;
                headerText();
            }

            else
            {
                var dbb = from t1 in db.result
                          join t2 in db.users on t1.id_user equals t2.Id
                          join t3 in db.test on t1.id_test equals t3.Id
                          where SqlMethods.Like(t1.datatime, "%" + textBox2.Text + "%") &&
                          SqlMethods.Like(t2.surname, "%" + textBox1.Text + "%")
                          &&
                          SqlMethods.Like(t3.t_name, "%" + textBox3.Text + "%")
                          select new { t1.Id, t2.name, t2.surname, t3.t_name, t3.theme, t1.point };
                dataGridView1.DataSource = dbb;
                headerText();
            }



            headerText();
        }
Beispiel #10
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();
        }