我的WebService入门
ERP:
1. Data Layer: (ProductInfoDBHelper.cs)
1 /// <summary> 2 /// 获取门店图片信息 3 /// </summary> 4 public static DataTable GetImage(string DeptID) 5 { 6 string strSql = string.Empty; 7 8 strSql += "select AD.ImageURL,A.Minute from officedba.AdvertisementDetail AD"; 9 strSql +=",officedba.Advertisement as A"; 10 11 strSql += " where ((AD.AdvertisementID like (select ‘%,‘ + convert(varchar(10),ID) + ‘,%‘ from officedba.Advertisement where DeptID = " + DeptID + "))"; 12 strSql += " or (AD.AdvertisementID like (select ‘‘ + convert(varchar(10),ID) + ‘,%‘ from officedba.Advertisement where DeptID = " + DeptID + "))"; 13 strSql += " or (AD.AdvertisementID like (select ‘%,‘ + convert(varchar(10),ID) + ‘‘ from officedba.Advertisement where DeptID = " + DeptID + "))"; 14 strSql += " or (AD.AdvertisementID = (select convert(varchar(10),ID) from officedba.Advertisement where DeptID = " + DeptID + ")))"; 15 strSql += " and A.DeptID=" + DeptID + ""; 16 SqlCommand comm = new SqlCommand(); 17 comm.CommandText = strSql; 18 19 return SqlHelper.ExecuteSearch(comm); 20 }
2. Business Layer (ProductInfoBus.cs)
1 /// <summary> 2 /// 获取门店图片信息 3 /// </summary> 4 public static DataTable GetImage(string DeptID) 5 { 6 return ProductInfoDBHelper.GetImage(DeptID); 7 }
3. App_Code\ProductInfoService.cs
1 /// <summary> 2 /// 获取门店图片信息 3 /// </summary> 4 [WebMethod] 5 public string GetImage(string DeptID) 6 { 7 string str = ""; 8 DataTable dt = ProductInfoBus.GetImage(DeptID); 9 dt.TableName = "LoginInfo"; 10 if (dt != null && dt.Rows.Count>0)
{ 11 str = XBase.Common.ConverToXML.ConvertDataTableToXML(dt); //把DataSet集合转换成XML文件 12 } 13 return str; 14 }
Winform:
1. Screen.cs
1 DataTable dt = null; 2 3 string aa = "227"; 4 //图片轮播方法 5 public void RunImage() //换图片的方法 6 { 7 string xml=ws.GetImage(Common.DeptID); 8 9 if (!string.IsNullOrEmpty(xml)) 10 { 11 dt = UserBus.ConvertXMLToDataSet(xml).Tables[0]; //把XML文件转换成DataSet集合 12 } 13 14 if (dt != null && dt.Rows.Count > 0) 15 { 16 while (true) //循环```` 17 { 18 for (int i = 0; i < dt.Rows.Count; i++) 19 { 20 pictureBox1.ImageLocation = dt.Rows[i]["ImageURL"].ToString(); 21 // string ccc = dt.Rows[i]["Minute"].ToString(); 22 Thread.Sleep(2000); //换一次图片让线程休息多少时间具体修改里面的参数例如一秒换一次填1000 23 } 24 } 25 } 26 else 27 { 28 pictureBox1.ImageLocation = "http://erp.ozz99.com.cn/SCImg/新浪微博登陆1.jpg"; 29 } 30 }
Web References\ProductInfoWS\References.cs
1 /// <remarks/> 2 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetImage", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] 3 public string GetImage(string DeptID) { 4 object[] results = this.Invoke("GetImage", new object[] { 5 DeptID}); 6 return ((string)(results[0])); 7 }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。