private void listview_Invoice_click(object sender, EventArgs e) { id = int.Parse(listViewInvoice.SelectedItems[0].Text); InvoiceBLL invoiceBLL = new InvoiceBLL(); DataTable dataTable = invoiceBLL.GetInvoiceDetail(id); string js_product = dataTable.Rows[0][2].ToString(); string js_combo = dataTable.Rows[0][3].ToString(); JArray rs_prd = (JArray)JsonConvert.DeserializeObject(js_product); JArray rs_combo = (JArray)JsonConvert.DeserializeObject(js_combo); ArrayList arr_product = new ArrayList(); ArrayList arr_combo = new ArrayList(); ListViewItem lvitem; if (rs_prd != null) { foreach (JObject obj in rs_prd) { Product product = new Product(); product = obj["Product"].ToObject <Product>(); arr_product.Add(product); } } if (rs_combo != null) { foreach (JObject obj in rs_combo) { Combo combo = new Combo(); combo = obj["Combo"].ToObject <Combo>(); arr_combo.Add(combo); } } LoadImage(arr_product, arr_combo); loadkhaibaoviewdetail(); int thanhtien = 0; if (rs_prd != null) { foreach (JObject obj in rs_prd) { Product product = new Product(); product = obj["Product"].ToObject <Product>(); lvitem = new ListViewItem(); int quantity = (int)obj["Quantity"]; int tongcong = quantity * product.price; thanhtien += tongcong; lvitem.ImageKey = product.id.ToString(); lvitem.SubItems.Add(product.productname); lvitem.SubItems.Add(quantity.ToString()); lvitem.SubItems.Add(product.price.ToString("0,0")); lvitem.SubItems.Add(tongcong.ToString("0,0")); listViewInvoiceDetail.Items.Add(lvitem); } } if (rs_combo != null) { foreach (JObject obj in rs_combo) { Combo combo = new Combo(); combo = obj["Combo"].ToObject <Combo>(); lvitem = new ListViewItem(); int quantity = (int)obj["Quantity"]; int tongcong = quantity * combo.total; thanhtien += tongcong; lvitem.ImageKey = combo.Id.ToString(); lvitem.SubItems.Add(combo.comboName); lvitem.SubItems.Add(quantity.ToString()); lvitem.SubItems.Add(combo.total.ToString("0,0")); lvitem.SubItems.Add(tongcong.ToString("0,0")); listViewInvoiceDetail.Items.Add(lvitem); } } txtThanhtien.Text = thanhtien.ToString("0,0"); }