您好。我需要你的帮助。如何计算或总和最后一个文本框中的所有值。我把数字放在我的照片中只想解释我需要的东西。
我花了一些钱计算GST并将其显示在Total Legal Fees文本框中。
在数字1之后,我暂时把数量放在1以上,所以如果我有其他金额,我只需点击添加按钮。
此添加按钮帮助我显示2号总金额。例如,如果我收取一笔费用20美元而其他费用是30美元。因此,总计是%50,它显示在Total Disbursement文本框中。
这是我遇到的问题。如何计算所有法律费用总额和支出总额并在我的总计大文本框中自动显示?
这是我的添加按钮的代码。
private void btnAdd_Click(object sender, EventArgs e)
{
dgvDisList.ColumnCount = 2;
dgvDisList.Columns[0].HeaderText = "Category";
dgvDisList.Columns[1].HeaderText = "Amount";
string[] row = new string[] { cbDisCategory.Text, tbAmount.Text };
dgvDisList.Rows.Add(row);
// Sum Total dari GridView
int sum = 0;
for (int i = 0; i < dgvDisList.Rows.Count; ++i)
{
sum += Convert.ToInt32(dgvDisList.Rows[i].Cells[1].Value);
}
tbTotalDisbursement.Text = sum.ToString();
}
这是我的GST计算
private void tbLegalFees_TextChanged(object sender, EventArgs e)
{
if (System.Text.RegularExpressions.Regex.IsMatch(tbLegalFees.Text, "^(\\$??)(\\d+)(\\.??)(\\d*)"))
{
decimal exGST = tbLegalFees.Text.StartsWith("") ? decimal.Parse(tbLegalFees.Text) : decimal.Parse(tbLegalFees.Text);
decimal incGST = exGST * (decimal)0.6;
decimal GST = incGST + exGST;
tbLegalFees.Text = string.Format("{0:f2}", exGST);
tbGSTpercent.Text = string.Format("{0:f2}", incGST);
tbTotalLegalFees.Text = string.Format("{0:f2}", GST);
}
}