Esempio n. 1
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            //var result = await SignInManager.PasswordSignInAsync(model.sta_username, model.sta_password, model.RememberMe, shouldLockout: false);
            //switch (result)
            //{
            //    case SignInStatus.Success:
            //        return RedirectToLocal(returnUrl);
            //    case SignInStatus.LockedOut:
            //        return View("Lockout");
            //    case SignInStatus.RequiresVerification:
            //        return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
            //    case SignInStatus.Failure:
            //    default:
            //        ModelState.AddModelError("", "Invalid login attempt.");
            //        return View(model);
            //}

            var db = new DBQLNSContext();

            if (db.staffs.Any(u => u.sta_username == model.sta_username && u.sta_password == model.sta_password))
            {
                var ident = new ClaimsIdentity(
                    new[] {
                    // adding following 2 claim just for supporting default antiforgery provider
                    new Claim(ClaimTypes.NameIdentifier, model.sta_username),
                    new Claim("http://schemas.Microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity", "http://www.w3.org/2001/XMLSchema#string"),

                    new Claim(ClaimTypes.Name, model.sta_username),

                    // optionally you could add roles if any
                    new Claim(ClaimTypes.Role, "Admin"),
                    new Claim(ClaimTypes.Role, "User"),
                },
                    DefaultAuthenticationTypes.ApplicationCookie);

                HttpContext.GetOwinContext().Authentication.SignIn(
                    new AuthenticationProperties {
                    IsPersistent = false
                }, ident);
                return(RedirectToAction("Index", "staffs", new { area = "TTNhom_QLNS" })); // auth succeed
            }
            // invalid username or password
            ModelState.AddModelError("", "invalid username or password");
            return(View());
        }
Esempio n. 2
0
        public ActionResult Dashboardv1()
        {
            //QUẢN LÝ THPT
            List <DIEM> hs = dbTHPTcontext.DIEMs.ToList();

            ViewBag.HocSinh = hs;

            ViewBag.totalStudent    = (from s in dbTHPTcontext.HOCSINHs select s).Count();
            ViewBag.totalStudentXS  = (from s in dbTHPTcontext.DIEMs where s.HocLuc == "Xuất Sắc" select s).Count();
            ViewBag.totalStudentG   = (from s in dbTHPTcontext.DIEMs where s.HocLuc == "Giỏi" select s).Count();
            ViewBag.totalStudentK   = (from s in dbTHPTcontext.DIEMs where s.HocLuc == "Khá" select s).Count();
            ViewBag.totalStudentTB  = (from s in dbTHPTcontext.DIEMs where s.HocLuc == "Trung Bình" select s).Count();
            ViewBag.totalStudentY   = (from s in dbTHPTcontext.DIEMs where s.HocLuc == "Yếu" select s).Count();
            ViewBag.totalStudentDUT = (from s in dbTHPTcontext.HOCSINHs where s.MaDUT != 1 select s).Count();
            ViewBag.totalTeacher    = (from t in dbTHPTcontext.HOCSINHs select t).Count();
            ViewBag.totalClass      = (from c in dbTHPTcontext.HOCSINHs select c).Count();

            // QL_NhanSu
            DBQLNSContext dBQLNS = new DBQLNSContext();

            ViewBag.TotalStaffON  = dBQLNS.staffs.Where(x => x.sta_status == 1).Count();
            ViewBag.TotalStaffOFF = dBQLNS.staffs.Where(x => x.sta_status == 0).Count();
            var gr_admin = dBQLNS.group_role.Where(x => x.gr_name == "Admin").FirstOrDefault();
            var gr_user  = dBQLNS.group_role.Where(x => x.gr_name == "User").FirstOrDefault();

            if (gr_admin != null)
            {
                ViewBag.TotalQL = dBQLNS.staffs.Where(x => x.group_role_id == gr_admin.gr_id).Count();
            }
            if (gr_user != null)
            {
                ViewBag.TotalND = dBQLNS.staffs.Where(x => x.group_role_id == gr_user.gr_id).Count();
            }


            // QL_ThuVien
            DBQLTVContext dbQLTV    = new DBQLTVContext();
            var           totalBook = (from b in dbQLTV.Saches
                                       select b).Count();

            var totalCategory = (from c in dbQLTV.TheLoais
                                 select c).Count();

            var totalPublishingCompany = (from c in dbQLTV.NhaXuatBans
                                          select c).Count();

            var totalAuthor = (from a in dbQLTV.TacGias
                               select a).Count();

            var totalReader = (from r in dbQLTV.DocGias
                               select r).Count();

            var totalBG = (from bg in dbQLTV.MuonTraSaches
                           select bg).Count();

            var alreadyBG = (from bg in dbQLTV.MuonTraSaches
                             where bg.DaTra == true
                             select bg).Count();

            var yetBG = (from bg in dbQLTV.MuonTraSaches
                         where bg.DaTra == false
                         select bg).Count();

            ViewBag.TotalBook              = totalBook;
            ViewBag.TotalCategory          = totalCategory;
            ViewBag.TotalPublishingCompany = totalPublishingCompany;
            ViewBag.TotalAuthor            = totalAuthor;
            ViewBag.TotalReader            = totalReader;
            ViewBag.TotalBG   = totalBG;
            ViewBag.AlreadyBG = alreadyBG;
            ViewBag.YetBG     = yetBG;

            // QL_Kho
            DBQLKHOContext dbQLKHO = new DBQLKHOContext();
            var            HH      = (from b in dbQLKHO.HANGHOAs
                                      select b).Count();

            var KH = (from c in dbQLKHO.KHACHHANGs
                      select c).Count();

            var NCC = (from c in dbQLKHO.NHACCs
                       select c).Count();

            var PN = (from a in dbQLKHO.PHIEUNHAPs
                      select a).Count();

            var PX = (from r in dbQLKHO.PHIEUXUATs
                      select r).Count();

            ViewBag.HH  = HH;
            ViewBag.KH  = KH;
            ViewBag.NCC = NCC;
            ViewBag.PN  = PN;
            ViewBag.PX  = PX;

            // QL_KhachSan

            QLKSdbContext dbQLKS = new QLKSdbContext();

            ViewBag.NhanVien = dbQLKS.NhanViens.Count();
            // số lượng khách hàng
            ViewBag.KhachHang = dbQLKS.KhachHangs.Count();
            // thu lãi ngày
            ViewBag.ThuNgay = Convert.ToDecimal((dbQLKS.PhieuThus.Where(p => p.ngaytao.Value.Day == DateTime.Now.Day).Sum(p => p.tongtien)));
            // chi tiề ngày
            ViewBag.ChiNgay = Convert.ToDecimal((dbQLKS.PhieuChis.Where(p => p.ngaytao.Value.Day == DateTime.Now.Day).Sum(p => p.tongtien)));
            // thu lãi tháng
            ViewBag.ThuThang = Convert.ToDecimal((dbQLKS.PhieuThus.Where(p => p.ngaytao.Value.Month == DateTime.Now.Month).Sum(p => p.tongtien)));
            // chi tiền tháng
            ViewBag.ChiThang = Convert.ToDecimal((dbQLKS.PhieuChis.Where(p => p.ngaytao.Value.Month == DateTime.Now.Month).Sum(p => p.tongtien)));

            // QL_TruongTHPT

            return(View());
        }