Download miễn phí Những kinh nghiệm căn bản cho lập trình





Truy cập các giá trịcủa Server từtrong Web Service
Một trong các câu hỏi thường gặp trong các newsgroup là '' Làm th ếnào tôi lấy được địa chỉIP của client browser trong một web service ?''. Câu trảlời rất đơn giản. Sửdụng lớp Context trong
System.Web.Ser vices. Bạn có thểhiểu được các làm thông qua các ví d ụsau của chúng tôi.



Để tải bản Đầy Đủ của tài liệu, xin Trả lời bài viết này, Mods sẽ gửi Link download cho bạn sớm nhất qua hòm tin nhắn.
Ai cần download tài liệu gì mà không tìm thấy ở đây, thì đăng yêu cầu down tại đây nhé:
Nhận download tài liệu miễn phí

Tóm tắt nội dung tài liệu:

Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
RadioButton1.CheckedChanged += new System.EventHandler (this.RadioButton1_CheckedChanged);
Button1.Click += new System.EventHandler (this.Button1_Click);
RadioButton2.CheckedChanged += new System.EventHandler (this.RadioButton2_CheckedChanged);
Button2.Click += new System.EventHandler (this.Button2_Click);
this.Load += new System.EventHandler (this.Page_Load);
}
public void Button2_Click (object sender, System.EventArgs e)
{
Label1.Text = ''You want to search on last name'';
}
public void Button1_Click (object sender, System.EventArgs e)
{
Label1.Text = ''You want to search on first name'';
}
public void RadioButton2_CheckedChanged (object sender, System.EventArgs e)
{
Panel1.Visible = false;
Copyright ©
29
Panel2.Visible = true;
}
public void RadioButton1_CheckedChanged (object sender, System.EventArgs e)
{
Panel1.Visible = true;
Panel2.Visible = false;
}
}
}
Chuyển đổi giá trị từ số sang chữ (.NET)
Đây là một ví dụ đơn giản dùng để chuyển đối số sang chử tương ứng (tiếng Anh). Rất hữu dụng trong kế
toán và các hoá đơn. Ví dụ bao gồm cả trang ASPX sử dụng service này
Numerals.asmx
Imports System
Imports System.Web.Services
Public Class NumberToWord : Inherits WebService
Public Function Int(num As double) As double
return(num-(num mod 1))
end function
Public Function BritishNumerals(numstr As double) As String
Dim tempstr as string
Dim newstr as string
numstr = Cdbl(numstr)
If numstr > 10 ^ 24 Then
return ''Too big''
Exit Function
End If
If numstr >= 10 ^ 7 Then
newstr = BritishNumerals(Int(numstr / (10^7)))
numstr = ((numstr / 10 ^ 7) - Int(numstr / 10 ^ 7)) * 10 ^ 7
If numstr = 0 Then
tempstr = tempstr & newstr & ''Crore ''
Else
tempstr = tempstr & newstr & ''Crore, ''
End If
End If
If numstr >= 10 ^ 5 Then
newstr = BritishNumerals(Int(numstr / 10 ^ 5))
numstr = ((numstr / 10 ^ 5) - Int(numstr / 10 ^ 5)) * 10 ^ 5
If numstr = 0 Then
tempstr = tempstr & newstr & ''Lakh ''
Else
Copyright ©
30
tempstr = tempstr & newstr & ''Lakh, ''
End If
End If
If numstr >= 10 ^ 3 Then
newstr = BritishNumerals(Int(numstr / 10 ^ 3))
numstr = ((numstr / 10 ^ 3) - Int(numstr / 10 ^ 3)) * 10 ^ 3
If numstr = 0 Then
tempstr = tempstr & newstr & ''Thousand ''
Else
tempstr = tempstr & newstr & ''Thousand, ''
End If
End If
If numstr >= 10 ^ 2 Then
newstr = BritishNumerals(Int(numstr / 10 ^ 2))
numstr = ((numstr / 10 ^ 2) - Int(numstr / 10 ^ 2)) * 10 ^ 2
If numstr = 0 Then
tempstr = tempstr & newstr & ''Hundred ''
Else
tempstr = tempstr & newstr & ''Hundred And ''
End If
End If
If numstr >= 20 Then
Select Case Int(numstr / 10)
Case 2
tempstr = tempstr & ''Twenty ''
Case 3
tempstr = tempstr & ''Thirty ''
Case 4
tempstr = tempstr & ''Forty ''
Case 5
tempstr = tempstr & ''Fifty ''
Case 6
tempstr = tempstr & ''Sixty ''
Case 7
tempstr = tempstr & ''Seventy ''
Case 8
tempstr = tempstr & ''Eighty ''
Case 9
tempstr = tempstr & ''Ninety ''
End Select
numstr = ((numstr / 10) - Int(numstr / 10)) * 10
End If
numstr=Int(numstr+0.5)
If numstr > 0 Then
Select Case NUMSTR MOD 100
Case 1
tempstr = tempstr & ''One ''
Case 2
tempstr = tempstr & ''Two ''
Case 3
Copyright ©
31
tempstr = tempstr & ''Three ''
Case 4
tempstr = tempstr & ''Four ''
Case 5
tempstr = tempstr & ''Five ''
Case 6
tempstr = tempstr & ''Six ''
Case 7
tempstr = tempstr & ''Seven ''
Case 8
tempstr = tempstr & ''Eight ''
Case 9
tempstr = tempstr & ''Nine ''
Case 10
tempstr = tempstr & ''Ten ''
Case 11
tempstr = tempstr & ''Eleven ''
Case 12
tempstr = tempstr & ''Twelve ''
Case 13
tempstr = tempstr & ''Thirteen ''
Case 14
tempstr = tempstr & ''Fourteen ''
Case 15
tempstr = tempstr & ''Fifteen ''
Case 16
tempstr = tempstr & ''Sixteen ''
Case 17
tempstr = tempstr & ''Seventeen ''
Case 18
tempstr = tempstr & ''Eighteen ''
Case 19
tempstr = tempstr & ''Nineteen ''
End Select
numstr = ((numstr / 10) - Int(numstr / 10)) * 10
End If
return tempstr
End Function
Public Function AmericanNumerals(numstr As double) As String
Dim tempstr as string
Dim newstr as string
numstr = Cdbl(numstr)
If numstr > 10 ^ 24 Then
return ''Too big''
Exit Function
End If
If numstr >= 10 ^ 9 Then
newstr = AmericanNumerals(Int(numstr / (10^9)))
numstr = ((numstr / 10 ^ 9) - Int(numstr / 10 ^ 9)) * 10 ^ 9
If numstr = 0 Then
tempstr = tempstr & newstr & ''Billion ''
Else
Copyright ©
32
tempstr = tempstr & newstr & ''Bullion, ''
End If
End If
If numstr >= 10 ^ 6 Then
newstr = AmericanNumerals(Int(numstr / 10 ^ 6))
numstr = ((numstr / 10 ^ 6) - Int(numstr / 10 ^ 6)) * 10 ^ 6
If numstr = 0 Then
tempstr = tempstr & newstr & ''Million ''
Else
tempstr = tempstr & newstr & ''Million, ''
End If
End If
If numstr >= 10 ^ 3 Then
newstr = AmericanNumerals(Int(numstr / 10 ^ 3))
numstr = ((numstr / 10 ^ 3) - Int(numstr / 10 ^ 3)) * 10 ^ 3
If numstr = 0 Then
tempstr = tempstr & newstr & ''Thousand ''
Else
tempstr = tempstr & newstr & ''Thousand, ''
End If
End If
If numstr >= 10 ^ 2 Then
newstr = AmericanNumerals(Int(numstr / 10 ^ 2))
numstr = ((numstr / 10 ^ 2) - Int(numstr / 10 ^ 2)) * 10 ^ 2
If numstr = 0 Then
tempstr = tempstr & newstr & ''Hundred ''
Else
tempstr = tempstr & newstr & ''Hundred And ''
End If
End If
If numstr >= 20 Then
Select Case Int(numstr / 10)
Case 2
tempstr = tempstr & ''Twenty ''
Case 3
tempstr = tempstr & ''Thirty ''
Case 4
tempstr = tempstr & ''Forty ''
Case 5
tempstr = tempstr & ''Fifty ''
Case 6
tempstr = tempstr & ''Sixty ''
Case 7
tempstr = tempstr & ''Seventy ''
Case 8
tempstr = tempstr & ''Eighty ''
Case 9
tempstr = tempstr & ''Ninety ''
End Select
numstr = ((numstr / 10) - Int(numstr / 10)) * 10
End If
Copyright ©
33
numstr=Int(numstr+0.5)
If numstr > 0 Then
Select Case NUMSTR MOD 100
Case 1
tempstr = tempstr & ''One ''
Case 2
tempstr = tempstr & ''Two ''
Case 3
tempstr = tempstr & ''Three ''
Case 4
tempstr = tempstr & ''Four ''
Case 5
tempstr = tempstr & ''Five ''
Case 6
tempstr = tempstr & ''Six ''
Case 7
tempstr = tempstr & ''Seven ''
Case 8
tempstr = tempstr & ''Eight ''
Case 9
tempstr = tempstr & ''Nine ''
Case 10
tempstr = tempstr & ''Ten ''
Case 11
tempstr = tempstr & ''Eleven ''
Case 12
tempstr = tempstr & ''Twelve ''
Case 13
tempstr = tempstr & ''Thirteen ''
Case 14
tempstr = tempstr & ''Fourteen ''
Case 15
tempstr = tempstr & ''Fifteen ''
Case 16
tempstr = tempstr & ''Sixteen ''
Case 17
tempstr = tempstr & ''Seventeen ''
Case 18
tempstr = tempstr & ''Eighteen ''
Case 19
tempstr = tempstr & ''Nineteen ''
End Select
numstr = ((numstr / 10) - Int(numstr / 10)) * 10
End If
return tempstr
End Function
End Class
NumberToWord.vb
'
' This class was generated by a tool.
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
Copyright ©
34
'
'------------------------------------------------------------------------------
Imports System.Xml.Serialization
Imports System.Web.Services.Protocols
Imports System.Web.Services
Public Class NumberToWord
Inherits System.Web.Services.Protocols.SoapClientProtocol
Public Sub New()
MyBase.New
Me.Url = ''numerals.asmx''
End Sub
Public Function Int(ByVal
num As Double) As Double
Dim results() As Object = Me.Invoke(''Int'', New Object() {num})
Return CType(results(0),Double)
End Function
Public Function BeginInt(ByVal num As Double, ByVal callback As System.AsyncCallback, ByVal
asyncState As Object) As System.IAsyncResult
Return Me.BeginInvoke(''Int'', New Object() {num}, callback, asyncState)
End Function
Public Function EndInt(ByVal asyncResult As System.IAsyncResult) As Double
Dim results() As Object = Me.EndInvoke(asyncResult)
Return CType(results(0),Double)
End Function
Public Function
BritishNumerals(ByVal numstr As Double) As String
Dim results() As Object = Me.Invoke(''BritishNumerals'', New Object() {numstr})
Return CType(results(0),String)
End Function
Public Function BeginBritishNumerals(ByVal numstr As Double, ByVal callback As System.AsyncCallback,
ByVal asyncState As Object) As System.IAsyncResult
Return Me.BeginInvoke(''BritishNumerals'', New Object() {numstr}, callback, asyncState)
End Function
Public Function EndBri...
 
Các chủ đề có liên quan khác
Tạo bởi Tiêu đề Blog Lượt trả lời Ngày
N Vụ tranh chấp bán phá giá cá tra, cá basa và những bài học kinh nghiệm với hàng xuất khẩu Việt Nam Luận văn Kinh tế 2
H Những bài học kinh nghiệm đối với Việt Nam trong hình thành và phát triển các tập đoàn kinh tế nhà n Luận văn Kinh tế 0
S Thị trường vốn mạo hiểm - kinh nghiệm quốc tế và những gợi ý cho Việt Nam Luận văn Sư phạm 0
S Tài phán hiến pháp của các nước Asean và những bài học kinh nghiệm cho việc xây dựng cơ chế tài phán Luận văn Sư phạm 0
E Tự do hoá tài chính lý luận, kinh nghiệm quốc tế và những vấn đề đặt ra cho Việt Nam Luận văn Sư phạm 2
O Kinh nghiệm phát triển lịch Quốc tế của Thái Lan và những gợi ý cho Việt Nam Luận văn Kinh tế 0
M Năng lực cạnh tranh của công ty Viettel Campuchia - Những bài học kinh nghiệm Luận văn Kinh tế 4
R Xuất khẩu dịch vụ tài chính ngân hàng (Kinh nghiệm quốc tế và những gợi ý đối với Việt Nam) Luận văn Kinh tế 0
K Cải cách doanh nghiệp nhà nước ở Trung Quốc và những bài học kinh nghiệm đối với Việt Nam Luận văn Kinh tế 0
L Tiến trình gia nhập WTO của Trung Quốc và những bài học kinh nghiệm đối với Việt Nam Luận văn Kinh tế 0

Các chủ đề có liên quan khác

Top