Esempio n. 1
0
        ///////////////////////////////////////////////
        public static void ReadXMLDocument(string name)
        {
            string      filepath = name + ".xml";
            FileStream  fs       = new FileStream(filepath, FileMode.Open);
            XmlDocument xd       = new XmlDocument();

            xd.Load(fs);

            XmlNodeList list = xd.GetElementsByTagName("Question"); //сделал тот крутой список из всех объектов xml документа наз-ся Question [тип 1]

            Global.QSet.Clear();                                    //старое очистим

            for (int i = 0; i < list.Count; i++)                    //запонляю свой список вопросами из файла
            {
                Global.Question New = new Global.Question();        //новый вопрос
                New.id          = list[i].Attributes[0].Value;
                New.Text        = list[i].ChildNodes[0].InnerText;
                New.Queue_place = Convert.ToInt32(list[i].ChildNodes[1].InnerText);
                New.Queue_name  = list[i].ChildNodes[2].InnerText;
                New.ratio       = list[i].ChildNodes[3].InnerText;
                Global.QSet.Add(New); //добавляем
            }

            fs.Close();
            xd.Save(filepath);
        }
Esempio n. 2
0
        public void Change_Click(object sender, EventArgs e)
        {
            QChanging QChanging = new QChanging(this);

            this.Hide();
            int    index = dataGridView1.CurrentRow.Index;
            string ind   = dataGridView1.CurrentRow.Cells[0].Value.ToString();

            QChanging.ShowDialog();
            QChanging.Close();
            Global.Question New = new Global.Question();
            New      = Global.QSet.Find(p => p.id == ind);
            New.id   = QChanging.textBox1.Text;
            New.Text = QChanging.QuestionWrite.Text;
            Global.QSet.Sort(new Global.Question.SortById());
            FillDataGridView(Global.QSet);
            textBox1.Text = (MaxIndex(Global.QSet) + 1) + "";
            this.Show();
        }
Esempio n. 3
0
        private void Next_Click(object sender, EventArgs e) //Добавить
        {
            if (IndexExists(textBox1.Text))
            {
                MessageBox.Show("Вопрос с таким номером уже существует!");
                return;
            }
            int a = -10;

            try
            {
                a = Convert.ToInt32(textBox1.Text);
            }
            catch
            {
                MessageBox.Show("Номер вопроса должен быть натуральным, положительным числом!");
                return;
            }
            if (a <= 0)
            {
                MessageBox.Show("Номер вопроса должен быть натуральным, положительным числом!");
                return;
            }
            Global.Question New = new Global.Question();
            New.Text        = QuestionWrite.Text;
            New.Queue_place = Global.LastPlaceInQueue("A");
            New.id          = textBox1.Text;
            New.Queue_name  = "A";
            New.ratio       = null;
            Global.QSet.Add(New);
            Global.QSet.Sort(new Global.Question.SortById());
            FillDataGridView(Global.QSet);
            QuestionWrite.Text = null; //обновим
            textBox1.Text      = (MaxIndex(Global.QSet) + 1) + "";
            if (Global.QSet.Count > 0)
            {
                Delete.BackColor = Color.FromArgb(255, 255, 192);
                Delete.Enabled   = true;
                Change.BackColor = Color.FromArgb(255, 255, 192);
                Change.Enabled   = true;
            }
            QuestionWrite.Focus();
        }
Esempio n. 4
0
 private void Delete_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow r in dataGridView1.SelectedRows)
     {
         string          ind = r.Cells[0].Value.ToString();
         Global.Question New = new Global.Question();
         New = Global.QSet.Find(p => p.id == ind);
         dataGridView1.Rows.Remove(r);
         Global.CorrectErrorInQueue(New.Queue_name, New.Queue_place);
         Global.QSet.Remove(New);
     }
     textBox1.Text = (MaxIndex(Global.QSet) + 1) + "";
     if (Global.QSet.Count == 0)
     {
         Delete.BackColor = Color.Gray;
         Delete.Enabled   = false;
         Change.BackColor = Color.Gray;
         Change.Enabled   = false;
     }
 }