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

📄 customerform.cs

📁 微软系列丛书<<C#2005从入门到精通>>
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CustomerDetails
{
	public partial class CustomerForm : Form
	{
		public CustomerForm()
		{
			InitializeComponent();
		}

		// Cross check the gender and the title to make sure they correspond
		private bool checkTitleAndGender()
		{
			if (title.Text == "Mr")
			{
				// Check that gender is Male
				if (!male.Checked)
				{
					MessageBox.Show("If the title is Mr the gender must be male", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
					return false;
				}
			}
			else
			{
				// Check that the gender is Female
				if (!female.Checked)
				{
					MessageBox.Show("If the title is Mrs, Miss, or Ms the gender must be female", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
					return false;
				}
			}

			// Title and gender match
			return true;
		}



		private void exitClick(object sender, EventArgs e)
		{
			this.Close();
		}

		private void saveClick(object sender, EventArgs e)
		{
			MessageBox.Show("Customer Saved", "Saved");
		}

		private void titleValidating(object sender, CancelEventArgs e)
		{
			if (!checkTitleAndGender())
			{
				e.Cancel = true;
			}
		}

		private void genderValidating(object sender, CancelEventArgs e)
		{
			if (!checkTitleAndGender())
			{
				e.Cancel = true;
			}
		}
	}
}

⌨️ 快捷键说明

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