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

📄 trans_manageform.cs

📁 第三方物流信息管理平台 1、数据库配置: 需要打开MS SQL SERVER 2000企业管理器
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace test007
{
	/// <summary>
	/// trans_manageForm 的摘要说明。
	/// </summary>
	public class trans_manageForm : System.Windows.Forms.Form
	{
		private CurrencyManager cmAmend;
		private DataSet ds = new DataSet();
		private LinkDataBase link = new LinkDataBase();	
		private string sendTableName = "short_pragh_xs";
		private string sendStrSQL = "SELECT 订单编号,最短路径 FROM short_pragh_xs";

		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.ToolBar toolBar1;
		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.ImageList imageList1;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox textBox3;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.ComponentModel.IContainer components;

		public trans_manageForm()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			this.ds = link.SelectDataBase(sendStrSQL,sendTableName);//创建数据库连接
			dataGrid1.DataSource = ds.Tables[0];
		
			cmAmend =( CurrencyManager )BindingContext[ds.Tables[0]];

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

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(trans_manageForm));
			this.label1 = new System.Windows.Forms.Label();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			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.imageList1 = new System.Windows.Forms.ImageList(this.components);
			this.button1 = new System.Windows.Forms.Button();
			this.label3 = new System.Windows.Forms.Label();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.textBox3 = new System.Windows.Forms.TextBox();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(232, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "运输路线列表:";
			// 
			// dataGrid1
			// 
			this.dataGrid1.CaptionVisible = false;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(24, 48);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ReadOnly = true;
			this.dataGrid1.Size = new System.Drawing.Size(584, 184);
			this.dataGrid1.TabIndex = 1;
			// 
			// toolBar1
			// 
			this.toolBar1.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right);
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.toolBarButton1,
																						this.toolBarButton2,
																						this.toolBarButton3,
																						this.toolBarButton4});
			this.toolBar1.ButtonSize = new System.Drawing.Size(50, 30);
			this.toolBar1.Dock = System.Windows.Forms.DockStyle.None;
			this.toolBar1.DropDownArrows = true;
			this.toolBar1.ImageList = this.imageList1;
			this.toolBar1.Location = new System.Drawing.Point(216, 232);
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.ShowToolTips = true;
			this.toolBar1.Size = new System.Drawing.Size(200, 33);
			this.toolBar1.TabIndex = 6;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// toolBarButton1
			// 
			this.toolBarButton1.ImageIndex = 0;
			this.toolBarButton1.ToolTipText = "首记录";
			// 
			// toolBarButton2
			// 
			this.toolBarButton2.ImageIndex = 2;
			this.toolBarButton2.ToolTipText = "上一个记录";
			// 
			// toolBarButton3
			// 
			this.toolBarButton3.ImageIndex = 3;
			this.toolBarButton3.ToolTipText = "下一个记录";
			// 
			// toolBarButton4
			// 
			this.toolBarButton4.ImageIndex = 1;
			this.toolBarButton4.ToolTipText = "末记录";
			// 
			// imageList1
			// 
			this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
			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;
			// 
			// button1
			// 
			this.button1.Image = ((System.Drawing.Bitmap)(resources.GetObject("button1.Image")));
			this.button1.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
			this.button1.Location = new System.Drawing.Point(392, 56);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(112, 32);
			this.button1.TabIndex = 7;
			this.button1.Text = "查询";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(40, 40);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(72, 16);
			this.label3.TabIndex = 8;
			this.label3.Text = "订单编号:";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(168, 40);
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(168, 21);
			this.textBox2.TabIndex = 9;
			this.textBox2.Text = "";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(24, 88);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(120, 16);
			this.label4.TabIndex = 10;
			this.label4.Text = "路径中经过的城市:";
			// 
			// textBox3
			// 
			this.textBox3.Location = new System.Drawing.Point(168, 80);
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(168, 21);
			this.textBox3.TabIndex = 11;
			this.textBox3.Text = "";
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.textBox3,
																					this.textBox2,
																					this.button1,
																					this.label4,
																					this.label3});
			this.groupBox1.Location = new System.Drawing.Point(24, 272);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(584, 136);
			this.groupBox1.TabIndex = 12;
			this.groupBox1.TabStop = false;
			// 
			// trans_manageForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(624, 421);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.groupBox1,
																		  this.toolBar1,
																		  this.dataGrid1,
																		  this.label1});
			this.Name = "trans_manageForm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "运输路线管理";
			this.Load += new System.EventHandler(this.trans_manageForm_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

	
		

		private void trans_manageForm_Load(object sender, System.EventArgs e)
		{
		
		}

		/*private void button2_Click(object sender, System.EventArgs e)
		{
			string order_n=this.textBox1.Text.Trim();
			int order_number=System.Int32.Parse(order_n);

			try  //调用存储过程
			{
				string tempPRD1="exec PRD_VIEW '"+order_number+"'";
				this.link.UpdateDataBase(tempPRD1);
				
			}
			catch
			{ 
				
				MessageBox.Show("错误产生!!!!","提示");
			}
			try  //调用存储过程
			{
				string tempPRD2="exec PRD_update '"+order_number+"'";
				this.link.UpdateDataBase(tempPRD2);
				
			}
			catch
			{ 
				
				MessageBox.Show("错误产生!!!!","提示");
			}
			MessageBox.Show("成功修改该订单的运输状态!!!","提示");
		
		}*/

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if (e.Button.ToolTipText == "首记录")
			{
				this.dataGrid1.UnSelect(cmAmend.Position); //取消选中指定行
				cmAmend.Position = 0;
				this.dataGrid1.Select(cmAmend.Position);       //选中指定行
				this.dataGrid1.CurrentRowIndex = cmAmend.Position; //移动表头指示图标
				return;
			}
			if (e.Button.ToolTipText == "上一个记录")
			{
				if (cmAmend.Position > 0)
				{
					this.dataGrid1.UnSelect(cmAmend.Position); 
					cmAmend.Position--;
					this.dataGrid1.Select(cmAmend.Position);      
					this.dataGrid1.CurrentRowIndex = cmAmend.Position; 
				}
				return;
			}
			if (e.Button.ToolTipText == "下一个记录")
			{
				if (cmAmend.Position < cmAmend.Count-1)
				{
					this.dataGrid1.UnSelect(cmAmend.Position); 
					cmAmend.Position++;
					this.dataGrid1.Select(cmAmend.Position);       
					this.dataGrid1.CurrentRowIndex = cmAmend.Position; 
				}
				return;
			}
			if (e.Button.ToolTipText == "末记录")
			{
				this.dataGrid1.UnSelect(cmAmend.Position); 
				cmAmend.Position = cmAmend.Count-1;
				this.dataGrid1.Select(cmAmend.Position);       
				this.dataGrid1.CurrentRowIndex = cmAmend.Position; 
				return;
			}
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			string strRowFilter = "";
			

			if(this.textBox2.Text.Trim() != "")//设置表的过滤条件
			{
				string order=this.textBox2.Text.Trim();
				int ordernum=System.Int32.Parse(order);
				strRowFilter += "订单编号 = "+ordernum+" and ";
			}
			if(this.textBox3.Text.Trim() != "")
				strRowFilter += "最短路径 like '%" + textBox3.Text.Trim() + "%' and ";
			

			if(strRowFilter != "")    // 存在查询条件
				strRowFilter = strRowFilter.Substring(0,strRowFilter.Length-5);

			ds.Tables[0].DefaultView.RowFilter = strRowFilter;
		}

		
	}
}

⌨️ 快捷键说明

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