private void button1_Click(object sender, EventArgs e) { string KeMu = comboBox1.SelectedValue.ToString().Trim(); string CeYan = comboBox2.SelectedValue.ToString().Trim(); Close = false; QuestionBankInformation f = new QuestionBankInformation(FatherForm); f.gettest(KeMu, CeYan, zhanghao, 1); f.Show(); this.Close(); }
private void button1_Click(object sender, EventArgs e) { string KeMu = textBox1.Text.Trim(); string CeYan = textBox2.Text.Trim(); Close = false; try { Encoding encoding = Encoding.GetEncoding("utf-8"); byte[] getWeatherUrl = encoding.GetBytes("http://1725r3a792.iask.in:28445/Server_Inquire.ashx?action=creat&&specifictest=" + CeYan); HttpWebRequest webReq = (HttpWebRequest)HttpWebRequest.Create("http://1725r3a792.iask.in:28445/Server_Inquire.ashx?action=creat&&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 { MessageBox.Show("链接失败"); } if (html == "0") { MessageBox.Show("创建测验成功,请加入具体题目"); QuestionBankInformation f = new QuestionBankInformation(FatherForm); f.gettest(CeYan, KeMu, zhanghao, 0); f.Show(); this.Close(); } else { MessageBox.Show("创建测验失败,请修改测验信息"); } }