Exemplo n.º 1
0
        public void Delete(int id)
        {
            clQuestion question = getItem(id);

            list.Remove(question);

            question.Delete();
        }
Exemplo n.º 2
0
        private void LoadFromSql()
        {
            sql       sql1 = new sql();
            DataTable dt   = sql1.GetRecords("exec Question_Select");

            list.Clear();

            foreach (DataRow row in dt.Rows)
            {
                clQuestion question = new clQuestion(row);
                Add(question);
            }
        }
Exemplo n.º 3
0
 public void Add(clQuestion question)
 {
     list.Add(question);
 }
Exemplo n.º 4
0
        private void загрузитьEmailToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = @"C:\";
            openFileDialog.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*";
            openFileDialog.FilterIndex = 2;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Multiselect = false;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                ExcelDoc excelDoc = new ExcelDoc(openFileDialog.FileName);
                int err = 0;
                int i = 2;
                try
                {

                    bool quest = true;
                    string s1;
                    clQuestion question = new clQuestion(globalData.UserID);

                    while (excelDoc.getValue("A" + i.ToString(), "A" + i.ToString()) != null)
                    {
                        s1 = excelDoc.getValue("A" + i.ToString(), "A" + i.ToString()).ToString().Replace("\"", "'");

                        if (quest)
                        {
                            question = new clQuestion(globalData.UserID);
                            question.Text = s1;
                            question.Save();

                            quest = false;
                        }
                        else
                        {
                            clAnswer answer = question.CreateAnswed();
                            answer.Right = (excelDoc.getValue("B" + i.ToString(), "B" + i.ToString()) != null);
                            answer.Text = s1;
                            answer.Save();
                        }

                        i++;

                        if (excelDoc.getValue("A" + i.ToString(), "A" + i.ToString()) == null)
                        {
                            i++;
                            quest = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ошибка при чтении файла. Системная ошибка: " + ex.Message + " В строке " + i.ToString());
                    err++;
                }
                finally
                {
                    if (err == 0)
                    {
                        excelDoc.Dispose();
                    }
                    else
                    {
                        MessageBox.Show("Загрузка завершена. Найдено " + err.ToString() + " ошибок.");
                        excelDoc.Show();
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void LoadFromSql()
        {
            Sql sql1 = new Sql();
            DataTable dt = sql1.GetRecords("exec Question_Select");

            list.Clear();

            foreach (DataRow row in dt.Rows)
            {
                clQuestion question = new clQuestion(row);
                Add(question);
            }
        }
Exemplo n.º 6
0
 public void Add(clQuestion question)
 {
     list.Add(question);
 }