All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
微软.NET平台中类型使用的基本原理_.net资料_编程技术
ASP.NET技巧:用GZip压缩和解压_[Asp.Net教程]
HTML 初学者指南(4)_[Html教程]
使用PHP,5.0,轻松解析XML文档_php资料_编程技术
ADO.NET中的多数据表操作浅析之读取_[Asp.Net教程]
一个程序详细研究DataReader_[Asp.Net教程]
PHP和MYSQL制作动态网站开发经验之谈_php资料_编程技术
总结:常见php页面漏洞分析及相关问题解决_php资料_编程技术
七个C#编程的小技巧_.net资料_编程技术
五个常见 PHP 数据库问题_[PHP教程]
Reading number is top 10 pictures
到底是谁撞谁呀?
Ashlynn Brooke show proud chest measurement1
30 beautiful school beauty4
The real super beauty15
恶搞漫画1
Born After 90 Beijing sports university campus flower photos3
HongMenYan premiere XinLiangGong clairvoyant outfit PK YiFeiLiu2
Extremely rare TianShan Mountains snow lotus2
狗狗与主人神同步1
Born After 90 Beijing sports university campus flower photos4
Download software ranking
Unix video tutorial9
Dance with duck(male prostitution)
Take off clothes to survival
Unix video tutorial15
Professional killers2 for Android
The Bermuda triangle2
Boxer's Top ten classic battle7
Unix video tutorial17
C#程序员参考手册
卡丁车单机版
qq published in(发表于) 2014/7/11 9:22:10 Edit(编辑)
C#教程:COM+组件建立客户端程序

C#教程:COM+组件建立客户端程序

C#教程:COM+组件建立客户端程序

建立客户端程序

下面将建立客户端程序,设计结果如图1所示。详细步骤如下所示。



图1 客户端设计结果图

(1)创建一个项目,项目类型为Windows应用程序,设置其名称为35_02,单击【确定】按钮,项目创建成功。

(2)向Windows窗体添加5个TextBox控件和一个Button控件,它们分别用于输入银行转账信息和执行银行转账命令。

(3)引用EnterpriseServices。选择“项目”/“添加引用”,弹出“添加引用”对话框,在列表中选择System. EnterpriseServices,单击【确定】按钮即可。

(4)添加引用COM+服务组件——引用Ex35_01.DLL即可。选择“项目”/“添加引用”,弹出“添加引用”对话框,然后选择“浏览”选项卡,找到注册Ex35_01.DLL文件位置,如图2所示,最后单击【确定】按钮。



图2 添加COM+服务组件

(5)客户端实现代码。

首先,添加Ex35_01命名空间,其次,声明Transfer服务类对象,通过类对象调用银行转账BankTransfer方法,实现转账功能。完整代码如下:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using Ex35_01;

namespace _5_02

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Transfer tt = new Transfer();

bool bl= tt.BankTransfer(txtFromBank.Text, txtFromAccount.Text, txtToBank.Text, txtToAccount.Text, Single. Parse(txtBalance.Text));

if (bl)

MessageBox.Show("银行转账成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon. Information);

else

MessageBox.Show("银行转账失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

}

完整程序代码如下:

★★★★★Form1.cs窗体代码文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using Ex35_01;

//using System.EnterpriseServices.CompensatingResourceManager;

namespace _5_02

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Transfer tt = new Transfer();

bool bl= tt.BankTransfer(txtFromBank.Text, txtFromAccount.Text, txtToBank.Text, txtToAccount.Text, Single.Parse(txtBalance.Text));

if (bl)

MessageBox.Show("银行转账成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

else

MessageBox.Show("银行转账失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);

}

}

}

★ ★★★★Form1.Designer.cs窗体设计文件完整程序代码★★★★★

namespace _5_02

{

partial class Form1

{

///



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

///


private System.ComponentModel.IContainer components = null;

///

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

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

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

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.button1 = new System.Windows.Forms.Button();

this.txtFromBank = new System.Windows.Forms.TextBox();

this.txtFromAccount = new System.Windows.Forms.TextBox();

this.txtToBank = new System.Windows.Forms.TextBox();

this.txtToAccount = new System.Windows.Forms.TextBox();


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.