/// <summary>
/// 返回指定日期的订单数据
/// </summary>
/// <param name="StartDate">起始日期</param>
/// <param name="EndDate">结束日期</param>
/// <returns>DataTable</returns>
public System.Data.DataTable GetOrderDt(DateTime StartDate, DateTime EndDate)
{
try
{
dllEncrypt des = new dllEncrypt();
string strStartDate = des.Get_Time_String(StartDate);
string strEndDate = des.Get_Time_String(EndDate);
WebClient web = new WebClient();
//设置post的参数
System.Collections.Specialized.NameValueCollection PostData = new System.Collections.Specialized.NameValueCollection();
PostData.Add("stime", strStartDate);//将textBox1中的数据变为用a标识的参数,并用POST传值方式传给网页
PostData.Add("etime", strEndDate);
//获取返回的数据
byte[] byRemoteInfo = web.UploadValues(GetUrl(), "POST", PostData);
string sRemoteInfo = System.Text.Encoding.UTF8.GetString(byRemoteInfo);
//读取字符串中的信息
StringReader StrStream = new StringReader(sRemoteInfo);
//获取StrStream中的数据并存储为XML类型数据
XmlTextReader Xmlrdr = new XmlTextReader(StrStream);
DataSet dss = new DataSet();
//将数据存储到数据集中
dss.ReadXml(Xmlrdr);
if (dss.Tables != null && dss.Tables.Count > 0)
{
return dss.Tables[0];
}
else
{
return null;
}
}
catch (Exception ex)
{
return null;
}
}
C# Winform中执行post操作并获取返回的XML类型的数据,码迷,mamicode.com
时间: 2024-12-13 09:49:50