private void listView_Click(object sender, EventArgs e) { flag = true; flagimage = true; ComboBLL comboBLL = new ComboBLL(); txtComboName.Text = listViewCombo.SelectedItems[0].SubItems[1].Text; dayStart.Value = DateTime.Parse(listViewCombo.SelectedItems[0].SubItems[2].Text); dayEnd.Value = DateTime.Parse(listViewCombo.SelectedItems[0].SubItems[3].Text); numDiscount.Text = listViewCombo.SelectedItems[0].SubItems[5].Text; txtTotal.Text = listViewCombo.SelectedItems[0].SubItems[4].Text; total = int.Parse(txtTotal.Text.Replace(",", "")); int idcombo = int.Parse(listViewCombo.SelectedItems[0].ImageKey); LoadPreviewImage(idcombo); id = idcombo; btnThem.Enabled = true; btnXoa.Enabled = true; btnSua.Enabled = true; list = comboBLL.ListIDProduct(id); }
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"); }