Esempio n. 1
0
        /// <summary>
        /// Đổi mật khẩu người dùng đã đăng nhập
        /// </summary>
        /// <returns></returns>
        public ActionResult ChangePass()
        {
            if (ses.isLogin() != 0)
            {
                Response.Redirect("/admin/login");
            }
            if (ses.isLogin() != 0)
            {
                //unlogined yet
                //                ses.gotoPage("/staff/login", "Thông báo", "Không có quyền thực hiện chức năng", 3000);
                return(Redirect("/home/index"));
            }
            dynamic defaultobject = new ExpandoObject();

            defaultobject.codeview = ses.loginName;
            defaultobject.thetype  = ses.loginType;
            ViewBag.defaultvalue   = JsonConvert.SerializeObject(defaultobject);
            string[] jsx =
            {
                "/jsx/Admin/Changepass/Changepass.jsx"
                , "/jsx/Admin/Changepass/App.jsx"
            };
            ViewBag.jsx = jsx;
            return(View("Adminindex"));
        }
Esempio n. 2
0
        public ActionResult Header()
        {
            bool isLoged = (ses.isLogin() == 0);

            ViewBag.isloged        = isLoged;
            ViewBag.departmentname = ses.loginDepartmentName;
            ViewBag.loginname      = ses.loginFullName;
            ViewBag.loginImg       = string.IsNullOrEmpty(ses.loginImg) ? "Content/sysimage/noimage.png" : ses.loginImg;
            if (!System.IO.File.Exists(Server.MapPath("/") + ViewBag.loginImg))
            {
                ViewBag.loginImg = "noimage.jpg";
            }
            return(View());
        }
Esempio n. 3
0
        /// <summary>
        /// Lấy danh sách các đơn vị với đơn vị cấp trên được xác định
        /// </summary>
        public JsonResult Getlist(int page, int pageSize, string codeView, bool typeCodeView, string name, bool typeName,
                                  string note, bool typeNote)
        {
            if (_ses.isLogin() < 0)
            {
                return(Json(new { ret = -1 }, JsonRequestBehavior.AllowGet));
            }
            //mặc định cho phần trang
            if (pageSize == 0)
            {
                pageSize = AppConfig.item4page();
            }
            if (page < 1)
            {
                page = 1;
            }
            //Khai báo lấy dữ liệu
            SUBJECT_BUS      bus  = new SUBJECT_BUS();
            List <fieldpara> lipa = new List <fieldpara>();

            if (!string.IsNullOrEmpty(codeView))
            {
                lipa.Add(typeCodeView ? new fieldpara("CODEVIEW", codeView, 1) : new fieldpara("CODEVIEW", codeView, 0));
            }
            if (!string.IsNullOrEmpty(name))
            {
                lipa.Add(typeName ? new fieldpara("NAME", name, 0) : new fieldpara("NAME", name, 1));
            }
            if (!string.IsNullOrEmpty(note))
            {
                lipa.Add(typeNote ? new fieldpara("NOTE", note, 0) : new fieldpara("NOTE", note, 1));
            }
            lipa.Add(new fieldpara("UNIVERSITYCODE", _ses.gUNIVERSITYCODE, 0));
            //lipa.Add(new fieldpara("LOCK", 0, 0));
            int countpage;
            //order by theorder, with pagesize and the page
            var data = bus.getAllBy2("CODEVIEW", pageSize, page, out countpage, lipa.ToArray());
            // tất cả các bản ghi
            List <SUBJECT_OBJ> totalData = bus.getAllBy2("CODEVIEW", lipa.ToArray());
            int totalItem = totalData.Count;

            bus.CloseConnection();
            //Chỉ số đầu tiên của trang hiện tại (đã trừ -1)
            int startpage = (page - 1) * pageSize;
            //Trả về client
            var a = JsonConvert.SerializeObject(data);

            return(Json(new
            {
                data,                   //Danh sách
                data2 = a,
                totalItem,              //số lượng bản ghi
                totalPage = countpage,
                startindex = startpage, //bắt đầu số trang
                ret = 0                 //ok
            }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            string sAction     = filterContext.RouteData.Values["action"].ToString();
            string sController = filterContext.RouteData.Values["controller"].ToString();
            string sKeys       = $"{sController.ToUpper()}.{sAction.ToUpper()}";
            string sPermission = "";

            if (dict.ContainsKey(sKeys))
            {
                sPermission = dict[sKeys];
            }
            //Only login require
            if (ses.isLogin() != 0)
            {
                //Chuyển sang form đăng nhập
                filterContext.Result = new RedirectResult("/home/login");
                return;
            }

            if (sPermission != "")
            {
                LoginType = "";
                //Try to get login type
                var filterAttribute = filterContext.ActionDescriptor.GetFilterAttributes(true)
                                      .Where(a => a.GetType() ==
                                             typeof(CustomAuthenticationAttribute));
                if (filterAttribute != null)
                {
                    foreach (CustomAuthenticationAttribute attr in filterAttribute)
                    {
                        LoginType = attr.LoginType;
                    }
                    //List<Role> roles =
                    //((User)filterContext.HttpContext.Session["CurrentUser"]).Roles;
                    //bool allowed = SecurityHelper.IsAccessible(AllowFeature, roles);
                }
                //Kiểm tra xem các phân quyền có chấp nhập được không
                string[] per  = sPermission.Split(',');
                int      iper = 0;
                foreach (var it in per)
                {
                    if (ses.func(it) > 0)
                    {
                        iper++;
                    }
                }
                if (iper == 0)
                {
                    filterContext.Result = new RedirectResult("/home/login");
                }
            }
        }
Esempio n. 5
0
        public JsonResult GetGrade(string classcode)
        {
            //Kiểm tra phân quyền
            List <GRADE_OBJ> li = new List <GRADE_OBJ>();

            if (ses.isLogin() < 0)
            {
                return(Json(new { lst = li, ret = -1 }, JsonRequestBehavior.AllowGet));
            }
            if (classcode != "")
            {
                // tìm đối tượng GRADE_OBJ có code = gradecode
                var       objClass = new CLASS_BUS().GetByID(new CLASS_OBJ.BusinessObjectID(classcode));
                GRADE_BUS bus      = new GRADE_BUS();
                var       objPro   = bus.GetByID(new GRADE_OBJ.BusinessObjectID(objClass.GRADECODE));
                li.Insert(0, objPro);
                bus.CloseConnection();
                //Chỉ số đầu tiên của trang hiện tại (đã trừ -1)
                //Trả về cho client
                return(Json(new { lst = li, ret = 0 }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { lst = li, ret = 0 }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 6
0
        public ActionResult Admin()
        {
            if (ses.isLogin() != 0)
            {
                Response.Redirect("/admin/login");
            }
            dynamic defaultobject = new ExpandoObject();

            defaultobject.thetype = ses.loginType;
            defaultobject.name    = ses.loginFullName;
            ViewBag.defaultvalue  = JsonConvert.SerializeObject(defaultobject);
            string[] jsx =
            {
                "/jsx/Core/home/HomeAdmin.jsx"
            };
            ViewBag.jsx = jsx;
            return(View("Adminindex"));
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="keysearchCodeView"></param>
        /// <param name="keyseacrhName"></param>
        /// <returns></returns>
        public JsonResult Update(CLASS_OBJ obj, string keysearchCodeView, string keyseacrhName)
        {
            CLASS_BUS bus = new CLASS_BUS();

            if (_ses.isLogin() < 0)
            {
                return(Json(new { ret = -1 }, JsonRequestBehavior.AllowGet));
            }
            int       ret;
            int       add = 0;
            CLASS_OBJ objTemp;

            // kiểm tra tồn tại cho trường hợp sửa
            if (!string.IsNullOrEmpty(obj.CODE)) // edit
            {
                objTemp = bus.GetByID(new CLASS_OBJ.BusinessObjectID(obj.CODE));
                if (objTemp == null)
                {
                    ret = -4;
                    bus.CloseConnection();
                    return(Json(new { sussess = ret }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                objTemp = new CLASS_OBJ();
            }
            objTemp.EDITTIME         = DateTime.Now;   // thời điểm sửa bản ghi
            objTemp.EDITUSER         = _ses.loginCode; // người sửa bản ghi
            objTemp.CODEVIEW         = obj.CODEVIEW;
            objTemp.NAME             = obj.NAME;
            objTemp.NOTE             = obj.NOTE;
            objTemp.LOCK             = obj.LOCK;
            objTemp.GRADECODE        = obj.GRADECODE;
            objTemp.STUDENTGROUPTYPE = obj.STUDENTGROUPTYPE;
            objTemp.DEPARTMENTCODE   = "DEPART";
            objTemp.DEPARTMENTCODE2  = "DEPART2";
            objTemp.FEE            = obj.FEE;
            objTemp.AMOUNT         = obj.AMOUNT;
            objTemp.UNIVERSITYCODE = _ses.gUNIVERSITYCODE;
            // kiểm tra tình trạng sửa hay thêm mới
            if (string.IsNullOrEmpty(obj.CODE))
            {
                // thêm mới
                add              = 1;
                objTemp.CODE     = bus.genNextCode(obj);
                objTemp.LOCKDATE = DateTime.Now;
            }
            if (add == 1)
            {
                bus.BeginTransaction();
                ret = bus.insert(objTemp);
                if (ret < 0)
                {
                    bus.RollbackTransaction();
                }
                else
                {
                    bus.CommitTransaction();
                }
            }
            else
            {
                // gán _ID để xác định bản ghi được cập nhật
                objTemp._ID.CODE = obj.CODE;
                ret = bus.update(objTemp);
            }
            int pagecount   = 0;
            int currentpage = 0;

            if (ret >= 0)
            {
                List <fieldpara> lipa = new List <fieldpara>();
                // thêm điều kiện lọc theo codeview nếu nhập
                if (!string.IsNullOrEmpty(keysearchCodeView))
                {
                    lipa.Add(new fieldpara("CODEVIEW", keysearchCodeView, 1));
                }
                // thêm điều kiện lọc theo name nếu nhập
                if (!string.IsNullOrEmpty(keyseacrhName))
                {
                    lipa.Add(new fieldpara("NAME", keyseacrhName, 1));
                }
                // lọc theo đơn vị cấp trên

                lipa.Add(new fieldpara("UNIVERSITYCODE", _ses.gUNIVERSITYCODE, 0));
                objTemp._ID.CODE = objTemp.CODE;
                ret = bus.checkPage(objTemp._ID, " CODE ", AppConfig.item4page(), out pagecount, out currentpage, lipa);
            }
            bus.CloseConnection();
            return(Json(new { ret, pagecount, currentpage }, JsonRequestBehavior.AllowGet));
        }