Esempio n. 1
0
        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();
                }
            }
        }
Esempio n. 2
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();
                }
            }
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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();
                }
            }
        }
Esempio n. 5
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;
        }