A "brute-force" solution could be as simple as:
cmd.Parameters.Add("@iznos_sa_pdv", SqlDbType.VarChar, 255).Value = $"-{ukupnolabel.Text}";
But be careful: if there is already a negative value in the textbox, you will end up with a value which is not a proper number.
It may be better to parse the string to a double, negate it, and provide the result back to the query:
double value;
if (double.TryParse(ukupnolabel.Text, out value))
{
value = -value;
cmd.Parameters.Add("@iznos_sa_pdv", SqlDbType.VarChar, 255).Value = value.ToString();
}
else
{
}
But there is an issue with your query: you specifiy two columns for
INSERT
statement but only provide a value for one of them.
Moreover, you should use proper data types in your database: if
iznos_sa_pdv
column is meant to hold real numbers, then it should not have a
varchar
type in the first place. It would then allow you to write
double value;
if (double.TryParse(ukupnolabel.Text, out value))
{
value = -value;
cmd.Parameters.Add("@iznos_sa_pdv", SqlDbType.Float).Value = value;
}
else
{
}