Ejemplo n.º 1
0
        private void newBand(object sender, RoutedEventArgs e)
        {
            Band band = new Band();

            band.name         = newBandName.Text;
            band.city         = newBandCity.Text.Any() ? newBandCity.Text : "Nevyplneno";
            band.description  = new TextRange(bandDescription.Document.ContentStart, bandDescription.Document.ContentEnd).Text;
            band.facebook     = facebook.Text.Contains("facebook".ToUpper()) ? facebook.Text : "Kapela nemá Facebook";
            band.banzone      = bandzone.Text.Contains("banzone".ToUpper()) ? bandzone.Text : "Kapela nemá Bandzone";
            band.website      = website.Text.Contains("www.") ? website.Text : "Kapela nemá webovou stránku";
            band.style        = newBandStyle.Text.Any() ? newBandStyle.Text : "Nedefinován styl!";
            band.personalNote = new TextRange(personalNote.Document.ContentStart, personalNote.Document.ContentEnd).Text;

            if (band.checkIfBandExists(band))
            {
                MessageBox.Show("Kapela s tímto názvem již existuje!");
            }
            else
            {
                band.saveBandToDb(band);
                if (contactName.Text.Any() && contactName.Text != "Jmeno")
                {
                    BandContact contact = new BandContact();
                    contact.fName    = contactName.Text;
                    contact.lName    = ContactSurname.Text;
                    contact.function = contactFunction.Text;
                    contact.phone    = contactPhone.Text;
                    contact.email    = contactEmail.Text;
                    contact.bandId   = band._id;

                    contact.saveContactToDb(contact);
                }
                this.NavigationService.Navigate(new BandsAdmin());
            }
        }
Ejemplo n.º 2
0
        private void deleteContactButtonClick(object sender, RoutedEventArgs e)
        {
            BandContact contactToDelete = (BandContact)contactListView.SelectedItem;

            if (contactToDelete != null)
            {
                try
                {
                    using (var db = new LiteDatabase(LiteDbConnection.getDbName()))
                    {
                        var contacts = db.GetCollection <BandContact>("BandContacts");
                        MessageBoxResult myResult;
                        myResult = MessageBox.Show("Opravdu chcete smazat kontakt " + contactToDelete.fName + " " +
                                                   contactToDelete.lName + " ?", "Delete Confirmation", MessageBoxButton.OKCancel);
                        if (myResult == MessageBoxResult.OK)
                        {
                            contacts.Delete(contactToDelete._id);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Není vybrán kontakt!");
            }

            this.NavigationService.Navigate(new BandDetail(bandDetail));
        }
Ejemplo n.º 3
0
        private void newContact(object sender, RoutedEventArgs e)
        {
            BandContact newContact = new BandContact();

            newContact.fName    = contactName.Text;
            newContact.lName    = ContactSurname.Text;
            newContact.function = contactFunction.Text;
            newContact.phone    = contactPhone.Text;
            newContact.email    = contactEmail.Text;
            newContact.bandId   = contactBandId;

            newContact.saveContactToDb(newContact);
            this.NavigationService.Navigate(new BandDetail(band));
        }
Ejemplo n.º 4
0
 public void saveContactToDb(BandContact contact)
 {
     try
     {
         using (var db = new LiteDatabase(@"EvaDB.db"))
         {
             var contacts = db.GetCollection <BandContact>("BandContacts");
             contacts.Upsert(contact);
         }
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show(ex.Message);
     }
 }