/// <summary>
        /// Lấy nhanh sách nhân viên theo điều kiện
        /// </summary>
        /// <param name="employeeFilter">
        /// Page
        /// PageSize
        /// Search
        /// </param>
        /// <returns>Danh sách nv</returns>
        /// CreatedBy KDLong 07/05/2021
        public Pagging <Employee> GetEmployees(EmployeeFilter employeeFilter)
        {
            using (dbConnection = new MySqlConnection(connectionString))
            {
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@Search", employeeFilter.Search);

                var totalRecords = dbConnection.QueryFirstOrDefault <int>("Proc_GetTotalEmployees", param: parameters, commandType: CommandType.StoredProcedure);

                var totalPages = Math.Ceiling((decimal)totalRecords / employeeFilter.PageSize);

                var employees = dbConnection.Query <Employee>("Proc_GetEmployeesFilter", param: employeeFilter, commandType: CommandType.StoredProcedure);

                // Dữ liệu pagging
                var paging = new Pagging <Employee>()
                {
                    TotalRecords = totalRecords,
                    TotalPages   = (int)totalPages,
                    Data         = employees,
                    PageIndex    = employeeFilter.Page,
                    PageSize     = employeeFilter.PageSize
                };
                return(paging);
            }
        }
        /// <summary>
        /// Lấy dữ liệu phân trang
        /// </summary>
        /// <param name="customerFilter">
        /// Page = Trang hiện tại
        /// PageSize = Số khách hàng trên 1 trang
        /// FullName = Tên dùng để filter
        /// PhoneNumber = Số điện thoại dùng để filter
        /// CustomerGroupId = Nhóm khách hàng dùng để filter
        /// </param>
        /// <returns></returns>
        /// CreatedBy KDLong 28/04/2021
        public Pagging <Customer> GetCustomers(CustomerFilter customerFilter)
        {
            using (dbConnection = new MySqlConnection(connectionString))
            {
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@FullName", customerFilter.FullName);
                parameters.Add("@PhoneNumber", customerFilter.PhoneNumber);
                parameters.Add("@CustomerGroupId", customerFilter.CustomerGroupId);

                var totalRecords = dbConnection.QueryFirstOrDefault <int>("Proc_KDLong_GetTotalCustomers", param: parameters, commandType: CommandType.StoredProcedure);

                var totalPages = Math.Ceiling((decimal)totalRecords / customerFilter.PageSize);

                var customers = dbConnection.Query <Customer>("Proc_KDLong_GetEmployees", param: customerFilter, commandType: CommandType.StoredProcedure);

                // Dữ liệu pagging
                var paging = new Pagging <Customer>()
                {
                    TotalRecords = totalRecords,
                    TotalPages   = (int)totalPages,
                    Data         = customers,
                    PageIndex    = customerFilter.Page,
                    PageSize     = customerFilter.PageSize
                };
                return(paging);
            }
        }
Exemple #3
0
        /// <summary>
        /// Phân trang
        /// </summary>
        /// <param name="pageSize">số lượng bản ghi trong trang</param>
        /// <param name="pageIndex">vị trí trang</param>
        /// <param name="filter">lọc chuỗi</param>
        /// <returns>
        /// Danh sách bản ghi
        /// </returns>
        /// CreatedBy: LMDuc (11/05/2021)
        public Pagging <Employee> GetEmployees(int pageSize, int pageIndex, string filter)
        {
            //Khởi tạo trang
            var res = new Pagging <Employee>()
            {
                Page     = pageIndex,
                PageSize = pageSize
            };

            using (dbConnection = new MySqlConnection(connectionString))
            {
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@filter", filter);
                // Tính tổng nhân viên.
                int?totalRecord = dbConnection.QueryFirstOrDefault <int>("Proc_GetTotalEmployees", parameters, commandType: CommandType.StoredProcedure);
                if (totalRecord == null)
                {
                    return(res);
                }
                res.TotalRecord = totalRecord;
                // Lấy danh sách nhân viên.
                DynamicParameters dynamicParameters = new DynamicParameters();
                dynamicParameters.Add("@pageIndex", pageIndex);
                dynamicParameters.Add("@pageSize", pageSize);
                dynamicParameters.Add("@filter", filter);
                var employees = dbConnection.Query <Employee>("Proc_GetEmployeeFilter", dynamicParameters, commandType: CommandType.StoredProcedure);
                res.Data = employees;
                return(res);
            }
        }
        public IEnumerable <Post> GetPosts(Pagging pagging)
        {
            IEnumerable <Post> requiredPosts = null;

            using var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted });
            requiredPosts   = _dataContext.Set <Post>()
                              .AsNoTracking()
                              .Skip((pagging.CurrentPage - 1) * pagging.PageSize).Take(pagging.PageSize).ToList();
            scope.Complete();
            return(requiredPosts);
        }
 /// <summary>
 /// Phân trang
 /// </summary>
 /// <param name="pagging"></param>
 /// <returns></returns>
 /// Created by: TMQuy
 public IEnumerable <Employee> Pagging(Pagging pagging)
 {
     using (dbConnection = new MySqlConnection(connectingDB))
     {
         var sqlCommad           = "Proc_PaggingEmployee";
         DynamicParameters param = new DynamicParameters();
         param.Add("@m_Page", pagging.pageIndex);
         param.Add("@m_PageSize", pagging.pageSize);
         param.Add("@fillter", pagging.fillter);
         var employees = dbConnection.Query <Employee>(sqlCommad, param: param, commandType: CommandType.StoredProcedure);
         return(employees);
     }
 }
Exemple #6
0
        /// <summary>
        /// Lọc dữ liệu phân trang
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public Pagging <Customer> GetCustomers(CustomerFilter filter)
        {
            // Thiết lập kết nối cơ sở dữ liệu.
            var connection = new MySqlConnection(connectionString);

            // Tính tổng số khách hàng có điều kiện.
            var totalRecord = connection.QueryFirstOrDefault <int>("Proc_D_GetTotalCustomer", filter, commandType: CommandType.StoredProcedure);

            // Lấy danh sách khách hàng có phân trang.
            var customers = connection.Query <Customer>("Proc_CustomerFilter", filter, commandType: CommandType.StoredProcedure);

            // trả dữ liệu.
            var paging = new Pagging <Customer>()
            {
                totalRecord = totalRecord,
                data        = customers,
                pageIndex   = filter.PageIndex,
                pageSize    = filter.PageSize
            };

            return(paging);


            /*  Pagging<Customer> pageNew = new Pagging<Customer>();
             *
             * var sqlCommand = "Proc_PaggingCustomers";
             * var customers = dbConnection.Query<Customer>(sqlCommand, param: filter, commandType: CommandType.StoredProcedure);
             * var totalPages = 1;
             * if (customers.Count() % 10 == 0)
             * {
             *    totalPages = customers.Count() / 10;
             * }
             * else
             * {
             *    totalPages = (customers.Count() / 10) + 1;
             * }
             * pageNew = new Pagging<Customer>
             * {
             *    totalRecord = customers.Count(),
             *    totalPages = totalPages,
             *    pageIndex = filter.PageIndex,
             *    data = customers,
             *    pageSize = filter.PageSize
             * };
             * pageNew.data = customers;
             * return pageNew;*/
        }
        public Pagging<Customer> GetCustomers(CustomerFilter filter)
        {
            using (dbConnection = new MySqlConnection(connectionString))
            {
                Pagging<Customer> pageNew = new Pagging<Customer>();
                //DynamicParameters dynamicParameters = new DynamicParameters();
                //dynamicParameters.Add("@page", filter.Page);
                //dynamicParameters.Add("@pageSize", filter.PageSize);
                //dynamicParameters.Add("@filter", filter.filter);
                //dynamicParameters.Add("@customerGroupId", filter.CustomerGroupId);

                var sqlCommand = "Proc_PaggingCustomers";
                var customers = dbConnection.Query<Customer>(sqlCommand, param: filter, commandType: CommandType.StoredProcedure);

                //var totalRecord = dbConnection.QueryFirstOrDefault<int>("Proc_GetTotalCustomers", param: dynamicParameters, commandType: CommandType.StoredProcedure);
                var totalPages = 1;
                if (customers.Count() % 10 == 0)
                {
                    totalPages = customers.Count() / 10;
                }
                else
                {
                    totalPages = (customers.Count() / 10) + 1;
                }
                pageNew = new Pagging<Customer>
                {
                    totalRecord = customers.Count(),
                    totalPages = totalPages,
                    pageIndex = filter.Page,
                    data = customers,
                    pageSize = filter.PageSize
                };
                pageNew.data = customers;
                return pageNew;
            }
        }
 public IEnumerable <Post> Posts(Pagging pagging)
 {
     return(_postDataService.GetPosts(pagging));
 }
Exemple #9
0
        public JsonResult GetListQuestion(int accountId, int examId, int page)
        {
            string functionName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            try
            {
                if (!_accountRepository.AccountExists(accountId))
                {
                    Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.accountNotFound));
                    return(Json(MessageResult.GetMessage(MessageType.ACCOUNT_NOT_FOUND)));
                }

                //Check id exam exist in the database
                if (!_examRepository.ExamExist(examId))
                {
                    Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.groupNotFound));
                    return(Json(MessageResult.GetMessage(MessageType.GROUP_NOT_FOUND)));
                }

                if (!ModelState.IsValid)
                {
                    Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(Constants.notFound));
                    return(Json(MessageResult.GetMessage(MessageType.NOT_FOUND)));
                }

                //This is get all questions of the exam by id exam
                List <ExamQuestionEntity> examQuestionEntity = _examQuestionRepository.getListQuestions(examId);
                List <AnswerUserEntity>   answerUsers        = _answerUserRepository.GetAnswerUserEntities(accountId);

                List <QuestionEntity> listQuestionEntities = new List <QuestionEntity>();
                foreach (var examQuestion in examQuestionEntity)
                {
                    // Get all informations of the question by questionId and save it in the list
                    QuestionEntity questionEntity = _questionRepository.getQuestionInformation(examQuestion.QuestionId);
                    listQuestionEntities.Add(questionEntity);
                }

                List <QuestionListResult> questionLists = new List <QuestionListResult>();
                foreach (var item in listQuestionEntities)
                {
                    QuestionListResult q = new QuestionListResult();
                    q.questionId    = item.QuestionId;
                    q.part          = item.Part;
                    q.image         = item.Image;
                    q.fileMp3       = item.FileMp3;
                    q.questionName  = item.QuestionName;
                    q.A             = item.A;
                    q.B             = item.B;
                    q.C             = item.C;
                    q.D             = item.D;
                    q.correctAnswer = item.CorrectAnswer;
                    q.team          = item.Team;
                    foreach (var answer in answerUsers)
                    {
                        if (q.questionId == answer.QuestionId)
                        {
                            q.answerUser = answer.AnswerKey;
                        }
                    }
                    questionLists.Add(q);
                }

                List <QuestionListResult> pagging = Pagging.GetQuestions(page, questionLists);

                return(Json(pagging));
            }
            catch (Exception ex)
            {
                Log4Net.log.Error(className + "." + functionName + " - " + Log4Net.AddErrorLog(ex.Message));
                return(Json(MessageResult.ShowServerError(ex.Message)));
            }
        }
Exemple #10
0
        public IActionResult Pagging([FromQuery] Pagging pagging)
        {
            var employees = _employeeService.Pagging(pagging);

            return(Ok(employees));
        }
        /// <summary>
        /// Phân trang
        /// </summary>
        /// <param name="pagging"></param>
        /// <returns></returns>
        /// Created by: TMQuy
        public IEnumerable <Employee> Pagging(Pagging pagging)
        {
            var employees = _employeeRepository.Pagging(pagging);

            return(employees);
        }
Exemple #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!IsPostBack)
                {
                    int _pageIndex = Lib.QueryString.PageIndex;
                    _pageIndex = _pageIndex == 0 ? 1 : _pageIndex;
                    _catID     = Lib.QueryString.CategoryID;

                    long news_ID = Lib.QueryString.NewsID;



                    //_catID = Lib.QueryString.ParentCategory==0 ? Lib.QueryString.ParentCategory : Lib.QueryString.CategoryID;
                    DataTable objCat = XpcHelper.SelectCategory(_catID);


                    if (objCat != null && objCat.Rows.Count > 0)
                    {
                        CatName = string.Format("<a title=\"{1}\" href=\"{0}\">{1}</a>", objCat.Rows[0]["Cat_URL"], objCat.Rows[0]["Cat_Name"]);
                        CatRSS  = string.Format("<a title=\"{1}\" target=\"_blank\" class=\"rss\" href=\"{0}\"><img src=\"/images/IconRSS.gif\"/></a>", objCat.Rows[0]["RSS_URL"], objCat.Rows[0]["Cat_Name"]);
                        Utility.SetPageHeader(this.Page, objCat.Rows[0]["Cat_Name"].ToString(), objCat.Rows[0]["Cat_Name"] + "-" + ", " + objCat.Rows[0]["Cat_displayURL"], objCat.Rows[0]["Cat_Name"] + ", " + objCat.Rows[0]["Cat_displayURL"], Lib.QueryString.PageIndex > 1);
                        //Đặt SEO cho Facebook
                        Utility.SetFaceBookSEO(this.Page, objCat.Rows[0]["Cat_Name"].ToString(), objCat.Rows[0]["Cat_Name"] + "-" + ", " + objCat.Rows[0]["Cat_displayURL"], System.Configuration.ConfigurationManager.AppSettings["WebDomain"] + "/images/BannerHome.png", System.Configuration.ConfigurationManager.AppSettings["WebDomain"] + "/" + objCat.Rows[0]["Cat_URL"]);
                    }

                    if (news_ID != 0)
                    {
                        DataTable detail = XpcHelper.displayMicrof_Detail(news_ID);
                        if (detail != null && detail.Rows.Count > 0)
                        {
                            DataRow dtRow  = detail.Rows[0];
                            string  noHTML = Regex.Replace(dtRow["News_Content"].ToString(), @"<[^>]+>|&nbsp;", "").Trim();
                            ltrBigVideo.Text       = "<iframe width=\"595\" height=\"351\" src=\"" + noHTML + "\" frameborder=\"0\" allowfullscreen=\"\"></iframe>";
                            ltrBigTitle.Text       = dtRow["News_Title"].ToString();
                            ltrDateTime.Text       = dtRow["PublishDate"].ToString();
                            ltrBigInitContent.Text = dtRow["News_InitContent"].ToString();

                            string Seo_Title   = dtRow["News_Title"].ToString();
                            string Seo_Des     = dtRow["News_InitContent"].ToString();
                            string Seo_KeyWord = !String.IsNullOrEmpty(dtRow["Extension3"].ToString()) ? dtRow["Extension3"].ToString() : "";

                            Utility.SetPageHeaderDetail(this.Page, Seo_Title, objCat.Rows[0]["Cat_Name"].ToString(), Seo_Des, Seo_KeyWord);
                        }
                    }
                    DataTable objTintuc = XpcHelper.displayGetDanhSachTin(_catID, 1, 5, 70);
                    if (objTintuc != null && objTintuc.Rows.Count > 0)
                    {
                        if (news_ID == 0)
                        {
                            DataRow dtRow  = objTintuc.Rows[0];
                            string  noHTML = Regex.Replace(dtRow["News_Content"].ToString(), @"<[^>]+>|&nbsp;", "").Trim();
                            ltrBigVideo.Text       = "<iframe width=\"595\" height=\"351\" src=\"" + noHTML + "\" frameborder=\"0\" allowfullscreen=\"\"></iframe>";
                            ltrBigTitle.Text       = dtRow["News_Title"].ToString();
                            ltrDateTime.Text       = dtRow["PublishDate"].ToString();
                            ltrBigInitContent.Text = dtRow["News_InitContent"].ToString();
                        }


                        rptData.DataSource = objTintuc;
                        rptData.DataBind();
                    }

                    DataTable objVideoTongHop = XpcHelper.displayGetDanhSachTin(_catID, _pageIndex, _pageSize, 120);
                    if (objVideoTongHop != null && objVideoTongHop.Rows.Count > 0)
                    {
                        rptListVideo.DataSource = objVideoTongHop;
                        rptListVideo.DataBind();
                    }
                    Pagging.TotalPage = XpcHelper.GetDanhSachTinCount(_catID);
                    Pagging.DoPagging(_pageIndex);
                }
            }
        }
Exemple #13
0
 public ActionResult Listar([FromBody] Pagging pagging)
 {
     return(Ok());
 }
Exemple #14
0
        public async Task <ICollection <Elanat> > GetAllElanatsPaged(paggingData paggingData)
        {
            if (paggingData.Expression.IsNullOrEmpty())
            {
                paggingData.Expression = "";
            }
            if (paggingData.SortBy.IsNullOrEmpty())
            {
                paggingData.SortBy = "ElanatId";
            }
            var list = _entity.Where(c => c.MessageTopic.Contains(paggingData.Expression) || c.MessageText.Contains(paggingData.Expression))
                       .OrderBy(c => c.ElanatId);



            if (paggingData.SortMethod == "asc")
            {
                switch (paggingData.SortBy)
                {
                case "messageTopic":
                    list = list.OrderBy(c => c.MessageTopic);
                    break;

                case "messageText":
                    list = list.OrderBy(c => c.MessageText);
                    break;

                case "dateFrom":
                    list = list.OrderBy(c => c.DateFrom);
                    break;

                case "dateTo":
                    list = list.OrderBy(c => c.DateTo);
                    break;
                //case "DesLevel":
                //    list = list.OrderBy(c => c.DesLevel);
                //    break;

                default:
                    list = list.OrderBy <Elanat>(paggingData.SortBy);
                    break;
                }
            }
            else
            {
                switch (paggingData.SortBy)
                {
                case "messageTopic":
                    list = list.OrderByDescending(c => c.MessageTopic);
                    break;

                case "messageText":
                    list = list.OrderByDescending(c => c.MessageText);
                    break;

                case "dateFrom":
                    list = list.OrderByDescending(c => c.DateFrom);
                    break;

                case "dateTo":
                    list = list.OrderByDescending(c => c.DateTo);
                    break;

                default:

                    list = list.OrderBy <Elanat>(paggingData.SortBy + " descending");
                    break;
                }
            }

            return(await Pagging.PagedResult(list, paggingData).ToListAsync());
        }
Exemple #15
0
 public IList <Pessoa> List(Pagging pagging)
 {
     return(_pessoaCollection.Find("").Skip((pagging.CurrentPage - 1) * pagging.CurrentPage).Limit(pagging.PageSize).ToList());
 }