Exemple #1
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     using (var db = new PartyContext())
     {
         Parties.ItemsSource = db.parties.ToList();
     }
 }
Exemple #2
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());
            }
        }
        private void Add_Tool_Click(object sender, RoutedEventArgs e)
        {
            int number = Convert.ToInt32(Number_quantity.Text);

            if (number > 0)
            {
                using (var db = new PartyContext())
                {
                    List <String> currentTools = new List <String>(this.result.ToolIDs);

                    if (currentTools != null)
                    {
                        currentTools.AddRange(Enumerable.Repeat(this.currentTool.ToolId.ToString(), number));
                    }
                    this.result.ToolIDs = currentTools;
                    Debug.WriteLine(currentTools.Count());
                    listTools.ItemsSource = null;
                    listTools.ItemsSource = DatabaseHelper.GetToolsByID(this.result.ToolIDs);
                }
            }
            Minus.IsEnabled      = false;
            Plus.IsEnabled       = false;
            Add_Tool.IsEnabled   = false;
            Number_quantity.Text = "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();
                }
            }
        }
        private async void  Delete_Click(object sender, RoutedEventArgs e)
        {
            MessageDialog showDialog = new MessageDialog("Voulez vous vraiment supprimer cet employé?");

            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())
                {
                    DatabaseHelper.DeleteEmployeeEntry(db.employees.Find(personID));
                }
                this.Frame.GoBack();
            }
        }
        private void Tool_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = ((ComboBox)sender).SelectedIndex;

            if (index != 0)
            {
                using (var db = new PartyContext()) {
                    if (index == 1)
                    {
                        listTools2.ItemsSource = null;
                        listTools2.ItemsSource = db.products.ToList();
                    }
                    else if (index == 2)
                    {
                        listTools2.ItemsSource = null;
                        listTools2.ItemsSource = db.machines.ToList();
                    }
                    else
                    {
                        listTools2.ItemsSource = null;
                        listTools2.ItemsSource = db.structures.ToList();
                    }
                }
            }
        }
Exemple #7
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();
        }
Exemple #8
0
 /// <summary>
 /// Initialise l'objet d'application de singleton.  Il s'agit de la première ligne du code créé
 /// à être exécutée. Elle correspond donc à l'équivalent logique de main() ou WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     using (var db = new PartyContext())
     {
         db.Database.Migrate();
         DatabaseHelper.CheckParties();
     }
 }
Exemple #9
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();
                }
            }
        }
Exemple #10
0
        private async void Add_StandList(object sender, RoutedEventArgs e)
        {
            MyCustomStands dial = new MyCustomStands();

            if (dial.Initialize(null, this.party))
            {
                Utilities.ShowDial("Veuillez spécifier les dates et accepter l'event avant de procéder au stand");
            }
            else
            {
                await dial.ShowAsync();

                if (dial.result != null)
                {
                    while (dial.displayEmployees)
                    {
                        using (var db = new PartyContext())
                        {
                            List <Person> employees = db.employees.ToList <Person>();
                            MyCustomContentDialogEmployee dialEmployee = new MyCustomContentDialogEmployee();
                            dialEmployee.Initialize(employees);
                            await dialEmployee.ShowAsync();

                            HashSet <String> toBeAdded        = new HashSet <String>(dialEmployee.Result.Select(u => u.PersonId.ToString()).ToList());
                            HashSet <String> currentEmployees = new HashSet <String>(dial.result.EmployeesIDs);

                            if (currentEmployees != null)
                            {
                                toBeAdded.UnionWith(currentEmployees);
                            }
                            dial.result.EmployeesIDs = toBeAdded.ToList();
                            dial.BlitEmployees();
                            await dial.ShowAsync();
                        }
                    }
                    HashSet <String> currentStands = new HashSet <String>(this.party.StandsIDs);
                    currentStands.Add(dial.result.StandId.ToString());
                    this.party.StandsIDs = currentStands.ToList();

                    listStands.ItemsSource = null;
                    Debug.WriteLine("sss " + dial.result.StandId.ToString());
                    listStands.ItemsSource = DatabaseHelper.GetStandsByID(currentStands.ToList());
                }
            }
        }
Exemple #11
0
        private async void Item_Stand_Click(object sender, ItemClickEventArgs e)
        {
            Stand item = (Stand)e.ClickedItem;

            if (item != null)
            {
                MyCustomStands dial = new MyCustomStands();
                if (dial.Initialize(item, this.party))
                {
                    Utilities.ShowDial("Veuillez spécifier les dates avant de procéder au stand");
                }
                else
                {
                    await dial.ShowAsync();

                    while (dial.displayEmployees)
                    {
                        using (var db = new PartyContext())
                        {
                            List <Person> employees = db.employees.ToList <Person>();
                            MyCustomContentDialogEmployee dialEmployee = new MyCustomContentDialogEmployee();
                            dialEmployee.Initialize(employees);
                            await dialEmployee.ShowAsync();

                            HashSet <String> toBeAdded        = new HashSet <String>(dialEmployee.Result.Select(u => u.PersonId.ToString()).ToList());
                            HashSet <String> currentEmployees = new HashSet <String>(dial.result.EmployeesIDs);

                            if (currentEmployees != null)
                            {
                                toBeAdded.UnionWith(currentEmployees);
                            }
                            dial.result.EmployeesIDs = toBeAdded.ToList();
                            dial.BlitEmployees();
                            await dial.ShowAsync();
                        }
                    }
                    listStands.ItemsSource = null;
                    listStands.ItemsSource = DatabaseHelper.GetStandsByID(this.party.StandsIDs);
                }
            }
        }
        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_SkillList(object sender, RoutedEventArgs e)
        {
            using (var db = new PartyContext())
            {
                List <Skill> skills             = db.skills.ToList <Skill>();
                MyCustomContentDialogSkill dial = new MyCustomContentDialogSkill();
                dial.Initialize(skills);
                await dial.ShowAsync();

                HashSet <String> toBeAdded     = new HashSet <String>(dial.Result.Select(u => u.ToolId.ToString()).ToList());
                HashSet <String> currentSkills = new HashSet <String>(this.employee.ToolIDs);

                if (currentSkills != null)
                {
                    toBeAdded.UnionWith(currentSkills);
                }
                this.employee.ToolIDs  = toBeAdded.ToList();
                listSkills.ItemsSource = null;
                listSkills.ItemsSource = DatabaseHelper.GetSkillsByID(toBeAdded.ToList());
            }
        }
Exemple #14
0
 private void Load_lists()
 {
     notTrigger = true;
     using (var db = new PartyContext())
     {
         if (db.products.Count() > 0)
         {
             Products_list.ItemsSource = db.products;
         }
         else
         {
             Products_list.IsEnabled = false;
         }
         if (db.structures.Count() > 0)
         {
             Structures_list.ItemsSource = db.structures;
         }
         else
         {
             Structures_list.IsEnabled = false;
         }
         if (db.skills.Count() > 0)
         {
             Skills_list.ItemsSource = db.skills;
         }
         else
         {
             Skills_list.IsEnabled = false;
         }
         if (db.machines.Count() > 0)
         {
             Machines_list.ItemsSource = db.machines;
         }
         else
         {
             Machines_list.IsEnabled = false;
         }
     }
 }
        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 #16
0
        private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)

        {
            List <Person> filteredList;
            string        text = sender.Text.ToLower();

            using (var db = new PartyContext())
            {
                switch (indexFilter)
                {
                case 0:
                    filteredList = db.employees.Where(t => t.Name.ToLower().Contains(text) || t.Age.ToString().Equals(text) || t.Surname.ToLower().Contains(text) || t.City.ToLower().Contains(text)).ToList();
                    break;

                case 1:
                    filteredList = db.employees.Where(t => t.Name.ToLower().Contains(text) || t.Surname.ToLower().Contains(text)).ToList();

                    break;

                case 2:
                    filteredList = db.employees.Where(t => t.Age.ToString().Equals(text)).ToList();

                    break;

                case 3:
                    filteredList = db.employees.Where(t => t.Adress.ToLower().Contains(text) || t.City.ToLower().Contains(text)).ToList();

                    break;

                default:
                    filteredList = new List <Person>();
                    break;
                }
            }

            MyEmployees.ItemsSource = filteredList;
        }
Exemple #17
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;
        }
Exemple #18
0
        private void Sort_Click(object sender, RoutedEventArgs e)
        {
            MyButton mb = (sender as MyButton);

            mb.State = (mb.State + 1) % 3;
            using (var db = new PartyContext())
            {
                if (mb.State == 0)
                {
                    MyEmployees.ItemsSource = db.employees.ToList();
                }
                else
                {
                    switch (mb.Tag)
                    {
                    case "ID":
                        if (mb.State == 1)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderBy(x => x.PersonId);
                        }
                        else if (mb.State == 2)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderByDescending(x => x.PersonId);
                        }
                        break;

                    case "Name":
                        if (mb.State == 1)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderBy(x => x.Name);
                        }
                        else if (mb.State == 2)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderByDescending(x => x.Name);
                        }
                        break;

                    case "Surname":
                        if (mb.State == 1)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderBy(x => x.Surname);
                        }
                        else if (mb.State == 2)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderByDescending(x => x.Surname);
                        }
                        break;

                    case "Age":
                        if (mb.State == 1)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderBy(x => x.Age);
                        }
                        else if (mb.State == 2)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderByDescending(x => x.Age);
                        }
                        break;

                    case "Phone":
                        if (mb.State == 1)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderBy(x => x.Phone_number1);
                        }
                        else if (mb.State == 2)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderByDescending(x => x.Phone_number1);
                        }
                        break;

                    case "Email":
                        if (mb.State == 1)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderBy(x => x.Email);
                        }
                        else if (mb.State == 2)
                        {
                            MyEmployees.ItemsSource = db.employees.ToList().OrderByDescending(x => x.Email);
                        }
                        break;
                    }
                }
                ResetArrow((string)mb.Tag);
            }
        }
Exemple #19
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 #20
0
        private void Sort_Click(object sender, RoutedEventArgs e)
        {
            MyButton mb = (sender as MyButton);

            mb.State = (mb.State + 1) % 3;
            Debug.WriteLine(mb.State);
            using (var db = new PartyContext())
            {
                if (mb.State == 0)
                {
                    Parties.ItemsSource = db.parties.ToList();
                }
                else
                {
                    switch (mb.Tag)
                    {
                    case "ID":
                        if (mb.State == 1)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderBy(x => x.PartyId);
                        }
                        else if (mb.State == 2)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderByDescending(x => x.PartyId);
                        }
                        break;

                    case "From":
                        if (mb.State == 1)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderBy(x => x.Date);
                        }
                        else if (mb.State == 2)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderByDescending(x => x.Date);
                        }
                        break;

                    case "To":
                        if (mb.State == 1)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderBy(x => x.ToDate);
                        }
                        else if (mb.State == 2)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderByDescending(x => x.ToDate);
                        }
                        break;

                    case "LastWrote":
                        if (mb.State == 1)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderBy(x => x.Lastwrote);
                        }
                        else if (mb.State == 2)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderByDescending(x => x.Lastwrote);
                        }
                        break;

                    case "FirstWrote":
                        if (mb.State == 1)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderBy(x => x.Firstwrote);
                        }
                        else if (mb.State == 2)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderByDescending(x => x.Firstwrote);
                        }
                        break;

                    case "Name":
                        if (mb.State == 1)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderBy(x => x.Name);
                        }
                        else if (mb.State == 2)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderByDescending(x => x.Name);
                        }
                        break;

                    case "City":
                        if (mb.State == 1)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderBy(x => x.City);
                        }
                        else if (mb.State == 2)
                        {
                            Parties.ItemsSource = db.parties.ToList().OrderByDescending(x => x.City);
                        }
                        break;
                    }
                }
                ResetArrow((string)mb.Tag);
            }
        }