private void button3_Click(object sender, EventArgs e) { Close = false; QuestionBank f = new QuestionBank(this.FatherForm); f.getmessage(zhanghao); f.Show(); this.Close(); }
private void button2_Click(object sender, EventArgs e) { string CeYan = comboBox2.Text; MessageBox.Show(CeYan); try { Encoding encoding = Encoding.GetEncoding("utf-8"); byte[] getWeatherUrl = encoding.GetBytes("http://1725r3a792.iask.in:28445/Server_Delete.ashx?action=delete&specifictest=" + CeYan); HttpWebRequest webReq = (HttpWebRequest)HttpWebRequest.Create("http://1725r3a792.iask.in:28445/Server_Delete.ashx?action=delete&specifictest=" + CeYan); 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(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } if (html == "1") { Close = false; MessageBox.Show("删除成功"); QuestionBank f2 = new QuestionBank(this.FatherForm); f2.getmessage(zhanghao); f2.Show(); this.Close(); } else { MessageBox.Show("删除失败"); } }
private void button1_Click(object sender, EventArgs e) { string html = "-1"; string str = ""; if (lei == 1) { str = "http://1725r3a792.iask.in:28445/Server_ChangeTest.ashx?action=questionchange&specifictest=" + CeYan.Trim(); } else { str = "http://1725r3a792.iask.in:28445/Server_ChangeTest.ashx?action=add&test=" + CeYan.Trim() + "&specifictest=" + KeMu.Trim(); dt.Rows[num]["question"] = textBox1.Text; dt.Rows[num]["testnumber"] = num + 1; if (radioButton1.Checked == true) { dt.Rows[num]["type"] = "1"; dt.Rows[num]["choiceanswerA"] = textBox2.Text; dt.Rows[num]["choiceanswerB"] = textBox3.Text; dt.Rows[num]["choiceanswerC"] = textBox4.Text; dt.Rows[num]["choiceanswerD"] = textBox5.Text; if (radioButton3.Checked == true) { dt.Rows[num]["answer"] = "A"; } else if (radioButton4.Checked == true) { dt.Rows[num]["answer"] = "B"; } else if (radioButton5.Checked == true) { dt.Rows[num]["answer"] = "C"; } else if (radioButton6.Checked == true) { dt.Rows[num]["answer"] = "D"; } } else { dt.Rows[num]["type"] = "2"; dt.Rows[num]["answer"] = textBox6.Text; } } for (int i = 0; i < zongshu; i++) { str = str + "&"; str = str + "testnumber" + i + "="; str = str + dt.Rows[i]["testnumber"].ToString(); str = str + "&"; str = str + "question" + i + "="; str = str + dt.Rows[i]["question"].ToString(); str = str + "&"; str = str + "type" + i + "="; str = str + dt.Rows[i]["type"].ToString(); str = str + "&"; str = str + "choiceanswerA" + i + "="; str = str + dt.Rows[i]["choiceanswerA"].ToString(); str = str + "&"; str = str + "choiceanswerB" + i + "="; str = str + dt.Rows[i]["choiceanswerB"].ToString(); str = str + "&"; str = str + "choiceanswerC" + i + "="; str = str + dt.Rows[i]["choiceanswerC"].ToString(); str = str + "&"; str = str + "choiceanswerD" + i + "="; str = str + dt.Rows[i]["choiceanswerD"].ToString(); str = str + "&"; str = str + "choiceanswer" + i + "="; if (dt.Rows[i]["type"].ToString() == "1") { str = str + dt.Rows[i]["answer"].ToString(); } str = str + "&"; str = str + "answer" + i + "="; if (dt.Rows[i]["type"].ToString() != "1") { str = str + dt.Rows[i]["answer"].ToString(); } } try { Encoding encoding = Encoding.GetEncoding("utf-8"); byte[] getWeatherUrl = encoding.GetBytes(str); HttpWebRequest webReq = (HttpWebRequest)HttpWebRequest.Create(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(); } catch { MessageBox.Show("链接失败123"); } if (html == "1") { if (MessageBox.Show("修改成功", "修改成功", MessageBoxButtons.OK) == DialogResult.OK) { Close = false; QuestionBank f = new QuestionBank(this.FatherForm); f.getmessage(zhanghao); f.Show(); this.Close(); } } else { MessageBox.Show("修改失败"); textBox1.Text = str; } }