ERP:
1. Data Layer: (ProductInfoDBHelper.cs)
/// <summary>
/// 获取门店图片信息
/// </summary>
public static DataTable GetImage(string DeptID)
{
string strSql = string.Empty; strSql += "select AD.ImageURL,A.Minute from officedba.AdvertisementDetail AD";
strSql +=",officedba.Advertisement as A"; strSql += " where ((AD.AdvertisementID like (select '%,' + convert(varchar(10),ID) + ',%' from officedba.Advertisement where DeptID = " + DeptID + "))";
strSql += " or (AD.AdvertisementID like (select '' + convert(varchar(10),ID) + ',%' from officedba.Advertisement where DeptID = " + DeptID + "))";
strSql += " or (AD.AdvertisementID like (select '%,' + convert(varchar(10),ID) + '' from officedba.Advertisement where DeptID = " + DeptID + "))";
strSql += " or (AD.AdvertisementID = (select convert(varchar(10),ID) from officedba.Advertisement where DeptID = " + DeptID + ")))";
strSql += " and A.DeptID=" + DeptID + "";
SqlCommand comm = new SqlCommand();
comm.CommandText = strSql; return SqlHelper.ExecuteSearch(comm);
}
2. Business Layer (ProductInfoBus.cs)
/// <summary>
/// 获取门店图片信息
/// </summary>
public static DataTable GetImage(string DeptID)
{
return ProductInfoDBHelper.GetImage(DeptID);
}
3. App_Code\ProductInfoService.cs
/// <summary>
/// 获取门店图片信息
/// </summary>
[WebMethod]
public string GetImage(string DeptID)
{
string str = "";
DataTable dt = ProductInfoBus.GetImage(DeptID);
dt.TableName = "LoginInfo";
if (dt != null && dt.Rows.Count>)
{
str = XBase.Common.ConverToXML.ConvertDataTableToXML(dt); //把DataSet集合转换成XML文件
}
return str;
}
Winform:
1. Screen.cs
DataTable dt = null; string aa = "";
//图片轮播方法
public void RunImage() //换图片的方法
{
string xml=ws.GetImage(Common.DeptID); if (!string.IsNullOrEmpty(xml))
{
dt = UserBus.ConvertXMLToDataSet(xml).Tables[]; //把XML文件转换成DataSet集合
} if (dt != null && dt.Rows.Count > )
{
while (true) //循环````
{
for (int i = ; i < dt.Rows.Count; i++)
{
pictureBox1.ImageLocation = dt.Rows[i]["ImageURL"].ToString();
// string ccc = dt.Rows[i]["Minute"].ToString();
Thread.Sleep(); //换一次图片让线程休息多少时间具体修改里面的参数例如一秒换一次填1000
}
}
}
else
{
pictureBox1.ImageLocation = "http://erp.ozz99.com.cn/SCImg/新浪微博登陆1.jpg";
}
}
Web References\ProductInfoWS\References.cs
/// <remarks/>
[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)]
public string GetImage(string DeptID) {
object[] results = this.Invoke("GetImage", new object[] {
DeptID});
return ((string)(results[]));
}