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

📄 frmtransferfunds.cs

📁 北大青鸟内部资料
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace Example_1
{
	/// <summary>
	/// Summary description for frmTransferFunds.
	/// </summary>
	public class frmTransferFunds : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lblFromAccount;
		private System.Windows.Forms.Label lblToAccount;
		private System.Windows.Forms.Label lblCity;
		private System.Windows.Forms.Label lblAmount;
		private System.Windows.Forms.ComboBox cboCity;
		private System.Windows.Forms.TextBox txtToAccount;
		private System.Windows.Forms.TextBox txtAmount;
		private System.Windows.Forms.ComboBox cboFromAccount;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Button btnContinue;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmTransferFunds()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.lblFromAccount = new System.Windows.Forms.Label();
			this.lblToAccount = new System.Windows.Forms.Label();
			this.lblCity = new System.Windows.Forms.Label();
			this.lblAmount = new System.Windows.Forms.Label();
			this.cboCity = new System.Windows.Forms.ComboBox();
			this.txtToAccount = new System.Windows.Forms.TextBox();
			this.txtAmount = new System.Windows.Forms.TextBox();
			this.btnCancel = new System.Windows.Forms.Button();
			this.btnContinue = new System.Windows.Forms.Button();
			this.cboFromAccount = new System.Windows.Forms.ComboBox();
			this.SuspendLayout();
			// 
			// lblFromAccount
			// 
			this.lblFromAccount.Location = new System.Drawing.Point(8, 15);
			this.lblFromAccount.Name = "lblFromAccount";
			this.lblFromAccount.Size = new System.Drawing.Size(80, 23);
			this.lblFromAccount.TabIndex = 0;
			this.lblFromAccount.Text = "起始帐户:";
			// 
			// lblToAccount
			// 
			this.lblToAccount.Location = new System.Drawing.Point(8, 47);
			this.lblToAccount.Name = "lblToAccount";
			this.lblToAccount.Size = new System.Drawing.Size(72, 23);
			this.lblToAccount.TabIndex = 1;
			this.lblToAccount.Text = "目标帐户:";
			// 
			// lblCity
			// 
			this.lblCity.Location = new System.Drawing.Point(8, 79);
			this.lblCity.Name = "lblCity";
			this.lblCity.Size = new System.Drawing.Size(64, 23);
			this.lblCity.TabIndex = 2;
			this.lblCity.Text = "城市:";
			// 
			// lblAmount
			// 
			this.lblAmount.Location = new System.Drawing.Point(8, 119);
			this.lblAmount.Name = "lblAmount";
			this.lblAmount.Size = new System.Drawing.Size(72, 23);
			this.lblAmount.TabIndex = 3;
			this.lblAmount.Text = "金额 ($)";
			// 
			// cboCity
			// 
			this.cboCity.Location = new System.Drawing.Point(111, 80);
			this.cboCity.Name = "cboCity";
			this.cboCity.TabIndex = 2;
			this.cboCity.Text = "...请选择一项.....";
			this.cboCity.Leave += new System.EventHandler(this.cboCity_Leave);
			// 
			// txtToAccount
			// 
			this.txtToAccount.Location = new System.Drawing.Point(112, 48);
			this.txtToAccount.MaxLength = 8;
			this.txtToAccount.Name = "txtToAccount";
			this.txtToAccount.Size = new System.Drawing.Size(120, 21);
			this.txtToAccount.TabIndex = 1;
			this.txtToAccount.Text = "";
			this.txtToAccount.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtToAccount_KeyPress);
			this.txtToAccount.Leave += new System.EventHandler(this.txtToAccount_Leave);
			// 
			// txtAmount
			// 
			this.txtAmount.Location = new System.Drawing.Point(112, 120);
			this.txtAmount.Name = "txtAmount";
			this.txtAmount.Size = new System.Drawing.Size(120, 21);
			this.txtAmount.TabIndex = 3;
			this.txtAmount.Text = "0";
			this.txtAmount.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtAmount_KeyPress);
			this.txtAmount.Leave += new System.EventHandler(this.txtAmount_Leave);
			// 
			// btnCancel
			// 
			this.btnCancel.Location = new System.Drawing.Point(160, 152);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 8;
			this.btnCancel.Text = "取消(&C)";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// btnContinue
			// 
			this.btnContinue.Enabled = false;
			this.btnContinue.Location = new System.Drawing.Point(80, 152);
			this.btnContinue.Name = "btnContinue";
			this.btnContinue.TabIndex = 7;
			this.btnContinue.Text = "继续(&O)";
			this.btnContinue.Click += new System.EventHandler(this.btnContinue_Click);
			// 
			// cboFromAccount
			// 
			this.cboFromAccount.Items.AddRange(new object[] {
																"54678908"});
			this.cboFromAccount.Location = new System.Drawing.Point(111, 16);
			this.cboFromAccount.Name = "cboFromAccount";
			this.cboFromAccount.TabIndex = 0;
			this.cboFromAccount.Text = "...请选择一项.....";
			this.cboFromAccount.Leave += new System.EventHandler(this.cboFromAccount_Leave);
			// 
			// frmTransferFunds
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
			this.ClientSize = new System.Drawing.Size(256, 189);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.txtToAccount);
			this.Controls.Add(this.lblAmount);
			this.Controls.Add(this.lblCity);
			this.Controls.Add(this.lblToAccount);
			this.Controls.Add(this.lblFromAccount);
			this.Controls.Add(this.cboCity);
			this.Controls.Add(this.txtAmount);
			this.Controls.Add(this.btnContinue);
			this.Controls.Add(this.cboFromAccount);
			this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Name = "frmTransferFunds";
			this.Text = "转帐";
			this.ResumeLayout(false);

		}
		#endregion

		private void txtToAccount_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			//Accepts only 0-9 and backspace 
			e.Handled = e.KeyChar < '0' || e.KeyChar > '9'; 
			if(e.KeyChar == (char)8)
				e.Handled=false;
		}

		
		private void cboFromAccount_Leave(object sender, System.EventArgs e)
		{
			if(this.cboFromAccount.SelectedIndex == -1)
			{
				MessageBox.Show("Select the account","Select");
				this.cboFromAccount.Focus();
			}
			
		}

		private void txtToAccount_Leave(object sender, System.EventArgs e)
		{
			int count = this.txtToAccount.Text.Length;
			if(count < 8)
			{
				MessageBox.Show("帐号的长度应该为 8 个字符","帐号");
				this.txtToAccount.Focus();
			}
			else
			{
				this.cboCity.Items.Clear();
				string[] cities = {"NewYork","California","Chicago","Washington"};
				for(int ctr = 0; ctr < cities.Length;ctr++)
				{
					this.cboCity.Items.Add(cities[ctr]);
				}
			}
			
		}

		private void txtAmount_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			//Accepts only 0-9 and backspace 
			e.Handled = e.KeyChar < '0' || e.KeyChar > '9'; 
			if(e.KeyChar == (char)8)
				e.Handled=false;
		}

		private void txtAmount_Leave(object sender, System.EventArgs e)
		{
			if(Convert.ToInt32(this.txtAmount.Text) < 1)
			{
				MessageBox.Show("金额值应该大于 0","金额");
				this.txtAmount.Text="0";
				this.txtAmount.Focus();
			}
			else
			{
				this.btnContinue.Enabled=true;

			}
		}

		private void cboCity_Leave(object sender, System.EventArgs e)
		{
			if(this.cboCity.SelectedIndex == -1)
			{
				MessageBox.Show("您还未选择城市","请选择城市");
				this.cboCity.Focus();
			}
		}

		private void btnContinue_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show("已将 "+this.txtAmount.Text+"$ 从帐户 "+this.cboFromAccount.SelectedItem+" 转入帐户 "+this.txtToAccount.Text,"转帐详情");
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}
	}
}

⌨️ 快捷键说明

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