码迷,mamicode.com
首页 > Web开发 > 详细

我的WebService入门

时间:2014-09-09 18:02:29      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:des   winform   style   blog   http   color   os   io   ar   

 

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         }

 

我的WebService入门

标签:des   winform   style   blog   http   color   os   io   ar   

原文地址:http://www.cnblogs.com/MarkTang/p/3962826.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!