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

📄 cdlgwsinfo.cs

📁 本书主要介绍了从基础开始建立Portal的快速应用开发过程(RAD)的方法。通过本书你可以了解到关于Oracle 9iAS Portal产品的主要特性、入口的开发和组织、网络开发和管理、实际的关系型数
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OracleClient;
using GlobleUtility;
using PlatF;


namespace PlatF
{
	/// <summary>
	/// 类名: CdlgWsInfoForCharge
	/// 功能: 添加工作站选择窗口
	/// 使用方法: 调用该类的构造函数,然后以有模式方式显示窗体
	/// </summary>
	public class CdlgWsInfoForCharge : System.Windows.Forms.Form
	{
		private ArrayList WsList = new ArrayList();

		private System.Windows.Forms.DataGrid dgWsInfo;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
		private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		/// <summary>
		/// 要添加的工作站列表
		/// </summary>
		public ArrayList SelectedWs
		{
			get
			{
				return WsList;
			}
		}

		public CdlgWsInfoForCharge()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
			if (InitWsInfo() == 1)
			{
				this.Close();
			}
		}

		/// <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.dgWsInfo = new System.Windows.Forms.DataGrid();
			this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
			this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.dgWsInfo)).BeginInit();
			this.SuspendLayout();
			// 
			// dgWsInfo
			// 
			this.dgWsInfo.CaptionVisible = false;
			this.dgWsInfo.DataMember = "";
			this.dgWsInfo.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgWsInfo.Location = new System.Drawing.Point(0, 0);
			this.dgWsInfo.Name = "dgWsInfo";
			this.dgWsInfo.ReadOnly = true;
			this.dgWsInfo.Size = new System.Drawing.Size(600, 208);
			this.dgWsInfo.TabIndex = 0;
			this.dgWsInfo.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
																								 this.dataGridTableStyle1});
			// 
			// dataGridTableStyle1
			// 
			this.dataGridTableStyle1.DataGrid = this.dgWsInfo;
			this.dataGridTableStyle1.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
																												  this.dataGridTextBoxColumn1});
			this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGridTableStyle1.MappingName = "Table";
			// 
			// dataGridTextBoxColumn1
			// 
			this.dataGridTextBoxColumn1.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
			this.dataGridTextBoxColumn1.Format = "";
			this.dataGridTextBoxColumn1.FormatInfo = null;
			this.dataGridTextBoxColumn1.HeaderText = "IP地址";
			this.dataGridTextBoxColumn1.MappingName = "IPAddr";
			this.dataGridTextBoxColumn1.Width = 200;
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(80, 224);
			this.btnOK.Name = "btnOK";
			this.btnOK.Size = new System.Drawing.Size(80, 32);
			this.btnOK.TabIndex = 1;
			this.btnOK.Text = "确定";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(408, 224);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(80, 32);
			this.btnCancel.TabIndex = 2;
			this.btnCancel.Text = "取消";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// CdlgWsInfoForCharge
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(594, 277);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.dgWsInfo);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
			this.Name = "CdlgWsInfoForCharge";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "工作站信息";
			((System.ComponentModel.ISupportInitialize)(this.dgWsInfo)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
		/// <summary>
		/// 初始化工作站信息,窗体创建时执行一次
		/// </summary>
		/// <returns>0:成功;1:失败</returns>
		private int InitWsInfo()
		{
			ErrorCode E = new ErrorCode();
			OracleConnection myConn = Connection.DBConnection;
			if (myConn == null)
			{
				E.ShowMessage(ErrorCode.E_3_ConnectDBFailed_Code);
				return 1;
			}
			string mySql = "Select t1.IPAddr IPAddr " + 
				"From charge_WS_Info t1 " + 
				"Order By IPAddr";
			OracleDataAdapter myDataAdapter = new OracleDataAdapter(mySql, myConn);
			DataSet myDataSet = new DataSet();
			try
			{
				myDataAdapter.Fill(myDataSet);
				dgWsInfo.DataSource = myDataSet.Tables[0].DefaultView;
			}
			catch
			{
				E.ShowMessage(8);
				return 1;
			}
			
			return 0;
		}

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			if (dgWsInfo.CurrentRowIndex == -1)
			{
				MessageBox.Show(this, "请选中要添加的工作站!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
			}
			else
			{
				WsList.Clear();
				for (int i = 0; i < dgWsInfo.VisibleRowCount; i++)
				{
					if (dgWsInfo.IsSelected(i))
					{
						dgWsInfo.UnSelect(i);
						WsList.Add(dgWsInfo[i, 0]);
					}
				}
				this.DialogResult = DialogResult.OK;
				this.Close();
			}
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
			for (int i = 0; i < dgWsInfo.VisibleRowCount; i++)
			{
				if (dgWsInfo.IsSelected(i))
				{
					dgWsInfo.UnSelect(i);
				}
			}
		}



	}
}

⌨️ 快捷键说明

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