⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddbview.cs

📁 Csharp网络应用案例导航 Csharp网络应用案例导航
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
using DDB;

using System.Net;

using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Activation;

namespace DdbView
{
	/// <summary>
	/// Summary description for DdbView.
	/// </summary>
	public class DdbView : System.Windows.Forms.Form
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Button Qbutton;

		private DbServer LocalDbServer;//提供服务的本地数据服务程序
		string port;					//发布DbServer的端口
		private System.Windows.Forms.Button BtClose;

		private TcpChannel MyChannel;// 用来侦听别机请求
		private System.Windows.Forms.Button Createbutton;
		private System.Windows.Forms.Button InitialButton;
		private System.Windows.Forms.Button btnCreDB;
		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.RadioButton radioLoc2;
		private System.Windows.Forms.RadioButton radioLoc1;
		private System.Windows.Forms.RadioButton radioRem4;
		private System.Windows.Forms.RadioButton radioRem3;
		private System.Windows.Forms.RadioButton radioRem2;
		private System.Windows.Forms.RadioButton radioRem1;
		private System.Windows.Forms.RadioButton radioJoin2;
		private System.Windows.Forms.DataGrid dataGridLoc;
		private System.Windows.Forms.DataGrid dataGridRem;
		private System.Windows.Forms.DataGrid dataGridJoin;
		private System.Windows.Forms.TabControl tabJoinDS;
		private System.Windows.Forms.TabPage tabLoc;
		private System.Windows.Forms.TabPage tabRem;
		private System.Windows.Forms.TabPage tabJoin;
		private System.Windows.Forms.RadioButton radioJoin1;
		
		public DdbView()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
 
			//
			// TODO: Add any constructor code after InitializeComponent call
			//

		

			IPHostEntry LocalHostEntry = Dns.GetHostByName(Dns.GetHostName());
			string[] temp=LocalHostEntry.AddressList[0].ToString().Split('.');

			//Change		
			port=(9000+Int32.Parse(temp[3])).ToString();

			///创建一个通道实例,该通道使用端口90后接本机ip最后一部分
			///
			MyChannel = new TcpChannel(Int32.Parse(port));
			///注册通道 
			///register the channel with the runtime
			ChannelServices.RegisterChannel( MyChannel );
		
			///register the remote type and pass in a uri identifying string
			RemotingConfiguration.RegisterWellKnownServiceType( typeof( DbServer ), "DDB", WellKnownObjectMode.Singleton);
			try
			{
				
			}
				///无法获得则捕捉异常,异常情况有可能是:指定的url地址不可达或者指定获得的对象定义不对
			catch( NullReferenceException nullExp )
			{
				MessageBox.Show( "The url for the object is invalid " + nullExp.Message );
			}
			catch( RemotingException remExp )
			{
				MessageBox.Show( "The object type is not defined properly, it needs to be derived for a remoting class " + remExp.Message );
			}
	
		}

		/// <summary>
		/// Clean up any 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
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Qbutton = new System.Windows.Forms.Button();
			this.dataGridLoc = new System.Windows.Forms.DataGrid();
			this.BtClose = new System.Windows.Forms.Button();
			this.dataGridRem = new System.Windows.Forms.DataGrid();
			this.dataGridJoin = new System.Windows.Forms.DataGrid();
			this.Createbutton = new System.Windows.Forms.Button();
			this.InitialButton = new System.Windows.Forms.Button();
			this.btnCreDB = new System.Windows.Forms.Button();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.menuItem4 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem5 = new System.Windows.Forms.MenuItem();
			this.tabJoinDS = new System.Windows.Forms.TabControl();
			this.tabLoc = new System.Windows.Forms.TabPage();
			this.radioLoc2 = new System.Windows.Forms.RadioButton();
			this.radioLoc1 = new System.Windows.Forms.RadioButton();
			this.tabRem = new System.Windows.Forms.TabPage();
			this.radioRem4 = new System.Windows.Forms.RadioButton();
			this.radioRem3 = new System.Windows.Forms.RadioButton();
			this.radioRem2 = new System.Windows.Forms.RadioButton();
			this.radioRem1 = new System.Windows.Forms.RadioButton();
			this.tabJoin = new System.Windows.Forms.TabPage();
			this.radioJoin2 = new System.Windows.Forms.RadioButton();
			this.radioJoin1 = new System.Windows.Forms.RadioButton();
			((System.ComponentModel.ISupportInitialize)(this.dataGridLoc)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGridRem)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataGridJoin)).BeginInit();
			this.tabJoinDS.SuspendLayout();
			this.tabLoc.SuspendLayout();
			this.tabRem.SuspendLayout();
			this.tabJoin.SuspendLayout();
			this.SuspendLayout();
			// 
			// Qbutton
			// 
			this.Qbutton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.Qbutton.Location = new System.Drawing.Point(103, 432);
			this.Qbutton.Name = "Qbutton";
			this.Qbutton.Size = new System.Drawing.Size(93, 38);
			this.Qbutton.TabIndex = 0;
			this.Qbutton.Text = "查询";
			this.Qbutton.Click += new System.EventHandler(this.OnQuery);
			// 
			// dataGridLoc
			// 
			this.dataGridLoc.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.dataGridLoc.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
			this.dataGridLoc.CaptionVisible = false;
			this.dataGridLoc.DataMember = "";
			this.dataGridLoc.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridLoc.Location = new System.Drawing.Point(10, 10);
			this.dataGridLoc.Name = "dataGridLoc";
			this.dataGridLoc.PreferredColumnWidth = 200;
			this.dataGridLoc.ReadOnly = true;
			this.dataGridLoc.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.dataGridLoc.RowHeadersVisible = false;
			this.dataGridLoc.Size = new System.Drawing.Size(818, 463);
			this.dataGridLoc.TabIndex = 1;
			// 
			// BtClose
			// 
			this.BtClose.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			this.BtClose.Location = new System.Drawing.Point(516, 432);
			this.BtClose.Name = "BtClose";
			this.BtClose.Size = new System.Drawing.Size(95, 36);
			this.BtClose.TabIndex = 2;
			this.BtClose.Text = "退出";
			this.BtClose.Click += new System.EventHandler(this.OnClose);
			// 
			// dataGridRem
			// 
			this.dataGridRem.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.dataGridRem.CaptionVisible = false;
			this.dataGridRem.DataMember = "";
			this.dataGridRem.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridRem.Location = new System.Drawing.Point(10, 10);
			this.dataGridRem.Name = "dataGridRem";
			this.dataGridRem.PreferredColumnWidth = 200;
			this.dataGridRem.RowHeadersVisible = false;
			this.dataGridRem.Size = new System.Drawing.Size(569, 312);
			this.dataGridRem.TabIndex = 3;
			// 
			// dataGridJoin
			// 
			this.dataGridJoin.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.dataGridJoin.CaptionVisible = false;
			this.dataGridJoin.ColumnHeadersVisible = false;
			this.dataGridJoin.DataMember = "";
			this.dataGridJoin.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridJoin.Location = new System.Drawing.Point(10, 10);
			this.dataGridJoin.Name = "dataGridJoin";
			this.dataGridJoin.PreferredColumnWidth = 200;
			this.dataGridJoin.ReadOnly = true;
			this.dataGridJoin.RightToLeft = System.Windows.Forms.RightToLeft.No;
			this.dataGridJoin.RowHeadersVisible = false;
			this.dataGridJoin.RowHeaderWidth = 25;
			this.dataGridJoin.Size = new System.Drawing.Size(569, 303);
			this.dataGridJoin.TabIndex = 4;
			// 
			// Createbutton
			// 
			this.Createbutton.Location = new System.Drawing.Point(196, 432);
			this.Createbutton.Name = "Createbutton";
			this.Createbutton.Size = new System.Drawing.Size(95, 38);
			this.Createbutton.TabIndex = 5;
			this.Createbutton.Text = "新建表";
			this.Createbutton.Click += new System.EventHandler(this.Createbutton_Click);
			// 
			// InitialButton
			// 
			this.InitialButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.InitialButton.Location = new System.Drawing.Point(10, 432);
			this.InitialButton.Name = "InitialButton";
			this.InitialButton.Size = new System.Drawing.Size(93, 38);
			this.InitialButton.TabIndex = 6;
			this.InitialButton.Text = "初始化";
			this.InitialButton.Click += new System.EventHandler(this.InitialButton_Click);
			// 
			// btnCreDB
			// 
			this.btnCreDB.Location = new System.Drawing.Point(423, 432);
			this.btnCreDB.Name = "btnCreDB";
			this.btnCreDB.Size = new System.Drawing.Size(93, 36);
			this.btnCreDB.TabIndex = 7;
			this.btnCreDB.Text = "建数据库";
			this.btnCreDB.Click += new System.EventHandler(this.btnCreDB_Click);
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1,
																					  this.menuItem2});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem3,
																					  this.menuItem4});
			this.menuItem1.Text = "功能";
			this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 0;
			this.menuItem3.Text = "初始化";
			// 
			// menuItem4
			// 
			this.menuItem4.Index = 1;
			this.menuItem4.Text = "退出";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 1;
			this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem5});
			this.menuItem2.Text = "操作";
			// 
			// menuItem5
			// 
			this.menuItem5.Index = 0;
			this.menuItem5.Text = "查询";
			// 
			// tabJoinDS
			// 
			this.tabJoinDS.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.tabJoinDS.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.tabLoc,
																					this.tabRem,
																					this.tabJoin});
			this.tabJoinDS.Location = new System.Drawing.Point(10, 10);
			this.tabJoinDS.Multiline = true;
			this.tabJoinDS.Name = "tabJoinDS";
			this.tabJoinDS.SelectedIndex = 0;
			this.tabJoinDS.Size = new System.Drawing.Size(601, 412);
			this.tabJoinDS.TabIndex = 11;
			// 
			// tabLoc
			// 
			this.tabLoc.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.radioLoc2,
																				 this.radioLoc1,
																				 this.dataGridLoc});
			this.tabLoc.Location = new System.Drawing.Point(4, 24);
			this.tabLoc.Name = "tabLoc";
			this.tabLoc.Size = new System.Drawing.Size(593, 384);
			this.tabLoc.TabIndex = 0;
			this.tabLoc.Text = "本地数据库";
			// 
			// radioLoc2
			// 
			this.radioLoc2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.radioLoc2.Enabled = false;
			this.radioLoc2.Location = new System.Drawing.Point(170, 482);
			this.radioLoc2.Name = "radioLoc2";
			this.radioLoc2.Size = new System.Drawing.Size(318, 29);
			this.radioLoc2.TabIndex = 3;
			this.radioLoc2.Text = "地产商信息(只有北京可以)";
			// 
			// radioLoc1
			// 
			this.radioLoc1.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left);
			this.radioLoc1.Checked = true;
			this.radioLoc1.Location = new System.Drawing.Point(10, 482);
			this.radioLoc1.Name = "radioLoc1";
			this.radioLoc1.Size = new System.Drawing.Size(150, 29);
			this.radioLoc1.TabIndex = 2;
			this.radioLoc1.TabStop = true;
			this.radioLoc1.Text = "本地楼盘信息";
			// 
			// tabRem

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -