实现个人所得税计算的迷你程序,使用VS.NET及.NET框架精简版,您将体验到使用微软.NET架构的开发比之BREW与J2ME,可以说是一种享受。
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
namespace SmartDeviceApplication个人所得税
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.MainMenu mainMenu2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MainMenu mainMenu1;
public Form1()
{
//
// 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 )
{
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.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.textBox1 = new System.Windows.Forms.TextBox();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.mainMenu2 = new System.Windows.Forms.MainMenu();
this.menuItem3 = new System.Windows.Forms.MenuItem();
//
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menuItem1);
this.mainMenu1.MenuItems.Add(this.menuItem2);
//
// menuItem1
//
this.menuItem1.Text = "退出";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// menuItem2
//
this.menuItem2.Text = "计算";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(16, 32);
this.textBox1.Size = new System.Drawing.Size(128, 25);
this.textBox1.Text = "textBox1";
//
// comboBox1
//
this.comboBox1.Items.Add("北京");
this.comboBox1.Items.Add("上海");
this.comboBox1.Items.Add("深圳");
this.comboBox1.Items.Add("其他地区");
this.comboBox1.Location = new System.Drawing.Point(16, 96);
this.comboBox1.Size = new System.Drawing.Size(128, 26);
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 8);
this.label1.Size = new System.Drawing.Size(104, 22);
this.label1.Text = "您的收入";
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 72);
this.label2.Size = new System.Drawing.Size(96, 22);
this.label2.Text = "您所在的地区";
//
// panel1
//
this.panel1.Controls.Add(this.label3);
this.panel1.Location = new System.Drawing.Point(24, 40);
this.panel1.Size = new System.Drawing.Size(112, 112);
this.panel1.Visible = false;
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 24);
this.label3.Size = new System.Drawing.Size(80, 80);
this.label3.Text = "label3";
this.label3.Visible = false;
//
// mainMenu2
//
this.mainMenu2.MenuItems.Add(this.menuItem3);
//
// menuItem3
//
this.menuItem3.Text = "确定";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// Form1
//
this.BackColor = System.Drawing.Color.Gainsboro;
this.ClientSize = new System.Drawing.Size(170, 183);
this.Controls.Add(this.panel1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.textBox1);
this.Menu = this.mainMenu1;
this.Text = "个人所得税计算";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
private void menuItem1_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
cal();
this.Menu = this.mainMenu2;
}
private void cal()
{
try
{
float v1=800;
if(this.comboBox1.SelectedIndex==0)
{
v1=1000;
}
if(this.comboBox1.SelectedIndex==1)
{
v1=1000;
}
if(this.comboBox1.SelectedIndex==2)
{
v1=1600;
}
float v2=float.Parse(this.textBox1.Text.Trim());
if(float.IsNaN(v2))
{
alert("输入的工资、薪金不正确");
return ;
}
float v3=v2-v1;
float result=0;
if(v3<=0)
{
result=0;
alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
if(v3<=500)
{
result=v3*0.05f;alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
if(v3<=2000)
{
result=v3*0.1f-25;alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
if(v3<=5000)
{
result=v3*0.15f-125;alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
if(v3<=20000)
{
result=v3*0.2f-375;alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
if(v3<=40000)
{
result=v3*0.25f-1375;alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
if(v3<=60000)
{
result=v3*0.3f-3375;alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
if(v3<=80000)
{
result=v3*0.35f-6375;alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
if(v3<=100000)
{
result=v3*0.4f-10375;alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
result=v3*0.45f-15375;alert("您需要缴纳个人所得税:"+result.ToString()+"元");
return;
}
catch
{
alert("输入的工资、薪金不正确");return;
}
}
private void alert(string str)
{
this.label3.Text=str;
this.panel1.Visible =true;
this.label3.Visible=true;
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
this.panel1.Visible=false;
this.label3.Visible=false;
this.Menu = this.mainMenu1;
}
}
}