Ejemplo n.º 1
0
        public void LoadResponseForm()
        {
            ReportShow  rp = BUS_AdminData.Instance.BUS_GetReportByReportId(reportId);
            AccountShow ac = BUS_AdminData.Instance.BUS_GetAccountByAccountId(rp.getAccountId());

            txb_classSV.Text        = ac.@class;
            txb_nameSV.Text         = ac.fullName;
            txbRoomId.Text          = roomId.ToString();
            txbEquipmentName.Text   = equipmentName;
            txbEquipmentStatus.Text = equipmentStatus;
            rtbNote.Text            = note;
            dtpReportedDate.Value   = Convert.ToDateTime(reportDate);
        }
Ejemplo n.º 2
0
        public JsonResult getAllUser()
        {
            try
            {
                int    length         = int.Parse(Request.Query["length"]);
                int    start          = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(int.Parse(Request.Query["start"]) / length))) + 1;
                string searchValue    = Request.Query["search[value]"];
                string sortColumnName = Request.Query["columns[" + Request.Query["order[0][column]"] + "][name]"];
                string sortDirection  = Request.Query["order[0][dir]"];


                AccountPaging apg = new AccountPaging();
                apg.data = new List <AccountShow>();
                start    = (start - 1) * length;
                List <Account> listAccount = _context.Accounts.ToList <Account>();
                apg.recordsTotal = listAccount.Count;
                //filter
                if (!string.IsNullOrEmpty(searchValue))
                {
                    listAccount = listAccount.Where(x => x.UserName.ToLower().Contains(searchValue.ToLower()) ||
                                                    x.Email.ToLower().Contains(searchValue.ToLower()) ||
                                                    x.FullName.ToLower().Contains(searchValue.ToLower()) ||
                                                    x.PhoneNumber.ToLower().Contains(searchValue.ToLower())
                                                    ).ToList <Account>();
                }
                //sorting

                if (sortDirection == "asc")
                {
                    listAccount = listAccount.OrderBy(x => x.GetType().GetProperty(sortColumnName).GetValue(x)).ToList <Account>();
                }
                else
                {
                    listAccount = listAccount.OrderByDescending(x => x.GetType().GetProperty(sortColumnName).GetValue(x)).ToList <Account>();
                }
                apg.recordsFiltered = listAccount.Count;
                //paging
                listAccount = listAccount.Skip(start).Take(length).ToList <Account>();
                apg.data    = new List <AccountShow>();
                for (int i = 0; i < listAccount.Count(); i++)
                {
                    AccountShow acs = new AccountShow
                    {
                        UserName    = listAccount[i].UserName,
                        FullName    = listAccount[i].FullName,
                        PhoneNumber = listAccount[i].PhoneNumber,
                        Email       = listAccount[i].Email,
                        DOB         = listAccount[i].DOB,
                        Active      = listAccount[i].Active,
                        Role        = string.Join(",", _context.Account_Roles.Where(x => x.UserName == listAccount[i].UserName).Select(x => x.RoleName).ToList()),
                        ClassCheck  = listAccount[i].Active?"fa-user-check" : "fa-user-lock"
                    };
                    apg.data.Add(acs);
                }
                apg.draw = int.Parse(Request.Query["draw"]);
                return(Json(apg));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }