public List<QuanLySanPhamViewModels> GetDanhSachSanPhamNguoiBan(int accountID, int? PageIndex, int? PageSize, ref  int TotalRecords)
        {
            SqlConnection sqlConnection = new SqlConnection();
            sqlConnection.ConnectionString = MyConnectionString1;
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "DanhSachSanPhamNguoiBan";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            SqlParameter i_Page_Index = sqlCommand.Parameters.Add("@i_Page_Index", SqlDbType.Int);
            i_Page_Index.Direction = ParameterDirection.Input;
            i_Page_Index.Value = PageIndex;

            SqlParameter i_Page_Count = sqlCommand.Parameters.Add("@i_Page_Count", SqlDbType.Int);
            i_Page_Count.Direction = ParameterDirection.Input;
            i_Page_Count.Value = PageSize;

            SqlParameter Module_Id = sqlCommand.Parameters.Add("@accountID", SqlDbType.Int);
            Module_Id.Direction = ParameterDirection.Input;
            Module_Id.Value = accountID;

            sqlCommand.Parameters.Add("@o_total_rows", SqlDbType.Int).Direction = ParameterDirection.Output;

            sqlCommand.Connection = sqlConnection;
            sqlConnection.Open();
            SqlDataReader reader = sqlCommand.ExecuteReader();
            List<QuanLySanPhamViewModels> QLSPViewModels = new List<QuanLySanPhamViewModels>();
            while (reader.Read())
            {
                QuanLySanPhamViewModels h = new QuanLySanPhamViewModels();
                h.QLSP_ID = reader.GetInt32(0);
                h.tenSanPham = reader.GetString(1);
                h.UrlHinh = reader.GetString(2);
                h.GiaGoc = reader.GetFloat(3);
                h.GiaThamKhao = reader.GetFloat(4);
                h.TrangThai = reader.GetString(5);
                QLSPViewModels.Add(h);
            }
            reader.NextResult();
            TotalRecords = Convert.ToInt32(sqlCommand.Parameters["@o_total_rows"].Value);
            return QLSPViewModels;
        }
        public List<QuanLySanPhamViewModels> SearchDetailsAdmin(int ShopID,string keyword, string TinhTrang,
            string TuNgaySearch,
            string DenNgaySearch,
            int? PageIndex,
            int? PageSize, ref  int TotalRecords)
        {
            HtmlHelperGeneral.openConnection();
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "SearchDetailsSanPhamAdmin";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            SqlParameter i_Page_Index = sqlCommand.Parameters.Add("@i_Page_Index", SqlDbType.Int);
            i_Page_Index.Direction = ParameterDirection.Input;
            i_Page_Index.Value = PageIndex;

            SqlParameter i_Page_Count = sqlCommand.Parameters.Add("@i_Page_Count", SqlDbType.Int);
            i_Page_Count.Direction = ParameterDirection.Input;
            i_Page_Count.Value = PageSize;

            SqlParameter i_ShopID = sqlCommand.Parameters.Add("@ShopID", SqlDbType.Int);
            i_ShopID.Direction = ParameterDirection.Input;
            i_ShopID.Value = ShopID;

            SqlParameter i_keyword = sqlCommand.Parameters.Add("@keyword", SqlDbType.NVarChar);
            i_keyword.Direction = ParameterDirection.Input;
            i_keyword.Value = keyword;

            SqlParameter i_TinhTrang = sqlCommand.Parameters.Add("@TinhTrang", SqlDbType.NVarChar);
            i_TinhTrang.Direction = ParameterDirection.Input;
            i_TinhTrang.Value = TinhTrang;

            SqlParameter i_TuNgaySearch = sqlCommand.Parameters.Add("@startDate", SqlDbType.VarChar);
            i_TuNgaySearch.Direction = ParameterDirection.Input;
            i_TuNgaySearch.Value = TuNgaySearch;

            SqlParameter i_DenNgaySearch = sqlCommand.Parameters.Add("@endDate", SqlDbType.VarChar);
            i_DenNgaySearch.Direction = ParameterDirection.Input;
            i_DenNgaySearch.Value = DenNgaySearch;

            sqlCommand.Parameters.Add("@o_total_rows", SqlDbType.Int).Direction = ParameterDirection.Output;

            sqlCommand.Connection = HtmlHelperGeneral.con;
            SqlDataReader reader = sqlCommand.ExecuteReader();
            List<QuanLySanPhamViewModels> QLSPViewModels = new List<QuanLySanPhamViewModels>();
            while (reader.Read())
            {
                QuanLySanPhamViewModels h = new QuanLySanPhamViewModels();
                h.QLSP_ID = reader.GetInt32NullCheck(0);
                h.tenSanPham = reader.GetStringNullCheck(1);
                h.UrlHinh = reader.GetStringNullCheck(2);
                h.GiaGoc = reader.GetFloatNullCheck(3);
                h.GiaThamKhao = reader.GetFloatNullCheck(4);
                h.TrangThai = reader.GetStringNullCheck(5);
                h.noidung = reader.GetStringNullCheck(6);
                h.QLSHOP_ID = reader.GetInt32NullCheck(7);
                h.AccountId = reader.GetInt32NullCheck(8);
                h.diemNoiBat = reader.GetStringNullCheck(9);
                if (!reader.IsDBNull(10)) {
                    h.NgayDuyet = reader.GetDateTime(10);
                }
                h.IsActive = reader.GetBooleanNullCheck(11);
                if (!reader.IsDBNull(12))
                {
                    h.NgayUpDate = reader.GetDateTime(12);
                }
                QLSPViewModels.Add(h);
            }
            reader.NextResult();
            TotalRecords = Convert.ToInt32(sqlCommand.Parameters["@o_total_rows"].Value);
            HtmlHelperGeneral.Close();
            return QLSPViewModels;
        }
        public List<QuanLySanPhamViewModels> SearchDetails(int? Nganhhang_ID, int? PageIndex, 
            int? PageSize, ref  int TotalRecords,
            int? tinh, string keyword,int? tg,
            int? tu, int? den)
        {
            SqlConnection sqlConnection = new SqlConnection();
            sqlConnection.ConnectionString = MyConnectionString1;
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "SearchDetailsSanPham";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            SqlParameter i_Page_Index = sqlCommand.Parameters.Add("@i_Page_Index", SqlDbType.Int);
            i_Page_Index.Direction = ParameterDirection.Input;
            i_Page_Index.Value = PageIndex;

            SqlParameter i_Page_Count = sqlCommand.Parameters.Add("@i_Page_Count", SqlDbType.Int);
            i_Page_Count.Direction = ParameterDirection.Input;
            i_Page_Count.Value = PageSize;

            SqlParameter i_Nganhhang_ID = sqlCommand.Parameters.Add("@Nganhhang_ID", SqlDbType.Int);
            i_Nganhhang_ID.Direction = ParameterDirection.Input;
            i_Nganhhang_ID.Value = Nganhhang_ID;

            SqlParameter i_tinh = sqlCommand.Parameters.Add("@tinh", SqlDbType.Int);
            i_tinh.Direction = ParameterDirection.Input;
            i_tinh.Value = tinh;

            SqlParameter i_keyword = sqlCommand.Parameters.Add("@keyword", SqlDbType.NVarChar);
            i_keyword.Direction = ParameterDirection.Input;
            i_keyword.Value = keyword;

            if (tg != null && tg != 0)
            {

                DateTime endDate = DateTime.Now;
                string endDateStr = endDate.ToString("MM/dd/yyyy");

                tg = tg > 0 ? tg * (-1) : tg;
                double ddays = Convert.ToDouble(tg);

                DateTime startDate = endDate.AddDays(ddays);
                string startDateStr = startDate.ToString("MM/dd/yyyy");

                SqlParameter i_startDate = sqlCommand.Parameters.Add("@startDate", SqlDbType.VarChar);
                i_startDate.Direction = ParameterDirection.Input;
                i_startDate.Value = startDateStr;

                SqlParameter i_endDate = sqlCommand.Parameters.Add("@endDate", SqlDbType.VarChar);
                i_endDate.Direction = ParameterDirection.Input;
                i_endDate.Value = endDateStr;
            }
            else if( tg == 0) {
                DateTime startDate = DateTime.Now;
                string startDateStr = startDate.ToString("MM/dd/yyyy");

                DateTime endDate = startDate.AddDays(+1);
                string endDateStr = endDate.ToString("MM/dd/yyyy");
                SqlParameter i_startDate = sqlCommand.Parameters.Add("@startDate", SqlDbType.VarChar);
                i_startDate.Direction = ParameterDirection.Input;
                i_startDate.Value = startDateStr;

                SqlParameter i_endDate = sqlCommand.Parameters.Add("@endDate", SqlDbType.VarChar);
                i_endDate.Direction = ParameterDirection.Input;
                i_endDate.Value = endDateStr;
            }

            SqlParameter i_tu = sqlCommand.Parameters.Add("@tu", SqlDbType.Int);
            i_tu.Direction = ParameterDirection.Input;
            i_tu.Value = tu;

            SqlParameter i_den = sqlCommand.Parameters.Add("@den", SqlDbType.Int);
            i_den.Direction = ParameterDirection.Input;
            i_den.Value = den;

            sqlCommand.Parameters.Add("@o_total_rows", SqlDbType.Int).Direction = ParameterDirection.Output;

            sqlCommand.Connection = sqlConnection;
            sqlConnection.Open();
            SqlDataReader reader = sqlCommand.ExecuteReader();
            List<QuanLySanPhamViewModels> QLSPViewModels = new List<QuanLySanPhamViewModels>();
            while (reader.Read())
            {
                QuanLySanPhamViewModels h = new QuanLySanPhamViewModels();
                h.QLSP_ID = reader.GetInt32(0);
                h.tenSanPham = reader.GetString(1);
                h.UrlHinh = reader.GetString(2);
                h.GiaGoc = reader.GetFloat(3);
                h.GiaThamKhao = reader.GetFloat(4);
                h.TrangThai = reader.GetString(5);
                h.noidung = reader.GetString(6);
                h.QLSHOP_ID = reader.GetInt32(7);
                QLSPViewModels.Add(h);
            }
            reader.NextResult();
            TotalRecords = Convert.ToInt32(sqlCommand.Parameters["@o_total_rows"].Value);
            return QLSPViewModels;
        }
        public List<QuanLySanPhamViewModels> GetSanPhamReviewRecent(
            int? PageIndex,
            int? PageSize,
            ref  int TotalRecords)
        {
            HtmlHelperGeneral.openConnection();
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "GetSanPhamReviewRecent";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            SqlParameter i_Page_Index = sqlCommand.Parameters.Add("@i_Page_Index", SqlDbType.Int);
            i_Page_Index.Direction = ParameterDirection.Input;
            i_Page_Index.Value = PageIndex;

            SqlParameter i_Page_Count = sqlCommand.Parameters.Add("@i_Page_Count", SqlDbType.Int);
            i_Page_Count.Direction = ParameterDirection.Input;
            i_Page_Count.Value = PageSize;

            sqlCommand.Parameters.Add("@o_total_rows", SqlDbType.Int).Direction = ParameterDirection.Output;

            sqlCommand.Connection = HtmlHelperGeneral.con;
            SqlDataReader reader = sqlCommand.ExecuteReader();
            List<QuanLySanPhamViewModels> spMoiNhat = new List<QuanLySanPhamViewModels>();
            while (reader.Read())
            {
                QuanLySanPhamViewModels h = new QuanLySanPhamViewModels();
                h.QLSP_ID = reader.GetInt32NullCheck(0);
                h.tenSanPham = reader.GetStringNullCheck(1);
                h.UrlHinh = reader.GetStringNullCheck(2);
                h.diemNoiBat = reader.GetStringNullCheck(3);
                h.GiaThamKhao = reader.GetFloatNullCheck(4);
                h.GiaGoc    = reader.GetFloatNullCheck(5);
                h.NgayUpDate = reader.GetDateTime(6);
                h.AccountId = reader.GetInt32NullCheck(7);
                h.TenTinhThanh = reader.GetStringNullCheck(8);
                spMoiNhat.Add(h);
            }
            reader.NextResult();
            TotalRecords = Convert.ToInt32(sqlCommand.Parameters["@o_total_rows"].Value);
            HtmlHelperGeneral.Close();
            return spMoiNhat;
        }