Build a .NET Remoting program (real three-layer structure) _ 突 血 推 推!!! Net Remoting provides a powerful and efficient way to process remote objects. When I developed a power software, because the traffic is large, three layers must be used. Implement data processing (browsing, update), but this area is very small. By groping what I found. Deliberate to use .NET development three-layer structure database application software and C # programmer who can't find the method.
Step 1: Create a shared library Click "File" -> "New Create" -> "Project", select Create a C # Library, and then name YDGLServerLibrary, then click the OK button. This will create a "shared command set" for our .NET Remote client and server. The front is a complete code for use system;
Using system.runtime;
Using system.data.oledb;
Using system.data.sqlclient;
Using system.data;
Using system.configuration;
Namespace YDGLSERVERCLASSLIBRARY1
{
///
/// Class1 summary description.
/// summary>
Public class ydgldb: System.MarshalByrefObject
{
Private system.data.oledb.oledbdataadapter oledbdataadapter1;
Private system.data.oledb.oledbcommand oledbselectcommand1;
Private system.data.oledb.oledbcommand oledbinsertcommand1;
Private system.data.oledb.oledbcommand oledbupdateCommand1;
Private system.data.oledb.oledbcommand oledbdeleteCommand1;
Private system.data.oledb.oledbconnection OLEDBCONNECTION1;
Private system.componentmodel.Container Components = NULL;
Public void initializeComponent ()
{
THIS.OLEDBDATAADAPTER1 = new system.data.oledb.oledbdataadapter ();
This.oledbselectCommand1 = new system.data.oledb.oledbcommand ();
THIS.OLEDBINSERTCOMMAND1 = new system.data.oledb.oledbcommand ();
THIS.OLEDBUPDATECOMMAND1 = new system.data.oledb.oledbcommand ();
This.OleDbdeleteCommand1 = new system.data.oledb.oledbcommand ();
THIS.OLEDBCONNECTION1 = new system.data.oledb.oledbconnection ();
//
// oleDBDataAdapter1
//
This.OledbdataAdapter1.deleteCommand = this.OleDbdeleteCommand1;
THIS.OLEDBDATADAPTER1.INSERTCOMMAND = THISOLDBINSERTCOMMAND1;
THISOLEDBDATAADAPTER1.SELECTCOMMAND = this.OLEDBSelectCommand1; this.oledbdataadapter1.tablemappings.addrange (new system.data.common.DataTableMapping "[] {
New system.data.common.DataTableMapping ("Table", "BM_GDFGS", new system.data.common.datacolumnmapping [] {
New system.data.common.datacolumnmapping ("Code", "code"),
New system.data.common.datacolumnMapping ("name", "name")})})
THIS.OLDBDATAADAPTER1.UPDATECOMMAND = this.OledbupdateCommand1;
//
// OLEDBSELECTCOMMAND1
//
THIS.OLEDBSELECTCOMMAND1.COMMANDTEXT = "Select Code, Name from BM_GDFGS";
THIS.OLEDBSELECTCOMMAND1.CONNECTION = this.OleDbconnection1;
//
// OLEDBINSERTCOMMAND1
//
This.oledbinsertCommand1.comMandtext = "INSERT INTO BM_GDFGS (CODE, NAME) VALUES (?,?); select code, name from bm_gdfgs w"
"Here";
THIS.OLEDBINSERTCOMMAND1.CONNECTION = this.Oledbconnection1;
This.OledbinsertCommand1.Parameters.Add (New System.Data.Oledb.OleDbParameter ("CODE", System.Data.Oledb.oledbtype.varchar, 2, "Code"));
This.OledbinsertCommand1.Parameters.Add (new system.data.oledb.oledbParameter ("name", system.data.oledb.oledbtype.varchar, 40, "name"));
This.OLledbinsertCommand1.Parameters.Add (new system.data.oledb.oledbParameter ("select_code", system.data.oledb.oledbtype.varchar, 2, "code");
//
// oledbupdateCommand1
//
THISOOLDBUPDATECOMMAND1.COMMANDTEXT = "Update bm_gdfgs set code =?, name =? where (code =?) and (name =? or? is nul"
"L and name is null; select code, name from bm_gdfgs where (code =?)";
this.oleDbUpdateCommand1.Connection = this.oleDbConnection1; this.oleDbUpdateCommand1.Parameters.Add (new System.Data.OleDb.OleDbParameter ( "code", System.Data.OleDb.OleDbType.VarChar, 2, "code"));
This. OledbupdateCommand1.Parameters.Add (New System.Data.Oledb.OleDbParameter ("name", system.data.oledb.oledbtype.varchar, 40, "name"));
this.oleDbUpdateCommand1.Parameters.Add (new System.Data.OleDb.OleDbParameter ( "Original_code", System.Data.OleDb.OleDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte) ( 0)), (System.byte) (0)), "CODE", System.Data.DataRowVersion.original, NULL);
this.oleDbUpdateCommand1.Parameters.Add (new System.Data.OleDb.OleDbParameter ( "Original_name", System.Data.OleDb.OleDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte) ( 0)), ((System.byte) (0)), "Name", System.Data.DataRowVersion.ORIGINAL, NULL);
this.oleDbUpdateCommand1.Parameters.Add (new System.Data.OleDb.OleDbParameter ( "Original_name1", System.Data.OleDb.OleDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte) ( 0)), ((System.byte) (0)), "Name", System.Data.DataRowVersion.ORIGINAL, NULL);
This.OLEDbupdateCommand1.Parameters.Add (New System.Data.Oledb.oledbParameter ("Select_code", System.Data.Oledb.oledbtype.varchar, 2, "Code");
//
// oleDbdeleteCommand1
//
THIS.OLEDBDELETECMMAND1.COMMANDTEXT = "DELETE from bm_gdfgs where (code =?) and (name =? or? is null and name is null"
")"
This.OleDbdeleteCommand1.connection = this.oledbconnection1;
this.oleDbDeleteCommand1.Parameters.Add (new System.Data.OleDb.OleDbParameter ( "Original_code", System.Data.OleDb.OleDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte) ( 0)), ((System.byte) (0)), "CODE", System.Data.DataRowVersion.original, Null); this.OleDbdeleteCommand1.Parameters.add (new system.data.oledb.oledbparameter ("Original_name ", System.data.oledb.oledbtype.varchar, 40, system.data.parameterDirection.input, false, ((System.byte) ((System.byte) (0))," Name ", System.Data.DataRowVersion.original, NULL);
this.oleDbDeleteCommand1.Parameters.Add (new System.Data.OleDb.OleDbParameter ( "Original_name1", System.Data.OleDb.OleDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte) ( 0)), ((System.byte) (0)), "Name", System.Data.DataRowVersion.ORIGINAL, NULL);
//
// OLEDBConnection1
//
this.oleDbConnection1.ConnectionString = @ "User ID = sa; Data Source = BILLGATES; Tag with column collation when possible = False; Initial Catalog = ydgl; Use Procedure for Prepare = 1; Auto Translate = True; Persist Security Info = False; Provider = "" sqloledb.1 ""; workstation id = Billgates; use encryption for data = false; packet size = 4096
//
// service1
//
}
Public DataSet GET_BM_GDFGS ()
{
DataSet DS = New Dataset ();
OLEDBDataAdapter1.fill (DS);
Return DS;
}
Public DataSet Update_Bm_GDFGS (Dataset DS)
{
IF (ds! = null)
{
OLEDBDATAADAPTER1.UPDATE (DS);
Return DS;
}
Else
{
Return NULL;
}
}
}
}
Keep in mind that if you get the information that does not exist in system.Runtime.Remoting.Channels.TCP namespace, check if you add a reference to System.Runtime.Remoting.dll as the code above. Compiling and created projects will get a DLL file and can be used in other projects. Step 2: Creating a Server object There are several ways to create a Server object. The most intuitive method is the following method: in Visual Studio.net, click "File" -> "New Creation" -> "Project", select Create a "Windows Application" and name it YDGLServer. The most important thing is that we need to add applications that have been created in the first step, which can operate correctly. Click "Project" -> Add References in turn, then add a reference to the DLL file created in the first step by clicking the "Browse" button. To use the .NET Remote feature, you must add a reference to the DLL file by selecting "Project" -> Add Reference. Select System.Runtime.Remoting.dll in the .NET tab, and then click the "OK" button. Then, you need to add a reference to System.Runtime.Remoting.DLL as we in the first step. The following object is quite simple and intuitive, I will explain each line of the three-line code related to .NET Remoting. TCPServerChannel is one of the two channel types supported by .NET Remoting, which will set our object to respond to the request from which port, ChannelServices.RegisterChannel will put the port number and the TCP / IP in the operating system. Stack binding. TcpServerChannel channel = new TcpServerChannel (9932); ChannelServices.RegisterChannel (channel); a channel may be provided another type of HTTP, it is simply used HttpServerChannel System.Runtime.Remoting.Channels.Http namespace objects to get. The difference between the HTTP and TCP channels can be simply concatenated: if the application is running on the LAN, it is best to use the TCP channel because its performance is better than the HTTP channel; if the application is running on the Internet, then Sometimes the HTTP is the only choice according to the configuration of the firewall. It is necessary to remember that if a firewall software is used, the firewall should configure the TCP data traffic through the port selected by you. RemotingConfiguration.RegisterWellkNownServiceType (Typeof (YDGLDB), "YDGLDB", WellkNownObjectMode.singlecall); This line code sets some of the parameters in the service and binds the object name to use with the remote object, the first parameter is bound Objects, the second parameter is a string of the remote object name in the TCP or HTTP channel, and the third parameter allows the container to know when there is a request to the object, how to handle the object. Although WellkNownObjectMode.single uses an instance of an object to all callars, it generates an instance of this object for each customer. The complete object code is as follows: use system; use system.drawing;
Using system.collections;
Using system.componentmodel;
Using system.windows.forms;
Using system.data; using system.runtime.remoting;
Using system.runtime.remoting.channels;
Using system.runtime.remoting.channels.tcp;
Using YDGLSERVERCLASSLIBRARY1;
Namespace YDGLSERVER1
{
///
/// Form1 summary description.
/// summary>
Public Class Form1: System.Windows.Forms.form
{
Private system.windows.Forms.PictureBox PictureBox1;
Private system.windows.Forms.Button button1;
Private system.windows.Forms.Button Button2;
Private system.windows.Forms.Button Button3;
Private system.windows.Forms.Label label1;
Private system.windows.Forms.Label label2;
Private system.windows.Forms.Label label3;
Private system.windows.Forms.comBobox ComboBox1;
///
/// The required designer variable.
/// summary>
Private system.componentmodel.Container Components = NULL;
Public Form1 ()
{
//
// Windows Form Designer Support
//
InitializationComponent ();
//
// Todo: Add any constructor code after INITIALIZECOMPONENT call
//
}
///
/// Clean all the resources being used.
/// summary>
Protected Override Void Dispose (Bool Disposing)
{
IF (Disposing)
{
IF (Components! = NULL)
{
Components.dispose ();
}
}
Base.dispose (Disposing);
}
#Region Windows Form Designer Generated Code
///
/// Designer supports the required method - do not use the code editor to modify
/// This method is content.
/// summary>
Private vidinitiRizeComponent ()
{
System.Resources.ResourceManager Resources = New System.Resources.ResourceManager (TypeOf (Form1));
This.PictureBox1 = new system.windows.Forms.PictureBox ();
This.button1 = new system.windows.Forms.Button ();
This.Button2 = new system.windows.Forms.Button ();
This.Button3 = new system.windows.Forms.Button ();
THIS.LABEL1 = New System.windows.Forms.label ();
THIS.LABEL2 = New System.windows.Forms.label ();
This.label3 = new system.windows.Forms.label ();
THIS.comBOBOX1 = New System.windows.Forms.comBobox ();
THIS.SUSPENDLAYOUT ();
//
// PictureBox1
//
This.PictureBox1.image = ((System.drawing.Image) ("PictureBox1.image)))));
This.PictureBox1.location = new system.drawing.point (32, 96);
This.PictureBox1.name = "PictureBox1";
This.Picturebox1.size = new system.drawing.size (56, 48);
This.PictureBox1.tabindex = 0;
This.PictureBox1.tabstop = false;
//
// Button1
//
This.Button1.Image = ((System.drawing.Image) ("Button1.image")))
This.button1.location = new system.drawing.point (253, 52);
This.button1.name = "button1";
This.button1.size = new system.drawing.size (32, 32);
This.button1.tabindex = 1;
//
// Button2
//
This.button2.image = ((System.drawing.Image))))))))); "Button2.Image"))
This.button2.location = new system.drawing.point (253, 100);
This.Button2.name = "button2";
This.button2.size = new system.drawing.size (32, 32);
This.button2.tabindex = 2;
//
// Button3
//
This.Button3.Image = ((System.drawing.Image) ("Button3.image"))));
This.button3.location = new system.drawing.point (253, 148);
This.button3.name = "button3";
This.button3.size = new system.drawing.size (32, 32);
this.button3.tabindex = 3;
//
// label1
//
THIS.Label1.Location = new system.drawing.point (149, 60);
THIS.LABEL1.NAME = "label1";
THIS.Label1.size = new system.drawing.size (32, 23);
THIS.Label1.tabindex = 4;
this.label1.text = "stop";
//
// label2
//
THIS.LABEL2.LOCATION = New System.drawing.Point (149, 108); this.label2.name = "label2";
THIS.Label2.size = new system.drawing.size (40, 23);
THIS.Label2.tabindex = 5;
THIS.Label2.text = "pause";
//
// label3
//
THIS.Label3.Location = new system.drawing.point (149, 156);
THIS.LABEL3.NAME = "label3";
THIS.Label3.size = new system.drawing.size (96, 23);
THIS.Label3.tabindex = 6;
THIS.Label3.Text = "start / continue";
//
// ComboBOX1
//
This.comBobox1.Location = new system.drawing.point (128, 24);
this.combobox1.name = "combobox1";
this.comboBOX1.Size = new system.drawing.size (160, 20);
This.combobox1.tabindex = 7;
this.comboBox1.text = "ydglserver";
//
// Form1
//
THIS.AUTOSCALEBASESIZE = New System.drawing.size (6, 14);
THIS.CLIENTSIZE = New System.drawing.size (392, 237);
This.Controls.add (this.comboBOX1);
THIS.CONTROLS.ADD (this.label3);
THIS.CONTROLS.ADD (this.label2);
This.Controls.add (this.label1);
This.Controls.add (this.button3);
This.Controls.add (this.button2);
This.Controls.add (this.button1);
This.Controls.add (this.PictureBox1);
THIS.NAME = "Form1";
This.startPosition = system.windows.forms.formstartPosition.CenterScreen
THIS.TEXT = "Power Marketing Application Server";
This.Load = New System.EventHandler (this.form1_load);
This.ResumeLayout (false);
}
#ndregion
///
/// The main entry point for the application.
/// summary>
[Stathread]
Static void main ()
{
Application.run (New Form1 ());
}
Private Void Form1_Load (Object Sender, System.EventArgs E)
{
// Register the channel
Tcpchannel CHAN = New TcpChannel (8085);
ChannelServices.RegisterChannel (CHAN);
// Register the remote object of the service
RemotingConfiguration.registerwellknownServiceType (Typeof (YDGLDB), WellkNownObjectMode.singleton;
}
}
Step 3: Creating the Remote client program YDGL is to test for the YDGLSERVER remote object created above. To create this project, click "File" -> "Create" -> "Project" in turn, then select Create a Windows Application Type, the name of YDGL. As in the second step, we need to add a reference to the DLL file created in the first step and System.Runtime.Remoting DLL. Both the following code is especially important for .NET Remoting. The first line creates a TCP client channel that is not bound to a port; the second line gets a reference to the remote YDGLDB object. Using system;
Using system.drawing;
Using system.collections;
Using system.componentmodel;
Using system.windows.forms;
Using system.data;
Using system.runtime.remoting;
Using system.runtime.remoting.channels;
Using system.runtime.remoting.channels.tcp;
Using YDGLSERVERCLASSLIBRARY1;
Namespace WinUi
{
///
/// Form1 summary description.
/// summary>
Public Class Form1: System.Windows.Forms.form
{
Private system.windows.Forms.mainMenu mainmentu1;
Private system.windows.Forms.MenuItem Menuitem1;
Private system.windows.Forms.MenuItem Menuitem2;
Private system.windows.Forms.MenuItem MenuItem3;
Private system.windows.Forms.MenuItem MenuItem4;
Private system.windows.Forms.MenuItem Menuitem5;
Private system.windows.Forms.MenuItem Menuitem6;
Private system.windows.Forms.MenuItem Menuitem7;
Private system.windows.Forms.MenuItem MenuItem8;
Private system.windows.Forms.MenuItem Menuitem9;
Private system.windows.Forms.MenuItem MenuItem 10;
Private system.windows.forms.menuitem menuitem11;
Private system.windows.forms.toolbar Toolbar1;
Private system.windows.Forms.statusbar statusbar1;
Private system.windows.forms.toolbarbutton ToolbarButton1;
Private system.windows.forms.toolbarbutton ToolbarButton2;
Private system.windows.forms.toolbarbutton toolbarbutton3; private system.windows.forms.toolbarbutton toolbarbutton4;
Private system.windows.forms.toolbarbutton ToolbarButton5;
Private system.windows.Forms.imagelist imagelist1;
Private system.windows.forms.DataGrid DataGrid1;
Private system.windows.Forms.Button button1;
Private system.componentmodel.icontainer components;
PRIVATE DATASET DS1;
Private system.windows.Forms.Button Button2;
Private YDGLDB YDGLDB1;
Public Form1 ()
{
//
// Windows Form Designer Support
//
InitializationComponent ();
//
// Todo: Add any constructor code after INITIALIZECOMPONENT call
//
}
///
/// Clean all the resources being used.
/// summary>
Protected Override Void Dispose (Bool Disposing)
{
IF (Disposing)
{
IF (Components! = NULL)
{
Components.dispose ();
}
}
Base.dispose (Disposing);
}
#Region Windows Form Designer Generated Code
///
/// Designer supports the required method - do not use the code editor to modify
/// This method is content.
/// summary>
Private vidinitiRizeComponent ()
{
This.Components = new system.componentmodel.container ();
System.Resources.ResourceManager Resources = New System.Resources.ResourceManager (TypeOf (Form1));
This.mainMenu1 = new system.windows.Forms.mainMenu ();
THIS.MENUITEM1 = New System.windows.Forms.Menuitem ();
THIS.MENUITEM6 = New System.windows.Forms.MenuItem ();
THIS.MENUITEM7 = New System.windows.Forms.MenuItem ();
THIS.MENUITEM9 = New System.windows.Forms.MenuItem ();
THIS.MENUITEM8 = New System.windows.Forms.MenuItem ();
THIS.MENUITEM2 = New System.windows.Forms.MenuItem ();
THIS.MENUITEM3 = New System.windows.Forms.MenuItem ();
This.Menuitem4 = new system.windows.Forms.MenuItem ();
THIS.MENUITEM5 = New System.windows.Forms.MenuItem ();
This.Menuitem10 = new system.windows.Forms.MenuItem (); this.Menuitem11 = new system.windows.forms.MenuItem ();
THIS.TOOLBAR1 = New System.windows.Forms.toolbar ();
This.ToolbarButton1 = new system.windows.Forms.toolbarButton ();
THIS.TOOLBARBUTTON2 = New System.windows.Forms.toolbarButton ();
This.ToolbarButton3 = new system.windows.Forms.toolbarButton ();
This.ToolbarButton4 = new system.windows.Forms.toolbarButton ();
THIS.TOOLBARBUTTON5 = new system.windows.forms.toolbarbutton ();
This.imagelist1 = new system.windows.forms.imagelist (this.components);
This.statusbar1 = new system.windows.Forms.statusbar ();
This.DataGrid1 = new system.windows.forms.dataGrid ();
This.button1 = new system.windows.Forms.Button ();
This.Button2 = new system.windows.Forms.Button ();
(System.comPonentModel.isupportInitialize) (DataAgrid1)). Begininit ();
THIS.SUSPENDLAYOUT ();
//
// mainmenu1
//
this.mainMenu1.Menuitems.Addrange (new system.windows.forms.MenuItem [] {
This.Menuitem1,
THIS.MENUITEM2,
THIS.MENUITEM5});
//
// Menuitem1
//
THIS.MENUITEM1.INDEX = 0;
This.Menuitem1.Menuitems.Addrange (new system.windows.forms.MenuItem [] {
this.Menuitem6,
this.Menuitem7,
this.Menuitem9,
THIS.MENUITEM8});
this.Menuitem1.Text = "& F file";
//
// Menuitem6
//
this.Menuitem6.index = 0;
This.Menuitem6.text = "Application Server Configuration";
//
// Menuitem7
//
THIS.MENUITEM7.INDEX = 1;
THIS.MENUITEM7.TEXT = "Login";
//
// Menuitem9
//
THIS.MENUITEM9.INDEX = 2;
THIS.MENUITEM9.TEXT = "-";
//
// Menuitem8
//
This.Menuitem8.index = 3;
this.Menuitem8.Text = "Exit";
//
// Menuitem2
//
this.Menuitem2.index = 1;
this.Menuitem2.Menuitems.addrange (new system.windows.forms.MenuItem [] {
this.Menuitem3,
THIS.MENUITEM4});
THIS.MENUITEM2.TEXT = "& w Window";
//
// Menuitem3
//
this.Menuitem3.index = 0;
THIS.MENUITEM3.TEXT = "horizontal";
This.Menuitem3.click = new system.eventhandler (this.MenuItem3_click);
//
// Menuitem4
//
this.Menuitem4.index = 1;
THIS.MENUITEM4.TEXT = "Vertical";
//
// Menuitem5
//
THIS.MENUITEM5.INDEX = 2;
This.Menuitem5.Menuitems.addrange (new system.windows.forms.MenuItem [] {
This.Menuitem10,
THIS.MENUITEM11});
this.Menuitem5.Text = "& H Help";
//
// Menuitem10
//
this.Menuitem10.index = 0;
THIS.MENUITEM10.TEXT = "Help";
THIS.MENUITEM10.Click = new system.eventhandler (this.Menuitem10_click);
//
// Menuitem11
//
THIS.MENUITEM11.INDEX = 1;
THIS.MENUITEM11.TEXT = "About Power Marketing Management System ..."
//
// Toolbar1
//
This.Toolbar1.buttons.addrange (new system.windows.forms.toolbarbutton [] {
THIS.TOOLBARBUTTON1,
THIS.TOOLBARBUTTON2,
THIS.TOOLBARBUTTON3,
THIS.TOOLBARBUTTON4,
THIS.TOOLBARBUTTON5});
THIS.TOOLBAR1.DROPDOWNARROWS = TRUE;
THIS.TOOLBAR1.Imagelist = this.imagelist1;
this.toolbar1.location = new system.drawing.point (0, 0);
THIS.TOOLBAR1.NAME = "Toolbar1";
THIS.TOOLBAR1.SHOWTOLTIPS = TRUE;
this.toolbar1.size = new system.drawing.size (1016, 28);
THIS.TOOLBAR1.TABINDEX = 2;
THIS.TOOLBAR1.BUTTONCLICK = New system.windows.forms.toolbarbuttonclickeventhandler (this.toolbar1_buttonclick);
//
// ToolbarButton1
//
THIS.TOOLBARBUTTON1.ImageIndex = 0;
//
// ToolbarButton2
//
THIS.TOOLBARBUTTON2.ImageIndex = 1;
//
// ToolbarButton3
//
This.ToolbarButton3.ImageIndex = 5;
//
// ToolbarButton4
//
THIS.TOOLBARBUTTON4.ImageIndex = 4;
//
// ToolbarButton5
//
THIS.TOOLBARBUTTON5.ImageIndex = 3;
//
// imaglist1
//
This.imagelist1.colordepth = system.windows.Forms.colorDepth.depth32bit;
this.imagelist1.imageSize = new system.drawing.size (16, 16);
This.imagelist1.imagestream = ((System.Windows.Forms.imageListStreame))))));
This.imagelist1.transparentcolor = system.drawing.color.transparent;
//
// statusbar1
//
This.statusbar1.location = new system.drawing.point (0, 699);
THIS.STATUSBAR1.NAME = "statusbar1";
THIS.STATUSBAR1.SIZE = New System.drawing.size (1016, 22);
THIS.STATUSBAR1.TABINDEX = 3;
THIS.STATUSBAR1.TEXT = "statusbar1";
//
// DataGrid1
//
THIS.DATAGRID1.DATAMEMBER = "";
This.DataGrid1.HeaderForeColor = system.drawing.systemcolors.ControlText;
This.DataGrid1.location = new system.drawing.point (304, 96);
This.DataGrid1.name = "datagrid1";
This.DataGrid1.size = new system.drawing.size (416, 160);
this.DataGrid1.tabindex = 5;
This.DataGrid1.navigate = new system.windows.forms.navigateEventHandler (this.DataGrid1_naviGate);
//
// Button1
//
This.Button1.Location = new system.drawing.point (488, 312);
This.button1.name = "button1";
this.button1.tabindex = 7;
This.button1.text = "update";
This.Button1.click = new system.eventhandler (this.button1_click);
//
// Button2
//
This.button2.location = new system.drawing.point (312, 312);
This.Button2.name = "button2";
this.button2.tabindex = 9;
This.button2.text = "retrieve"; this.button2.click = new system.eventhandler (this.button2_click);
//
// Form1
//
THIS.AUTOSCALEBASESIZE = New System.drawing.size (6, 14);
THISTEM.DRAWING.SYSTEMCOLORS.CONTROL;
THIS.CLIENTSIZE = New System.drawing.size (1016, 721);
This.Controls.add (this.button2);
This.Controls.add (this.button1);
This.Controls.add (this.DataGrid1);
This.Controls.add (this.statusbar1);
This.Controls.add (this.toolbar1);
THIS.IsmdicontAiner = True;
THIS.MENU = this.mainMenu1;
THIS.NAME = "Form1";
This.startPosition = system.windows.forms.formstartPosition.CenterScreen
THIS.TEXT = "Power Marketing Management";
This.WindowsTate = system.windows.forms.formwindowsTate.maximized;
This.Load = New System.EventHandler (this.form1_load);
(System.comPonentModel.isupportInitialize) (THISDATAGRID1)). Endinit ();
This.ResumeLayout (false);
}
#ndregion
///
/// The main entry point for the application.
/// summary>
[Stathread]
Static void main ()
{
RemotingConfiguration.registerwellknownClientType (TypeOf (YDGLDB), "TCP: //10.176.174.20: 8085 / ydgldb");
Application.run (New Form1 ());
}
Private Void Menuitem3_Click (Object Sender, System.EventArgs E)
{
}
Private Void Form1_Load (Object Sender, System.EventArgs E)
{
YDGLDB1 = New YDGLDB ();
}
Private Void Menuitem10_Click (Object Sender, System.EventArgs E)
{
}
Private void Toolbar1_ButtonClick (Object Sender, System.Windows.Forms.ToolbarButtonclicKeventargs E)
{
}
Private void SqlConnection1_infomessage (Object Sender, System.data.sqlclient.sqlinfomentsageEventArgeEventArgs E)
{
}
Private void DataGrid1_navigate (Object Sender, System.Windows.Forms.navigateEventArgs Ne)
{
}
Private void button1_click (Object sender, system.eventargs e) {
YDGLDB1.UPDATE_BM_GDFGS (DS1);
}
Private void button2_click (Object Sender, System.Eventargs E)
{
YDGLDB1.INITIALIZECMPONENT ();
DS1 = YDGLDB1.GET_BM_GDFGS ();
DataGrid1.datasource = DS1.TABLES [0];
}
}
}
About the Author: The author is much smaller range, is a software engineer in the direction of the software. He is currently working in China Chengdu Direction Software Technology Co., Ltd., engaged in .NET, SYBASE development and research. Email: fanxiaoduo@yahoo.com.cn Address: 8-1-14, No.3, Nanxun Road, Jinnan District, Chengdu, China Postcode: 641001
Author Blog:
http://blog.9cbs.net/fanxiaoduo/