参考上贴写了个asp.net的2019个税计算

horizon_zpy 2019-01-27 02:50:55
https://bbs.csdn.net/topics/392504385
参考上贴写了个asp.net的2019个税计算
<%@ Page Language="C#" Debug="true" trace="false" validateRequest="false" EnableViewStateMac="false" EnableEventValidation="false" EnableViewState="true"%>
<%@ import Namespace="System.Collections.Generic"%>
<%@ import Namespace="System.Text"%>
<%@ import Namespace="System.Linq"%>
<%@ import Namespace="System.Text.RegularExpressions"%>

<html>
<head runat="server">
<title>tax2019</title>
<style type="text/css">
.btn{
background-color:transparent;
color:#00FF00;
border:1px solid #00FF00;
font-size:12px;
font-weight:bold;
}
</style>
<script language="c#" runat="server">
string strout;
void Page_Load(object sender, EventArgs e)
{
this.lblthispath.Text ="[Salaray] [BasicLine] [WuXian] [JianMian]";
}
void btnUpload_Click(object sender, EventArgs e)
{
string str=txtPass.Text;
string[] sArray=Regex.Split(str," ",RegexOptions.IgnoreCase);
strout=Main(sArray,"");
result.InnerHtml=strout;

}

static string Main(string[] args,string strout)
{
if(args.Length != 4)
{
strout+=("<br>Please input correct argument with below:");
strout+=("<br>TaxTool.exe [Salaray] [BasicLine] [WuXian] [JianMian]");
}else{
double salary = double.Parse(args[0]);
double basicline = double.Parse(args[1]);
double wuxian = double.Parse(args[2]);
double jianmian = double.Parse(args[3]);

double totalTax = 0;

//double salary = 20000;
//double basicline = 5000;
//double wuxian = 4000;
//double jianmian = 2000;

double Jan = GetTax(1, salary, basicline, wuxian, jianmian);
strout+=("<br>Jan tax is " + Jan);
double Feb = GetTax(2, salary, basicline, wuxian, jianmian);
strout+=("<br>Feb tax is " + Feb);
double March = GetTax(3, salary, basicline, wuxian, jianmian);
strout+=("<br>March tax is " + March);
double April = GetTax(4, salary, basicline, wuxian, jianmian);
strout+=("<br>April tax is " + April);
double May = GetTax(5, salary, basicline, wuxian, jianmian);
strout+=("<br>May tax is " + May);
double June = GetTax(6, salary, basicline, wuxian, jianmian);
strout+=("<br>June tax is " + June);
double July = GetTax(7, salary, basicline, wuxian, jianmian);
strout+=("<br>July tax is " + July);
double August = GetTax(8, salary, basicline, wuxian, jianmian);
strout+=("<br>August tax is " + August);
double September = GetTax(9, salary, basicline, wuxian, jianmian);
strout+=("<br>September tax is " + September);
double Octorber = GetTax(10, salary, basicline, wuxian, jianmian);
strout+=("<br>Octorber tax is " + Octorber);
double November = GetTax(11, salary, basicline, wuxian, jianmian);
strout+=("<br>November tax is " + November);
double December = GetTax(12, salary, basicline, wuxian, jianmian);
strout+=("<br>December tax is " + December);
totalTax = Jan + Feb + March + April + May + June + July + August + September + Octorber + November + December;
strout+=("<br>====================================");
strout+=("<br>Total tax is : " + totalTax);

}
return strout;
}



static double GetTax(int month, double salary, double basicline, double wuxian, double jianmian)
{
double tax = 0;
double history = 0;
if (month == 1)
{
double number1 = GetFirstNumber(month, salary, basicline, wuxian, jianmian);
double rate = GetRate(number1);
double fast = GetFastNumber(number1);

tax = number1 * rate - fast;
}
else
{
double number1 = GetFirstNumber(month, salary, basicline, wuxian, jianmian);
double rate = GetRate(number1);
double fast = GetFastNumber(number1);
int i = 1;
while (i < month)
{
//Response.Write("<br>History is " + history);
history =history + GetTax(i, salary, basicline, wuxian, jianmian);

i++;
}

tax = number1 * rate - fast - history;
}

return tax;
}

static double GetRate(double number)
{
if (number < 36000)
return 0.03;

else if (36000 < number && number < 144000)
return 0.1;

else if (144000 < number && number < 300000)
return 0.2;

else if (300000 < number && number < 420000)
return 0.25;

else if (420000 < number && number < 650000)
return 0.3;

else if (650000 < number && number < 960000)
return 0.35;

else if (960000 < number)
return 0.45;

else return 0.03;
}

static double GetFastNumber(double number)
{
if (number < 36000)
return 0;

else if (36000 < number && number < 144000)
return 2520;

else if (144000 < number && number < 300000)
return 16920;

else if (300000 < number && number < 420000)
return 31920;

else if (420000 < number && number < 650000)
return 52920;

else if (650000 < number && number < 960000)
return 85920;

else if (960000 < number)
return 181920;

else return 0;
}

static double GetFirstNumber(int month, double salary, double basicline, double wuxian, double jianmian)
{
double number = 0;
if (month < 0 || month > 12)
{
// Response.Write("<br>Month must less than 12 and bigger than 0!");
}
else {
number = salary * month - basicline * month - wuxian * month - jianmian * month;
}

return number;
}

</script>

</head>
<body style="font-size:12px;font-weight:bold;color:#00FF00;font-family:Arial, Helvetica, sans-serif;background-color:#000000;">
<form id="form1" runat="server">
<div>
Please input correct argument with below:<asp:Label runat="server" ID="lblthispath" Text=""></asp:Label>
<br />
一共4个参数 分别是税前薪水,计税基准线,五险扣除数,减免额度(六项减免总计)
<br />

<asp:TextBox runat="server" ID="txtPass" Width="400px">20000 5000 4000 2000</asp:TextBox>
<br />
<asp:Button runat="server" ID="btnUpload" text="计算" CssClass="btn" OnClick="btnUpload_Click"/>
<div runat="server" id="result"></div>
</div>
</form>
</body>
</html>




















...全文
451 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
horizon_zpy 2019-01-30
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
原帖就不符合累进 几岁的原则,自然你也没有逃出厄运
马上就是二月了,你自己考察一下你的收入,就可知道问题在哪了!

版主,啥意思啊,啥是累进 几岁的原则?没听懂。。。
threenewbee 2019-01-29
  • 打赏
  • 举报
回复
不管写得对不对,起码是写出来了。
xuzuning 2019-01-29
  • 打赏
  • 举报
回复
原帖就不符合累进 几岁的原则,自然你也没有逃出厄运 马上就是二月了,你自己考察一下你的收入,就可知道问题在哪了!

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧