今天终于弄完了税率问题,成功的进行了一次测试~~~~~
昨晚没白通宵!
虽说今天早上还是错误中,但回宿舍睡了一觉后,改了几个地方竟没问题啦。
昨晚写了半夜的代码~~~~~~~挺好玩了~~~~~~
尤其是在早上,由于一个错误,工资是1000元,扣完税后能领2300多呢~~~~~~
传入用户名和流水账号,算出:本月是否领过金额,本月累计收入,上次领过金额,本次应发金额;
public DataTable GetRateTable(string username, string account)
{
string fstime = sdh.dbExecuteSql4Values("SELECT [FSTime] FROM [TFM].[dbo].[Feedback] where [account]='" + account + "'") + sdh.dbExecuteSql4Values("SELECT [FSTime] FROM [TFM].[dbo].[FeedbackW] where [account]='" + account + "'");
DataTable dtLaccount = sdh.dbODSGetDataTable("SELECT [account] FROM [TFM].[dbo].[Feedback] where [FSTime] ='" + fstime + "' and ([isback] = 1 or [isback] = 5)");
DataTable dtWaccount = sdh.dbODSGetDataTable("SELECT [account] FROM [TFM].[dbo].[FeedbackW] where [FSTime] ='" + fstime + "' and ([isback] = 1 or [isback] = 5)");
double wagebase = 2000;
double ltatol1 = 0;
double ltatol5 = 0;
double wtatol1 = 0;
double wtatol5 = 0;
string isReceive = "否";
for (int i = 0; i < dtLaccount.Rows.Count; i++)
{
string laccount = dtLaccount.Rows[i][0].ToString();
string dtl5 = sdh.dbExecuteSql4Values("SELECT dbo.Labor.UserName FROM dbo.Feedback INNER JOIN dbo.Labor ON dbo.Feedback.account = dbo.Labor.account where dbo.Feedback.account='" + laccount + "' and [isback] = 5 and [username] = '" + username + "'");
if (dtl5 == "")
{
string lamount = sdh.dbExecuteSql4Values("SELECT dbo.Labor.Amount FROM dbo.Feedback INNER JOIN dbo.Labor ON dbo.Feedback.account = dbo.Labor.account where [UserName] = '" + username + "' and dbo.Feedback.account = '" + laccount + "' and [isback] = 1");
if (lamount == "")
{
}
else
{
ltatol1 = ltatol1 + Convert.ToDouble(lamount);
}
}
else
{
isReceive = "是";
string lamount5 = sdh.dbExecuteSql4Values("SELECT dbo.Labor.Amount FROM dbo.Feedback INNER JOIN dbo.Labor ON dbo.Feedback.account = dbo.Labor.account where [UserName] = '" + username + "' and dbo.Labor.account = '" + laccount + "' and [isback] = 5");
if (lamount5 == "")
{
}
else
{
ltatol5 = ltatol5 + Convert.ToDouble(lamount5);
}
}
}
for (int j = 0; j < dtWaccount.Rows.Count; j++)
{
string waccount = dtWaccount.Rows[j][0].ToString();
string dtw5 = sdh.dbExecuteSql4Values("SELECT dbo.Wage.UserName FROM dbo.FeedbackW INNER JOIN dbo.Wage ON dbo.FeedbackW.account = dbo.Wage.account where dbo.Wage.account ='" + waccount + "' and [isback] = 5 and [username] = '" + username + "'");
if (dtw5 == "")
{
string wamount = sdh.dbExecuteSql4Values("SELECT dbo.Wage.shifaheji FROM dbo.FeedbackW INNER JOIN dbo.Wage ON dbo.FeedbackW.account = dbo.Wage.account where [UserName]='" + username + "' and dbo.Wage.account ='" + waccount + "' and [isback] = 1");
if (wamount == "")
{
}
else
{
wtatol1 = wtatol1 + Convert.ToDouble(wamount);
}
}
else
{
isReceive = "是";
string wamount = sdh.dbExecuteSql4Values("SELECT dbo.Wage.shifaheji FROM dbo.FeedbackW INNER JOIN dbo.Wage ON dbo.FeedbackW.account = dbo.Wage.account where [UserName]='" + username + "' and dbo.Wage.account ='" + waccount + "' and [isback] = 5");
if (wamount == "")
{
}
else
{
wtatol5 = wtatol5 + Convert.ToDouble(wamount);
}
}
}
double tatol1 = ltatol1 + wtatol1;
double tatol5 = ltatol5 + wtatol5;
double tatol = tatol1 + tatol5;
double amountt = 0;
double amount5 = 0;
if (tatol - wagebase > 100000)
{ amountt = tatol - (tatol - wagebase) * 0.45 + 15375; }
else if (tatol - wagebase > 80000 && tatol - wagebase <= 100000)
{ amountt = tatol - (tatol - wagebase) * 0.40 + 10375; }
else if (tatol - wagebase > 60000 && tatol - wagebase <= 80000)
{ amountt = tatol - (tatol - wagebase) * 0.35 + 6375; }
else if (tatol - wagebase > 40000 && tatol - wagebase <= 60000)
{ amountt = tatol - (tatol - wagebase) * 0.30 + 3375; }
else if (tatol - wagebase > 20000 && tatol - wagebase <= 40000)
{ amountt = tatol - (tatol - wagebase) * 0.25 + 1375; }
else if (tatol - wagebase > 5000 && tatol - wagebase <= 20000)
{ amountt = tatol - (tatol - wagebase) * 0.20 + 375; }
else if (tatol - wagebase > 2000 && tatol - wagebase < 5000)
{ amountt = tatol - (tatol - wagebase) * 0.15 + 125; }
else if (tatol - wagebase > 500 && tatol - wagebase <= 2000)
{ amountt = tatol - (tatol - wagebase) * 0.10 + 25; }
else if (tatol - wagebase > 0 && tatol - wagebase <= 500)
{ amountt = tatol - (tatol - wagebase) * 0.05; }
else
{ amountt = tatol; }
if (tatol5 - wagebase > 100000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.45 + 15375; }
else if (tatol5 - wagebase > 80000 && tatol5 - wagebase <= 100000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.40 + 10375; }
else if (tatol - wagebase > 60000 && tatol5 - wagebase <= 80000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.35 + 6375; }
else if (tatol5 - wagebase > 40000 && tatol5 - wagebase <= 60000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.30 + 3375; }
else if (tatol5 - wagebase > 20000 && tatol5 - wagebase <= 40000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.25 + 1375; }
else if (tatol5 - wagebase > 5000 && tatol5 - wagebase <= 20000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.20 + 375; }
else if (tatol5 - wagebase > 2000 && tatol5 - wagebase < 5000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.15 + 125; }
else if (tatol5 - wagebase > 500 && tatol5 - wagebase <= 2000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.10 + 25; }
else if (tatol5 - wagebase > 0 && tatol5 - wagebase <= 500)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.05; }
else
{ amount5 = tatol5; }
double amount = amountt - amount5;
DataTable dt = new DataTable();
dt.Columns.Add("本月是否领过金额");
dt.Columns.Add("本月累计收入");
dt.Columns.Add("上次领过金额");
dt.Columns.Add("本次应发金额");
DataRow row = dt.NewRow();
row["本月是否领过金额"] = isReceive;
row["本月累计收入"] = tatol.ToString();
row["上次领过金额"] = amount5.ToString();
row["本次应发金额"] = amount.ToString();
dt.Rows.Add(row);
return dt;
}
{
string fstime = sdh.dbExecuteSql4Values("SELECT [FSTime] FROM [TFM].[dbo].[Feedback] where [account]='" + account + "'") + sdh.dbExecuteSql4Values("SELECT [FSTime] FROM [TFM].[dbo].[FeedbackW] where [account]='" + account + "'");
DataTable dtLaccount = sdh.dbODSGetDataTable("SELECT [account] FROM [TFM].[dbo].[Feedback] where [FSTime] ='" + fstime + "' and ([isback] = 1 or [isback] = 5)");
DataTable dtWaccount = sdh.dbODSGetDataTable("SELECT [account] FROM [TFM].[dbo].[FeedbackW] where [FSTime] ='" + fstime + "' and ([isback] = 1 or [isback] = 5)");
double wagebase = 2000;
double ltatol1 = 0;
double ltatol5 = 0;
double wtatol1 = 0;
double wtatol5 = 0;
string isReceive = "否";
for (int i = 0; i < dtLaccount.Rows.Count; i++)
{
string laccount = dtLaccount.Rows[i][0].ToString();
string dtl5 = sdh.dbExecuteSql4Values("SELECT dbo.Labor.UserName FROM dbo.Feedback INNER JOIN dbo.Labor ON dbo.Feedback.account = dbo.Labor.account where dbo.Feedback.account='" + laccount + "' and [isback] = 5 and [username] = '" + username + "'");
if (dtl5 == "")
{
string lamount = sdh.dbExecuteSql4Values("SELECT dbo.Labor.Amount FROM dbo.Feedback INNER JOIN dbo.Labor ON dbo.Feedback.account = dbo.Labor.account where [UserName] = '" + username + "' and dbo.Feedback.account = '" + laccount + "' and [isback] = 1");
if (lamount == "")
{
}
else
{
ltatol1 = ltatol1 + Convert.ToDouble(lamount);
}
}
else
{
isReceive = "是";
string lamount5 = sdh.dbExecuteSql4Values("SELECT dbo.Labor.Amount FROM dbo.Feedback INNER JOIN dbo.Labor ON dbo.Feedback.account = dbo.Labor.account where [UserName] = '" + username + "' and dbo.Labor.account = '" + laccount + "' and [isback] = 5");
if (lamount5 == "")
{
}
else
{
ltatol5 = ltatol5 + Convert.ToDouble(lamount5);
}
}
}
for (int j = 0; j < dtWaccount.Rows.Count; j++)
{
string waccount = dtWaccount.Rows[j][0].ToString();
string dtw5 = sdh.dbExecuteSql4Values("SELECT dbo.Wage.UserName FROM dbo.FeedbackW INNER JOIN dbo.Wage ON dbo.FeedbackW.account = dbo.Wage.account where dbo.Wage.account ='" + waccount + "' and [isback] = 5 and [username] = '" + username + "'");
if (dtw5 == "")
{
string wamount = sdh.dbExecuteSql4Values("SELECT dbo.Wage.shifaheji FROM dbo.FeedbackW INNER JOIN dbo.Wage ON dbo.FeedbackW.account = dbo.Wage.account where [UserName]='" + username + "' and dbo.Wage.account ='" + waccount + "' and [isback] = 1");
if (wamount == "")
{
}
else
{
wtatol1 = wtatol1 + Convert.ToDouble(wamount);
}
}
else
{
isReceive = "是";
string wamount = sdh.dbExecuteSql4Values("SELECT dbo.Wage.shifaheji FROM dbo.FeedbackW INNER JOIN dbo.Wage ON dbo.FeedbackW.account = dbo.Wage.account where [UserName]='" + username + "' and dbo.Wage.account ='" + waccount + "' and [isback] = 5");
if (wamount == "")
{
}
else
{
wtatol5 = wtatol5 + Convert.ToDouble(wamount);
}
}
}
double tatol1 = ltatol1 + wtatol1;
double tatol5 = ltatol5 + wtatol5;
double tatol = tatol1 + tatol5;
double amountt = 0;
double amount5 = 0;
if (tatol - wagebase > 100000)
{ amountt = tatol - (tatol - wagebase) * 0.45 + 15375; }
else if (tatol - wagebase > 80000 && tatol - wagebase <= 100000)
{ amountt = tatol - (tatol - wagebase) * 0.40 + 10375; }
else if (tatol - wagebase > 60000 && tatol - wagebase <= 80000)
{ amountt = tatol - (tatol - wagebase) * 0.35 + 6375; }
else if (tatol - wagebase > 40000 && tatol - wagebase <= 60000)
{ amountt = tatol - (tatol - wagebase) * 0.30 + 3375; }
else if (tatol - wagebase > 20000 && tatol - wagebase <= 40000)
{ amountt = tatol - (tatol - wagebase) * 0.25 + 1375; }
else if (tatol - wagebase > 5000 && tatol - wagebase <= 20000)
{ amountt = tatol - (tatol - wagebase) * 0.20 + 375; }
else if (tatol - wagebase > 2000 && tatol - wagebase < 5000)
{ amountt = tatol - (tatol - wagebase) * 0.15 + 125; }
else if (tatol - wagebase > 500 && tatol - wagebase <= 2000)
{ amountt = tatol - (tatol - wagebase) * 0.10 + 25; }
else if (tatol - wagebase > 0 && tatol - wagebase <= 500)
{ amountt = tatol - (tatol - wagebase) * 0.05; }
else
{ amountt = tatol; }
if (tatol5 - wagebase > 100000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.45 + 15375; }
else if (tatol5 - wagebase > 80000 && tatol5 - wagebase <= 100000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.40 + 10375; }
else if (tatol - wagebase > 60000 && tatol5 - wagebase <= 80000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.35 + 6375; }
else if (tatol5 - wagebase > 40000 && tatol5 - wagebase <= 60000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.30 + 3375; }
else if (tatol5 - wagebase > 20000 && tatol5 - wagebase <= 40000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.25 + 1375; }
else if (tatol5 - wagebase > 5000 && tatol5 - wagebase <= 20000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.20 + 375; }
else if (tatol5 - wagebase > 2000 && tatol5 - wagebase < 5000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.15 + 125; }
else if (tatol5 - wagebase > 500 && tatol5 - wagebase <= 2000)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.10 + 25; }
else if (tatol5 - wagebase > 0 && tatol5 - wagebase <= 500)
{ amount5 = tatol5 - (tatol5 - wagebase) * 0.05; }
else
{ amount5 = tatol5; }
double amount = amountt - amount5;
DataTable dt = new DataTable();
dt.Columns.Add("本月是否领过金额");
dt.Columns.Add("本月累计收入");
dt.Columns.Add("上次领过金额");
dt.Columns.Add("本次应发金额");
DataRow row = dt.NewRow();
row["本月是否领过金额"] = isReceive;
row["本月累计收入"] = tatol.ToString();
row["上次领过金额"] = amount5.ToString();
row["本次应发金额"] = amount.ToString();
dt.Rows.Add(row);
return dt;
}