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

📄 zkselect.cs

📁 剖面生成器
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.SqlClient;
using Microsoft.Win32;
using System.Data;

namespace ProfileCtrl
{
	/// <summary>
	/// ZkSelect 的摘要说明。
	/// </summary>
	public class ZkSelect : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button btnDelAll;
		private System.Windows.Forms.Button btnAddAll;
		private System.Windows.Forms.Button btnDel;
		private System.Windows.Forms.Button btnAdd;
		private System.Windows.Forms.ListBox lstInput;
		public System.Windows.Forms.ListBox lstSource;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private AxSuperMapLib.AxSuperWorkspace axSuperWorkspace1;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public ZkSelect()
		{
			//
			// 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(ZkSelect));
			this.btnDelAll = new System.Windows.Forms.Button();
			this.btnAddAll = new System.Windows.Forms.Button();
			this.btnDel = new System.Windows.Forms.Button();
			this.btnAdd = new System.Windows.Forms.Button();
			this.lstInput = new System.Windows.Forms.ListBox();
			this.lstSource = new System.Windows.Forms.ListBox();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.axSuperWorkspace1 = new AxSuperMapLib.AxSuperWorkspace();
			((System.ComponentModel.ISupportInitialize)(this.axSuperWorkspace1)).BeginInit();
			this.SuspendLayout();
			// 
			// btnDelAll
			// 
			this.btnDelAll.Location = new System.Drawing.Point(152, 152);
			this.btnDelAll.Name = "btnDelAll";
			this.btnDelAll.Size = new System.Drawing.Size(32, 24);
			this.btnDelAll.TabIndex = 25;
			this.btnDelAll.Text = "<--";
			this.btnDelAll.Click += new System.EventHandler(this.btnDelAll_Click);
			// 
			// btnAddAll
			// 
			this.btnAddAll.Location = new System.Drawing.Point(152, 112);
			this.btnAddAll.Name = "btnAddAll";
			this.btnAddAll.Size = new System.Drawing.Size(32, 24);
			this.btnAddAll.TabIndex = 24;
			this.btnAddAll.Text = "++>";
			this.btnAddAll.Click += new System.EventHandler(this.btnAddAll_Click);
			// 
			// btnDel
			// 
			this.btnDel.Location = new System.Drawing.Point(152, 72);
			this.btnDel.Name = "btnDel";
			this.btnDel.Size = new System.Drawing.Size(32, 24);
			this.btnDel.TabIndex = 23;
			this.btnDel.Text = "<-";
			this.btnDel.Click += new System.EventHandler(this.btnDel_Click);
			// 
			// btnAdd
			// 
			this.btnAdd.Location = new System.Drawing.Point(152, 32);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.Size = new System.Drawing.Size(32, 24);
			this.btnAdd.TabIndex = 22;
			this.btnAdd.Text = "+>";
			this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
			// 
			// lstInput
			// 
			this.lstInput.ItemHeight = 12;
			this.lstInput.Location = new System.Drawing.Point(200, 32);
			this.lstInput.Name = "lstInput";
			this.lstInput.Size = new System.Drawing.Size(104, 160);
			this.lstInput.TabIndex = 21;
			// 
			// lstSource
			// 
			this.lstSource.ItemHeight = 12;
			this.lstSource.Location = new System.Drawing.Point(24, 32);
			this.lstSource.Name = "lstSource";
			this.lstSource.Size = new System.Drawing.Size(104, 160);
			this.lstSource.TabIndex = 20;
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(200, 8);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(80, 24);
			this.label4.TabIndex = 18;
			this.label4.Text = "已经选取钻孔";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(40, 8);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(80, 24);
			this.label5.TabIndex = 19;
			this.label5.Text = "可选钻孔编号";
			this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// button1
			// 
			this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.button1.Location = new System.Drawing.Point(48, 216);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(72, 32);
			this.button1.TabIndex = 26;
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.button2.Location = new System.Drawing.Point(184, 216);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(72, 32);
			this.button2.TabIndex = 26;
			this.button2.Text = "取消";
			// 
			// axSuperWorkspace1
			// 
			this.axSuperWorkspace1.Enabled = true;
			this.axSuperWorkspace1.Location = new System.Drawing.Point(256, 144);
			this.axSuperWorkspace1.Name = "axSuperWorkspace1";
			this.axSuperWorkspace1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axSuperWorkspace1.OcxState")));
			this.axSuperWorkspace1.Size = new System.Drawing.Size(32, 32);
			this.axSuperWorkspace1.TabIndex = 27;
			// 
			// ZkSelect
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(330, 272);
			this.Controls.Add(this.axSuperWorkspace1);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.btnDelAll);
			this.Controls.Add(this.btnAddAll);
			this.Controls.Add(this.btnDel);
			this.Controls.Add(this.btnAdd);
			this.Controls.Add(this.lstInput);
			this.Controls.Add(this.lstSource);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.button2);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "ZkSelect";
			this.Text = "ZkSelect";
			this.Load += new System.EventHandler(this.ZkSelect_Load);
			((System.ComponentModel.ISupportInitialize)(this.axSuperWorkspace1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new ZkSelect());
		}
		private void btnAdd_Click(object sender, System.EventArgs e)//增加一个输入属性
		{
			if (lstSource.SelectedItem ==null)
			{
				MessageBox.Show("请选择一个列表项!","提醒");
				return;
			}
			lstInput.Items.Add( lstSource.Text);
			lstSource.Items.Remove( lstSource.Text );
		}

		private void btnAddAll_Click(object sender, System.EventArgs e)
		{
			int i,iLstCount;
			iLstCount = lstSource.Items .Count; 
			for( i = 0;i<=iLstCount-1;i++)
			{
				lstInput.Items.Add(lstSource.Items [0]);
				lstSource.Items.Remove(lstSource.Items [0]);
			}
			
		}

		private void btnDel_Click(object sender, System.EventArgs e)
		{
			if (lstInput.Items.Count<= 0)
			{
				return;
			}
            
			if (lstInput.SelectedItem ==null)
			{
				MessageBox.Show("请选择一个列表项!","提醒");
				return;
			}
			lstSource.Items .Add ( lstInput.Text);
			lstInput.Items.Remove(lstInput.Text);
		}

		private void btnDelAll_Click(object sender, System.EventArgs e)
		{
			int i , iLstCount;
			iLstCount = lstInput.Items.Count;
			for (i = 0 ;i<=iLstCount - 1;i++)
			{
				lstSource.Items.Add(lstInput.Items [0]);
				lstInput.Items.Remove(lstInput.Items [0]);
			}
		}

		private void ZkSelect_Load(object sender, System.EventArgs e)
		{
			SuperMapLib.soFillStyleLib objFill = axSuperWorkspace1.Resources.FillStyleLib;
			objFill.RemoveAll();
			objFill.Import("Gwater.bru",true);
//			MessageBox.Show(this.axSuperWorkspace1.Resources.FillStyleLib.Find("粘土",0).ToString());


			string server,database,password,userid;
			RegistryKey mykey=Registry.LocalMachine.OpenSubKey("Software",true);
			RegistryKey Borekey=mykey.OpenSubKey("WORKFLOW");
			server= (string)Borekey.GetValue("SQLServer_DataSource");
			userid= (string)Borekey.GetValue("SQLServer_UserID");
			password= (string)Borekey.GetValue("SQLServer_Password");
			database=(string)Borekey.GetValue("SQLServer_serverCatalog");
			Borekey.Close();
			//数据库链接字符串
			string con1="Server="+server+";uid="+userid+";pwd="+password+";database="+database;

			SqlConnection con = new SqlConnection(con1);
			con.Open();
			SqlDataAdapter da= new SqlDataAdapter("select tybh from  zkjlb",con);
//			SqlCommandBuilder MyCB = new SqlCommandBuilder(da);
			DataSet ds = new DataSet();
			da.Fill(ds, "zkjlb");
			this.lstInput.Items.Clear();
			this.lstSource.Items.Clear();
			for(int i=0;i<ds.Tables["zkjlb"].Rows.Count;i++)
			{
				this.lstSource.Items.Add(ds.Tables["zkjlb"].Rows[i]["tybh"].ToString().Trim());

			}
            da=null;
			ds=null;
			con.Close();
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			ArrayList arrListZK = new ArrayList();			
			for(int i=0;i<lstInput.Items.Count;i++)
			{	
				arrListZK.Add(lstInput.Items[i].ToString());
			}	
			ProfileCtrl.Profile proflie = new ProfileCtrl.Profile();
			proflie.ShowInTaskbar = false;
			proflie.SuperWorkspace = this.axSuperWorkspace1;
			proflie.WindowState = FormWindowState.Maximized;
			proflie.ArrList = arrListZK;
			proflie.IsSum = true;
			if(proflie.DrawProfile())
			{
				proflie.ShowDialog(this);
			}
			proflie.Dispose();
			this.Dispose();
			this.Close();
		}

	}
}

⌨️ 快捷键说明

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