I want to show sum of total Price of items. I am facing 2 issues:
- It's showing me wrong total of items price
- I want to add
.00
to the total price
You can check issue in the image for a clear explanation.
Here is my code:
tDisplay.Text = "Return/" + "Receipt No:" + Return_Form.setalueforText011;
label1.Text = Return_Form.setalueforText011;
OleDbConnection VCON = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:Restaurant.accdb");
DataSet dsa = new DataSet();
DataTable dt = new DataTable();
dsa.Tables.Add(dt);
OleDbDataAdapter da = new OleDbDataAdapter();
da = new OleDbDataAdapter("SELECT [Column1],[Column2],[Column3] from [Total] Where [Receipt No] = " + label1.Text + "", VCON);
da.Fill(dt);
//dataGridView1.DataSource = dt;
for (int i = 0; i < dt.Rows.Count; i++)
{
products.Add(new tblProduct() { productName = dt.Rows[i]["Column2"].ToString(),productPrice = Convert.ToDecimal(Math.Round(Convert.ToDecimal(dt.Rows[i]["Column1"].ToString())))});
label3.Text = dt.Rows[i]["Column3"].ToString();
textBox59.Text = "Rs: "+String.Format("{0:}", Total);
tblProduct selected = (tblProduct)(listBox60.SelectedItem);
Total += (decimal)selected.productPrice;
}
VCON.Close();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…