In the following code below I want to take 80% of the price for each item and return a total amount. It does this fine but doesn't round to 2 decimal places I'm using SQL CE edition so I can only use money as the field type.
I have tried this "("SELECT BookID, MemberID, Title, Author, (Price=Round([Price],2) * 0.8) As Price FROM [CashOutDB] Where MemberID = '" + m.MemberID + "'", con);"
but the select isn't returning anything so I assume its wrong. Any tips or suggestions would be great.
public static void LoadCashOutList(ListView lv, Member m, TextBox txtTotal, Label label1)
SqlCeConnection con = BookStoreDB.GetConnection();
SqlCeCommand comm = new SqlCeCommand("SELECT BookID, MemberID, Title, Author, (Price * 0.8) As Price FROM [CashOutDB] Where MemberID = '" + m.MemberID + "'", con);
SqlCeDataReader reader = comm.ExecuteReader();
decimal cashOutTotal = 0;
string data = new string;
data = reader["BookID"].ToString();
data = reader["MemberID"].ToString();
data = reader["Title"].ToString();
data = reader["Author"].ToString();
data = reader["Price"].ToString();
cashOutTotal += Convert.ToDecimal(reader["Price"]);
ListViewItem liv = new ListViewItem(data);
label1.Text = " Hello " + m.FirstName + " " + m.LastName + ", Here are your books avaliable for cashing out";
txtTotal.Text = "$ " + cashOutTotal.ToString();