人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當(dāng)前位置:蘿卜系統(tǒng)下載站 > 技術(shù)開發(fā)教程 > 詳細(xì)頁(yè)面

webservice結(jié)合dhtml的容易例子(一,webservice)

webservice結(jié)合dhtml的容易例子(一,webservice)

更新時(shí)間:2022-06-06 文章作者:未知 信息來(lái)源:網(wǎng)絡(luò) 閱讀次數(shù):

前段事件在網(wǎng)上看到一個(gè)基于web的財(cái)務(wù)系統(tǒng),它是通過activex實(shí)現(xiàn)的,實(shí)際上如果用webservice結(jié)合dhtml,那完全可以拋開activex。下面是個(gè)簡(jiǎn)單的例子。
首先是webservice , 很簡(jiǎn)單,我就不詳細(xì)說(shuō)明了,看注釋就可以了。

文件 study.asmx.cs

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Xml.Serialization ;

namespace StudyXML
{
/// <summary>
/// <br>一個(gè)webservice的例子</br>
/// <br>Author:Bigeagle@163.net</br>
/// <br>Date:2001/12/21</br>
/// <br>History: 2001//12/21完成</br>
/// </summary>
/// <remarks>
/// 這個(gè)webservice實(shí)現(xiàn)的功能很簡(jiǎn)單
/// 主要功能有兩個(gè),一個(gè)是取得預(yù)定義的Item數(shù)組
/// 另一個(gè)是保存Record類型的紀(jì)錄
/// </remarks>
public class Study : System.Web.Services.WebService
{

private ArrayList m_arrItems ;

private ArrayList m_arrReocrds ;

public Study()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
this.m_arrReocrds = new ArrayList() ;

this.m_arrItems = new ArrayList() ;

//增加一些實(shí)驗(yàn)數(shù)據(jù)
for(int i = 0 ; i < 100 ; i ++)
{
this.m_arrItems.Add(new Item("ItemName" + i.ToString()
, "ItemValue" + (i + 1).ToString())) ;
}


}

/// <summary>
///
/// </summary>
/// <param name="a_strItemName">Item name</param>
/// <returns>Item對(duì)象</returns>
private Item GetItem(string a_strItemName)
{
//throw(new Exception(Server.UrlDecode(a_strItemName))) ;
for(int i = 0 ; i < this.m_arrItems.Count ; i ++)
{
Item item = (Item)this.m_arrItems[i] ;
if(item.Name == Server.UrlDecode(a_strItemName).Trim())
{
return item ;
}
}

return null ;
}

#region Component Designer generated code

//Required by the Web Services Designer
private IContainer components = null;

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}

#endregion


[WebMethod]
public void AddItem(string a_strName , string a_strValue)
{
this.m_arrItems.Add(new Item(a_strName , a_strValue));
}


/// <summary>
/// 取得Item列表
/// </summary>
/// <returns>arraylist</returns>
[WebMethod]
[XmlInclude(typeof(Item))]
public ArrayList GetItems()
{
return this.m_arrItems ;
}

/// <summary>
///保存紀(jì)錄
/// </summary>
/// <param name="a_strItemName"></param>
/// <param name="a_strDemoName"></param>
/// <param name="a_intDemoAmount"></param>
/// <returns>如果成功返回false,否則返回false</returns>
[WebMethod]
public bool SaveRecord(string a_strItemName
, string a_strDemoName , int a_intDemoAmount)
{
try
{
Item item = this.GetItem(a_strItemName) ;
if(item != null)
{
this.m_arrReocrds.Add(new Record(this.m_arrReocrds.Count + 1
, item
, new Demo(a_strDemoName , a_intDemoAmount))) ;
}
else
{
throw(new Exception("指定Item的Name錯(cuò)誤!")) ;
}
return true ;
}
catch(Exception e)
{
throw(new Exception(e.ToString())) ;
//return false ;
}
}//end method
}//end class

/// <summary>
/// 一個(gè)簡(jiǎn)單的類,用來(lái)對(duì)應(yīng)象select的option這類東西
/// </summary>
public class Item
{
private string m_strName ;
private string m_strValue ;

public string Name
{
get
{
return this.m_strName ;
}
set
{
this.m_strName = value ;
}
}

public string Value
{
get
{
return this.m_strValue ;
}
set
{
this.m_strValue = value ;
}
}

public Item(string a_strName , string a_strValue)
{
this.m_strName = a_strName ;
this.m_strValue = a_strValue ;
}
public Item()
{
this.m_strName = "" ;
this.m_strValue = "" ;
}
}//end class

/// <summary>
/// 簡(jiǎn)單的示例用類
/// 結(jié)構(gòu)很簡(jiǎn)單,三個(gè)成員變量
/// 一個(gè)int類型的編號(hào),
/// 一個(gè)item類型,一個(gè)Demo類型
/// </summary>
public class Record
{
private int m_intID ;
private Item m_objMyItem ;
private Demo m_objMyDemo ;

public Record()
{
this.m_intID = 0 ;
this.m_objMyDemo = new Demo() ;
this.m_objMyItem = new Item() ;
}

public Record(int a_intID , Item a_objItem , Demo a_objDemo)
{
this.m_intID = a_intID ;
this.m_objMyDemo = a_objDemo ;
this.m_objMyItem = a_objItem ;
}
}//end calss

/// <summary>
/// 一個(gè)簡(jiǎn)單的示例用類
/// 結(jié)構(gòu)很簡(jiǎn)單,只有兩個(gè)成員變量,一個(gè)name , 一個(gè)amount
/// </summary>
public class Demo
{
private string m_strName ;
private int m_intAmount ;

public string Name
{
get
{
return this.m_strName ;
}
set
{
this.m_strName = value ;
}

}

public int Amount
{
get
{
return this.m_intAmount ;
}
set
{
this.m_intAmount = value ;
}
}


/// <summary>
/// 構(gòu)造函數(shù)
/// </summary>
public Demo()
{
this.m_intAmount = 0 ;
this.m_strName = "" ;
}

/// <summary>
/// 重載構(gòu)造函數(shù)
/// </summary>
/// <param name="a_strName"></param>
/// <param name="a_intAmount"></param>
public Demo(string a_strName , int a_intAmount)
{
this.m_intAmount = a_intAmount ;
this.m_strName = a_strName ;
}

}//end class

}//end namespace

溫馨提示:喜歡本站的話,請(qǐng)收藏一下本站!

本類教程下載

系統(tǒng)下載排行

網(wǎng)站地圖xml | 網(wǎng)站地圖html
主站蜘蛛池模板: 巧家县| 宝应县| 沾益县| 南木林县| 蓝田县| 古蔺县| 宁阳县| 广昌县| 梧州市| 济南市| 长宁区| 慈溪市| 海兴县| 彭水| 周至县| 昆山市| 项城市| 垣曲县| 开封市| 禄丰县| 汤原县| 恩平市| 乌鲁木齐市| 伊吾县| 盐池县| 科技| 乌兰察布市| 南川市| 丹江口市| 大宁县| 姚安县| 扶绥县| 凭祥市| 榆树市| 邢台县| 深水埗区| 康乐县| 嘉鱼县| 勃利县| 柘城县| 朔州市|