public bool MuaHang(int maKH, int maNV, DateTime thoigian, Dictionary <int, int> hangmua)
        {
            bool result = true;

            if (KiemTraDuHang(hangmua))
            {
                //sua lai so luong hang
                foreach (int maHH in hangmua.Keys)
                {
                    HangHoa hang = _dalHangHoa.GetRow(maHH);
                    hang.SoLuong = hang.SoLuong - hangmua[maHH];
                    _dalHangHoa.Sua(hang);
                }
                KhachHang khachang = _dalKhachHang.GetRow(maKH);
                float     tong     = TinhTongTien(maKH, hangmua);
                int       maHD     = _dalHoaDon.GetNextID();
                //them HoaDon
                _dalHoaDon.Them(new HoaDon(maHD, maKH, maNV, thoigian, tong));
                //them ChiTietHoaDon
                foreach (int maHH in hangmua.Keys)
                {
                    _dalChiTietHoaDon.Them(new ChiTietHoaDon(maHD, maHH, _dalHangHoa.GetRow(maHH).DonGia, hangmua[maHH]));
                }
                khachang.SoDiem = khachang.SoDiem + (int)tong / 100000 * 10;
                _dalKhachHang.Sua(khachang);

                MessageBox.Show("Giao dịch thành công!");
            }
            else
            {
                result = false;
            }
            return(result);
        }
예제 #2
0
        public void Them(DTO_HoaDon MaHD)
        {
            DAL_HoaDon DAL = new DAL_HoaDon();

            DAL.Them(MaHD);
        }