コード例 #1
0
 private void checkTeacher()
 {
     conn = new SqlConnection(connectionString);
     conn.Open();
     SqlCommand comm = new SqlCommand();
     comm.Connection = conn;
     comm.CommandText = "select [№ преподавателя] from Преподаватель where Фамилия = '" + textBox1.Text + "' and Имя = '" + textBox2.Text + "' and Отчество = '" + textBox3.Text + "' and Пароль = '" + textBox4.Text + "'";
     SqlDataReader rdr = comm.ExecuteReader();
     if (rdr.HasRows)
     {
         label6.Visible = false;
         rdr.Read();
         menuPrepod tw = new menuPrepod(rdr[0].ToString());
         tw.Show();
         this.Hide();
     }
     else
     {
         label6.Visible = true;
         clearColumns();
     }
     rdr.Close();
     conn.Close();
 }
コード例 #2
0
 private void выходToolStripMenuItem_Click(object sender, EventArgs e)
 {
     menuPrepod menupr = new menuPrepod(numTeacher.ToString());
     menupr.Show();
     this.Hide();
 }
コード例 #3
0
 private void выйтиToolStripMenuItem_Click(object sender, EventArgs e)
 {
     menuPrepod rf = new menuPrepod(numPrepod);
     rf.Show();
     this.Hide();
 }
コード例 #4
0
 private void btnExit_Click(object sender, EventArgs e)
 {
     menuPrepod menupr = new menuPrepod(numPrepod.ToString());
     menupr.Show();
     this.Hide();
 }
コード例 #5
0
 private void btnPrev_Click(object sender, EventArgs e)
 {
     this.Hide();
     menuPrepod menuPr = new menuPrepod(numTeacher.ToString());
     menuPr.Show();
 }
コード例 #6
0
        private void btnTestDone_Click(object sender, EventArgs e)
        {
            if (SaveTest == false)
            {
                string pathprepod;
                conn = new SqlConnection(connectionString);
                using (conn)
                {
                    conn.Open();
                    SqlCommand comm = new SqlCommand();
                    comm.Connection = conn;
                    try
                    {
                        comm.CommandText = "select [Путь к папке] from Преподаватель where [№ преподавателя]=" + "'" + NumTeacher.ToString() + "'";
                        comm.ExecuteNonQuery();
                        SqlDataReader rdr = comm.ExecuteReader();
                        rdr.Read();
                        pathprepod = rdr[0].ToString();
                        rdr.Close();
                    }
                    finally
                    {
                        conn.Close();
                    }
                    Pictures=false;
                    for (int pop = 0; pop <= Questions.Count-1;pop++)
                    {
                        if (PicturePaths[pop] != null)
                            Pictures = true;
                    }
                        if (Pictures == true)
                        {
                            System.IO.Directory.CreateDirectory(Application.StartupPath + pathprepod + "Тесты\\" + NameTest);
                            writer = new XmlTextWriter(Application.StartupPath + pathprepod + "Тесты\\" + NameTest + "\\" + NameTest + ".xml", Encoding.UTF8);
                            writer.Formatting = Formatting.Indented;
                            tempstring="";
                            for (int pop = 0; pop <= Questions.Count-1;pop++)
                            {
                                if (PicturePaths[pop]!=null)
                                {
                                    tempstring=PicturePaths[pop].Substring(PicturePaths[pop].LastIndexOf(@"\"));
                                    //tempstring = tempstring.Remove(0, 1);
                                    File.Copy(PicturePaths[pop], Application.StartupPath + pathprepod + "Тесты\\" + NameTest + tempstring);
                                    //tek.question = Application.StartupPath + pathprepod + "Тесты\\" + NameTest + tempstring;
                                    Questions[pop].question = Application.StartupPath + pathprepod + "Тесты\\" + NameTest + tempstring;
                                }
                                //1--получить имя
                                //2--скопировать в папку
                                //3 заменить путь в tek на новый
                            }
                            //File.Copy(PicturePath, Application.StartupPath + pathprepod + "Тесты\\" + NameTest);
                        }
                        else
                        {
                            writer = new XmlTextWriter(Application.StartupPath + pathprepod + "Тесты\\" + NameTest + ".xml", Encoding.UTF8);
                            writer.Formatting = Formatting.Indented;
                        }
                            writer.WriteStartDocument();
                            writer.WriteStartElement("Test");

                            writer.WriteStartElement("Discription");
                            writer.WriteString(DescrTest);
                            writer.WriteEndElement();

                            writer.WriteStartElement("Theme");
                            writer.WriteString(ThemeTest);
                            writer.WriteEndElement();

                            writer.WriteStartElement("Discipline");
                            writer.WriteString("C#");
                            writer.WriteEndElement();

                            writer.WriteStartElement("Questions");

                            //-------

                            writer.WriteStartAttribute("Number");
                            int p = Questions.Count;
                            writer.WriteString(p.ToString());
                            writer.WriteEndAttribute();
                            for (int i = 0; i <= Questions.Count - 1; i++)
                            {
                                writer.WriteStartElement("Question" + Questions[i].num);

                                writer.WriteStartElement("Text");
                                writer.WriteString(Questions[i].question);
                                writer.WriteEndElement();

                                #region TypeAnswer
                                //writer.WriteStartAttribute("Type Answer");
                                writer.WriteStartElement("TypeAnswer");
                                if (Questions[i].type_question == "Один вариант ответа")
                                {
                                    writer.WriteString("One");
                                    Questions[i].price = Int32.Parse(numList1.Value.ToString());
                                }
                                else
                                    if (Questions[i].type_question == "Несколько вариантов ответа")
                                    {
                                        writer.WriteString("Several");
                                        Questions[i].price = Int32.Parse(numList2.Value.ToString());
                                    }
                                    else
                                        if (Questions[i].type_question == "Выстроить последовательность")
                                        {
                                            writer.WriteString("Sequence");
                                            Questions[i].price = Int32.Parse(numList3.Value.ToString());
                                        }
                                        else
                                            if (Questions[i].type_question == "Свободный ответ")
                                            {
                                                writer.WriteString("Writing");
                                                Questions[i].price = Int32.Parse(numList4.Value.ToString());
                                            }
                                            else
                                            {
                                                writer.WriteString("Comparison");
                                                Questions[i].price = Int32.Parse(numList5.Value.ToString());
                                            }
                                //writer.WriteEndAttribute();
                                writer.WriteEndElement();
                                #endregion

                                #region Answers
                                //writer.WriteStartAttribute("Answers");
                                writer.WriteStartElement("Answers");
                                if (Questions[i].answ2 != null)
                                    writer.WriteString(Questions[i].answ1 + "|" + Questions[i].answ2 + "|" + Questions[i].answ3 + "|" + Questions[i].answ4);
                                else
                                    writer.WriteString(Questions[i].answ1);
                                //writer.WriteEndAttribute();
                                writer.WriteEndElement();
                                #endregion

                                #region RightAnswer
                                //Записываем правильный ответ в атрибут Right answer
                                //writer.WriteStartAttribute("Right answer");
                                writer.WriteStartElement("RightAnswer");
                                if (Questions[i].type_question == "Один вариант ответа")
                                {
                                    for (int h = 0; h <= 3; h++)
                                    {
                                        if (Questions[i].rightans[h] != null)
                                            writer.WriteString(Questions[i].rightans[h]);
                                    }
                                }
                                else
                                    if (Questions[i].type_question == "Несколько вариантов ответа")
                                    {
                                        string tmp = null;
                                        for (int h = 0; h <= 3; h++)
                                        {
                                            if (Questions[i].rightans[h] != null)
                                            {
                                                tmp = tmp + Questions[i].rightans[h];
                                                tmp = tmp + "|";
                                            }
                                        }
                                        for (int h = 0; h <= 3; h++)
                                        {
                                            if (tmp != null)
                                                if (tmp.LastIndexOf("|") == tmp.Length - 1)
                                                    tmp = tmp.Remove(tmp.Length - 1, 1);
                                        }
                                        writer.WriteString(tmp);

                                    }

                                    else
                                        if (Questions[i].type_question == "Выстроить последовательность")
                                        {
                                            string tmp = null;
                                            for (int h = 0; h <= 3; h++)
                                            {
                                                if (Questions[i].rightans[h] != null)
                                                {
                                                    tmp = tmp + Questions[i].rightans[h];
                                                    tmp = tmp + "|";
                                                }
                                            }
                                            if (tmp.LastIndexOf("|") == tmp.Length - 1)
                                                tmp = tmp.Remove(tmp.Length - 1, 1);
                                            writer.WriteString(tmp);
                                        }
                                        else
                                            if (Questions[i].type_question == "Свободный ответ")
                                                writer.WriteString(Questions[i].rightans[0]);
                                            else
                                            {
                                                string tmp = null;
                                                tmp = Questions[i].rightans[0] + "==" + Questions[i].rightans[1];
                                                tmp = tmp + "|" + Questions[i].rightans[2] + "==" + Questions[i].rightans[3];
                                                writer.WriteString(tmp);
                                            }
                                //writer.WriteEndAttribute();
                                writer.WriteEndElement();
                                #endregion

                                #region Part
                                //writer.WriteStartAttribute("Part");
                                writer.WriteStartElement("Part");
                                string temp = null;
                                for (int u = 0; u <= 9; u++)
                                {
                                    if (Questions[i].part[u] != null)
                                    {
                                        temp = temp + Questions[i].part[u];
                                        temp = temp + "|";
                                    }
                                }
                                //if(temp!=null)
                                //  if (temp.LastIndexOf("|") == temp.Length - 1)
                                //    temp.Remove(temp.Length - 1, 1);
                                for (int h = 0; h <= 9; h++)
                                {
                                    if (temp != null)
                                        if (temp.LastIndexOf("|") == temp.Length - 1)
                                            temp.Remove(temp.Length - 1, 1);
                                }
                                if (temp == null)
                                    temp = "";
                                writer.WriteString(temp);
                                //writer.WriteEndAttribute();
                                writer.WriteEndElement();
                                #endregion

                                #region Price
                                //writer.WriteStartAttribute("Price");
                                writer.WriteStartElement("Price");
                                writer.WriteString(Questions[i].price.ToString());
                                //writer.WriteEndAttribute();
                                writer.WriteEndElement();
                                #endregion

                                writer.WriteEndElement();
                            }
                            writer.WriteEndElement();
                            //Завершение записи
                            writer.WriteStartElement("Time");

                            writer.WriteString(numTime.Value.ToString());
                            writer.WriteEndElement();

                            writer.WriteStartElement("Report");
                            writer.WriteString(cBOtch.Text);
                            writer.WriteEndElement();

                            //Завершаем написание документа
                            writer.WriteEndElement(); //Закрывем основной тэг - test
                            writer.WriteEndDocument(); //Закрываем документ

                            writer.Close();

                            MessageBox.Show("Тест был успешно создан!", "Выход");
                            insertTask();
                            insertTest();
                            SaveTest = true;
                       // }
                    menuPrepod newmenu = new menuPrepod(NumTeacher.ToString());
                    this.Hide();
                    newmenu.Show();
                } conn.Close();
            }
            else
            {
                MessageBox.Show("Тест уже сохранен.", "Ошибка!");
            }
        }
コード例 #7
0
 private void taskEditor_FormClosed(object sender, FormClosedEventArgs e)
 {
     menuPrepod mp = new menuPrepod(numPrepod);
     mp.Show();
 }