每当我将值放入 TextBox 时,我希望我的输出不会被四舍五入。例如 5000/2000 我想显示的输出是 2 但它显示的是 3。
这是我的代码
private void InsertReceipt()
{
decimal Stub;
Stub = decimal.Parse(txtAmount.Text) / 2000;
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "INSERT INTO Ticket(CustomerID, Date, Store, Amount, NoStub)" + "VALUES (@CustomerID, @Date, @Store, @Amount, @NoStub) ";
cmd.Parameters.AddWithValue("@CustomerID", txtCustomerID.Text);
cmd.Parameters.AddWithValue("@Date", dtpDate.Value.Date.ToString());
cmd.Parameters.AddWithValue("@Store", txtStore.Text);
decimal amount = decimal.Parse(txtAmount.Text);
cmd.Parameters.AddWithValue("@Amount", amount);
cmd.Parameters.Add("@NoStub", SqlDbType.Decimal).Value = Stub;
cmd.ExecuteNonQuery();
}