Exemplo n.º 1
0
        /*
         * - Duyệt từng phần tử ở trong lv_hoaDon và lấy dữ liệu từng dòng thêm vào chi tiết hóa đơn qua class DetailBillDao và sau khi thêm mỗi dòng
         * thì đồng thời thực hiện việc xóa dòng đó ở lv_hoaDon.
         * - Nếu việc thêm chi tiết hóa đơn không thành công thì sẽ xuất ra MessageBox
         */
        private void addDetailBill()
        {
            foreach (ListViewItem items in lv_hoaDon_banHangControl.Items)
            {
                model.DetailBill detailBill = new model.DetailBill();
                detailBill.id_bill    = max;
                detailBill.id_product = items.Name;
                detailBill.amount     = int.Parse(items.SubItems[4].Text);
                detailBill.price      = int.Parse(items.SubItems[5].Text);

                if (!detail_bill.addDetailBill(detailBill))
                {
                    MessageBox.Show("Thêm chi tiết hóa đơn không thành công");
                }

                updateAmountProduct(items.Name, detailBill.amount);

                lv_hoaDon_banHangControl.Items.Remove(items);
            }
            bt_refresh_banHangControl_Click(null, null);
        }