Guangzhou bus line query tool (WebServices)

Source: Internet
Author: User

Reference WebServices address:

 

Http://www.complacent.com.cn/Service1.asmx

Through vs2003 + Windows Server 2003, the client does not include databases

Using system;
Using system. drawing;
Using system. Drawing. printing;
Using system. collections;
Using system. componentmodel;
Using system. Windows. forms;
Using system. Data;
Using system. Data. oledb;

Namespace buswindows
{
/// <Summary>
/// Summary of form1.
/// </Summary>
Public class form1: system. Windows. Forms. Form
{
Private system. Windows. Forms. Button button1;
Private system. Windows. Forms. groupbox groupbox1;
Private system. Windows. Forms. Label label1;
Private system. Windows. Forms. Label label2;
Private system. Windows. Forms. Label label3;
Private system. Windows. Forms. Label label4;
Private system. Windows. Forms. textbox txtsta;
Private system. Windows. Forms. textbox txtend;
Private system. Windows. Forms. textbox txtno;
Private system. Windows. Forms. RichTextBox MSG;
Private system. Windows. Forms. contextmenu contextmenu1;
Private system. Windows. Forms. menuitem menuitem1;
Private system. Windows. Forms. menuitem menuitem2;
Private system. Windows. Forms. Label label6;
Private system. Windows. Forms. linklabel linklabel1;
Private system. Windows. Forms. linklabel linklabel2;
Private system. Windows. Forms. mainmenu mainmenu1;
Private system. Windows. Forms. menuitem menuitem3;
Private system. Windows. Forms. menuitem menuitem4;
Private system. Windows. Forms. menuitem menuitem6;
Private system. Windows. Forms. menuitem menuitem7;
Public String data = "";
Private system. Windows. Forms. savefiledialog savefiledialog1;
/// <Summary>
/// Required designer variables.
/// </Summary>
Private system. componentmodel. Container components = NULL;

Public form1 ()
{
//
// Required for Windows Form Designer support
//
Initializecomponent ();

//
// Todo: add Any constructor code after initializecomponent calls
//
}

/// <Summary>
/// Clear all resources in use.
/// </Summary>
Protected override void dispose (bool disposing)
{
If (disposing)
{
If (components! = NULL)
{
Components. Dispose ();
}
}
Base. Dispose (disposing );
}

# Region code generated by Windows Form Designer
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void initializecomponent ()
{
This. button1 = new system. Windows. Forms. Button ();
This.txt sta = new system. Windows. Forms. Textbox ();
This.txt end = new system. Windows. Forms. Textbox ();
This. groupbox1 = new system. Windows. Forms. groupbox ();
This. linklabel2 = new system. Windows. Forms. linklabel ();
This. linklabel1 = new system. Windows. Forms. linklabel ();
This. label6 = new system. Windows. Forms. Label ();
This. MSG = new system. Windows. Forms. RichTextBox ();
This. contextmenu1 = new system. Windows. Forms. contextmenu ();
This. menuitem1 = new system. Windows. Forms. menuitem ();
This. menuitem2 = new system. Windows. Forms. menuitem ();
This. label4 = new system. Windows. Forms. Label ();
This. label3 = new system. Windows. Forms. Label ();
This.txt NO = new system. Windows. Forms. Textbox ();
This. label2 = new system. Windows. Forms. Label ();
This. label1 = new system. Windows. Forms. Label ();
This. mainmenu1 = new system. Windows. Forms. mainmenu ();
This. menuitem3 = new system. Windows. Forms. menuitem ();
This. menuitem4 = new system. Windows. Forms. menuitem ();
This. menuitem6 = new system. Windows. Forms. menuitem ();
This. menuitem7 = new system. Windows. Forms. menuitem ();
This. savefiledialog1 = new system. Windows. Forms. savefiledialog ();
This. groupbox1.suspendlayout ();
This. suspendlayout ();
//
// Button1
//
This. button1.flatstyle = system. Windows. Forms. flatstyle. Popup;
This. button1.location = new system. Drawing. Point (200,104 );
This. button1.name = "button1 ";
This. button1.size = new system. Drawing. Size (56, 23 );
This. button1.tabindex = 0;
This. button1.text = "query ";
This. button1.click + = new system. eventhandler (this. button#click );
//
// Txtsta
//
This.txt Sta. Location = new system. Drawing. Point (88, 64 );
This.txt Sta. Name = "txtsta ";
This.txt Sta. tabindex = 1;
This.txt Sta. Text = "";
//
// Txtend
//
This.txt end. Location = new system. Drawing. Point (88,104 );
This.txt end. Name = "txtend ";
This.txt end. tabindex = 2;
This.txt end. Text = "";
This.txt end. keydown + = new system.windows.forms.keyeventhandler(this.txt end_keydown );
//
// Groupbox1
//
This. groupbox1.anchor = (system. Windows. Forms. anchorstyles) (system. Windows. Forms. anchorstyles. Top | system. Windows. Forms. anchorstyles. Bottom)
| System. Windows. Forms. anchorstyles. Left)
| System. Windows. Forms. anchorstyles. Right )));
This. groupbox1.controls. Add (this. linklabel2 );
This. groupbox1.controls. Add (this. linklabel1 );
This. groupbox1.controls. Add (this. label6 );
This. groupbox1.controls. Add (this. msg );
This. groupbox1.controls. Add (this. label4 );
This. groupbox1.controls. Add (this. label3 );
This.groupbox1.controls.add(this.txt No );
This. groupbox1.controls. Add (this. label2 );
This. groupbox1.controls. Add (this. label1 );
This. groupbox1.controls. Add (this. button1 );
This.groupbox1.controls.add(this.txt end );
This.groupbox1.controls.add(this.txt Sta );
This. groupbox1.flatstyle = system. Windows. Forms. flatstyle. system;
This. groupbox1.location = new system. Drawing. Point (16, 16 );
This. groupbox1.name = "groupbox1 ";
This. groupbox1.size = new system. Drawing. Size (368,328 );
This. groupbox1.tabindex = 3;
This. groupbox1.tabstop = false;
This. groupbox1.text = "Guangzhou bus line ";
//
// Linklabel2
//
This. linklabel2.location = new system. Drawing. Point (328,110 );
This. linklabel2.name = "linklabel2 ";
This. linklabel2.size = new system. Drawing. Size (32, 23 );
This. linklabel2.tabindex = 14;
This. linklabel2.tabstop = true;
This. linklabel2.text = "Homepage ";
This. linklabel2.linkclicked + = new system. Windows. Forms. linklabellinkclickedeventhandler (this. linklabel2_linkclicked );
//
// Linklabel1
//
This. linklabel1.location = new system. Drawing. Point (264,110 );
This. linklabel1.name = "linklabel1 ";
This. linklabel1.size = new system. Drawing. Size (56, 23 );
This. linklabel1.tabindex = 13;
This. linklabel1.tabstop = true;
This. linklabel1.text = "Contact Author ";
This. linklabel1.linkclicked + = new system. Windows. Forms. linklabellinkclickedeventhandler (this. linklabel1_linkclicked );
//
// Label6
//
This. label6.location = new system. Drawing. Point (96,288 );
This. label6.name = "label6 ";
This. label6.size = new system. Drawing. Size (256, 32 );
This. label6.tabindex = 11;
This. label6.text = "this tool belongs to the distributed structure of Web Services./N supports fuzzy query by train or station ";
//
// Msg
//
This. msg. contextmenu = This. contextmenu1;
This. msg. Location = new system. Drawing. Point (88,136 );
This. msg. Name = "MSG ";
This. msg. size = new system. Drawing. Size (256,144 );
This. msg. tabindex = 9;
This. msg. Text = "";
//
// Contextmenu1
//
This. contextmenu1.menuitems. addrange (new system. Windows. Forms. menuitem [] {
This. menuitem1,
This. menuitem2 });
//
// Menuitem1
//
This. menuitem1.index = 0;
This. menuitem1.text = "select all ";
This. menuitem1.click + = new system. eventhandler (this. menuitem#click );
//
// Menuitem2
//
This. menuitem2.index = 1;
This. menuitem2.text = "copy ";
This. menuitem2.click + = new system. eventhandler (this. menuitem2_click );
//
// Label4
//
This. label4.location = new system. Drawing. Point (24,144 );
This. label4.name = "label4 ";
This. label4.size = new system. Drawing. Size (48, 23 );
This. label4.tabindex = 7;
This. label4.text = "message :";
//
// Label3
//
This. label3.location = new system. Drawing. Point (24, 26 );
This. label3.name = "label3 ";
This. label3.size = new system. Drawing. Size (48, 23 );
This. label3.tabindex = 6;
This. label3.text = "vehicle count :";
//
// Txtno
//
This.txt No. Location = new system. Drawing. Point (88, 24 );
This.txt No. Name = "txtno ";
This.txt No. tabindex = 5;
This.txt No. Text = "";
//
// Label2
//
This. label2.location = new system. Drawing. Point (24,104 );
This. label2.name = "label2 ";
This. label2.size = new system. Drawing. Size (48, 23 );
This. label2.tabindex = 4;
This. label2.text = "destination site :";
//
// Label1
//
This. label1.location = new system. Drawing. Point (24, 64 );
This. label1.name = "label1 ";
This. label1.size = new system. Drawing. Size (56, 23 );
This. label1.tabindex = 3;
This. label1.text = "Departure Site :";
//
// Mainmenu1
//
This. mainmenu1.menuitems. addrange (new system. Windows. Forms. menuitem [] {
This. menuitem3 });
//
// Menuitem3
//
This. menuitem3.index = 0;
This. menuitem3.menuitems. addrange (new system. Windows. Forms. menuitem [] {
This. menuitem4,
This. menuitem6,
This. menuitem7 });
This. menuitem3.text = "file (& F )";
//
// Menuitem4
//
This. menuitem4.index = 0;
This. menuitem4.text = "save ";
This. menuitem4.click + = new system. eventhandler (this. menuitem4_click );
//
// Menuitem6
//
This. menuitem6.index = 1;
This. menuitem6.text = "-";
//
// Menuitem7
//
This. menuitem7.index = 2;
This. menuitem7.text = "quit ";
This. menuitem7.click + = new system. eventhandler (this. menuitem7_click );
//
// Savefiledialog1
//
This. savefiledialog1.filter = "TXT | *. txt ";
//
// Form1
//
This. autoscalebasesize = new system. Drawing. Size (6, 14 );
This. clientsize = new system. Drawing. Size (400,357 );
This. Controls. Add (this. groupbox1 );
This. maximizebox = false;
This. Menu = This. mainmenu1;
This. Name = "form1 ";
This. startposition = system. Windows. Forms. formstartposition. centerscreen;
This. Text = "Guangzhou bus line query tool ";
This. Load + = new system. eventhandler (this. form#load );
This. groupbox1.resumelayout (false );
This. resumelayout (false );

}
# Endregion

/// <Summary>
/// Main entry point of the application.
/// </Summary>
[Stathread]
Static void main ()
{
Application. enablevisualstyles (); // use the Windows XP interface style
Application. doevents ();
Application. Run (New form1 ());
}

Private void button#click (Object sender, system. eventargs E)
{
Try
{
Bus. service1 bus = new buswindows. Bus. service1 ();
Dataset DS = new dataset ();
DS = bus. bus (txtno. text. trim (). tostring (), txtsta. text. trim (). tostring (), txtend. text. trim (). tostring ());
If (Ds. Tables [0]. Rows. Count! = 0)
{

Foreach (datarow row in DS. Tables [0]. Rows)
{
Foreach (datacolumn column in DS. Tables [0]. columns)
{
Data + = row [column] + "/n ================== ";
}
Data + = "/N ";
}
Data + = "/N ";
Data = data. Replace ("*", "--> ");
MSG. Text = data. tostring ();
}
Else
{
MessageBox. Show ("sorry, there are no trains on this route ");
}
}
Catch (exception ex)
{
MessageBox. Show (ex. Message. tostring ());
}

}

Private void menuitem1_click (Object sender, system. eventargs E)
{
MSG. selectall ();
}

Private void menuitem2_click (Object sender, system. eventargs E)
{
MSG. Copy ();
}

Private void form1_load (Object sender, system. eventargs E)
{
// Application. enablevisualstyles ();
}

Private void txtend_keydown (Object sender, system. Windows. Forms. keyeventargs E)
{
If (E. keycode. tostring () = "enter ")
{
Button#click (sender, e );
}
}

Private void linklabel1_linkclicked (Object sender, system. Windows. Forms. linklabellinkclickedeventargs E)
{
System. Diagnostics. process. Start ("mailto: cn.e@163.com ");
}

Private void linklabel2_linkclicked (Object sender, system. Windows. Forms. linklabellinkclickedeventargs E)
{
System. Diagnostics. process. Start ("http://blog.csdn.net/add8848 ");
}

Private void menuitem7_click (Object sender, system. eventargs E)
{
Application. Exit ();
}
Private void menuitem4_click (Object sender, system. eventargs E)
{
Try
{
If (savefiledialog1.showdialog () = dialogresult. OK)
{
System. Io. streamwriter Sw = new system. Io. streamwriter (savefiledialog1.filename, true, system. Text. encoding. getencoding ("gb2312 "));
Sw. Write (data );
Sw. Close ();

}
}
Catch (exception ex)
{
MessageBox. Show (ex. Message );
}
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.