我有一门课,我在其中计算剩余的信用额度。并通过 DataTable 返回值。但是在 IF 条件下,它会抛出错误“输入字符串的格式不正确。”,代码有什么问题。
请帮助,在此先感谢
string cmd2 = "select sum(FacilityAmountINR),sum(LCAmountPaid) from FacilityIssueDetails where Status='open' AND LCType = 'Inland LC'";
DataTable a = DbRdRw.SqlDbRead(cmd2, "FacilityIssueDetails");
decimal AvailInlandLC = 0;
string totcred = Convert.ToString(a.Rows[0]["Column1"]);
string totpaid = Convert.ToString(a.Rows[0]["Column2"]);
if (totcred != null && totpaid != null)
{
decimal TotalAmountCredit = Convert.ToDecimal(totcred);// error here
decimal TotalAmountpaid = Convert.ToDecimal(totpaid); // error here
AvailInlandLC = InlandLC - TotalAmountCredit + TotalAmountpaid;
}
//*************************************************************************
DataTable AvailableLimitTable = new DataTable();
AvailableLimitTable.Columns.Add("LCType",typeof (string));
AvailableLimitTable.Columns.Add("TotalLimit",typeof (decimal));
AvailableLimitTable.Columns.Add("AvailableLimit",typeof (decimal));
DataRow dr = AvailableLimitTable.NewRow();
dr["LCType"] = "Inland LC";
dr["TotalLimit"] = InlandLC;
dr["AvailableLimit"] = AvailInlandLC;
AvailableLimitTable.Rows.InsertAt(dr, 0);