Esempio n. 1
0
        public ActionResult Save()
        {
            Activity model = Session["Activity"] as Activity;

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect(Path.Combine(Server.MapPath("~").ToString(), "bdd.bin")))
            {
                if (bddAccess.Information != null && bddAccess.Information != "")
                {
                    ViewBag.Erreur = bddAccess.Information;

                    return(View("Error"));
                }

                bddAccess.SaveActivities(model);
            }
            else
            {
                ViewBag.Error = bddAccess.Information;

                return(View("Error"));
            }

            return(View("Work", model));
        }
        public OpenBDD()
        {
            InitializeComponent();

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect())
            {
                activities = bddAccess.GetActivities(new Teacher()
                {
                    FirstName = "Vincent", LastName = "RAPIN"
                });

                if (!string.IsNullOrEmpty(bddAccess.Information))
                {
                    MessageBox.Show(bddAccess.Information, "Studio des Langues", MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
                    return;
                }

                foreach (Activity activite in activities)
                {
                    ActivitesListBox.Items.Add(activite.ActivityName);
                }
            }
            else
            {
                MessageBox.Show(bddAccess.Information, "Studio des Langues", MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
            }
        }
Esempio n. 3
0
        public MainWindow(string activityInformations, ref Teacher teacher) : this()
        {
            activity = ActivityPathParser.Parser(activityInformations);

            this.teacher = teacher;

            if (activity.IDActivity != -2)
            {
                BDDAccess bddAccess = new BDDAccess();

                if (bddAccess.Connect())
                {
                    activity = bddAccess.GetActivity(activity.IDActivity);

                    activity.ProvidedWords = activity.ProvidedWords.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

                    TexteTextBox.DataContext = activity;

                    ProvidedWordsListBox.ItemsSource = activity.ProvidedWords;

                    if (!string.IsNullOrEmpty(bddAccess.Information))
                    {
                        MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
                    }
                }
            }
        }
Esempio n. 4
0
        public OpenBDDWindow(Teacher teacher)
        {
            InitializeComponent();

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect())
            {
                activities = bddAccess.GetActivities(teacher);

                if (!string.IsNullOrEmpty(bddAccess.Information))
                {
                    MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
                    return;
                }

                foreach (Activity activite in activities)
                {
                    ActivitesListBox.Items.Add(activite.ActivityName);
                }
            }
            else
            {
                MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
            }
        }
        public ActivitiesWindow(Teacher teacher)
        {
            InitializeComponent();

            this.teacher = teacher;

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect())
            {
                activities = bddAccess.GetActivities(teacher);

                ActivitiesListView.ItemsSource = activities;

                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(ActivitiesListView.ItemsSource);

                view.Filter = ActivityFilter;
            }
            else
            {
                MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);

                isClosed = true;

                Close();
            }
        }
Esempio n. 6
0
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            activity.TeacherName = TeacherNameTextBox.Text;

            if (string.IsNullOrEmpty(ActivityNameTextBox.Text))
            {
                MessageBox.Show("Entrer un nom pour l'activité avant de la sauvegarder.", new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
                return;
            }
            else
            {
                activity.ActivityName = ActivityNameTextBox.Text;
            }

            activity.Classes.Clear();

            int compteur = 0;

            foreach (CheckBox item in ClassesListBox.Items)
            {
                if ((bool)item.IsChecked)
                {
                    activity.Classes.Add(new Class()
                    {
                        IDClass = classes[compteur].IDClass, ClassName = classes[compteur].ClassName
                    });
                }

                compteur++;
            }

            if (activity.Classes.Count <= 0)
            {
                MessageBox.Show("Selectionner au minimum une classe pour pouvoir sauvegarder l'activité.", new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
                return;
            }

            activity.ActivityVisibility = (bool)VisibilityCheckBox.IsChecked;

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect())
            {
                bddAccess.SaveActivities(activity);

                if (!string.IsNullOrEmpty(bddAccess.Information))
                {
                    MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
                    return;
                }
            }
            else
            {
                MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
                return;
            }
        }
Esempio n. 7
0
        public ActionResult Index(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var result = CheckCredential(model);

            switch (result)
            {
            case SignInStatus.Success:
                BDDAccess bddAccess = new BDDAccess();

                if (bddAccess.Connect(Path.Combine(Server.MapPath("~"), "bdd.bin")))
                {
                    if (bddAccess.GetIdEtudiant((Session["User"] as User).FirstName, (Session["User"] as User).LastName) == -1)
                    {
                        bddAccess.CreateStudent((Session["User"] as User).FirstName, (Session["User"] as User).LastName, Student.GetClass((Session["User"] as User).Groups[0]));
                    }
                }
                else
                {
                    ViewBag.Error = bddAccess.Information;

                    return(View("Error"));
                }

                if (Url.IsLocalUrl(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("Index", "Activity"));
                }

            case SignInStatus.ChangePasswordFirstUse:
                return(RedirectToAction("ChangePassword", "Manage", new { tips = "firstUse" }));

            case SignInStatus.AdminAccount:
                return(RedirectToAction("Index", "Administration"));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Tentative de connexion non valide.");
                return(View(model));
            }
        }
        private void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect())
            {
                activities = bddAccess.GetActivities(teacher);

                ActivitiesListView.ItemsSource = activities;

                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(ActivitiesListView.ItemsSource);

                view.Filter = ActivityFilter;
            }
        }
Esempio n. 9
0
        public ActionResult Work(int id, string tag)
        {
            Activity model = new Activity();

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect(Path.Combine(Server.MapPath("~").ToString(), "bdd.bin")))
            {
                if (bddAccess.Information != null && bddAccess.Information != "")
                {
                    ViewBag.Erreur = bddAccess.Information;

                    return(View("Error"));
                }

                Student student = new Student()
                {
                    FirstName = (Session["User"] as User).FirstName, LastName = (Session["User"] as User).LastName, Class = new Class()
                    {
                        ClassName = Student.GetClass((Session["User"] as User).Groups[0])
                    }
                };

                if (tag == "saved")
                {
                    model = bddAccess.GetSavedActivity(id, student);
                }
                else
                {
                    model = bddAccess.GetActivity(id);
                }

                model.GetTextToDisplay("");

                model.CountWords();

                Session["Activity"] = model;
            }
            else
            {
                ViewBag.Error = bddAccess.Information;

                return(View("Error"));
            }

            return(View(model));
        }
Esempio n. 10
0
        public SaveBDDWindow(Activity activity, Teacher teacher)
        {
            InitializeComponent();

            this.activity = activity;

            classes = new List <Class>();

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect())
            {
                classes = bddAccess.GetClasses();

                TeacherNameTextBox.Text = teacher.FirstName + " " + teacher.LastName;

                foreach (var classe in classes)
                {
                    ClassesListBox.Items.Add(new CheckBox()
                    {
                        Content = classe.ClassName
                    });
                }

                ActivityNameTextBox.Text = activity.ActivityName;

                VisibilityCheckBox.IsChecked = activity.ActivityVisibility;

                foreach (var classe in activity.Classes)
                {
                    foreach (CheckBox listBoxItem in ClassesListBox.Items)
                    {
                        if (listBoxItem.Content.ToString().Equals(classe.ClassName, StringComparison.CurrentCultureIgnoreCase))
                        {
                            listBoxItem.IsChecked = true;
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);

                Close();
            }
        }
        private void DeleteCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            List <Activity> deletedActivities = null;

            if (selectedActivity != null)
            {
                deletedActivities = new List <Activity> {
                    selectedActivity
                };

                BDDAccess bddAccess = new BDDAccess();

                if (bddAccess.Connect())
                {
                    bddAccess.DeleteActivities(deletedActivities);
                }

                if (!string.IsNullOrEmpty(bddAccess.Information))
                {
                    MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
                }
            }
            else if (ActivitiesListView.SelectedIndex != -1)
            {
                deletedActivities = new List <Activity>();

                foreach (Activity activity in ActivitiesListView.SelectedItems)
                {
                    deletedActivities.Add(activity);
                }

                BDDAccess bddAccess = new BDDAccess();

                if (bddAccess.Connect())
                {
                    bddAccess.DeleteActivities(deletedActivities);
                }

                if (!string.IsNullOrEmpty(bddAccess.Information))
                {
                    MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
                }
            }

            selectedActivity = null;
        }
Esempio n. 12
0
        public ActionResult SavedActivities()
        {
            BDDAccess bddAccess = new BDDAccess();

            List <Activity> activities = new List <Activity>();

            if (bddAccess.Connect(Path.Combine(Server.MapPath("~").ToString(), "bdd.bin")))
            {
                if (bddAccess.Information != null && bddAccess.Information != "")
                {
                    ViewBag.Erreur = bddAccess.Information;

                    return(View("Error"));
                }

                if (Session["User"] == null)
                {
                    Users users = Users.Load(Path.Combine(Server.MapPath("~"), "credential", User.Identity.GetUserName() + ".credential"));

                    Session["User"] = users[0];
                }

                Student student = new Student()
                {
                    FirstName = (Session["User"] as User).FirstName, LastName = (Session["User"] as User).LastName, Class = new Class()
                    {
                        ClassName = Student.GetClass((Session["User"] as User).Groups[0])
                    }
                };

                activities = bddAccess.GetSavedActivities(student, ActivitiesVisibility.Visible);
            }
            else
            {
                ViewBag.Error = bddAccess.Information;

                return(View("Error"));
            }

            return(View(activities));
        }
Esempio n. 13
0
        public ActivityResultsWindow(Activity activity)
        {
            InitializeComponent();

            Title = Title += activity.ActivityName;

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect())
            {
                activityResults = bddAccess.GetStudentResults(activity);

                ResultsListView.ItemsSource = activityResults;

                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(ResultsListView.ItemsSource);
            }

            if (!string.IsNullOrEmpty(bddAccess.Information))
            {
                MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
            }
        }
Esempio n. 14
0
        private void OpenCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (!Ldap.IsAuthificated)
            {
                new AuthentificationWindow(ref teacher).ShowDialog(this);
            }

            if (Ldap.IsAuthificated)
            {
                OpenBDDWindow openBDD = new OpenBDDWindow(teacher);
                openBDD.ShowDialog(this);

                if (openBDD.ActivityInformations != "" && openBDD.ActivityInformations != null)
                {
                    activity = ActivityPathParser.Parser(openBDD.ActivityInformations);

                    if (activity.IDActivity != -2)
                    {
                        BDDAccess bddAccess = new BDDAccess();

                        if (bddAccess.Connect())
                        {
                            activity = bddAccess.GetActivity(activity.IDActivity);

                            activity.ProvidedWords = activity.ProvidedWords.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();

                            TexteTextBox.DataContext = activity;

                            ProvidedWordsListBox.ItemsSource = activity.ProvidedWords;

                            if (!string.IsNullOrEmpty(bddAccess.Information))
                            {
                                MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 15
0
        public ActionResult Work(string motAChercher)
        {
            Activity model = Session["Activity"] as Activity;

            BDDAccess bddAccess = new BDDAccess();

            if (bddAccess.Connect(Path.Combine(Server.MapPath("~").ToString(), "bdd.bin")))
            {
                if (!string.IsNullOrEmpty(motAChercher) && motAChercher != null)
                {
                    model.CheckWordPresence(motAChercher);
                }

                Session["Activity"] = model;

                return(View(model));
            }
            else
            {
                ViewBag.Error = bddAccess.Information;

                return(View("Error"));
            }
        }