//THỐNG KÊ THEO NHÂN VIÊN CHI TIẾT
        public static List <ThongKeTheoHoaDonPublic> ThongKeTheoNhanVienChiTiet(string _MaNV, DateTime _dtTuNgay, DateTime _dtDenNgay)
        {
            List <ThongKeTheoHoaDonPublic> _lstKqThongKeTheoNhanVien = new List <ThongKeTheoHoaDonPublic>();

            DateTime _dtNgayBatDau  = new DateTime(_dtTuNgay.Year, _dtTuNgay.Month, _dtTuNgay.Day, 0, 0, 0);
            DateTime _dtNgayKetThuc = new DateTime(_dtDenNgay.Year, _dtDenNgay.Month, _dtDenNgay.Day, 23, 59, 59);

            //Lấy danh sách hóa đơn theo nhân viên
            SqlCommand _cmd = new SqlCommand();

            _cmd.CommandType = CommandType.StoredProcedure;
            _cmd.CommandText = "[Lấy danh sách hóa đơn theo nhân viên]";
            _cmd.Parameters.AddWithValue("@Ma_NV", _MaNV);
            _cmd.Parameters.AddWithValue("@TuNgay", _dtNgayBatDau);
            _cmd.Parameters.AddWithValue("@DenNgay", _dtNgayKetThuc);

            DataTable _dtHoaDon = conn.GetDataSet2(_cmd).Tables[0];
            ThongKeTheoHoaDonPublic _thongKeTheoHoaDon;

            //Tính chi tiết hóa đơn
            if (_dtHoaDon.Rows.Count > 0)
            {
                for (int i = 0; i < _dtHoaDon.Rows.Count; i++)
                {
                    int _TongThu      = 0;
                    int _TongLoiNhuan = 0;
                    int _TongTienNhap = 0;
                    _thongKeTheoHoaDon = new ThongKeTheoHoaDonPublic();
                    HoaDonPublic _hd = new HoaDonPublic();
                    _hd = TinhTien1HoaDon(_dtHoaDon.Rows[i]["SoHD_HD"].ToString());

                    _TongThu      += _hd.ThanhTien;
                    _TongTienNhap += _hd.TongTienNhap;
                    _TongLoiNhuan  = _TongThu - _TongTienNhap;

                    _thongKeTheoHoaDon.HoaDon       = _hd;
                    _thongKeTheoHoaDon.TongThu      = UntilitiesDataAccess.ThemDauPhay(_TongThu.ToString());
                    _thongKeTheoHoaDon.TongLoiNhuan = UntilitiesDataAccess.ThemDauPhay(_TongLoiNhuan.ToString());
                    _lstKqThongKeTheoNhanVien.Add(_thongKeTheoHoaDon);
                }
            }
            return(_lstKqThongKeTheoNhanVien);
        }
        //THỐNG KÊ THEO HÓA ĐƠN
        public static List <ThongKeTheoHoaDonPublic> ThongKeTheoHoaDon(DateTime _dtTuNgay, DateTime _dtDenNgay)
        {
            List <ThongKeTheoHoaDonPublic> _lstKqThongKeTheoHoaDon = new List <ThongKeTheoHoaDonPublic>();

            #region 1.Lấy hóa đơn, hàng mua trong khoảng thời gian
            DateTime _dtNgayBatDau  = new DateTime(_dtTuNgay.Year, _dtTuNgay.Month, _dtTuNgay.Day, 0, 0, 0);
            DateTime _dtNgayKetThuc = new DateTime(_dtDenNgay.Year, _dtDenNgay.Month, _dtDenNgay.Day, 23, 59, 59);

            SqlCommand _cmd = new SqlCommand();
            _cmd.CommandType = CommandType.StoredProcedure;
            _cmd.CommandText = "[Thống kê theo hóa đơn]";
            _cmd.Parameters.AddWithValue("@TuNgay", _dtNgayBatDau);
            _cmd.Parameters.AddWithValue("@DenNgay", _dtNgayKetThuc);

            DataSet _dsThongKeTheoHoaDon = conn.GetDataSet2(_cmd);
            _cmd.Dispose();

            DataTable _dtHoaDon  = _dsThongKeTheoHoaDon.Tables[0];
            DataTable _dtHangMua = _dsThongKeTheoHoaDon.Tables[1];
            #endregion

            #region 2.Tính thống kê tổng thu, tổng lợi nhuận từng hóa đơn
            if (_dtHoaDon.Rows.Count > 0)
            {
                for (int i = 0; i < _dtHoaDon.Rows.Count; i++)
                {
                    ThongKeTheoHoaDonPublic _thongKeTheoHoaDon = new ThongKeTheoHoaDonPublic();

                    ////Lấy thông tin hóa đơn
                    //HoaDonPublic _hoaDon = new HoaDonPublic();
                    //_hoaDon.SoHD_HD = _dtHoaDon.Rows[i]["SoHD_HD"].ToString();
                    //_hoaDon.NgayLap_HD = Convert.ToDateTime(_dtHoaDon.Rows[i]["NgayLap_HD"].ToString());
                    //_hoaDon.NguoiLap_HD.MaNV_NV = _dtHoaDon.Rows[i]["NguoiLap_HD"].ToString();
                    //_hoaDon.KhachHang_HD.MaKH_KH = _dtHoaDon.Rows[i]["MaKH_HD"].ToString();
                    //_hoaDon.BanLe_HD = (bool)_dtHoaDon.Rows[i]["BanLe_HD"];
                    //_hoaDon.TongCKHoaDon = Convert.ToInt32(UntilitiesDataAccess.BoDauPhay(_dtHoaDon.Rows[i]["ChietKhauTienMat_HD"].ToString()));
                    //_hoaDon.TienKhachTra_HD = Convert.ToInt32(UntilitiesDataAccess.BoDauPhay(_dtHoaDon.Rows[i]["TienKhachTra_HD"].ToString()));
                    //_hoaDon.VouCher_HD = Convert.ToInt32(UntilitiesDataAccess.BoDauPhay(_dtHoaDon.Rows[i]["VouCher_HD"].ToString()));
                    //_hoaDon.MaGiamGia.MaThe_MGG = _dtHoaDon.Rows[i]["MaGiamGia_HD"].ToString();
                    //_hoaDon.CKPhanTram_HD = float.Parse(_dtHoaDon.Rows[i]["CKPhanTram_HD"].ToString());
                    //_hoaDon.TraHang_HD = (bool)_dtHoaDon.Rows[i]["TraHang_HD"];
                    //_hoaDon.DangDung_HD = (bool)_dtHoaDon.Rows[i]["DangDung_HD"];

                    //_thongKeTheoHoaDon.HoaDon = _hoaDon;

                    ////Tính tiền cho từng hóa đơn
                    //int _TongThu = 0;
                    //int _TongLai = 0;
                    //int _TongSoLuongBan = 0;
                    //int _TongTienNhap = 0;
                    //string _strFilterHangMua = "SoHD_HM = '" + _thongKeTheoHoaDon.HoaDon.SoHD_HD + "'";
                    //DataView _dvHangMua = new DataView(_dtHangMua, _strFilterHangMua, "SoHD_HM", DataViewRowState.CurrentRows);

                    //if (_dvHangMua.Count > 0)
                    //{
                    //    for (int j = 0; j < _dvHangMua.Count; j++)
                    //    {
                    //        int _soLuong = Convert.ToInt32(_dvHangMua[j]["SoLuong_HM"].ToString());
                    //        int _giaBan = Convert.ToInt32(UntilitiesDataAccess.BoDauPhay(_dvHangMua[j]["GiaBan_HM"].ToString()));
                    //        int _giaNhap = Convert.ToInt32(UntilitiesDataAccess.BoDauPhay(_dvHangMua[j]["GiaNhap_HM"].ToString()));
                    //        int _TienCKSP = Convert.ToInt32(UntilitiesDataAccess.BoDauPhay(_dvHangMua[j]["CKTienMat_HM"].ToString()));

                    //        _TongTienNhap = _TongTienNhap + _giaNhap;
                    //        _TongSoLuongBan = _TongSoLuongBan + _soLuong;
                    //        _TongThu = _TongThu + (_soLuong * _giaBan - _TienCKSP);
                    //    }
                    //    _TongLai = _TongThu - _TongTienNhap;
                    //}


                    HoaDonPublic _hd = TinhTien1HoaDon(_dtHoaDon.Rows[i]["SoHD_HD"].ToString());
                    _thongKeTheoHoaDon.HoaDon = _hd;
                    int _TongLoiNhuan = _hd.ThanhTien - _hd.TongTienNhap;

                    _thongKeTheoHoaDon.TongThu      = UntilitiesDataAccess.ThemDauPhay(_hd.ThanhTien.ToString());
                    _thongKeTheoHoaDon.TongLoiNhuan = UntilitiesDataAccess.ThemDauPhay(_TongLoiNhuan.ToString());

                    _lstKqThongKeTheoHoaDon.Add(_thongKeTheoHoaDon);
                }
            }

            #endregion

            return(_lstKqThongKeTheoHoaDon);
        }