Exemple #1
0
        private async void Add_OrgaList(object sender, RoutedEventArgs e)
        {
            Organisateur orga = new Organisateur();
            MyCustomContentDialogOrga dial = new MyCustomContentDialogOrga();
            Grid myGrid = ((Grid)dial.FindName("Grid_Orga"));

            myGrid.DataContext = orga;
            await dial.ShowAsync();

            if (dial.Result == MyResult.Ok)
            {
                using (var db = new PartyContext())
                {
                    db.organisateurs.Add(orga);
                    db.SaveChanges();
                }

                HashSet <String> currentOrga = new HashSet <String>(this.party.OrgaIDs);
                currentOrga.Add(orga.OrganisateurId.ToString());

                this.party.OrgaIDs = currentOrga.ToList();

                listOrga.ItemsSource = null;
                listOrga.ItemsSource = DatabaseHelper.GetOrgasByID(currentOrga.ToList());
            }
        }
Exemple #2
0
        private async System.Threading.Tasks.Task Save_File_LocalAsync()
        {
            List <File>   newList     = new List <File>();
            StorageFolder rootFolder  = ApplicationData.Current.LocalFolder;
            StorageFolder filesFolder = await rootFolder.CreateFolderAsync("Files", CreationCollisionOption.OpenIfExists);


            var           projectFolderName = this.party.Name + "_" + this.party.PartyId;
            StorageFolder projectFolder     = projectFolder = await filesFolder.CreateFolderAsync(projectFolderName, CreationCollisionOption.OpenIfExists);

            using (var db = new PartyContext())
            {
                foreach (StorageFile file in this.FilesToBeAdded)
                {
                    if (file != null)
                    {
                        StorageFile newFile = await file.CopyAsync(projectFolder);

                        File myFile = new File {
                            Name = newFile.Name, Path = newFile.Path
                        };
                        newList.Add(myFile);
                        db.files.Add(myFile);
                    }
                }
                List <File> tmp = DatabaseHelper.GetFilesByID(this.party.FilesIDs);
                if (tmp != null)
                {
                    newList = newList.Concat(tmp).ToList();
                }
                db.SaveChanges();
            }

            this.party.FilesIDs = newList.Select(u => u.FileId.ToString()).ToList();
        }
        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            MessageDialog showDialog = new MessageDialog("Voulez vous vraiment sauvegarder tout les changements?");

            showDialog.Commands.Add(new UICommand("Oui")
            {
                Id = 0
            });
            showDialog.Commands.Add(new UICommand("Non")
            {
                Id = 1
            });
            showDialog.DefaultCommandIndex = 0;
            showDialog.CancelCommandIndex  = 1;
            var result = await showDialog.ShowAsync();

            if ((int)result.Id == 0)
            {
                using (var db = new PartyContext())
                {
                    var partyDb = db.parties.Find(rightParty.PartyId);
                    db.Entry(partyDb).CurrentValues.SetValues(rightParty);
                    foreach (Party tmp in partyArrayLeft)
                    {
                        var partyTmp = db.parties.Find(tmp.PartyId);
                        Debug.WriteLine(partyTmp.PartyId);
                        db.Entry(partyTmp).CurrentValues.SetValues(tmp);
                    }
                    db.SaveChanges();
                }
            }
        }
Exemple #4
0
        private async void Add_click(object sender, RoutedEventArgs e)
        {
            if (!isModified)
            {
                using (var db = new PartyContext())
                {
                    db.parties.Add(this.party);
                    db.SaveChanges();
                }
            }

            await Save_File_LocalAsync();

            using (var db = new PartyContext())
            {
                if (ValidateEntry())
                {
                    if (isModified)
                    {
                        MessageDialog showDialog = new MessageDialog("Voulez vous vraiment modifier ces informations?");
                        showDialog.Commands.Add(new UICommand("Oui")
                        {
                            Id = 0
                        });
                        showDialog.Commands.Add(new UICommand("Non")
                        {
                            Id = 1
                        });
                        showDialog.DefaultCommandIndex = 0;
                        showDialog.CancelCommandIndex  = 1;
                        var result = await showDialog.ShowAsync();

                        if ((int)result.Id == 0)
                        {
                            Debug.WriteLine(this.party.PartyId);
                            var partyDb = db.parties.Find(this.party.PartyId);
                            db.Entry(partyDb).CurrentValues.SetValues(this.party);
                        }
                    }
                    else
                    {
                        var partyDb = db.parties.Find(this.party.PartyId);
                        db.Entry(partyDb).CurrentValues.SetValues(this.party);
                    }

                    db.SaveChanges();
                    this.Frame.GoBack();
                }
            }
        }
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new PartyContext())
            {
                if (isModified)
                {
                    var standDb = db.stands.Find(this.result.StandId);
                    db.Entry(standDb).CurrentValues.SetValues(this.result);
                }
                else
                {
                    Debug.WriteLine("Add stand");
                    db.stands.Add(this.result);
                }
                db.SaveChanges();
                // this.result = db.stands.Find(this.result.StandId);
            }
            Debug.WriteLine("ss: " + this.result.StandId.ToString());

            dialog.Hide();
        }
        private async void Add_click(object sender, RoutedEventArgs e)
        {
            using (var db = new PartyContext())
            {
                DateTimeOffset sourceTime = employeeBirthDate.Date ?? new DateTimeOffset();
                if (ValidateEntry())
                {
                    //var employee = new Person { Name = employeeName.Text, Surname = employeeSurName.Text, BirthDate = sourceTime.DateTime, Email = employeeEmail.Text, Adress = employeeAdress.Text, ZIP= employeeZip.Text, City =  employeeCity.Text, IBAN = employeeIBAN.Text, AVS = employeeAVS.Text, Phone_number1 = employeePhone1.Text, Phone_number2 = employeePhone2.Text };
                    if (!isModifiedPage)
                    {
                        db.employees.Add(employee);
                    }
                    else
                    {
                        MessageDialog showDialog = new MessageDialog("Voulez vous vraiment modifier ces informations?");
                        showDialog.Commands.Add(new UICommand("Oui")
                        {
                            Id = 0
                        });
                        showDialog.Commands.Add(new UICommand("Non")
                        {
                            Id = 1
                        });
                        showDialog.DefaultCommandIndex = 0;
                        showDialog.CancelCommandIndex  = 1;
                        var result = await showDialog.ShowAsync();

                        if ((int)result.Id == 0)
                        {
                            employee.PersonId = personID;
                            var employeeDb = db.employees.Find(employee.PersonId);
                            db.Entry(employeeDb).CurrentValues.SetValues(employee);
                        }
                    }
                    db.SaveChanges();
                    this.Frame.GoBack();
                }
            }
        }
Exemple #7
0
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            Button tmp = (Button)sender;
            MyCustomContentDialog dialog = new MyCustomContentDialog();

            dialog.Title = "Ajouter";
            ((Button)dialog.FindName("Delete")).Visibility = Visibility.Collapsed;
            Grid myGrid = ((Grid)dialog.FindName("Grid_Dial"));

            if ((string)tmp.Tag == "0" || (string)tmp.Tag == "1")
            {
                myGrid.RowDefinitions[1].Height = new GridLength(0);
            }
            Tool toolToAdd = null;

            switch (tmp.Tag)
            {
            case "0":
                toolToAdd          = new Skill();
                myGrid.DataContext = toolToAdd;
                break;

            case "1":
                toolToAdd          = new Product();
                myGrid.DataContext = toolToAdd;
                break;

            case "2":
                toolToAdd          = new Structure();
                myGrid.DataContext = toolToAdd;
                break;

            case "3":
                toolToAdd          = new Machine();
                myGrid.DataContext = toolToAdd;

                break;
            }


            await dialog.ShowAsync();

            if (dialog.Result == MyResult.Ok)
            {
                //save
                using (var db = new PartyContext())
                {
                    switch (tmp.Tag)
                    {
                    case "0":
                        //Add to skills
                        db.skills.Add((Skill)toolToAdd);
                        break;

                    case "1":
                        //Add to produtcst
                        db.products.Add((Product)toolToAdd);
                        break;

                    case "2":
                        //Add to structures
                        db.structures.Add((Structure)toolToAdd);
                        break;

                    case "3":
                        //Add to machine
                        db.machines.Add((Machine)toolToAdd);

                        break;
                    }
                    db.SaveChanges();
                }
                Load_lists();
            }
        }
Exemple #8
0
        private async void List_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!notTrigger)
            {
                ComboBox tmp = (ComboBox)sender;


                Tool toolToAdd = (Tool)tmp.SelectedItem;
                MyCustomContentDialog dialog = new MyCustomContentDialog();
                dialog.Title = "Modifier";

                Grid myGrid = ((Grid)dialog.FindName("Grid_Dial"));
                if ((string)tmp.Tag == "0" || (string)tmp.Tag == "1")
                {
                    myGrid.RowDefinitions[1].Height = new GridLength(0);
                }
                myGrid.DataContext = toolToAdd;
                await dialog.ShowAsync();

                if (dialog.Result == MyResult.Ok)
                {
                    //save
                    using (var db = new PartyContext())
                    {
                        switch (tmp.Tag)
                        {
                        case "0":
                            //Add to skills
                            var skillDb = db.skills.Find(toolToAdd.ToolId);
                            db.Entry(skillDb).CurrentValues.SetValues(toolToAdd);
                            break;

                        case "1":
                            //Add to produtcst
                            var productDb = db.products.Find(toolToAdd.ToolId);
                            db.Entry(productDb).CurrentValues.SetValues(toolToAdd);
                            break;

                        case "2":
                            //Add to structures
                            var structureDb = db.structures.Find(toolToAdd.ToolId);
                            db.Entry(structureDb).CurrentValues.SetValues(toolToAdd);
                            break;

                        case "3":
                            //Add to machine
                            var machineDb = db.machines.Find(toolToAdd.ToolId);
                            db.Entry(machineDb).CurrentValues.SetValues(toolToAdd);

                            break;
                        }
                        db.SaveChanges();
                    }
                }
                else if (dialog.Result == MyResult.Delete)
                {
                    MessageDialog showDialog = new MessageDialog("Voulez vous vraiment supprimer cette entrée?");
                    showDialog.Commands.Add(new UICommand("Oui")
                    {
                        Id = 0
                    });
                    showDialog.Commands.Add(new UICommand("Non")
                    {
                        Id = 1
                    });
                    showDialog.DefaultCommandIndex = 0;
                    showDialog.CancelCommandIndex  = 1;
                    var result = await showDialog.ShowAsync();

                    if ((int)result.Id == 0)
                    {
                        using (var db = new PartyContext())
                        {
                            switch (tmp.Tag)
                            {
                            case "0":
                                //Add to skills
                                DatabaseHelper.DeleteToolEntry(db.skills.Find(toolToAdd.ToolId));
                                break;

                            case "1":
                                //Add to produtcst
                                DatabaseHelper.DeleteToolEntry(db.products.Find(toolToAdd.ToolId));
                                break;

                            case "2":
                                //Add to structures
                                DatabaseHelper.DeleteToolEntry(db.structures.Find(toolToAdd.ToolId));
                                break;

                            case "3":
                                //Add to machine
                                DatabaseHelper.DeleteToolEntry(db.machines.Find(toolToAdd.ToolId));

                                break;
                            }
                            db.SaveChanges();
                        }
                    }
                }
                dialog.Hide();
                Load_lists();
            }
            notTrigger = false;
        }