示例#1
0
 public void AddCollection(CollectionOfTest COT)
 {
     if (COT.ToString().Length > 0)
     {
         this.ArrayOfTest.Add(COT);
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Class Predmet : При добавлении теста его данные не полные!");
     }
 }
示例#2
0
文件: Journal.cs 项目: mazuryv/Test_M
 public void AddLogCollection(int UserID, Predmet predmet, CollectionOfTest NameOfTest, int[] Prav, int[] Neprav, int [] CollMark, double Mark)
 {
     if (UserID > 0 && predmet != null && NameOfTest != null && Mark > -1 && Prav.Length > 0 && Neprav.Length > 0 && CollMark.Length > 0)
     {
         list.Add(new Log(UserID, predmet, NameOfTest.ToString(), Prav, Neprav, CollMark, Mark));
     }
     else
     {
         System.Windows.Forms.MessageBox.Show(" ласс ∆урнал! входные данные о добавл¤емой записи коллекции не соответсвуют формату ");
     }
 }
示例#3
0
        private void buttonNext_Click(object sender, EventArgs e)
        {
            if (this.listViewTest.SelectedItems.Count == 0)
            {
                MessageBox.Show("Виберіть тест, який необхідно пройти!");
            }
            else
            {
                Predmet SelectPredmet = (Predmet)this.listBoxPredmet.Items[this.listBoxPredmet.SelectedIndex];
                if (this.listViewTest.SelectedItems[0].ImageIndex != -1)
                {
                    if (!this.MF.setting.GetPovtorSdachi())
                    {
                        MessageBox.Show("Повторне складання тестів заборонене адміністратором!");
                    }
                    else
                    {
                        DateTime TimePass       = this.MF.setting.WhenPassTest(SelectPredmet.FindTest(this.listViewTest.SelectedItems[0].Text), this.CurrentUser.GetID());
                        DateTime TimeForNewTest = TimePass.AddMinutes(Convert.ToInt32(this.MF.setting.GetTimeForNewTest()));
                        TimeSpan interval       = TimeForNewTest - DateTime.Now;
                        MessageBox.Show("Повторне складання вказаного тесту Вами можливо лише через " + interval.Hours + " годин та " + interval.Minutes + " хвилин!");
                    }
                }
                else
                {
                    string NameofTest    = SelectPredmet.FindTest(this.listViewTest.SelectedItems[0].Text).ToString();
                    string NameColection = NameofTest.Substring(0, 3);
                    if (NameColection.Equals("(K)"))
                    //это коллекция
                    {
                        COT = new CollectionOfTest();

                        COT = (CollectionOfTest)SelectPredmet.FindTest(NameofTest);
                        int    SummOfMark = 0;
                        string message    = "";
                        System.Collections.ArrayList AOT = COT.GetTests();
                        int[] APrav    = new int[AOT.Count];
                        int[] ANeprav  = new int[AOT.Count];
                        int[] CollMark = new int[AOT.Count];
                        this.Visible = false;
                        for (int i = 0; i < AOT.Count; i++)
                        {
                            TestForm tf = new TestForm((Test)AOT[i], CurrentUser);

                            tf.ShowDialog();
                            SummOfMark += tf.mark;
                            APrav[i]    = tf.prav;
                            ANeprav[i]  = tf.neprav;
                            CollMark[i] = tf.mark;
                            message    += (i + 1) + ". " + ((Test)AOT[i]).GetNameOfTest() + " - " + tf.mark + "\n";
                        }


                        string caption = "Оцінки за проходження колекції тестів: \"" + NameOfColl + "\"";

                        if (COT.GetHowMark() == 0 || COT.GetHowMark() == 2)
                        {
                            message += "\n Загальна оцінка за вказаними тестами - " + SummOfMark;
                            //запись в журнал результатов
                            this.MF.setting.AddLogCollection(CurrentUser.GetID(), (Predmet)this.listBoxPredmet.SelectedItem, COT, APrav, ANeprav, CollMark, SummOfMark);
                        }
                        else
                        {
                            message += "\n Середньоарифметична оцінка за вказаними тестами - " + ((float)SummOfMark) / (AOT.Count);
                            this.MF.setting.AddLogCollection(CurrentUser.GetID(), (Predmet)this.listBoxPredmet.SelectedItem, COT, APrav, ANeprav, CollMark, ((float)SummOfMark) / (AOT.Count));
                        }

                        MessageBox.Show(message, caption);
                        this.Visible = true;
                    }
                    else
                    //єто тест
                    {
                        Test T = new Test();
                        T = (Test)SelectPredmet.FindTest(NameofTest);
                        TestForm tf = new TestForm(T, CurrentUser);
                        this.Visible = false;
                        tf.ShowDialog();
                        //запись в журнал результатов
                        this.MF.setting.AddLogTest(this.CurrentUser.GetID(), (Predmet)this.listBoxPredmet.SelectedItem, T, tf.prav, tf.neprav, tf.mark);
                        tf.Close();
                        this.Visible = true;
                    }
                }
                this.listBox1_SelectedIndexChanged(this.listBoxPredmet, new EventArgs());
            }
        }
示例#4
0
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            String name      = this.openFileDialog1.SafeFileName;
            String Extention = name.Substring(name.Length - 5);
            String ShortName = name.Substring(0, name.Length - 5);

            byte[]           Key     = { 13, 20, 94, 153, 8, 22, 109, 154, 231, 97, 91, 118, 97, 208, 214, 249, 128, 246, 150, 170, 173, 191, 207, 138 };
            byte[]           IV      = { 227, 182, 38, 145, 55, 77, 174, 23 };
            Test             NewTest = new Test();
            CollectionOfTest COT     = new CollectionOfTest();

            if (Extention.Equals(".test")) //добавление теста
            {
                //проверка нет ли такого же названия (файла)

                Object [] AllTest = this.CurrentTeacher.GetArrayOfPredmet()[this.listBoxPredmet.SelectedIndex].GetTests();

                if (!this.MF.setting.GetOnlyOur())
                {//дозволено додавання нових тестів всім
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    FileStream fs = new FileStream(
                        this.openFileDialog1.FileName, FileMode.Open, FileAccess.Read);

                    System.Security.Cryptography.CryptoStream cStream = new System.Security.Cryptography.CryptoStream(fs,
                                                                                                                      new System.Security.Cryptography.TripleDESCryptoServiceProvider().CreateDecryptor(Key, IV),
                                                                                                                      System.Security.Cryptography.CryptoStreamMode.Read);
                    NewTest = (Test)bf.Deserialize(cStream);

                    cStream.Close();
                    fs.Close();
                    if (NewTest.GetOwnerID() != this.CurrentTeacher.GetID())
                    {
                        MessageBox.Show("  Тест, що додається, не створений Вами.\n Зверніться до адміністратора для встановлення опції \n \"Дозволити додавання тестів не їх \"власником\"\".");
                    }
                    else
                    {//перевырка чи вже не доданий аналогычний тест
                        bool SameFileITest = false;
                        for (int i = 0; i < AllTest.Length; i++)
                        {
                            if (AllTest[i].ToString().Equals(NewTest.ToString()))
                            {
                                SameFileITest = true;
                            }
                        }
                        if (SameFileITest)
                        {
                            MessageBox.Show("Тест з цього файлу вже добавлено! Виберіть інший файл!");
                        }
                        else
                        {
                            if (!NewTest.ToString().Equals((new Test()).ToString()))                                         //если что-то с файлов прочитано
                            {
                                this.CurrentTeacher.GetArrayOfPredmet()[this.listBoxPredmet.SelectedIndex].AddTest(NewTest); //тут добавляем тест из файла
                            }
                            else
                            {
                                MessageBox.Show("Неможливо добавити тест з цього файлу! Виберіть інший файл!");
                            }
                        }
                    }
                }
                else //разрешено добавление тестов только собственниками
                {
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    FileStream fs = new FileStream(
                        this.openFileDialog1.FileName, FileMode.Open, FileAccess.Read);

                    System.Security.Cryptography.CryptoStream cStream = new System.Security.Cryptography.CryptoStream(fs,
                                                                                                                      new System.Security.Cryptography.TripleDESCryptoServiceProvider().CreateDecryptor(Key, IV),
                                                                                                                      System.Security.Cryptography.CryptoStreamMode.Read);
                    NewTest = (Test)bf.Deserialize(cStream);

                    cStream.Close();
                    fs.Close();

                    {//перевырка чи вже не доданий аналогычний тест
                        bool SameFileITest = false;
                        for (int i = 0; i < AllTest.Length; i++)
                        {
                            if (AllTest[i].ToString().Equals(NewTest.ToString()))
                            {
                                SameFileITest = true;
                            }
                        }
                        if (SameFileITest)
                        {
                            MessageBox.Show("Тест з цього файлу вже добавлено! Виберіть інший файл!");
                        }
                        else
                        {
                            if (!NewTest.ToString().Equals((new Test()).ToString()))                                         //если что-то с файлов прочитано
                            {
                                this.CurrentTeacher.GetArrayOfPredmet()[this.listBoxPredmet.SelectedIndex].AddTest(NewTest); //тут добавляем тест из файла
                            }
                            else
                            {
                                MessageBox.Show("Неможливо добавити тест з цього файлу! Виберіть інший файл!");
                            }
                        }
                    }
                }
            }
            if (Extention.Equals(".tcln")) //добавление колекції
            {
                //проверка нет ли такого же названия (файла)
                Object[] AllTest = this.CurrentTeacher.GetArrayOfPredmet()[this.listBoxPredmet.SelectedIndex].GetTests();

                if (!this.MF.setting.GetOnlyOur())
                {    //разрешено добавлять всем
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    System.IO.FileStream fs = new FileStream(
                        this.openFileDialog1.FileName, FileMode.Open, FileAccess.Read);

                    System.Security.Cryptography.CryptoStream cStream = new System.Security.Cryptography.CryptoStream(fs,
                                                                                                                      new System.Security.Cryptography.TripleDESCryptoServiceProvider().CreateDecryptor(Key, IV),
                                                                                                                      System.Security.Cryptography.CryptoStreamMode.Read);



                    COT = ((CollectionOfTest)bf.Deserialize(cStream));

                    cStream.Close();
                    fs.Close();

                    if (COT.GetOwnerID() != this.CurrentTeacher.GetID())
                    {
                        MessageBox.Show("  Тест, що додається, не створений Вами.\n Зверніться до адміністратора для встановлення опції \n \"Дозволити додавання тестів не їх \"власником\"\".");
                    }
                    else
                    {
                        bool SameFileITest = false;
                        for (int i = 0; i < AllTest.Length; i++)
                        {
                            if (AllTest[i].ToString().Equals(COT.ToString()))
                            {
                                SameFileITest = true;
                            }
                        }
                        if (SameFileITest)
                        {
                            MessageBox.Show("Тест з цього файлу вже добавлено! Виберіть інший файл!");
                        }
                        else
                        {
                            this.CurrentTeacher.GetArrayOfPredmet()[this.listBoxPredmet.SelectedIndex].AddCollection(COT);          //тут добавляем тест из файла
                        }
                    }
                }

                else
                {     //разрешено добавлЯть только собственникам
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    System.IO.FileStream fs = new FileStream(
                        this.openFileDialog1.FileName, FileMode.Open, FileAccess.Read);

                    System.Security.Cryptography.CryptoStream cStream = new System.Security.Cryptography.CryptoStream(fs,
                                                                                                                      new System.Security.Cryptography.TripleDESCryptoServiceProvider().CreateDecryptor(Key, IV),
                                                                                                                      System.Security.Cryptography.CryptoStreamMode.Read);



                    COT = ((CollectionOfTest)bf.Deserialize(cStream));

                    cStream.Close();
                    fs.Close();

                    bool SameFileITest = false;
                    for (int i = 0; i < AllTest.Length; i++)
                    {
                        if (AllTest[i].ToString().Equals(COT.ToString()))
                        {
                            SameFileITest = true;
                        }
                    }
                    if (SameFileITest)
                    {
                        MessageBox.Show("Тест з цього файлу вже добавлено! Виберіть інший файл!");
                    }
                    else
                    {
                        this.CurrentTeacher.GetArrayOfPredmet()[this.listBoxPredmet.SelectedIndex].AddCollection(COT);              //тут добавляем тест из файла
                    }
                }
            }
        }