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

📄 wangshangjiaoyi.cs

📁 主要用C#写的代码
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using DataAccess;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using BusinessRule.Tables;
using BusinessRule.TablesBusines;
using System.Data;
using System.Text;
using BusinessRule.TablesBusiness;
using BusinessRule.Table;



namespace FromZhuJieMian
{
	/// <summary>
	/// WangShangJiaoYi 的摘要说明。
	/// </summary>
	public class WangShangJiaoYi : System.Windows.Forms.Form
	{
		
		TrainBank bank=new TrainBank();
          

		private System.Windows.Forms.Label lblWangShang;
		private System.Windows.Forms.Label lblID;
		private System.Windows.Forms.TextBox txtID;
		private System.Windows.Forms.Label lblPW;
		private System.Windows.Forms.TextBox txtPW;
		private System.Windows.Forms.Button bntOK;
		private System.Windows.Forms.Button bntClose;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Label lblQishizhan;
		private System.Windows.Forms.Label lblstop;
		private System.Windows.Forms.Label lblLeixing;
		private System.Windows.Forms.Label lblprice;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label lblKaicheTime;
		private System.Windows.Forms.Label lblTime;

		//票价
		double price;
		string speed;
		string leavetime;
        string tocity;
        string fromcity;
		private System.Windows.Forms.Label lblChechi;
		private System.Windows.Forms.Button button1;
        string schedulecode;
		public WangShangJiaoYi(double price,string speed,string leavetime,string tocity,string fromcity,string schedulecode )
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
			this.price = price;
			this.speed=speed;
			this.leavetime=leavetime;
			this.tocity=tocity;
			this.fromcity=fromcity;
			this.schedulecode=schedulecode;
		}

		/// <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.lblWangShang = new System.Windows.Forms.Label();
			this.lblID = new System.Windows.Forms.Label();
			this.txtID = new System.Windows.Forms.TextBox();
			this.lblPW = new System.Windows.Forms.Label();
			this.txtPW = new System.Windows.Forms.TextBox();
			this.bntOK = new System.Windows.Forms.Button();
			this.bntClose = new System.Windows.Forms.Button();
			this.panel1 = new System.Windows.Forms.Panel();
			this.panel2 = new System.Windows.Forms.Panel();
			this.lblChechi = new System.Windows.Forms.Label();
			this.lblTime = new System.Windows.Forms.Label();
			this.lblKaicheTime = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.lblprice = new System.Windows.Forms.Label();
			this.lblLeixing = new System.Windows.Forms.Label();
			this.lblstop = new System.Windows.Forms.Label();
			this.lblQishizhan = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.panel1.SuspendLayout();
			this.panel2.SuspendLayout();
			this.SuspendLayout();
			// 
			// lblWangShang
			// 
			this.lblWangShang.Font = new System.Drawing.Font("宋体", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblWangShang.ForeColor = System.Drawing.Color.DarkGreen;
			this.lblWangShang.Location = new System.Drawing.Point(24, 16);
			this.lblWangShang.Name = "lblWangShang";
			this.lblWangShang.Size = new System.Drawing.Size(520, 48);
			this.lblWangShang.TabIndex = 0;
			this.lblWangShang.Text = "欢迎进入北京银行网上交易系统";
			// 
			// lblID
			// 
			this.lblID.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblID.Location = new System.Drawing.Point(224, 88);
			this.lblID.Name = "lblID";
			this.lblID.Size = new System.Drawing.Size(112, 32);
			this.lblID.TabIndex = 1;
			this.lblID.Text = "请输入卡号";
			// 
			// txtID
			// 
			this.txtID.Location = new System.Drawing.Point(104, 136);
			this.txtID.Name = "txtID";
			this.txtID.Size = new System.Drawing.Size(376, 21);
			this.txtID.TabIndex = 1;
			this.txtID.Text = "";
			// 
			// lblPW
			// 
			this.lblPW.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblPW.Location = new System.Drawing.Point(224, 184);
			this.lblPW.Name = "lblPW";
			this.lblPW.Size = new System.Drawing.Size(112, 32);
			this.lblPW.TabIndex = 3;
			this.lblPW.Text = "请输入密码";
			// 
			// txtPW
			// 
			this.txtPW.Location = new System.Drawing.Point(104, 240);
			this.txtPW.Name = "txtPW";
			this.txtPW.PasswordChar = '*';
			this.txtPW.Size = new System.Drawing.Size(376, 21);
			this.txtPW.TabIndex = 2;
			this.txtPW.Text = "";
			// 
			// bntOK
			// 
			this.bntOK.Font = new System.Drawing.Font("宋体", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.bntOK.Location = new System.Drawing.Point(112, 432);
			this.bntOK.Name = "bntOK";
			this.bntOK.Size = new System.Drawing.Size(104, 40);
			this.bntOK.TabIndex = 3;
			this.bntOK.Text = "缴费";
			this.bntOK.Click += new System.EventHandler(this.bntOK_Click);
			// 
			// bntClose
			// 
			this.bntClose.Font = new System.Drawing.Font("宋体", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.bntClose.Location = new System.Drawing.Point(320, 432);
			this.bntClose.Name = "bntClose";
			this.bntClose.Size = new System.Drawing.Size(104, 40);
			this.bntClose.TabIndex = 4;
			this.bntClose.Text = "取消";
			this.bntClose.Click += new System.EventHandler(this.bntClose_Click);
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.lblPW);
			this.panel1.Controls.Add(this.txtPW);
			this.panel1.Controls.Add(this.lblID);
			this.panel1.Controls.Add(this.txtID);
			this.panel1.Controls.Add(this.lblWangShang);
			this.panel1.Location = new System.Drawing.Point(32, 8);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(632, 336);
			this.panel1.TabIndex = 5;
			// 
			// panel2
			// 
			this.panel2.BackColor = System.Drawing.Color.Salmon;
			this.panel2.Controls.Add(this.lblChechi);
			this.panel2.Controls.Add(this.lblTime);
			this.panel2.Controls.Add(this.lblKaicheTime);
			this.panel2.Controls.Add(this.label1);
			this.panel2.Controls.Add(this.lblprice);
			this.panel2.Controls.Add(this.lblLeixing);
			this.panel2.Controls.Add(this.lblstop);
			this.panel2.Controls.Add(this.lblQishizhan);
			this.panel2.ForeColor = System.Drawing.Color.Black;
			this.panel2.Location = new System.Drawing.Point(56, 24);
			this.panel2.Name = "panel2";
			this.panel2.Size = new System.Drawing.Size(584, 392);
			this.panel2.TabIndex = 6;
			this.panel2.Visible = false;
			// 
			// lblChechi
			// 
			this.lblChechi.Font = new System.Drawing.Font("宋体", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblChechi.Location = new System.Drawing.Point(16, 16);
			this.lblChechi.Name = "lblChechi";
			this.lblChechi.Size = new System.Drawing.Size(112, 32);
			this.lblChechi.TabIndex = 7;
			// 
			// lblTime
			// 
			this.lblTime.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblTime.Location = new System.Drawing.Point(168, 184);
			this.lblTime.Name = "lblTime";
			this.lblTime.Size = new System.Drawing.Size(240, 32);
			this.lblTime.TabIndex = 6;
			// 
			// lblKaicheTime
			// 
			this.lblKaicheTime.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblKaicheTime.Location = new System.Drawing.Point(32, 184);
			this.lblKaicheTime.Name = "lblKaicheTime";
			this.lblKaicheTime.Size = new System.Drawing.Size(112, 40);
			this.lblKaicheTime.TabIndex = 5;
			this.lblKaicheTime.Text = "开车时间";
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.Location = new System.Drawing.Point(32, 288);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(136, 32);
			this.label1.TabIndex = 4;
			this.label1.Text = "3日到有效";
			// 
			// lblprice
			// 
			this.lblprice.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblprice.Location = new System.Drawing.Point(448, 80);
			this.lblprice.Name = "lblprice";
			this.lblprice.Size = new System.Drawing.Size(120, 40);
			this.lblprice.TabIndex = 3;
			// 
			// lblLeixing
			// 
			this.lblLeixing.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblLeixing.Location = new System.Drawing.Point(304, 80);
			this.lblLeixing.Name = "lblLeixing";
			this.lblLeixing.Size = new System.Drawing.Size(120, 40);
			this.lblLeixing.TabIndex = 2;
			// 
			// lblstop
			// 
			this.lblstop.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblstop.Location = new System.Drawing.Point(152, 80);
			this.lblstop.Name = "lblstop";
			this.lblstop.Size = new System.Drawing.Size(120, 40);
			this.lblstop.TabIndex = 1;
			// 
			// lblQishizhan
			// 
			this.lblQishizhan.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.lblQishizhan.Location = new System.Drawing.Point(8, 80);
			this.lblQishizhan.Name = "lblQishizhan";
			this.lblQishizhan.Size = new System.Drawing.Size(120, 40);
			this.lblQishizhan.TabIndex = 0;
			// 
			// button1
			// 
			this.button1.Font = new System.Drawing.Font("宋体", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.button1.Location = new System.Drawing.Point(512, 432);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(88, 40);
			this.button1.TabIndex = 7;
			this.button1.Text = "打印";
			// 
			// WangShangJiaoYi
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.Highlight;
			this.ClientSize = new System.Drawing.Size(696, 502);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.panel2);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.bntClose);
			this.Controls.Add(this.bntOK);
			this.Name = "WangShangJiaoYi";
			this.Text = "网上交易";
			this.Load += new System.EventHandler(this.WangShangJiaoYi_Load);
			this.panel1.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
         //卡的详细信息
		BankClass bankclass=new BankClass();
		//卡相对应的详细信息
	     TrainBank trainbank=new TrainBank();
		private void bntOK_Click(object sender, System.EventArgs e)
		{
		      //获得卡号
			string id=this.txtID.Text;
             //判断匹配的字符串对象
			Regex regex=new Regex(@"^\d{6}$");
             //判断是否匹配
			bool wid=regex.IsMatch(this.txtID.Text);
			if(wid!=true)
			{
                 MessageBox.Show("您输入的用户不存在!!!请核实后再重新输入!!!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
				return;
			}
			  //获得密码
			string pw=this.txtPW.Text;
			//判断匹配的字符串对象
			Regex r=new Regex(@"^\d{6}$");
			//判断是否匹配
			bool b = r.IsMatch(this.txtPW.Text);
			//添加提示框
			if(b!=true)
			{
				MessageBox.Show("您输入的密码不正确!!!请重新输入。。。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
				return;
			}
			
			//封装
			bankclass.Bnakid=id;
			bankclass.Bankpw=pw;
			//打开数据库连接
			//MyConn.Conn.Open();
			//银行卡对应的业务逻辑层
			int returnNum = trainbank.LoginTorF( bankclass );
			//获得用户卡上的余额
			TrainBank bank=new TrainBank();
			double money=bank.JiaoYiMingXi(id);
		
			//判断
			if(returnNum==0)
			{
                MessageBox.Show("您输入的用户不存在!请核实后重新输入!!!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
				return;
			}
			
            DialogResult d = MessageBox.Show("您确定要交易吗?您的卡上余额为:"+money,"提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
		
			//确认交易
			if(d == DialogResult.Yes)
			{
				//TrainBank bank=new TrainBank();
			    //double money=bank.JiaoYiMingXi(id);
				double moneyYue=money-price;
				if(moneyYue>0)
				{
					//MessageBox.Show("可以交易!!!!");
					int num=bank.JiaoYi(price,id);
					if(num==1)
					{
						
						//获得起始站添加到lab中
						this.lblQishizhan.Text=fromcity;
						//获得终点站添加到lab中
						this.lblstop.Text=tocity;
						//获得火车类型添加到lab中
						this.lblLeixing.Text=speed;
						//获得票价添加到lab中
						this.lblprice.Text=Convert.ToString(price);
						//获得车次添加到lab中
						this.lblChechi.Text=schedulecode;
						//获得开车时间添加到lab中
						this.lblTime.Text=leavetime;
					}
					if(d==DialogResult.No)
					{
						MessageBox.Show("谢谢使用!本次业务办理失败!!!");
					}
					//显示panel2传过来的内容
					this.panel2.Visible=true;

				}
				else
				{
					MessageBox.Show("您的卡上余额不足!!!本次业务办理失败!!!");
					
				}

            }
			
//           this.panel2.Visible=true;
			
	}

		private void bntClose_Click(object sender, System.EventArgs e)
		{
			//返回上一个界面
			this.Hide();
			this.Visible=false;
			Form1 f=new Form1();
			f.Show();
		}

		private void WangShangJiaoYi_Load(object sender, System.EventArgs e)
		{
		    //隐藏panel2控件
			this.panel2.Visible=false;
		}

		

		
	}
}

⌨️ 快捷键说明

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