分享
 
 
 

构建一个.net Remoting 程序(真正的三层结构)_吐血推荐

王朝c#·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

构建一个.net Remoting 程序(真正的三层结构)_突血推荐!!!

NET Remoting提供了一个功能强大、高效的处理远程对象的方法。我在开发一个电力软件时,由于业务量大,必须用三层结构。实现数据处理(浏览、更新)但是这方面的资料很少。通过摸索我找到的方法。谨献给想用.net开发三层结构数据库应用软件而又苦于找不到方法的C#程序员。

第一步:创建共享库

依次点击“文件”->“新创建”->“工程”,选择创建一个C# Library,并将其命名为ydglServerLibrary,然后点击OK按钮。这将创建一个我们的.NET Remote客户端和服务器端用来通讯的“共享命令集”。

正面是完整的代码

using System;

using System.Runtime ;

using System.Data.OleDb;

using System.Data.SqlClient;

using System.Data;

using System.Configuration;

namespace ydglServerClassLibrary1

{

/// <summary>

/// Class1 的摘要说明。

/// </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.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;

this.oleDbDataAdapter1.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.oleDbDataAdapter1.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 (code = ?)";

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.oleDbInsertCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Select_code", System.Data.OleDb.OleDbType.VarChar, 2, "code"));

//

// oleDbUpdateCommand1

//

this.oleDbUpdateCommand1.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.oleDbDeleteCommand1.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)(0)), ((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;

}

}

}

}

请记住,如果得到System.Runtime.Remoting.Channels.Tcp名字空间不存在的信息,请检查是否象上面的代码那样添加了对System.Runtime.Remoting.dll的引用。

编译创建的工程,就会得到一个DLL文件,并可以在其他的工程中使用它。

第二步:创建Server对象

有几种方法可以创建Server对象,最直观的方法是下面的方法:在Visual Studio.NET中,依次点击“文件”->“新创建”->“工程”,选择创建一个“Windows Application”,并将它命名为ydglServer。

最最重要的是,我们需要添加对刚才在第一步中所创建的DLL文件的应用,该应用程序才能正确地运行。依次点击“工程”->“添加引用”,然后通过点击“浏览”按钮添加一个对在第一步中所创建的DLL文件的引用。

为了使用.NET remote功能,必须通过选择“工程”->“添加引用”,添加对DLL文件的引用。在.NET标签中选择System.Runtime.Remoting.DLL,然后点击“OK”按钮。然后,需要象我们在第一步中那样添加对System.Runtime.Remoting.dll的引用。

下面的对象相当的简单和直观,我将就真正与.NET remoting相关的3行代码中的每一行进行解释。

TcpServerChannel是.NET remoting支持的二种信道类型中的一种,它将设置我们希望我们的对象对来自哪一个端口的请求进行回应,ChannelServices.RegisterChannel将把该端口号与操作系统中的TCP/IP栈绑定。

TcpServerChannel channel = new TcpServerChannel(9932);

ChannelServices.RegisterChannel(channel);

另一种可以设置的信道类型是HTTP,只要简单地使用System.Runtime.Remoting.Channels.Http名字空间中的HttpServerChannel对象即可搞定。使用HTTP和TCP信道之间的区别可以简单的归结为:如果应用程序是在局域网上运行,则最好使用TCP信道,因为它的性能要好于HTTP信道;如果应用程序是在互联网上运行,则有时候根据防火墙的配置,HTTP是唯一的选择。需要记住的是,如果使用了防火墙软件,则防火墙应该配置成允许TCP数据流量通过你为对象选择的端口。

RemotingConfiguration.RegisterWellKnownServiceType(typeof(ydglDB),

"ydglDB", WellKnownObjectMode.SingleCall);

这行代码设置了服务中的一些参数和把欲使用的对象名字与远程对象进行绑定,第一个参数是绑定的对象,第二个参数是TCP或HTTP信道中远程对象名字的字符串,第三个参数让容器知道,当有对对象的请求传来时,应该如何处理对象。尽管WellKnownObjectMode.Single对所有的调用者使用一个对象的实例,但它为每个客户生成这个对象的一个实例。

完整的对象代码如下所示:

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 ydglserver1

{

/// <summary>

/// Form1 的摘要说明。

/// </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;

/// <summary>

/// 必需的设计器变量。

/// </summary>

private System.ComponentModel.Container components = null;

public Form1()

{

//

// Windows 窗体设计器支持所必需的

//

InitializeComponent();

//

// TODO: 在 InitializeComponent 调用后添加任何构造函数代码

//

}

/// <summary>

/// 清理所有正在使用的资源。

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows 窗体设计器生成的代码

/// <summary>

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

/// </summary>

private void InitializeComponent()

{

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)(resources.GetObject("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)(resources.GetObject("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)(resources.GetObject("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)(resources.GetObject("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 = "电力营销应用服务器";

this.Load += new System.EventHandler(this.Form1_Load);

this.ResumeLayout(false);

}

#endregion

/// <summary>

/// 应用程序的主入口点。

/// </summary>

[STAThread]

static void Main()

{

Application.Run(new Form1());

}

private void Form1_Load(object sender, System.EventArgs e)

{

//注册信道

TcpChannel chan=new TcpChannel(8085);

ChannelServices.RegisterChannel(chan);

//注册提供服务的远程对象

RemotingConfiguration.RegisterWellKnownServiceType(typeof(ydglDB),"ydglDB",WellKnownObjectMode.Singleton);

}

}

}

第三步:创建Remote客户端程序

ydgl是我们为对在上面创建的ydglServer远程对象进行测试而创建的。要创建这一工程,可以依次点击“文件”->“创建”->“工程”,然后选择创建一个windows Application类型、名字为ydgl的工程名。象在第二步中那样,我们需要添加对在第一步中创建的DLL文件和System.Runtime.Remoting DLL的引用。

下面的代码中有二行对于.NET remoting而言是特别重要的。第一行创建了一个TCP客户端信道,该信道并不是绑定在一个端口上的;第二行获取了一个对远程的ydgldb对象的引用。

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

{

/// <summary>

/// Form1 的摘要说明。

/// </summary>

public class Form1 : System.Windows.Forms.Form

{

private System.Windows.Forms.MainMenu mainMenu1;

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 menuItem10;

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 窗体设计器支持所必需的

//

InitializeComponent();

//

// TODO: 在 InitializeComponent 调用后添加任何构造函数代码

//

}

/// <summary>

/// 清理所有正在使用的资源。

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows 窗体设计器生成的代码

/// <summary>

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

/// </summary>

private void InitializeComponent()

{

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)(this.dataGrid1)).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文件 ";

//

// menuItem6

//

this.menuItem6.Index = 0;

this.menuItem6.Text = "应用服务器配置";

//

// menuItem7

//

this.menuItem7.Index = 1;

this.menuItem7.Text = "登录";

//

// menuItem9

//

this.menuItem9.Index = 2;

this.menuItem9.Text = "-";

//

// menuItem8

//

this.menuItem8.Index = 3;

this.menuItem8.Text = "退出";

//

// menuItem2

//

this.menuItem2.Index = 1;

this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

this.menuItem3,

this.menuItem4});

this.menuItem2.Text = "&W窗口 ";

//

// menuItem3

//

this.menuItem3.Index = 0;

this.menuItem3.Text = "水平";

this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);

//

// menuItem4

//

this.menuItem4.Index = 1;

this.menuItem4.Text = "垂直";

//

// menuItem5

//

this.menuItem5.Index = 2;

this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {

this.menuItem10,

this.menuItem11});

this.menuItem5.Text = "&H帮助";

//

// menuItem10

//

this.menuItem10.Index = 0;

this.menuItem10.Text = "帮助";

this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);

//

// menuItem11

//

this.menuItem11.Index = 1;

this.menuItem11.Text = "关于电力营销管理系统...";

//

// 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.ShowToolTips = 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;

//

// imageList1

//

this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;

this.imageList1.ImageSize = new System.Drawing.Size(16, 16);

this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));

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);

this.BackColor = System.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 = "电力营销管理";

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

this.Load += new System.EventHandler(this.Form1_Load);

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();

this.ResumeLayout(false);

}

#endregion

/// <summary>

/// 应用程序的主入口点。

/// </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.SqlInfoMessageEventArgs 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.InitializeComponent();

ds1=ydglDB1.Get_bm_gdfgs();

dataGrid1.DataSource=ds1.Tables[0];

}

}

}

关于作者:本文作者范小多,是方向软件的软件工程师。他目前在中国成都方向软件技术有限公司工作,从事.net,Sybase的方面的开发和研究。

Email:fanxiaoduo@yahoo.com.cn

联系地址:成都市金牛区圃园南二路3号丽景湾8-1-14

邮编:641001

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有