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

📄 frmtrain.cs

📁 列车时刻查询Visual Studio 2005 + sql2005
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.lblym.Location = new System.Drawing.Point(240, 144);
			this.lblym.Name = "lblym";
			this.lblym.Size = new System.Drawing.Size(24, 24);
			this.lblym.TabIndex = 14;
			this.lblym.Tag = "玉门";
			this.lblym.Click += new System.EventHandler(this.lblwlmq_Click);
			// 
			// lblgel
			// 
			this.lblgel.BackColor = System.Drawing.Color.Transparent;
			this.lblgel.Location = new System.Drawing.Point(208, 192);
			this.lblgel.Name = "lblgel";
			this.lblgel.Size = new System.Drawing.Size(24, 24);
			this.lblgel.TabIndex = 13;
			this.lblgel.Tag = "格尔木";
			this.lblgel.Click += new System.EventHandler(this.lblwlmq_Click);
			// 
			// lblhm
			// 
			this.lblhm.BackColor = System.Drawing.Color.Transparent;
			this.lblhm.Location = new System.Drawing.Point(208, 112);
			this.lblhm.Name = "lblhm";
			this.lblhm.Size = new System.Drawing.Size(24, 24);
			this.lblhm.TabIndex = 12;
			this.lblhm.Tag = "哈密";
			this.lblhm.Click += new System.EventHandler(this.lblwlmq_Click);
			// 
			// lblwlmq
			// 
			this.lblwlmq.BackColor = System.Drawing.Color.Transparent;
			this.lblwlmq.Location = new System.Drawing.Point(160, 96);
			this.lblwlmq.Name = "lblwlmq";
			this.lblwlmq.Size = new System.Drawing.Size(24, 24);
			this.lblwlmq.TabIndex = 11;
			this.lblwlmq.Tag = "乌鲁木齐";
			this.lblwlmq.Click += new System.EventHandler(this.lblwlmq_Click);
			// 
			// tabtrainresult
			// 
			this.tabtrainresult.Controls.Add(this.dgtrainresult);
			this.tabtrainresult.Location = new System.Drawing.Point(4, 21);
			this.tabtrainresult.Name = "tabtrainresult";
			this.tabtrainresult.Size = new System.Drawing.Size(720, 391);
			this.tabtrainresult.TabIndex = 1;
			this.tabtrainresult.Text = "查询结果";
			// 
			// dgtrainresult
			// 
			this.dgtrainresult.DataMember = "";
			this.dgtrainresult.Dock = System.Windows.Forms.DockStyle.Fill;
			this.dgtrainresult.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgtrainresult.Location = new System.Drawing.Point(0, 0);
			this.dgtrainresult.Name = "dgtrainresult";
			this.dgtrainresult.ReadOnly = true;
			this.dgtrainresult.Size = new System.Drawing.Size(720, 391);
			this.dgtrainresult.TabIndex = 0;
			this.dgtrainresult.Click += new System.EventHandler(this.dgtrainresult_Click);
			this.dgtrainresult.CurrentCellChanged += new System.EventHandler(this.dgtrainresult_Click);
			// 
			// tabtraindetails
			// 
			this.tabtraindetails.Controls.Add(this.dgtraindetails);
			this.tabtraindetails.Location = new System.Drawing.Point(4, 21);
			this.tabtraindetails.Name = "tabtraindetails";
			this.tabtraindetails.Size = new System.Drawing.Size(720, 391);
			this.tabtraindetails.TabIndex = 2;
			this.tabtraindetails.Text = "车次详细信息";
			// 
			// dgtraindetails
			// 
			this.dgtraindetails.DataMember = "";
			this.dgtraindetails.Dock = System.Windows.Forms.DockStyle.Fill;
			this.dgtraindetails.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dgtraindetails.Location = new System.Drawing.Point(0, 0);
			this.dgtraindetails.Name = "dgtraindetails";
			this.dgtraindetails.ReadOnly = true;
			this.dgtraindetails.Size = new System.Drawing.Size(720, 391);
			this.dgtraindetails.TabIndex = 0;
			// 
			// btnprint
			// 
			this.btnprint.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnprint.Location = new System.Drawing.Point(464, 72);
			this.btnprint.Name = "btnprint";
			this.btnprint.TabIndex = 11;
			this.btnprint.Text = "打印";
			this.btnprint.Visible = false;
			this.btnprint.Click += new System.EventHandler(this.btnprint_Click);
			// 
			// btnexport
			// 
			this.btnexport.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnexport.Location = new System.Drawing.Point(552, 8);
			this.btnexport.Name = "btnexport";
			this.btnexport.TabIndex = 12;
			this.btnexport.Text = "导出为文本";
			this.btnexport.Visible = false;
			this.btnexport.Click += new System.EventHandler(this.btnexport_Click);
			// 
			// btnexportxml
			// 
			this.btnexportxml.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnexportxml.Location = new System.Drawing.Point(552, 40);
			this.btnexportxml.Name = "btnexportxml";
			this.btnexportxml.TabIndex = 13;
			this.btnexportxml.Text = "导出为XML";
			this.btnexportxml.Visible = false;
			this.btnexportxml.Click += new System.EventHandler(this.btnexportxml_Click);
			// 
			// btnImportData
			// 
			this.btnImportData.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnImportData.Location = new System.Drawing.Point(464, 8);
			this.btnImportData.Name = "btnImportData";
			this.btnImportData.TabIndex = 14;
			this.btnImportData.Text = "导入XML";
			this.btnImportData.Click += new System.EventHandler(this.btnImportData_Click);
			// 
			// frmMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(630, 508);
			this.Controls.Add(this.btnImportData);
			this.Controls.Add(this.btnexportxml);
			this.Controls.Add(this.btnexport);
			this.Controls.Add(this.btnprint);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.btnquery2);
			this.Controls.Add(this.btnquery1);
			this.Controls.Add(this.lbltrainnum);
			this.Controls.Add(this.txttrainnum);
			this.Controls.Add(this.cboMdiStation);
			this.Controls.Add(this.txtfinalstation);
			this.Controls.Add(this.txtbeginstation);
			this.Controls.Add(this.lblfinalstation);
			this.Controls.Add(this.lblmidstation);
			this.Controls.Add(this.lblbeginstation);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.Name = "frmMain";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "列车时刻查询";
			this.panel1.ResumeLayout(false);
			this.tabdisplay.ResumeLayout(false);
			this.tabmap.ResumeLayout(false);
			this.tabtrainresult.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dgtrainresult)).EndInit();
			this.tabtraindetails.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dgtraindetails)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmMain());
		}

		/// <summary>
		/// 设置站点名称
		/// </summary>
		/// <param name="station">站点的名称</param>
		public void setstation(string station)
		{
			if(txtbeginstation.Focused)
			{
				txtbeginstation.Text=station;
				return;
			}
			if(txtfinalstation.Focused)
			{
				txtfinalstation.Text=station;
				return;
			}
		}
		//点击标签根据当前控件的tag,添入适当的起点终点站
		private void lblwlmq_Click(object sender, System.EventArgs e)
		{
			Control control=(Control)sender;
			setstation(control.Tag.ToString());
		}	

		//根据起点站、终点站查询列车信息
		private void btnquery1_Click(object sender, System.EventArgs e)
		{	
			schedulesystem.GetScheduleList(txtbeginstation.Text,txtfinalstation.Text);
		}
		
		//单击DataGrid得到列车的详细信息
		private void dgtrainresult_Click(object sender, System.EventArgs e)
		{
			if(dgtrainresult.DataSource!=null)
			{
				schedulesystem.GetMidScheduleList(dgtrainresult[dgtrainresult.CurrentRowIndex,0].ToString());
			}
		}
		//根据列车车次查询列车信息
		private void btnquery2_Click(object sender, System.EventArgs e)
		{
			schedulesystem.GetScheduleByCode(txttrainnum.Text);
		}
		//打印按扭的显示与隐藏
		private void tabdisplay_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			schedulesystem.showprintbutton();
		}
		//打印
		private void btnprint_Click(object sender, System.EventArgs e)
		{
			if(this.tabdisplay.SelectedIndex==1)
			{
				printer=new DataGridPrinter(this.schedulesystem.schedule.GetTableResult());
			}
			if(this.tabdisplay.SelectedIndex==2)
			{
				printer=new DataGridPrinter(this.schedulesystem.schedule.GetTableDetails());
			}
			try
			{
				printer.Print();
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}

		private void txtbeginstation_Enter(object sender, System.EventArgs e)
		{
			cboMdiStation.DataSource=null;
			txttrainnum.Text="";
		}

		private void cboMdiStation_SelectionChangeCommitted(object sender, System.EventArgs e)
		{
			schedulesystem.GetMidStation(txtbeginstation.Text,cboMdiStation.SelectedText,txtfinalstation.Text);
		}

		private void txttrainnum_Enter(object sender, System.EventArgs e)
		{
			this.dgtraindetails.DataSource=null;
			cboMdiStation.DataSource=null;
			txtbeginstation.Text="";
			txtfinalstation.Text="";
		}

		private void btnexport_Click(object sender, System.EventArgs e)
		{
			if(this.tabdisplay.SelectedIndex==1)
			{
				if(export.Export(this.schedulesystem.schedule.GetTableResult()))
				{
					MessageBox.Show(this,"导出文本文件成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
				}
				else
				{
					MessageBox.Show(this,"用户取消操作","失败",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
			}
			if(this.tabdisplay.SelectedIndex==2)
			{
				if(export.Export(this.schedulesystem.schedule.GetTableDetails()))
				{
					MessageBox.Show(this,"导出文本文件成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
				}
				else
				{
					MessageBox.Show(this,"用户取消操作!","失败",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
			}
		}

		private void btnexportxml_Click(object sender, System.EventArgs e)
		{
			if(this.tabdisplay.SelectedIndex==1)
			{
				if(export.exportXml(this.schedulesystem.schedule.GetTableResult()))
				{
					MessageBox.Show(this,"导出XML文件成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
				}
				else
				{
					MessageBox.Show(this,"用户取消操作","失败",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
			}
			if(this.tabdisplay.SelectedIndex==2)
			{
				if(export.exportXml(this.schedulesystem.schedule.GetTableDetails()))
				{
					MessageBox.Show(this,"导出XML文件成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
				}
				else
				{
					MessageBox.Show(this,"用户取消操作!","失败",MessageBoxButtons.OK,MessageBoxIcon.Error);
				}
			}
		}

		private void btnImportData_Click(object sender, System.EventArgs e)
		{
			if(schedulesystem.ImportData())
			{
				MessageBox.Show(this,"导入成功!","成功",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
			}
			else
			{
				MessageBox.Show(this,"用户取消操作!","失败",MessageBoxButtons.OK,MessageBoxIcon.Error);
			}
		}
	}
}

⌨️ 快捷键说明

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