Пример #1
0
        private void Ban_Click(object sender, EventArgs e)
        {
            lsvBill.Items.Clear();
            Button btn = (Button)sender;

            soBan      = int.Parse(btn.Name.Substring(6));
            lbBan.Text = "Bàn " + soBan.ToString();
            int kq = hdBus.GetMaHoaDonLonNhat();

            tinhTrangBan = Convert.ToBoolean(banBus.GetTinhTrangBanByIDBan(soBan)["TinhTrang"]);
            if (tinhTrangBan == false)
            {
                btnThem.Enabled      = true;
                btnInPhieu.Enabled   = true;
                btnGiam.Enabled      = true;
                btnThanhToan.Enabled = false;
                Tong   = 0;
                alow   = true;
                hoaDon = kq + 1;
            }
            else
            {
                btnThem.Enabled      = false;
                btnGiam.Enabled      = false;
                btnInPhieu.Enabled   = false;
                btnThanhToan.Enabled = true;
                alow = false;
                DataRow r = hdBus.GetThongTinHoaDonByIDBan(soBan);
                hoaDon = Convert.ToInt32(r["MaHD"]);
                Tong   = Convert.ToInt32(r["TongTien"]);
                DataTable dataTable = new HoaDonChiTiet_BUS().GetThongTinHoaDonChiTietByMaHD(hoaDon);
                foreach (DataRow dr in dataTable.Rows)
                {
                    int          MaSP = int.Parse(dr["MaSP"].ToString());
                    DataRow      row  = spBus.GetSanPhamByMaSP(MaSP);
                    ListViewItem item = new ListViewItem(row["Ten"].ToString());
                    item.SubItems.Add(dr["SoLuong"].ToString());
                    item.SubItems.Add(row["GiaBan"].ToString());
                    item.SubItems.Add(row["DonVi"].ToString());
                    item.SubItems.Add(row["MaSP"].ToString());
                    lsvBill.Items.Add(item);
                }
            }
            lbTongTien.Text = Tong.ToString();
        }