商品の合計金額を表示したいと思います。私はあなたが明確な説明のためにimageで問題を確認することができます合計金額 合計を表示するデータテーブルの列の値の合計
に.00
を追加したい
- が
- の価格:私は2つの問題に直面しています。あなたは常に合計のSelectedItemの行に追加するにはループでは
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();
ありがとうございます私は本当にありがとう、あなたは本当に天才な人を殺しているリストボックス –
と私の最初の質問であなたに尋ねるもう一つのことについては気にしない場合はもう一度質問をすることができますか? –
あなたの質問のこの部分は私には不明です。 ListBoxに項目を追加する方法がわかりません。しかし、商品を商品リストから取り出した場合は、今のようにフォーマットする必要があります。 – Steve