private void btnAdd_Click(object sender, EventArgs e) { LapDonHangBLL donHangBLL = new LapDonHangBLL(); if (newCus) { donHangBLL.AddKhach(firstname, lastname, phone, address); } int totalqty = 0; foreach (ObjCombo item in arr_combo) { totalqty += item.Quantity; ComboBLL comboBLL = new ComboBLL(); ArrayList listid = comboBLL.ListIDProduct(item.Combo.Id); foreach (int a in listid) { ProductBLL productBLL = new ProductBLL(); productBLL.EditProduct(item.Quantity, a); } } foreach (ObjProduct item in arr_product) { totalqty += item.Quantity; ProductBLL productBLL = new ProductBLL(); productBLL.EditProduct(item.Quantity, item.Product.id); } Invoice invoice = new Invoice(); if (newCus) { invoice.customer_id = donHangBLL.getIdCustommer(); } else { invoice.customer_id = idcus; } invoice.customeraddress = address; invoice.totalmoney = txtThanhtien.Text.Replace(",", ""); invoice.amount = totalqty.ToString(); invoice.creatday = DateTime.Now; invoice.ordernote = "123"; invoice.postcode = "123"; invoice.status = "Done"; donHangBLL.AddInvoice(invoice); string products = ""; if (arr_product.Count != 0) { products = JsonConvert.SerializeObject(arr_product); } string combos = ""; if (arr_combo.Count != 0) { combos = JsonConvert.SerializeObject(arr_combo); } donHangBLL.AddInvoiceDetail(products, combos); LoadListViewSelect(); arr_combo = new ArrayList(); arr_product = new ArrayList(); MessageBox.Show("Đã thêm đơn hàng thành công"); }