ldj/wince/dnSeeds/NewSeeds.cs

77 lines
2.0 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
namespace dnSeeds
{
public partial class ScanInput : Form
{
public ScanInput()
{
InitializeComponent();
}
int deskId;
string seedsNo;
string svrUrl = "http://192.168.1.101:9998/DNLight/startSeeds?deskId={0}&seedsNo={1}";
private void btnStart_Click(object sender, EventArgs e)
{
if (validInput())
{
startNewSeeds(deskId,seedsNo);
}
}
void startNewSeeds(int deskId,string seedsNo)
{
svrUrl = string.Format(svrUrl, deskId, seedsNo);
HttpWebRequest webReq;
webReq = (HttpWebRequest)WebRequest.Create(new Uri(svrUrl));
System.Net.HttpWebResponse response;
response = (System.Net.HttpWebResponse)webReq.GetResponse();
System.IO.StreamReader myreader = new System.IO.StreamReader(response.GetResponseStream(), Encoding.UTF8);
string responseText = myreader.ReadToEnd();
myreader.Close();
MessageBox.Show(responseText);
}
bool validInput()
{
try
{
deskId = Convert.ToInt16(textBoxDeskId.Text.Trim().ToString());
}
catch (Exception e)
{
MessageBox.Show("请输入播种台ID");
textBoxDeskId.SelectAll();
textBoxDeskId.Focus();
return false;
}
seedsNo = txtboxSeedsNo.Text.Trim();
if (seedsNo.Length == 0)
{
MessageBox.Show("请输入播种台ID");
txtboxSeedsNo.SelectAll();
txtboxSeedsNo.Focus();
return false;
}
return true;
}
}
}