private bool IsInConfirmTime(Student student)
        {
            StartConfirmDate = DateTime.MaxValue;
            EndConfirmDate = DateTime.MinValue;
            if (student.StudentClass.RegisterTimes.Count > 0)
            {
                foreach (RegisterTime regTime in student.StudentClass.RegisterTimes)
                {

                    if (regTime.Active)
                    {
                        if ((regTime.ConfirmDateStart <= DateTime.Now) && (regTime.ConfirmDateEnd.AddDays(1) >= DateTime.Now))
                        {
                            return true;
                        }
                        else
                        {
                            StartConfirmDate = StartConfirmDate > regTime.ConfirmDateStart ? regTime.ConfirmDateStart : StartConfirmDate;
                            EndConfirmDate = EndConfirmDate < regTime.ConfirmDateEnd ? regTime.ConfirmDateEnd : EndConfirmDate;
                        }
                    }
                }
                return false;
            }
            return false;
        }
        private bool IsInDeptStudent(ObjectSpace objectSpace, Student student, out decimal deptAmount)
        {
            deptAmount = 0;
            try
            {
                ConstrainstParameter cp = objectSpace.FindObject<ConstrainstParameter>(
                   new BinaryOperator("Code", "MINDEPTCANENROLL"));

                deptAmount = -Convert.ToDecimal(student.AccountBalance.Value);
                if (deptAmount > Convert.ToDecimal(cp.Value))
                    return true;
            }
            catch { }
            finally { }
            return false;
        }
Esempio n. 3
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            NestedUnitOfWork UOW = this.Session.BeginNestedUnitOfWork();
            UOW.BeginTransaction();
            //khoi tao quan tai khoan quan tri he thong (mau)
            User systemAmdmin = UOW.FindObject<User>(new BinaryOperator("UserName", "SystemAdmin"));
            if (systemAmdmin == null)
            {
                systemAmdmin = new User(UOW);
                systemAmdmin.UserName = "******";
                systemAmdmin.SetPassword("SystemAdmin");
            }
            //khoi tao quan tai khoan sinh vien (mau)
            Student student = UOW.FindObject<Student>(new BinaryOperator("UserName", "SampleStudent"));
            if (student == null)
            {
                student = new Student(UOW);
                student.UserName = "******";
                student.SetPassword("SampleStudent");
            }
            User guest = UOW.FindObject<User>(new BinaryOperator("UserName", "guest"));
            if (guest == null)
            {
                guest = new User(UOW);
                guest.UserName = "******";
                guest.SetPassword("guest");
            }
            //khoi tao quan tai khoan quan quan ly dao tao
            User dataAdmin = UOW.FindObject<User>(new BinaryOperator("UserName", "DataAdmin"));
            if (dataAdmin == null)
            {
                dataAdmin = new User(UOW);
                dataAdmin.UserName = "******";
                dataAdmin.SetPassword("DataAdmin");
            }

            // If a role with the Administrators name does not exist in the database, create this role
            Role adminRole = UOW.FindObject<Role>(new BinaryOperator("Name", "Administrators"));
            if (adminRole == null)
            {
                adminRole = new Role(UOW);
                adminRole.Name = "Administrators";
            }
            // If a role with the Users name does not exist in the database, create this role
            Role userRole = UOW.FindObject<Role>(new BinaryOperator("Name", "Users"));
            if (userRole == null)
            {
                userRole = new Role(UOW);
                userRole.Name = "Users";
            }

            // If a role with the Users name does not exist in the database, create this role
            Role dataRole = UOW.FindObject<Role>(new BinaryOperator("Name", "DataAdmins"));
            if (dataRole == null)
            {
                dataRole = new Role(UOW);
                dataRole.Name = "DataAdmins";
            }

            Role studentRole = UOW.FindObject<Role>(new BinaryOperator("Name", "Students"));
            if (studentRole == null)
            {
                studentRole = new Role(UOW);
                studentRole.Name = "Students";
            }

             //Delete all permissions assigned to the Administrators and Users roles

            while (adminRole.PersistentPermissions.Count > 0)
            {
                UOW.Delete(adminRole.PersistentPermissions[0]);
            }
            while (userRole.PersistentPermissions.Count > 0)
            {
                UOW.Delete(userRole.PersistentPermissions[0]);
            }
            while (dataRole.PersistentPermissions.Count > 0)
            {
                UOW.Delete(dataRole.PersistentPermissions[0]);
            }
            while (studentRole.PersistentPermissions.Count > 0)
            {
                UOW.Delete(studentRole.PersistentPermissions[0]);
            }
            UOW.PurgeDeletedObjects();

            // Allow full access to all objects to the Administrators role
            adminRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.AllAccess));
            // Allow editing the Application Model to the Administrators role
            adminRole.AddPermission(new EditModelPermission(ModelAccessModifier.Allow));
            // Save the Administrators role to the database
            adminRole.Save();

            // Allow full access to all objects to the DataAdmins role
            dataRole.AddPermission(new ObjectAccessPermission(typeof(object), ObjectAccess.AllAccess));
            // Allow editing the Application Model to the Administrators role
            dataRole.AddPermission(new EditModelPermission(ModelAccessModifier.Allow));
            // Save the Administrators role to the database
            dataRole.Save();

            AddRoleToUser(userRole);
            // Allow full access to all objects to the Users role

            userRole.Save();
            AddRoleToStudent(studentRole);
            studentRole.Save();
            // Add the Administrators role to the user1
            systemAmdmin.Roles.Add(adminRole);
            dataAdmin.Roles.Add(dataRole);
            student.Roles.Add(studentRole);
            guest.Roles.Add(userRole);
            systemAmdmin.Save();
            dataAdmin.Save();
            student.Save();
            guest.Save();

            UOW.CommitTransaction();

            //First Mynote
            MyNote mynote = this.Session.FindObject<MyNote>(new BinaryOperator("Title", "Welcome"));
            if ((mynote == null))
            {
                mynote = new MyNote(Session);
                mynote.Title = "Welcome";
                mynote.Intro = "Welcome all to visit our website!!! ";
                mynote.FullContent = "Change full content here!!! ";
                mynote.Save();
            }

            //create report
            CreateReport("Bảng điểm nhóm MH");
            CreateReport("Bảng điểm nhóm MH (tách lớp sv)");
            CreateReport("Bảng điểm nhóm MH (theo nhóm lớp)");
            CreateReport("Danh sách lớp biên chế");
            CreateReport("Danh sách sinh viên theo lớp");
            CreateReport("Điểm học kỳ");
            CreateReport("Điểm học tập");
            CreateReport("Điểm tích lũy");
            CreateReport("DTBHKReport");
            CreateReport("Giao dịch học phí sinh viên");
            CreateReport("Kết quả ĐK 1 SV");
            CreateReport("Kết quả ĐK tất cả SV");
            CreateReport("Kết quả KT ĐK lớp biên chế");
            CreateReport("Kết quả KT ĐK tất cả SV");
            CreateReport("Kết quả học tập");
            CreateReport("Lịch giảng viên");
            CreateReport("Lịch lớp biên chế");
            CreateReport("Lịch môn học");
            CreateReport("Lịch phòng học cơ sở");
            CreateReport("Lịch phòng học");
            CreateReport("Lịch sinh viên");
            CreateReport("Tỉ lệ nợ lớp biên chế NHHK");
            CreateReport("Tỉ lệ nợ sinh viên lớp biên chế");
            CreateParam();
        }