예제 #1
0
 public void copyto(Class_Upload b)
 {
     examineenumber = b.examineenumber;
     subject        = b.subject;
     test           = b.test;
     testnumber     = b.testnumber;
     choice_answer  = b.choice_answer;
     answer         = b.answer;
 }
예제 #2
0
        private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            string str = "";

            str = dataGridView1.CurrentRow.Cells[0].ToString();
            str = str.Remove(0, str.Length - 3);
            str = str.Remove(1, 2);

            if (Convert.ToInt32(str) > nownum)
            {
                MessageBox.Show("请按顺序答题!");
                dataGridView1.Focus();
                dataGridView1.CurrentCell = dataGridView1.Rows[num].Cells[0];
                return;
            }
            Class_Upload c = new Class_Upload();

            if (radioButton1.Checked)
            {
                c.Choice_answer = "A";
            }
            else if (radioButton2.Checked)
            {
                c.Choice_answer = "B";
            }
            else if (radioButton3.Checked)
            {
                c.Choice_answer = "C";
            }
            else if (radioButton4.Checked)
            {
                c.Choice_answer = "D";
            }
            else if (c.Test != "")
            {
                c.Answer = textBox2.Text;
            }
            else
            {
                MessageBox.Show("请填写答案");
            }
            c.Subject    = ceshiming;
            c.Test       = kaoshiming;
            c.Testnumber = Convert.ToString(num);
            if (num == nownum && num == anwser.Count)
            {
                anwser.Add(c);
            }
            else
            {
                anwser[num].copyto(c);
            }
            if (dt.Rows[num]["type"].ToString() != "1" && textBox2.Text != "")
            {
                s = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                s = s.Remove(1, s.Length - 1);
                if (s != "√")
                {
                    dataGridView1.CurrentRow.Cells[0].Value = "√" + dataGridView1.CurrentRow.Cells[0].Value;
                }
            }
            else if (dt.Rows[num]["type"].ToString() == "1" && (radioButton1.Checked || radioButton2.Checked || radioButton3.Checked || radioButton4.Checked))
            {
                s = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                s = s.Remove(1, s.Length - 1);
                if (s != "√")
                {
                    dataGridView1.CurrentRow.Cells[0].Value = "√" + dataGridView1.CurrentRow.Cells[0].Value;
                }
            }
            num = Convert.ToInt32(str);

            label2.Text = "第" + (num + 1) + "题目";
            //显示题目
            textBox1.Text = dt.Rows[num]["question"].ToString();
            if (dt.Rows[num]["type"].ToString() == "1")
            {
                // radioButton1
                //MessageBox.Show(Convert.ToString( anwser.Count));
                //MessageBox.Show(Convert.ToString(num));
                if (anwser.Count <= num)
                {
                    radioButton1.Checked = false;
                    radioButton2.Checked = false;
                    radioButton3.Checked = false;
                    radioButton4.Checked = false;
                }
                else
                {
                    if (anwser[num].Choice_answer == "A")
                    {
                        radioButton1.Checked = true;
                    }
                    else if (anwser[num].Choice_answer == "B")
                    {
                        radioButton2.Checked = true;
                    }
                    else if (anwser[num].Choice_answer == "C")
                    {
                        radioButton3.Checked = true;
                    }
                    else if (anwser[num].Choice_answer == "D")
                    {
                        radioButton4.Checked = true;
                    }
                    else
                    {
                        radioButton1.Checked = false;
                        radioButton2.Checked = false;
                        radioButton3.Checked = false;
                        radioButton4.Checked = false;
                    }
                }
                groupBox1.Show();
                groupBox2.Hide();
                //textBox2.Hide();
                radioButton1.Text = "A." + dt.Rows[num]["choiceanswerA"].ToString();
                radioButton2.Text = "B." + dt.Rows[num]["choiceanswerB"].ToString();
                radioButton3.Text = "C." + dt.Rows[num]["choiceanswerC"].ToString();
                radioButton4.Text = "D." + dt.Rows[num]["choiceanswerD"].ToString();
            }
            else
            {
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                radioButton4.Checked = false;
                groupBox1.Hide();
                groupBox2.Show();
                //textBox2.Show();
            }
        }
예제 #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            Close = false;
            Results f = new Results(this.FatherForm, 1);

            f.getmessage(zhanghao);
            //提交
            if (num == anwser.Count)
            {
                Class_Upload c = new Class_Upload();
                if (radioButton1.Checked)
                {
                    c.Choice_answer = "A";
                }
                else if (radioButton2.Checked)
                {
                    c.Choice_answer = "B";
                }
                else if (radioButton3.Checked)
                {
                    c.Choice_answer = "C";
                }
                else if (radioButton4.Checked)
                {
                    c.Choice_answer = "D";
                }
                else
                {
                    c.Answer = textBox2.Text;
                }


                c.Subject    = ceshiming;
                c.Test       = kaoshiming;
                c.Testnumber = Convert.ToString(num);
                anwser.Add(c);
            }
            string str = "";

            for (int i = 0; i < anwser.Count; ++i)
            {
                if (int.Parse(dt.Rows[i]["type"].ToString()) == 1)
                {
                    str = str + (i + 1) + "=" + anwser[i].Choice_answer + "&";
                }
                else
                {
                    str = str + (i + 1) + "=" + anwser[i].Answer + "&";
                }
            }
            str = str.Remove(str.Length - 1, 1);
            //MessageBox.Show(str);

            string html = "";

            try
            {
                Encoding       encoding      = Encoding.GetEncoding("utf-8");
                byte[]         getWeatherUrl = encoding.GetBytes("http://1725r3a792.iask.in:28445/Server_Test.ashx?action=answer&zhanghao=" + zhanghao + "&specifictest=" + kaoshiming + "&" + str);
                HttpWebRequest webReq        = (HttpWebRequest)HttpWebRequest.Create("http://1725r3a792.iask.in:28445/Server_Test.ashx?action=answer&zhanghao=" + zhanghao + "&specifictest=" + kaoshiming + "&" + str);
                webReq.Method      = "post";
                webReq.ContentType = "text/xml";

                Stream outstream = webReq.GetRequestStream();
                outstream.Write(getWeatherUrl, 0, getWeatherUrl.Length);
                outstream.Flush();
                outstream.Close();

                webReq.Timeout = 2000;
                HttpWebResponse webResp = (HttpWebResponse)webReq.GetResponse();
                Stream          stream  = webResp.GetResponseStream();
                StreamReader    sr      = new StreamReader(stream, encoding);
                html = sr.ReadToEnd();
                sr.Close();
                stream.Close();
                score = html;
            }
            catch
            {
                MessageBox.Show("链接失败");
            }



            //接受成绩
            f.getscore(ceshiming, kaoshiming, score);
            f.Show();
            this.Close();
        }
예제 #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (num + 1 == zongshu)
            {
                MessageBox.Show("已完成所有试题,请交卷!");
                if (dt.Rows[num]["type"].ToString() != "1" && textBox2.Text != "")
                {
                    s = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                    s = s.Remove(1, s.Length - 1);
                    if (s != "√")
                    {
                        dataGridView1.CurrentRow.Cells[0].Value = "√" + dataGridView1.CurrentRow.Cells[0].Value;
                    }
                }
                else if (dt.Rows[num]["type"].ToString() == "1" && (radioButton1.Checked || radioButton2.Checked || radioButton3.Checked || radioButton4.Checked))
                {
                    s = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                    s = s.Remove(1, s.Length - 1);
                    if (s != "√")
                    {
                        dataGridView1.CurrentRow.Cells[0].Value = "√" + dataGridView1.CurrentRow.Cells[0].Value;
                    }
                }
                return;
            }
            if (nownum == num && num == anwser.Count)
            {
                Class_Upload c = new Class_Upload();
                if (radioButton1.Checked)
                {
                    c.Choice_answer = "A";
                }
                else if (radioButton2.Checked)
                {
                    c.Choice_answer = "B";
                }
                else if (radioButton3.Checked)
                {
                    c.Choice_answer = "C";
                }
                else if (radioButton4.Checked)
                {
                    c.Choice_answer = "D";
                }
                else if (dt.Rows[num]["type"].ToString() != "1")
                {
                    c.Answer = textBox2.Text;
                }

                if (dt.Rows[num]["type"].ToString() != "1" && textBox2.Text != "")
                {
                    s = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                    s = s.Remove(1, s.Length - 1);
                    if (s != "√")
                    {
                        dataGridView1.CurrentRow.Cells[0].Value = "√" + dataGridView1.CurrentRow.Cells[0].Value;
                    }
                }
                else if (dt.Rows[num]["type"].ToString() == "1" && (radioButton1.Checked || radioButton2.Checked || radioButton3.Checked || radioButton4.Checked))
                {
                    s = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                    s = s.Remove(1, s.Length - 1);
                    if (s != "√")
                    {
                        dataGridView1.CurrentRow.Cells[0].Value = "√" + dataGridView1.CurrentRow.Cells[0].Value;
                    }
                }

                c.Subject    = ceshiming;
                c.Test       = kaoshiming;
                c.Testnumber = Convert.ToString(num);
                num++;
                nownum++;
                anwser.Add(c);

                // MessageBox.Show(anwser[num - 1].Choice_answer);
            }
            else
            {
                Class_Upload c = new Class_Upload();
                if (radioButton1.Checked)
                {
                    c.Choice_answer = "A";
                }
                else if (radioButton2.Checked)
                {
                    c.Choice_answer = "B";
                }
                else if (radioButton3.Checked)
                {
                    c.Choice_answer = "C";
                }
                else if (radioButton4.Checked)
                {
                    c.Choice_answer = "D";
                }
                else
                {
                    c.Answer = textBox2.Text;
                }

                if (dt.Rows[num]["type"].ToString() != "1" && textBox2.Text != "")
                {
                    s = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                    s = s.Remove(1, s.Length - 1);
                    if (s != "√")
                    {
                        dataGridView1.CurrentRow.Cells[0].Value = "√" + dataGridView1.CurrentRow.Cells[0].Value;
                    }
                }
                else if (dt.Rows[num]["type"].ToString() == "1" && (radioButton1.Checked || radioButton2.Checked || radioButton3.Checked || radioButton4.Checked))
                {
                    s = dataGridView1.CurrentRow.Cells[0].Value.ToString();
                    s = s.Remove(1, s.Length - 1);
                    if (s != "√")
                    {
                        dataGridView1.CurrentRow.Cells[0].Value = "√" + dataGridView1.CurrentRow.Cells[0].Value;
                    }
                }

                //c.Subject = ceshiming;
                c.Test       = kaoshiming;
                c.Testnumber = Convert.ToString(num);
                anwser[num].copyto(c);
                num++;
            }

            label2.Text = "第" + (num + 1) + "题目";
            //显示题目
            textBox1.Text = dt.Rows[num]["question"].ToString();
            if (dt.Rows[num]["type"].ToString() == "1")
            {
                // radioButton1
                //MessageBox.Show(Convert.ToString( anwser.Count));
                //MessageBox.Show(Convert.ToString(num));
                if (anwser.Count <= num)
                {
                    radioButton1.Checked = false;
                    radioButton2.Checked = false;
                    radioButton3.Checked = false;
                    radioButton4.Checked = false;
                }
                else
                {
                    if (anwser[num].Choice_answer == "A")
                    {
                        radioButton1.Checked = true;
                    }
                    else if (anwser[num].Choice_answer == "B")
                    {
                        radioButton2.Checked = true;
                    }
                    else if (anwser[num].Choice_answer == "C")
                    {
                        radioButton3.Checked = true;
                    }
                    else if (anwser[num].Choice_answer == "D")
                    {
                        radioButton4.Checked = true;
                    }
                    else
                    {
                        radioButton1.Checked = false;
                        radioButton2.Checked = false;
                        radioButton3.Checked = false;
                        radioButton4.Checked = false;
                    }
                }
                groupBox1.Show();
                groupBox2.Hide();
                //textBox2.Hide();
                radioButton1.Text = "A." + dt.Rows[num]["choiceanswerA"].ToString();
                radioButton2.Text = "B." + dt.Rows[num]["choiceanswerB"].ToString();
                radioButton3.Text = "C." + dt.Rows[num]["choiceanswerC"].ToString();
                radioButton4.Text = "D." + dt.Rows[num]["choiceanswerD"].ToString();
            }
            else
            {
                radioButton1.Checked = false;
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                radioButton4.Checked = false;
                groupBox1.Hide();
                groupBox2.Show();
                //textBox2.Show();
                if (num >= anwser.Count)
                {
                    textBox2.Text = "";
                }
                else
                {
                    textBox2.Text = anwser[num].Answer;
                }
            }
            //  MessageBox.Show(Convert.ToString(anwser.Count));
            dataGridView1.Focus();
            dataGridView1.CurrentCell = dataGridView1.Rows[num].Cells[0];
        }