Exemple #1
0
 private void lista_dgv_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (type == 1 && e.RowIndex >= 0 && !editor_opened)
     {
         //open test editor
         string path = string.Format($"teste/{data[2]}/{data[0]}_{data[1]}/{lista_dgv["Nume_fisier", e.RowIndex].Value}.txt");
         if (File.Exists(path))
         {
             editor        = new TestEditor(path);
             editor_opened = true;
             editor.link   = this;
             editor.Show();
         }
         else
         {
             MessageBox.Show("A aparut o eroare , se pare ca acel fisier nu exista.", "Eroare", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
 }
Exemple #2
0
        private void studenti_dgv_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (tip == 1)
            {
                if (e.RowIndex >= 0 && studenti_dgv.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
                {
                    string sql = string.Empty;
                    sql = string.Format("SELECT Nume_Materie FROM TabelMaterii WHERE ID_Profesori LIKE '%{0}%';", Main_form.id_user);
                    string numeMaterie = MyData.stringSelector(sql, "Nume_Materie");
                    string path        = string.Format($"teste/{numeMaterie}/{getName(Main_form.id_user, 1)}_{getName(Main_form.id_user, 2)}/{studenti_dgv[1, e.RowIndex].Value}.txt");
                    if (e.ColumnIndex == 3)
                    {
                        //sterge test
                        DialogResult res = MessageBox.Show($"Esti sigur ca vrei sa stergi acest test pentru elevul {nume_cmb.SelectedItem.ToString()} ?", "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        switch (res)
                        {
                        case DialogResult.Yes:
                            sql = string.Format("SELECT ID_Test FROM Teste_Materii WHERE ID_Student={0} AND ID_Prof={1} AND Nume_fisier='{2}';", getStudentID(), Main_form.id_user, studenti_dgv[1, e.RowIndex].Value);
                            int id_test = MyData.selectData(sql, "ID_Test");
                            sql = string.Format("SELECT IDTesteAdaugate FROM Materii WHERE IDProfesor={0};", Main_form.id_user);
                            string   id_teste   = MyData.stringSelector(sql, "IDTesteAdaugate");
                            string[] splitTeste = id_teste.Split(',');
                            string[] new_data   = new string[splitTeste.Length - 1];
                            int      j          = 0;
                            for (int i = 0; i < splitTeste.Length; i++)
                            {
                                if (id_test != Convert.ToInt32(splitTeste[i]))
                                {
                                    new_data[j] = splitTeste[i];
                                    j++;
                                }
                            }
                            id_teste = string.Join(",", new_data);
                            sql      = string.Format("UPDATE Materii SET IDTesteAdaugate='{0}' WHERE IDProfesor={1};", id_teste, Main_form.id_user);
                            MyData.execSql(sql);
                            //delete test
                            sql = string.Format("DELETE * FROM Teste_Materii WHERE ID_Student={0} AND ID_Prof={1} AND Nume_fisier='{2}';", getStudentID(), Main_form.id_user, studenti_dgv[1, e.RowIndex].Value);
                            MyData.execSql(sql);
                            if (File.Exists(path))
                            {
                                File.Delete(path);
                            }
                            MessageBox.Show("Testul a fost sters cu succes din baza de date.", "Informatie", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            //recreate
                            ListaTeste();
                            break;

                        case DialogResult.No:
                            break;
                        }
                    }
                    else if (e.ColumnIndex == 4)
                    {
                        //modifica test
                        if (File.Exists(path))
                        {
                            editor = new TestEditor(path);
                            editor.Show();
                        }
                    }
                    else if (e.ColumnIndex == 5)
                    {
                        //reset test
                        sql = string.Format("UPDATE Teste_Materii SET Nota=0 AND Promovat=false WHERE ID_Test={0} AND ID_Student={1} AND ID_Prof={2};", studenti_dgv[0, e.RowIndex].Value.ToString(), getStudentID(), Main_form.id_user);
                        MyData.execSql(sql);
                        ListaTeste();
                        MessageBox.Show("Testul a fost reinitializat cu succes, acum studentul poate relua testul.", "Informatie", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }