示例#1
0
        //确定事件
        private void button1_Click(object sender, EventArgs e)
        {
            string sql    = "SELECT name FROM [dbo].[Users] WHERE name='" + name_textbox.Text + "'";
            int    result = DatabaseHelp.SelectNum(sql);

            if (passwd_textbox.Text != passwd2_textbox.Text)
            {
                MessageBox.Show("请输入相同的密码");
                return;
            }
            if (result != 0)
            {
                MessageBox.Show("该用户名已被注册!");
            }
            else
            {
                sql    = "INSERT INTO [dbo].[Users] (name, password, email, time, acc, question_num) VALUES";
                sql   += "('" + name_textbox.Text + "','" + passwd_textbox.Text + "','" + mail_textbox.Text + "',";
                sql   += "0.0, 0.0, 0)";
                result = DatabaseHelp.executeCommand(sql);
                if (result == 0)
                {
                    MessageBox.Show("用户创建失败,请联系管理员");
                    return;
                }
                MessageBox.Show("用户创建成功");
                DialogResult = DialogResult.OK;
            }
        }
示例#2
0
        //完成
        private void button3_Click(object sender, EventArgs e)
        {
            intostring();
            string sql = "select * from ReadingQuestionType where type = '" + comboBox1.Text + "'";

            if (DatabaseHelp.SelectNum(sql) == 0)
            {
                comboBox1.Items.Add(comboBox1.Text);
                if (model <= 3)
                {
                    sql = "insert into ReadingQuestionType values('" + comboBox1.Text + "')";
                }
                else if (model == 4)
                {
                    sql = "insert into ComWritingSubject values('" + comboBox1.Text + "')";
                }
                else
                {
                    sql = "insert into IndWritingSubject values('" + comboBox1.Text + "')";
                }
                DatabaseHelp.executeCommand(sql);
            }

            sql = "select * from ReadingArticleSubject where subject = '" + comboBox2.Text + "'";
            if (DatabaseHelp.SelectNum(sql) == 0)
            {
                comboBox2.Items.Add(comboBox2.Text);
                sql = "insert into ReadingArticleSubject values('" + comboBox2.Text + "')";
                DatabaseHelp.executeCommand(sql);
            }
            MessageBox.Show("完成");
        }
示例#3
0
        private void updateAccNum()
        {
            string sql;

            sql = "select * from Users where name = '" + SystemConfig.name + "'";
            SqlDataReader reader = DatabaseHelp.getReader(sql);

            reader.Read();
            SystemConfig.acc          = DatabaseHelp.convert(SystemConfig.acc, reader["acc"]);
            SystemConfig.question_num = DatabaseHelp.convert(SystemConfig.question_num, reader["question_num"]);
            reader.Close();
            right_label.Text = "      平均正确率:" + SystemConfig.acc.ToString("f2");
            count_label.Text = "累计练习题目数量:" + SystemConfig.question_num.ToString();
        }
示例#4
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult closeWindowsBox = MessageBox.Show("你舍得离我而去吗???", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (closeWindowsBox == DialogResult.Yes)
            {
                //写入数据库
                SystemConfig.end_time = Timer();
                double updateTime = SystemConfig.end_time - SystemConfig.start_time;
                updateTime = SystemConfig.time + updateTime / 60;
                string sql = "update Users set time = " + updateTime + "where name = '" + SystemConfig.name + "'";
                DatabaseHelp.executeCommand(sql);
            }
        }
示例#5
0
        private void setup()
        {
            double time = SystemConfig.time;

            label1.Text      = "你好! " + SystemConfig.name;
            study_label.Text = "    累计学习时间:" + ((int)time).ToString() + "h";
            if ((int)((time - (int)time) * 60) != 0)
            {
                study_label.Text += ((int)((time - (int)time) * 60)).ToString() + "m";
            }
            right_label.Text        = "      平均正确率:" + SystemConfig.acc.ToString("f2");
            count_label.Text        = "累计练习题目数量:" + SystemConfig.question_num.ToString();
            SystemConfig.start_time = Timer();
            if (SystemConfig.name == "admin")
            {
                button1.Visible = false;
                button2.Visible = false;
                button3.Visible = false;
                label5.Text     = "意见反馈列表";
                listBox1.Items.Clear();
                string        sql    = "select * from (select *,ROW_NUMBER() over(order by date) as num from UserSuggestion) as x where num < 15";
                SqlDataReader reader = DatabaseHelp.getReader(sql);
                while (reader.Read())
                {
                    listBox1.Items.Add(reader["name"].ToString().Trim() + ":" + reader["title"]);
                }
                reader.Close();
            }
            else
            {
                listBox1.Items.Clear();
                string sql = "select * from ReadingQuestion inner join (select id,ReadingAns.date from ReadingAns where (name = '";
                sql += SystemConfig.name + "'and ReadingAns.date in (select max(date) as date from ReadingAns where name = '";
                sql += SystemConfig.name;
                sql += "' and correct = 0 group by id))) as xx on ReadingQuestion.id = xx.id order by date desc";
                SqlDataReader reader = DatabaseHelp.getReader(sql);
                errid = new int[15];
                for (int i = 0; i < 15; i++)
                {
                    if (!reader.Read())
                    {
                        break;
                    }
                    listBox1.Items.Add(reader["type"] + ":" + reader["stem"]);
                    errid[i] = Convert.ToInt32(reader["id"]);
                }
                reader.Close();
            }
        }
示例#6
0
        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)//综合写作
        {
            string sql = "SELECT * FROM[dbo].[ComWritingProblem] WHERE subject='" + comboBox3.SelectedItem + "'";

            listView3.Items.Clear();
            SqlDataReader reader = DatabaseHelp.getReader(sql);
            int           i      = 0;

            while (reader.Read())
            {
                listView3.Items.Add(new ListViewItem(new string[] { (i + 1).ToString(), DatabaseHelp.convert("", reader["setid"].ToString()) }));
                i++;
            }
            reader.Close();
        }
示例#7
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string sql = "SELECT * FROM[dbo].[ReadingArticle] WHERE subject='" + comboBox1.SelectedItem + "'";

            listView1.Items.Clear();
            SqlDataReader reader = DatabaseHelp.getReader(sql);
            int           i      = 0;

            while (reader.Read())
            {
                listView1.Items.Add(new ListViewItem(new string[] { (i + 1).ToString(), DatabaseHelp.convert("", reader["setid"].ToString()), DatabaseHelp.convert("", reader["title"]) }));
                i++;
            }
            reader.Close();
        }
示例#8
0
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string sql = "SELECT * FROM[dbo].[ReadingQuestion] WHERE type='" + comboBox2.SelectedItem + "'";

            listView2.Items.Clear();
            SqlDataReader reader = DatabaseHelp.getReader(sql);
            int           i      = 0;

            while (reader.Read())
            {
                listView2.Items.Add(new ListViewItem(new string[] { (i + 1).ToString(), DatabaseHelp.convert("", reader["num"].ToString()), DatabaseHelp.convert("", reader["stem"]), reader["id"].ToString() }));
                i++;
            }
            reader.Close();
        }
示例#9
0
        private void button1_Click(object sender, EventArgs e)
        {
            string sc1 = textBox1.Text;
            string sc  = "";

            string[] ssts = sc1.Split('\'');
            for (int i = 0; i < ssts.Count(); i++)
            {
                if (i != 0)
                {
                    sc += "''";
                }
                sc += ssts[i];
            }

            int    result;
            string cm1 = richTextBox1.Text;
            string cm  = "";

            string[] sts = cm1.Split('\'');
            for (int i = 0; i < sts.Count(); i++)
            {
                if (i != 0)
                {
                    cm += "''";
                }
                cm += sts[i];
            }
            string sql = "INSERT INTO [dbo].[UserSuggestion]([name],[suggest],[date],[title])  ";

            sql += "VALUES('" + SystemConfig.name + "','" + cm + "','" + DateTime.Now + "','" + sc + "')";
            try
            {
                result = DatabaseHelp.executeCommand(sql);
            }
            catch (Exception ex)
            {
                MessageBox.Show("感谢您的反馈,我们会尽快处理");
                return;
            }
            if (result == 0)
            {
                MessageBox.Show("感谢您的反馈,我们会尽快处理");
                return;
            }
            MessageBox.Show("感谢您的反馈,我们会尽快处理");
            DialogResult = DialogResult.OK;
        }
示例#10
0
        private void reading_Click(object sender, EventArgs e)
        {
            int artnumber = Convert.ToInt32((sender as Button).Name.Replace("button", ""));

            string name = "reading" + artnumber.ToString();
            string sql  = "select " + name + " from [dbo].[TestSet] where id=" + this.tpoNo.ToString();

            SqlDataReader reader = DatabaseHelp.getReader(sql);

            reader.Read();
            int x = DatabaseHelp.convert(1, reader[name]);

            reader.Close();

            reading read_form = new reading(1, x);

            read_form.ShowDialog();
        }
示例#11
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count != 1)
            {
                return;
            }
            string        title  = listView1.SelectedItems[0].SubItems[2].Text;
            string        sql    = "select [id] from [dbo].[ReadingArticle] where title='" + title + "'";
            SqlDataReader reader = DatabaseHelp.getReader(sql);

            reader.Read();
            int x = DatabaseHelp.convert(1, reader["id"]);

            reader.Close();
            reading rd = new reading(1, x);

            rd.ShowDialog();
        }
示例#12
0
        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = this.listBox1.IndexFromPoint(e.Location);

            if (index == System.Windows.Forms.ListBox.NoMatches)
            {
                return;
            }
            if (SystemConfig.name == "admin")
            {
                string[] item;
                item = listBox1.Items[index].ToString().Split(':');
                string name  = item[0];
                string title = "";
                for (int i = 1; i < item.Length; i++)
                {
                    title += item[i];
                }
                string        sql    = "select * from UserSuggestion where name = '" + name + "' and title = '" + title + "'";
                SqlDataReader reader = DatabaseHelp.getReader(sql);
                while (reader.Read())
                {
                    feedbackAdmin fd     = new feedbackAdmin(reader["title"].ToString(), reader["name"].ToString(), reader["suggest"].ToString(), reader["date"].ToString());
                    DialogResult  result = fd.ShowDialog();
                    if (result == DialogResult.No)
                    {
                        reader.Close();
                        return;
                    }
                }
                reader.Close();
                sql = "delete from UserSuggestion where name = '" + name + "' and title = '" + title + "'";
                DatabaseHelp.executeCommand(sql);
                setup();
            }
            else
            {
                //链接到reading界面
                reading rd = new reading(3, errid[index]);
                rd.ShowDialog();
            }
        }
示例#13
0
 private void submit()
 {
     if (model == 1) //单项
     {
         string   sql;
         int      result;
         DateTime now = DateTime.Now;
         for (int i = 0; i < arti.questionnum; i++)
         {
             sql = "insert into ReadingAns(name, date, id, ans) values('" + SystemConfig.name + "', '" + now.ToString() + "', " + rq[i].id + ", '" + studentAnswers[i] + "')";
             try {
                 result = DatabaseHelp.executeCommand(sql);
             }
             catch
             {
                 MessageBox.Show("保存失败!");
             }
         }
     }
     else if (model == 2)
     {
         string   sql;
         int      result;
         int      index = 0;
         DateTime now   = DateTime.Now;
         for (int j = 0; j < 3; j++)
         {
             for (int i = 0; i < artis[j].questionnum; i++)
             {
                 sql = "insert into ReadingAns(name, date, id, ans) values('" + SystemConfig.name + "', '" + now.ToString() + "', " + rq[index].id + ", '" + studentAnswers[index++] + "')";
                 try
                 {
                     result = DatabaseHelp.executeCommand(sql);
                 }
                 catch
                 {
                     MessageBox.Show("保存失败");
                 }
             }
         }
     }
 }
示例#14
0
 private void write_Load(object sender, EventArgs e)
 {
     if (this.model == 1)
     {
         string        sql    = "select * from IndWritingProblem where setid = " + tpo.ToString();
         SqlDataReader reader = DatabaseHelp.getReader(sql);
         reader.Read();
         label1.Text = ProString("题目:\n" + reader["stem"], 25);
         reader.Close();
     }
     else if (this.model == 2)
     {
         string        sql    = "select * from ComWritingProblem where setid = " + tpo.ToString();
         SqlDataReader reader = DatabaseHelp.getReader(sql);
         reader.Read();
         label1.Text = ProString("题目:\n" + reader["stem"], 25)
                       + ProString("\n\n阅读材料:\n\n" + reader["redmaterial"], 25)
                       + ProString("\n\n听力材料:\n\n" + reader["lismaterial"], 25);
         reader.Close();
     }
 }
示例#15
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (this.model == 1)
     {
         DialogResult submitWindowsBox = MessageBox.Show("是否确定提交", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (submitWindowsBox == DialogResult.Yes)
         {
             //写入数据库
             string sql = "insert into IndWritingAns (name, date, id, ans) values('" + SystemConfig.name + "', '" + DateTime.Now.ToString() + "', " + tpo.ToString() + ", '" + richTextBox1.Text.Replace("'", "''") + "')";
             if (DatabaseHelp.executeCommand(sql) == 0)
             {
                 MessageBox.Show("保存出现问题,请联系管理员!");
             }
             else
             {
                 MessageBox.Show("保存成功!");
             }
             DialogResult = DialogResult.OK;
         }
     }
     else if (this.model == 2)
     {
         DialogResult submitWindowsBox = MessageBox.Show("是否确定提交", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (submitWindowsBox == DialogResult.Yes)
         {
             //写入数据库
             string sql = "insert into ComWritingAns (name, date, id, ans) values('" + SystemConfig.name + "', '" + DateTime.Now.ToString() + "', " + tpo.ToString() + ", '" + richTextBox1.Text.Replace("'", "''") + "')";
             if (DatabaseHelp.executeCommand(sql) == 0)
             {
                 MessageBox.Show("保存出现问题,请联系管理员!");
             }
             else
             {
                 MessageBox.Show("保存成功!");
             }
             DialogResult = DialogResult.OK;
         }
     }
     //xxx.ShowDialog();
 }
示例#16
0
        private void setupTPO()
        {
            string sql;

            sql = "select id from [dbo].Testset";
            SqlDataReader reader = DatabaseHelp.getReader(sql);

            Button newButton;

            while (reader.Read())
            {
                newButton = new Button();
                panel1.Controls.Add(newButton);
                newButton.Name = "tpo_button" + reader["id"];
                int row = ((int)reader["id"] - 1) / 3;
                if ((int)reader["id"] % 3 == 1) //第一列 41
                {
                    newButton.Location = new Point(30, 9 + 110 * row);
                }
                else if ((int)reader["id"] % 3 == 2) //265
                {
                    newButton.Location = new Point(220, 9 + 110 * row);
                }
                else //503
                {
                    newButton.Location = new Point(410, 9 + 110 * row);
                }
                newButton.Margin = new Padding(2, 2, 2, 2);
                newButton.Size   = new Size(146, 61);
                newButton.Text   = "tpo" + reader["id"];
                newButton.UseVisualStyleBackColor = true;
                newButton.Click += new System.EventHandler(this.tpo_Click);

                newButton.Tag = newButton.Width + ":" + newButton.Height + ":" + newButton.Left + ":" + newButton.Top + ":" + newButton.Font.Size;
            }
            reader.Close();
        }
示例#17
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (SystemConfig.name == "admin")
            {
                SystemConfig.authority       = true;
                this.panel1.ContextMenuStrip = this.contextMenuStrip1;
            }
            else
            {
                SystemConfig.authority = false;
            }

            string        sql    = "SELECT [subject] FROM[dbo].[ReadingArticleSubject]";
            SqlDataReader reader = DatabaseHelp.getReader(sql);

            while (reader.Read())
            {
                comboBox1.Items.Add(reader["subject"]);
            }
            reader.Close();

            sql    = "SELECT [subject]  FROM[dbo].[ComWritingSubject]";
            reader = DatabaseHelp.getReader(sql);
            while (reader.Read())
            {
                comboBox3.Items.Add(reader["subject"]);
            }
            reader.Close();

            sql    = "SELECT [subject]  FROM[dbo].[IndWritingSubject]";
            reader = DatabaseHelp.getReader(sql);
            while (reader.Read())
            {
                comboBox4.Items.Add(reader["subject"]);
            }
            reader.Close();
        }
示例#18
0
        //确定事件
        private void button1_Click(object sender, EventArgs e)
        {
            string sql    = "SELECT * FROM [dbo].[Users] WHERE name='" + textBox1.Text + "' AND password='******'";
            int    result = DatabaseHelp.SelectNum(sql);

            if (result != 0)
            {
                SystemConfig.name = textBox1.Text;
                SqlDataReader reader = DatabaseHelp.getReader(sql);
                reader.Read();
                SystemConfig.name         = DatabaseHelp.convert(SystemConfig.name, reader["name"]).Trim();
                SystemConfig.password     = DatabaseHelp.convert(SystemConfig.password, reader["password"]).Trim();
                SystemConfig.email        = DatabaseHelp.convert(SystemConfig.email, reader["email"]).Trim();
                SystemConfig.acc          = DatabaseHelp.convert(SystemConfig.acc, reader["acc"]);
                SystemConfig.time         = DatabaseHelp.convert(SystemConfig.time, reader["time"]);
                SystemConfig.question_num = DatabaseHelp.convert(SystemConfig.question_num, reader["question_num"]);
                reader.Close();
                DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("用户名或密码不对");
            }
        }
示例#19
0
        void init()
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 20; j++)
                {
                    for (int k = 0; k < 12; k++)
                    {
                        Readtext[i, j, k] = "";
                    }
                }
            }
            for (int i = 0; i < 4; i++)
            {
                comWritetext[i] = "";
            }
            for (int i = 0; i < 3; i++)
            {
                indWritetext[i] = "";
            }
            string        sql    = "select * from ReadingQuestionType";
            SqlDataReader reader = DatabaseHelp.getReader(sql);

            while (reader.Read())
            {
                comboBox1.Items.Add(reader["type"]);
            }
            reader.Close();
            sql    = "select * from ReadingArticleSubject";
            reader = DatabaseHelp.getReader(sql);
            while (reader.Read())
            {
                comboBox2.Items.Add(reader["subject"]);
            }
            reader.Close();
        }
示例#20
0
        private void load4model2()
        {
            int i, j, k;

            this.Hide();//先藏起来,悄咪咪的load数据

            string sql    = "SELECT [id],[reading1],[reading2],[reading3] FROM[dbo].[TestSet] WHERE id=" + this.tponum.ToString();
            int    result = DatabaseHelp.SelectNum(sql);

            if (result == 0)
            {
                MessageBox.Show("本套tpo尚未导入,敬请期待");
                DialogResult = DialogResult.Cancel;
                this.Show();
                return;
            }
            //找到了这套题的信息,录入阅读文章号。

            SqlDataReader reader = DatabaseHelp.getReader(sql);

            reader.Read();
            this.artinum[0] = DatabaseHelp.convert(this.artinum[0], reader["reading1"]);
            this.artinum[1] = DatabaseHelp.convert(this.artinum[1], reader["reading2"]);
            this.artinum[2] = DatabaseHelp.convert(this.artinum[2], reader["reading3"]);
            reader.Close();

            for (i = 0; i < 3; i++)//分别录入每篇文章的信息到artis
            {
                sql    = "SELECT * FROM [dbo].[ReadingArticle] WHERE id = " + this.artinum[i].ToString();
                reader = DatabaseHelp.getReader(sql);
                reader.Read();
                this.artis[i]             = new article();
                this.artis[i].title       = DatabaseHelp.convert(this.artis[i].title, reader["title"]);
                this.artis[i].content     = DatabaseHelp.convert(this.artis[i].content, reader["article"]);
                this.artis[i].questionnum = DatabaseHelp.convert(this.artis[i].questionnum, reader["questionno"]);
                this.artis[i].questionIds = new int[this.artis[i].questionnum];
                for (j = 0; j < this.artis[i].questionnum; j++)
                {
                    this.artis[i].questionIds[j] = DatabaseHelp.convert(this.artis[i].questionIds[j], reader["questionid" + (j + 1).ToString()]);
                }
                this.artis[i].average = DatabaseHelp.convert(this.artis[i].average, reader["average"]);
                reader.Close();
            }
            this.allrqnum       = this.artis[0].questionnum + this.artis[1].questionnum + this.artis[2].questionnum;
            this.rq             = new readingQuestion[this.allrqnum];
            this.studentAnswers = new string[this.allrqnum];
            i = 0;
            for (k = 0; k < 3; k++)
            {
                for (j = 0; j < this.artis[k].questionnum; j++)
                {
                    studentAnswers[i] = "";
                    sql    = "SELECT * FROM [dbo].[ReadingQuestion] WHERE id=" + this.artis[k].questionIds[j];
                    reader = DatabaseHelp.getReader(sql);
                    reader.Read();
                    this.rq[i]           = new readingQuestion();
                    this.rq[i].id        = this.artis[k].questionIds[j];
                    this.rq[i].articleid = DatabaseHelp.convert(this.rq[i].articleid, reader["articleid"]);

                    this.rq[i].num        = DatabaseHelp.convert(this.rq[i].num, reader["num"]);
                    this.rq[i].type       = DatabaseHelp.convert(this.rq[i].type, reader["type"]);
                    this.rq[i].stem       = DatabaseHelp.convert(this.rq[i].stem, reader["stem"]);
                    this.rq[i].opnum      = DatabaseHelp.convert(this.rq[i].opnum, reader["opnum"]);
                    this.rq[i].paragraph  = DatabaseHelp.convert(this.rq[i].paragraph, reader["paragraph"]);
                    this.rq[i].paragraph2 = DatabaseHelp.convert(this.rq[i].paragraph2, reader["paragraph2"]);
                    this.rq[i].optionx    = new string[this.rq[i].opnum];
                    for (int j1 = 0; j1 < this.rq[i].opnum; j1++)
                    {
                        this.rq[i].optionx[j1] = DatabaseHelp.convert(this.rq[i].optionx[j1], reader["option" + (j1 + 1).ToString()]);
                    }
                    this.rq[i].ans      = DatabaseHelp.convert(this.rq[i].ans, reader["ans"]);
                    this.rq[i].acc      = DatabaseHelp.convert(this.rq[i].acc, reader["acc"]);
                    this.rq[i].analysis = DatabaseHelp.convert(this.rq[i].analysis, reader["analysis"]);
                    reader.Close();
                    i++;
                }
            }

            //load第一篇文章。

            button3.Enabled = false;
            this.nownum     = 0;
            this.nowarti    = 0;
            this.nowartinum = 0;
            this.webBrowser1.DocumentText = "<span style='color: rgb(128, 128, 128); text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: \"Helvetica Neue\", Helvetica, \"Hiragino Sans GB\", \"Microsoft YaHei\", Arial, sans-serif; font-size: 16px; font-style: normal; font-weight: 400; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;'>"
                                            + "<p align=\"center\">" + artis[nowarti].title + "</p>" + "<p>" + artis[nowarti].content.Replace("\r\n", "</p><p>").Replace("\n", "</p><p>") + "</p></span>";
            load_left_ins();
            this.timer1.Enabled = true;
            this.leftTime       = TimeSpan.Parse("1:0:0");
            this.label1.Text    = this.leftTime.ToString();
            this.Show();
        }
示例#21
0
        private void reading_Load(object sender, EventArgs e)//对不同的模式,有不同的load函数
        {
            if (this.model == 1)
            {
                load4model1();
            }
            else if (this.model == 2)
            {
                load4model2();
            }
            else if (this.model == 3)
            {
                this.Hide();
                label1.Visible  = false;
                button1.Visible = false;
                button2.Visible = false;
                button4.Visible = false;
                button5.Visible = false;
                button3.Visible = false;
                button6.Text    = "查看解析";
                rq    = new readingQuestion[1];
                rq[0] = new readingQuestion();

                string        sql    = "SELECT * FROM [dbo].[ReadingQuestion] WHERE id=" + this.id.ToString();
                SqlDataReader reader = DatabaseHelp.getReader(sql);
                reader.Read();
                int i = 0;
                this.rq[i].id         = this.id;
                this.rq[i].articleid  = DatabaseHelp.convert(this.rq[i].articleid, reader["articleid"]);
                this.rq[i].num        = DatabaseHelp.convert(this.rq[i].num, reader["num"]);
                this.rq[i].type       = DatabaseHelp.convert(this.rq[i].type, reader["type"]);
                this.rq[i].stem       = DatabaseHelp.convert(this.rq[i].stem, reader["stem"]);
                this.rq[i].opnum      = DatabaseHelp.convert(this.rq[i].opnum, reader["opnum"]);
                this.rq[i].paragraph  = DatabaseHelp.convert(this.rq[i].paragraph, reader["paragraph"]);
                this.rq[i].paragraph2 = DatabaseHelp.convert(this.rq[i].paragraph2, reader["paragraph2"]);
                this.rq[i].optionx    = new string[this.rq[i].opnum];
                for (int j1 = 0; j1 < this.rq[i].opnum; j1++)
                {
                    this.rq[i].optionx[j1] = DatabaseHelp.convert(this.rq[i].optionx[j1], reader["option" + (j1 + 1).ToString()]);
                }
                this.rq[i].ans      = DatabaseHelp.convert(this.rq[i].ans, reader["ans"]);
                this.rq[i].acc      = DatabaseHelp.convert(this.rq[i].acc, reader["acc"]);
                this.rq[i].analysis = DatabaseHelp.convert(this.rq[i].analysis, reader["analysis"]);


                reader.Close();

                artis = new article[1];

                sql    = "SELECT * FROM [dbo].[ReadingArticle] WHERE id = " + this.rq[0].articleid.ToString();
                reader = DatabaseHelp.getReader(sql);
                reader.Read();
                this.artis[i]         = new article();
                this.artis[i].title   = DatabaseHelp.convert(this.artis[i].title, reader["title"]);
                this.artis[i].content = DatabaseHelp.convert(this.artis[i].content, reader["article"]);

                reader.Close();
                load_left_ins();
                this.webBrowser1.DocumentText = "<span style='color: rgb(128, 128, 128); text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: \"Helvetica Neue\", Helvetica, \"Hiragino Sans GB\", \"Microsoft YaHei\", Arial, sans-serif; font-size: 16px; font-style: normal; font-weight: 400; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;'>"
                                                + "<p align=\"center\">" + artis[0].title + "</p>" + "<p>" + artis[0].content.Replace("\r\n", "</p><p>").Replace("\n", "</p><p>") + "</p></span>";
                this.Show();
            }
        }
示例#22
0
        private void peer_check_Load(object sender, EventArgs e)
        {
            if (this.model == 1)
            {
                int    i;
                string sql = "SELECT[dbo].[ComWritingAns].id as id,";
                sql   += "[dbo].[ComWritingAns].date as date,";
                sql   += "[dbo].[ComWritingAns].name as name,";
                sql   += "[dbo].[ComWritingAns].ans as ans,";
                sql   += "[dbo].[ComWritingAns].score as score,";
                sql   += "[dbo].[ComWritingAns].comment as comment,";
                sql   += "[dbo].[ComWritingProblem].stem,";
                sql   += "[dbo].[ComWritingProblem].setid as tpoid,";
                sql   += "[dbo].[ComWritingProblem].lismaterial as lismaterial,";
                sql   += "[dbo].[ComWritingProblem].redmaterial as redmaterial ";
                sql   += "FROM[dbo].[ComWritingAns],[dbo].[ComWritingProblem] ";
                sql   += "where[dbo].[ComWritingAns].id=[dbo].[ComWritingProblem].id ";
                sql   += "and ISNULL([dbo].[ComWritingAns].score,-1)= -1 ";
                sql   += "and [dbo].[ComWritingAns].name!=\'" + SystemConfig.name + "\'";
                allcom = DatabaseHelp.SelectNum(sql);
                if (allcom > 0)
                {
                    wrt1 = new writing[allcom];
                    SqlDataReader reader = DatabaseHelp.getReader(sql);
                    for (i = 0; i < allcom; i++)
                    {
                        reader.Read();
                        wrt1[i]             = new writing();
                        wrt1[i].type        = 1;
                        wrt1[i].tpoid       = DatabaseHelp.convert(wrt1[i].tpoid, reader["tpoid"]);
                        wrt1[i].id          = DatabaseHelp.convert(wrt1[i].id, reader["id"]);
                        wrt1[i].date        = DatabaseHelp.convert(wrt1[i].date, reader["date"]);
                        wrt1[i].name        = DatabaseHelp.convert(wrt1[i].name, reader["name"]);
                        wrt1[i].ans         = DatabaseHelp.convert(wrt1[i].ans, reader["ans"]);
                        wrt1[i].stem        = DatabaseHelp.convert(wrt1[i].stem, reader["stem"]);
                        wrt1[i].lismaterial = DatabaseHelp.convert(wrt1[i].lismaterial, reader["lismaterial"]);
                        wrt1[i].redmaterial = DatabaseHelp.convert(wrt1[i].redmaterial, reader["redmaterial"]);
                    }
                    reader.Close();
                }
                sql    = "SELECT[dbo].[IndWritingAns].id as id,";
                sql   += "[dbo].[IndWritingAns].date as date,";
                sql   += "[dbo].[IndWritingAns].name as name,";
                sql   += "[dbo].[IndWritingAns].ans as ans,";
                sql   += "[dbo].[IndWritingAns].score as score,";
                sql   += "[dbo].[IndWritingAns].comment as comment,";
                sql   += "[dbo].[IndWritingProblem].stem,";
                sql   += "[dbo].[IndWritingProblem].setid as tpoid ";
                sql   += "FROM[dbo].[IndWritingAns],[dbo].[IndWritingProblem] ";
                sql   += "where[dbo].[IndWritingAns].id=[dbo].[IndWritingProblem].id ";
                sql   += "and ISNULL([dbo].[IndWritingAns].score,-1)= -1 ";
                sql   += "and [dbo].[IndWritingAns].name!=\'" + SystemConfig.name + "\'";
                allind = DatabaseHelp.SelectNum(sql);
                if (allind > 0)
                {
                    wrt2 = new writing[allind];
                    SqlDataReader reader = DatabaseHelp.getReader(sql);
                    for (i = 0; i < allind; i++)
                    {
                        reader.Read();
                        wrt2[i]       = new writing();
                        wrt2[i].type  = 1;
                        wrt2[i].tpoid = DatabaseHelp.convert(wrt2[i].tpoid, reader["tpoid"]);
                        wrt2[i].id    = DatabaseHelp.convert(wrt2[i].id, reader["id"]);
                        wrt2[i].date  = DatabaseHelp.convert(wrt2[i].date, reader["date"]);
                        wrt2[i].name  = DatabaseHelp.convert(wrt2[i].name, reader["name"]);
                        wrt2[i].ans   = DatabaseHelp.convert(wrt2[i].ans, reader["ans"]);
                        wrt2[i].stem  = DatabaseHelp.convert(wrt2[i].stem, reader["stem"]);
                    }
                    reader.Close();
                }
                for (i = 0; i < allcom; i++)
                {
                    listView1.Items.Add(new ListViewItem(new string[]
                                                         { (i + 1).ToString(),
                                                           wrt1[i].tpoid.ToString(),
                                                           this.wrt1[i].name,
                                                           "综合写作",
                                                           this.wrt1[i].date.ToString() }));
                }
                for (i = 0; i < allind; i++)
                {
                    listView1.Items.Add(new ListViewItem(new string[]
                                                         { (i + allcom + 1).ToString(),
                                                           wrt2[i].tpoid.ToString(),
                                                           this.wrt2[i].name,
                                                           "独立写作",
                                                           this.wrt2[i].date.ToString() }));
                }
            }

            else if (this.model == 2)
            {
                this.listView1.Clear();
                ColumnHeader header1 = new ColumnHeader();
                header1.Text = "序号";
                ColumnHeader header2 = new ColumnHeader();
                header2.Text = "TPO编号";
                ColumnHeader header3 = new ColumnHeader();
                header3.Text = "评价者";
                ColumnHeader header4 = new ColumnHeader();
                header4.Text = "类型";
                ColumnHeader header5 = new ColumnHeader();
                header5.Text = "日期";
                this.listView1.Columns.AddRange(new ColumnHeader[] { header1, header2, header3, header4, header5 });
                richTextBox1.ReadOnly = true;
                textBox1.ReadOnly     = true;
                button1.Text          = "重新评改";
                int    i;
                string sql = "SELECT[dbo].[ComWritingAns].id as id,";
                sql += "[dbo].[ComWritingAns].date as date,";
                sql += "[dbo].[ComWritingAns].comname as comname,";
                sql += "[dbo].[ComWritingAns].name as name,";
                sql += "[dbo].[ComWritingAns].ans as ans,";
                sql += "ISNULL([dbo].[ComWritingAns].score,-1) as score,";
                sql += "[dbo].[ComWritingAns].comment as comment,";
                sql += "[dbo].[ComWritingProblem].stem,";
                sql += "[dbo].[ComWritingProblem].setid as tpoid,";
                sql += "[dbo].[ComWritingProblem].lismaterial as lismaterial,";
                sql += "[dbo].[ComWritingProblem].redmaterial as redmaterial ";
                sql += "FROM[dbo].[ComWritingAns],[dbo].[ComWritingProblem] ";
                sql += "where[dbo].[ComWritingAns].id=[dbo].[ComWritingProblem].id ";
                // sql += "and ISNULL([dbo].[ComWritingAns].score,-1)!= -1 ";
                sql   += "and [dbo].[ComWritingAns].name=\'" + SystemConfig.name + "\'";
                allcom = DatabaseHelp.SelectNum(sql);
                if (allcom > 0)
                {
                    wrt1 = new writing[allcom];
                    SqlDataReader reader = DatabaseHelp.getReader(sql);
                    for (i = 0; i < allcom; i++)
                    {
                        reader.Read();
                        wrt1[i]             = new writing();
                        wrt1[i].type        = 1;
                        wrt1[i].tpoid       = DatabaseHelp.convert(wrt1[i].tpoid, reader["tpoid"]);
                        wrt1[i].id          = DatabaseHelp.convert(wrt1[i].id, reader["id"]);
                        wrt1[i].date        = DatabaseHelp.convert(wrt1[i].date, reader["date"]);
                        wrt1[i].name        = DatabaseHelp.convert(wrt1[i].name, reader["name"]);
                        wrt1[i].comname     = DatabaseHelp.convert(wrt1[i].name, reader["comname"]);
                        wrt1[i].ans         = DatabaseHelp.convert(wrt1[i].ans, reader["ans"]);
                        wrt1[i].stem        = DatabaseHelp.convert(wrt1[i].stem, reader["stem"]);
                        wrt1[i].lismaterial = DatabaseHelp.convert(wrt1[i].lismaterial, reader["lismaterial"]);
                        wrt1[i].redmaterial = DatabaseHelp.convert(wrt1[i].redmaterial, reader["redmaterial"]);
                        wrt1[i].score       = DatabaseHelp.convert(wrt1[i].score, reader["score"]);
                        wrt1[i].comment     = DatabaseHelp.convert(wrt1[i].comment, reader["comment"]);
                    }
                    reader.Close();
                }
                sql  = "SELECT[dbo].[IndWritingAns].id as id,";
                sql += "[dbo].[IndWritingAns].date as date,";
                sql += "[dbo].[IndWritingAns].comname as comname,";
                sql += "[dbo].[IndWritingAns].name as name,";
                sql += "[dbo].[IndWritingAns].ans as ans,";
                sql += "ISNULL([dbo].[IndWritingAns].score,-1) as score,";
                sql += "[dbo].[IndWritingAns].comment as comment,";
                sql += "[dbo].[IndWritingProblem].stem,";
                sql += "[dbo].[IndWritingProblem].setid as tpoid ";
                sql += "FROM[dbo].[IndWritingAns],[dbo].[IndWritingProblem] ";
                sql += "where[dbo].[IndWritingAns].id=[dbo].[IndWritingProblem].id ";
                // sql += "and ISNULL([dbo].[IndWritingAns].score,-1)!= -1 ";
                sql   += "and [dbo].[IndWritingAns].name=\'" + SystemConfig.name + "\'";
                allind = DatabaseHelp.SelectNum(sql);
                if (allind > 0)
                {
                    wrt2 = new writing[allind];
                    SqlDataReader reader = DatabaseHelp.getReader(sql);
                    for (i = 0; i < allind; i++)
                    {
                        reader.Read();
                        wrt2[i]         = new writing();
                        wrt2[i].type    = 1;
                        wrt2[i].tpoid   = DatabaseHelp.convert(wrt2[i].tpoid, reader["tpoid"]);
                        wrt2[i].id      = DatabaseHelp.convert(wrt2[i].id, reader["id"]);
                        wrt2[i].date    = DatabaseHelp.convert(wrt2[i].date, reader["date"]);
                        wrt2[i].name    = DatabaseHelp.convert(wrt2[i].name, reader["name"]);
                        wrt2[i].comname = DatabaseHelp.convert(wrt2[i].comname, reader["comname"]);
                        wrt2[i].ans     = DatabaseHelp.convert(wrt2[i].ans, reader["ans"]);
                        wrt2[i].stem    = DatabaseHelp.convert(wrt2[i].stem, reader["stem"]);
                        wrt2[i].score   = DatabaseHelp.convert(wrt2[i].score, reader["score"]);
                        wrt2[i].comment = DatabaseHelp.convert(wrt2[i].comment, reader["comment"]);
                    }
                    reader.Close();
                }
                for (i = 0; i < allcom; i++)
                {
                    listView1.Items.Add(new ListViewItem(new string[]
                                                         { (i + 1).ToString(),
                                                           wrt1[i].tpoid.ToString(),
                                                           this.wrt1[i].comname,
                                                           "综合写作",
                                                           this.wrt1[i].date.ToString() }));
                }
                for (i = 0; i < allind; i++)
                {
                    listView1.Items.Add(new ListViewItem(new string[]
                                                         { (i + allcom + 1).ToString(),
                                                           wrt2[i].tpoid.ToString(),
                                                           this.wrt2[i].comname,
                                                           "独立写作",
                                                           this.wrt2[i].date.ToString() }));
                }
            }
        }
示例#23
0
        private void load4model1()
        {
            this.Hide();//先藏起来,悄咪咪的load数据
            string sql = "SELECT * FROM [dbo].[ReadingArticle] WHERE id = " + this.artnumber.ToString();

            int result = DatabaseHelp.SelectNum(sql);

            if (result == 0)
            {
                MessageBox.Show("本篇阅读尚未导入,敬请期待!");
                DialogResult = DialogResult.Cancel;
                this.Show();
                return;
            }
            if (result != 0)//把数据存起来
            {
                SqlDataReader reader = DatabaseHelp.getReader(sql);
                reader.Read();
                this.arti.title       = DatabaseHelp.convert(this.arti.title, reader["title"]);
                this.arti.content     = DatabaseHelp.convert(this.arti.content, reader["article"]);
                this.arti.questionnum = DatabaseHelp.convert(this.arti.questionnum, reader["questionno"]);
                this.arti.questionIds = new int[this.arti.questionnum];
                for (int i = 0; i < this.arti.questionnum; i++)
                {
                    this.arti.questionIds[i] = DatabaseHelp.convert(this.arti.questionIds[i], reader["questionid" + (i + 1).ToString()]);
                }
                this.arti.average = DatabaseHelp.convert(this.arti.average, reader["average"]);
                reader.Close();
            }
            this.rq             = new readingQuestion[this.arti.questionnum];
            this.studentAnswers = new string[this.arti.questionnum];
            for (int i = 0; i < this.arti.questionnum; i++)
            {
                studentAnswers[i] = "";
                sql = "SELECT * FROM [dbo].[ReadingQuestion] WHERE id=" + this.arti.questionIds[i];
                SqlDataReader reader = DatabaseHelp.getReader(sql);
                reader.Read();
                this.rq[i]           = new readingQuestion();
                this.rq[i].id        = this.arti.questionIds[i];
                this.rq[i].articleid = DatabaseHelp.convert(this.rq[i].articleid, reader["articleid"]);

                this.rq[i].num        = DatabaseHelp.convert(this.rq[i].num, reader["num"]);
                this.rq[i].type       = DatabaseHelp.convert(this.rq[i].type, reader["type"]);
                this.rq[i].stem       = DatabaseHelp.convert(this.rq[i].stem, reader["stem"]);
                this.rq[i].opnum      = DatabaseHelp.convert(this.rq[i].opnum, reader["opnum"]);
                this.rq[i].paragraph  = DatabaseHelp.convert(this.rq[i].paragraph, reader["paragraph"]);
                this.rq[i].paragraph2 = DatabaseHelp.convert(this.rq[i].paragraph2, reader["paragraph2"]);
                this.rq[i].optionx    = new string[this.rq[i].opnum];
                for (int j = 0; j < this.rq[i].opnum; j++)
                {
                    this.rq[i].optionx[j] = DatabaseHelp.convert(this.rq[i].optionx[j], reader["option" + (j + 1).ToString()]);
                }
                this.rq[i].ans      = DatabaseHelp.convert(this.rq[i].ans, reader["ans"]);
                this.rq[i].acc      = DatabaseHelp.convert(this.rq[i].acc, reader["acc"]);
                this.rq[i].analysis = DatabaseHelp.convert(this.rq[i].analysis, reader["analysis"]);
                reader.Close();
            }

            this.webBrowser1.DocumentText = "<span style='color: rgb(128, 128, 128); text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: \"Helvetica Neue\", Helvetica, \"Hiragino Sans GB\", \"Microsoft YaHei\", Arial, sans-serif; font-size: 16px; font-style: normal; font-weight: 400; word-spacing: 0px; float: none; display: inline !important; white-space: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;'>"
                                            + "<p align=\"center\">" + arti.title + "</p>" + "<p>" + arti.content.Replace("\r\n", "</p><p>").Replace("\n", "</p><p>") + "</p></span>";
            button3.Enabled = false;
            this.nownum     = 0;
            load_left_ins();
            this.timer1.Enabled = true;
            this.leftTime       = TimeSpan.Parse("0:20:0");
            this.label1.Text    = this.leftTime.ToString();
            this.Show();
        }
示例#24
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.model == 1)
            {
                string   sc  = textBox1.Text;
                string   cm1 = richTextBox1.Text;
                string   cm  = "";
                string[] sts = cm1.Split('\'');
                for (int i = 0; i < sts.Count(); i++)
                {
                    if (i != 0)
                    {
                        cm += "''";
                    }
                    cm += sts[i];
                }

                int scnum;
                try
                {
                    scnum = int.Parse(sc);
                }
                catch (Exception)
                {
                    MessageBox.Show("请在分数栏输入正确的数字");
                    return;
                }
                if (scnum < 0 || scnum > 30)
                {
                    MessageBox.Show("分数必须介于0和30之间");
                    return;
                }
                if (nowtype == 1)
                {
                    int    result;
                    string sql = "UPDATE [dbo].[ComWritingAns]";
                    sql += " SET [score] = " + scnum;
                    sql += " ,[comment] = \'" + cm + "\'";
                    sql += " ,[comname] =\'" + SystemConfig.name + "'";
                    sql += " WHERE [name] = \'" + wrt1[nowno - 1].name + "\'";
                    sql += " and [date] = \'" + wrt1[nowno - 1].date + "'";
                    sql += " and [id] = " + wrt1[nowno - 1].id;
                    try
                    {
                        result = DatabaseHelp.executeCommand(sql);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("评分失败,请联系管理员");
                        return;
                    }
                    if (result == 0)
                    {
                        MessageBox.Show("评分失败,请联系管理员");
                        return;
                    }
                    MessageBox.Show("评分成功");
                    DialogResult = DialogResult.OK;
                }
                else if (nowtype == 2)
                {
                    int    result;
                    string sql = "UPDATE [dbo].[IndWritingAns]";
                    sql += " SET [score] = " + scnum;
                    sql += " ,[comment] = \'" + cm + "\'";
                    sql += " ,[comname] =\'" + SystemConfig.name + "'";
                    sql += " WHERE [name] = \'" + wrt2[nowno - allcom - 1].name + "\'";
                    sql += " and [date] = \'" + wrt2[nowno - allcom - 1].date + "'";
                    sql += " and [id] = " + wrt2[nowno - allcom - 1].id;
                    try
                    {
                        result = DatabaseHelp.executeCommand(sql);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("评分失败,请联系管理员");
                        return;
                    }
                    if (result == 0)
                    {
                        MessageBox.Show("评分失败,请联系管理员");
                        return;
                    }
                    MessageBox.Show("评分成功");
                    DialogResult = DialogResult.OK;
                }
            }

            else if (this.model == 2)
            {
                if (nowtype == 1)
                {
                    int    result;
                    string sql = "UPDATE [dbo].[ComWritingAns]";
                    sql += " SET [score] = " + "-1";
                    sql += " ,[comment] = \'" + "\'";
                    sql += " ,[comname] =\'" + "'";
                    sql += " WHERE [name] = \'" + wrt1[nowno - 1].name + "\'";
                    sql += " and [date] = \'" + wrt1[nowno - 1].date + "'";
                    sql += " and [id] = " + wrt1[nowno - 1].id;
                    try
                    {
                        result = DatabaseHelp.executeCommand(sql);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("操作失败,请联系管理员");
                        return;
                    }
                    if (result == 0)
                    {
                        MessageBox.Show("操作失败,请联系管理员");
                        return;
                    }
                    MessageBox.Show("操作成功");
                    DialogResult = DialogResult.OK;
                }
                else if (nowtype == 2)
                {
                    int    result;
                    string sql = "UPDATE [dbo].[IndWritingAns]";
                    sql += " SET [score] = " + "-1";
                    sql += " ,[comment] = \'" + "\'";
                    sql += " ,[comname] =\'" + "'";
                    sql += " WHERE [name] = \'" + wrt2[nowno - allcom - 1].name + "\'";
                    sql += " and [date] = \'" + wrt2[nowno - allcom - 1].date + "'";
                    sql += " and [id] = " + wrt2[nowno - allcom - 1].id;
                    try
                    {
                        result = DatabaseHelp.executeCommand(sql);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("操作失败,请联系管理员");
                        return;
                    }
                    if (result == 0)
                    {
                        MessageBox.Show("操作失败,请联系管理员");
                        return;
                    }
                    MessageBox.Show("操作成功");
                    DialogResult = DialogResult.OK;
                }
            }
        }
示例#25
0
        private void button4_Click(object sender, EventArgs e) //提交
        {
            XmlDocument xmldoc;
            XmlElement  xmlelem;

            xmldoc = new XmlDocument();
            XmlDeclaration xmldecl;

            xmldecl = xmldoc.CreateXmlDeclaration("1.0", "gb2312", null);
            xmldoc.AppendChild(xmldecl);

            xmlelem = xmldoc.CreateElement("", "NEWTPO", "");
            xmldoc.AppendChild(xmlelem);

            XmlNode root = xmldoc.SelectSingleNode("NEWTPO");

            xmlelem = xmldoc.CreateElement("IndWriting");
            xmlelem.SetAttribute("setid", textBox1.Text);
            xmlelem.SetAttribute("subject", indWritetext[1]);
            xmlelem.SetAttribute("stem", indWritetext[0]);
            xmlelem.SetAttribute("model", indWritetext[2]);
            root.AppendChild(xmlelem);

            xmlelem = xmldoc.CreateElement("ComWriting");
            xmlelem.SetAttribute("setid", textBox1.Text);
            xmlelem.SetAttribute("subject", comWritetext[1]);
            xmlelem.SetAttribute("stem", comWritetext[0]);
            xmlelem.SetAttribute("model", comWritetext[2]);
            xmlelem.SetAttribute("redmaterial", comWritetext[3]);
            root.AppendChild(xmlelem);

            xmlelem = xmldoc.CreateElement("Reading");
            XmlElement xmlelem2;

            //[i,0,0]是文章,[i,1~19,*]是题目, [i,1~19,0]是题目类型, 1是段落号, 2是题干, 3--9是选项, 10是ans, 11是解析
            for (int i = 0; i < 3; i++)
            {
                xmlelem2 = xmldoc.CreateElement("Reading" + i);
                XmlElement xmlarticle;
                xmlarticle = xmldoc.CreateElement("Article");
                xmlarticle.SetAttribute("article", Readtext[i, 0, 0]);
                xmlarticle.SetAttribute("title", Readtext[i, 0, 1]);
                xmlarticle.SetAttribute("setid", textBox1.Text);
                xmlarticle.SetAttribute("subject", Readtext[i, 0, 2]);
                int no = 0;
                for (no = 1; no <= 19; no++)
                {
                    if (Readtext[i, no, 2] == "")
                    {
                        break;
                    }
                }
                xmlarticle.SetAttribute("questionno", (no - 1).ToString());
                xmlelem2.AppendChild(xmlarticle);
                for (int j = 1; j <= 19; j++)
                {
                    if (Readtext[i, j, 2] == "")
                    {
                        continue;
                    }
                    XmlElement xmlQuestion;
                    xmlQuestion = xmldoc.CreateElement("question");
                    xmlQuestion.SetAttribute("id", j.ToString());
                    xmlQuestion.SetAttribute("articleid", (i + 1).ToString());
                    xmlQuestion.SetAttribute("num", j.ToString());
                    xmlQuestion.SetAttribute("type", Readtext[i, j, 0]);
                    string[] temp_para = Readtext[i, j, 1].Split(new char[2] {
                        ',', ' '
                    });
                    if (temp_para.Length == 1)
                    {
                        xmlQuestion.SetAttribute("paragraph", temp_para[0]);
                        xmlQuestion.SetAttribute("paragraph2", temp_para[0]);
                    }
                    else
                    {
                        xmlQuestion.SetAttribute("paragraph", temp_para[0]);
                        xmlQuestion.SetAttribute("paragraph2", temp_para[1]);
                    }
                    xmlQuestion.SetAttribute("stem", Readtext[i, j, 2]);
                    int k;
                    for (k = 0; k < 7; k++)
                    {
                        if (Readtext[i, j, k + 3] == "")
                        {
                            break;
                        }
                    }
                    xmlQuestion.SetAttribute("opnum", k.ToString());
                    for (int l = 0; l < 7; l++)
                    {
                        xmlQuestion.SetAttribute("option" + (l + 1), Readtext[i, j, 3 + l]);
                    }
                    xmlQuestion.SetAttribute("ans", Readtext[i, j, 10]);
                    xmlQuestion.SetAttribute("analysis", Readtext[i, j, 11]);

                    xmlelem2.AppendChild(xmlQuestion);
                }
                xmlelem.AppendChild(xmlelem2);
            }
            root.AppendChild(xmlelem);

            //string test;
            //test = "<?xml version=\"1.0\" encoding=\"gb2312\"?><NEWTPO><IndWriting setid=\"101\" subject=\"随便答题\" stem=\"为什么张夫洋最帅\" model=\"就是帅\" /><ComWriting setid=\"101\" subject=\"简单题\" stem=\"谁最帅\" model=\"张夫洋\" redmaterial=\"到底谁最帅\" /><Reading><Reading0><Article article=\"民工漫\" title=\"漫画\" setid=\"101\" subject=\"中文话题\" questionno=\"2\" /><question id=\"1\" articleid=\"1\" num=\"1\" type=\"错别字\" paragraph=\"1\" paragraph2=\"1\" stem=\"海贼王\" opnum=\"4\" option1=\"路费\" option2=\"娜美\" option3=\"香吉士\" option4=\"索隆\" option5=\"\" option6=\"\" option7=\"\" ans=\"A\" analysis=\"\" /><question id=\"2\" articleid=\"1\" num=\"2\" type=\"女性\" paragraph=\"2\" paragraph2=\"2\" stem=\"火影\" opnum=\"4\" option1=\"名人\" option2=\"宇智波鼬\" option3=\"佐助\" option4=\"小樱\" option5=\"\" option6=\"\" option7=\"\" ans=\"D\" analysis=\"\" /></Reading0><Reading1><Article article=\"NBA的题\" title=\"NBA\" setid=\"101\" subject=\"NBA话题\" questionno=\"1\" /><question id=\"1\" articleid=\"2\" num=\"1\" type=\"最nb\" paragraph=\"0\" paragraph2=\"1\" stem=\"NBA\" opnum=\"4\" option1=\"休斯顿火箭\" option2=\"圣安东尼奥马刺\" option3=\"奥克拉荷马雷霆\" option4=\"金州勇士\" option5=\"\" option6=\"\" option7=\"\" ans=\"D\" analysis=\"\" /></Reading1><Reading2><Article article=\"计算机知识\" title=\"计算机\" setid=\"101\" subject=\"计算机话题\" questionno=\"2\" /><question id=\"1\" articleid=\"3\" num=\"1\" type=\"随便选\" paragraph=\"20\" paragraph2=\"20\" stem=\"CPU\" opnum=\"5\" option1=\"主频\" option2=\"寄存器\" option3=\"时钟\" option4=\"cache\" option5=\"总线\" option6=\"\" option7=\"\" ans=\"D\" analysis=\"\" /><question id=\"2\" articleid=\"3\" num=\"2\" type=\"重要\" paragraph=\"5\" paragraph2=\"5\" stem=\"硬件\" opnum=\"5\" option1=\"cpu\" option2=\"内存\" option3=\"外存\" option4=\"显卡\" option5=\"显示器\" option6=\"\" option7=\"\" ans=\"A\" analysis=\"\" /></Reading2></Reading></NEWTPO>";
            // DatabaseHelp.ExecuteProc(test, "insert_new_tpo");
            try
            {
                DatabaseHelp.ExecuteProc(xmldoc.InnerXml, "insert_new_tpo");
            }
            catch
            {
                MessageBox.Show("输入有误!");
                return;
            }
            TransfEvent(textBox1.Text);
            this.Close();
            return;
        }