Exemple #1
0
        public JsonResult DataTable_IgnoreGroups(jQueryDataTableParamModel param, List <String> SubjectID = null, List <String> Class = null, List <String> Check = null, String Search = null, String ShowIgnore = null, String ShowNotIgnore = null)
        {
            if (SubjectID != null && Class != null && Check != null)
            {
                OutputHelper.SaveIgnoreGroups(SubjectID, Class, Check, false);
            }
            Dictionary <String, Group> dbGroups = Clone.Dictionary <String, Group>((Dictionary <String, Group>)(CurrentSession.Get("IgnoreGroups") ?? InputHelper.Groups));
            var Groups = from m in dbGroups.Values select m;
            var total  = Groups.Count();

            if (!string.IsNullOrEmpty(Search))
            {
                Groups = Groups.Where(m => m.MaMonHoc.ToLower().Contains(Search.ToLower()) || m.TenMonHoc.ToLower().Contains(Search.ToLower()));
            }
            if (ShowIgnore != null && ShowNotIgnore != null)
            {
                if (ShowIgnore == "checked" && ShowNotIgnore != "checked")
                {
                    Groups = Groups.Where(m => m.IsIgnored == true);
                }
                if (ShowIgnore != "checked" && ShowNotIgnore == "checked")
                {
                    Groups = Groups.Where(m => m.IsIgnored == false);
                }
                if (ShowIgnore != "checked" && ShowNotIgnore != "checked")
                {
                    Groups = Groups.Where(m => false);
                }
            }

            var Result = new List <string[]>();

            foreach (var su in Groups.OrderBy(m => m.TenMonHoc).Skip(param.iDisplayStart).Take(param.iDisplayLength))
            {
                Result.Add(new string[] {
                    su.MaMonHoc,
                    su.TenMonHoc,
                    su.TenBoMon,
                    su.TenKhoa,
                    su.Nhom.ToString(),
                    su.SoLuongDK.ToString(),
                    su.IsIgnored?"checked":"",
                    //"Xoá"
                }
                           );
            }
            return(Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = total,
                iTotalDisplayRecords = Groups.Count(),
                //iTotalDisplayedRecords = Subjects.Count(),
                aaData = Result
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }
        public JsonResult DataTable_SelectGroups(jQueryDataTableParamModel param, List <String> SubjectID = null, List <String> Class = null, List <int> Group = null, String Search = null)
        {
            if (SubjectID != null && Class != null && Group != null)
            {
                OutputHelper.SaveGroups(SubjectID, Class, Group, false);
            }
            Dictionary <String, Group> dbGroups = Clone.Dictionary <String, Group>((Dictionary <String, Group>)(CurrentSession.Get("Groups") ?? InputHelper.Groups));
            var Groups = from m in dbGroups.Values.Where(g => !g.IsIgnored) select m;
            var total  = Groups.Count();

            if (!string.IsNullOrEmpty(Search))
            {
                Groups = Groups.Where(m => m.MaMonHoc.ToLower().Contains(Search.ToLower()) || m.TenMonHoc.ToLower().Contains(Search.ToLower()));
            }
            var Result = new List <string[]>();

            foreach (var su in Groups.OrderBy(m => m.TenMonHoc).Skip(param.iDisplayStart).Take(param.iDisplayLength))
            {
                Result.Add(new string[] {
                    su.MaMonHoc,
                    su.TenMonHoc,
                    su.TenBoMon,
                    su.TenKhoa,
                    su.Nhom.ToString(),
                    su.SoLuongDK.ToString(),
                    su.GroupID.ToString(),
                    //"Xoá"
                }
                           );
            }
            return(Json(new
            {
                sEcho = param.sEcho,
                iTotalRecords = total,
                iTotalDisplayRecords = Groups.Count(),
                //iTotalDisplayedRecords = Subjects.Count(),
                aaData = Result
            },
                        JsonRequestBehavior.AllowGet
                        ));

            //if (SubjectID != null && Class != null && Group != null)
            //{
            //    OutputHelper.SaveGroups(SubjectID, Class, Group, false);
            //}

            //Dictionary<String, Group> dbGroups = Clone.Dictionary<String, Group>((Dictionary<String, Group>)(CurrentSession.Get("Groups") ?? InputHelper.Groups));
            //var Groups = from m in dbGroups.Values.Where(g => !g.IsIgnored) select m;
            //var total = Groups.Count();
            //if (!string.IsNullOrEmpty(Search))
            //{
            //    Groups = Groups.Where(m => m.MaMonHoc.ToLower().Contains(Search.ToLower()) || m.TenMonHoc.ToLower().Contains(Search.ToLower()));
            //}

            //var Result = new List<string[]>();

            //var MH = (from m in InputHelper.db.This
            //          select new
            //          {
            //              MaMonHoc = m.MaMonHoc,
            //              Nhom = m.Nhom,
            //          });

            //Dictionary<String, List<String>> CheckMH = new Dictionary<string, List<string>>();

            //foreach (var m in MH)
            //{
            //    if (CheckMH.ContainsKey(m.MaMonHoc))
            //        CheckMH[m.MaMonHoc].Add(m.Nhom);
            //    else
            //        CheckMH.Add(m.MaMonHoc, new List<String> { m.Nhom });
            //}

            //foreach (var su in Groups.OrderBy(m => m.TenMonHoc))
            //{
            //    if (CheckMH.ContainsKey(su.MaMonHoc))
            //    {
            //        if (!CheckGroup(CheckMH[su.MaMonHoc], su.Nhom.ToString()))
            //        {
            //            Result.Add(new string[] {
            //                                su.MaMonHoc,
            //                                su.TenMonHoc,
            //                                su.TenBoMon,
            //                                su.TenKhoa,
            //                                su.Nhom.ToString(),
            //                                su.SoLuongDK.ToString(),
            //                                su.GroupID.ToString(),
            //                            }
            //                        );
            //        }
            //    }
            //    else
            //    {
            //        Result.Add(new string[] {
            //                                su.MaMonHoc,
            //                                su.TenMonHoc,
            //                                su.TenBoMon,
            //                                su.TenKhoa,
            //                                su.Nhom.ToString(),
            //                                su.SoLuongDK.ToString(),
            //                                su.GroupID.ToString(),
            //                            }
            //                        );
            //    }

            //}

            //return Json(new
            //                {
            //                    sEcho = param.sEcho,
            //                    iTotalRecords = total,
            //                    iTotalDisplayRecords = Result.Count(),
            //                    //iTotalDisplayedRecords = Subjects.Count(),
            //                    aaData = Result.Skip(param.iDisplayStart).Take(param.iDisplayLength)
            //                },
            //                JsonRequestBehavior.AllowGet
            //            );
        }