public ViewModelBase(
            INavigationService navigationService = null,
            IPageDialogService dialogService     = null,
            ISQLiteHelper sqLiteHelper           = null)
        {
            if (navigationService != null)
            {
                NavigationService = navigationService;
            }
            if (dialogService != null)
            {
                Dialog = dialogService;
            }
            if (sqLiteHelper != null)
            {
                Database = sqLiteHelper;
            }

            BackCommand = new DelegateCommand(BackCommandExecute);

            BCommand = new DelegateCommand(BExecute);

            ACommand = new DelegateCommand(AExecute);

            CCommand = new DelegateCommand(CExecute);
        }
예제 #2
0
        public DataRepository(ISQLiteHelper sqlConnection)
        {
            SQLite.Net.IBlobSerializer serializer = new SQLite.Net.BlobSerializerDelegate(SerializeObject, DeSerializeObject, CanSerialize);
            helper = sqlConnection;

            _db = new SQLiteConnection(sqlConnection.GetPlatform(), sqlConnection.GetDBPath(), false, serializer);
        }
예제 #3
0
        private void DocumentOpenedAction(object sender, DocumentOpenedEventArgs even)
        {
            settings              = ExtensibleStorage.GetTooltipInfo(even.Document.ProjectInformation);
            this.mysql            = new MysqlUtil(settings);
            this.sqlite           = new SQLiteHelper(settings);
            m_previousDocPathName = even.Document.PathName;
            current_doc           = even.Document;

            //过滤测点待使用
            //打开文档就过滤一次
            keyNameToElementMap = new Dictionary <string, Element>();
            BuiltInParameter       testParam   = BuiltInParameter.ALL_MODEL_TYPE_NAME;
            ParameterValueProvider pvp         = new ParameterValueProvider(new ElementId(testParam));
            FilterStringEquals     eq          = new FilterStringEquals();
            FilterRule             rule        = new FilterStringRule(pvp, eq, Res.String_ParameterSurveyType, false);
            ElementParameterFilter paramFilter = new ElementParameterFilter(rule);
            Document document = current_doc;
            FilteredElementCollector elementCollector = new FilteredElementCollector(document).OfClass(typeof(FamilyInstance));
            IList <Element>          elems            = elementCollector.WherePasses(paramFilter).ToElements();

            foreach (var elem in elems)
            {
                string    param_value = string.Empty;
                Parameter param       = elem.get_Parameter(Res.String_ParameterName);
                if (null != param && param.StorageType == StorageType.String)
                {
                    param_value = param.AsString();
                    if (!string.IsNullOrWhiteSpace(param_value))
                    {
                        keyNameToElementMap.Add(param_value, elem);
                    }
                }
            }


            //准备Material
            IEnumerable <Material> allMaterial = new FilteredElementCollector(even.Document).OfClass(typeof(Material)).Cast <Material>();

            foreach (Material elem in allMaterial)
            {
                if (elem.Name.Equals(Res.String_Color_Redline))
                {
                    color_red = elem;
                }
                if (elem.Name.Equals(Res.String_Color_Gray))
                {
                    color_gray = elem;
                }
                if (elem.Name.Equals(Res.String_Color_Blue))
                {
                    color_blue = elem;
                }
                if (color_gray != null && color_red != null && color_blue != null)
                {
                    this.ColorMaterialIsReady = true;
                    break;
                }
            }
        }
예제 #4
0
 public void Show(ISQLiteHelper database, Class cls)
 {
     _db    = database;
     _class = cls;
     EntrySubjectName.Text = cls.Name;
     LabelWrong.IsVisible  = false;
     App.Current.MainPage.Navigation.PushPopupAsync(this);
 }
 public void Show(ISQLiteHelper database, Subject subject)
 {
     _db      = database;
     _subject = subject;
     EntrySubjectName.Text = subject.Name;
     LabelWrong.IsVisible  = false;
     App.Current.MainPage.Navigation.PushPopupAsync(this);
 }
        public StudentScoreTabViewModel(INavigationService navigationService, IPageDialogService dialogService,
                                        ISQLiteHelper sqLiteHelper)
            : base(navigationService, dialogService, sqLiteHelper)
        {
            var user = Database.GetUser();

            _student = Database.Get <Student>(s => s.Id == user.Id);

            LoadPersonalScore();
        }
예제 #7
0
        public void GetScore(ISQLiteHelper db, int subjectId, int semester)
        {
            var score = db.Get <Score>(s =>
                                       s.StudentId == this.Id && s.SubjectId == subjectId && s.Semester == semester);

            if (score != null)
            {
                this.Score = score;
            }
        }
예제 #8
0
        public void CountStudent(ISQLiteHelper db)
        {
            var students = db.GetList <Student>(s => s.ClassId == Id);

            Students = students?.Count() ?? 0;
            Boys     = students?.Count(s => s.Gender == 1) ?? 0;
            Girls    = Students - Boys;

            MaxStudents = db.GetSetting().MaxStudentPerClass;
            IsFull      = Students >= MaxStudents;
        }
        public SettingsPageViewModel(INavigationService navigationService, ISQLiteHelper sqLiteHelper)
            : base(navigationService, sqLiteHelper: sqLiteHelper)
        {
            // Set values
            PageTitle = "Cài đặt";

            // Commands
            SettingCommand = new DelegateCommand(SettingExecute);
            LogOutCommand  = new DelegateCommand(LogOutExecute);

            InitUser();
        }
예제 #10
0
        public bool Login(ISQLiteHelper db, string username, string password)
        {
            var user = _users.FirstOrDefault(u => u.UserName.ToLower().Equals(username.Trim().ToLower()) &&
                                             u.Password.Equals(password));

            if (user == null)
            {
                return(false);
            }

            db.DeleteAll <User>();
            db.Insert(user);

            return(true);
        }
예제 #11
0
        public void GetReportBySubject(ISQLiteHelper db, int subjectId, int semester)
        {
            var students = db.GetList <Student>(s => s.ClassId == Id);
            var settings = db.GetSetting();

            Passes = 0;

            foreach (var student in students)
            {
                student.GetScore(db, subjectId, semester);
                if (student.Score.ScoreAverage >= settings.SubjectPassScore)
                {
                    this.Passes++;
                }
            }
            PassesPercents = (float)Passes / Students * 100;
        }
예제 #12
0
        public void GetReportBySemester(ISQLiteHelper db, int semester)
        {
            var students = db.GetList <Student>(s => s.ClassId == Id);
            var settings = db.GetSetting();

            Passes = 0;

            foreach (var student in students)
            {
                student.GetAvgScore(db);
                if (settings.SubjectPassScore <= (semester == 1 ? student.ScoreAvg1 : student.ScoreAvg2))
                {
                    this.Passes++;
                }
            }
            PassesPercents = (float)Passes / Students * 100;
        }
예제 #13
0
 public ViewModelBase(
     INavigationService navigationService = null,
     IPageDialogService dialogService     = null,
     ISQLiteHelper sqLiteHelper           = null)
 {
     if (navigationService != null)
     {
         NavigationService = navigationService;
     }
     if (dialogService != null)
     {
         Dialog = dialogService;
     }
     if (sqLiteHelper != null)
     {
         Database = sqLiteHelper;
     }
 }
예제 #14
0
        public void GetAvgScore(ISQLiteHelper db)
        {
            var scores = db.GetList <Score>(score => score.StudentId == this.Id).ToList();

            float totalScore1 = 0;
            float totalScore2 = 0;

            foreach (var score in scores)
            {
                if (score.Semester == 1)
                {
                    totalScore1 += score.ScoreAverage;
                }
                else
                {
                    totalScore2 += score.ScoreAverage;
                }
            }
            ScoreAvg1 = (float)Math.Round(totalScore1 / (scores.Count / 2), 1);
            ScoreAvg2 = (float)Math.Round(totalScore2 / (scores.Count / 2), 1);
        }
예제 #15
0
 public SearchPageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) :
     base(navigationService, dialogService, sqLiteHelper)
 {
     PageTitle = "Tra cứu";
 }
예제 #16
0
        public StudentDetailPageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) :
            base(navigationService, dialogService, sqLiteHelper)
        {
            //ViewScoreBoardCommand = new DelegateCommand(ViewScoreBoardExecute);

            user = Database.GetUser();

            if (user.Role.Equals(RoleManager.StudentRole))
            {
                GetStudentDetail();
            }

            PageTitle = "Thông tin";

            Instance = this;

            // Commands
            ViewClassInfoCommand  = new DelegateCommand(ViewClassInfoExecute);
            ViewScoreBoardCommand = new DelegateCommand(ViewScoreBoardExecute);
            RemoveStudentCommand  = new DelegateCommand(RemoveStudentExecute);
            EditStudentCommand    = new DelegateCommand(EditStudentExecute);
        }
        public ClassDetailPageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) :
            base(navigationService, dialogService, sqLiteHelper)
        {
            // Commands
            ViewListStudentCommand = new DelegateCommand(ViewListStudentExecute);
            ViewScoreBoardCommand  = new DelegateCommand(ViewScoreBoardExecute);
            AcceptCommand          = new DelegateCommand(AcceptExecute);

            user = Database.GetUser();

            if (user.Role.Equals(RoleManager.TeacherRole))
            {
                GetClassInfo();
            }
        }
예제 #18
0
 public HomePageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) :
     base(navigationService, dialogService, sqLiteHelper)
 {
 }
        public ScoreBoardPageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) : base(navigationService, dialogService, sqLiteHelper)
        {
            PageTitle    = "Bảng điểm";
            SemesterName = "Học kỳ 1";

            user = Database.GetUser();
            if (user.Role.Equals(RoleManager.TeacherRole))
            {
                GetScoreClassBoard();
            }
        }
예제 #20
0
        public AddNewStudentPageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) : base(navigationService, dialogService, sqLiteHelper)
        {
            // Set values
            PageTitle  = "Tiếp nhận học sinh";
            DoB        = new DateTime(2001, 1, 1);
            ButtonName = "Tiếp theo";

            // Commands
            ContinueCommand = new DelegateCommand(ContinueExecute);
        }
예제 #21
0
        public InputScorePageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) :
            base(navigationService, dialogService, sqLiteHelper)
        {
            PageTitle = "Nhập bảng điểm môn";

            //Get list class name
            ClassNames   = new ObservableCollection <string>();
            StudentNames = new ObservableCollection <string>();

            Students = new ObservableCollection <Student>();
            GetListPicker();

            SaveCommand = new DelegateCommand(SaveExecute);
        }
예제 #22
0
 public MockData(ISQLiteHelper sqLite)
 {
     _db = sqLite;
 }
 public ReportHomePageViewModel(INavigationService navigationService, IPageDialogService dialogService,
                                ISQLiteHelper sqLiteHelper)
     : base(navigationService, dialogService, sqLiteHelper)
 {
     PageTitle = "Báo cáo tổng kết";
 }
 public ChooseClassPageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) :
     base(navigationService, dialogService, sqLiteHelper)
 {
     // Set values
     PageTitle = "Chọn lớp";
     LoadClass();
 }
예제 #25
0
        public ClassesPageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) :
            base(navigationService, dialogService, sqLiteHelper)
        {
            SearchToolbarItemsCommand = new DelegateCommand(SearchToolbarItemsExecute);
            SearchIconCommand         = new DelegateCommand(SearchIconExecute);
            FilterIconCommand         = new DelegateCommand(FilterIconExecute);

            var classes = sqLiteHelper.GetList <Class>(c => c.Id > 0);

            foreach (var c in classes)
            {
                c.CountStudent(sqLiteHelper);
            }
            ListClass = Classes = new ObservableCollection <Class>(classes);

            ShowSearchBox = false;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DivingLogSQLiteRepositroy"/> class.
 /// </summary>
 /// <param name="sQLiteHelper">The s q lite helper.</param>
 public DivingLogSQLiteRepositroy(ISQLiteHelper sQLiteHelper)
 {
     _sQLiteHelper = sQLiteHelper;
 }
예제 #27
0
 public void Logout(ISQLiteHelper db)
 {
     db.DeleteAll <User>();
 }
예제 #28
0
        private void InitDatabase()
        {
            var connectionService = DependencyService.Get <IDatabaseConnection>();

            _sqLiteHelper = new SQLiteHelper(connectionService);
        }
예제 #29
0
 public void Show(ISQLiteHelper database)
 {
     _db = database;
     LabelWrong.IsVisible = false;
     App.Current.MainPage.Navigation.PushPopupAsync(this);
 }
예제 #30
0
        public StudentsPageViewModel(INavigationService navigationService = null, IPageDialogService dialogService = null, ISQLiteHelper sqLiteHelper = null) :
            base(navigationService, dialogService, sqLiteHelper)
        {
            Title = "Danh sách";

            user = Database.GetUser();

            if (user.Role.Equals(RoleManager.StudentRole))
            {
                GetStudentsInClass();
            }
            else if (!user.Role.Equals(RoleManager.TeacherRole))
            {
                SetListStudentData();
            }

            // Commands
            SearchToolbarItemsCommand = new DelegateCommand(SearchToolbarItemsExecute);
            SearchIconCommand         = new DelegateCommand(SearchIconExecute);
            FilterIconCommand         = new DelegateCommand(FilterIconExecute);
        }