using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace IfSample
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            decimal salary, actualSalary;
            string name;
            DateTime hireDate;
            decimal taxRate = 0.1M;
            int hireYear, bonus;

            salary = decimal.Parse(txtSalary.Text);
            name = txtName.Text;
            hireDate = DateTime.Parse(txtHireDate.Text);

            //TODO: 1.取出雇用年份
            hireYear = hireDate.Year;

            //TODO: 2.判断应付红利
            if ((hireYear <= 2000) || (salary > 50000))
            {
                bonus = 3000;
            }
            else if ((hireYear <= 2003) && (salary > 30000))
            {
                bonus = 1500;
            }
            else
            {
                bonus = 500;
            }


            //实领薪 = 月薪 - 税额 (月薪 * 税率)
            actualSalary = salary - (salary * taxRate) + bonus;
            txtResult.Text = name + "于" + hireDate +
                    "入职, 本月实际领取薪资为" + actualSalary;
        }
    }
}

